diff options
Diffstat (limited to 'src/calendar.c')
-rw-r--r-- | src/calendar.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/calendar.c b/src/calendar.c index 29768caa..65c2bf90 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -28,6 +28,7 @@ static GtkWidget *calendar; +static ZenityCalendarData *zen_cal_data; static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data); @@ -38,6 +39,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) GtkWidget *dialog; GtkWidget *text; + zen_cal_data = cal_data; + glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); if (glade_dialog == NULL) { @@ -50,7 +53,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_calendar_dialog_response), cal_data); + G_CALLBACK (zenity_calendar_dialog_response), data); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -81,20 +84,22 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityCalendarData *cal_data = data; ZenityData *zen_data; gint day, month, year; gchar time_string[128]; GDate *date = NULL; - + + zen_data = data; + switch (response) { case GTK_RESPONSE_OK: gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - date = g_date_new_dmy (year, month+1, day); + date = g_date_new_dmy (year, month + 1, day); g_date_strftime (time_string, 127, - cal_data->date_format, date); - g_printerr ("%s\n",time_string); - g_date_free ( date ); + zen_cal_data->date_format, date); + g_printerr ("%s\n", time_string); + if (date != NULL) + g_date_free (date); zen_data->exit_code = 0; gtk_main_quit (); break; |