summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2023-03-29 16:29:03 +1300
committerFelipe Borges <felipeborges@gnome.org>2023-03-29 11:04:24 +0000
commita3d99c78f6f35318dd81ffa579c4191b85b40d24 (patch)
treee9fe337d031c4f747faed3c10fc3808447289b83
parent6490afd3ca85c53390d14e112c153044485edfdb (diff)
downloadgnome-control-center-a3d99c78f6f35318dd81ffa579c4191b85b40d24.tar.gz
datetime: Fix widget names and types
-rw-r--r--panels/datetime/cc-datetime-panel.c142
-rw-r--r--panels/datetime/cc-datetime-panel.ui4
2 files changed, 72 insertions, 74 deletions
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index 3a8ac1e45..17bde318f 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -23,6 +23,7 @@
#include "cc-time-editor.h"
#include "cc-datetime-panel.h"
#include "cc-datetime-resources.h"
+#include "cc-list-row.h"
#include <langinfo.h>
#include <sys/time.h>
@@ -74,29 +75,28 @@ struct _CcDateTimePanel
GSettings *datetime_settings;
GSettings *filechooser_settings;
GDesktopClockFormat clock_format;
- GtkWidget *auto_datetime_row;
- GtkWidget *auto_timezone_row;
- GtkWidget *auto_timezone_switch;
- GtkWidget *date_grid;
- GtkWidget *datetime_button;
- GtkWidget *datetime_dialog;
- GtkWidget *datetime_label;
- GtkWidget *day_spinbutton;
- GtkWidget *timeformat_row;
- GtkWidget *h_spinbutton;
+ AdwActionRow *auto_datetime_row;
+ AdwActionRow *auto_timezone_row;
+ GtkSwitch *auto_timezone_switch;
+ AdwActionRow *datetime_row;
+ GtkDialog *datetime_dialog;
+ GtkLabel *datetime_label;
+ GtkSpinButton *day_spinbutton;
+ AdwComboRow *timeformat_row;
+ GtkSpinButton *h_spinbutton;
GtkLockButton *lock_button;
GtkListBox *date_box;
- GtkListBoxRow *day_row;
+ AdwActionRow *day_row;
GtkSingleSelection *month_model;
GtkPopover *month_popover;
- GtkListBoxRow *month_row;
- GtkListBoxRow *year_row;
- GtkWidget *network_time_switch;
- GtkWidget *time_editor;
- GtkWidget *timezone_button;
- GtkWidget *timezone_dialog;
- GtkWidget *timezone_label;
- GtkWidget *year_spinbutton;
+ CcListRow *month_row;
+ AdwActionRow *year_row;
+ GtkSwitch *network_time_switch;
+ CcTimeEditor *time_editor;
+ AdwActionRow *timezone_row;
+ CcTzDialog *timezone_dialog;
+ GtkLabel *timezone_label;
+ GtkSpinButton *year_spinbutton;
GnomeWallClock *clock_tracker;
@@ -181,7 +181,7 @@ change_clock_settings (GObject *gobject,
g_signal_handlers_block_by_func (self->clock_settings, clock_settings_changed_cb,
self);
- item = ADW_ENUM_LIST_ITEM (adw_combo_row_get_selected_item (ADW_COMBO_ROW (self->timeformat_row)));
+ item = ADW_ENUM_LIST_ITEM (adw_combo_row_get_selected_item (self->timeformat_row));
value = adw_enum_list_item_get_value (item);
g_settings_set_enum (self->clock_settings, CLOCK_FORMAT_KEY, value);
@@ -205,9 +205,9 @@ clock_settings_changed_cb (CcDateTimePanel *self,
g_signal_handlers_block_by_func (self->timeformat_row, change_clock_settings, self);
- adw_combo_row_set_selected (ADW_COMBO_ROW (self->timeformat_row), value);
+ adw_combo_row_set_selected (self->timeformat_row, value);
- cc_time_editor_set_am_pm (CC_TIME_EDITOR (self->time_editor),
+ cc_time_editor_set_am_pm (self->time_editor,
value == G_DESKTOP_CLOCK_FORMAT_12H);
update_time (self);
@@ -227,7 +227,7 @@ update_time (CcDateTimePanel *self)
else
use_ampm = FALSE;
- cc_time_editor_set_time (CC_TIME_EDITOR (self->time_editor),
+ cc_time_editor_set_time (self->time_editor,
g_date_time_get_hour (self->date),
g_date_time_get_minute (self->date));
@@ -245,7 +245,7 @@ update_time (CcDateTimePanel *self)
self->month = g_date_time_get_month (self->date);
gtk_single_selection_set_selected (self->month_model, self->month - 1);
- gtk_label_set_text (GTK_LABEL (self->datetime_label), label);
+ gtk_label_set_text (self->datetime_label, label);
}
static void
@@ -306,7 +306,7 @@ set_using_ntp_cb (GObject *source,
gboolean ntp_on;
g_object_get (self->dtm, "ntp", &ntp_on, NULL);
- gtk_switch_set_state (GTK_SWITCH (self->network_time_switch), ntp_on);
+ gtk_switch_set_state (self->network_time_switch, ntp_on);
}
}
@@ -360,15 +360,15 @@ change_date (CcDateTimePanel *self)
guint y, d;
g_autoptr(GDateTime) old_date = NULL;
- y = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (self->year_spinbutton));
- d = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (self->day_spinbutton));
+ y = gtk_spin_button_get_value_as_int (self->year_spinbutton);
+ d = gtk_spin_button_get_value_as_int (self->day_spinbutton);
old_date = self->date;
self->date = g_date_time_new_local (y, self->month, d,
g_date_time_get_hour (old_date),
g_date_time_get_minute (old_date),
g_date_time_get_second (old_date));
- cc_time_editor_set_time (CC_TIME_EDITOR (self->time_editor),
+ cc_time_editor_set_time (self->time_editor,
g_date_time_get_hour (self->date),
g_date_time_get_minute (self->date));
@@ -415,7 +415,7 @@ update_timezone (CcDateTimePanel *self)
label = g_strdup_printf (C_("timezone desc", "%s (%s)"),
g_date_time_get_timezone_abbreviation (self->date),
city_country);
- gtk_label_set_text (GTK_LABEL (self->timezone_label), label);
+ gtk_label_set_text (self->timezone_label, label);
}
static void
@@ -426,13 +426,13 @@ get_initial_timezone (CcDateTimePanel *self)
timezone = timedate1_get_timezone (self->dtm);
if (timezone == NULL ||
- !cc_tz_dialog_set_tz (CC_TZ_DIALOG (self->timezone_dialog), timezone))
+ !cc_tz_dialog_set_tz (self->timezone_dialog, timezone))
{
g_warning ("Timezone '%s' is unhandled, setting %s as default", timezone ? timezone : "(null)", DEFAULT_TZ);
- cc_tz_dialog_set_tz (CC_TZ_DIALOG (self->timezone_dialog), DEFAULT_TZ);
+ cc_tz_dialog_set_tz (self->timezone_dialog, DEFAULT_TZ);
}
- self->current_location = cc_tz_dialog_get_selected_location (CC_TZ_DIALOG (self->timezone_dialog));
+ self->current_location = cc_tz_dialog_get_selected_location (self->timezone_dialog);
update_timezone (self);
}
@@ -448,19 +448,17 @@ month_year_changed (CcDateTimePanel *self)
guint y;
guint num_days;
GtkAdjustment *adj;
- GtkSpinButton *day_spin;
- y = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (self->year_spinbutton));
+ y = gtk_spin_button_get_value_as_int (self->year_spinbutton);
/* Check the number of days in that month */
num_days = g_date_get_days_in_month (self->month, y);
- day_spin = GTK_SPIN_BUTTON (self->day_spinbutton);
- adj = GTK_ADJUSTMENT (gtk_spin_button_get_adjustment (day_spin));
+ adj = GTK_ADJUSTMENT (gtk_spin_button_get_adjustment (self->day_spinbutton));
gtk_adjustment_set_upper (adj, num_days + 1);
- if (gtk_spin_button_get_value_as_int (day_spin) > num_days)
- gtk_spin_button_set_value (day_spin, num_days);
+ if (gtk_spin_button_get_value_as_int (self->day_spinbutton) > num_days)
+ gtk_spin_button_set_value (self->day_spinbutton, num_days);
change_date (self);
}
@@ -471,7 +469,7 @@ on_date_box_row_activated_cb (CcDateTimePanel *self,
{
g_assert (CC_IS_DATE_TIME_PANEL (self));
- if (row == self->month_row)
+ if (row == GTK_LIST_BOX_ROW (self->month_row))
gtk_popover_popup (self->month_popover);
}
@@ -554,14 +552,14 @@ on_permission_changed (CcDateTimePanel *self)
allowed = (self->permission != NULL && g_permission_get_allowed (self->permission));
location_allowed = g_settings_get_boolean (self->location_settings, LOCATION_ENABLED);
tz_allowed = (self->tz_permission != NULL && g_permission_get_allowed (self->tz_permission));
- using_ntp = gtk_switch_get_active (GTK_SWITCH (self->network_time_switch));
- auto_timezone = gtk_switch_get_active (GTK_SWITCH (self->auto_timezone_switch));
+ using_ntp = gtk_switch_get_active (self->network_time_switch);
+ auto_timezone = gtk_switch_get_active (self->auto_timezone_switch);
/* All the widgets but the lock button and the 24h setting */
- gtk_widget_set_sensitive (self->auto_datetime_row, allowed);
- gtk_widget_set_sensitive (self->auto_timezone_row, location_allowed && (allowed || tz_allowed));
- gtk_widget_set_sensitive (self->datetime_button, allowed && !using_ntp);
- gtk_widget_set_sensitive (self->timezone_button, (allowed || tz_allowed) && (!auto_timezone || !location_allowed));
+ gtk_widget_set_sensitive (GTK_WIDGET (self->auto_datetime_row), allowed);
+ gtk_widget_set_sensitive (GTK_WIDGET (self->auto_timezone_row), location_allowed && (allowed || tz_allowed));
+ gtk_widget_set_sensitive (GTK_WIDGET (self->datetime_row), allowed && !using_ntp);
+ gtk_widget_set_sensitive (GTK_WIDGET (self->timezone_row), (allowed || tz_allowed) && (!auto_timezone || !location_allowed));
/* Hide the subdialogs if we no longer have permissions */
if (!allowed)
@@ -579,7 +577,7 @@ on_location_settings_changed (CcDateTimePanel *panel)
static void
on_can_ntp_changed (CcDateTimePanel *self)
{
- gtk_widget_set_visible (self->auto_datetime_row, is_ntp_available (self));
+ gtk_widget_set_visible (GTK_WIDGET (self->auto_datetime_row), is_ntp_available (self));
}
static void
@@ -621,7 +619,7 @@ on_timedated_properties_changed (CcDateTimePanel *self,
static void
run_dialog (CcDateTimePanel *self,
- GtkWidget *dialog)
+ GtkDialog *dialog)
{
GtkWidget *parent;
@@ -670,7 +668,7 @@ switch_to_row_transform_func (GBinding *binding,
static void
bind_switch_to_row (CcDateTimePanel *self,
- GtkWidget *gtkswitch,
+ GtkSwitch *gtkswitch,
GtkWidget *listrow)
{
g_object_bind_property_full (gtkswitch, "active",
@@ -685,7 +683,7 @@ panel_tz_selection_changed_cb (CcDateTimePanel *self)
{
g_assert (CC_IS_DATE_TIME_PANEL (self));
- self->current_location = cc_tz_dialog_get_selected_location (CC_TZ_DIALOG (self->timezone_dialog));
+ self->current_location = cc_tz_dialog_get_selected_location (self->timezone_dialog);
queue_set_timezone (self);
}
@@ -694,13 +692,13 @@ list_box_row_activated (CcDateTimePanel *self,
GtkListBoxRow *row)
{
- if (row == GTK_LIST_BOX_ROW (self->datetime_button))
+ if (row == GTK_LIST_BOX_ROW (self->datetime_row))
{
run_dialog (self, self->datetime_dialog);
}
- else if (row == GTK_LIST_BOX_ROW (self->timezone_button))
+ else if (row == GTK_LIST_BOX_ROW (self->timezone_row))
{
- run_dialog (self, self->timezone_dialog);
+ run_dialog (self, GTK_DIALOG (self->timezone_dialog));
}
}
@@ -717,8 +715,8 @@ time_changed_cb (CcDateTimePanel *self,
self->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),
- cc_time_editor_get_hour (CC_TIME_EDITOR (self->time_editor)),
- cc_time_editor_get_minute (CC_TIME_EDITOR (self->time_editor)),
+ cc_time_editor_get_hour (self->time_editor),
+ cc_time_editor_get_minute (self->time_editor),
g_date_time_get_second (old_date));
update_time (self);
@@ -756,8 +754,7 @@ setup_datetime_dialog (CcDateTimePanel *self)
g_date_time_get_year (self->date));
adjustment = (GtkAdjustment*) gtk_adjustment_new (g_date_time_get_day_of_month (self->date), 1,
num_days + 1, 1, 10, 1);
- gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (self->day_spinbutton),
- adjustment);
+ gtk_spin_button_set_adjustment (self->day_spinbutton, adjustment);
g_signal_connect_object (G_OBJECT (self->day_spinbutton), "value-changed",
G_CALLBACK (day_changed), self, G_CONNECT_SWAPPED);
@@ -765,8 +762,7 @@ setup_datetime_dialog (CcDateTimePanel *self)
adjustment = (GtkAdjustment*) gtk_adjustment_new (g_date_time_get_year (self->date),
1, G_MAXDOUBLE, 1,
10, 1);
- gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (self->year_spinbutton),
- adjustment);
+ gtk_spin_button_set_adjustment (self->year_spinbutton, adjustment);
g_signal_connect_object (G_OBJECT (self->year_spinbutton), "value-changed",
G_CALLBACK (month_year_changed), self, G_CONNECT_SWAPPED);
@@ -780,39 +776,41 @@ sort_date_box (GtkListBoxRow *a,
GtkListBoxRow *b,
CcDateTimePanel *self)
{
- GtkListBoxRow *month_row;
+ GtkListBoxRow *day_row, *month_row, *year_row;
g_assert (CC_IS_DATE_TIME_PANEL (self));
+ day_row = GTK_LIST_BOX_ROW (self->day_row);
month_row = GTK_LIST_BOX_ROW (self->month_row);
+ year_row = GTK_LIST_BOX_ROW (self->year_row);
switch (date_endian_get_default (FALSE)) {
case DATE_ENDIANESS_BIG:
/* year, month, day */
- if (a == self->year_row || b == self->day_row)
+ if (a == year_row || b == day_row)
return -1;
- if (a == self->day_row || b == self->year_row)
+ if (a == day_row || b == year_row)
return 1;
case DATE_ENDIANESS_LITTLE:
/* day, month, year */
- if (a == self->day_row || b == self->year_row)
+ if (a == day_row || b == year_row)
return -1;
- if (a == self->year_row || b == self->day_row)
+ if (a == year_row || b == day_row)
return 1;
case DATE_ENDIANESS_MIDDLE:
/* month, day, year */
- if (a == month_row || b == self->year_row)
+ if (a == month_row || b == year_row)
return -1;
- if (a == self->year_row || b == month_row)
+ if (a == year_row || b == month_row)
return 1;
case DATE_ENDIANESS_YDM:
/* year, day, month */
- if (a == self->year_row || b == month_row)
+ if (a == year_row || b == month_row)
return -1;
- if (a == month_row || b == self->year_row)
+ if (a == month_row || b == year_row)
return 1;
}
@@ -836,7 +834,7 @@ cc_date_time_panel_class_init (CcDateTimePanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, auto_timezone_row);
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, auto_timezone_switch);
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, date_box);
- gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, datetime_button);
+ gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, datetime_row);
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, datetime_dialog);
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, datetime_label);
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, day_row);
@@ -848,7 +846,7 @@ cc_date_time_panel_class_init (CcDateTimePanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, month_row);
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, network_time_switch);
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, time_editor);
- gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, timezone_button);
+ gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, timezone_row);
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, timezone_dialog);
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, timezone_label);
gtk_widget_class_bind_template_child (widget_class, CcDateTimePanel, year_row);
@@ -926,18 +924,18 @@ cc_date_time_panel_init (CcDateTimePanel *self)
/* set up network time switch */
bind_switch_to_row (self,
self->network_time_switch,
- self->datetime_button);
+ GTK_WIDGET (self->datetime_row));
g_signal_connect_object (self->dtm, "notify::ntp",
G_CALLBACK (on_ntp_changed), self, G_CONNECT_SWAPPED);
g_signal_connect_object (self->network_time_switch, "state-set",
G_CALLBACK (change_ntp), self, G_CONNECT_SWAPPED);
on_ntp_changed (self);
- gtk_widget_set_visible (self->auto_datetime_row, is_ntp_available (self));
+ gtk_widget_set_visible (GTK_WIDGET (self->auto_datetime_row), is_ntp_available (self));
/* Timezone settings */
g_object_bind_property_full (self->auto_timezone_switch, "active",
- self->timezone_button, "sensitive",
+ self->timezone_row, "sensitive",
G_BINDING_SYNC_CREATE,
(GBindingTransformFunc) tz_switch_to_row_transform_func,
NULL, self, NULL);
diff --git a/panels/datetime/cc-datetime-panel.ui b/panels/datetime/cc-datetime-panel.ui
index 5e9d783e8..1786634c9 100644
--- a/panels/datetime/cc-datetime-panel.ui
+++ b/panels/datetime/cc-datetime-panel.ui
@@ -134,7 +134,7 @@
</object>
</child>
<child>
- <object class="AdwActionRow" id="datetime_button">
+ <object class="AdwActionRow" id="datetime_row">
<property name="title" translatable="yes">Date &amp;amp; _Time</property>
<property name="use_underline">True</property>
<property name="activatable">True</property>
@@ -174,7 +174,7 @@
</object>
</child>
<child>
- <object class="AdwActionRow" id="timezone_button">
+ <object class="AdwActionRow" id="timezone_row">
<property name="title" translatable="yes">Time Z_one</property>
<property name="use_underline">True</property>
<property name="activatable">True</property>