diff options
author | Felipe Borges <felipeborges@gnome.org> | 2017-09-03 15:27:25 +0200 |
---|---|---|
committer | Felipe Borges <felipeborges@gnome.org> | 2017-09-12 11:10:33 +0200 |
commit | 357e9443364765ccf9a297578e8d4f894a3dc504 (patch) | |
tree | 3e81f852fc0822efa06a2616ec19b0a8d6d4c666 /shell/cc-window.c | |
parent | d946668fbd4141e31c49eec4ca4e1a83d41519c1 (diff) | |
download | gnome-control-center-357e9443364765ccf9a297578e8d4f894a3dc504.tar.gz |
window: Split the window decorations between the header bars
When application menus are not supported by the desktop environment
or are disabled, Gtk+ makes the menu available with a fallback. For
client-side decorations the fallback consists of adding a menu
button at the begining of the titlebar. Since g-c-c has a split
headerbar, we need to explicitly handle the decoration layout.
This commit forces the "menu" to belong to the left headerbar, and
leaves the other buttons to ble placed at the right headerbar.
The "show-close-button" property has to be set in order to present
any type of decoration buttons in the header bar.
https://bugzilla.gnome.org/show_bug.cgi?id=786692
Diffstat (limited to 'shell/cc-window.c')
-rw-r--r-- | shell/cc-window.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/shell/cc-window.c b/shell/cc-window.c index 2eecbeaee..f051dad8f 100644 --- a/shell/cc-window.c +++ b/shell/cc-window.c @@ -721,8 +721,33 @@ window_key_press_event (GtkWidget *win, } static void +split_decorations (GtkSettings *settings, + GParamSpec *pspec, + CcWindow *self) +{ + g_autofree gchar *layout = NULL; + g_autofree gchar *layout_start = NULL; + g_autofree gchar *layout_end = NULL; + g_autofree gchar **buttons; + + g_object_get (settings, "gtk-decoration-layout", &layout, NULL); + + buttons = g_strsplit (layout, ":", -1); + layout_start = g_strconcat ("", buttons[0], ":", NULL); + + if (g_strv_length (buttons) > 1) + layout_end = g_strconcat (":", buttons[1], NULL); + else + layout_end = g_strdup (""); + + gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (self->header), layout_start); + gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (self->panel_headerbar), layout_end); +} + +static void create_window (CcWindow *self) { + GtkSettings *settings; AtkObject *accessible; /* previous button */ @@ -765,6 +790,15 @@ create_window (CcWindow *self) gtk_widget_add_events (GTK_WIDGET (self), GDK_BUTTON_RELEASE_MASK); g_signal_connect (self, "button-release-event", G_CALLBACK (window_button_release_event), self); + + /* handle decorations for the split headers. */ + settings = gtk_settings_get_default (); + g_signal_connect (settings, + "notify::gtk-decoration-layout", + G_CALLBACK (split_decorations), + self); + + split_decorations (settings, NULL, self); } static void |