[glade/ui-incubator] GladeEditorPropertyBoolClass replaced toggle button with a switch.



commit 1e09e9934069b9a15c9a92fbbc7a75007305c4b8
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Sat Oct 20 16:02:17 2012 -0700

    GladeEditorPropertyBoolClass replaced toggle button with a switch.

 gladeui/glade-editor-property.c |   36 ++++++++++++------------------------
 1 files changed, 12 insertions(+), 24 deletions(-)
---
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index 2bffc1c..22996c2 100644
--- a/gladeui/glade-editor-property.c
+++ b/gladeui/glade-editor-property.c
@@ -2230,7 +2230,7 @@ typedef struct
 {
   GladeEditorProperty parent_instance;
 
-  GtkWidget *toggle;
+  GtkWidget *gswitch;
 } GladeEPropBool;
 
 GLADE_MAKE_EPROP (GladeEPropBool, glade_eprop_bool)
@@ -2239,7 +2239,9 @@ GLADE_MAKE_EPROP (GladeEPropBool, glade_eprop_bool)
 #define GLADE_IS_EPROP_BOOL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_BOOL))
 #define GLADE_IS_EPROP_BOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_BOOL))
 #define GLADE_EPROP_BOOL_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_EPROP_BOOL, GladeEPropBoolClass))
-     static void glade_eprop_bool_finalize (GObject *object)
+
+static void
+glade_eprop_bool_finalize (GObject *object)
 {
   /* Chain up */
   G_OBJECT_CLASS (editor_property_class)->finalize (object);
@@ -2248,41 +2250,27 @@ GLADE_MAKE_EPROP (GladeEPropBool, glade_eprop_bool)
 static void
 glade_eprop_bool_load (GladeEditorProperty *eprop, GladeProperty *property)
 {
-  GladeEPropBool *eprop_bool = GLADE_EPROP_BOOL (eprop);
-  GtkWidget *label;
-  gboolean state;
-
   /* Chain up first */
   editor_property_class->load (eprop, property);
 
   if (property)
     {
-      state = g_value_get_boolean (glade_property_inline_value (property));
-
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (eprop_bool->toggle),
-                                    state);
-
-      label = gtk_bin_get_child (GTK_BIN (eprop_bool->toggle));
-      gtk_label_set_text (GTK_LABEL (label), state ? _("Yes") : _("No"));
+      GladeEPropBool *eprop_bool = GLADE_EPROP_BOOL (eprop);
+      gboolean state = g_value_get_boolean (glade_property_inline_value (property));
+      gtk_switch_set_active (GTK_SWITCH (eprop_bool->gswitch), state);
     }
 }
 
 static void
-glade_eprop_bool_changed (GtkWidget *button, GladeEditorProperty *eprop)
+glade_eprop_bool_changed (GtkSwitch *gswitch, GladeEditorProperty *eprop)
 {
-  GtkWidget *label;
-  gboolean state;
   GValue val = { 0, };
 
   if (eprop->priv->loading)
     return;
 
-  state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
-  label = gtk_bin_get_child (GTK_BIN (button));
-  gtk_label_set_text (GTK_LABEL (label), state ? _("Yes") : _("No"));
-
   g_value_init (&val, G_TYPE_BOOLEAN);
-  g_value_set_boolean (&val, state);
+  g_value_set_boolean (&val, gtk_switch_get_active (gswitch));
 
   glade_editor_property_commit_no_callback (eprop, &val);
 
@@ -2294,12 +2282,12 @@ glade_eprop_bool_create_input (GladeEditorProperty *eprop)
 {
   GladeEPropBool *eprop_bool = GLADE_EPROP_BOOL (eprop);
 
-  eprop_bool->toggle = gtk_toggle_button_new_with_label (_("No"));
+  eprop_bool->gswitch = gtk_switch_new ();
 
-  g_signal_connect (G_OBJECT (eprop_bool->toggle), "toggled",
+  g_signal_connect (eprop_bool->gswitch, "activate",
                     G_CALLBACK (glade_eprop_bool_changed), eprop);
 
-  return eprop_bool->toggle;
+  return eprop_bool->gswitch;
 }
 
 



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