[gtk+] Use titlebar action settings for CSD windows
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Use titlebar action settings for CSD windows
- Date: Thu, 25 Sep 2014 18:55:20 +0000 (UTC)
commit fcec9b98127cf7dcb63be475490f095db1bc6faa
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Sep 25 01:26:06 2014 -0400
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
gtk/gtkwindow.c | 45 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index e6dbb12..8099f3a 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]