Add a deletable property with getter and setter, to control the close

2005-08-30  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtk.symbols:
	* gtk/gtkwindow.h:
	* gtk/gtkwindow.c: Add a deletable property with getter
	and setter, to control the close button in the window
	frame.  (#59718, Havoc Pennington)
This commit is contained in:
Matthias Clasen 2005-08-30 04:46:09 +00:00 committed by Matthias Clasen
parent 6681ce0dd6
commit adb16c5b89
7 changed files with 126 additions and 0 deletions

View File

@ -1,3 +1,11 @@
2005-08-30 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk.symbols:
* gtk/gtkwindow.h:
* gtk/gtkwindow.c: Add a deletable property with getter
and setter, to control the close button in the window
frame. (#59718, Havoc Pennington)
2005-08-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkrc.key.emacs: Add C-n/C-p/C-f/C-b as alternatives

View File

@ -1,3 +1,11 @@
2005-08-30 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk.symbols:
* gtk/gtkwindow.h:
* gtk/gtkwindow.c: Add a deletable property with getter
and setter, to control the close button in the window
frame. (#59718, Havoc Pennington)
2005-08-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkrc.key.emacs: Add C-n/C-p/C-f/C-b as alternatives

View File

@ -1,3 +1,7 @@
2005-08-30 Matthias Clasen <mclasen@redhat.com>
* gtk/gtk-sections.txt: Add gtk_window_[sg]et_deletable.
2005-08-29 Matthias Clasen <mclasen@redhat.com>
* gtk/tmpl/gtkstatusicon.sgml: Add a long description.

View File

@ -4771,6 +4771,7 @@ gtk_window_set_keep_below
gtk_window_begin_resize_drag
gtk_window_begin_move_drag
gtk_window_set_decorated
gtk_window_set_deletable
gtk_window_set_frame_dimensions
gtk_window_set_has_frame
gtk_window_set_mnemonic_modifier
@ -4782,6 +4783,7 @@ gtk_window_set_urgency_hint
gtk_window_set_accept_focus
gtk_window_set_focus_on_map
gtk_window_get_decorated
gtk_window_get_deletable
gtk_window_get_default_icon_list
gtk_window_get_default_size
gtk_window_get_destroy_with_parent

View File

@ -3930,6 +3930,7 @@ gtk_window_deiconify
gtk_window_fullscreen
gtk_window_get_accept_focus
gtk_window_get_decorated
gtk_window_get_deletable
gtk_window_get_default_icon_list
gtk_window_get_default_size
gtk_window_get_destroy_with_parent
@ -3979,6 +3980,7 @@ gtk_window_resize
gtk_window_set_accept_focus
gtk_window_set_auto_startup_notification
gtk_window_set_decorated
gtk_window_set_deletable
gtk_window_set_default
gtk_window_set_default_icon
gtk_window_set_default_icon_from_file PRIVATE

View File

@ -87,6 +87,7 @@ enum {
PROP_ACCEPT_FOCUS,
PROP_FOCUS_ON_MAP,
PROP_DECORATED,
PROP_DELETABLE,
PROP_GRAVITY,
/* Readonly properties */
@ -170,6 +171,7 @@ struct _GtkWindowPrivate
guint urgent : 1;
guint accept_focus : 1;
guint focus_on_map : 1;
guint deletable : 1;
};
static void gtk_window_class_init (GtkWindowClass *klass);
@ -634,6 +636,22 @@ gtk_window_class_init (GtkWindowClass *klass)
TRUE,
GTK_PARAM_READWRITE));
/**
* GtkWindow:deletable:
*
* Whether the window frame should have a close button.
*
* Since: 2.10
*/
g_object_class_install_property (gobject_class,
PROP_DELETABLE,
g_param_spec_boolean ("deletable",
P_("Deletable"),
P_("Whether the window frame should have a close button"),
TRUE,
GTK_PARAM_READWRITE));
/**
* GtkWindow:gravity:
*
@ -783,6 +801,7 @@ gtk_window_init (GtkWindow *window)
priv->accept_focus = TRUE;
priv->focus_on_map = TRUE;
priv->deletable = TRUE;
colormap = _gtk_widget_peek_colormap ();
if (colormap)
@ -892,6 +911,9 @@ gtk_window_set_property (GObject *object,
case PROP_DECORATED:
gtk_window_set_decorated (window, g_value_get_boolean (value));
break;
case PROP_DELETABLE:
gtk_window_set_deletable (window, g_value_get_boolean (value));
break;
case PROP_GRAVITY:
gtk_window_set_gravity (window, g_value_get_enum (value));
break;
@ -996,6 +1018,9 @@ gtk_window_get_property (GObject *object,
case PROP_DECORATED:
g_value_set_boolean (value, gtk_window_get_decorated (window));
break;
case PROP_DELETABLE:
g_value_set_boolean (value, gtk_window_get_deletable (window));
break;
case PROP_GRAVITY:
g_value_set_enum (value, gtk_window_get_gravity (window));
break;
@ -2432,6 +2457,74 @@ gtk_window_get_decorated (GtkWindow *window)
return window->decorated;
}
/**
* @window: a #GtkWindow
* @setting: %TRUE to decorate the window as deletable
*
* By default, windows have a close button in the window frame. Some
* <link linkend="gtk-X11-arch">window managers</link> allow GTK+ to
* disable this button. If you set the deletable property to %FALSE
* using this function, GTK+ will do its best to convince the window
* manager not to show a close button. Depending on the system, this
* function may not have any effect when called on a window that is
* already visible, so you should call it before calling gtk_window_show().
*
* On Windows, this function always works, since there's no window manager
* policy involved.
*
* Since: 2.10
*/
void
gtk_window_set_deletable (GtkWindow *window,
gboolean setting)
{
GtkWindowPrivate *priv;
g_return_if_fail (GTK_IS_WINDOW (window));
priv = GTK_WINDOW_GET_PRIVATE (window);
setting = setting != FALSE;
if (setting == priv->deletable)
return;
priv->deletable = setting;
if (GTK_WIDGET (window)->window)
{
if (priv->deletable)
gdk_window_set_functions (GTK_WIDGET (window)->window,
GDK_FUNC_ALL);
else
gdk_window_set_functions (GTK_WIDGET (window)->window,
GDK_FUNC_ALL | GDK_FUNC_CLOSE);
}
g_object_notify (G_OBJECT (window), "deletable");
}
/**
* gtk_window_get_deletable:
* @window: a #GtkWindow
*
* Returns whether the window has been set to have a close button
* via gtk_window_set_deletable().
*
* Return value: %TRUE if the window has been set to have a close button
**/
gboolean
gtk_window_get_deletable (GtkWindow *window)
{
GtkWindowPrivate *priv;
g_return_val_if_fail (GTK_IS_WINDOW (window), TRUE);
priv = GTK_WINDOW_GET_PRIVATE (window);
return priv->deletable;
}
static GtkWindowIconInfo*
get_icon_info (GtkWindow *window)
{
@ -4058,9 +4151,12 @@ gtk_window_realize (GtkWidget *widget)
GdkWindow *parent_window;
GdkWindowAttr attributes;
gint attributes_mask;
GtkWindowPrivate *priv;
window = GTK_WINDOW (widget);
priv = GTK_WINDOW_GET_PRIVATE (window);
/* ensure widget tree is properly size allocated */
if (widget->allocation.x == -1 &&
widget->allocation.y == -1 &&
@ -4182,6 +4278,9 @@ gtk_window_realize (GtkWidget *widget)
if (!window->decorated)
gdk_window_set_decorations (widget->window, 0);
if (!priv->deletable)
gdk_window_set_functions (widget->window, GDK_FUNC_ALL | GDK_FUNC_CLOSE);
gdk_window_set_type_hint (widget->window, window->type_hint);
if (gtk_window_get_skip_pager_hint (window))

View File

@ -257,6 +257,9 @@ void gtk_window_get_frame_dimensions (GtkWindow *window,
void gtk_window_set_decorated (GtkWindow *window,
gboolean setting);
gboolean gtk_window_get_decorated (GtkWindow *window);
void gtk_window_set_deletable (GtkWindow *window,
gboolean setting);
gboolean gtk_window_get_deletable (GtkWindow *window);
void gtk_window_set_icon_list (GtkWindow *window,
GList *list);