GtkWindow

Name

GtkWindow -- 

Synopsis


#include <gtk/gtk.h>


struct      GtkWindow;
GtkWidget*  gtk_window_new                  (GtkWindowType type);
void        gtk_window_set_title            (GtkWindow *window,
                                             const gchar *title);
void        gtk_window_set_wmclass          (GtkWindow *window,
                                             const gchar *wmclass_name,
                                             const gchar *wmclass_class);
void        gtk_window_set_policy           (GtkWindow *window,
                                             gint allow_shrink,
                                             gint allow_grow,
                                             gint auto_shrink);
void        gtk_window_add_accel_group      (GtkWindow *window,
                                             GtkAccelGroup *accel_group);
void        gtk_window_remove_accel_group   (GtkWindow *window,
                                             GtkAccelGroup *accel_group);
#define     gtk_window_position
gboolean    gtk_window_activate_focus       (GtkWindow *window);
gboolean    gtk_window_activate_default     (GtkWindow *window);
void        gtk_window_set_modal            (GtkWindow *window,
                                             gboolean modal);
void        gtk_window_set_default_size     (GtkWindow *window,
                                             gint width,
                                             gint height);
void        gtk_window_set_geometry_hints   (GtkWindow *window,
                                             GtkWidget *geometry_widget,
                                             GdkGeometry *geometry,
                                             GdkWindowHints geom_mask);
void        gtk_window_set_position         (GtkWindow *window,
                                             GtkWindowPosition position);
void        gtk_window_set_transient_for    (GtkWindow *window,
                                             GtkWindow *parent);
void        gtk_window_set_destroy_with_parent
                                            (GtkWindow *window,
                                             gboolean setting);
GList*      gtk_window_list_toplevels       (void);
void        gtk_window_add_mnemonic         (GtkWindow *window,
                                             guint keyval,
                                             GtkWidget *target);
void        gtk_window_deiconify            (GtkWindow *window);
void        gtk_window_iconify              (GtkWindow *window);
void        gtk_window_maximize             (GtkWindow *window);
void        gtk_window_present              (GtkWindow *window);
void        gtk_window_remove_mnemonic      (GtkWindow *window,
                                             guint keyval,
                                             GtkWidget *target);
void        gtk_window_set_decorated        (GtkWindow *window,
                                             gboolean setting);
void        gtk_window_set_decorations_hint (GtkWindow *window,
                                             GdkWMDecoration decorations);
void        gtk_window_set_frame_dimensions (GtkWindow *window,
                                             gint left,
                                             gint top,
                                             gint right,
                                             gint bottom);
void        gtk_window_set_functions_hint   (GtkWindow *window,
                                             GdkWMFunction functions);
void        gtk_window_set_has_frame        (GtkWindow *window);
void        gtk_window_set_mnemonic_modifier
                                            (GtkWindow *window,
                                             GdkModifierType modifier);
void        gtk_window_set_role             (GtkWindow *window,
                                             const gchar *role);
void        gtk_window_set_type_hint        (GtkWindow *window,
                                             GdkWindowTypeHint hint);
void        gtk_window_stick                (GtkWindow *window);
void        gtk_window_unmaximize           (GtkWindow *window);
void        gtk_window_unstick              (GtkWindow *window);


Object Hierarchy


  GObject
   +----GtkObject
         +----GtkWidget
               +----GtkContainer
                     +----GtkBin
                           +----GtkWindow

Args


  "type"                 GtkWindowType        : Read / Write / Construct Only
  "title"                gchararray           : Read / Write
  "auto-shrink"          gboolean             : Read / Write
  "allow-shrink"         gboolean             : Read / Write
  "allow-grow"           gboolean             : Read / Write
  "modal"                gboolean             : Read / Write
  "window-position"      GtkWindowPosition    : Read / Write
  "default-width"        gint                 : Read / Write
  "default-height"       gint                 : Read / Write
  "destroy-with-parent"  gboolean             : Read / Write

Signal Prototypes


"frame-event"
            gboolean    user_function      (GtkWindow *window,
                                            GdkEvent *event,
                                            gpointer user_data);
