datetime: make dialog instant apply
This commit is contained in:
parent
1d5309973d
commit
15a0ad5fad
2 changed files with 55 additions and 50 deletions
|
@ -255,6 +255,10 @@ set_time_cb (CcDateTimePanel *self,
|
||||||
{
|
{
|
||||||
g_warning ("Could not set system time: %s", error->message);
|
g_warning ("Could not set system time: %s", error->message);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
update_time (self);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -280,14 +284,41 @@ set_using_ntp_cb (CcDateTimePanel *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_button_clicked_cb (GtkButton *button,
|
queue_set_datetime (CcDateTimePanel *self)
|
||||||
CcDateTimePanel *self)
|
{
|
||||||
|
time_t unixtime;
|
||||||
|
|
||||||
|
/* for now just do it */
|
||||||
|
unixtime = g_date_time_to_unix (self->priv->date);
|
||||||
|
set_system_time_async (unixtime, (GFunc) set_time_cb, self, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
queue_set_ntp (CcDateTimePanel *self)
|
||||||
|
{
|
||||||
|
CcDateTimePanelPrivate *priv = self->priv;
|
||||||
|
gboolean using_ntp;
|
||||||
|
/* for now just do it */
|
||||||
|
using_ntp = gtk_switch_get_active (GTK_SWITCH (W("network_time_switch")));
|
||||||
|
set_using_ntp_async (using_ntp, (GFunc) set_using_ntp_cb, self, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
queue_set_timezone (CcDateTimePanel *self)
|
||||||
|
{
|
||||||
|
/* for now just do it */
|
||||||
|
if (self->priv->current_location)
|
||||||
|
{
|
||||||
|
set_system_timezone_async (self->priv->current_location->zone, (GFunc) set_timezone_cb, self, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
change_date (CcDateTimePanel *self)
|
||||||
{
|
{
|
||||||
CcDateTimePanelPrivate *priv = self->priv;
|
CcDateTimePanelPrivate *priv = self->priv;
|
||||||
guint mon, y, d;
|
guint mon, y, d;
|
||||||
time_t unixtime;
|
|
||||||
GDateTime *old_date;
|
GDateTime *old_date;
|
||||||
gboolean using_ntp;
|
|
||||||
|
|
||||||
old_date = priv->date;
|
old_date = priv->date;
|
||||||
|
|
||||||
|
@ -300,18 +331,7 @@ apply_button_clicked_cb (GtkButton *button,
|
||||||
g_date_time_get_minute (old_date),
|
g_date_time_get_minute (old_date),
|
||||||
g_date_time_get_second (old_date));
|
g_date_time_get_second (old_date));
|
||||||
g_date_time_unref (old_date);
|
g_date_time_unref (old_date);
|
||||||
|
queue_set_datetime (self);
|
||||||
unixtime = g_date_time_to_unix (priv->date);
|
|
||||||
|
|
||||||
set_system_time_async (unixtime, (GFunc) set_time_cb, self, NULL);
|
|
||||||
|
|
||||||
if (priv->current_location)
|
|
||||||
{
|
|
||||||
set_system_timezone_async (priv->current_location->zone, (GFunc) set_timezone_cb, self, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
using_ntp = gtk_switch_get_active (GTK_SWITCH (W("network_time_switch")));
|
|
||||||
set_using_ntp_async (using_ntp, (GFunc) set_using_ntp_cb, self, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -386,6 +406,8 @@ location_changed_cb (CcTimezoneMap *map,
|
||||||
while (gtk_tree_model_iter_next (model, &iter));
|
while (gtk_tree_model_iter_next (model, &iter));
|
||||||
|
|
||||||
g_strfreev (split);
|
g_strfreev (split);
|
||||||
|
|
||||||
|
queue_set_timezone (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -560,6 +582,13 @@ update_widget_state_for_ntp (CcDateTimePanel *panel,
|
||||||
gtk_widget_set_sensitive (W("table2"), !using_ntp);
|
gtk_widget_set_sensitive (W("table2"), !using_ntp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
day_changed (GtkWidget *widget,
|
||||||
|
CcDateTimePanel *panel)
|
||||||
|
{
|
||||||
|
change_date (panel);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
month_year_changed (GtkWidget *widget,
|
month_year_changed (GtkWidget *widget,
|
||||||
CcDateTimePanel *panel)
|
CcDateTimePanel *panel)
|
||||||
|
@ -582,6 +611,8 @@ month_year_changed (GtkWidget *widget,
|
||||||
|
|
||||||
if (gtk_spin_button_get_value_as_int (day_spin) > num_days)
|
if (gtk_spin_button_get_value_as_int (day_spin) > num_days)
|
||||||
gtk_spin_button_set_value (day_spin, num_days);
|
gtk_spin_button_set_value (day_spin, num_days);
|
||||||
|
|
||||||
|
change_date (panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -622,14 +653,16 @@ change_time (GtkButton *button,
|
||||||
g_date_time_unref (old_date);
|
g_date_time_unref (old_date);
|
||||||
|
|
||||||
update_time (panel);
|
update_time (panel);
|
||||||
|
queue_set_datetime (panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
change_ntp (GObject *gobject,
|
change_ntp (GObject *gobject,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
gpointer user_data)
|
CcDateTimePanel *self)
|
||||||
{
|
{
|
||||||
update_widget_state_for_ntp (user_data, gtk_switch_get_active (GTK_SWITCH (gobject)));
|
update_widget_state_for_ntp (self, gtk_switch_get_active (GTK_SWITCH (gobject)));
|
||||||
|
queue_set_ntp (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -717,6 +750,8 @@ cc_date_time_panel_init (CcDateTimePanel *self)
|
||||||
num_days + 1, 1, 10, 1);
|
num_days + 1, 1, 10, 1);
|
||||||
gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (W ("day-spinbutton")),
|
gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (W ("day-spinbutton")),
|
||||||
adjustment);
|
adjustment);
|
||||||
|
g_signal_connect (G_OBJECT (W("day-spinbutton")), "value-changed",
|
||||||
|
G_CALLBACK (day_changed), self);
|
||||||
|
|
||||||
adjustment = (GtkAdjustment*) gtk_adjustment_new (g_date_time_get_year (priv->date),
|
adjustment = (GtkAdjustment*) gtk_adjustment_new (g_date_time_get_year (priv->date),
|
||||||
G_MINDOUBLE, G_MAXDOUBLE, 1,
|
G_MINDOUBLE, G_MAXDOUBLE, 1,
|
||||||
|
@ -752,12 +787,6 @@ cc_date_time_panel_init (CcDateTimePanel *self)
|
||||||
|
|
||||||
update_time (self);
|
update_time (self);
|
||||||
|
|
||||||
g_signal_connect ((GtkWidget*) gtk_builder_get_object (priv->builder,
|
|
||||||
"button_apply"),
|
|
||||||
"clicked",
|
|
||||||
G_CALLBACK (apply_button_clicked_cb),
|
|
||||||
self);
|
|
||||||
|
|
||||||
get_system_timezone_async ((GetTimezoneFunc) get_timezone_cb, self, NULL);
|
get_system_timezone_async ((GetTimezoneFunc) get_timezone_cb, self, NULL);
|
||||||
|
|
||||||
priv->locations = (GtkTreeModel*) gtk_builder_get_object (priv->builder,
|
priv->locations = (GtkTreeModel*) gtk_builder_get_object (priv->builder,
|
||||||
|
|
|
@ -431,30 +431,6 @@
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkHButtonBox" id="hbuttonbox1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="layout_style">end</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="button_apply">
|
|
||||||
<property name="label">gtk-apply</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue