[gnome-control-center/gnome-3-26] window: Split the window decorations between the header bars
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gnome-3-26] window: Split the window decorations between the header bars
- Date: Tue, 12 Sep 2017 14:35:18 +0000 (UTC)
commit 04a96edf868f4af84d754118a486f33fef803477
Author: Felipe Borges <felipeborges gnome org>
Date: Sun Sep 3 15:27:25 2017 +0200
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
shell/cc-window.c | 37 +++++++++++++++++++++++++++++++++++++
shell/window.ui | 1 +
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/shell/cc-window.c b/shell/cc-window.c
index 2eecbea..b3e9c56 100644
--- a/shell/cc-window.c
+++ b/shell/cc-window.c
@@ -721,8 +721,36 @@ window_key_press_event (GtkWidget *win,
}
static void
+split_decorations (GtkSettings *settings,
+ GParamSpec *pspec,
+ CcWindow *self)
+{
+ gchar *layout, *layout_start, *layout_end;
+ 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);
+
+ g_free (layout_start);
+ g_free (layout_end);
+ g_strfreev (buttons);
+ g_free (layout);
+}
+
+static void
create_window (CcWindow *self)
{
+ GtkSettings *settings;
AtkObject *accessible;
/* previous button */
@@ -765,6 +793,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
diff --git a/shell/window.ui b/shell/window.ui
index b3a73d7..3f48916 100644
--- a/shell/window.ui
+++ b/shell/window.ui
@@ -108,6 +108,7 @@
<object class="GtkHeaderBar" id="header">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="show-close-button">True</property>
<property name="title" translatable="yes">Settings</property>
<child>
<object class="GtkButton" id="previous_button">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]