"set-focus" void        user_function      (GtkWindow *window,
                                            GtkWidget *widget,
                                            gpointer user_data);

Description

Details

struct GtkWindow

struct GtkWindow;


gtk_window_new ()

GtkWidget*  gtk_window_new                  (GtkWindowType type);

Creates a new GtkWindow, which is a toplevel window that can contain other widgets. Nearly always, the type of the window should be GTK_WINDOW_TOPLEVEL. If you're implementing something like a popup menu from scratch (which is a bad idea, just use GtkMenu), you might use GTK_WINDOW_POPUP. GTK_WINDOW_POPUP is not for dialogs, though in some other toolkits dialogs are called "popups." In GTK+, GTK_WINDOW_POPUP means a pop-up menu or pop-up tooltip. Popup windows are not controlled by the window manager.

If you simply want an undecorated window (no window borders), use gtk_window_set_decorated(), don't use GTK_WINDOW_POPUP.

type : type of window
Returns : a new GtkWindow.


gtk_window_set_title ()

void        gtk_window_set_title            (GtkWindow *window,
                                             const gchar *title);

Sets the title of the GtkWindow. The title of a window will be displayed in its title bar; on the X Window System, the title bar is rendered by the window manager, so exactly how the title appears to users may vary according to a user's exact configuration. The title should help a user distinguish this window from other windows they may have open. A good title might include the application name and current document filename, for example.

window : a GtkWindow
title : title of the window


gtk_window_set_wmclass ()

void        gtk_window_set_wmclass          (GtkWindow *window,
                                             const gchar *wmclass_name,
                                             const gchar *wmclass_class);

Don't use this function. It sets the X Window System "class" and "name" hints for a window. According to the ICCCM, you should always set these to the same value for all windows in an application, and GTK sets them to that value by default, so calling this function is sort of pointless. However, you may want to call gtk_window_set_role() on each window in your application, for the benefit of the session manager. Setting the role allows the window manager to restore window positions when loading a saved session.

window : a GtkWindow
wmclass_name : window name hint
wmclass_class : window class hint


gtk_window_set_policy ()

void        gtk_window_set_policy           (GtkWindow *window,
                                             gint allow_shrink,
                                             gint allow_grow,
                                             gint auto_shrink);

Warning

gtk_window_set_policy is deprecated and should not be used in newly-written code.

Changes how a toplevel window deals with its size request and user resize attempts. There are really only two reasonable ways to call this function:

  1. gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, FALSE) means that the window is user-resizable.

  2. gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE) means that the window's size is program-controlled, and should simply match the current size request of the window's children.

The first policy is the default, that is, by default windows are designed to be resized by users.

The basic ugly truth of this function is that it should be simply:
 void gtk_window_set_user_resizeable(GtkWidget* window, gboolean setting);
So, pretend it is like that, and only use the two policies mentioned above. GTK+ 1.4 may replace gtk_window_set_policy() with a nicer function like gtk_window_set_user_resizeable().

If set to TRUE, the allow_grow parameter allows the user to expand the window beyond the size request of its child widgets. If allow_grow is TRUE, be sure to check that your child widgets work properly as the window is resized.

A toplevel window will always change size to ensure its child widgets receive their requested size. This means that if you add child widgets, the toplevel window will expand to contain them. However, normally the toplevel will not shrink to fit the size request of its children if it's too large; the auto_shrink parameter causes the window to shrink when child widgets have too much space. auto_shrink is normally used with the second of the two window policies mentioned above. That is, set auto_shrink to TRUE if you want the window to have a fixed, always-optimal size determined by your program.

Note that auto_shrink doesn't do anything if allow_shrink and allow_grow are both set to FALSE.

Neither of the two suggested window policies set the allow_shrink paramter to TRUE. If allow_shrink is TRUE, the user can shrink the window so that its children do not receive their full size request; this is basically a bad thing, because most widgets will look wrong if this happens. Furthermore GTK+ has a tendency to re-expand the window if size is recalculated for any reason. The upshot is that allow_shrink should always be set to FALSE.

