From e755daf53920082e8f062c44e18cd4b7d71be96b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20T=2E=20Colombini=20G=C3=B3mez?= Date: Wed, 9 Jul 2014 12:12:22 +0200 Subject: [PATCH] VnDateChooser: - Solucionados algunos problemas --- debian/changelog | 2 +- vn/field/vn-date-chooser.c | 70 ++++++++++++++++---------------------- vn/field/vn-date-chooser.h | 2 +- vn/vn-gui.c | 2 +- 4 files changed, 32 insertions(+), 44 deletions(-) diff --git a/debian/changelog b/debian/changelog index 85f6205..b67e8c2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -libhedera (1.0-13) stable; urgency=low +libhedera (1.0-12) stable; urgency=low * Initial Release. diff --git a/vn/field/vn-date-chooser.c b/vn/field/vn-date-chooser.c index 88898fd..f6b5df7 100644 --- a/vn/field/vn-date-chooser.c +++ b/vn/field/vn-date-chooser.c @@ -109,18 +109,12 @@ static GDateTime * vn_date_chooser_get_datetime (VnDateChooser * obj) guint year, month, day, hour = 0, minute = 0; gdouble second = 0.0; - if (obj->show_date) - { - gtk_calendar_get_date (obj->calendar, &year, &month, &day); - month++; - } + gtk_calendar_get_date (obj->calendar, &year, &month, &day); + month++; - if (obj->show_time) - { - hour = (guint) gtk_adjustment_get_value (obj->hour); - minute = (guint) gtk_adjustment_get_value (obj->minute); - second = gtk_adjustment_get_value (obj->second); - } + hour = (guint) gtk_adjustment_get_value (obj->hour); + minute = (guint) gtk_adjustment_get_value (obj->minute); + second = gtk_adjustment_get_value (obj->second); return g_date_time_new_local (year, month, day, hour, minute, second); } @@ -258,26 +252,19 @@ static void vn_date_chooser_on_toggled (GtkToggleButton * button, VnDateChooser if (obj->datetime) { - if (obj->show_date) - { - gtk_calendar_select_month (obj->calendar - ,g_date_time_get_month (obj->datetime) - 1 - ,g_date_time_get_year (obj->datetime) - ); - gtk_calendar_select_day (obj->calendar, - g_date_time_get_day_of_month (obj->datetime)); - } + gtk_calendar_select_month (obj->calendar + ,g_date_time_get_month (obj->datetime) - 1 + ,g_date_time_get_year (obj->datetime) + ); + gtk_calendar_select_day (obj->calendar, + g_date_time_get_day_of_month (obj->datetime)); - if (obj->show_time) - { - gtk_adjustment_set_value (obj->hour, - g_date_time_get_hour (obj->datetime)); - gtk_adjustment_set_value (obj->minute, - g_date_time_get_minute (obj->datetime)); - gtk_adjustment_set_value (obj->second, - g_date_time_get_second (obj->datetime)); - gtk_widget_set_no_show_all (GTK_WIDGET (obj->time), obj->show_time); - } + gtk_adjustment_set_value (obj->hour, + g_date_time_get_hour (obj->datetime)); + gtk_adjustment_set_value (obj->minute, + g_date_time_get_minute (obj->datetime)); + gtk_adjustment_set_value (obj->second, + g_date_time_get_second (obj->datetime)); } else gtk_calendar_select_day (obj->calendar, 0); @@ -286,11 +273,17 @@ static void vn_date_chooser_on_toggled (GtkToggleButton * button, VnDateChooser if (!obj->show_date) gtk_widget_hide (GTK_WIDGET (obj->calendar)); + if (!obj->show_time) - gtk_widget_hide (GTK_WIDGET (obj->time)); + gtk_widget_hide (obj->time); gtk_widget_set_no_show_all (GTK_WIDGET (obj->calendar), !obj->show_date); - gtk_widget_set_no_show_all (GTK_WIDGET (obj->time), !obj->show_time); + gtk_widget_set_no_show_all (obj->time, !obj->show_time); + + gtk_widget_get_preferred_width (obj->box, &x, NULL); + gtk_widget_get_preferred_height (obj->box, &y, NULL); + + gtk_window_resize (GTK_WINDOW (obj->popup), x, y); // Setting the position of the popup @@ -306,7 +299,6 @@ static void vn_date_chooser_on_toggled (GtkToggleButton * button, VnDateChooser gdk_screen_get_monitor_geometry (screen, gdk_screen_get_monitor_at_point (screen, x, y), &monitor); - gtk_widget_show (GTK_WIDGET (obj->calendar)); gtk_widget_get_preferred_size (obj->popup, &req, NULL); if (y - monitor.y > monitor.height) @@ -430,16 +422,12 @@ static void vn_date_chooser_init (VnDateChooser * obj) obj->device = NULL; obj->datetime = NULL; - obj->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8); - gtk_container_add (GTK_CONTAINER (obj), GTK_WIDGET (obj->box)); - VN_FIELD (obj)->field = obj->box; - obj->button = gtk_toggle_button_new (); gtk_widget_set_tooltip_text (GTK_WIDGET (obj->button), _("Change date")); g_signal_connect (obj->button, "toggled", G_CALLBACK (vn_date_chooser_on_toggled), obj); - gtk_box_pack_start (GTK_BOX (obj->box), - GTK_WIDGET (obj->button), TRUE, TRUE, 0); + VN_FIELD (obj)->field = obj->button; + gtk_container_add (GTK_CONTAINER (obj), GTK_WIDGET (obj->button)); g_object_set (obj->button, "relief", GTK_RELIEF_HALF, NULL); obj->label = GTK_LABEL (gtk_label_new (NULL)); @@ -462,8 +450,8 @@ static void vn_date_chooser_init (VnDateChooser * obj) obj->second = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "second")); obj->time = GTK_WIDGET (gtk_builder_get_object (builder, "time")); - gtk_container_add (GTK_CONTAINER (obj->popup), - GTK_WIDGET (gtk_builder_get_object (builder, "box"))); + obj->box = GTK_WIDGET (gtk_builder_get_object (builder, "box")); + gtk_container_add (GTK_CONTAINER (obj->popup), obj->box); } static void vn_date_chooser_finalize (VnDateChooser * obj) diff --git a/vn/field/vn-date-chooser.h b/vn/field/vn-date-chooser.h index 2f84d18..1f8bc26 100644 --- a/vn/field/vn-date-chooser.h +++ b/vn/field/vn-date-chooser.h @@ -36,9 +36,9 @@ struct _VnDateChooser gchar * format; gboolean show_time; gboolean show_date; - GtkWidget * box; GtkLabel * label; GtkWidget * popup; + GtkWidget * box; GtkWidget * button; GdkDevice * device; GtkCalendar * calendar; diff --git a/vn/vn-gui.c b/vn/vn-gui.c index eb6bf0a..18d332f 100644 --- a/vn/vn-gui.c +++ b/vn/vn-gui.c @@ -335,7 +335,7 @@ static void vn_gui_load_module (VnGui * obj, const gchar * dir, const gchar * fi ,-1 ); - len = gdome_nl_length (nl, &e) ; + len = gdome_nl_length (nl, &e); for (n = 0; n < len; n++) {