static void change_date (CcDateTimePanel *self) { CcDateTimePanelPrivate *priv = self->priv; guint mon, y, d; GDateTime *old_date; old_date = priv->date; mon = 1 + gtk_combo_box_get_active (GTK_COMBO_BOX (W ("month-combobox"))); y = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("year-spinbutton"))); d = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("day-spinbutton"))); priv->date = g_date_time_new_local (y, mon, d, g_date_time_get_hour (old_date), g_date_time_get_minute (old_date), g_date_time_get_second (old_date)); g_date_time_unref (old_date); queue_set_datetime (self); }
static void change_time (GtkButton *button, CcDateTimePanel *panel) { CcDateTimePanelPrivate *priv = panel->priv; const gchar *widget_name; gint direction; GDateTime *old_date; old_date = priv->date; widget_name = gtk_buildable_get_name (GTK_BUILDABLE (button)); if (strstr (widget_name, "up")) direction = 1; else direction = -1; if (widget_name[0] == 'h') { priv->date = g_date_time_add_hours (old_date, direction); } else if (widget_name[0] == 'm') { priv->date = g_date_time_add_minutes (old_date, direction); } else { int hour; hour = g_date_time_get_hour (old_date); if (hour >= 12) priv->date = g_date_time_add_hours (old_date, -12); else priv->date = g_date_time_add_hours (old_date, 12); } g_date_time_unref (old_date); update_time (panel); queue_set_datetime (panel); }
static void change_time (CcDateTimePanel *panel) { CcDateTimePanelPrivate *priv = panel->priv; guint h, m; GDateTime *old_date; old_date = priv->date; h = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("h_spinbutton"))); m = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("m_spinbutton"))); if (priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H) { gboolean is_pm_time; GtkWidget *visible_child; visible_child = gtk_stack_get_visible_child (GTK_STACK (priv->am_pm_stack)); if (visible_child == priv->pm_label) is_pm_time = TRUE; else is_pm_time = FALSE; if (h == 12) h = 0; if (is_pm_time) h += 12; } priv->date = g_date_time_new_local (g_date_time_get_year (old_date), g_date_time_get_month (old_date), g_date_time_get_day_of_month (old_date), h, m, g_date_time_get_second (old_date)); g_date_time_unref (old_date); update_time (panel); queue_set_datetime (panel); }