From ae7834726aff9bedbd0bcec14c167d6b7d292bbc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 14 Jul 2010 11:37:01 -0500 Subject: Ignoring the tramp stamp --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index 6504595..79f4fe1 100644 --- a/.bzrignore +++ b/.bzrignore @@ -6,3 +6,4 @@ src/indicator-datetime-service po/indicator-datetime.pot indicator-datetime-[0-9].[0-9].[0-9].tar.gz data/indicator-datetime.service +data/org.ayatana.indicator.datetime.gschema.valid -- cgit v1.2.3 From 3575d726899cdb7ce8f928fe2f873c925c8cb9e3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Jul 2010 15:02:17 -0500 Subject: I swear, there were somethings I didn't change! Getting some final settings that make sense. --- data/org.ayatana.indicator.datetime.gschema.xml | 56 ++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/data/org.ayatana.indicator.datetime.gschema.xml b/data/org.ayatana.indicator.datetime.gschema.xml index 5833d63..c794d83 100644 --- a/data/org.ayatana.indicator.datetime.gschema.xml +++ b/data/org.ayatana.indicator.datetime.gschema.xml @@ -1,9 +1,61 @@ + + + + + + - + + 'locale-default' + What the time format should be + + Controls the time format that is displayed in the indicator. For almost + all users this should be the default for their locale. If you think the + setting is wrong for your locale please join or talk to the translation + team for your langauge. If you just want something different you can + adjust this to be either 12 or 24 time. Or, you can use a custom format + string and set the custom-time-format setting. + + + + false + Show the number of seconds in the indicator + + Makes the datetime indicator show the number of seconds in the indicator. + It's important to note that this will cause additional battery drain as + the time will update 60 times as often, so it is not recommended. Also, + this setting will be ignored if the time-format value is set to custom. + + + + false + Show the day of the week in the indicator + + Puts the day of the week on the panel along with the time and/or date + depending on settings. This setting will be ignored if the time-format + value is set to custom. + + + + false + Show the month and date in the indicator + + Puts the month and the date in the panel along with the time and/or day + of the week depending on settings. This setting will be ignored if the + time-format value is set to custom. + + + "%l:%M %p" The format string passed to strftime - The format of the time and/or date that is visible on the panel when using the indicator. For most users this will be a set of predefined values as determined by the configuration utility, but advanced users can change it to anything strftime can accept. Look at the man page on strftime for more information. + + The format of the time and/or date that is visible on the panel when using + the indicator. For most users this will be a set of predefined values as + determined by the configuration utility, but advanced users can change it + to anything strftime can accept. Look at the man page on strftime for + more information. + -- cgit v1.2.3 From c3563f869fcf33736919e95acc159c08b3f9faa1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Jul 2010 15:18:49 -0500 Subject: Getting defines for all the new settings and making things compile again. --- src/indicator-datetime.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 4779313..f7449c9 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -84,10 +84,23 @@ enum { #define PROP_TIME_FORMAT_S "time-format" -#define SETTING_INTERFACE "org.ayatana.indicator.datetime" -#define SETTING_TIME_FORMAT_S "indicator-time-format" +#define SETTINGS_INTERFACE "org.ayatana.indicator.datetime" +#define SETTINGS_TIME_FORMAT "time-format" +#define SETTINGS_SHOW_SECONDS "show-seconds" +#define SETTINGS_SHOW_DAY "show-day" +#define SETTINGS_SHOW_DATE "show-date" +#define SETTINGS_CUSTOM_TIME_FORMAT_S "custom-time-format" -#define DEFAULT_TIME_FORMAT "%l:%M %p" +enum { + SETTINGS_TIME_LOCALE = 0, + SETTINGS_TIME_12_HOUR = 1, + SETTINGS_TIME_24_HOUR = 2, + SETTINGS_TIME_CUSTOM = 3 +}; + +#define DEFAULT_TIME_12_FORMAT "%l:%M %p" +#define DEFAULT_TIME_24_FORMAT "%H:%M" +#define DEFAULT_TIME_FORMAT DEFAULT_TIME_12_FORMAT #define INDICATOR_DATETIME_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_DATETIME_TYPE, IndicatorDatetimePrivate)) @@ -159,15 +172,15 @@ indicator_datetime_init (IndicatorDatetime *self) self->priv->sm = NULL; self->priv->menu = NULL; - self->priv->settings = g_settings_new(SETTING_INTERFACE); + self->priv->settings = g_settings_new(SETTINGS_INTERFACE); if (self->priv->settings != NULL) { g_settings_bind(self->priv->settings, - SETTING_TIME_FORMAT_S, + SETTINGS_CUSTOM_TIME_FORMAT_S, self, PROP_TIME_FORMAT_S, G_SETTINGS_BIND_DEFAULT); } else { - g_warning("Unable to get settings for '" SETTING_INTERFACE "'"); + g_warning("Unable to get settings for '" SETTINGS_INTERFACE "'"); } self->priv->sm = indicator_service_manager_new_version(SERVICE_NAME, SERVICE_VERSION); -- cgit v1.2.3 From a5fe313e98d9b8df5ab952fb0fecb7449f9d8524 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Jul 2010 15:24:45 -0500 Subject: Turning the time format string into custom time format. --- src/indicator-datetime.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index f7449c9..c4fc933 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -79,10 +79,12 @@ struct _IndicatorDatetimePrivate { found and looked up. */ enum { PROP_0, - PROP_TIME_FORMAT + PROP_TIME_FORMAT, + PROP_CUSTOM_TIME_FORMAT }; #define PROP_TIME_FORMAT_S "time-format" +#define PROP_CUSTOM_TIME_FORMAT_S "time-format" #define SETTINGS_INTERFACE "org.ayatana.indicator.datetime" #define SETTINGS_TIME_FORMAT "time-format" @@ -141,13 +143,13 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass) io_class->get_menu = get_menu; /** - IndicatorDatetime:time-format: + IndicatorDatetime:custom-time-format: The format that is used to show the time on the panel. */ g_object_class_install_property (object_class, - PROP_TIME_FORMAT, - g_param_spec_string(PROP_TIME_FORMAT_S, + 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.", DEFAULT_TIME_FORMAT, @@ -177,7 +179,7 @@ indicator_datetime_init (IndicatorDatetime *self) g_settings_bind(self->priv->settings, SETTINGS_CUSTOM_TIME_FORMAT_S, self, - PROP_TIME_FORMAT_S, + PROP_CUSTOM_TIME_FORMAT_S, G_SETTINGS_BIND_DEFAULT); } else { g_warning("Unable to get settings for '" SETTINGS_INTERFACE "'"); @@ -244,7 +246,7 @@ indicator_datetime_finalize (GObject *object) static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { - g_return_if_fail(prop_id == PROP_TIME_FORMAT); + g_return_if_fail(prop_id == PROP_CUSTOM_TIME_FORMAT); IndicatorDatetime * self = INDICATOR_DATETIME(object); if (self->priv->time_format != NULL) { @@ -261,7 +263,7 @@ set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { - g_return_if_fail(prop_id == PROP_TIME_FORMAT); + g_return_if_fail(prop_id == PROP_CUSTOM_TIME_FORMAT); IndicatorDatetime * self = INDICATOR_DATETIME(object); g_value_set_string(value, self->priv->time_format); -- cgit v1.2.3 From 6d7a5eeb4c4d91ae4490b27d13c6bad39098486d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Jul 2010 15:41:56 -0500 Subject: Whoa, we got lots of properties now. --- src/indicator-datetime.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index c4fc933..500f091 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -80,11 +80,17 @@ struct _IndicatorDatetimePrivate { enum { PROP_0, PROP_TIME_FORMAT, + PROP_SHOW_SECONDS, + PROP_SHOW_DAY, + PROP_SHOW_DATE, PROP_CUSTOM_TIME_FORMAT }; -#define PROP_TIME_FORMAT_S "time-format" -#define PROP_CUSTOM_TIME_FORMAT_S "time-format" +#define PROP_TIME_FORMAT_S "time-format" +#define PROP_SHOW_SECONDS_S "show-seconds" +#define PROP_SHOW_DAY_S "show-day" +#define PROP_SHOW_DATE_S "show-date" +#define PROP_CUSTOM_TIME_FORMAT_S "custom-time-format" #define SETTINGS_INTERFACE "org.ayatana.indicator.datetime" #define SETTINGS_TIME_FORMAT "time-format" @@ -142,11 +148,36 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass) io_class->get_label = get_label; io_class->get_menu = get_menu; - /** - IndicatorDatetime:custom-time-format: - - The format that is used to show the time on the panel. - */ + g_object_class_install_property (object_class, + 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().", + SETTINGS_TIME_LOCALE, /* min */ + SETTINGS_TIME_CUSTOM, /* max */ + SETTINGS_TIME_LOCALE, /* default */ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, + PROP_SHOW_SECONDS, + g_param_spec_boolean(PROP_SHOW_SECONDS_S, + "Whether to show seconds in the indicator.", + "Shows seconds along with the time in the indicator. Also effects refresh interval.", + FALSE, /* default */ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, + PROP_SHOW_DAY, + g_param_spec_boolean(PROP_SHOW_DAY_S, + "Whether to show the day of the week in the indicator.", + "Shows the day of the week along with the time in the indicator.", + FALSE, /* default */ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, + PROP_SHOW_DATE, + g_param_spec_boolean(PROP_SHOW_DATE_S, + "Whether to show the day and month in the indicator.", + "Shows the day and month along with the time in the indicator.", + FALSE, /* default */ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_CUSTOM_TIME_FORMAT, g_param_spec_string(PROP_CUSTOM_TIME_FORMAT_S, -- cgit v1.2.3 From 8fb0d0bf48f4cdc374683ed207df16c02a0fa756 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Jul 2010 15:46:02 -0500 Subject: Binding the properties into the settings database. --- src/indicator-datetime.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 500f091..de0edb7 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -93,10 +93,10 @@ enum { #define PROP_CUSTOM_TIME_FORMAT_S "custom-time-format" #define SETTINGS_INTERFACE "org.ayatana.indicator.datetime" -#define SETTINGS_TIME_FORMAT "time-format" -#define SETTINGS_SHOW_SECONDS "show-seconds" -#define SETTINGS_SHOW_DAY "show-day" -#define SETTINGS_SHOW_DATE "show-date" +#define SETTINGS_TIME_FORMAT_S "time-format" +#define SETTINGS_SHOW_SECONDS_S "show-seconds" +#define SETTINGS_SHOW_DAY_S "show-day" +#define SETTINGS_SHOW_DATE_S "show-date" #define SETTINGS_CUSTOM_TIME_FORMAT_S "custom-time-format" enum { @@ -207,6 +207,26 @@ indicator_datetime_init (IndicatorDatetime *self) self->priv->settings = g_settings_new(SETTINGS_INTERFACE); if (self->priv->settings != NULL) { + g_settings_bind(self->priv->settings, + SETTINGS_TIME_FORMAT_S, + self, + PROP_TIME_FORMAT_S, + G_SETTINGS_BIND_DEFAULT); + g_settings_bind(self->priv->settings, + SETTINGS_SHOW_SECONDS_S, + self, + PROP_SHOW_SECONDS_S, + G_SETTINGS_BIND_DEFAULT); + g_settings_bind(self->priv->settings, + SETTINGS_SHOW_DAY_S, + self, + PROP_SHOW_DAY_S, + G_SETTINGS_BIND_DEFAULT); + g_settings_bind(self->priv->settings, + SETTINGS_SHOW_DATE_S, + self, + PROP_SHOW_DATE_S, + G_SETTINGS_BIND_DEFAULT); g_settings_bind(self->priv->settings, SETTINGS_CUSTOM_TIME_FORMAT_S, self, -- cgit v1.2.3 From 533863c215051dd84213daa03f7aa214f64d11cd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Jul 2010 16:12:12 -0500 Subject: Moving all these properties into the private structure. --- src/indicator-datetime.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index de0edb7..52785bb 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -64,7 +64,13 @@ struct _IndicatorDatetimePrivate { GtkLabel * label; guint timer; - gchar * time_format; + gchar * time_string; + + gint time_mode; + gboolean show_seconds; + gboolean show_date; + gboolean show_day; + gchar * custom_string; guint idle_measure; gint max_width; @@ -200,7 +206,13 @@ indicator_datetime_init (IndicatorDatetime *self) self->priv->idle_measure = 0; self->priv->max_width = 0; - self->priv->time_format = g_strdup(DEFAULT_TIME_FORMAT); + self->priv->time_string = g_strdup(DEFAULT_TIME_FORMAT); + + self->priv->time_mode = SETTINGS_TIME_LOCALE; + self->priv->show_seconds = FALSE; + self->priv->show_date = FALSE; + self->priv->show_day = FALSE; + self->priv->custom_string = g_strdup(DEFAULT_TIME_FORMAT); self->priv->sm = NULL; self->priv->menu = NULL; @@ -285,9 +297,14 @@ indicator_datetime_finalize (GObject *object) { IndicatorDatetime * self = INDICATOR_DATETIME(object); - if (self->priv->time_format != NULL) { - g_free(self->priv->time_format); - self->priv->time_format = NULL; + if (self->priv->time_string != NULL) { + g_free(self->priv->time_string); + self->priv->time_string = NULL; + } + + if (self->priv->custom_string != NULL) { + g_free(self->priv->custom_string); + self->priv->custom_string = NULL; } G_OBJECT_CLASS (indicator_datetime_parent_class)->finalize (object); -- cgit v1.2.3 From 4de10d0ced1994599c040223fcd5012886f3d872 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Jul 2010 16:13:18 -0500 Subject: Clearing set and get property as we're going to have to start from scratch there. --- src/indicator-datetime.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 52785bb..13d22e3 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -314,28 +314,12 @@ indicator_datetime_finalize (GObject *object) static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { - g_return_if_fail(prop_id == PROP_CUSTOM_TIME_FORMAT); - IndicatorDatetime * self = INDICATOR_DATETIME(object); - - if (self->priv->time_format != NULL) { - g_free(self->priv->time_format); - self->priv->time_format = NULL; - } - - self->priv->time_format = g_value_dup_string(value); - g_debug("Changing time format to '%s'", self->priv->time_format); - return; } static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { - g_return_if_fail(prop_id == PROP_CUSTOM_TIME_FORMAT); - IndicatorDatetime * self = INDICATOR_DATETIME(object); - - g_value_set_string(value, self->priv->time_format); - return; } @@ -381,7 +365,7 @@ update_label (IndicatorDatetime * io) return; } - strftime(longstr, 128, self->priv->time_format, ltime); + strftime(longstr, 128, self->priv->time_string, ltime); gchar * utf8 = g_locale_to_utf8(longstr, -1, NULL, NULL, NULL); gtk_label_set_label(self->priv->label, utf8); -- cgit v1.2.3