[gtk+/client-side-decorations] Toggle the max button image
- From: Matthias Clasen <matthiasc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+/client-side-decorations] Toggle the max button image
- Date: Thu, 9 Jul 2009 01:49:19 +0000 (UTC)
commit 15a7543e0a3fd77ae28e7cf803d5f38c5e3e0704
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jul 8 21:48:14 2009 -0400
Toggle the max button image
Show a different image in maximized state; this is common in window
manager themes.
gtk/gtkwindow.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 525ad8e..0eea23d 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -239,6 +239,8 @@ static gboolean gtk_window_map_event (GtkWidget *widget,
GdkEventAny *event);
static gint gtk_window_configure_event (GtkWidget *widget,
GdkEventConfigure *event);
+static gint gtk_window_state_event (GtkWidget *widget,
+ GdkEventWindowState *event);
static gint gtk_window_key_press_event (GtkWidget *widget,
GdkEventKey *event);
static gint gtk_window_key_release_event (GtkWidget *widget,
@@ -490,6 +492,7 @@ gtk_window_class_init (GtkWindowClass *klass)
widget_class->size_request = gtk_window_size_request;
widget_class->size_allocate = gtk_window_size_allocate;
widget_class->configure_event = gtk_window_configure_event;
+ widget_class->window_state_event = gtk_window_state_event;
widget_class->key_press_event = gtk_window_key_press_event;
widget_class->key_release_event = gtk_window_key_release_event;
widget_class->enter_notify_event = gtk_window_enter_notify_event;
@@ -1520,6 +1523,29 @@ update_window_buttons (GtkWindow *window)
}
static void
+update_max_button (GtkWindow *window,
+ gboolean maximized)
+{
+ GtkWindowPrivate *priv = GTK_WINDOW_GET_PRIVATE (window);
+ GtkWidget *button;
+ GtkWidget *image;
+
+ button = GTK_BIN (priv->max_button);
+ image = gtk_bin_get_child (GTK_BIN (button));
+
+ if (maximized)
+ {
+ gtk_image_set_from_stock (GTK_IMAGE (image), GTK_STOCK_ZOOM_100, GTK_ICON_SIZE_MENU);
+ gtk_widget_set_tooltip_text (button, _("Restore Window"));
+ }
+ else
+ {
+ gtk_image_set_from_stock (GTK_IMAGE (image), GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_MENU);
+ gtk_widget_set_tooltip_text (button, _("Maximize Window"));
+ }
+}
+
+static void
ensure_title_box (GtkWindow *window)
{
GtkWindowPrivate *priv = GTK_WINDOW_GET_PRIVATE (window);
@@ -5581,6 +5607,21 @@ gtk_window_configure_event (GtkWidget *widget,
return TRUE;
}
+static gboolean
+gtk_window_state_event (GtkWidget *widget,
+ GdkEventWindowState *event)
+{
+ GtkWindow *window = GTK_WINDOW (widget);
+
+ if (is_client_side_decorated (window))
+ {
+ if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED)
+ update_max_button (window, event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED);
+ }
+
+ return FALSE;
+}
+
/* the accel_key and accel_mods fields of the key have to be setup
* upon calling this function. it'll then return whether that key
* is at all used as accelerator, and if so will OR in the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]