Sometimes when you think you want to use allow_shrink, the real problem is that some specific child widget is requesting too much space, so the user can't shrink the window sufficiently. Perhaps you are calling gtk_widget_set_usize() on a child widget, and forcing its size request to be too large. Instead of setting the child's usize, consider using gtk_window_set_default_size() so that the child gets a larger allocation than it requests.

window :the window
allow_shrink :whether the user can shrink the window below its size request
allow_grow :whether the user can grow the window larger than its size request
auto_shrink :whether the window automatically snaps back to its size request if it's larger


gtk_window_add_accel_group ()

void        gtk_window_add_accel_group      (GtkWindow *window,
                                             GtkAccelGroup *accel_group);

window : 
accel_group : 


gtk_window_remove_accel_group ()

void        gtk_window_remove_accel_group   (GtkWindow *window,
                                             GtkAccelGroup *accel_group);

window : 
accel_group : 


gtk_window_position

#define	gtk_window_position			gtk_window_set_position


gtk_window_activate_focus ()

gboolean    gtk_window_activate_focus       (GtkWindow *window);

window : 
Returns : 


gtk_window_activate_default ()

gboolean    gtk_window_activate_default     (GtkWindow *window);

window : 
Returns : 


gtk_window_set_modal ()

void        gtk_window_set_modal            (GtkWindow *window,
                                             gboolean modal);

Sets a window modal or non-modal. Modal windows prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use gtk_window_set_transient_for() to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.

window : a GtkWindow
modal : whether the window is modal


gtk_window_set_default_size ()

void        gtk_window_set_default_size     (GtkWindow *window,
                                             gint width,
                                             gint height);

Warning

gtk_window_set_default_size is deprecated and should not be used in newly-written code.

Sets the default size of a window. If the window's "natural" size (its size request) is larger than the default, the default will be ignored. So the default size is a minimum initial size. Unlike gtk_widget_set_usize(), which sets a size request for a widget and thus would keep users from shrinking the window, this function only sets the initial size, just as if the user had resized the window themselves. Users can still shrink the window again as they normally would. Setting a default size of 0 means to use the "natural" default size (the size request of the window).

For more control over a window's initial size and how resizing works, investigate gtk_window_set_geometry_hints().

A useful feature: if you set the "geometry widget" via gtk_window_set_geometry_hints(), the default size specified by gtk_window_set_default_size() will be the default size of that widget, not of the entire window.

window : a GtkWindow
width : width in pixels, 0 to unset, or -1 to leave the width unchanged
height : height in pixels, 0 to unset, or -1 to leave the height unchanged


gtk_window_set_geometry_hints ()

void        gtk_window_set_geometry_hints   (GtkWindow *window,
                                             GtkWidget *geometry_widget,
                                             GdkGeometry *geometry,
                                             GdkWindowHints geom_mask);

This function sets up hints about how a window can be resized by the user. You can set a minimum and maximum size; allowed resize increments (e.g. for xterm, you can only resize by the size of a character); aspect ratios; and more. See the GdkGeometry struct.

window : a GdkWindow
geometry_widget : widget the geometry hints will be applied to
geometry : struct containing geometry information
geom_mask : mask indicating which struct fields should be paid attention to


gtk_window_set_position ()

void        gtk_window_set_position         (GtkWindow *window,
                                             GtkWindowPosition position);

window : 
position : 


gtk_window_set_transient_for ()

void        gtk_window_set_transient_for    (GtkWindow *window,
                                             GtkWindow *parent);

Dialog windows should be set transient for the main application window they were spawned from. This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window. gtk_dialog_new_with_buttons() and other convenience functions in GTK+ will sometimes call gtk_window_set_transient_for() on your behalf.

window : a GtkWindow
parent : parent window


gtk_window_set_destroy_with_parent ()

void        gtk_window_set_destroy_with_parent
                                            (GtkWindow *window,
                                             gboolean setting);

If setting is TRUE, then destroying the transient parent of window will also destroy window itself. This is useful for dialogs that shouldn't persist beyond the lifetime of the main window they're associated with, for example.

window : a GtkWindow
setting : whether to destroy window with its transient parent


gtk_window_list_toplevels ()

