diff options
author | Michael Terry <michael.terry@canonical.com> | 2011-08-03 13:05:34 -0400 |
---|---|---|
committer | Michael Terry <michael.terry@canonical.com> | 2011-08-03 13:05:34 -0400 |
commit | a71045671c8681c900847af89afdf0f8b17c7189 (patch) | |
tree | 756a5df404771cbc0dbae3eca8ae7a18a0c7b7d0 | |
parent | c60b7f972eb8faa1b06366dfebdb4a220d565f1e (diff) | |
download | ayatana-indicator-sound-a71045671c8681c900847af89afdf0f8b17c7189.tar.gz ayatana-indicator-sound-a71045671c8681c900847af89afdf0f8b17c7189.tar.bz2 ayatana-indicator-sound-a71045671c8681c900847af89afdf0f8b17c7189.zip |
don't show player bridge and settings links when used in a greeter
-rw-r--r-- | src/sound-service-dbus.c | 44 | ||||
-rw-r--r-- | src/sound-service-dbus.h | 2 | ||||
-rw-r--r-- | src/sound-service.c | 19 |
3 files changed, 41 insertions, 24 deletions
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index 6fb0a64..0db03d4 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -56,6 +56,7 @@ struct _SoundServiceDbusPrivate { GDBusConnection* connection; DbusmenuMenuitem* root_menuitem; Device* device; + gboolean greeter_mode; }; static GDBusNodeInfo * node_info = NULL; @@ -144,9 +145,10 @@ sound_service_dbus_init (SoundServiceDbus *self) } DbusmenuMenuitem* -sound_service_dbus_create_root_item (SoundServiceDbus* self) +sound_service_dbus_create_root_item (SoundServiceDbus* self, gboolean greeter_mode) { SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self); + priv->greeter_mode = greeter_mode; priv->root_menuitem = dbusmenu_menuitem_new(); //g_debug("Root ID: %d", dbusmenu_menuitem_get_id(priv->root_menuitem)); DbusmenuServer *server = dbusmenu_server_new (INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH); @@ -169,25 +171,27 @@ sound_service_dbus_build_sound_menu ( SoundServiceDbus* self, dbusmenu_menuitem_child_add_position (priv->root_menuitem, slider_item, 1); dbusmenu_menuitem_child_add_position (priv->root_menuitem, voip_input_menu_item, 2); - // Separator - DbusmenuMenuitem* separator = dbusmenu_menuitem_new(); - - dbusmenu_menuitem_property_set (separator, - DBUSMENU_MENUITEM_PROP_TYPE, - DBUSMENU_CLIENT_TYPES_SEPARATOR); - dbusmenu_menuitem_child_add_position (priv->root_menuitem, separator, 3); - g_object_unref (separator); - - // Sound preferences dialog - DbusmenuMenuitem* settings_mi = dbusmenu_menuitem_new(); - - dbusmenu_menuitem_property_set( settings_mi, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Sound Settings...")); - dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi); - g_object_unref (settings_mi); - g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK(show_sound_settings_dialog), NULL); + if (!priv->greeter_mode) { + // Separator + DbusmenuMenuitem* separator = dbusmenu_menuitem_new(); + + dbusmenu_menuitem_property_set (separator, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + dbusmenu_menuitem_child_add_position (priv->root_menuitem, separator, 3); + g_object_unref (separator); + + // Sound preferences dialog + DbusmenuMenuitem* settings_mi = dbusmenu_menuitem_new(); + + dbusmenu_menuitem_property_set( settings_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Sound Settings...")); + dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi); + g_object_unref (settings_mi); + g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK(show_sound_settings_dialog), NULL); + } } /** diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h index 9b19a5e..1c15fc7 100644 --- a/src/sound-service-dbus.h +++ b/src/sound-service-dbus.h @@ -53,7 +53,7 @@ struct _SoundServiceDbusClass { GType sound_service_dbus_get_type (void) G_GNUC_CONST; -DbusmenuMenuitem* sound_service_dbus_create_root_item (SoundServiceDbus* self); +DbusmenuMenuitem* sound_service_dbus_create_root_item (SoundServiceDbus* self, gboolean greeter_mode); void sound_service_dbus_update_sound_state (SoundServiceDbus* self, SoundState new_state); void sound_service_dbus_build_sound_menu ( SoundServiceDbus* self, DbusmenuMenuitem* mute_item, diff --git a/src/sound-service.c b/src/sound-service.c index 1324537..a368081 100644 --- a/src/sound-service.c +++ b/src/sound-service.c @@ -47,12 +47,21 @@ service_shutdown (IndicatorService *service, gpointer user_data) return; } +static gboolean +get_greeter_mode (void) +{ + const gchar *var; + var = g_getenv("INDICATOR_GREETER_MODE"); + return (g_strcmp0(var, "1") == 0); +} + /** main: **/ int main (int argc, char ** argv) { + gboolean greeter_mode; g_type_init(); textdomain (GETTEXT_PACKAGE); @@ -67,9 +76,13 @@ main (int argc, char ** argv) SoundServiceDbus* sound_service = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL); - DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service); - MusicPlayerBridge* server = music_player_bridge_new(); - music_player_bridge_set_root_menu_item(server, root_menuitem); + greeter_mode = get_greeter_mode(); + + DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service, greeter_mode); + if (!greeter_mode) { + MusicPlayerBridge* server = music_player_bridge_new(); + music_player_bridge_set_root_menu_item(server, root_menuitem); + } // Run the loop mainloop = g_main_loop_new(NULL, FALSE); |