[gnome-control-center] 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] window: Split the window decorations between the header bars
- Date: Tue, 12 Sep 2017 09:11:39 +0000 (UTC)
commit 357e9443364765ccf9a297578e8d4f894a3dc504
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 | 34 ++++++++++++++++++++++++++++++++++
shell/window.ui | 1 +
2 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/shell/cc-window.c b/shell/cc-window.c
index 2eecbea..f051dad 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
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]