diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-09-25 01:26:06 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-09-25 14:54:49 -0400 |
commit | fcec9b98127cf7dcb63be475490f095db1bc6faa (patch) | |
tree | 76f1785aaabbb5a85fbbecc8d143111161ed0861 /gtk/gtkwindow.c | |
parent | d20fdd18eb334ed8aea607dfc91746c4660cd4ca (diff) | |
download | gtk+-fcec9b98127cf7dcb63be475490f095db1bc6faa.tar.gz |
Use titlebar action settings for CSD windows
Instead of hardcoding these actions, consult the settings.
Note that not all of the actions supported by gnome-shell are
implemented here, only maximize, minimize, lower, and menu.
https://bugzilla.gnome.org/show_bug.cgi?id=729782
Diffstat (limited to 'gtk/gtkwindow.c')
-rw-r--r-- | gtk/gtkwindow.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index e6dbb12815..8099f3a059 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -1360,24 +1360,47 @@ gtk_window_titlebar_action (GtkWindow *window, guint button, gint n_press) { + GtkSettings *settings; + gchar *action = NULL; + gboolean retval = TRUE; + + settings = gtk_widget_get_settings (GTK_WIDGET (window)); switch (button) { case GDK_BUTTON_PRIMARY: if (n_press == 2) - { - _gtk_window_toggle_maximized (window); - return TRUE; - } - return FALSE; + g_object_get (settings, "gtk-titlebar-double-click", &action, NULL); + break; case GDK_BUTTON_MIDDLE: - gdk_window_lower (gtk_widget_get_window (GTK_WIDGET (window))); - return TRUE; + g_object_get (settings, "gtk-titlebar-middle-click", &action, NULL); + break; case GDK_BUTTON_SECONDARY: - gtk_window_do_popup (window, (GdkEventButton*) event); - return TRUE; - default: - return FALSE; + g_object_get (settings, "gtk-titlebar-right-click", &action, NULL); + break; } + + if (action == NULL) + retval = FALSE; + else if (g_str_equal (action, "none")) + retval = FALSE; + /* treat all maximization variants the same */ + else if (g_str_has_prefix (action, "toggle-maximize")) + _gtk_window_toggle_maximized (window); + else if (g_str_equal (action, "lower")) + gdk_window_lower (gtk_widget_get_window (GTK_WIDGET (window))); + else if (g_str_equal (action, "minimize")) + gdk_window_iconify (gtk_widget_get_window (GTK_WIDGET (window))); + else if (g_str_equal (action, "menu")) + gtk_window_do_popup (window, (GdkEventButton*) event); + else + { + g_warning ("Unsupported titlebar action %s\n", action); + retval = FALSE; + } + + g_free (action); + + return retval; } static void |