[gedit] Override the label property instead of redefining it



commit 7d85f53fb71e07ced2e4f0b112ddc04ef767f5c5
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Apr 28 16:57:16 2013 +0200

    Override the label property instead of redefining it

 gedit/gedit-status-combo-box.c |   44 ++++++++++++---------------------------
 gedit/gedit-status-combo-box.h |    4 ---
 gedit/gedit-window.c           |    6 +---
 3 files changed, 16 insertions(+), 38 deletions(-)
---
diff --git a/gedit/gedit-status-combo-box.c b/gedit/gedit-status-combo-box.c
index b589dbe..efecd2e 100644
--- a/gedit/gedit-status-combo-box.c
+++ b/gedit/gedit-status-combo-box.c
@@ -56,6 +56,19 @@ gedit_status_combo_box_finalize (GObject *object)
 }
 
 static void
+gedit_status_combo_box_set_label (GeditStatusComboBox *combo,
+                                 const gchar         *label)
+{
+       gtk_label_set_markup (GTK_LABEL (combo->priv->label), label);
+}
+
+static const gchar *
+gedit_status_combo_box_get_label (GeditStatusComboBox *combo)
+{
+       return gtk_label_get_label (GTK_LABEL (combo->priv->label));
+}
+
+static void
 gedit_status_combo_box_get_property (GObject    *object,
                                     guint       prop_id,
                                     GValue     *value,
@@ -111,12 +124,7 @@ gedit_status_combo_box_class_init (GeditStatusComboBoxClass *klass)
        object_class->get_property = gedit_status_combo_box_get_property;
        object_class->set_property = gedit_status_combo_box_set_property;
 
-       g_object_class_install_property (object_class, PROP_LABEL,
-                                        g_param_spec_string ("label",
-                                                             "LABEL",
-                                                             "The label",
-                                                             NULL,
-                                                             G_PARAM_READWRITE));
+       g_object_class_override_property (object_class, PROP_LABEL, "label");
 
        g_type_class_add_private (object_class, sizeof (GeditStatusComboBoxPrivate));
 
@@ -168,8 +176,6 @@ gedit_status_combo_box_init (GeditStatusComboBox *self)
                                        GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 }
 
-/* public functions */
-
 /**
  * gedit_status_combo_box_new:
  * @label: (allow-none):
@@ -180,26 +186,4 @@ gedit_status_combo_box_new (const gchar *label)
        return g_object_new (GEDIT_TYPE_STATUS_COMBO_BOX, "label", label, NULL);
 }
 
-/**
- * gedit_status_combo_box_set_label:
- * @combo:
- * @label: (allow-none):
- */
-void
-gedit_status_combo_box_set_label (GeditStatusComboBox *combo,
-                                 const gchar         *label)
-{
-       g_return_if_fail (GEDIT_IS_STATUS_COMBO_BOX (combo));
-
-       gtk_label_set_markup (GTK_LABEL (combo->priv->label), label);
-}
-
-const gchar *
-gedit_status_combo_box_get_label (GeditStatusComboBox *combo)
-{
-       g_return_val_if_fail (GEDIT_IS_STATUS_COMBO_BOX (combo), NULL);
-
-       return gtk_label_get_label (GTK_LABEL (combo->priv->label));
-}
-
 /* ex:set ts=8 noet: */
diff --git a/gedit/gedit-status-combo-box.h b/gedit/gedit-status-combo-box.h
index 24cc06e..ea57091 100644
--- a/gedit/gedit-status-combo-box.h
+++ b/gedit/gedit-status-combo-box.h
@@ -61,10 +61,6 @@ GType gedit_status_combo_box_get_type                        (void) G_GNUC_CONST;
 
 GtkWidget *gedit_status_combo_box_new                  (const gchar            *label);
 
-const gchar *gedit_status_combo_box_get_label          (GeditStatusComboBox    *combo);
-void gedit_status_combo_box_set_label                  (GeditStatusComboBox    *combo,
-                                                        const gchar            *label);
-
 G_END_DECLS
 
 #endif /* __GEDIT_STATUS_COMBO_BOX_H__ */
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index d63308f..6f5c593 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -2433,8 +2433,7 @@ tab_width_changed (GObject     *object,
        new_tab_width = gtk_source_view_get_tab_width (GTK_SOURCE_VIEW (object));
 
        label = g_strdup_printf (_("Tab Width: %u"), new_tab_width);
-       gedit_status_combo_box_set_label (GEDIT_STATUS_COMBO_BOX (window->priv->tab_width_combo),
-                                         label);
+       gtk_button_set_label (GTK_BUTTON (window->priv->tab_width_combo), label);
        g_free (label);
 
        for (item = items; item; item = item->next)
@@ -2483,8 +2482,7 @@ language_changed (GObject     *object,
        else
                label = _("Plain Text");
 
-       gedit_status_combo_box_set_label (GEDIT_STATUS_COMBO_BOX (window->priv->language_combo),
-                                         label);
+       gtk_button_set_label (GTK_BUTTON (window->priv->language_combo), label);
 }
 
 static void


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