From 667f56dcaffbbdf9c29b5f0d17fa1293d9d464bc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 12 Jul 2010 16:26:04 -0500 Subject: Trying to build the first gschema file. --- data/org.ayatana.indicator.datetime.gschema | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 data/org.ayatana.indicator.datetime.gschema diff --git a/data/org.ayatana.indicator.datetime.gschema b/data/org.ayatana.indicator.datetime.gschema new file mode 100644 index 0000000..f51cda3 --- /dev/null +++ b/data/org.ayatana.indicator.datetime.gschema @@ -0,0 +1,9 @@ + + + + %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. + + + -- cgit v1.2.3 From 89692e244aab0cf3f3dba3bb489c026be8b386e1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 12 Jul 2010 16:55:18 -0500 Subject: Bringing in the gesttings love. --- configure.ac | 10 +++++++++- data/Makefile.am | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9bf0a3c..460aadc 100644 --- a/configure.ac +++ b/configure.ac @@ -35,14 +35,22 @@ 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..be4c97d 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,5 +1,9 @@ #SUBDIRS = icons +gsettings_SCHEMAS = \ + org.ayatana.indicator.datetime.gschema +@GSETTINGS_RULES@ + dbus_servicesdir = $(DBUSSERVICEDIR) dbus_services_DATA = indicator-datetime.service -- cgit v1.2.3 From 3ef7359d1f7b8db5d46a53ec6f35fc738724ac87 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 12 Jul 2010 16:59:55 -0500 Subject: Renaming file --- data/Makefile.am | 2 +- data/org.ayatana.indicator.datetime.gschema | 9 --------- data/org.ayatana.indicator.datetime.gschema.xml | 9 +++++++++ 3 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 data/org.ayatana.indicator.datetime.gschema create mode 100644 data/org.ayatana.indicator.datetime.gschema.xml diff --git a/data/Makefile.am b/data/Makefile.am index be4c97d..2e6900c 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,7 +1,7 @@ #SUBDIRS = icons gsettings_SCHEMAS = \ - org.ayatana.indicator.datetime.gschema + org.ayatana.indicator.datetime.gschema.xml @GSETTINGS_RULES@ dbus_servicesdir = $(DBUSSERVICEDIR) diff --git a/data/org.ayatana.indicator.datetime.gschema b/data/org.ayatana.indicator.datetime.gschema deleted file mode 100644 index f51cda3..0000000 --- a/data/org.ayatana.indicator.datetime.gschema +++ /dev/null @@ -1,9 +0,0 @@ - - - - %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. - - - diff --git a/data/org.ayatana.indicator.datetime.gschema.xml b/data/org.ayatana.indicator.datetime.gschema.xml new file mode 100644 index 0000000..f51cda3 --- /dev/null +++ b/data/org.ayatana.indicator.datetime.gschema.xml @@ -0,0 +1,9 @@ + + + + %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. + + + -- cgit v1.2.3 From 4f6a98808a8ba52193f25fb3683436c0a043ffa5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 12 Jul 2010 17:07:50 -0500 Subject: Getting the schema to validate. --- data/org.ayatana.indicator.datetime.gschema.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/org.ayatana.indicator.datetime.gschema.xml b/data/org.ayatana.indicator.datetime.gschema.xml index f51cda3..5833d63 100644 --- a/data/org.ayatana.indicator.datetime.gschema.xml +++ b/data/org.ayatana.indicator.datetime.gschema.xml @@ -1,7 +1,7 @@ - - - %l:%M %p + + + "%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. -- cgit v1.2.3 From a173af9719ee3183c360c9e2416c1e16e9e68397 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 12 Jul 2010 20:28:37 -0500 Subject: Setting up basic property stuff and making a husk of a first property. --- src/indicator-datetime.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 6b32f1a..deef2f5 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -70,6 +70,17 @@ struct _IndicatorDatetimePrivate { DbusmenuGtkMenu * menu; }; +/* 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_TIME_FORMAT_S "indicator-time-format" + #define INDICATOR_DATETIME_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), INDICATOR_DATETIME_TYPE, IndicatorDatetimePrivate)) @@ -77,6 +88,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 +111,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.", + "%l:%M %p", + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + return; } @@ -167,6 +196,20 @@ indicator_datetime_finalize (GObject *object) return; } +static void +set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) +{ + + return; +} + +static void +get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) +{ + + 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 -- cgit v1.2.3 From 72de11ccac28b0bad7485a5501bc87329560f39b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 12 Jul 2010 20:35:50 -0500 Subject: Setting up a 'time_format' variable and pulling it into a property. --- src/indicator-datetime.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index deef2f5..847cb8e 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -63,6 +63,8 @@ struct _IndicatorDatetimePrivate { GtkLabel * label; guint timer; + gchar * time_format; + guint idle_measure; gint max_width; @@ -146,6 +148,8 @@ indicator_datetime_init (IndicatorDatetime *self) self->priv->idle_measure = 0; self->priv->max_width = 0; + self->priv->time_format = NULL; + self->priv->sm = NULL; self->priv->menu = NULL; @@ -191,6 +195,12 @@ 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; @@ -199,6 +209,16 @@ 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; } @@ -206,6 +226,10 @@ 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); + IndicatorDatetime * self = INDICATOR_DATETIME(object); + + g_value_set_string(value, self->priv->time_format); return; } -- cgit v1.2.3 From 5c0172d8d390f7f5ff1d8475ef7aea40106f58ea Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 12 Jul 2010 20:42:55 -0500 Subject: Moving the default format into a define and using our new variable. --- src/indicator-datetime.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 847cb8e..854bf4d 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -83,6 +83,8 @@ enum { #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)) @@ -131,7 +133,7 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass) 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.", - "%l:%M %p", + DEFAULT_TIME_FORMAT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); return; @@ -148,7 +150,7 @@ indicator_datetime_init (IndicatorDatetime *self) self->priv->idle_measure = 0; self->priv->max_width = 0; - self->priv->time_format = NULL; + self->priv->time_format = g_strdup(DEFAULT_TIME_FORMAT); self->priv->sm = NULL; self->priv->menu = NULL; @@ -276,7 +278,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); -- cgit v1.2.3 From a994c55bc39f419ce752d02a60bc01d5659aad62 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 12 Jul 2010 20:56:23 -0500 Subject: Going into the gsettings world. --- src/indicator-datetime.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 854bf4d..4779313 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -27,6 +27,7 @@ with this program. If not, see . #include #include #include +#include /* Indicator Stuff */ #include @@ -70,6 +71,8 @@ struct _IndicatorDatetimePrivate { IndicatorServiceManager * sm; DbusmenuGtkMenu * menu; + + GSettings * settings; }; /* Enum for the properties so that they can be quickly @@ -81,6 +84,7 @@ enum { #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" @@ -155,6 +159,17 @@ indicator_datetime_init (IndicatorDatetime *self) 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; @@ -190,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; } -- cgit v1.2.3