project: Make time format a first-class citizen
The current code deals with 12/24h clock formats almost like a workaround of the issue. This commit adds proper support to different clock formats.
This commit is contained in:
@@ -111,11 +111,6 @@ struct _GcalMonthView
|
||||
GDateTime *start_mark_cell;
|
||||
GDateTime *end_mark_cell;
|
||||
|
||||
/*
|
||||
* clock format from GNOME desktop settings
|
||||
*/
|
||||
gboolean use_24h_format;
|
||||
|
||||
/* Storage for the accumulated scrolling */
|
||||
gdouble scroll_value;
|
||||
guint update_grid_id;
|
||||
@@ -2246,16 +2241,3 @@ gcal_month_view_set_first_weekday (GcalMonthView *self,
|
||||
update_weekday_labels (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_month_view_set_use_24h_format:
|
||||
* @view:
|
||||
* @use_24h:
|
||||
*
|
||||
* Whether the view will show time using 24h or 12h format
|
||||
*/
|
||||
void
|
||||
gcal_month_view_set_use_24h_format (GcalMonthView *self,
|
||||
gboolean use_24h)
|
||||
{
|
||||
self->use_24h_format = use_24h;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ struct _GcalWeekGrid
|
||||
GdkWindow *event_window;
|
||||
|
||||
gint first_weekday;
|
||||
gboolean use_24h_format : 1;
|
||||
|
||||
icaltimetype *active_date;
|
||||
|
||||
@@ -1154,15 +1153,6 @@ gcal_week_grid_set_first_weekday (GcalWeekGrid *self,
|
||||
self->first_weekday = nr_day;
|
||||
}
|
||||
|
||||
void
|
||||
gcal_week_grid_set_use_24h_format (GcalWeekGrid *self,
|
||||
gboolean use_24h_format)
|
||||
{
|
||||
g_return_if_fail (GCAL_IS_WEEK_GRID (self));
|
||||
|
||||
self->use_24h_format = use_24h_format;
|
||||
}
|
||||
|
||||
void
|
||||
gcal_week_grid_add_event (GcalWeekGrid *self,
|
||||
GcalEvent *event)
|
||||
|
||||
@@ -36,9 +36,6 @@ void gcal_week_grid_set_manager (GcalWeekGrid
|
||||
void gcal_week_grid_set_first_weekday (GcalWeekGrid *week_grid,
|
||||
gint nr_day);
|
||||
|
||||
void gcal_week_grid_set_use_24h_format (GcalWeekGrid *week_grid,
|
||||
gboolean use_24h_format);
|
||||
|
||||
void gcal_week_grid_add_event (GcalWeekGrid *self,
|
||||
GcalEvent *event);
|
||||
|
||||
|
||||
@@ -86,8 +86,6 @@ struct _GcalWeekHeader
|
||||
*/
|
||||
gboolean expanded;
|
||||
|
||||
gboolean use_24h_format;
|
||||
|
||||
icaltimetype *active_date;
|
||||
|
||||
gint selection_start;
|
||||
@@ -1834,15 +1832,6 @@ gcal_week_header_set_first_weekday (GcalWeekHeader *self,
|
||||
self->first_weekday = nr_day;
|
||||
}
|
||||
|
||||
void
|
||||
gcal_week_header_set_use_24h_format (GcalWeekHeader *self,
|
||||
gboolean use_24h_format)
|
||||
{
|
||||
g_return_if_fail (GCAL_IS_WEEK_HEADER (self));
|
||||
|
||||
self->use_24h_format = use_24h_format;
|
||||
}
|
||||
|
||||
void
|
||||
gcal_week_header_add_event (GcalWeekHeader *self,
|
||||
GcalEvent *event)
|
||||
|
||||
@@ -38,9 +38,6 @@ void gcal_week_header_set_manager (GcalWeekHeader
|
||||
void gcal_week_header_set_first_weekday (GcalWeekHeader *self,
|
||||
gint nr_day);
|
||||
|
||||
void gcal_week_header_set_use_24h_format (GcalWeekHeader *self,
|
||||
gboolean use_24h_format);
|
||||
|
||||
void gcal_week_header_add_event (GcalWeekHeader *self,
|
||||
GcalEvent *event);
|
||||
|
||||
|
||||
+24
-20
@@ -19,6 +19,7 @@
|
||||
#define G_LOG_DOMAIN "GcalWeekView"
|
||||
|
||||
#include "gcal-debug.h"
|
||||
#include "gcal-enums.h"
|
||||
#include "gcal-event-widget.h"
|
||||
#include "gcal-utils.h"
|
||||
#include "gcal-view.h"
|
||||
@@ -54,10 +55,8 @@ struct _GcalWeekView
|
||||
*/
|
||||
gint first_weekday;
|
||||
|
||||
/*
|
||||
* clock format from GNOME desktop settings
|
||||
*/
|
||||
gboolean use_24h_format;
|
||||
|
||||
GcalTimeFormat time_format;
|
||||
|
||||
/* property */
|
||||
icaltimetype *date;
|
||||
@@ -80,6 +79,7 @@ enum
|
||||
PROP_0,
|
||||
PROP_DATE,
|
||||
PROP_MANAGER,
|
||||
PROP_TIME_FORMAT,
|
||||
PROP_WEATHER_SERVICE,
|
||||
NUM_PROPS
|
||||
};
|
||||
@@ -429,7 +429,7 @@ gcal_week_view_draw_hours (GcalWeekView *self,
|
||||
{
|
||||
gchar *hours;
|
||||
|
||||
if (self->use_24h_format)
|
||||
if (self->time_format == GCAL_TIME_FORMAT_24H)
|
||||
{
|
||||
hours = g_strdup_printf ("%02d:00", i);
|
||||
}
|
||||
@@ -543,6 +543,12 @@ gcal_week_view_set_property (GObject *object,
|
||||
g_object_notify (object, "manager");
|
||||
break;
|
||||
|
||||
case PROP_TIME_FORMAT:
|
||||
g_debug ("BLAAA");
|
||||
self->time_format = g_value_get_enum (value);
|
||||
gtk_widget_queue_draw (self->hours_bar);
|
||||
break;
|
||||
|
||||
case PROP_WEATHER_SERVICE:
|
||||
if (g_set_object (&self->weather_service, g_value_get_object (value)))
|
||||
g_object_notify (object, "weather-service");
|
||||
@@ -575,6 +581,10 @@ gcal_week_view_get_property (GObject *object,
|
||||
g_value_set_object (value, self->manager);
|
||||
break;
|
||||
|
||||
case PROP_TIME_FORMAT:
|
||||
g_value_set_enum (value, self->time_format);
|
||||
break;
|
||||
|
||||
case PROP_WEATHER_SERVICE:
|
||||
g_value_set_object (value, self->weather_service);
|
||||
break;
|
||||
@@ -602,6 +612,15 @@ gcal_week_view_class_init (GcalWeekViewClass *klass)
|
||||
g_object_class_override_property (object_class, PROP_MANAGER, "manager");
|
||||
g_object_class_override_property (object_class, PROP_WEATHER_SERVICE, "weather-service");
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_TIME_FORMAT,
|
||||
g_param_spec_enum ("time-format",
|
||||
"Time format",
|
||||
"Time format",
|
||||
GCAL_TYPE_TIME_FORMAT,
|
||||
GCAL_TIME_FORMAT_24H,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/week-view.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWeekView, header);
|
||||
@@ -661,18 +680,3 @@ gcal_week_view_set_first_weekday (GcalWeekView *self,
|
||||
gcal_week_grid_set_first_weekday (GCAL_WEEK_GRID (self->week_grid), self->first_weekday);
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_week_view_set_use_24h_format:
|
||||
* @view:
|
||||
* @use_24h:
|
||||
*
|
||||
* Whether the view will show time using 24h or 12h format
|
||||
**/
|
||||
void
|
||||
gcal_week_view_set_use_24h_format (GcalWeekView *self,
|
||||
gboolean use_24h)
|
||||
{
|
||||
g_return_if_fail (GCAL_IS_WEEK_VIEW (self));
|
||||
|
||||
self->use_24h_format = use_24h;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,6 @@ GtkWidget* gcal_week_view_new (void);
|
||||
void gcal_week_view_set_first_weekday (GcalWeekView *self,
|
||||
gint day_nr);
|
||||
|
||||
void gcal_week_view_set_use_24h_format (GcalWeekView *self,
|
||||
gboolean use_24h);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GCAL_WEEK_VIEW_H__ */
|
||||
|
||||
@@ -97,11 +97,6 @@ struct _GcalYearView
|
||||
/* Storage for the accumulated scrolling */
|
||||
gdouble scroll_value;
|
||||
|
||||
/**
|
||||
* clock format from GNOME desktop settings
|
||||
*/
|
||||
gboolean use_24h_format;
|
||||
|
||||
/* show week numbers from GNOME Shell settings */
|
||||
GSettings *calendar_settings;
|
||||
gboolean show_week_numbers;
|
||||
@@ -2108,10 +2103,3 @@ gcal_year_view_set_first_weekday (GcalYearView *year_view,
|
||||
{
|
||||
year_view->first_weekday = nr_day;
|
||||
}
|
||||
|
||||
void
|
||||
gcal_year_view_set_use_24h_format (GcalYearView *year_view,
|
||||
gboolean use_24h_format)
|
||||
{
|
||||
year_view->use_24h_format = use_24h_format;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,6 @@ G_DECLARE_FINAL_TYPE (GcalYearView, gcal_year_view, GCAL, YEAR_VIEW, GtkBox)
|
||||
void gcal_year_view_set_first_weekday (GcalYearView *year_view,
|
||||
gint nr_day);
|
||||
|
||||
void gcal_year_view_set_use_24h_format (GcalYearView *year_view,
|
||||
gboolean use_24h_format);
|
||||
|
||||
void gcal_year_view_set_current_date (GcalYearView *year_view,
|
||||
icaltimetype *current_date);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user