aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-datetime.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/indicator-datetime.c')
-rw-r--r--src/indicator-datetime.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index 16ad131..61cfc5f 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -144,9 +144,6 @@ struct _indicator_item_t {
#define PROP_SHOW_WEEK_NUMBERS_S "show-week-numbers"
#define PROP_SHOW_CALENDAR_S "show-calendar"
-#define INDICATOR_DATETIME_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_DATETIME_TYPE, IndicatorDatetimePrivate))
-
enum {
STRFTIME_MASK_NONE = 0, /* Hours or minutes as we always test those */
STRFTIME_MASK_SECONDS = 1 << 0, /* Seconds count */
@@ -159,7 +156,7 @@ enum {
STRFTIME_MASK_ALL = (STRFTIME_MASK_SECONDS | STRFTIME_MASK_AMPM | STRFTIME_MASK_WEEK | STRFTIME_MASK_DAY | STRFTIME_MASK_MONTH | STRFTIME_MASK_YEAR)
};
-GType indicator_datetime_get_type (void);
+GType indicator_datetime_get_type (void) G_GNUC_CONST;
static void indicator_datetime_class_init (IndicatorDatetimeClass *klass);
static void indicator_datetime_init (IndicatorDatetime *self);
@@ -221,7 +218,7 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass)
PROP_TIME_FORMAT,
g_param_spec_int(PROP_TIME_FORMAT_S,
"A choice of which format should be used on the panel",
- "Chooses between letting the locale choose the time, 12-hour time, 24-time or using the custom string passed to strftime().",
+ "Chooses between letting the locale choose the time, 12-hour time, 24-time or using the custom string passed to g_date_time_format().",
SETTINGS_TIME_LOCALE, /* min */
SETTINGS_TIME_CUSTOM, /* max */
SETTINGS_TIME_LOCALE, /* default */
@@ -251,7 +248,7 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass)
PROP_CUSTOM_TIME_FORMAT,
g_param_spec_string(PROP_CUSTOM_TIME_FORMAT_S,
"The format that is used to show the time on the panel.",
- "A format string in the form used to pass to strftime to make a string for displaying on the panel.",
+ "A format string in the form used to pass to g_date_time_format() to make a string for displaying on the panel.",
DEFAULT_TIME_FORMAT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
@@ -297,7 +294,9 @@ menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointe
static void
indicator_datetime_init (IndicatorDatetime *self)
{
- self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ INDICATOR_DATETIME_TYPE,
+ IndicatorDatetimePrivate);
self->priv->label = NULL;
@@ -410,11 +409,10 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
g_return_if_fail(self != NULL);
+ IndicatorDatetimePrivate * priv = self->priv;
GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
- IndicatorDatetimePrivate * priv = INDICATOR_DATETIME_GET_PRIVATE(self);
-
if (priv->service_proxy_cancel != NULL) {
g_object_unref(priv->service_proxy_cancel);
priv->service_proxy_cancel = NULL;
@@ -547,7 +545,8 @@ bind_enum_get (GValue * value, GVariant * variant, gpointer user_data)
static void
timezone_update_all_labels (IndicatorDatetime * self)
{
- IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self);
+ IndicatorDatetimePrivate *priv = self->priv;
+
g_list_foreach(priv->timezone_items, (GFunc)timezone_update_labels, NULL);
}
@@ -791,6 +790,12 @@ set_label_to_time_in_zone (IndicatorDatetime * self, GtkLabel * label,
}
else {
timestr = g_date_time_format(datetime_now, format);
+ if (timestr == NULL) {
+ g_warning ("The custom date format is not valid, check the\n"
+ "g_date_time_format() documentation for the supported\n"
+ "format specifiers ");
+ timestr = g_strdup ("Date format not supported");
+ }
}
gboolean use_markup = FALSE;
@@ -1359,8 +1364,7 @@ new_calendar_item (DbusmenuMenuitem * newitem,
/* Note: not checking parent, it's reasonable for it to be NULL */
IndicatorDatetime *self = INDICATOR_DATETIME(user_data);
- self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);
-
+
IdoCalendarMenuItem *ido = IDO_CALENDAR_MENU_ITEM (ido_calendar_menu_item_new ());
self->priv->ido_calendar = ido;
@@ -1404,7 +1408,9 @@ timezone_toggled_cb (GtkCheckMenuItem *checkmenuitem, DbusmenuMenuitem * dbusite
static void
timezone_destroyed_cb (indicator_item_t * mi_data, DbusmenuMenuitem * dbusitem)
{
- IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(mi_data->self);
+ IndicatorDatetime *self = INDICATOR_DATETIME (mi_data->self);
+ IndicatorDatetimePrivate *priv = self->priv;
+
priv->timezone_items = g_list_remove(priv->timezone_items, mi_data);
g_signal_handlers_disconnect_by_func(G_OBJECT(mi_data->gmi), G_CALLBACK(timezone_toggled_cb), dbusitem);
g_free(mi_data);
@@ -1422,7 +1428,7 @@ new_timezone_item(DbusmenuMenuitem * newitem,
/* Note: not checking parent, it's reasonable for it to be NULL */
IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
- IndicatorDatetimePrivate *priv = INDICATOR_DATETIME_GET_PRIVATE(self);
+ IndicatorDatetimePrivate *priv = self->priv;
// Menu item with a radio button and a right aligned time
indicator_item_t * mi_data = g_new0(indicator_item_t, 1);