[glade/headerbar: 4/7] Redo sensitivity handling
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade/headerbar: 4/7] Redo sensitivity handling
- Date: Wed, 5 Nov 2014 11:23:46 +0000 (UTC)
commit adb41ec5696b7a591f2b31600bbf6f9342f4964b
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Nov 3 23:59:48 2014 -0500
Redo sensitivity handling
And ignore show-close-button.
plugins/gtk+/glade-header-bar-editor.c | 43 ++++++++++++++++++++++++++----
plugins/gtk+/glade-header-bar-editor.ui | 14 ++++++----
plugins/gtk+/gtk+.xml.in | 4 +--
3 files changed, 46 insertions(+), 15 deletions(-)
---
diff --git a/plugins/gtk+/glade-header-bar-editor.c b/plugins/gtk+/glade-header-bar-editor.c
index 344edb1..37ef06b 100644
--- a/plugins/gtk+/glade-header-bar-editor.c
+++ b/plugins/gtk+/glade-header-bar-editor.c
@@ -26,15 +26,19 @@
#include "glade-header-bar-editor.h"
+#define TITLE_DISABLED_MESSAGE _("This property does not apply when a custom title is set")
+
static void glade_header_bar_editor_editable_init (GladeEditableIface * iface);
static void glade_header_bar_editor_grab_focus (GtkWidget * widget);
static void use_custom_title_toggled (GtkWidget *widget, GladeHeaderBarEditor * editor);
+static void show_decoration_toggled (GtkWidget *widget, GladeHeaderBarEditor * editor);
struct _GladeHeaderBarEditorPrivate
{
GtkWidget *embed;
GtkWidget *use_custom_title_check;
+ GtkWidget *show_decoration_check;
};
static GladeEditableIface *parent_editable_iface;
@@ -54,7 +58,9 @@ glade_header_bar_editor_class_init (GladeHeaderBarEditorClass * klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/gladegtk/glade-header-bar-editor.ui");
gtk_widget_class_bind_template_child_private (widget_class, GladeHeaderBarEditor, embed);
gtk_widget_class_bind_template_child_private (widget_class, GladeHeaderBarEditor, use_custom_title_check);
+ gtk_widget_class_bind_template_child_private (widget_class, GladeHeaderBarEditor, show_decoration_check);
gtk_widget_class_bind_template_callback (widget_class, use_custom_title_toggled);
+ gtk_widget_class_bind_template_callback (widget_class, show_decoration_toggled);
}
static void
@@ -89,6 +95,8 @@ glade_header_bar_editor_load (GladeEditable *editable,
glade_widget_property_get (gwidget, "use-custom-title", &setting);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->use_custom_title_check), setting);
+ glade_widget_property_get (gwidget, "show-close-button", &setting);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->show_decoration_check), setting);
}
}
@@ -146,12 +154,18 @@ use_custom_title_toggled (GtkWidget *widget,
if (use_custom_title)
{
- property = glade_widget_get_property (gwidget, "title");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (gwidget, "subtitle");
- glade_command_set_property (property, NULL);
- property = glade_widget_get_property (gwidget, "has-subtitle");
- glade_command_set_property (property, TRUE);
+ glade_widget_property_set (gwidget, "title", NULL);
+ glade_widget_property_set (gwidget, "subtitle", NULL);
+ glade_widget_property_set (gwidget, "has-subtitle", TRUE);
+ glade_widget_property_set_sensitive (gwidget, "title", FALSE, TITLE_DISABLED_MESSAGE);
+ glade_widget_property_set_sensitive (gwidget, "subtitle", FALSE, TITLE_DISABLED_MESSAGE);
+ glade_widget_property_set_sensitive (gwidget, "has-subtitle", FALSE, TITLE_DISABLED_MESSAGE);
+ }
+ else
+ {
+ glade_widget_property_set_sensitive (gwidget, "title", TRUE, NULL);
+ glade_widget_property_set_sensitive (gwidget, "subtitle", TRUE, NULL);
+ glade_widget_property_set_sensitive (gwidget, "has-subtitle", TRUE, NULL);
}
glade_command_pop_group ();
@@ -161,6 +175,23 @@ use_custom_title_toggled (GtkWidget *widget,
glade_editable_load (GLADE_EDITABLE (editor), gwidget);
}
+static void
+show_decoration_toggled (GtkWidget *widget,
+ GladeHeaderBarEditor *editor)
+{
+ GladeHeaderBarEditorPrivate *priv = editor->priv;
+ GladeWidget *gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (editor));
+ gboolean show_decoration;
+
+ if (glade_editable_loading (GLADE_EDITABLE (editor)) || !gwidget)
+ return;
+
+ show_decoration = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->show_decoration_check));
+
+ glade_widget_property_set (gwidget, "show-close-button", show_decoration);
+ glade_widget_property_set_sensitive (gwidget, "decoration-layout", show_decoration, "");
+}
+
GtkWidget *
glade_header_bar_editor_new (void)
{
diff --git a/plugins/gtk+/glade-header-bar-editor.ui b/plugins/gtk+/glade-header-bar-editor.ui
index 365f19a..e93a05d 100644
--- a/plugins/gtk+/glade-header-bar-editor.ui
+++ b/plugins/gtk+/glade-header-bar-editor.ui
@@ -156,13 +156,16 @@ Author: Matthias Clasen <mclasen redhat com>
</packing>
</child>
<child>
- <object class="GladePropertyShell" id="show_decoration_editor">
+ <object class="GtkCheckButton" id="show_decoration_check">
+ <property name="label" translatable="yes">Show window controls</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip-text" translatable="yes">Whether to show window controls, e.g. a close
button.</property>
<property name="margin_left">12</property>
- <property name="property_name">show-close-button</property>
- <property name="editor_type">GladeEpropCheck</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="show_decoration_toggled"/>
</object>
<packing>
<property name="left_attach">0</property>
@@ -292,7 +295,6 @@ Author: Matthias Clasen <mclasen redhat com>
<editor id="subtitle_label"/>
<editor id="subtitle_editor"/>
<editor id="has_subtitle_editor"/>
- <editor id="show_decoration_editor"/>
<editor id="decoration_layout_label"/>
<editor id="decoration_layout_editor"/>
<editor id="spacing_label"/>
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 3ffb238..d88e2c3 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -2417,9 +2417,7 @@
<property id="has-subtitle" _name="Reserve space for subtitle" custom-layout="True">
<_tooltip>Keep the headerbar height the same as the subtitle changes dynamically.</_tooltip>
</property>
- <property id="show-close-button" _name="Show window controls" custom-layout="True">
- <_tooltip>Whether to show window controls, e.g. a close button</_tooltip>
- </property>
+ <property id="show-close-button" ignore="True" save="True" custom-layout="True"/>
<property id="spacing" custom-layout="True"/>
<property id="decoration-layout" _name="Decoration Layout" optional="True" optional-default="False"
custom-layout="True"/>
<property id="decoration-layout-set" disabled="True"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]