gtk-sharp Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. Gtk.Bin Toplevel which can contain other widgets. using System; using Gtk; class WindowTester { static void Main () { Application.Init (); Window myWindow = new Window ("This is a window"); myWindow.DeleteEvent += OnDelete; myWindow.SetDefaultSize (200, 200); //Put a button in the Window Button button = new Button ("Click"); myWindow.Add (button); myWindow.ShowAll (); Application.Run (); } static void OnDelete (object o, DeleteEventArgs e) { Application.Quit (); } } Toplevel which can contain other widgets. Constructor A . Creates a new Window object, based on the . Creates a new Window object, wich can be of type TopLevel ( most of the cases ) or PopUp. Take care with the use of PopUp type, since it is not controlled by the window manager. Constructor Pointer to the C object. Internal constructor. This is an internal constructor, and should not be used by user code. Constructor A string. Creates a new TopLevel Window object, with as the title. Creates a new TopLevel Window object, using as the title. You get the same if you use the public Window ( Gtk.WindowType type ) constructor and later set the string Title property. Property GLib.Property("accept-focus") System.Boolean Windows may set a hint asking the desktop environment not to receive the input focus. a to let this window receive input focus Method System.Boolean Activates the default for the . if a is activated. That is unless the current focused has been configured to receive the default (see ) action in which case the case the focused is activated. Method System.Boolean Activates the current focused within the . if a got activated. Method System.Boolean a Activates mnemonics and accelerators for this window. a This is normally called by the default KeyPressEvent handler for toplevel windows, however in some cases it may be useful to call this directly when overriding the standard key handling for a toplevel window. Method System.Void A . Associate with . Such that calling on will activate accelerators in . Method System.Void The mnemonic. The that gets activated by the mnemonic. Adds a mnemonic to this . Property GLib.Property("application") Gtk.Application To be added. To be added. To be added. Property System.Boolean Property used for setting the automatic startup notification. if set to automatically do startup notification. By default, after showing the first for each , GTK# calls . Use this property to disable the automatic startup notification. You might do this if your first is a splash screen, and you want to delay notification until after your real main has been shown, for example. In that example, you would disable startup notification temporarily, show your splash screen, then re-enable it so that showing the main would automatically result in notification. Method System.Void Mouse button that initiated the drag. X position where the user clicked to initiate the drag, in root window coordinates. Y position where the user clicked to initiate the drag. Timestamp from the click event that initiated the drag. Starts moving a . This method is used if an application has window movement grips. When GDK can support it, the window movement will be done using the standard mechanism for the window manager or windowing system. Otherwise, GDK will try to emulate window movement, potentially not all that well, depending on the windowing system. Method System.Void Position of the resize control. Mouse button that initiated the drag. X position where the user clicked to initiate the drag, in root window coordinates. Y position where the user clicked to initiate the drag Timestamp from the click event that initiated the drag. Starts resizing a . This method is used if an application has window resizing controls. When GDK can support it, the resize will be done using the standard mechanism for the window manager or windowing system. Otherwise, GDK will try to emulate window resizing, potentially not all that well, depending on the windowing system. Property GLib.Property("decorated") System.Boolean Sets or obtains whether the has been set to have decorations. if the has been set to have decorations. With this property you control if a will be decorated or not. By default, windows are decorated with a title bar and resize controls. Some window managers allow to disable these decorations, creating a borderless Window. If you set this property as false, Gtk# will try to convince the window manager not to decorate the . Property Gtk.Widget Sets or unsets the default for a about. A . The default is the widget that's activated when the user presses Enter in a dialog (for example). When setting (rather than unsetting) the default it's generally easier to call on the . Before making a default , you must set the flag on the you'd like to make the default. Event GLib.Signal("activate-default") System.EventHandler DefaultActivated event. This event is emited when the keybinding for default widget activation is triggered. Property GLib.Property("default-height") System.Int32 Property used for setting or obtaining the default height of a . The default height of the . This property will allow you to define the default height for your . It only define the default one, so if the is resized, it won't be able to do anything. Property Gdk.Pixbuf Sets an icon to be used as fallback for windows that have not had called on them from a pixbuf. a Property Gdk.Pixbuf[] Sets or obtains the icon list to be used as fallback for windows that haven't had called on them to set up a window-specific icon list. An array of icons list. This method allows you to set up the icon for all windows in your app at once. Property System.String To be added a To be added Property Gdk.Size Sets or obtains the default size of . a A value of -1 for the size indicates that a default size has not been explicitly set for that dimension, so the "natural" size of the will be used. If the 's "natural" size (its size request) is larger than the default, the default will be ignored. More generally, if the default size does not obey the geometry hints for the ( can be used to set these explicitly), the default size will be clamped to the nearest permitted size. Unlike , which sets a size request for a and thus would keep users from shrinking the , this method only sets the initial size, just as if the user had resized the themselves. Users can still shrink the again as they normally would. Setting a default size of -1 means to use the "natural" default size (the size request of the ). For more control over a 's initial size and how resizing works, read . For some uses, is a more appropriate method. changes the current size of the , rather than the size to be used on initial display. always affects the itself, not the geometry widget. The default size of a only affects the first time a is shown; if a is hidden and re-shown, it will remember the size it had prior to hiding, rather than using the default size. Windows can't actually be 0x0 in size, they must be at least 1x1, but passing 0 is OK, resulting in a 1x1 default size. Property Gtk.Widget To be added. To be added. To be added. Property GLib.Property("default-width") System.Int32 Property used for setting or obtaining the default width of a . The default width of the . This property will allow you to define the default width for . It only define the default one, so if the is resized, it won't be able to do anything. Method System.Void Asks to deiconify (i.e. unminimize) the specified . Note that you shouldn't assume the 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 event on GtkWidget. Property GLib.Property("deletable") System.Boolean Indicates if the window has a close button. if , a close button is displayed. Property GLib.Property("destroy-with-parent") System.Boolean Sets or obtains whether the transient parent of will also destroy itself an object of type This is useful for dialogs that shouldn't persist beyond the livefime of the main they're associated with, for example. Property Gtk.Widget Sets a to be the focus widget for the if it is not the current focus widget, and its focusable, or retrieves the current focused within the . The currently focused , or if there is none. To set the focus to a particular in the toplevel, it is usually more convenient to use . Note: when retrieving the current focused is the that would have the focus if the toplevel focused; if the toplevel is not focused then will not be for the . Event GLib.Signal("activate-focus") System.EventHandler FocusActivated event. This event is emited when the keybinding for focused widget activation is triggered. Property GLib.Property("focus-on-map") System.Boolean To be added a To be added Method System.Void Asks to place in the fullscreen state. Note that you shouldn't assume the is definitely full screen afterward, because other entities (e.g. the user or window manager) could unfullscreen it again, and not all window managers honor requests to fullscreen windows. But normally the will end up restored to its normal state. Just don't write code that crashes if not. You can track the fullscreen state via the event on . Method System.Void Location to store the default width, or . Location to store the default height, or . Gets the default size of the . A value of -1 for the width or height indicates that a default size has not been explicitly set for that dimension, so the "natural" size of the will be used. Method System.Void Return location for X coordinate of gravity-determined reference point. Return location for Y coordinate of gravity-determined reference point. This method returns the position you need to pass to to keep in its current position. If you haven't changed the window gravity, its gravity will be . This means that gets the position of the top-left corner of the window manager frame for the . sets the position of this same top-left corner. is not 100% reliable because the X Window System does not specify a way to obtain the geometry of the decorations placed on a by the window manager. Thus GTK# is using a "best guess" that works with most window managers. Moreover, nearly all window managers are historically broken with respect to their handling of window gravity. So moving a to its current position as returned by tends to result in moving the slightly. Window managers are slowly getting better over time. If a has gravity the window manager frame is not relevant, and thus will always produce accurate results. However you can't use static gravity to do things like place a in a corner of the screen, because static gravity ignores the window manager decorations. If you are saving and restoring your application's positions, you should know that it's impossible for applications to do this without getting it somewhat wrong because applications do not have sufficient knowledge of window manager state. The Correct Mechanism is to support the session management protocol (see the "GnomeClient" object in the GNOME libraries for example) and allow the window manager to save your sizes and positions. Method System.Boolean To be added. To be added. To be added. To be added. Method System.Void Return location for width, or . Return location for height, or . Obtains the current size of . If is not onscreen, it returns the size GTK# will suggest to the window manager for the initial window size (but this is not reliably the same as the size the window manager will actually select). The size obtained by is the last size received in a GdkEventConfigure, that is, GTK# uses its locally-stored size, rather than querying the X server for the size. As a result, if you call then immediately call , the size would not have taken effect yet. After the window manager processes the resize request, GTK# receives notification that the size has changed via a configure event, and the size of the gets updated. Note 1: Nearly any use of this method creates a race condition, because the size of the may change between the time that you get the size and the time that you perform some action assuming that size is the current size. To avoid race conditions, connect to on the and adjust your size-dependent state to match the size delivered in the GdkEventConfigure. The following example will print the height and width of a called myWindow to the console. int height =0; int width = 0; myWindow.GetSize(out width , out height); Console.WriteLine("Width: {0}, Height: {1}" , width , height); Property GLib.Property("gravity") Gdk.Gravity Sets or obtains the meaning of coordinates passed to . A window gravity. The default window gravity is which is typically "do what you mean". See and . Property Gtk.WindowGroup Gets the Group the window is associated with. a . Property GLib.GType GType Property a Returns the native GObject type for . Property System.Boolean To be added. To be added. To be added. Property GLib.Property("has-resize-grip") System.Boolean To be added. To be added. To be added. Property GLib.Property("has-toplevel-focus") System.Boolean Whether the input focus is within this . if the has the input focus. Property System.Boolean To be added. To be added. To be added. Property GLib.Property("icon") Gdk.Pixbuf Property used for setting the icon for a . The default icon for . Method System.Void Asks to iconify (i.e. minimize) the specified . Note that you shouldn't assume the 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 will end up iconified. Just do not write code that crashes if not. You can track iconification via the event on . Property Gdk.Pixbuf[] Sets or obtains the list of icons representing a . An array of s. The icon is used when is minimized (also known as iconified). Some window managers or desktop environments may also place it in the window frame, or display it in other contexts. allows you to pass the same icon in several hand-drawn sizes. The list should contain the natural sizes your icon is available in; that is, don't scale the image before passing it to GTK#. Scaling is postponed unitl the last minute, when the desired final size is known, to allow best quality. By passing several sizes, you may improve the final image quality of the icon, by reducing or eliminating automatic image scaling. Recommended sizes to provide: 16x16, 32x32, 48x48 at minimum, and larger images (64x64, 128x128) if you have them). Note that transient windows (those who have been set transient for another using will inherit their icon from their transient parent. So there's no need to explicity set the icon on transient windows. When retrieving the list is copied, but the reference count on each won't be incremented. Property GLib.Property("icon-name") System.String To be added a To be added Property GLib.Property("is-active") System.Boolean Whether the toplevel is the current active . if the is the toplevel. Property System.Boolean Asks to keep window above, so that it stays on top. a Note that you should not assume the window is definitely below afterward, because other entities (e.g. the user or window manager) could not keep it above, and not all window managers support putting windows below. But normally the window will be kept above. Just do not write code that crashes if not. It is permitted to call this function before showing a window, in which case the window will be kept above when it appears onscreen initially. You can track the below state via event. Note that, according to the Extended Window Manager Hints specification, the above state is mainly meant for user preferences and should not be used by applications e.g. for drawing attention to their dialogs. Property System.Boolean Asks to keep window below, so that it stays in bottom. a Note that you should not assume the window is definitely below afterward, because other entities (e.g. the user or window manager) could not keep it below, and not all window managers support putting windows below. But normally the window will be kept below. Just do not write code that crashes if not. It is permitted to call this function before showing a window, in which case the window will be kept below when it appears onscreen initially. You can track the below state via event. Note that, according to the Extended Window Manager Hints specification, the above state is mainly meant for user preferences and should not be used by applications e.g. for drawing attention to their dialogs. Event GLib.Signal("keys-changed") System.EventHandler KeysChanged event. This event is emited when the or mnemonic associated with the is changed. Method Gtk.Window[] Returns a list of all existing toplevel windows. An array of toplevel widgets. The widgets in the list are not individually referenced. Method System.Void Asks to maximize , so that it becomes full-screen. Note that you shouldn't assume the 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 will end up maximized. Just don't write code that crashes if not. You can track maximization via the event on . It's permitted to call this method before showing a , in which case the will be maximized when it appears onscreen initially. Method System.Boolean The mnemonic. The modifiers. Activates the targets associated with the mnemonic. if the activation is done. Property Gdk.ModifierType Sets or obtains the mnemonic modifier for this . The modifier mask used to activate mnemonics on this . Property GLib.Property("mnemonics-visible") System.Boolean To be added. To be added. To be added. Property GLib.Property("modal") System.Boolean Sets or obtains the modal status of . if the is set to be modal and establishes a grab when shown. Modal windows prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent. There are two status: modal () and non-modal (). Method System.Void X coordinate to move to. Y coordinate to move to. Asks the window manager to move to the given position. Window managers are free to ignore this; most window managers ignore requests for initial window positions (instead using a user-defined placement algorithm) and honor requests after the has already been shown. Note: the position is the position of the gravity-determined reference point for the . The gravity determines two things: first, the location of the reference point in root coordinates; and second, which point on the is positioned at the reference point. By default the gravity is so the reference point is simply the x, y supplied to . The top-left corner of the decorations (aka window frame or border) will be placed at , . Therefore, to position a at the top left of the screen, you want to use the default gravity (which is ) and move the to 0,0. To position a at the bottom right corner of the screen, you would set , which means that the reference point is at x + the width and y + the height, and the bottom-right corner of the window border will be placed at that reference point. Method GLib.DefaultSignalHandler(ConnectionMethod="OverrideDefaultActivated", Type=typeof(Gtk.Window)) System.Void Default handler for the event. Override this method in a subclass to provide a default handler for the event. Method GLib.DefaultSignalHandler(ConnectionMethod="OverrideFocusActivated", Type=typeof(Gtk.Window)) System.Void Default handler for the event. Override this method in a subclass to provide a default handler for the event. Method GLib.DefaultSignalHandler(ConnectionMethod="OverrideKeysChanged", Type=typeof(Gtk.Window)) System.Void Default handler for the event. Override this method in a subclass to provide a default handler for the event. Method GLib.DefaultSignalHandler(ConnectionMethod="OverrideSetFocus", Type=typeof(Gtk.Window)) System.Void a Default handler for the event. Override this method in a subclass to provide a default handler for the event. Property GLib.Property("opacity") System.Double Opacity property. Range from 0.0 to 1.0. Only valid when compositing is supported. Method System.Boolean Parses a standard X Window System geometry string. if string was parsed successfully. does work on all GTK# ports including Win32 but is primarily intended for an X environment. If either a size or a position can be extracted from the geometry string, returns and calls and/or to resize/move the . If returns , it will also set the and/or hints indicating to the window manager that the size/position of the was user-specified. This causes most window managers to honor the geometry. Note that for to work as expected, it has to be called when the has its "final" size, i.e. after calling on the contents and on the . Method System.Void Presents a to the user. This may mean raising the 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 is hidden, this method calls as well. This method should be used when the user tries to open a 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 to move the already-open dialog where the user can see it. Method System.Void a timestamp from a user event. Present with a user action timestamp. If you need to Present a window without a timestamp, use . Method System.Boolean a Propagate a key press or release event to the focus widget and up the focus container chain until a widget handles . a This is normally called by the default KeyPressEvent and KeyReleaseEvent handlers for toplevel windows, however in some cases it may be useful to call this directly when overriding the standard key handling for a toplevel window. Method System.Void A . Reverses the effects of . Method System.Void The mnemonic. The that gets activated by the mnemonic. Removes a mnemonic from this . Method System.Void Hides , then reshows it, resetting the default size and position of the . Used by GUI builders only. Property GLib.Property("resizable") System.Boolean Sets or obtains whether a will be resizable by the user or not. if the user can resize the . By default, the are resizable, so you can change the size of them. But if you set this property to false, the user won't be able to change the size of them. Method System.Void Width in pixels to resize the to. Height in pixels to resize the to. Resizes the as if the user had done so, obeying geometry constraints. The default geometry constraint is that windows may not be smaller than their size request; to override this constraint, call to set the 's request to a smaller value. If is called before showing a for the first time, it overrides any default size set with . Windows may not be resized smaller than 1 by 1 pixels. Method System.Boolean To be added. To be added. To be added. Property GLib.Property("resize-grip-visible") System.Boolean To be added. To be added. To be added. Method System.Void To be added. To be added. To be added. To be added. Property GLib.Property("role") System.String Sets or obtains the role of the . The role of the if set, or . The returned is owned by the widget and must not be modified or freed. This property is only useful on X11, not with other GTK# targets. In combination with the title, the role allows a window manager to identify "the same" when an application is restarted. So for example you might set the "toolbox" role on your app's toolbox , so that when the user restarts their session, the session manager can put the toolbox back in the same place. If a already has a unique title, you don't need to set the role, since the WM can use the title to identigy the when restoring the session. Property GLib.Property("screen") Gdk.Screen Sets or obtains the where the is displayed. A . If the is already mapped, it will be unmapped, and then remapped on the new screen. Method System.Void To be added. To be added. To be added. To be added. Method System.Boolean Location of icon file. Sets an icon to be used as fallback for windows that haven't had called on them from a file on disk. if setting the icon succeded. Method System.Void Width in pixels, or -1 to unset the default width. Height in pixels, or -1 to unset the default height. Sets the default size of an object, with the specified width and height arguments. If the 's "natural" size (its size request) is larger than the default, the default will be ignored. More generally, if the default size does not obey the geometry hints for the ( can be used to set these explicitly), the default size will be clamped to the nearest permitted size. Unlike which sets a size request for a and thus would keep users from shrinking the , this method only sets the initial size, just as if the user had resized the themselves. Users can still shrink the again as they normally would. Setting a default size of -1 means to use the "natural" default size (the size request of the ). For more control over a 's initial size and how resizing works, investigate . For some uses, is a more appropriate method. changes the current size of the , rather than the size to be used on initial display. always affects the itself, not the geometry widget. The default size of a only affects the first time a is shown; if a is hidden and re-shown, it will remember the size it had prior to hiding, rather than using the default size. Event GLib.Signal("set-focus") Gtk.SetFocusHandler SetFocus event. This event is emited when the focused widget is set. Method System.Void Widget the geometry hints will be applied to. Struct containing geometry information. Mask indicating which struct fields should be paid attention to. This method sets up hints about how a 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 . Method System.Boolean Location of icon file. Sets the icon for . if setting the icon succeded. This method is equivalent to calling with pixbuf created by loading the image from . Method System.Void A position constraint. Sets the position constraint for a . Is is used for placing the in some area, depending on the constraint. Method System.Void Window name hint. Window class hint. It sets the X Window System "class" and "name" hints for a . (Don't use this method.) 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 method is sort of pointless. However, you may want to call on each 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. Property GLib.Property("skip-pager-hint") System.Boolean Whether the should not be in the pager. if the should not be in the pager. Property GLib.Property("skip-taskbar-hint") System.Boolean Whether the should not be in the taskbar. if the should not be in the taskbar. Property GLib.Property("startup-id") System.String To be added. To be added. To be added. Method System.Void Asks to stick , which means that it will appear on all user desktops. Note that you shouldn't assume the 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 will end up stuck. Just don't write code that crashes if not. You can track stickiness via the event on GtkWidget. It's permitted to call this method before showing a . Property GLib.Property("title") System.String Property used for setting the title. The title of the , or if none has been set explicitely. The returned string is owned by the and must not be modified or freed. This property will allow you to set the title. The title of a will be displayed in its title bar. Since the title bar is rendered by the window managers on X Window System, the way it appears will depend on the user preferences. This title should help the users to distinguish a from others opened. A good title will have the application name an the actual document, for example. Property GLib.Property("transient-for") Gtk.Window Sets or obtains the transient parent window. Dialog windows should be transient for the main they were spawned from, this allows windows managers to e.g. keep the dialog on top of the main , or center the dialog over the main . On Windows(tm), this function will and put the child on top of the parent, much as the would have done in X. Property GLib.Property("type") Gtk.WindowType The type of . The type. See also . Property GLib.Property("type-hint") Gdk.WindowTypeHint Sets or obtains the type hint for . The type hint for . By setting the type hint for the , you allow the window manager to decorate and handle the in a way which is suitable to the function of the in your application. This property should be called before the becomes visible. Method System.Void Asks to toggle off the fullscreen state for . Note that you shouldn't assume the is definitely not full screen afterward, because other entities (e.g. the user or window manager) could fullscreen it again, and not all window managers honor requests to unfullscreen windows. But normally the will end up restored to its normal state. Just don't write code that crashes if not. You can track the fullscreen state via the event on . Method System.Void Asks to unmaximize . Note that you shouldn't assume the 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 will end up unmaximized. Just don't write code that crashes if not. You can track maximization via the event on Method System.Void Asks to unstick , which means that it will appear on only one of the user's desktops. Note that you shouldn't assume the is definitely unstuck afterward, because other entities (e.g. the user or window manager) could stick it again. But normally the will end up stuck. Just do not write code that crashes if not. You can track stickiness via the event on . Property GLib.Property("urgency-hint") System.Boolean Urgency Hint. if the hint should be set on the window. This hint notifies the desktop environment to draw the user's attention to the window for urgent action. Property GLib.Property("window-position") Gtk.WindowPosition Property used for setting/getting the position. The position. See also . This property will alow you to define where a should be displayed on the screen. Position values are described in the definition. Property Gtk.WindowType To be added. To be added. To be added.