GList*      gtk_window_list_toplevels       (void);

Returns a list of all existing toplevel windows. The widgets in the list are not individually referenced. If you want to iterate through the list and perform actions involving callbacks that might destroy the widgets, you MUST call g_list_foreach (result, (GFunc)g_object_ref, NULL) first, and then unref all the widgets afterwards.

Returns : list of toplevel widgets


gtk_window_add_mnemonic ()

void        gtk_window_add_mnemonic         (GtkWindow *window,
                                             guint keyval,
                                             GtkWidget *target);

window : 
keyval : 
target : 


gtk_window_deiconify ()

void        gtk_window_deiconify            (GtkWindow *window);

Asks to deiconify window. Note that you shouldn't assume the window is definitely deiconified afterward, because other entities (e.g. the user or window manager) could iconify it again before your code which assumes deiconification gets to run.

You can track iconification via the "window_state_event" signal on GtkWidget.

window : a GtkWindow


gtk_window_iconify ()

void        gtk_window_iconify              (GtkWindow *window);

Asks to iconify window. Note that you shouldn't assume the window is definitely iconified afterward, because other entities (e.g. the user or window manager) could deiconify it again, or there may not be a window manager in which case iconification isn't possible, etc. But normally the window will end up iconified. Just don't write code that crashes if not.

It's permitted to call this function before showing a window, in which case the window will be iconified before it ever appears onscreen.

You can track iconification via the "window_state_event" signal on GtkWidget.

window : a GtkWindow


gtk_window_maximize ()

void        gtk_window_maximize             (GtkWindow *window);

Asks to maximize window, so that it becomes full-screen. Note that you shouldn't assume the window is definitely maximized afterward, because other entities (e.g. the user or window manager) could unmaximize it again, and not all window managers support maximization. But normally the window will end up maximized. Just don't write code that crashes if not.

It's permitted to call this function before showing a window, in which case the window will be maximized when it appears onscreen initially.

You can track maximization via the "window_state_event" signal on GtkWidget.

window : a GtkWindow


gtk_window_present ()

void        gtk_window_present              (GtkWindow *window);

Presents a window to the user. This may mean raising the window in the stacking order, deiconifying it, moving it to the current desktop, and/or giving it the keyboard focus, possibly dependent on the user's platform, window manager, and preferences.

If window is hidden, this function calls gtk_widget_show() as well.

This function should be used when the user tries to open a window that's already open. Say for example the preferences dialog is currently open, and the user chooses Preferences from the menu a second time; use gtk_window_present() to move the already-open dialog where the user can see it.

window : a GtkWindow


gtk_window_remove_mnemonic ()

void        gtk_window_remove_mnemonic      (GtkWindow *window,
                                             guint keyval,
                                             GtkWidget *target);

window : 
keyval : 
target : 


gtk_window_set_decorated ()

void        gtk_window_set_decorated        (GtkWindow *window,
                                             gboolean setting);

By default, windows are decorated with a title bar, resize controls, etc. Some window managers allow GTK+ to disable these decorations, creating a borderless window. If you set the decorated property to FALSE using this function, GTK+ will do its best to convince the window manager not to decorate the window.

window : a GtkWindow
setting : TRUE to decorate the window


gtk_window_set_decorations_hint ()

void        gtk_window_set_decorations_hint (GtkWindow *window,
                                             GdkWMDecoration decorations);

window : 
decorations : 


gtk_window_set_frame_dimensions ()

void        gtk_window_set_frame_dimensions (GtkWindow *window,
                                             gint left,
                                             gint top,
                                             gint right,
                                             gint bottom);

For windows with frames (see gtk_window_set_has_frame) this function can be used to change the size of the frame border.

window : a GtkWindow that has a frame
left : The width of the left border
top : The height of the top border
right : The width of the right border
bottom : The height of the bottom border


gtk_window_set_functions_hint ()

void        gtk_window_set_functions_hint   (GtkWindow *window,
                                             GdkWMFunction functions);

window : 
functions : 


gtk_window_set_has_frame ()

void        gtk_window_set_has_frame        (GtkWindow *window);

