From ab979ed1516e087eda9e108d4147c3c395f0ca28 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Thu, 10 Mar 2011 10:05:51 -0500 Subject: make 'show monthly calendar' checkbox work --- src/datetime-service.c | 2 -- src/indicator-datetime.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/datetime-service.c b/src/datetime-service.c index 6f38004..3a0a3f0 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -336,8 +336,6 @@ static gboolean check_for_calendar (gpointer user_data) { g_return_val_if_fail (calendar != NULL, FALSE); - - if (!g_settings_get_boolean(conf, SETTINGS_SHOW_CALENDAR_S)) return FALSE; gchar *evo = g_find_program_in_path("evolution"); if (evo != NULL) { diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 7953883..0bbc56d 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -84,6 +84,7 @@ struct _IndicatorDatetimePrivate { gboolean custom_show_seconds; gboolean show_week_numbers; + gboolean show_calendar; gint week_start; guint idle_measure; @@ -110,7 +111,8 @@ enum { PROP_SHOW_DAY, PROP_SHOW_DATE, PROP_CUSTOM_TIME_FORMAT, - PROP_SHOW_WEEK_NUMBERS + PROP_SHOW_WEEK_NUMBERS, + PROP_SHOW_CALENDAR }; typedef struct _indicator_item_t indicator_item_t; @@ -129,6 +131,7 @@ struct _indicator_item_t { #define PROP_SHOW_DATE_S "show-date" #define PROP_CUSTOM_TIME_FORMAT_S "custom-time-format" #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)) @@ -240,6 +243,13 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass) "Shows the week numbers in the monthly calendar in indicator-datetime's menu.", FALSE, /* default */ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, + PROP_SHOW_CALENDAR, + g_param_spec_boolean(PROP_SHOW_CALENDAR_S, + "Whether to show the calendar.", + "Shows the monthly calendar in indicator-datetime's menu.", + TRUE, /* default */ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); return; } @@ -303,6 +313,11 @@ indicator_datetime_init (IndicatorDatetime *self) self, PROP_SHOW_WEEK_NUMBERS_S, G_SETTINGS_BIND_DEFAULT); + g_settings_bind(self->priv->settings, + SETTINGS_SHOW_CALENDAR_S, + self, + PROP_SHOW_CALENDAR_S, + G_SETTINGS_BIND_DEFAULT); } else { g_warning("Unable to get settings for '" SETTINGS_INTERFACE "'"); } @@ -541,6 +556,13 @@ set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec } break; } + case PROP_SHOW_CALENDAR: { + if (g_value_get_boolean(value) != self->priv->show_calendar) { + self->priv->show_calendar = g_value_get_boolean(value); + gtk_widget_set_visible (GTK_WIDGET (self->priv->ido_calendar), self->priv->show_calendar); + } + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); return; @@ -599,6 +621,9 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe case PROP_SHOW_WEEK_NUMBERS: g_value_set_boolean(value, self->priv->show_week_numbers); break; + case PROP_SHOW_CALENDAR: + g_value_set_boolean(value, self->priv->show_calendar); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); return; @@ -1228,7 +1253,9 @@ new_calendar_item (DbusmenuMenuitem * newitem, else flags &= ~GTK_CALENDAR_SHOW_WEEK_NUMBERS; ido_calendar_menu_item_set_display_options (self->priv->ido_calendar, flags); - + + gtk_widget_set_visible (GTK_WIDGET (self->priv->ido_calendar), self->priv->show_calendar); + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent); g_signal_connect_after(ido, "month-changed", G_CALLBACK(month_changed_cb), (gpointer)newitem); return TRUE; -- cgit v1.2.3 From 721aa2d317bf0fa15579e1775812e02dcf7043fb Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Thu, 10 Mar 2011 12:25:19 -0500 Subject: make show-clock work --- src/indicator-datetime.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 7953883..618d00d 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -76,6 +76,7 @@ struct _IndicatorDatetimePrivate { gchar * time_string; + gboolean show_clock; gint time_mode; gboolean show_seconds; gboolean show_date; @@ -105,6 +106,7 @@ struct _IndicatorDatetimePrivate { found and looked up. */ enum { PROP_0, + PROP_SHOW_CLOCK, PROP_TIME_FORMAT, PROP_SHOW_SECONDS, PROP_SHOW_DAY, @@ -123,6 +125,7 @@ struct _indicator_item_t { GtkWidget * right; }; +#define PROP_SHOW_CLOCK_S "show-clock" #define PROP_TIME_FORMAT_S "time-format" #define PROP_SHOW_SECONDS_S "show-seconds" #define PROP_SHOW_DAY_S "show-day" @@ -195,6 +198,13 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass) io_class->get_menu = get_menu; io_class->get_accessible_desc = get_accessible_desc; + g_object_class_install_property (object_class, + PROP_SHOW_CLOCK, + g_param_spec_boolean(PROP_SHOW_CLOCK_S, + "Whether to show the clock in the menu bar.", + "Shows indicator-datetime in the shell's menu bar.", + TRUE, /* default */ + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, PROP_TIME_FORMAT, g_param_spec_int(PROP_TIME_FORMAT_S, @@ -254,6 +264,7 @@ indicator_datetime_init (IndicatorDatetime *self) self->priv->idle_measure = 0; self->priv->max_width = 0; + self->priv->show_clock = TRUE; self->priv->time_mode = SETTINGS_TIME_LOCALE; self->priv->show_seconds = FALSE; self->priv->show_date = FALSE; @@ -270,6 +281,11 @@ 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_SHOW_CLOCK_S, + self, + PROP_SHOW_CLOCK_S, + G_SETTINGS_BIND_DEFAULT); g_settings_bind_with_mapping(self->priv->settings, SETTINGS_TIME_FORMAT_S, self, @@ -478,6 +494,13 @@ set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec gboolean update = FALSE; switch(prop_id) { + case PROP_SHOW_CLOCK: { + if (g_value_get_boolean(value) != self->priv->show_clock) { + self->priv->show_clock = g_value_get_boolean(value); + gtk_widget_set_visible (GTK_WIDGET (self->priv->label), self->priv->show_clock); + } + break; + } case PROP_TIME_FORMAT: { gint newval = g_value_get_int(value); if (newval != self->priv->time_mode) { @@ -581,6 +604,9 @@ get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspe IndicatorDatetime * self = INDICATOR_DATETIME(object); switch(prop_id) { + case PROP_SHOW_CLOCK: + g_value_set_boolean(value, self->priv->show_clock); + break; case PROP_TIME_FORMAT: g_value_set_int(value, self->priv->time_mode); break; @@ -1330,7 +1356,7 @@ get_label (IndicatorObject * io) g_signal_connect(G_OBJECT(self->priv->label), "screen-changed", G_CALLBACK(update_text_gravity), self); guess_label_size(self); update_label(self, NULL); - gtk_widget_show(GTK_WIDGET(self->priv->label)); + gtk_widget_set_visible(GTK_WIDGET (self->priv->label), self->priv->show_clock); } if (self->priv->timer == 0) { -- cgit v1.2.3 From 6b45333cec98af6d488fff6e7fccd42673a42a85 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Thu, 10 Mar 2011 14:49:11 -0500 Subject: prefs: only let user change clock prefs if the clock is running; don't connect to response signal, it's no longer a dialog --- src/datetime-prefs.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/datetime-prefs.c b/src/datetime-prefs.c index 5248911..f38a863 100644 --- a/src/datetime-prefs.c +++ b/src/datetime-prefs.c @@ -225,7 +225,8 @@ tz_query_answered (GObject *object, GAsyncResult *res, gpointer user_data) g_variant_unref (answers); } -void proxy_ready (GObject *object, GAsyncResult *res, gpointer user_data) +static void +proxy_ready (GObject *object, GAsyncResult *res, gpointer user_data) { GError * error = NULL; @@ -244,6 +245,35 @@ void proxy_ready (GObject *object, GAsyncResult *res, gpointer user_data) NULL, tz_query_answered, NULL); } +static void +service_name_owner_changed (GDBusProxy * proxy, GParamSpec *pspec, gpointer user_data) +{ + GtkWidget * widget = GTK_WIDGET (user_data); + gchar * owner = g_dbus_proxy_get_name_owner (proxy); + + gtk_widget_set_sensitive (widget, (owner != NULL)); + + g_free (owner); +} + +static void +service_proxy_ready (GObject *object, GAsyncResult *res, gpointer user_data) +{ + GError * error = NULL; + + proxy = g_dbus_proxy_new_for_bus_finish (res, &error); + + if (error != NULL) { + g_critical("Could not grab DBus proxy for indicator-datetime-service: %s", error->message); + g_error_free(error); + return; + } + + /* And now, do initial proxy configuration */ + g_signal_connect (proxy, "notify::g-name-owner", G_CALLBACK (service_name_owner_changed), user_data); + service_name_owner_changed (proxy, NULL, user_data); +} + static gboolean are_spinners_focused (void) { @@ -634,6 +664,17 @@ create_dialog (void) "org.gnome.SettingsDaemon.DateTimeMechanism", NULL, proxy_ready, NULL); + /* Grab proxy for datetime service, to see if it's running. It would + actually be more ideal to see if the indicator module itself is running, + but that doesn't yet claim a name on the bus. Presumably the service + would have been started by any such indicator, so this will at least tell + us if there *was* a datetime module run this session. */ + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL, + "com.canonical.indicator.datetime", + "/com/canonical/indicator/datetime/service", + "com.canonical.indicator.datetime.service", + NULL, service_proxy_ready, WIG ("showClockCheck")); + #undef WIG g_object_unref (conf); @@ -678,7 +719,6 @@ main (int argc, char ** argv) unique_app_watch_window (app, GTK_WINDOW (dlg)); gtk_widget_show_all (dlg); - g_signal_connect (dlg, "response", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect (dlg, "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_main (); } -- cgit v1.2.3 From 1fe486f1ef23907938172a25e95fc377d9783d50 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Mar 2011 22:02:32 -0600 Subject: Use the shared header file for the service and interface names. --- src/datetime-prefs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/datetime-prefs.c b/src/datetime-prefs.c index f38a863..fbc88f2 100644 --- a/src/datetime-prefs.c +++ b/src/datetime-prefs.c @@ -35,6 +35,7 @@ with this program. If not, see . #include #include +#include "dbus-shared.h" #include "settings-shared.h" #include "utils.h" #include "datetime-prefs-locations.h" @@ -670,9 +671,7 @@ create_dialog (void) would have been started by any such indicator, so this will at least tell us if there *was* a datetime module run this session. */ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL, - "com.canonical.indicator.datetime", - "/com/canonical/indicator/datetime/service", - "com.canonical.indicator.datetime.service", + SERVICE_NAME, SERVICE_OBJ, SERVICE_IFACE, NULL, service_proxy_ready, WIG ("showClockCheck")); #undef WIG -- cgit v1.2.3 From 139938582ae1356e2b884d8904da33697bd2bcff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Mar 2011 21:40:24 -0500 Subject: Commenting out value as we're not using it yet. --- src/indicator-datetime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index d48cb55..83ae161 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -1154,9 +1154,9 @@ indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant *value, } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_CLEAR_MARKS)) { ido_calendar_menu_item_clear_marks (IDO_CALENDAR_MENU_ITEM (mi_data)); } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_SET_DATE)) { - gint *array = g_variant_get_fixed_array(value, 3, sizeof(gint)); + // const gint * array = g_variant_get_fixed_array(value, NULL, sizeof(gint)); // TODO: Needs ido branch merged - lp:~karl-qdh/ido/select-activate-set-date - //ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), array[0], array[1], array[2]); + // ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), array[0], array[1], array[2]); } else { g_warning("Indicator Item property '%s' unknown", prop); } -- cgit v1.2.3