diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-03-07 09:27:31 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-03-17 20:49:12 +0800 |
commit | 3b205698762afcd86ac79595960253d84aff5487 (patch) | |
tree | f0f1ae05b5bd7fbd0008dbd8dbdd10908ebc1c6c /modules/calendar | |
parent | 5a7097278a6f6eb2a984d9e0c742342135971c35 (diff) | |
download | gsoc2013-evolution-3b205698762afcd86ac79595960253d84aff5487.tar gsoc2013-evolution-3b205698762afcd86ac79595960253d84aff5487.tar.gz gsoc2013-evolution-3b205698762afcd86ac79595960253d84aff5487.tar.bz2 gsoc2013-evolution-3b205698762afcd86ac79595960253d84aff5487.tar.lz gsoc2013-evolution-3b205698762afcd86ac79595960253d84aff5487.tar.xz gsoc2013-evolution-3b205698762afcd86ac79595960253d84aff5487.tar.zst gsoc2013-evolution-3b205698762afcd86ac79595960253d84aff5487.zip |
Convert all "week-start-day" properties to GDateWeekday.
Diffstat (limited to 'modules/calendar')
-rw-r--r-- | modules/calendar/e-cal-shell-settings.c | 63 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-view-private.c | 7 | ||||
-rw-r--r-- | modules/calendar/e-calendar-preferences.c | 9 | ||||
-rw-r--r-- | modules/calendar/e-calendar-preferences.ui | 47 |
4 files changed, 27 insertions, 99 deletions
diff --git a/modules/calendar/e-cal-shell-settings.c b/modules/calendar/e-cal-shell-settings.c index 7f6527b531..d3288401f5 100644 --- a/modules/calendar/e-cal-shell-settings.c +++ b/modules/calendar/e-cal-shell-settings.c @@ -147,31 +147,7 @@ transform_weekdays_settings_to_evolution (GBinding *binding, } /* Evolution numbering */ - switch (weekday) { - case G_DATE_MONDAY: - g_value_set_int (target_value, 0); - break; - case G_DATE_TUESDAY: - g_value_set_int (target_value, 1); - break; - case G_DATE_WEDNESDAY: - g_value_set_int (target_value, 2); - break; - case G_DATE_THURSDAY: - g_value_set_int (target_value, 3); - break; - case G_DATE_FRIDAY: - g_value_set_int (target_value, 4); - break; - case G_DATE_SATURDAY: - g_value_set_int (target_value, 5); - break; - case G_DATE_SUNDAY: - g_value_set_int (target_value, 6); - break; - default: - return FALSE; - } + g_value_set_enum (target_value, weekday); return TRUE; } @@ -192,34 +168,10 @@ transform_weekdays_evolution_to_settings (GBinding *binding, /* This is purposefully verbose for better readability. */ - /* setting numbering */ - switch (g_value_get_int (source_value)) { - case 0: - weekday = G_DATE_MONDAY; - break; - case 1: - weekday = G_DATE_TUESDAY; - break; - case 2: - weekday = G_DATE_WEDNESDAY; - break; - case 3: - weekday = G_DATE_THURSDAY; - break; - case 4: - weekday = G_DATE_FRIDAY; - break; - case 5: - weekday = G_DATE_SATURDAY; - break; - case 6: - weekday = G_DATE_SUNDAY; - break; - default: - return FALSE; - } - /* Evolution numbering */ + weekday = g_value_get_enum (source_value); + + /* setting numbering */ switch (weekday) { case G_DATE_MONDAY: g_value_set_int (target_value, 1); @@ -802,13 +754,12 @@ e_cal_shell_backend_init_settings (EShell *shell) (GDestroyNotify) g_object_unref); e_shell_settings_install_property ( - g_param_spec_int ( + g_param_spec_enum ( "cal-week-start-day", NULL, NULL, - 0, /* Monday */ - 6, /* Sunday */ - 0, + E_TYPE_DATE_WEEKDAY, + G_DATE_MONDAY, G_PARAM_READWRITE)); g_object_bind_property_full ( diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index b8a5583b37..4561ad35dd 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -96,7 +96,7 @@ cal_shell_view_date_navigator_selection_changed_cb (ECalShellView *cal_shell_vie time_t start, end, new_time; gboolean starts_on_week_start_day; gint new_days_shown, old_days_shown; - gint week_start_day; + GDateWeekday week_start_day; cal_shell_content = cal_shell_view->priv->cal_shell_content; calendar = e_cal_shell_content_get_calendar (cal_shell_content); @@ -125,7 +125,8 @@ cal_shell_view_date_navigator_selection_changed_cb (ECalShellView *cal_shell_vie multi_week_view = e_week_view_get_multi_week_view (week_view); compress_weekend = e_week_view_get_compress_weekend (week_view); - if (week_start_day == 0 && (!multi_week_view || compress_weekend)) + if (week_start_day == G_DATE_SUNDAY && + (!multi_week_view || compress_weekend)) g_date_add_days (&start_date, 1); } @@ -151,7 +152,7 @@ cal_shell_view_date_navigator_selection_changed_cb (ECalShellView *cal_shell_vie * day is set to Sunday, we don't actually show complete * weeks in the week view, so this may need tweaking. */ starts_on_week_start_day = - (g_date_get_weekday (&new_start_date) % 7 == week_start_day); + (g_date_get_weekday (&new_start_date) == week_start_day); /* Update selection to be in the new time range. */ tt = icaltime_null_time (); diff --git a/modules/calendar/e-calendar-preferences.c b/modules/calendar/e-calendar-preferences.c index 5c71fd81fa..0079b2cf95 100644 --- a/modules/calendar/e-calendar-preferences.c +++ b/modules/calendar/e-calendar-preferences.c @@ -584,11 +584,14 @@ calendar_preferences_construct (ECalendarPreferences *prefs, G_BINDING_SYNC_CREATE); widget = e_builder_get_widget (prefs->builder, "week_start_day"); - g_object_bind_property ( + g_object_bind_property_full ( shell_settings, "cal-week-start-day", - widget, "active", + widget, "active-id", G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); + G_BINDING_SYNC_CREATE, + e_binding_transform_enum_value_to_nick, + e_binding_transform_enum_nick_to_value, + NULL, (GDestroyNotify) NULL); widget = e_builder_get_widget (prefs->builder, "start_of_day"); prefs->start_of_day = widget; /* XXX delete this */ diff --git a/modules/calendar/e-calendar-preferences.ui b/modules/calendar/e-calendar-preferences.ui index cb508ae3be..7af3f2036d 100644 --- a/modules/calendar/e-calendar-preferences.ui +++ b/modules/calendar/e-calendar-preferences.ui @@ -19,35 +19,6 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> - <object class="GtkListStore" id="model1"> - <columns> - <!-- column-name gchararray --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">Monday</col> - </row> - <row> - <col id="0" translatable="yes">Tuesday</col> - </row> - <row> - <col id="0" translatable="yes">Wednesday</col> - </row> - <row> - <col id="0" translatable="yes">Thursday</col> - </row> - <row> - <col id="0" translatable="yes">Friday</col> - </row> - <row> - <col id="0" translatable="yes">Saturday</col> - </row> - <row> - <col id="0" translatable="yes">Sunday</col> - </row> - </data> - </object> <object class="GtkListStore" id="model2"> <columns> <!-- column-name gchararray --> @@ -588,15 +559,17 @@ </packing> </child> <child> - <object class="GtkComboBox" id="week_start_day"> + <object class="GtkComboBoxText" id="week_start_day"> <property name="visible">True</property> - <property name="model">model1</property> - <child> - <object class="GtkCellRendererText" id="renderer1"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> + <items> + <item translatable="yes" id="monday">Monday</item> + <item translatable="yes" id="tuesday">Tuesday</item> + <item translatable="yes" id="wednesday">Wednesday</item> + <item translatable="yes" id="thursday">Thursday</item> + <item translatable="yes" id="friday">Friday</item> + <item translatable="yes" id="saturday">Saturday</item> + <item translatable="yes" id="sunday">Sunday</item> + </items> </object> <packing> <property name="left_attach">1</property> |