aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-07-12 20:58:24 -0500
committerTed Gould <ted@gould.cx>2010-07-12 20:58:24 -0500
commitfe6129a2aec01220da2e413a9141980bbd827ae8 (patch)
tree2a45dccba3d7fcc3851e3641e85bd111b16535f0
parentd051dbe509a1e88a0c3047a19c94130d58a9aa94 (diff)
parenta994c55bc39f419ce752d02a60bc01d5659aad62 (diff)
downloadayatana-indicator-datetime-fe6129a2aec01220da2e413a9141980bbd827ae8.tar.gz
ayatana-indicator-datetime-fe6129a2aec01220da2e413a9141980bbd827ae8.tar.bz2
ayatana-indicator-datetime-fe6129a2aec01220da2e413a9141980bbd827ae8.zip
* Merge upstream
* Adding in GSettings for configuring the format on the panel.
-rw-r--r--configure.ac10
-rw-r--r--data/Makefile.am4
-rw-r--r--data/org.ayatana.indicator.datetime.gschema.xml9
-rw-r--r--debian/changelog7
-rw-r--r--src/indicator-datetime.c91
5 files changed, 119 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 9bf0a3c..460aadc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,15 +35,23 @@ PKG_PROG_PKG_CONFIG
INDICATOR_REQUIRED_VERSION=0.3.0
DBUSMENUGLIB_REQUIRED_VERSION=0.1.1
DBUSMENUGTK_REQUIRED_VERSION=0.1.1
+GIO_REQUIRED_VERSION=2.25.0
PKG_CHECK_MODULES(INDICATOR, indicator >= $INDICATOR_REQUIRED_VERSION
dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION
- dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION)
+ dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION
+ gio-2.0 >= $GIO_REQUIRED_VERSION)
AC_SUBST(INDICATOR_CFLAGS)
AC_SUBST(INDICATOR_LIBS)
###########################
+# Grab the GSettings Macros
+###########################
+
+GLIB_GSETTINGS
+
+###########################
# Check to see if we're local
###########################
diff --git a/data/Makefile.am b/data/Makefile.am
index b19cee4..2e6900c 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,9 @@
#SUBDIRS = icons
+gsettings_SCHEMAS = \
+ org.ayatana.indicator.datetime.gschema.xml
+@GSETTINGS_RULES@
+
dbus_servicesdir = $(DBUSSERVICEDIR)
dbus_services_DATA = indicator-datetime.service
diff --git a/data/org.ayatana.indicator.datetime.gschema.xml b/data/org.ayatana.indicator.datetime.gschema.xml
new file mode 100644
index 0000000..5833d63
--- /dev/null
+++ b/data/org.ayatana.indicator.datetime.gschema.xml
@@ -0,0 +1,9 @@
+<schemalist>
+ <schema id="org.ayatana.indicator.datetime" path="/apps/indicators/datetime/" gettext-domain="indicator-datetime">
+ <key name="indicator-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>
+ </key>
+ </schema>
+</schemalist>
diff --git a/debian/changelog b/debian/changelog
index 0913c6f..19b025e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+indicator-datetime (0.0.3-0ubuntu2~ppa1~confmat1) UNRELEASED; urgency=low
+
+ * Merge upstream
+ * Adding in GSettings for configuring the format on the panel.
+
+ -- Ted Gould <ted@ubuntu.com> Mon, 12 Jul 2010 20:57:15 -0500
+
indicator-datetime (0.0.3-0ubuntu2~ppa1~service1) lucid; urgency=low
* Merge upstream
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index 6b32f1a..4779313 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -27,6 +27,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <glib.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
+#include <gio/gio.h>
/* Indicator Stuff */
#include <libindicator/indicator.h>
@@ -63,13 +64,31 @@ struct _IndicatorDatetimePrivate {
GtkLabel * label;
guint timer;
+ gchar * time_format;
+
guint idle_measure;
gint max_width;
IndicatorServiceManager * sm;
DbusmenuGtkMenu * menu;
+
+ GSettings * settings;
};
+/* Enum for the properties so that they can be quickly
+ found and looked up. */
+enum {
+ PROP_0,
+ PROP_TIME_FORMAT
+};
+
+#define PROP_TIME_FORMAT_S "time-format"
+
+#define SETTING_INTERFACE "org.ayatana.indicator.datetime"
+#define SETTING_TIME_FORMAT_S "indicator-time-format"
+
+#define DEFAULT_TIME_FORMAT "%l:%M %p"
+
#define INDICATOR_DATETIME_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_DATETIME_TYPE, IndicatorDatetimePrivate))
@@ -77,6 +96,8 @@ GType indicator_datetime_get_type (void);
static void indicator_datetime_class_init (IndicatorDatetimeClass *klass);
static void indicator_datetime_init (IndicatorDatetime *self);
+static void set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec);
+static void get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec);
static void indicator_datetime_dispose (GObject *object);
static void indicator_datetime_finalize (GObject *object);
static GtkLabel * get_label (IndicatorObject * io);
@@ -98,11 +119,27 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass)
object_class->dispose = indicator_datetime_dispose;
object_class->finalize = indicator_datetime_finalize;
+ object_class->set_property = set_property;
+ object_class->get_property = get_property;
+
IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(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,
+ "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,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
return;
}
@@ -117,9 +154,22 @@ 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->sm = NULL;
self->priv->menu = NULL;
+ self->priv->settings = g_settings_new(SETTING_INTERFACE);
+ if (self->priv->settings != NULL) {
+ g_settings_bind(self->priv->settings,
+ SETTING_TIME_FORMAT_S,
+ self,
+ PROP_TIME_FORMAT_S,
+ G_SETTINGS_BIND_DEFAULT);
+ } else {
+ g_warning("Unable to get settings for '" SETTING_INTERFACE "'");
+ }
+
self->priv->sm = indicator_service_manager_new_version(SERVICE_NAME, SERVICE_VERSION);
return;
@@ -155,6 +205,11 @@ indicator_datetime_dispose (GObject *object)
self->priv->sm = NULL;
}
+ if (self->priv->settings != NULL) {
+ g_object_unref(G_OBJECT(self->priv->settings));
+ self->priv->settings = NULL;
+ }
+
G_OBJECT_CLASS (indicator_datetime_parent_class)->dispose (object);
return;
}
@@ -162,11 +217,45 @@ indicator_datetime_dispose (GObject *object)
static void
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;
+ }
G_OBJECT_CLASS (indicator_datetime_parent_class)->finalize (object);
return;
}
+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;
+}
+
/* Looks at the size of the label, if it grew beyond what we
thought was the max, make sure it doesn't shrink again. */
static gboolean
@@ -209,7 +298,7 @@ update_label (IndicatorDatetime * io)
return;
}
- strftime(longstr, 128, "%l:%M %p", ltime);
+ strftime(longstr, 128, self->priv->time_format, ltime);
gchar * utf8 = g_locale_to_utf8(longstr, -1, NULL, NULL, NULL);
gtk_label_set_label(self->priv->label, utf8);