[glade] Added GladePropertyShell:disable-check proxy property and the corresponding accessors API. Simplifie



commit 02f61cef14f97dc6b18e8acc10beabf2a05bcf64
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Mon Apr 21 15:10:40 2014 -0300

    Added GladePropertyShell:disable-check proxy property and the corresponding accessors API.
    Simplified code in GtkAboutDialog editor using new API.

 gladeui/glade-editor-property.c           |   36 ++++++++++++----
 gladeui/glade-editor-property.h           |   65 +++++++++++++++--------------
 gladeui/glade-property-shell.c            |   51 +++++++++++++++++++++-
 gladeui/glade-property-shell.h            |    3 +
 plugins/gtk+/glade-about-dialog-editor.c  |   14 ------
 plugins/gtk+/glade-about-dialog-editor.ui |    2 +
 6 files changed, 114 insertions(+), 57 deletions(-)
---
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index 2ee292c..a598f13 100644
--- a/gladeui/glade-editor-property.c
+++ b/gladeui/glade-editor-property.c
@@ -227,6 +227,32 @@ glade_editor_property_get_custom_text (GladeEditorProperty *eprop)
   return eprop->priv->custom_text;
 }
 
+void
+glade_editor_property_set_disable_check (GladeEditorProperty *eprop,
+                                         gboolean             disable_check)
+{
+  GladeEditorPropertyPrivate *priv;
+
+  g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
+
+  priv = eprop->priv;
+
+  if (priv->disable_check != disable_check)
+    {
+      priv->disable_check = disable_check;
+      gtk_widget_set_visible (priv->check, !disable_check);
+      g_object_notify (G_OBJECT (eprop), "disable-check");
+    }
+}
+
+gboolean
+glade_editor_property_get_disable_check (GladeEditorProperty *eprop)
+{
+  g_return_val_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop), FALSE);
+
+  return eprop->priv->disable_check;
+}
+
 GtkWidget *
 glade_editor_property_get_item_label  (GladeEditorProperty *eprop)
 {
@@ -444,15 +470,7 @@ glade_editor_property_set_property (GObject      *object,
         eprop->priv->use_command = g_value_get_boolean (value);
         break;
       case PROP_DISABLE_CHECK:
-        eprop->priv->disable_check = g_value_get_boolean (value);
-
-       if (eprop->priv->check)
-         {
-           if (eprop->priv->disable_check)
-             gtk_widget_hide (eprop->priv->check);
-           else
-             gtk_widget_show (eprop->priv->check);
-         }
+        glade_editor_property_set_disable_check (eprop, g_value_get_boolean (value));
         break;
       case PROP_CUSTOM_TEXT:
        glade_editor_property_set_custom_text (eprop, g_value_get_string (value));
diff --git a/gladeui/glade-editor-property.h b/gladeui/glade-editor-property.h
index f7dd553..8f7c8e4 100644
--- a/gladeui/glade-editor-property.h
+++ b/gladeui/glade-editor-property.h
@@ -97,42 +97,45 @@ struct _GladeEditorPropertyClass {
 
 
 
-GType                glade_editor_property_get_type       (void) G_GNUC_CONST;
+GType                glade_editor_property_get_type           (void) G_GNUC_CONST;
 
-void                 glade_editor_property_load           (GladeEditorProperty *eprop,
-                                                          GladeProperty       *property);
+void                 glade_editor_property_load               (GladeEditorProperty *eprop,
+                                                              GladeProperty       *property);
 
-void                 glade_editor_property_load_by_widget (GladeEditorProperty *eprop,
-                                                          GladeWidget         *widget);
+void                 glade_editor_property_load_by_widget     (GladeEditorProperty *eprop,
+                                                              GladeWidget         *widget);
 
-void                 glade_editor_property_commit         (GladeEditorProperty *eprop,
-                                                          GValue              *value);
+void                 glade_editor_property_commit             (GladeEditorProperty *eprop,
+                                                              GValue              *value);
 void                 glade_editor_property_commit_no_callback (GladeEditorProperty *eprop,
                                                               GValue              *value);
-void                 glade_editor_property_set_custom_text(GladeEditorProperty *eprop,
-                                                          const gchar         *custom_text);
-const gchar         *glade_editor_property_get_custom_text(GladeEditorProperty *eprop);
-
-GtkWidget           *glade_editor_property_get_item_label  (GladeEditorProperty *eprop);
-GladePropertyClass  *glade_editor_property_get_pclass      (GladeEditorProperty *eprop);
-GladeProperty       *glade_editor_property_get_property    (GladeEditorProperty *eprop);
-gboolean             glade_editor_property_loading         (GladeEditorProperty *eprop);
-
-gboolean             glade_editor_property_show_i18n_dialog (GtkWidget            *parent,
-                                                            gchar               **text,
-                                                            gchar               **context,
-                                                            gchar               **comment,
-                                                            gboolean             *translatable);
-gboolean             glade_editor_property_show_resource_dialog (GladeProject     *project, 
-                                                                GtkWidget        *parent, 
-                                                                gchar           **filename);
-
-gboolean             glade_editor_property_show_object_dialog (GladeProject       *project,
-                                                              const gchar        *title,
-                                                              GtkWidget          *parent, 
-                                                              GType               object_type,
-                                                              GladeWidget        *exception,
-                                                              GladeWidget       **object);
+void                 glade_editor_property_set_custom_text    (GladeEditorProperty *eprop,
+                                                               const gchar         *custom_text);
+const gchar         *glade_editor_property_get_custom_text    (GladeEditorProperty *eprop);
+void                 glade_editor_property_set_disable_check  (GladeEditorProperty *eprop,
+                                                               gboolean             disable_check);
+gboolean             glade_editor_property_get_disable_check  (GladeEditorProperty *eprop);
+
+GtkWidget           *glade_editor_property_get_item_label     (GladeEditorProperty *eprop);
+GladePropertyClass  *glade_editor_property_get_pclass         (GladeEditorProperty *eprop);
+GladeProperty       *glade_editor_property_get_property       (GladeEditorProperty *eprop);
+gboolean             glade_editor_property_loading            (GladeEditorProperty *eprop);
+
+gboolean             glade_editor_property_show_i18n_dialog     (GtkWidget         *parent,
+                                                                 gchar            **text,
+                                                                 gchar            **context,
+                                                                 gchar            **comment,
+                                                                 gboolean          *translatable);
+gboolean             glade_editor_property_show_resource_dialog (GladeProject      *project, 
+                                                                GtkWidget         *parent, 
+                                                                gchar            **filename);
+
+gboolean             glade_editor_property_show_object_dialog   (GladeProject      *project,
+                                                                 const gchar       *title,
+                                                                 GtkWidget         *parent, 
+                                                                 GType              object_type,
+                                                                 GladeWidget       *exception,
+                                                                 GladeWidget      **object);
 
 /* Generic eprops */
 #define GLADE_TYPE_EPROP_NUMERIC         (glade_eprop_numeric_get_type())
diff --git a/gladeui/glade-property-shell.c b/gladeui/glade-property-shell.c
index 3708a25..6b034cd 100644
--- a/gladeui/glade-property-shell.c
+++ b/gladeui/glade-property-shell.c
@@ -60,6 +60,7 @@ struct _GladePropertyShellPrivate
   gchar               *custom_text;
   guint                packing : 1;
   guint                use_command : 1;
+  guint                disable_check : 1;
 };
 
 enum {
@@ -68,7 +69,8 @@ enum {
   PROP_PACKING,
   PROP_USE_COMMAND,
   PROP_EDITOR_TYPE,
-  PROP_CUSTOM_TEXT
+  PROP_CUSTOM_TEXT,
+  PROP_DISABLE_CHECK
 };
 
 enum
@@ -94,6 +96,7 @@ glade_property_shell_init (GladePropertyShell *shell)
 
   shell->priv->packing = FALSE;
   shell->priv->use_command = TRUE;
+  shell->priv->disable_check = FALSE;
 }
 
 static void
@@ -134,7 +137,13 @@ glade_property_shell_class_init (GladePropertyShellClass *klass)
        g_param_spec_string ("custom-text", _("Custom Text"),
                            _("Custom Text to display in the property label"),
                            NULL, G_PARAM_READWRITE));
-
+  
+  g_object_class_install_property
+      (gobject_class, PROP_DISABLE_CHECK,
+       g_param_spec_boolean ("disable-check", _("Disable Check"),
+                            _("Whether to explicitly disable the check button"),
+                            FALSE, G_PARAM_READWRITE));
+  
   /**
    * GladePropertyShell::pre-commit:
    * @gladeeditorproperty: the #GladeEditorProperty which changed value
@@ -220,6 +229,9 @@ glade_property_shell_set_real_property (GObject      *object,
     case PROP_CUSTOM_TEXT:
       glade_property_shell_set_custom_text (shell, g_value_get_string (value));
       break;
+    case PROP_DISABLE_CHECK:
+      glade_property_shell_set_disable_check (shell, g_value_get_boolean (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -248,6 +260,9 @@ glade_property_shell_get_real_property (GObject    *object,
     case PROP_CUSTOM_TEXT:
       g_value_set_string (value, glade_property_shell_get_custom_text (shell));
       break;
+    case PROP_DISABLE_CHECK:
+      g_value_set_boolean (value, glade_property_shell_get_disable_check (shell));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -296,7 +311,8 @@ glade_property_shell_set_eprop (GladePropertyShell  *shell,
       if (priv->property_editor)
        {
          glade_editor_property_set_custom_text (priv->property_editor, priv->custom_text);
-
+          glade_editor_property_set_disable_check (priv->property_editor, priv->disable_check);
+            
          priv->pre_commit_id = g_signal_connect (priv->property_editor, "commit",
                                                  G_CALLBACK (propagate_pre_commit), shell);
          priv->post_commit_id = g_signal_connect_after (priv->property_editor, "commit",
@@ -521,3 +537,32 @@ glade_property_shell_get_use_command (GladePropertyShell *shell)
 
   return shell->priv->use_command;
 }
+
+void
+glade_property_shell_set_disable_check (GladePropertyShell *shell,
+                                        gboolean            disable_check)
+{
+  GladePropertyShellPrivate *priv;
+
+  g_return_if_fail (GLADE_IS_PROPERTY_SHELL (shell));
+
+  priv = shell->priv;
+
+  if (priv->disable_check != disable_check)
+    {
+      priv->disable_check = disable_check;
+
+      if (priv->property_editor)
+       g_object_set (priv->property_editor, "disable-check", disable_check, NULL);
+
+      g_object_notify (G_OBJECT (shell), "disable-check");
+    }
+}
+
+gboolean
+glade_property_shell_get_disable_check (GladePropertyShell *shell)
+{
+  g_return_val_if_fail (GLADE_IS_PROPERTY_SHELL (shell), FALSE);
+
+  return shell->priv->disable_check;
+}
diff --git a/gladeui/glade-property-shell.h b/gladeui/glade-property-shell.h
index baace4b..d7bfa35 100644
--- a/gladeui/glade-property-shell.h
+++ b/gladeui/glade-property-shell.h
@@ -68,6 +68,9 @@ gboolean       glade_property_shell_get_packing       (GladePropertyShell *shell
 void           glade_property_shell_set_use_command   (GladePropertyShell *shell,
                                                       gboolean            use_command);
 gboolean       glade_property_shell_get_use_command   (GladePropertyShell *shell);
+void           glade_property_shell_set_disable_check (GladePropertyShell *shell,
+                                                       gboolean            disable_check);
+gboolean       glade_property_shell_get_disable_check (GladePropertyShell *shell);
 
 G_END_DECLS
 
diff --git a/plugins/gtk+/glade-about-dialog-editor.c b/plugins/gtk+/glade-about-dialog-editor.c
index 696d1a5..8d8ab4e 100644
--- a/plugins/gtk+/glade-about-dialog-editor.c
+++ b/plugins/gtk+/glade-about-dialog-editor.c
@@ -45,8 +45,6 @@ struct _GladeAboutDialogEditorPrivate
   GtkWidget *license_label;
   GtkWidget *license_editor;
   GtkWidget *wrap_license_editor;
-  GtkWidget *logo_file_editor;
-  GtkWidget *logo_icon_editor;
 
   GtkWidget *logo_file_radio;
   GtkWidget *logo_icon_radio;
@@ -69,8 +67,6 @@ glade_about_dialog_editor_class_init (GladeAboutDialogEditorClass * klass)
   gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, license_label);
   gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, license_editor);
   gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, wrap_license_editor);
-  gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, logo_file_editor);
-  gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, logo_icon_editor);
   gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, logo_file_radio);
   gtk_widget_class_bind_template_child_private (widget_class, GladeAboutDialogEditor, logo_icon_radio);
 
@@ -89,13 +85,6 @@ glade_about_dialog_editor_init (GladeAboutDialogEditor *self)
 }
 
 static void
-glade_eprop_disable_check (GtkWidget *child, gpointer data)
-{
-  if (GLADE_IS_EDITOR_PROPERTY (child))
-    g_object_set (child, "disable-check", TRUE, NULL);
-}
-
-static void
 glade_about_dialog_editor_load (GladeEditable *editable, GladeWidget *widget)
 {
   GladeAboutDialogEditor *dialog_editor = GLADE_ABOUT_DIALOG_EDITOR (editable);
@@ -120,9 +109,6 @@ glade_about_dialog_editor_load (GladeEditable *editable, GladeWidget *widget)
 
       /* Set the radio button state to our virtual property */
       glade_widget_property_get (widget, "glade-logo-as-file", &as_file);
-
-      gtk_container_forall (GTK_CONTAINER (priv->logo_file_editor), glade_eprop_disable_check, NULL);
-      gtk_container_forall (GTK_CONTAINER (priv->logo_icon_editor), glade_eprop_disable_check, NULL);
       
       glade_widget_property_set_enabled (widget, "logo-icon-name", !as_file);
       glade_widget_property_set_enabled (widget, "logo", as_file);
diff --git a/plugins/gtk+/glade-about-dialog-editor.ui b/plugins/gtk+/glade-about-dialog-editor.ui
index f06ebfd..9c9f97f 100644
--- a/plugins/gtk+/glade-about-dialog-editor.ui
+++ b/plugins/gtk+/glade-about-dialog-editor.ui
@@ -253,6 +253,7 @@ Author: Tristan Van Berkom <tvb gnome org>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="hexpand">False</property>
+                <property name="disable_check">True</property>
                 <property name="property_name">logo-icon-name</property>
               </object>
               <packing>
@@ -267,6 +268,7 @@ Author: Tristan Van Berkom <tvb gnome org>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="hexpand">False</property>
+                <property name="disable_check">True</property>
                 <property name="property_name">logo</property>
               </object>
               <packing>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]