From: Andrea Zagli Date: Tue, 31 May 2011 17:17:59 +0000 (+0200) Subject: Started developing of time part of the widget. X-Git-Tag: v.gtk2~12^2~2 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=6a999473ed2c2db65805f2c4ee91ecf504a16eae;p=libgtkdateentry Started developing of time part of the widget. --- diff --git a/src/gtkdateentry.c b/src/gtkdateentry.c index a242f30..7f445c9 100644 --- a/src/gtkdateentry.c +++ b/src/gtkdateentry.c @@ -43,6 +43,7 @@ enum { PROP_0, PROP_SEPARATOR, + PROP_TIME_SEPARATOR, PROP_FORMAT, PROP_EDITABLE_WITH_CALENDAR, PROP_CALENDAR_BUTTON_VISIBLE @@ -102,7 +103,14 @@ struct _GtkDateEntryPrivate GtkWidget *wCalendar; GtkWidget *calendar; + GtkWidget *spnHours; + GtkWidget *lblMinutes; + GtkWidget *spnMinutes; + GtkWidget *lblSeconds; + GtkWidget *spnSeconds; + gchar *separator; + gchar *time_separator; gchar *format; gboolean editable_with_calendar; }; @@ -130,14 +138,21 @@ gtk_date_entry_class_init (GtkDateEntryClass *klass) g_object_class_install_property (object_class, PROP_SEPARATOR, g_param_spec_string ("separator", "The separator", - "The separator between day, month and year", + "The separator between day, month and year.", + "", + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_TIME_SEPARATOR, + g_param_spec_string ("time-separator", + "The time separator", + "The separator between hours, minutes and seconds.", "", 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", + "The date's format.", "", G_PARAM_READWRITE)); @@ -145,14 +160,14 @@ gtk_date_entry_class_init (GtkDateEntryClass *klass) 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", + " 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", + "Determines if the calendar's button is visible or not.", TRUE, G_PARAM_READWRITE)); } @@ -165,6 +180,7 @@ gtk_date_entry_init (GtkDateEntry *date) GtkDateEntryPrivate *priv = GTK_DATE_ENTRY_GET_PRIVATE (date); priv->separator = gtk_date_entry_get_separator_from_locale (); + priv->time_separator = ":"; priv->format = gtk_date_entry_get_format_from_locale (); priv->hbox = gtk_hbox_new (FALSE, 0); @@ -210,6 +226,25 @@ gtk_date_entry_init (GtkDateEntry *date) G_CALLBACK (calendar_on_day_selected), (gpointer)date); g_signal_connect (G_OBJECT (priv->calendar), "day-selected-double-click", G_CALLBACK (calendar_on_day_selected_double_click), (gpointer)date); + + priv->spnHours = gtk_spin_button_new_with_range (0, 23, 1); + priv->lblMinutes = gtk_label_new (":"); + priv->spnMinutes = gtk_spin_button_new_with_range (0, 59, 1); + priv->lblSeconds = gtk_label_new (":"); + priv->spnSeconds = gtk_spin_button_new_with_range (0, 59, 1); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON (priv->spnHours), 0); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON (priv->spnMinutes), 0); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON (priv->spnSeconds), 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->spnHours, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->lblMinutes, TRUE, TRUE, 3); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->spnMinutes, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->lblSeconds, TRUE, TRUE, 3); + gtk_box_pack_start (GTK_BOX (priv->hbox), priv->spnSeconds, TRUE, TRUE, 0); + gtk_widget_show (priv->spnHours); + gtk_widget_show (priv->lblMinutes); + gtk_widget_show (priv->spnMinutes); + gtk_widget_show (priv->lblSeconds); + gtk_widget_show (priv->spnSeconds); } /** @@ -277,6 +312,8 @@ gtk_date_entry_set_separator (GtkDateEntry *date, const gchar *separator) { gchar *_separator; + g_return_val_if_fail (GTK_IS_DATE_ENTRY (date), FALSE); + GDate *gdate = gtk_date_entry_get_gdate (date); GtkDateEntryPrivate *priv = GTK_DATE_ENTRY_GET_PRIVATE (date); @@ -298,6 +335,41 @@ gtk_date_entry_set_separator (GtkDateEntry *date, const gchar *separator) g_free (_separator); } +/** + * gtk_date_entry_set_time_separator: + * @date: a #GtkDateEntry object. + * @separator: a #gchar that represents the separator between hours, minutes and seconds. + * + * Set the separator between hours, minutes and seconds. + */ +gboolean +gtk_date_entry_set_time_separator (GtkDateEntry *date, const gchar *separator) +{ + gchar *_separator; + + g_return_val_if_fail (GTK_IS_DATE_ENTRY (date), FALSE); + + GDate *gdate = gtk_date_entry_get_gdate (date); + + GtkDateEntryPrivate *priv = GTK_DATE_ENTRY_GET_PRIVATE (date); + + if (separator == NULL) + { + return FALSE; + } + _separator = g_strstrip (g_strdup (separator)); + if (strlen (_separator) != 1) + { + return FALSE; + } + + priv->time_separator = g_strdup (_separator); + gtk_label_set_text (GTK_LABEL (priv->lblMinutes), _separator); + gtk_label_set_text (GTK_LABEL (priv->lblSeconds), _separator); + + g_free (_separator); +} + /** * gtk_date_entry_set_format: * @date: a #GtkDateEntry object. @@ -377,9 +449,26 @@ gtk_date_entry_set_format (GtkDateEntry *date, const gchar *format) const gchar *gtk_date_entry_get_text (GtkDateEntry *date) { - GtkDateEntryPrivate *priv = GTK_DATE_ENTRY_GET_PRIVATE (date); + gchar *ret; + + GtkDateEntryPrivate *priv; - return gtk_entry_get_text (GTK_ENTRY (priv->day)); + g_return_val_if_fail (GTK_IS_DATE_ENTRY (date), NULL); + + priv = GTK_DATE_ENTRY_GET_PRIVATE (date); + ret = (gchar *)gtk_entry_get_text (GTK_ENTRY (priv->day)); + + if (gtk_widget_get_visible (priv->spnHours)) + { + ret = g_strconcat (ret, + g_strdup_printf (" %02d:%02d:%02d", + gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->spnHours)), + gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->spnMinutes)), + gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->spnSeconds))), + NULL); + } + + return ret; } /** @@ -461,12 +550,26 @@ struct tm { struct tm tm; - const GDate *gdate = gtk_date_entry_get_gdate (date); + const GDate *gdate; + GtkDateEntryPrivate *priv; + + g_return_val_if_fail (GTK_IS_DATE_ENTRY (date), NULL); + + priv = GTK_DATE_ENTRY_GET_PRIVATE (date); + + gdate = gtk_date_entry_get_gdate (date); if (gdate == NULL) return NULL; g_date_to_struct_tm (gdate, &tm); + if (gtk_widget_get_visible (priv->spnHours)) + { + tm.tm_hour = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->spnHours)); + tm.tm_min = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->spnMinutes)); + tm.tm_sec = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->spnSeconds)); + } + return (struct tm *)g_memdup ((gconstpointer)&tm, sizeof (struct tm)); } @@ -624,10 +727,19 @@ gtk_date_entry_set_date_strf (GtkDateEntry *date, void gtk_date_entry_set_date_tm (GtkDateEntry *date, const struct tm tmdate) { + GtkDateEntryPrivate *priv; + + g_return_if_fail (GTK_IS_DATE_ENTRY (date)); + + priv = GTK_DATE_ENTRY_GET_PRIVATE (date); + GDate *gdate = g_date_new_dmy ((GDateDay)tmdate.tm_mday, (GDateMonth)tmdate.tm_mon + 1, (GDateYear)tmdate.tm_year + 1900); gtk_date_entry_set_date_gdate (date, (const GDate *)gdate); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spnHours), tmdate.tm_hour); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spnMinutes), tmdate.tm_min); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spnSeconds), tmdate.tm_sec); } /** @@ -712,6 +824,9 @@ gtk_date_entry_set_editable (GtkDateEntry *date, gtk_editable_set_editable (GTK_EDITABLE (priv->day), is_editable); gtk_widget_set_sensitive (priv->btnCalendar, is_editable); + gtk_widget_set_sensitive (priv->spnHours, is_editable); + gtk_widget_set_sensitive (priv->spnMinutes, is_editable); + gtk_widget_set_sensitive (priv->spnSeconds, is_editable); } /** @@ -755,6 +870,37 @@ gtk_date_entry_set_calendar_button_visible (GtkDateEntry *date, } } +/** + * gtk_date_entry_set_time_visible: + * @date: a #GtkDateEntry. + * @is_visible: TRUE if the time must be visible. + * + * Determines if the time is visible or not. + */ +void +gtk_date_entry_set_time_visible (GtkDateEntry *date, + gboolean is_visible) +{ + GtkDateEntryPrivate *priv = GTK_DATE_ENTRY_GET_PRIVATE (date); + + if (is_visible) + { + gtk_widget_show (priv->spnHours); + gtk_widget_show (priv->lblMinutes); + gtk_widget_show (priv->spnMinutes); + gtk_widget_show (priv->lblSeconds); + gtk_widget_show (priv->spnSeconds); + } + else + { + gtk_widget_hide (priv->spnHours); + gtk_widget_hide (priv->lblMinutes); + gtk_widget_hide (priv->spnMinutes); + gtk_widget_hide (priv->lblSeconds); + gtk_widget_hide (priv->spnSeconds); + } +} + /* PRIVATE */ static void gtk_date_entry_change_mask (GtkDateEntry *date) @@ -963,6 +1109,10 @@ gtk_date_entry_set_property (GObject *object, guint property_id, const GValue *v gtk_date_entry_set_separator (date_entry, g_value_get_string (value)); break; + case PROP_TIME_SEPARATOR: + gtk_date_entry_set_time_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; @@ -994,6 +1144,10 @@ gtk_date_entry_get_property (GObject *object, guint property_id, GValue *value, g_value_set_string (value, priv->separator); break; + case PROP_TIME_SEPARATOR: + g_value_set_string (value, priv->time_separator); + break; + case PROP_FORMAT: g_value_set_string (value, priv->format); break; diff --git a/src/gtkdateentry.h b/src/gtkdateentry.h index 3832342..db3910a 100644 --- a/src/gtkdateentry.h +++ b/src/gtkdateentry.h @@ -61,6 +61,8 @@ GtkWidget *gtk_date_entry_new (const gchar *format, gboolean gtk_date_entry_set_separator (GtkDateEntry *date, const gchar *separator); +gboolean gtk_date_entry_set_time_separator (GtkDateEntry *date, + const gchar *separator); gboolean gtk_date_entry_set_format (GtkDateEntry *date, const gchar *format); @@ -91,6 +93,9 @@ void gtk_date_entry_set_editable_with_calendar (GtkDateEntry *date, void gtk_date_entry_set_calendar_button_visible (GtkDateEntry *date, gboolean is_visible); +void gtk_date_entry_set_time_visible (GtkDateEntry *date, + gboolean is_visible); + G_END_DECLS diff --git a/tests/date_entry.c b/tests/date_entry.c index 013bfcd..b4b6aa6 100644 --- a/tests/date_entry.c +++ b/tests/date_entry.c @@ -1,7 +1,7 @@ /* * GtkDateEntry widget for GTK+ * - * Copyright (C) 2005-2009 Andrea Zagli + * Copyright (C) 2005-2011 Andrea Zagli * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -25,15 +25,22 @@ GtkWidget *window; GtkWidget *table; + GtkWidget *date; + GtkWidget *separator; GtkWidget *btnSeparator; +GtkWidget *time_separator; +GtkWidget *btnTimeSeparator; GtkWidget *format; GtkWidget *btnFormat; GtkWidget *txtSetStrf; GtkWidget *txtSetStrfFormat; GtkWidget *txtSetStrfSep; GtkWidget *btnSetStrf; +GtkWidget *txtGetText; +GtkWidget *btnGetText; + GtkWidget *tbtnEditable; GtkWidget *tbtnEditableWithCalendar; GtkWidget *tbtnSensitive; @@ -46,6 +53,14 @@ on_btnSeparator_clicked (GtkButton *button, gtk_entry_get_text (GTK_ENTRY (separator))); } +static void +on_btnTimeSeparator_clicked (GtkButton *button, + gpointer user_data) +{ + gtk_date_entry_set_time_separator (GTK_DATE_ENTRY (date), + gtk_entry_get_text (GTK_ENTRY (time_separator))); +} + static void on_btnFormat_clicked (GtkButton *button, gpointer user_data) @@ -67,6 +82,13 @@ on_btnSetStrf_clicked (GtkButton *button, NULL); } +static void +on_btnGetText_clicked (GtkButton *button, + gpointer user_data) +{ + gtk_entry_set_text (GTK_ENTRY (txtGetText), gtk_date_entry_get_text (GTK_DATE_ENTRY (date))); +} + static void on_tbtnEditable_toggled (GtkToggleButton *togglebutton, gpointer user_data) @@ -118,6 +140,9 @@ on_tbtnSensitive_toggled (GtkToggleButton *togglebutton, int main (int argc, char **argv) { + guint x; + guint y; + GtkWidget *label; gtk_init (&argc, &argv); @@ -133,86 +158,152 @@ main (int argc, char **argv) gtk_container_add (GTK_CONTAINER (window), table); gtk_widget_show (table); + x = 0; + y = 0; label = gtk_label_new ("GtkDateEntry"); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (label); + x++; date = gtk_date_entry_new (NULL, NULL, TRUE); - gtk_table_attach (GTK_TABLE (table), date, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), date, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (date); + x = 0; + y++; label = gtk_label_new ("Separator"); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (label); + x++; separator = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (separator), "/"); gtk_entry_set_max_length (GTK_ENTRY (separator), 1); - gtk_table_attach (GTK_TABLE (table), separator, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), separator, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (separator); + x++; btnSeparator = gtk_button_new_with_label ("Set separator"); - gtk_table_attach (GTK_TABLE (table), btnSeparator, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), btnSeparator, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (btnSeparator); g_signal_connect (G_OBJECT (btnSeparator), "clicked", G_CALLBACK (on_btnSeparator_clicked), NULL); + x = 0; + y++; + label = gtk_label_new ("Time Separator"); + gtk_table_attach (GTK_TABLE (table), label, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (label); + + x++; + time_separator = gtk_entry_new (); + gtk_entry_set_text (GTK_ENTRY (time_separator), ":"); + gtk_entry_set_max_length (GTK_ENTRY (time_separator), 1); + gtk_table_attach (GTK_TABLE (table), time_separator, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (time_separator); + + x++; + btnTimeSeparator = gtk_button_new_with_label ("Set time separator"); + gtk_table_attach (GTK_TABLE (table), btnTimeSeparator, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (btnTimeSeparator); + + g_signal_connect (G_OBJECT (btnTimeSeparator), "clicked", + G_CALLBACK (on_btnTimeSeparator_clicked), NULL); + + x = 0; + y++; label = gtk_label_new ("Format"); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (label); + x++; format = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (format), "dmY"); gtk_entry_set_max_length (GTK_ENTRY (format), 3); - gtk_table_attach (GTK_TABLE (table), format, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), format, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (format); + x++; btnFormat = gtk_button_new_with_label ("Set format"); - gtk_table_attach (GTK_TABLE (table), btnFormat, 2, 3, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), btnFormat, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (btnFormat); g_signal_connect (G_OBJECT (btnFormat), "clicked", G_CALLBACK (on_btnFormat_clicked), NULL); + x = 0; + y++; label = gtk_label_new ("Strf"); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), label, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (label); + x++; txtSetStrf = gtk_entry_new (); - gtk_table_attach (GTK_TABLE (table), txtSetStrf, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), txtSetStrf, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (txtSetStrf); + x++; btnSetStrf = gtk_button_new_with_label ("set_date_strf"); - gtk_table_attach (GTK_TABLE (table), btnSetStrf, 2, 3, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), btnSetStrf, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (btnSetStrf); g_signal_connect (G_OBJECT (btnSetStrf), "clicked", G_CALLBACK (on_btnSetStrf_clicked), NULL); + x = 0; + y++; + label = gtk_label_new ("Text"); + gtk_table_attach (GTK_TABLE (table), label, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (label); + + x++; + txtGetText = gtk_entry_new (); + gtk_table_attach (GTK_TABLE (table), txtGetText, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_editable_set_editable (GTK_EDITABLE (txtGetText), FALSE); + gtk_widget_show (txtGetText); + + x++; + btnGetText = gtk_button_new_with_label ("Get text"); + gtk_table_attach (GTK_TABLE (table), btnGetText, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (btnGetText); + + g_signal_connect (G_OBJECT (btnGetText), "clicked", + G_CALLBACK (on_btnGetText_clicked), NULL); + + x = 0; + y++; tbtnEditable = gtk_toggle_button_new_with_label ("Editable"); - gtk_table_attach (GTK_TABLE (table), tbtnEditable, 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), tbtnEditable, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (tbtnEditable); g_signal_connect (G_OBJECT (tbtnEditable), "toggled", G_CALLBACK (on_tbtnEditable_toggled), NULL); + x++; 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_table_attach (GTK_TABLE (table), tbtnEditableWithCalendar, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (tbtnEditableWithCalendar); g_signal_connect (G_OBJECT (tbtnEditableWithCalendar), "toggled", G_CALLBACK (on_tbtnEditableWithCalendar_toggled), NULL); + x++; tbtnSensitive = gtk_toggle_button_new_with_label ("Sensitive"); - gtk_table_attach (GTK_TABLE (table), tbtnSensitive, 2, 3, 4, 5, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), tbtnSensitive, x, x + 1, y, y + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (tbtnSensitive); g_signal_connect (G_OBJECT (tbtnSensitive), "toggled", G_CALLBACK (on_tbtnSensitive_toggled), NULL); + time_t tt; + struct tm *tm; + tt = time (NULL); + tm = localtime (&tt); + gtk_date_entry_set_date_tm (GTK_DATE_ENTRY (date), *tm); + gtk_widget_show (window); - + gtk_main (); return 0;