aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-07-15 21:26:16 -0500
committerTed Gould <ted@gould.cx>2010-07-15 21:26:16 -0500
commitbe38ec815f69218a152ec40ddc0ba4b4239cb901 (patch)
tree1e693d6293993043f47e722d9805def677add5be
parentfc3ab7720e32da20cf06c2b0e6af2aac0cc44f73 (diff)
parent4de10d0ced1994599c040223fcd5012886f3d872 (diff)
downloadayatana-indicator-datetime-be38ec815f69218a152ec40ddc0ba4b4239cb901.tar.gz
ayatana-indicator-datetime-be38ec815f69218a152ec40ddc0ba4b4239cb901.tar.bz2
ayatana-indicator-datetime-be38ec815f69218a152ec40ddc0ba4b4239cb901.zip
* Upstream Merge
* Moving around the preferences to have something more flexible and updating code.
-rw-r--r--data/org.ayatana.indicator.datetime.gschema.xml56
-rw-r--r--debian/changelog8
-rw-r--r--src/indicator-datetime.c139
3 files changed, 165 insertions, 38 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 @@
<schemalist>
+ <enum id="time-enum">
+ <value nick="locale-default" value="0" />
+ <value nick="12-hour" value="1" />
+ <value nick="24-hour" value="2" />
+ <value nick="custom" value="3" />
+ </enum>
<schema id="org.ayatana.indicator.datetime" path="/apps/indicators/datetime/" gettext-domain="indicator-datetime">
- <key name="indicator-time-format" type="s">
+ <key name="time-format" enum="time-enum">
+ <default>'locale-default'</default>
+ <summary>What the time format should be</summary>
+ <description>
+ 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.
+ </description>
+ </key>
+ <key name="show-seconds" type="b">
+ <default>false</default>
+ <summary>Show the number of seconds in the indicator</summary>
+ <description>
+ 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.
+ </description>
+ </key>
+ <key name="show-day" type="b">
+ <default>false</default>
+ <summary>Show the day of the week in the indicator</summary>
+ <description>
+ 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.
+ </description>
+ </key>
+ <key name="show-date" type="b">
+ <default>false</default>
+ <summary>Show the month and date in the indicator</summary>
+ <description>
+ 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.
+ </description>
+ </key>
+ <key name="custom-time-format" type="s">
<default>"%l:%M %p"</default>
<summary>The format string passed to strftime</summary>
- <description>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.</description>
+ <description>
+ 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.
+ </description>
</key>
</schema>
</schemalist>
diff --git a/debian/changelog b/debian/changelog
index a79b5b7..544f06c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+indicator-datetime (0.0.3-0ubuntu2~ppa1~confmat3) UNRELEASED; urgency=low
+
+ * Upstream Merge
+ * Moving around the preferences to have something more flexible
+ and updating code.
+
+ -- Ted Gould <ted@ubuntu.com> Thu, 15 Jul 2010 21:25:40 -0500
+
indicator-datetime (0.0.3-0ubuntu2~ppa1~confmat2) lucid; urgency=low
* Rebuilding for new glib
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index 4779313..13d22e3 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;
@@ -79,15 +85,36 @@ struct _IndicatorDatetimePrivate {
found and looked up. */
enum {
PROP_0,
- PROP_TIME_FORMAT
+ 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_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_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"
-#define SETTING_INTERFACE "org.ayatana.indicator.datetime"
-#define SETTING_TIME_FORMAT_S "indicator-time-format"
+enum {
+ SETTINGS_TIME_LOCALE = 0,
+ SETTINGS_TIME_12_HOUR = 1,
+ SETTINGS_TIME_24_HOUR = 2,
+ SETTINGS_TIME_CUSTOM = 3
+};
-#define DEFAULT_TIME_FORMAT "%l:%M %p"
+#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))
@@ -127,14 +154,39 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass)
io_class->get_label = get_label;
io_class->get_menu = get_menu;
- /**
- IndicatorDatetime: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,
+ 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,
"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,
@@ -154,20 +206,46 @@ 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;
- 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_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,
+ PROP_CUSTOM_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);
@@ -219,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);
@@ -231,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_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_TIME_FORMAT);
- IndicatorDatetime * self = INDICATOR_DATETIME(object);
-
- g_value_set_string(value, self->priv->time_format);
-
return;
}
@@ -298,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);