]> saetta.ns0.it Git - libgtkdateentry/commitdiff
Added properties to GObject.
authorAndrea Zagli <azagli@libero.it>
Sat, 30 Apr 2011 11:37:07 +0000 (13:37 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 30 Apr 2011 11:37:07 +0000 (13:37 +0200)
glade/gtkdateentry.xml
src/gtkdateentry.c
tests/date_entry.c

index b263365561720f6745bb042a1a5a5be8860b27b3..4c3b22a41eaa31ccd89e5b1a74f8cb7a62e4dfb7 100644 (file)
@@ -4,11 +4,14 @@
        <glade-widget-classes>
                <glade-widget-class name="GtkDateEntry" generic-name="gtkdateentry" title="Date Entry">
                        <properties>
-                               <property name="Editable with calendar" id="editable_with_calendar" />
+                               <property name="Separator" id="separator" />
+                               <property name="Format" id="format" />
+                               <property name="Editable only from calendar" id="editable-from-calendar" />
+                               <property name="Calendar's button visible" id="calendar-button-visible" />
                        </properties>
                </glade-widget-class>
        </glade-widget-classes>
-  
+
        <glade-widget-group name="gtk-control-display" title="Control and Display">
                <glade-widget-class-ref name="GtkDateEntry" />
        </glade-widget-group>
index eeb59799c41d5e4029069c14521b0fed9cd8f41b..6dc7a561f5d0f36c1e600326ef83ba508abfa921 100644 (file)
 enum
 {
        PROP_0,
-       PROP_EDITABLE_WITH_CALENDAR
+       PROP_SEPARATOR,
+       PROP_FORMAT,
+       PROP_EDITABLE_WITH_CALENDAR,
+       PROP_CALENDAR_BUTTON_VISIBLE
 };
 
 static void gtk_date_entry_class_init (GtkDateEntryClass *klass);
@@ -115,13 +118,34 @@ gtk_date_entry_class_init (GtkDateEntryClass *klass)
        widget_class->size_request = gtk_date_entry_size_request;
        widget_class->size_allocate = gtk_date_entry_size_allocate;
 
+       g_object_class_install_property (object_class, PROP_SEPARATOR,
+                                        g_param_spec_string ("separator",
+                                                             "The separator",
+                                                             "The separator between day, month and year",
+                                                             "",
+                                                             G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_FORMAT,
+                                        g_param_spec_string ("format",
+                                                             "The date's format",
+                                                             "The date's format",
+                                                             "",
+                                                             G_PARAM_READWRITE));
+
        g_object_class_install_property (object_class, PROP_EDITABLE_WITH_CALENDAR,
-                                        g_param_spec_boolean ("editable-with-calendar",
+                                        g_param_spec_boolean ("editable-from-calendar",
                                                               "TRUE if it is editable only from calendar",
                                                               "Determines if the user can edit the text"
                                                               " in the #GtkDateEntry widget only from the calendar or not",
                                                               FALSE,
                                                               G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_CALENDAR_BUTTON_VISIBLE,
+                                        g_param_spec_boolean ("calendar-button-visible",
+                                                              "TRUE to show the calendar's button",
+                                                              "Determines if the calendar's button is visible or not",
+                                                              TRUE,
+                                                              G_PARAM_READWRITE));
 }
 
 static void
@@ -937,10 +961,22 @@ gtk_date_entry_set_property (GObject *object, guint property_id, const GValue *v
 
        switch (property_id)
                {
+                       case PROP_SEPARATOR:
+                               gtk_date_entry_set_separator (date_entry, g_value_get_string (value));
+                               break;
+
+                       case PROP_FORMAT:
+                               gtk_date_entry_set_format (date_entry, g_value_get_string (value));
+                               break;
+
                        case PROP_EDITABLE_WITH_CALENDAR:
                                gtk_date_entry_set_editable_with_calendar (date_entry, g_value_get_boolean (value));
                                break;
 
+                       case PROP_CALENDAR_BUTTON_VISIBLE:
+                               gtk_date_entry_set_calendar_button_visible (date_entry, g_value_get_boolean (value));
+                               break;
+
                        default:
                                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                                break;
@@ -956,10 +992,22 @@ gtk_date_entry_get_property (GObject *object, guint property_id, GValue *value,
 
        switch (property_id)
                {
+                       case PROP_SEPARATOR:
+                               g_value_set_string (value, priv->separator);
+                               break;
+
+                       case PROP_FORMAT:
+                               g_value_set_string (value, priv->format);
+                               break;
+
                        case PROP_EDITABLE_WITH_CALENDAR:
                                g_value_set_boolean (value, priv->editable_with_calendar);
                                break;
 
+                       case PROP_CALENDAR_BUTTON_VISIBLE:
+                               g_value_set_boolean (value, gtk_widget_get_visible (priv->btnCalendar));
+                               break;
+
                        default:
                                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                                break;
index f3bbc807932353a59c0994c449a810a8c7c13ba3..f841c198ac15693fe2d0f718bb07c9d480bef18d 100644 (file)
@@ -90,12 +90,12 @@ on_tbtnEditableWithCalendar_toggled (GtkToggleButton *togglebutton,
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tbtnEditableWithCalendar)))
                {
                        gtk_date_entry_set_editable_with_calendar (GTK_DATE_ENTRY (date), TRUE);
-                       gtk_button_set_label (GTK_BUTTON (tbtnEditableWithCalendar), "Editable only with calendar");
+                       gtk_button_set_label (GTK_BUTTON (tbtnEditableWithCalendar), "Editable only from calendar");
                }
        else
                {
                        gtk_date_entry_set_editable_with_calendar (GTK_DATE_ENTRY (date), FALSE);
-                       gtk_button_set_label (GTK_BUTTON (tbtnEditableWithCalendar), "Editable also with calendar");
+                       gtk_button_set_label (GTK_BUTTON (tbtnEditableWithCalendar), "Editable also from calendar");
                }
 }
 
@@ -197,7 +197,7 @@ main (int argc, char **argv)
        g_signal_connect (G_OBJECT (tbtnEditable), "toggled",
                          G_CALLBACK (on_tbtnEditable_toggled), NULL);
 
-       tbtnEditableWithCalendar = gtk_toggle_button_new_with_label ("Editable also with calendar");
+       tbtnEditableWithCalendar = gtk_toggle_button_new_with_label ("Editable also from calendar");
        gtk_table_attach (GTK_TABLE (table), tbtnEditableWithCalendar, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
        gtk_widget_show (tbtnEditableWithCalendar);