← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~mterry/indicator-datetime/add-greeter-mode into lp:indicator-datetime

 

Michael Terry has proposed merging lp:~mterry/indicator-datetime/add-greeter-mode into lp:indicator-datetime.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)
Related bugs:
  Bug #811853 in Indicator Date and Time: "Don't allow starting programs via the greeter indicators"
  https://bugs.launchpad.net/indicator-datetime/+bug/811853

For more details, see:
https://code.launchpad.net/~mterry/indicator-datetime/add-greeter-mode/+merge/70342

When in a greeter, use a simpler interface. See bug 811853 for more.
-- 
https://code.launchpad.net/~mterry/indicator-datetime/add-greeter-mode/+merge/70342
Your team ayatana-commits is subscribed to branch lp:indicator-datetime.
=== modified file 'src/datetime-service.c'
--- src/datetime-service.c	2011-07-07 21:17:58 +0000
+++ src/datetime-service.c	2011-08-03 17:58:33 +0000
@@ -60,6 +60,7 @@
 static void setup_timer (void);
 static void geo_client_invalid (GeoclueMasterClient * client, gpointer user_data);
 static void geo_address_change (GeoclueMasterClient * client, gchar * a, gchar * b, gchar * c, gchar * d, gpointer user_data);
+static gboolean get_greeter_mode (void);
 
 static IndicatorService * service = NULL;
 static GMainLoop * mainloop = NULL;
@@ -534,6 +535,10 @@
 update_timezone_menu_items(gpointer user_data) {
 	g_debug("Updating timezone menu items");
 
+	if (locations_separator == NULL || current_location == NULL) {
+		return FALSE;
+	}
+
 	gchar ** locations = g_settings_get_strv(conf, SETTINGS_LOCATIONS_S);
 
 	if (locations == NULL) { 
@@ -1077,45 +1082,47 @@
 
 		g_idle_add(check_for_calendar, NULL);
 	}
-	
-	locations_separator = dbusmenu_menuitem_new();
-	dbusmenu_menuitem_property_set(locations_separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
-	dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
-	dbusmenu_menuitem_child_append(root, locations_separator);
-
-	geo_location = dbusmenu_menuitem_new();
-	dbusmenu_menuitem_property_set      (geo_location, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE);
-	set_current_timezone_label (geo_location, "");
-	dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
-	dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
-	g_signal_connect(G_OBJECT(geo_location), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL);
-	dbusmenu_menuitem_child_append(root, geo_location);
-
-	current_location = dbusmenu_menuitem_new();
-	dbusmenu_menuitem_property_set      (current_location, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE);
-	set_current_timezone_label (current_location, "");
-	dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
-	dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
-	dbusmenu_menuitem_child_append(root, current_location);
-	
-	check_timezone_sync();
-	
-	g_signal_connect (conf, "changed::" SETTINGS_SHOW_LOCATIONS_S, G_CALLBACK (show_locations_changed), NULL);
-	g_signal_connect (conf, "changed::" SETTINGS_LOCATIONS_S, G_CALLBACK (show_locations_changed), NULL);
-	g_signal_connect (conf, "changed::" SETTINGS_SHOW_EVENTS_S, G_CALLBACK (show_events_changed), NULL);
-	g_signal_connect (conf, "changed::" SETTINGS_TIME_FORMAT_S, G_CALLBACK (time_format_changed), NULL);
-
-	DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
-	dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
-	dbusmenu_menuitem_child_append(root, separator);
-
-	settings = dbusmenu_menuitem_new();
-	dbusmenu_menuitem_property_set     (settings, DBUSMENU_MENUITEM_PROP_LABEL, _("Time & Date Settings..."));
-	/* insensitive until we check for available apps */
-	dbusmenu_menuitem_property_set_bool(settings, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
-	g_signal_connect(G_OBJECT(settings), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "gnome-control-center indicator-datetime");
-	dbusmenu_menuitem_child_append(root, settings);
-	g_idle_add(check_for_timeadmin, NULL);
+
+	if (!get_greeter_mode ()) {
+		locations_separator = dbusmenu_menuitem_new();
+		dbusmenu_menuitem_property_set(locations_separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
+		dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+		dbusmenu_menuitem_child_append(root, locations_separator);
+
+		geo_location = dbusmenu_menuitem_new();
+		dbusmenu_menuitem_property_set      (geo_location, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE);
+		set_current_timezone_label (geo_location, "");
+		dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+		dbusmenu_menuitem_property_set_bool (geo_location, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+		g_signal_connect(G_OBJECT(geo_location), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(quick_set_tz), NULL);
+		dbusmenu_menuitem_child_append(root, geo_location);
+
+		current_location = dbusmenu_menuitem_new();
+		dbusmenu_menuitem_property_set      (current_location, DBUSMENU_MENUITEM_PROP_TYPE, TIMEZONE_MENUITEM_TYPE);
+		set_current_timezone_label (current_location, "");
+		dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+		dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
+		dbusmenu_menuitem_child_append(root, current_location);
+	
+		check_timezone_sync();
+	
+		g_signal_connect (conf, "changed::" SETTINGS_SHOW_LOCATIONS_S, G_CALLBACK (show_locations_changed), NULL);
+		g_signal_connect (conf, "changed::" SETTINGS_LOCATIONS_S, G_CALLBACK (show_locations_changed), NULL);
+		g_signal_connect (conf, "changed::" SETTINGS_SHOW_EVENTS_S, G_CALLBACK (show_events_changed), NULL);
+		g_signal_connect (conf, "changed::" SETTINGS_TIME_FORMAT_S, G_CALLBACK (time_format_changed), NULL);
+
+		DbusmenuMenuitem * separator = dbusmenu_menuitem_new();
+		dbusmenu_menuitem_property_set(separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
+		dbusmenu_menuitem_child_append(root, separator);
+
+		settings = dbusmenu_menuitem_new();
+		dbusmenu_menuitem_property_set     (settings, DBUSMENU_MENUITEM_PROP_LABEL, _("Time & Date Settings..."));
+		/* insensitive until we check for available apps */
+		dbusmenu_menuitem_property_set_bool(settings, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
+		g_signal_connect(G_OBJECT(settings), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "gnome-control-center indicator-datetime");
+		dbusmenu_menuitem_child_append(root, settings);
+		g_idle_add(check_for_timeadmin, NULL);
+	}
 
 	return;
 }
@@ -1396,6 +1403,14 @@
 	return;
 }
 
+static gboolean
+get_greeter_mode (void)
+{
+  const gchar *var;
+  var = g_getenv("INDICATOR_GREETER_MODE");
+  return (g_strcmp0(var, "1") == 0);
+}
+
 /* Repsonds to the service object saying it's time to shutdown.
    It stops the mainloop. */
 static void 


Follow ups