diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2013-04-14 02:43:17 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2013-04-14 02:49:37 +0900 |
commit | 961108a3f2d8840bf0af21ddeddeecfdcc8ccc81 (patch) | |
tree | 7ca3b7c3cfb9dce72a8dafd75fa4be613c450575 | |
parent | 05cdf1e8548a88dd7660e2c98f425194ae7fc186 (diff) |
Port GladeActivatableEditor to use a template.
Also, removed a lot of code regarding managing sensitivity
states with action-appearance, make use-action-appearance/related-action
optional properties as well.
Let's hope things survive with all this removed code.
-rw-r--r-- | plugins/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/gtk+/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/gtk+/glade-activatable-editor.c | 353 | ||||
-rw-r--r-- | plugins/gtk+/glade-activatable-editor.h | 10 | ||||
-rw-r--r-- | plugins/gtk+/glade-activatable-editor.ui | 148 | ||||
-rw-r--r-- | plugins/gtk+/glade-button-editor.c | 65 | ||||
-rw-r--r-- | plugins/gtk+/glade-button-editor.ui | 489 | ||||
-rw-r--r-- | plugins/gtk+/glade-gtk-activatable.c | 98 | ||||
-rw-r--r-- | plugins/gtk+/glade-gtk-activatable.h | 44 | ||||
-rw-r--r-- | plugins/gtk+/glade-gtk-resources.gresource.xml | 1 | ||||
-rw-r--r-- | plugins/gtk+/glade-gtk-switch.c | 25 | ||||
-rw-r--r-- | plugins/gtk+/glade-gtk.c | 79 | ||||
-rw-r--r-- | plugins/gtk+/gtk+.xml.in | 40 | ||||
-rw-r--r-- | po/POTFILES.in | 1 |
14 files changed, 497 insertions, 860 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 7eb8b49b..7366796e 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -13,4 +13,4 @@ endif dtddir = $(pkgdatadir)/catalogs dtd_DATA = glade-catalog.dtd -EXTRA_DIST = glade-catalog.dtd
\ No newline at end of file +EXTRA_DIST = glade-catalog.dtd gtk-private/glade-gtk-private.xml diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am index 3f97fd88..491d5d0e 100644 --- a/plugins/gtk+/Makefile.am +++ b/plugins/gtk+/Makefile.am @@ -48,7 +48,6 @@ libgladegtk_la_SOURCES = \ glade-gtk-box.c \ glade-gtk-action-widgets.c \ glade-gtk-info-bar.c \ - glade-gtk-activatable.c \ glade-gtk-switch.c libgladegtk_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS) @@ -77,7 +76,6 @@ noinst_HEADERS = \ glade-tool-item-group-editor.h \ glade-string-list.h \ glade-gtk-marshallers.h \ - glade-gtk-activatable.h \ glade-gtk-action-widgets.h \ glade-gtk-resources.h diff --git a/plugins/gtk+/glade-activatable-editor.c b/plugins/gtk+/glade-activatable-editor.c index a8d5cfc0..7cd7c8f3 100644 --- a/plugins/gtk+/glade-activatable-editor.c +++ b/plugins/gtk+/glade-activatable-editor.c @@ -20,26 +20,18 @@ */ #include <config.h> -#include <gladeui/glade.h> #include <glib/gi18n-lib.h> #include <gdk/gdkkeysyms.h> #include "glade-activatable-editor.h" - -static void glade_activatable_editor_finalize (GObject * object); - -static void glade_activatable_editor_editable_init (GladeEditableIface * iface); - static void glade_activatable_editor_grab_focus (GtkWidget * widget); -static GladeEditableIface *parent_editable_iface; - -G_DEFINE_TYPE_WITH_CODE (GladeActivatableEditor, glade_activatable_editor, - GTK_TYPE_VBOX, - G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, - glade_activatable_editor_editable_init)); +struct _GladeActivatableEditorPrivate { + GtkWidget *embed; +}; +G_DEFINE_TYPE (GladeActivatableEditor, glade_activatable_editor, GLADE_TYPE_EDITOR_SKELETON); static void glade_activatable_editor_class_init (GladeActivatableEditorClass * klass) @@ -47,68 +39,24 @@ glade_activatable_editor_class_init (GladeActivatableEditorClass * klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - object_class->finalize = glade_activatable_editor_finalize; widget_class->grab_focus = glade_activatable_editor_grab_focus; -} - -static void -glade_activatable_editor_init (GladeActivatableEditor * self) -{ -} - -static void -glade_activatable_editor_load (GladeEditable * editable, GladeWidget * widget) -{ - GladeActivatableEditor *activatable_editor = - GLADE_ACTIVATABLE_EDITOR (editable); - GList *l; - /* Chain up to default implementation */ - parent_editable_iface->load (editable, widget); + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-activatable-editor.ui"); + gtk_widget_class_bind_child (widget_class, GladeActivatableEditorPrivate, embed); - /* load the embedded editable... */ - if (activatable_editor->embed) - glade_editable_load (GLADE_EDITABLE (activatable_editor->embed), widget); + g_type_class_add_private (object_class, sizeof (GladeActivatableEditorPrivate)); - for (l = activatable_editor->properties; l; l = l->next) - glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), - widget); } static void -glade_activatable_editor_set_show_name (GladeEditable * editable, - gboolean show_name) -{ - GladeActivatableEditor *activatable_editor = - GLADE_ACTIVATABLE_EDITOR (editable); - - glade_editable_set_show_name (GLADE_EDITABLE (activatable_editor->embed), - show_name); -} - -static void -glade_activatable_editor_editable_init (GladeEditableIface * iface) +glade_activatable_editor_init (GladeActivatableEditor * self) { - parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE); + self->priv = + G_TYPE_INSTANCE_GET_PRIVATE (self, + GLADE_TYPE_ACTIVATABLE_EDITOR, + GladeActivatableEditorPrivate); - iface->load = glade_activatable_editor_load; - iface->set_show_name = glade_activatable_editor_set_show_name; -} - -static void -glade_activatable_editor_finalize (GObject * object) -{ - GladeActivatableEditor *activatable_editor = - GLADE_ACTIVATABLE_EDITOR (object); - - if (activatable_editor->properties) - g_list_free (activatable_editor->properties); - activatable_editor->properties = NULL; - activatable_editor->embed = NULL; - - glade_editable_load (GLADE_EDITABLE (object), NULL); - - G_OBJECT_CLASS (glade_activatable_editor_parent_class)->finalize (object); + gtk_widget_init_template (GTK_WIDGET (self)); } static void @@ -117,283 +65,12 @@ glade_activatable_editor_grab_focus (GtkWidget * widget) GladeActivatableEditor *activatable_editor = GLADE_ACTIVATABLE_EDITOR (widget); - gtk_widget_grab_focus (activatable_editor->embed); -} - -static void -table_attach (GtkWidget * table, GtkWidget * child, gint pos, gint row) -{ - gtk_grid_attach (GTK_GRID (table), child, pos, row, 1, 1); - - if (pos) - gtk_widget_set_hexpand (child, TRUE); -} - -static void -reset_property (GladeWidget * gwidget, const gchar * property_name) -{ - GladeProperty *property; - GValue value = { 0, }; - - if ((property = glade_widget_get_property (gwidget, property_name)) != NULL) - { - glade_property_get_default (property, &value); - glade_command_set_property_value (property, &value); - g_value_unset (&value); - } -} - -static GladeWidget * -get_image_widget (GladeWidget * widget) -{ - GtkWidget *image = NULL; - - if (GTK_IS_IMAGE_MENU_ITEM (glade_widget_get_object (widget))) - image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (glade_widget_get_object (widget))); - return image ? glade_widget_get_from_gobject (image) : NULL; -} - -static void -reset_properties (GladeWidget * gwidget, - GtkAction * action, - gboolean use_appearance, gboolean use_appearance_changed) -{ - GObject *object; - - reset_property (gwidget, "visible"); - reset_property (gwidget, "sensitive"); - - object = glade_widget_get_object (gwidget); - - if (GTK_IS_MENU_ITEM (object)) - { - if (!use_appearance_changed) - reset_property (gwidget, "accel-group"); - - if (use_appearance) - { - GladeWidget *image; - GladeProperty *property; - - reset_property (gwidget, "stock"); - reset_property (gwidget, "use-underline"); - reset_property (gwidget, "use-stock"); - - /* Delete image... */ - if ((image = get_image_widget (gwidget)) != NULL) - { - GList list = { 0, }; - list.data = image; - glade_command_unlock_widget (image); - glade_command_delete (&list); - } - - property = glade_widget_get_property (gwidget, "label"); - glade_command_set_property (property, NULL); - } - else if (use_appearance_changed) - { - reset_property (gwidget, "stock"); - reset_property (gwidget, "use-underline"); - reset_property (gwidget, "use-stock"); - - reset_property (gwidget, "label"); - - } - } - else if (GTK_IS_TOOL_ITEM (object)) - { - reset_property (gwidget, "visible-horizontal"); - reset_property (gwidget, "visible-vertical"); - reset_property (gwidget, "is-important"); - - if (use_appearance || use_appearance_changed) - { - reset_property (gwidget, "label-widget"); - reset_property (gwidget, "custom-label"); - reset_property (gwidget, "stock-id"); - reset_property (gwidget, "icon-name"); - reset_property (gwidget, "icon"); - reset_property (gwidget, "icon-widget"); - reset_property (gwidget, "image-mode"); - } - } - else if (GTK_IS_BUTTON (object)) - { - reset_property (gwidget, "active"); - - - if (use_appearance) - { - - GtkWidget *button, *child; - GladeWidget *gchild = NULL; - GladeProperty *property; - - /* If theres a widget customly inside... command remove it first... */ - button = GTK_WIDGET (object); - child = gtk_bin_get_child (GTK_BIN (button)); - if (child) - gchild = glade_widget_get_from_gobject (child); - - if (gchild && glade_widget_get_parent (gchild) == gwidget) - { - GList widgets = { 0, }; - widgets.data = gchild; - glade_command_delete (&widgets); - } - - reset_property (gwidget, "custom-child"); - reset_property (gwidget, "stock"); - //reset_property (gwidget, "use-stock"); - - property = glade_widget_get_property (gwidget, "label"); - glade_command_set_property (property, ""); - - } - else if (use_appearance_changed) - { - reset_property (gwidget, "label"); - reset_property (gwidget, "custom-child"); - reset_property (gwidget, "stock"); - //reset_property (gwidget, "use-stock"); - } - } - /* Make sure none of our property resets screw with the current selection, - * since we rely on the selection during commit time. - */ - glade_project_selection_set (glade_widget_get_project (gwidget), object, TRUE); -} - -static void -related_action_pre_commit (GladeEditorProperty * property, - GValue * value, - GladeActivatableEditor * activatable_editor) -{ - GladeWidget *gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (activatable_editor)); - GtkAction *action = g_value_get_object (value); - gboolean use_appearance = FALSE; - - glade_widget_property_get (gwidget, "use-action-appearance", &use_appearance); - - glade_command_push_group (_("Setting %s action"), glade_widget_get_name (gwidget)); - - reset_properties (gwidget, action, use_appearance, FALSE); - -} - -static void -related_action_post_commit (GladeEditorProperty * property, - GValue * value, - GladeActivatableEditor * activatable_editor) -{ - - glade_command_pop_group (); -} - - -static void -use_appearance_pre_commit (GladeEditorProperty * property, - GValue * value, - GladeActivatableEditor * activatable_editor) -{ - GladeWidget *gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (activatable_editor)); - GtkAction *action = NULL; - gboolean use_appearance = g_value_get_boolean (value); - - glade_widget_property_get (gwidget, "related-action", &action); - - glade_editable_block (GLADE_EDITABLE (activatable_editor)); - - glade_command_push_group (use_appearance ? - _("Setting %s to use action appearance") : - _("Setting %s to not use action appearance"), - glade_widget_get_name (gwidget)); - - reset_properties (gwidget, action, use_appearance, TRUE); -} - -static void -use_appearance_post_commit (GladeEditorProperty * property, - GValue * value, - GladeActivatableEditor * activatable_editor) -{ - - glade_command_pop_group (); - - glade_editable_unblock (GLADE_EDITABLE (activatable_editor)); + gtk_widget_grab_focus (activatable_editor->priv->embed); } GtkWidget * glade_activatable_editor_new (GladeWidgetAdaptor * adaptor, GladeEditable * embed) { - GladeActivatableEditor *activatable_editor; - GladeEditorProperty *eprop; - GtkWidget *table, *frame, *alignment, *label; - gchar *str; - gint row = 0; - - g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL); - g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL); - - activatable_editor = g_object_new (GLADE_TYPE_ACTIVATABLE_EDITOR, NULL); - activatable_editor->embed = GTK_WIDGET (embed); - - /* Pack the parent on top... */ - gtk_box_pack_start (GTK_BOX (activatable_editor), GTK_WIDGET (embed), FALSE, - FALSE, 0); - - str = g_strdup_printf ("<b>%s</b>", _("Action")); - label = gtk_label_new (str); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - g_free (str); - frame = gtk_frame_new (NULL); - gtk_frame_set_label_widget (GTK_FRAME (frame), label); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE); - gtk_box_pack_start (GTK_BOX (activatable_editor), frame, FALSE, FALSE, 4); - - alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0); - gtk_container_add (GTK_CONTAINER (frame), alignment); - - table = gtk_grid_new (); - gtk_orientable_set_orientation (GTK_ORIENTABLE (table), - GTK_ORIENTATION_VERTICAL); - gtk_grid_set_row_spacing (GTK_GRID (table), 4); - - gtk_container_add (GTK_CONTAINER (alignment), table); - - eprop = - glade_widget_adaptor_create_eprop_by_name (adaptor, "related-action", - FALSE, TRUE); - table_attach (table, glade_editor_property_get_item_label (eprop), 0, row); - table_attach (table, GTK_WIDGET (eprop), 1, row++); - activatable_editor->properties = - g_list_prepend (activatable_editor->properties, eprop); - - g_signal_connect (G_OBJECT (eprop), "commit", - G_CALLBACK (related_action_pre_commit), activatable_editor); - g_signal_connect_after (G_OBJECT (eprop), "commit", - G_CALLBACK (related_action_post_commit), - activatable_editor); - - eprop = - glade_widget_adaptor_create_eprop_by_name (adaptor, - "use-action-appearance", FALSE, - TRUE); - table_attach (table, glade_editor_property_get_item_label (eprop), 0, row); - table_attach (table, GTK_WIDGET (eprop), 1, row++); - activatable_editor->properties = - g_list_prepend (activatable_editor->properties, eprop); - - gtk_widget_show_all (GTK_WIDGET (activatable_editor)); - - g_signal_connect (G_OBJECT (eprop), "commit", - G_CALLBACK (use_appearance_pre_commit), activatable_editor); - g_signal_connect_after (G_OBJECT (eprop), "commit", - G_CALLBACK (use_appearance_post_commit), - activatable_editor); - - return GTK_WIDGET (activatable_editor); + return g_object_new (GLADE_TYPE_ACTIVATABLE_EDITOR, NULL); } diff --git a/plugins/gtk+/glade-activatable-editor.h b/plugins/gtk+/glade-activatable-editor.h index ba588e48..2a36fa0e 100644 --- a/plugins/gtk+/glade-activatable-editor.h +++ b/plugins/gtk+/glade-activatable-editor.h @@ -22,6 +22,7 @@ #define _GLADE_ACTIVATABLE_EDITOR_H_ #include <gtk/gtk.h> +#include <gladeui/glade.h> G_BEGIN_DECLS @@ -34,19 +35,18 @@ G_BEGIN_DECLS typedef struct _GladeActivatableEditor GladeActivatableEditor; typedef struct _GladeActivatableEditorClass GladeActivatableEditorClass; +typedef struct _GladeActivatableEditorPrivate GladeActivatableEditorPrivate; struct _GladeActivatableEditor { - GtkVBox parent; + GladeEditorSkeleton parent; - GtkWidget *embed; - - GList *properties; /* A list of eprops to update at load() time */ + GladeActivatableEditorPrivate *priv; }; struct _GladeActivatableEditorClass { - GtkVBoxClass parent; + GladeEditorSkeletonClass parent; }; GType glade_activatable_editor_get_type (void) G_GNUC_CONST; diff --git a/plugins/gtk+/glade-activatable-editor.ui b/plugins/gtk+/glade-activatable-editor.ui new file mode 100644 index 00000000..bb11eeed --- /dev/null +++ b/plugins/gtk+/glade-activatable-editor.ui @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface domain="glade"> + <!-- interface-requires gtk+ 3.8 --> + <!-- interface-requires gladeui 0.0 --> + <template class="GladeActivatableEditor" parent="GladeEditorSkeleton"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">4</property> + <child> + <object class="GladeEditorTable" id="embed"> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="frame1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkGrid" id="grid1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">12</property> + <property name="margin_top">6</property> + <property name="row_spacing">4</property> + <child> + <object class="GladePropertyLabel" id="propertylabel1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="visible_window">False</property> + <property name="property_name">related-action</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyShell" id="propertyshell1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="property_name">related-action</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyLabel" id="propertylabel2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="visible_window">False</property> + <property name="property_name">use-action-appearance</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyShell" id="propertyshell2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="property_name">use-action-appearance</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyLabel" id="propertylabel3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="visible_window">False</property> + <property name="property_name">action-name</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyShell" id="propertyshell3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="property_name">action-name</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Activatable / Actionable</property> + <property name="use_markup">True</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child-editors> + <editor id="embed"/> + <editor id="propertylabel1"/> + <editor id="propertyshell1"/> + <editor id="propertylabel2"/> + <editor id="propertyshell2"/> + <editor id="propertylabel3"/> + <editor id="propertyshell3"/> + </child-editors> + </template> +</interface> diff --git a/plugins/gtk+/glade-button-editor.c b/plugins/gtk+/glade-button-editor.c index e8f90953..248706c3 100644 --- a/plugins/gtk+/glade-button-editor.c +++ b/plugins/gtk+/glade-button-editor.c @@ -109,16 +109,13 @@ glade_button_editor_load (GladeEditable * editable, GladeWidget * widget) GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (editable); GladeWidget *gchild = NULL; GtkWidget *child, *button; - gboolean use_stock = FALSE, use_appearance = FALSE; + gboolean use_stock = FALSE; /* Chain up to default implementation */ parent_editable_iface->load (editable, widget); if (widget) { - glade_widget_property_get (widget, "use-action-appearance", - &use_appearance); - button = GTK_WIDGET (glade_widget_get_object (widget)); child = gtk_bin_get_child (GTK_BIN (button)); if (child) @@ -157,12 +154,6 @@ glade_button_editor_load (GladeEditable * editable, GladeWidget * widget) (button_editor->priv->label_radio), TRUE); } } - - if (use_appearance) - gtk_widget_set_sensitive (button_editor->priv->custom_radio, FALSE); - else - gtk_widget_set_sensitive (button_editor->priv->custom_radio, TRUE); - } } @@ -198,7 +189,6 @@ standard_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) GladeWidget *gchild = NULL, *gwidget; GtkWidget *child, *button; GValue value = { 0, }; - gboolean use_appearance = FALSE; gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (button_editor)); @@ -227,28 +217,20 @@ standard_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) glade_command_delete (&widgets); } - property = - glade_widget_get_property (gwidget, "custom-child"); + property = glade_widget_get_property (gwidget, "custom-child"); glade_command_set_property (property, FALSE); /* Setup reasonable defaults for button label. */ property = glade_widget_get_property (gwidget, "stock"); glade_command_set_property (property, NULL); - property = - glade_widget_get_property (gwidget, "use-stock"); + property = glade_widget_get_property (gwidget, "use-stock"); glade_command_set_property (property, FALSE); - glade_widget_property_get (gwidget, - "use-action-appearance", &use_appearance); - if (!use_appearance) - { - property = - glade_widget_get_property (gwidget, "label"); - glade_property_get_default (property, &value); - glade_command_set_property_value (property, &value); - g_value_unset (&value); - } + property = glade_widget_get_property (gwidget, "label"); + glade_property_get_default (property, &value); + glade_command_set_property_value (property, &value); + g_value_unset (&value); glade_command_pop_group (); @@ -280,8 +262,7 @@ custom_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) property = glade_widget_get_property (gwidget, "image"); glade_command_set_property (property, NULL); - property = - glade_widget_get_property (gwidget, "use-stock"); + property = glade_widget_get_property (gwidget, "use-stock"); glade_command_set_property (property, FALSE); property = glade_widget_get_property (gwidget, "stock"); @@ -291,8 +272,7 @@ custom_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) glade_command_set_property (property, NULL); /* Add a placeholder via the custom-child property... */ - property = - glade_widget_get_property (gwidget, "custom-child"); + property = glade_widget_get_property (gwidget, "custom-child"); glade_command_set_property (property, TRUE); glade_command_pop_group (); @@ -307,7 +287,6 @@ static void stock_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) { GladeProperty *property; - gboolean use_appearance = FALSE; GladeWidget *gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (button_editor)); if (glade_editable_loading (GLADE_EDITABLE (button_editor)) || !gwidget) @@ -326,16 +305,10 @@ stock_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) property = glade_widget_get_property (gwidget, "image"); glade_command_set_property (property, NULL); - glade_widget_property_get (gwidget, "use-action-appearance", &use_appearance); - if (!use_appearance) - { - property = - glade_widget_get_property (gwidget, "label"); - glade_command_set_property (property, ""); - } + property = glade_widget_get_property (gwidget, "label"); + glade_command_set_property (property, ""); - property = - glade_widget_get_property (gwidget, "use-stock"); + property = glade_widget_get_property (gwidget, "use-stock"); glade_command_set_property (property, TRUE); property = glade_widget_get_property (gwidget, "stock"); @@ -354,7 +327,6 @@ label_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) { GladeProperty *property; GValue value = { 0, }; - gboolean use_appearance = FALSE; GladeWidget *gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (button_editor)); if (glade_editable_loading (GLADE_EDITABLE (button_editor)) || !gwidget) @@ -375,15 +347,10 @@ label_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) property = glade_widget_get_property (gwidget, "use-stock"); glade_command_set_property (property, FALSE); - glade_widget_property_get (gwidget, "use-action-appearance", &use_appearance); - if (!use_appearance) - { - property = - glade_widget_get_property (gwidget, "label"); - glade_property_get_default (property, &value); - glade_command_set_property_value (property, &value); - g_value_unset (&value); - } + property = glade_widget_get_property (gwidget, "label"); + glade_property_get_default (property, &value); + glade_command_set_property_value (property, &value); + g_value_unset (&value); glade_command_pop_group (); diff --git a/plugins/gtk+/glade-button-editor.ui b/plugins/gtk+/glade-button-editor.ui index 997f2796..1c860152 100644 --- a/plugins/gtk+/glade-button-editor.ui +++ b/plugins/gtk+/glade-button-editor.ui @@ -1,13 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <interface domain="glade"> - <!-- interface-requires gladeui 0.0 --> <!-- interface-requires gtk+ 3.8 --> + <!-- interface-requires gladeui 0.0 --> <template class="GladeButtonEditor" parent="GladeEditorSkeleton"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="orientation">vertical</property> + <property name="spacing">4</property> <child> - <object class="GladeEditorTable" id="embed"> + <object class="GladeActivatableEditor" id="embed"> <property name="visible">True</property> <property name="can_focus">False</property> </object> @@ -18,105 +19,292 @@ </packing> </child> <child> - <object class="GtkFrame" id="standard"> + <object class="GtkFrame" id="frame1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> <child> - <object class="GtkBox" id="standard_frame"> + <object class="GtkBox" id="box1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="margin_left">12</property> - <property name="margin_top">6</property> - <property name="hexpand">True</property> <property name="orientation">vertical</property> - <property name="spacing">8</property> <child> - <object class="GtkFrame" id="stock"> + <object class="GtkFrame" id="standard"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> + <property name="margin_left">4</property> + <property name="margin_top">4</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> <child> - <object class="GtkGrid" id="stock_frame"> + <object class="GtkBox" id="standard_frame"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="margin_left">12</property> <property name="margin_top">6</property> <property name="hexpand">True</property> - <property name="row_spacing">4</property> - <child> - <object class="GladePropertyLabel" id="propertylabel1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">False</property> - <property name="visible_window">False</property> - <property name="property_name">stock</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GladePropertyLabel" id="propertylabel2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">False</property> - <property name="visible_window">False</property> - <property name="property_name">image-position</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> + <property name="orientation">vertical</property> + <property name="spacing">8</property> <child> - <object class="GladePropertyShell" id="propertyshell2"> + <object class="GtkFrame" id="stock"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="property_name">image-position</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkGrid" id="stock_frame"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">12</property> + <property name="margin_top">6</property> + <property name="hexpand">True</property> + <property name="row_spacing">4</property> + <child> + <object class="GladePropertyLabel" id="propertylabel1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">False</property> + <property name="visible_window">False</property> + <property name="property_name">stock</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyLabel" id="propertylabel2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">False</property> + <property name="visible_window">False</property> + <property name="property_name">image-position</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyShell" id="propertyshell2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="property_name">image-position</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyShell" id="propertyshell1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="property_name">stock</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkRadioButton" id="stock_radio"> + <property name="label" translatable="yes">Stock Button</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="stock_toggled" swapped="no"/> + </object> + </child> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> </packing> </child> <child> - <object class="GladePropertyShell" id="propertyshell1"> + <object class="GtkFrame" id="frame2"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="property_name">stock</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkGrid" id="label_frame"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">12</property> + <property name="margin_top">6</property> + <property name="hexpand">True</property> + <property name="row_spacing">4</property> + <child> + <object class="GladePropertyLabel" id="propertylabel3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">False</property> + <property name="visible_window">False</property> + <property name="property_name">label</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyShell" id="propertyshell3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="property_name">label</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyLabel" id="propertylabel4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">False</property> + <property name="visible_window">False</property> + <property name="property_name">use-underline</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyShell" id="propertyshell4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="property_name">use-underline</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyLabel" id="propertylabel5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">False</property> + <property name="visible_window">False</property> + <property name="property_name">image</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyShell" id="propertyshell5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="property_name">image</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyLabel" id="propertylabel6"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">False</property> + <property name="visible_window">False</property> + <property name="property_name">image-position</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GladePropertyShell" id="propertyshell6"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="property_name">image-position</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkRadioButton" id="label_radio"> + <property name="label" translatable="yes">Label with optional image</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">stock_radio</property> + <signal name="toggled" handler="label_toggled" swapped="no"/> + </object> + </child> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> </packing> </child> </object> </child> <child type="label"> - <object class="GtkRadioButton" id="stock_radio"> - <property name="label" translatable="yes">Stock Button</property> + <object class="GtkRadioButton" id="standard_radio"> + <property name="label" translatable="yes">Configure Button Content</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="xalign">0</property> <property name="active">True</property> <property name="draw_indicator">True</property> - <signal name="toggled" handler="stock_toggled" swapped="no"/> + <signal name="toggled" handler="standard_toggled" swapped="no"/> </object> </child> </object> @@ -127,151 +315,17 @@ </packing> </child> <child> - <object class="GtkFrame" id="frame1"> + <object class="GtkRadioButton" id="custom_radio"> + <property name="label" translatable="yes">Add custom button content</property> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - <child> - <object class="GtkGrid" id="label_frame"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_left">12</property> - <property name="margin_top">6</property> - <property name="hexpand">True</property> - <property name="row_spacing">4</property> - <child> - <object class="GladePropertyLabel" id="propertylabel3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">False</property> - <property name="visible_window">False</property> - <property name="property_name">label</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GladePropertyShell" id="propertyshell3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="property_name">label</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GladePropertyLabel" id="propertylabel4"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">False</property> - <property name="visible_window">False</property> - <property name="property_name">use-underline</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GladePropertyShell" id="propertyshell4"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="property_name">use-underline</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GladePropertyLabel" id="propertylabel5"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">False</property> - <property name="visible_window">False</property> - <property name="property_name">image</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GladePropertyShell" id="propertyshell5"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="property_name">image</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GladePropertyLabel" id="propertylabel6"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">False</property> - <property name="visible_window">False</property> - <property name="property_name">image-position</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GladePropertyShell" id="propertyshell6"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="property_name">image-position</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkRadioButton" id="label_radio"> - <property name="label" translatable="yes">Label with optional image</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="xalign">0</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - <property name="group">stock_radio</property> - <signal name="toggled" handler="label_toggled" swapped="no"/> - </object> - </child> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="margin_left">8</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">standard_radio</property> + <signal name="toggled" handler="custom_toggled" swapped="no"/> </object> <packing> <property name="expand">False</property> @@ -282,15 +336,14 @@ </object> </child> <child type="label"> - <object class="GtkRadioButton" id="standard_radio"> - <property name="label" translatable="yes">Configure Button Content</property> + <object class="GtkLabel" id="label1"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="xalign">0</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="standard_toggled" swapped="no"/> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Button Appearance</property> + <property name="use_markup">True</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> </object> </child> </object> @@ -300,24 +353,6 @@ <property name="position">1</property> </packing> </child> - <child> - <object class="GtkRadioButton" id="custom_radio"> - <property name="label" translatable="yes">Add custom button content</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="xalign">0</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - <property name="group">standard_radio</property> - <signal name="toggled" handler="custom_toggled" swapped="no"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> <child-editors> <editor id="embed"/> <editor id="propertylabel1"/> diff --git a/plugins/gtk+/glade-gtk-activatable.c b/plugins/gtk+/glade-gtk-activatable.c deleted file mode 100644 index 222a3e7d..00000000 --- a/plugins/gtk+/glade-gtk-activatable.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * glade-gtk-activatable.c - * - * Copyright (C) 2010 Tristan Van Berkom. - * - * Author: - * Tristan Van Berkom <tvb@gnome.org> - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include <config.h> -#include "glade-gtk-activatable.h" - -/* ----------------------------- GtkActivatable ------------------------------ */ -void -glade_gtk_activatable_parse_finished (GladeProject *project, - GladeWidget *widget) -{ - GObject *related_action = NULL; - - glade_widget_property_get (widget, "related-action", &related_action); - if (related_action == NULL) - { - glade_widget_property_set_sensitive (widget, "use-action-appearance", FALSE, ACTION_APPEARANCE_MSG); - glade_widget_property_set (widget, "use-action-appearance", FALSE); - } -} - -void -glade_gtk_activatable_evaluate_property_sensitivity (GObject *object, - const gchar *id, - const GValue *value) -{ - GladeWidget *gwidget = glade_widget_get_from_gobject (object); - gboolean sensitivity; - gchar *msg; - - if (!strcmp (id, "related-action")) - { - GtkAction *action = g_value_get_object (value); - - if (action) - { - sensitivity = FALSE; - msg = ACTION_APPEARANCE_MSG; - } - else - { - sensitivity = TRUE; - msg = NULL; - } - - glade_widget_property_set_sensitive (gwidget, "visible", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "sensitive", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "accel-group", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "use-action-appearance", !sensitivity, sensitivity ? msg : NULL); - } - else if (!strcmp (id, "use-action-appearance")) - { - if (g_value_get_boolean (value)) - { - sensitivity = FALSE; - msg = ACTION_APPEARANCE_MSG; - } - else - { - sensitivity = TRUE; - msg = NULL; - } - - glade_widget_property_set_sensitive (gwidget, "label", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "use-underline", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "stock", sensitivity, msg); - //glade_widget_property_set_sensitive (gwidget, "use-stock", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "image", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "image-position", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "custom-child", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "stock-id", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "label-widget", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "icon-name", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "icon-widget", sensitivity, msg); - glade_widget_property_set_sensitive (gwidget, "icon", sensitivity, msg); - } -} diff --git a/plugins/gtk+/glade-gtk-activatable.h b/plugins/gtk+/glade-gtk-activatable.h deleted file mode 100644 index 9333328f..00000000 --- a/plugins/gtk+/glade-gtk-activatable.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * glade-gtk-activatable.h - * - * Copyright (C) 2010 Tristan Van Berkom. - * - * Author: - * Tristan Van Berkom <tvb@gnome.org> - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef __GLADE_GTK_ACTIVATABLE_H__ -#define __GLADE_GTK_ACTIVATABLE_H__ - -#include <gladeui/glade.h> -#include "glade-gtk.h" - -G_BEGIN_DECLS - -void -glade_gtk_activatable_parse_finished (GladeProject *project, - GladeWidget *widget); - -void -glade_gtk_activatable_evaluate_property_sensitivity (GObject *object, - const gchar *id, - const GValue *value); - -G_END_DECLS - -#endif /* __GLADE_GTK_ACTIVATABLE_H__ */ diff --git a/plugins/gtk+/glade-gtk-resources.gresource.xml b/plugins/gtk+/glade-gtk-resources.gresource.xml index e840f4f8..c0b13b38 100644 --- a/plugins/gtk+/glade-gtk-resources.gresource.xml +++ b/plugins/gtk+/glade-gtk-resources.gresource.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <gresources> <gresource prefix="/org/gnome/gladegtk"> + <file compressed="true" preprocess="xml-stripblanks">glade-activatable-editor.ui</file> <file compressed="true" preprocess="xml-stripblanks">glade-button-editor.ui</file> </gresource> </gresources> diff --git a/plugins/gtk+/glade-gtk-switch.c b/plugins/gtk+/glade-gtk-switch.c index 5dba4436..cae415aa 100644 --- a/plugins/gtk+/glade-gtk-switch.c +++ b/plugins/gtk+/glade-gtk-switch.c @@ -23,22 +23,16 @@ */ #include <config.h> -#include "glade-gtk-activatable.h" #include "glade-activatable-editor.h" GladeEditable * glade_gtk_switch_create_editable (GladeWidgetAdaptor *adaptor, GladeEditorPageType type) { - GladeEditable *editable; - - /* Get base editable */ - editable = GWA_GET_CLASS (GTK_TYPE_WIDGET)->create_editable (adaptor, type); - if (type == GLADE_PAGE_GENERAL) - return (GladeEditable *) glade_activatable_editor_new (adaptor, editable); + return (GladeEditable *) glade_activatable_editor_new (adaptor, NULL); - return editable; + return GWA_GET_CLASS (GTK_TYPE_WIDGET)->create_editable (adaptor, type); } void @@ -53,19 +47,4 @@ glade_gtk_switch_post_create (GladeWidgetAdaptor *adaptor, g_return_if_fail (GTK_IS_SWITCH (widget)); gwidget = glade_widget_get_from_gobject (widget); g_return_if_fail (GLADE_IS_WIDGET (gwidget)); - - g_signal_connect (glade_widget_get_project (gwidget), "parse-finished", - G_CALLBACK (glade_gtk_activatable_parse_finished), - gwidget); -} - -void -glade_gtk_switch_set_property (GladeWidgetAdaptor *adaptor, - GObject *object, - const gchar *id, - const GValue *value) -{ - glade_gtk_activatable_evaluate_property_sensitivity (object, id, value); - - GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value); } diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c index 1e52ce45..5e25c9b9 100644 --- a/plugins/gtk+/glade-gtk.c +++ b/plugins/gtk+/glade-gtk.c @@ -40,7 +40,6 @@ #include "glade-cell-renderer-editor.h" #include "glade-treeview-editor.h" #include "glade-entry-editor.h" -#include "glade-gtk-activatable.h" #include "glade-activatable-editor.h" #include "glade-tool-item-group-editor.h" #include "glade-string-list.h" @@ -694,7 +693,7 @@ glade_gtk_widget_write_widget (GladeWidgetAdaptor * adaptor, GladeWidget * widget, GladeXmlContext * context, GladeXmlNode * node) { - GObject *obj; + GladeProperty *prop; if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) || glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE))) @@ -702,20 +701,13 @@ glade_gtk_widget_write_widget (GladeWidgetAdaptor * adaptor, /* Make sure use-action-appearance and related-action properties are * ordered in a sane way and are only saved if there is an action */ - if ((obj = glade_widget_get_object (widget)) && - GTK_IS_ACTIVATABLE (obj) && - gtk_activatable_get_related_action (GTK_ACTIVATABLE (obj))) - { - GladeProperty *prop; + prop = glade_widget_get_property (widget, "use-action-appearance"); + if (prop) + glade_property_write (prop, context, node); - prop = glade_widget_get_property (widget, "use-action-appearance"); - if (prop) - glade_property_write (prop, context, node); - - prop = glade_widget_get_property (widget, "related-action"); - if (prop) - glade_property_write (prop, context, node); - } + prop = glade_widget_get_property (widget, "related-action"); + if (prop) + glade_property_write (prop, context, node); /* First chain up and read in all the normal properties.. */ GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node); @@ -3717,19 +3709,10 @@ GladeEditable * glade_gtk_button_create_editable (GladeWidgetAdaptor * adaptor, GladeEditorPageType type) { - GladeEditable *editable; - - /* Get base editable */ - editable = - GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type); - if (type == GLADE_PAGE_GENERAL) - { - editable = - (GladeEditable *) glade_activatable_editor_new (adaptor, editable); - return (GladeEditable *) glade_button_editor_new (adaptor, editable); - } - return editable; + return (GladeEditable *) glade_button_editor_new (adaptor, NULL); + + return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type); } static void @@ -3769,11 +3752,7 @@ glade_gtk_button_post_create (GladeWidgetAdaptor * adaptor, glade_widget_property_set_sensitive (gbutton, "response-id", FALSE, RESPID_INSENSITIVE_MSG); - if (reason == GLADE_CREATE_LOAD) - g_signal_connect (glade_widget_get_project (gbutton), "parse-finished", - G_CALLBACK (glade_gtk_activatable_parse_finished), - gbutton); - else if (reason == GLADE_CREATE_USER) + if (reason == GLADE_CREATE_USER) glade_gtk_button_update_stock (gbutton); } @@ -3785,8 +3764,6 @@ glade_gtk_button_set_property (GladeWidgetAdaptor * adaptor, GladeWidget *widget = glade_widget_get_from_gobject (object); GladeProperty *property = glade_widget_get_property (widget, id); - glade_gtk_activatable_evaluate_property_sensitivity (object, id, value); - if (strcmp (id, "custom-child") == 0) { GtkWidget *child = gtk_bin_get_child (GTK_BIN (object)); @@ -4123,15 +4100,10 @@ GladeEditable * glade_gtk_recent_chooser_menu_create_editable (GladeWidgetAdaptor * adaptor, GladeEditorPageType type) { - GladeEditable *editable; - - /* Get base editable */ - editable = GWA_GET_CLASS (GTK_TYPE_MENU)->create_editable (adaptor, type); - if (type == GLADE_PAGE_GENERAL) - return (GladeEditable *) glade_activatable_editor_new (adaptor, editable); + return (GladeEditable *) glade_activatable_editor_new (adaptor, NULL); - return editable; + return GWA_GET_CLASS (GTK_TYPE_MENU)->create_editable (adaptor, type); } void @@ -4142,8 +4114,6 @@ glade_gtk_recent_chooser_menu_set_property (GladeWidgetAdaptor * adaptor, GladeWidget *widget = glade_widget_get_from_gobject (object); GladeProperty *property = glade_widget_get_property (widget, id); - glade_gtk_activatable_evaluate_property_sensitivity (object, id, value); - if (GPC_VERSION_CHECK (glade_property_get_class (property), gtk_major_version, gtk_minor_version + 1)) GWA_GET_CLASS (GTK_TYPE_MENU)->set_property (adaptor, object, id, value); } @@ -4748,16 +4718,10 @@ GladeEditable * glade_gtk_activatable_create_editable (GladeWidgetAdaptor * adaptor, GladeEditorPageType type) { - GladeEditable *editable; - - /* Get base editable */ - editable = - GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type); - if (type == GLADE_PAGE_GENERAL) - return (GladeEditable *) glade_activatable_editor_new (adaptor, editable); + return (GladeEditable *) glade_activatable_editor_new (adaptor, NULL); - return editable; + return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type); } void @@ -4829,11 +4793,6 @@ glade_gtk_menu_item_post_create (GladeWidgetAdaptor * adaptor, gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_container_add (GTK_CONTAINER (object), label); } - - if (reason == GLADE_CREATE_LOAD) - g_signal_connect (G_OBJECT (glade_widget_get_project (gitem)), "parse-finished", - G_CALLBACK (glade_gtk_activatable_parse_finished), - gitem); } GList * @@ -4955,8 +4914,6 @@ glade_gtk_menu_item_set_property (GladeWidgetAdaptor * adaptor, GladeWidget *gwidget = glade_widget_get_from_gobject (object); GladeProperty *property = glade_widget_get_property (gwidget, id); - glade_gtk_activatable_evaluate_property_sensitivity (object, id, value); - if (!strcmp (id, "use-underline")) glade_gtk_menu_item_set_use_underline (object, value); else if (!strcmp (id, "label")) @@ -5965,11 +5922,6 @@ glade_gtk_tool_item_post_create (GladeWidgetAdaptor *adaptor, if (reason == GLADE_CREATE_USER && gtk_bin_get_child (GTK_BIN (object)) == NULL) gtk_container_add (GTK_CONTAINER (object), glade_placeholder_new ()); - - if (reason == GLADE_CREATE_LOAD) - g_signal_connect (G_OBJECT (glade_widget_get_project (gitem)), "parse-finished", - G_CALLBACK (glade_gtk_activatable_parse_finished), - gitem); } void @@ -5980,7 +5932,6 @@ glade_gtk_tool_item_set_property (GladeWidgetAdaptor * adaptor, GladeWidget *gwidget = glade_widget_get_from_gobject (object); GladeProperty *property = glade_widget_get_property (gwidget, id); - glade_gtk_activatable_evaluate_property_sensitivity (object, id, value); 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, diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in index 9fa8b32b..94937174 100644 --- a/plugins/gtk+/gtk+.xml.in +++ b/plugins/gtk+/gtk+.xml.in @@ -556,8 +556,13 @@ embedded in another object</_tooltip> <property id="use-underline" _name="Use Underline" since="2.16"/> <!-- GtkActivatable --> - <property id="related-action" _name="Related Action" custom-layout="True" since="2.16" save="False" needs-sync="True"/> - <property id="use-action-appearance" _name="Use Action Appearance" save="False" custom-layout="True" needs-sync="True" since="2.16" default="False"/> + <property id="related-action" _name="Related Action" custom-layout="True" since="2.16" save="False" needs-sync="True" + optional="True" optional-default="False"/> + <property id="use-action-appearance" _name="Use Action Appearance" save="False" custom-layout="True" needs-sync="True" + since="2.16" default="False" optional="True" optional-default="False"/> + + <!-- GtkActionable --> + <property id="action-name" _name="Action Name" custom-layout="True" since="3.4"/> <!-- Atk click property --> <property id="atk-click" _name="Click" ignore="True" atk-property="True" save="False" @@ -785,8 +790,10 @@ embedded in another object</_tooltip> <properties> <!-- GtkActivatable --> - <property id="related-action" _name="Related Action" custom-layout="True" since="2.16" save="False" needs-sync="True"/> - <property id="use-action-appearance" _name="Use Action Appearance" custom-layout="True" save="False" needs-sync="True" since="2.16" default="False"/> + <property id="related-action" _name="Related Action" custom-layout="True" since="2.16" save="False" needs-sync="True" + optional="True" optional-default="False"/> + <property id="use-action-appearance" _name="Use Action Appearance" custom-layout="True" save="False" needs-sync="True" + since="2.16" default="False" optional="True" optional-default="False"/> </properties> </glade-widget-class> @@ -799,6 +806,10 @@ embedded in another object</_tooltip> <set-property-function>glade_gtk_tool_button_set_property</set-property-function> <read-widget-function>glade_gtk_tool_button_read_widget</read-widget-function> <properties> + + <!-- GtkActionable --> + <property id="action-name" _name="Action Name" custom-layout="True" since="3.4"/> + <!-- Virtual label type property --> <property id="custom-label" visible="False" save="False"> <parameter-spec> @@ -1114,8 +1125,13 @@ embedded in another object</_tooltip> </property> <!-- GtkActivatable --> - <property id="related-action" _name="Related Action" custom-layout="True" since="2.16" save="False" needs-sync="True"/> - <property id="use-action-appearance" _name="Use Action Appearance" custom-layout="True" save="False" needs-sync="True" since="2.16" default="False"/> + <property id="related-action" _name="Related Action" custom-layout="True" since="2.16" save="False" needs-sync="True" + optional="True" optional-default="False"/> + <property id="use-action-appearance" _name="Use Action Appearance" custom-layout="True" save="False" needs-sync="True" + since="2.16" default="False" optional="True" optional-default="False"/> + + <!-- GtkActionable --> + <property id="action-name" _name="Action Name" custom-layout="True" since="3.4"/> <!-- Atk click property --> <property id="atk-click" _name="Click" ignore="True" atk-property="True" save="False" multiline="True"> @@ -1198,18 +1214,24 @@ embedded in another object</_tooltip> <glade-widget-class name="GtkSwitch" generic-name="switch" _title="Switch"> <post-create-function>glade_gtk_switch_post_create</post-create-function> - <set-property-function>glade_gtk_switch_set_property</set-property-function> <create-editable-function>glade_gtk_switch_create_editable</create-editable-function> <properties> + <!-- GtkActivatable --> - <property id="related-action" _name="Related Action" custom-layout="True" save="False" needs-sync="True"> + <property id="related-action" _name="Related Action" custom-layout="True" save="False" needs-sync="True" + optional="True" optional-default="False"> <parameter-spec> <type>GParamObject</type> <value-type>GtkToggleAction</value-type> </parameter-spec> </property> - <property id="use-action-appearance" _name="Use Action Appearance" custom-layout="True" save="False" needs-sync="True" default="False"/> + <property id="use-action-appearance" _name="Use Action Appearance" custom-layout="True" save="False" needs-sync="True" + default="False" optional="True" optional-default="False"/> </properties> + + <!-- GtkActionable --> + <property id="action-name" _name="Action Name" custom-layout="True" since="3.4"/> + </glade-widget-class> <glade-widget-class name="GtkFileChooserButton" generic-name="filechooserbutton" _title="File Chooser Button"> diff --git a/po/POTFILES.in b/po/POTFILES.in index 57623769..7702f0b2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -54,6 +54,7 @@ gladeui/icon-naming-spec.c # gtk plugin backend plugins/gtk+/glade-accels.c plugins/gtk+/glade-activatable-editor.c +[type: gettext/glade]plugins/gtk+/glade-activatable-editor.ui plugins/gtk+/glade-attributes.c plugins/gtk+/glade-button-editor.c [type: gettext/glade]plugins/gtk+/glade-button-editor.ui |