If this function is called on a window before it is realized or showed it will have a "frame" window around widget-window, accessible in window->frame. Using the signal frame_event you can recieve all events targeted at the frame.

This function is used by the linux-fb port to implement managed windows, but it could concievably be used by X-programs that want to do their own window decorations.

window : a GtkWindow


gtk_window_set_mnemonic_modifier ()

void        gtk_window_set_mnemonic_modifier
                                            (GtkWindow *window,
                                             GdkModifierType modifier);

window : 
modifier : 


gtk_window_set_role ()

void        gtk_window_set_role             (GtkWindow *window,
                                             const gchar *role);

In combination with the window title, the window role allows a window manager to identify "the same" window when an application is restarted. So for example you might set the "toolbox" role on your app's toolbox window, so that when the user restarts their session, the window manager can put the toolbox back in the same place.

If a window already has a unique title, you don't need to set the role, since the WM can use the title to identify the window when restoring the session.

window : a GtkWindow
role : unique identifier for the window to be used when restoring a session


gtk_window_set_type_hint ()

void        gtk_window_set_type_hint        (GtkWindow *window,
                                             GdkWindowTypeHint hint);

By setting the type hint for the window, you allow the window manager to decorate and handle the window in a way which is suitable to the function of the window in your application.

This function should be called before the window becomes visible.

gtk_dialog_new_with_buttons() and other convenience functions in GTK+ will sometimes call gtk_window_set_type_hint() on your behalf.

window : a GtkWindow
hint : the window type


gtk_window_stick ()

void        gtk_window_stick                (GtkWindow *window);

Asks to stick window, which means that it will appear on all user desktops. Note that you shouldn't assume the window is definitely stuck afterward, because other entities (e.g. the user or window manager) could unstick it again, and some window managers do not support sticking windows. But normally the window will end up stuck. Just don't write code that crashes if not.

It's permitted to call this function before showing a window.

You can track stickiness via the "window_state_event" signal on GtkWidget.

window : a GtkWindow


gtk_window_unmaximize ()

void        gtk_window_unmaximize           (GtkWindow *window);

Asks to unmaximize window. Note that you shouldn't assume the window is definitely unmaximized afterward, because other entities (e.g. the user or window manager) could maximize it again, and not all window managers honor requests to unmaximize. But normally the window will end up unmaximized. Just don't write code that crashes if not.

You can track maximization via the "window_state_event" signal on GtkWidget.

window : a GtkWindow


gtk_window_unstick ()

void        gtk_window_unstick              (GtkWindow *window);

Asks to unstick window, which means that it will appear on only one of the user's desktops. Note that you shouldn't assume the window is definitely unstuck afterward, because other entities (e.g. the user or window manager) could stick it again. But normally the window will end up stuck. Just don't write code that crashes if not.

You can track stickiness via the "window_state_event" signal on GtkWidget.

window : a GtkWindow

Args

"type" (GtkWindowType : Read / Write / Construct Only)

The type of the window.

"title" (gchararray : Read / Write)

The title of the window.

"auto-shrink" (gboolean : Read / Write)

If the window shrinks automatically when widgets within it shrink.

"allow-shrink" (gboolean : Read / Write)

If the window can be resized to a smaller size by the user.

"allow-grow" (gboolean : Read / Write)

If the window can be resized to a larger size by the user.

"modal" (gboolean : Read / Write)

If the window is modal, i.e. it grabs all GTK+ events.

"window-position" (GtkWindowPosition : Read / Write)

The position of the window.

"default-width" (gint : Read / Write)

"default-height" (gint : Read / Write)

"destroy-with-parent" (gboolean : Read / Write)

Signals

The "frame-event" signal

gboolean    user_function                  (GtkWindow *window,
                                            GdkEvent *event,
                                            gpointer user_data);

window :the object which received the signal.
event : 
user_data :user data set when the signal handler was connected.
Returns : 


The "set-focus" signal

void        user_function                  (GtkWindow *window,
                                            GtkWidget *widget,
                                            gpointer user_data);

window :the object which received the signal.
widget : 
user_data :user data set when the signal handler was connected.