Website hosting and cheap domain registration services


GTK Classes
Prev GtkWindow Next


Widget that provides windows for an application.

Object Hierarchy

`-- GtkWidget
       `-- GtkContainer
              `-- GtkBin
                     `-- GtkWindow


GtkWindow is the widget providing the windows for an application. There are three different types, defined by the programmer during construction - toplevel, dialog or popup.

Toplevel windows contain the standard window decorations minimize, maximize and close. Of these, the first two exhibit the expected default behaviour; this is pre-set within the GDK source, and cannot currently be altered from within PHP-GTK. The close button is not pre-set in same way, in that its emission of the "destroy" signal can be overridden by connecting a function to the window's "delete-event" signal and having that function return true. Note that the main window's "destroy" signal should be connected, directly or otherwise, to a function that will quit the GTK main loop.

A dialog window is not the same thing as a GtkDialog, but is simply a normal toplevel window with the maximize function disabled. Both dialog and popup windows are designed to be used when a message to the user requires a response, and should be used in conjunction with the set_transient_for() and set_modal() methods.

A popup window lacks any window decoration, so needs an alternative means of closure. This could triggered by a timer, an event, or a widget capable of user interaction.

Note that both the window decorations and the associated functions described above are provided by the underlying system's window manager, and could possibly vary or be absent.

A GtkWindow object is derived from GtkBin, and can therefore only have one child widget added to it directly. To add more children it is necessary to make that child a container that can hold mulitple children. See GtkBox.

There is no clean way to maximize a window in php-gtk 1. You only can use the following workaround:

This leads to the problem that the size of task bars are not respected; so you shouldn't do that. For Windows you can use an API call:

$api =& new win32;

//register windows functions
$api->registerfunction("long GetLastError Alias GetError () From kernel32.dll");
$api->registerfunction("long FindWindow (string &ClassName, string &WindowName) From user32.dll");
$api->registerfunction("long ShowWindow (long hWnd, long nCmdShow) From user32.dll");

$window =& new GtkWindow();
$window->set_title('PHP Test');
$class_string = 'gdkWindowToplevel';
$title_string = 'PHP Test';
if(!$sw = $api->FindWindow($class_string,$title_string)){
    $error = $api->getError();
    echo ' Oops FindWindow error: '.$error."\n";

You still have to take care only to call these functions when the php-gtk application is running on Windows.

If you need to set the window cursor, you should have look at GdkWindow.


GtkWindow ([ GtkWindowType type = GTK_WINDOW_TOPLEVEL ]);

-- Creates a new GtkWindow.


  Sets window title.
  Sets window manager class and name.
  Sets window resizing policy. *deprecated in GTK2*
  Associates accelerator group with window.
  Removes associated accelerator group from window.
  Sets screen position of window.
  Activates child that currently has focus.
  Activates child currently set as default.
  Sets window as transient for the given parent.
  Sets default window size.
  Toggles window modality.
  Gives child widget focus.
  Sets child widget as default.


  Emitted when set_focus() is called.

Prev Home Next
GtkWidget::parent Up GtkWindow Constructor



Network sites:

Domain registration - Domain registration and domain name transfer Cheap Domain Registrar - Buy domain name from $5.95/year 


Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to