[glade] Added GtkLockButton support.
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Added GtkLockButton support.
- Date: Mon, 28 Apr 2014 23:47:20 +0000 (UTC)
commit 6690a1a2737ba05485e09f5ae47129972cf359b8
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date: Sat Apr 26 02:32:00 2014 -0300
Added GtkLockButton support.
@aaa
plugins/gtk+/glade-gtk-button.c | 37 ++++++++++++++++---
plugins/gtk+/gtk+.xml.in | 37 +++++++++++++++++++-
plugins/gtk+/icons/16x16/Makefile.am | 1 +
plugins/gtk+/icons/16x16/widget-gtk-lockbutton.png | Bin 0 -> 274 bytes
plugins/gtk+/icons/22x22/Makefile.am | 1 +
plugins/gtk+/icons/22x22/widget-gtk-lockbutton.png | Bin 0 -> 264 bytes
6 files changed, 69 insertions(+), 7 deletions(-)
---
diff --git a/plugins/gtk+/glade-gtk-button.c b/plugins/gtk+/glade-gtk-button.c
index ab6f985..5a3ae39 100644
--- a/plugins/gtk+/glade-gtk-button.c
+++ b/plugins/gtk+/glade-gtk-button.c
@@ -127,7 +127,7 @@ glade_gtk_button_create_editable (GladeWidgetAdaptor * adaptor,
return (GladeEditable *) glade_font_button_editor_new ();
else if (g_type_is_a (type, GTK_TYPE_SCALE_BUTTON))
return (GladeEditable *) glade_scale_button_editor_new ();
- else
+ else if (!g_type_is_a (type, GTK_TYPE_LOCK_BUTTON))
return (GladeEditable *) glade_button_editor_new ();
}
@@ -166,6 +166,12 @@ glade_gtk_button_post_create (GladeWidgetAdaptor * adaptor,
g_signal_connect
(button, "color-set",
G_CALLBACK (glade_gtk_color_button_refresh_color), gbutton);
+ else if (GTK_IS_LOCK_BUTTON (button))
+ {
+ /* Gtk <= 3.12 crash if you click on a LockButton without a permission set */
+ gtk_lock_button_set_permission (GTK_LOCK_BUTTON (button),
+ g_simple_permission_new (TRUE));
+ }
/* Disabled response-id until its in an action area */
glade_widget_property_set_sensitive (gbutton, "response-id", FALSE,
@@ -175,6 +181,15 @@ glade_gtk_button_post_create (GladeWidgetAdaptor * adaptor,
glade_gtk_button_update_stock (gbutton);
}
+
+static inline gboolean
+glade_gtk_lock_button_is_own_property (GladeProperty *property)
+{
+ GladePropertyClass *klass = glade_property_get_class (property);
+ GParamSpec *spec = glade_property_class_get_pspec (klass);
+ return (spec->owner_type == GTK_TYPE_LOCK_BUTTON);
+}
+
void
glade_gtk_button_set_property (GladeWidgetAdaptor * adaptor,
GObject * object,
@@ -182,7 +197,7 @@ glade_gtk_button_set_property (GladeWidgetAdaptor * adaptor,
{
GladeWidget *widget = glade_widget_get_from_gobject (object);
GladeProperty *property = glade_widget_get_property (widget, id);
-
+
if (strcmp (id, "custom-child") == 0)
{
GtkWidget *child = gtk_bin_get_child (GTK_BIN (object));
@@ -221,6 +236,12 @@ glade_gtk_button_set_property (GladeWidgetAdaptor * adaptor,
}
else if (GPC_VERSION_CHECK (glade_property_get_class (property), gtk_major_version, gtk_minor_version + 1))
GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value);
+
+ /* GtkLockButton hides itself after setting a property so we need to make sure
+ * we keep it visible.
+ */
+ if (GTK_IS_LOCK_BUTTON (object) && glade_gtk_lock_button_is_own_property (property));
+ gtk_widget_set_visible (GTK_WIDGET (object), TRUE);
}
void
@@ -262,15 +283,19 @@ glade_gtk_button_write_widget (GladeWidgetAdaptor * adaptor,
GladeProperty *prop;
gboolean use_stock;
gchar *stock = NULL;
+ GObject *object;
if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) ||
glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE)))
return;
- /* Do not save GtkColorButton GtkFontButton and GtkScaleButton label property */
- if (!(GTK_IS_COLOR_BUTTON (glade_widget_get_object (widget)) ||
- GTK_IS_FONT_BUTTON (glade_widget_get_object (widget)) ||
- GTK_IS_SCALE_BUTTON (glade_widget_get_object (widget))))
+ object = glade_widget_get_object (widget);
+
+ /* Do not save GtkColorButton GtkFontButton GtkLockButton and GtkScaleButton
+ * label property
+ */
+ if (!(GTK_IS_COLOR_BUTTON (object) || GTK_IS_FONT_BUTTON (object) ||
+ GTK_IS_LOCK_BUTTON (object) || GTK_IS_SCALE_BUTTON (object)))
{
/* Make a copy of the GladeProperty,
* override its value and ensure non-translatable if use-stock is TRUE
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index ed3f872..1293822 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -2682,7 +2682,41 @@
<property id="align-widget" ignore="True"/>
</properties>
</glade-widget-class>
-
+
+ <glade-widget-class name="GtkLockButton" generic-name="lockbutton" _title="Lock Button" since="3.2">
+ <properties>
+ <property id="permission" disabled="True"/>
+ <property id="text-lock" translatable="True"/>
+ <property id="text-unlock" translatable="True"/>
+ <property id="tooltip-lock" multiline="True" translatable="True"/>
+ <property id="tooltip-unlock" multiline="True" translatable="True"/>
+ <property id="tooltip-not-authorized" multiline="True" translatable="True"/>
+
+ <!-- Disable Button Properties -->
+ <property id="always-show-image" disabled="True"/>
+ <property id="receives-default" disabled="True"/>
+ <property id="image" disabled="True"/>
+ <property id="use-stock" disabled="True"/>
+ <property id="label" disabled="True"/>
+ <property id="use-underline" disabled="True"/>
+ <property id="xalign" disabled="True"/>
+ <property id="yalign" disabled="True"/>
+ <property id="relief" disabled="True"/>
+ <property id="focus-on-click" disabled="True"/>
+ <property id="stock" disabled="True"/>
+ <property id="custom-child" disabled="True"/>
+ <property id="image-position" disabled="True"/>
+ <property id="response-id" disabled="True"/>
+
+ <!-- GtkActivatable -->
+ <property id="related-action" disabled="True"/>
+ <property id="use-action-appearance" disabled="True"/>
+
+ <!-- GtkActionable -->
+ <property id="action-name" disabled="True"/>
+ </properties>
+ </glade-widget-class>
+
<glade-widget-class name="GtkLayout" generic-name="layout" _title="Layout" use-placeholders="False">
<create-editable-function>glade_gtk_layout_create_editable</create-editable-function>
<create-widget-function>glade_gtk_create_fixed_widget</create-widget-function>
@@ -5082,6 +5116,7 @@
<glade-widget-class-ref name="GtkCheckButton"/>
<glade-widget-class-ref name="GtkRadioButton"/>
<glade-widget-class-ref name="GtkMenuButton"/>
+ <glade-widget-class-ref name="GtkLockButton"/>
<glade-widget-class-ref name="GtkSwitch"/>
<glade-widget-class-ref name="GtkEntry"/>
diff --git a/plugins/gtk+/icons/16x16/Makefile.am b/plugins/gtk+/icons/16x16/Makefile.am
index 645e815..baaeba7 100644
--- a/plugins/gtk+/icons/16x16/Makefile.am
+++ b/plugins/gtk+/icons/16x16/Makefile.am
@@ -66,6 +66,7 @@ icons_DATA = \
widget-gtk-label.png \
widget-gtk-layout.png \
widget-gtk-linkbutton.png \
+ widget-gtk-lockbutton.png \
widget-gtk-menu.png \
widget-gtk-menubar.png \
widget-gtk-menubutton.png \
diff --git a/plugins/gtk+/icons/16x16/widget-gtk-lockbutton.png
b/plugins/gtk+/icons/16x16/widget-gtk-lockbutton.png
new file mode 100644
index 0000000..0bfab01
Binary files /dev/null and b/plugins/gtk+/icons/16x16/widget-gtk-lockbutton.png differ
diff --git a/plugins/gtk+/icons/22x22/Makefile.am b/plugins/gtk+/icons/22x22/Makefile.am
index 505861b..ff45e33 100644
--- a/plugins/gtk+/icons/22x22/Makefile.am
+++ b/plugins/gtk+/icons/22x22/Makefile.am
@@ -66,6 +66,7 @@ icons_DATA = \
widget-gtk-label.png \
widget-gtk-layout.png \
widget-gtk-linkbutton.png \
+ widget-gtk-lockbutton.png \
widget-gtk-menu.png \
widget-gtk-menubar.png \
widget-gtk-menubutton.png \
diff --git a/plugins/gtk+/icons/22x22/widget-gtk-lockbutton.png
b/plugins/gtk+/icons/22x22/widget-gtk-lockbutton.png
new file mode 100644
index 0000000..64bab5f
Binary files /dev/null and b/plugins/gtk+/icons/22x22/widget-gtk-lockbutton.png differ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]