← Back to team overview

ayatana-commits team mailing list archive

lp:~mterry/indicator-datetime/disable-clock-prefs-if-no-indicator into lp:indicator-datetime

 

Michael Terry has proposed merging lp:~mterry/indicator-datetime/disable-clock-prefs-if-no-indicator into lp:indicator-datetime.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)

For more details, see:
https://code.launchpad.net/~mterry/indicator-datetime/disable-clock-prefs-if-no-indicator/+merge/52912

As per spec, don't enable clock prefs if no clock
-- 
https://code.launchpad.net/~mterry/indicator-datetime/disable-clock-prefs-if-no-indicator/+merge/52912
Your team ayatana-commits is subscribed to branch lp:indicator-datetime.
=== modified file 'src/datetime-prefs.c'
--- src/datetime-prefs.c	2011-03-03 18:14:14 +0000
+++ src/datetime-prefs.c	2011-03-10 19:51:58 +0000
@@ -225,7 +225,8 @@
   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 @@
                      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 @@
                             "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 @@
     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 ();
   }


Follow ups