summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-03-09 22:28:39 -0500
committerMatthias Clasen <mclasen@redhat.com>2013-03-09 22:28:39 -0500
commit74cd6de40994cb4ec7cece67a03aa4b6483ef2c3 (patch)
tree6d9c447661d1f155e06b23638cd0f699dc5b5804
parentca849344f1e4dc62b436dd91207dfdbe6541127d (diff)
downloadgtk+-74cd6de40994cb4ec7cece67a03aa4b6483ef2c3.tar.gz
Hide buttons when appropriate
Hide the close button if the window is not deletable, hide the maximize button if the window is not resizable, and hide all buttons if the window is a dialog.
-rw-r--r--gtk/gtkwindow.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 0c4687e706..0105e6b1b6 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -437,6 +437,7 @@ static void gtk_window_unrealize_icon (GtkWindow *window);
static void resize_grip_create_window (GtkWindow *window);
static void resize_grip_destroy_window (GtkWindow *window);
static void update_grip_visibility (GtkWindow *window);
+static void update_window_buttons (GtkWindow *window);
static void gtk_window_notify_keys_changed (GtkWindow *window);
static GtkKeyHash *gtk_window_get_key_hash (GtkWindow *window);
@@ -2900,6 +2901,8 @@ gtk_window_set_type_hint (GtkWindow *window,
priv->reset_type_hint = TRUE;
priv->gdk_type_hint = hint;
+
+ update_window_buttons (window);
}
/**
@@ -3480,6 +3483,8 @@ gtk_window_set_deletable (GtkWindow *window,
GDK_FUNC_ALL | GDK_FUNC_CLOSE);
}
+ update_window_buttons (window);
+
g_object_notify (G_OBJECT (window), "deletable");
}
@@ -4853,6 +4858,51 @@ get_default_title (void)
return title;
}
+static void
+update_window_buttons (GtkWindow *window)
+{
+ GtkWindowPrivate *priv = window->priv;
+
+ if (priv->client_decorated)
+ {
+ if (priv->title_box != NULL)
+ gtk_widget_show (priv->title_box);
+
+ if (priv->title_min_button != NULL)
+ {
+ if (priv->gdk_type_hint == GDK_WINDOW_TYPE_HINT_NORMAL)
+ gtk_widget_show (priv->title_min_button);
+ else
+ gtk_widget_hide (priv->title_min_button);
+ }
+
+ if (priv->title_max_button != NULL)
+ {
+ if (priv->resizable &&
+ priv->gdk_type_hint == GDK_WINDOW_TYPE_HINT_NORMAL)
+ gtk_widget_show (priv->title_max_button);
+ else
+ gtk_widget_hide (priv->title_max_button);
+ }
+
+ if (priv->title_close_button != NULL)
+ {
+ if (priv->deletable &&
+ priv->gdk_type_hint == GDK_WINDOW_TYPE_HINT_NORMAL)
+ gtk_widget_show_all (priv->title_close_button);
+ else
+ gtk_widget_hide (priv->title_close_button);
+ }
+
+ if (priv->title_label != NULL)
+ gtk_widget_show (priv->title_label);
+ }
+ else
+ {
+ if (priv->title_box != NULL)
+ gtk_widget_hide (priv->title_box);
+ }
+}
static void
create_decoration (GtkWidget *widget)
@@ -4929,6 +4979,8 @@ create_decoration (GtkWidget *widget)
G_CALLBACK (gtk_window_title_min_clicked), window);
gtk_widget_show_all (priv->title_box);
+
+ update_window_buttons (window);
}
}
@@ -8765,6 +8817,7 @@ gtk_window_set_resizable (GtkWindow *window,
priv->resizable = resizable;
update_grip_visibility (window);
+ update_window_buttons (window);
gtk_widget_queue_resize_no_redraw (GTK_WIDGET (window));