aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-06-19 01:26:32 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-06-19 01:26:32 -0500
commit22fb11bd6b8b4dca696e16baf6619c50399abd14 (patch)
tree920a3774fead37f771edaa162d45545e1524a966
parent3bd2f55923c0555b2f5438b2169ea0030aca2fe1 (diff)
downloadayatana-indicator-datetime-22fb11bd6b8b4dca696e16baf6619c50399abd14.tar.gz
ayatana-indicator-datetime-22fb11bd6b8b4dca696e16baf6619c50399abd14.tar.bz2
ayatana-indicator-datetime-22fb11bd6b8b4dca696e16baf6619c50399abd14.zip
in the gnome control center datetime panel, use g_bus_watch_name() to see if com.canonical.indicator.datetime is available.
-rw-r--r--src/datetime-prefs.c55
-rw-r--r--src/dbus-shared.h22
-rw-r--r--src/service.c4
3 files changed, 33 insertions, 48 deletions
diff --git a/src/datetime-prefs.c b/src/datetime-prefs.c
index d7f0def..ef0a553 100644
--- a/src/datetime-prefs.c
+++ b/src/datetime-prefs.c
@@ -58,6 +58,7 @@ struct _IndicatorDatetimePanel
struct _IndicatorDatetimePanelPrivate
{
+ guint name_watch_id;
GtkBuilder * builder;
GDBusProxy * proxy;
GtkWidget * auto_radio;
@@ -286,33 +287,30 @@ proxy_ready (GObject *object, GAsyncResult *res, IndicatorDatetimePanel * self)
}
}
+#define WIG(name) GTK_WIDGET (gtk_builder_get_object(self->priv->builder, name))
+
static void
-service_name_owner_changed (GDBusProxy * proxy, GParamSpec *pspec, gpointer user_data)
+set_show_clock_check_sensitive (IndicatorDatetimePanel * self,
+ gboolean sensitive)
{
- 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);
+ gtk_widget_set_sensitive (WIG("showClockCheck"), sensitive);
}
static void
-service_proxy_ready (GObject *object, GAsyncResult *res, gpointer user_data)
+on_bus_name_appeared (GDBusConnection * connection G_GNUC_UNUSED,
+ const char * name G_GNUC_UNUSED,
+ const char * name_owner,
+ gpointer self)
{
- GError * error = NULL;
-
- GDBusProxy * 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;
- }
+ set_show_clock_check_sensitive (self, name_owner && *name_owner);
+}
- /* 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 void
+on_bus_name_vanished (GDBusConnection * connection G_GNUC_UNUSED,
+ const char * name G_GNUC_UNUSED,
+ gpointer self)
+{
+ set_show_clock_check_sensitive (self, FALSE);
}
static gboolean
@@ -656,7 +654,6 @@ indicator_datetime_panel_init (IndicatorDatetimePanel * self)
GSettings * conf = g_settings_new (SETTINGS_INTERFACE);
-#define WIG(name) GTK_WIDGET (gtk_builder_get_object (self->priv->builder, name))
/* Add policykit button */
GtkWidget * polkit_button = gtk_lock_button_new (NULL);
@@ -745,10 +742,13 @@ indicator_datetime_panel_init (IndicatorDatetimePanel * self)
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,
- SERVICE_NAME, SERVICE_OBJ, SERVICE_IFACE,
- NULL, (GAsyncReadyCallback)service_proxy_ready,
- WIG ("showClockCheck"));
+ self->priv->name_watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
+ BUS_NAME,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ on_bus_name_appeared,
+ on_bus_name_vanished,
+ self,
+ NULL);
#undef WIG
@@ -772,6 +772,11 @@ indicator_datetime_panel_dispose (GObject * object)
priv->loc_dlg = NULL;
}
+ if (priv->name_watch_id != 0) {
+ g_bus_unwatch_name (priv->name_watch_id);
+ priv->name_watch_id = 0;
+ }
+
if (priv->save_time_id) {
g_source_remove (priv->save_time_id);
priv->save_time_id = 0;
diff --git a/src/dbus-shared.h b/src/dbus-shared.h
index 9e3a781..24319e3 100644
--- a/src/dbus-shared.h
+++ b/src/dbus-shared.h
@@ -19,24 +19,6 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define BUS_NAME "com.canonical.indicator.datetime"
+#define BUS_PATH "/com/canonical/indicator/datetime"
-#define SERVICE_NAME "com.canonical.indicator.datetime"
-#define SERVICE_IFACE "com.canonical.indicator.datetime.service"
-#define SERVICE_OBJ "/com/canonical/indicator/datetime/service"
-#define SERVICE_VERSION 1
-
-#define MENU_OBJ "/com/canonical/indicator/datetime/menu"
-
-#define DBUSMENU_CALENDAR_MENUITEM_TYPE "x-canonical-calendar-item"
-
-#define CALENDAR_MENUITEM_PROP_MARKS "calendar-marks"
-
-#define APPOINTMENT_MENUITEM_TYPE "appointment-item"
-#define APPOINTMENT_MENUITEM_PROP_LABEL "appointment-label"
-#define APPOINTMENT_MENUITEM_PROP_ICON "appointment-icon"
-#define APPOINTMENT_MENUITEM_PROP_RIGHT "appointment-time"
-
-#define TIMEZONE_MENUITEM_TYPE "timezone-item"
-#define TIMEZONE_MENUITEM_PROP_ZONE "timezone-zone"
-#define TIMEZONE_MENUITEM_PROP_NAME "timezone-name"
-#define TIMEZONE_MENUITEM_PROP_RADIO "timezone-radio"
diff --git a/src/service.c b/src/service.c
index e6a1209..5c8f966 100644
--- a/src/service.c
+++ b/src/service.c
@@ -25,6 +25,7 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
+#include "dbus-shared.h"
#include "planner-eds.h"
#include "timezone-file.h"
#include "timezone-geoclue.h"
@@ -32,9 +33,6 @@
#include "settings-shared.h"
#include "utils.h"
-#define BUS_NAME "com.canonical.indicator.datetime"
-#define BUS_PATH "/com/canonical/indicator/datetime"
-
#define SKEW_CHECK_INTERVAL_SEC 10
#define SKEW_DIFF_THRESHOLD_USEC ((SKEW_CHECK_INTERVAL_SEC+5) * G_USEC_PER_SEC)