aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-06-14 19:51:03 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-06-14 19:51:03 -0500
commit537a40e055d701e5d735f1bf47a4875e3461df02 (patch)
tree792eea66e752e207ac3a53e1369b1e6872421214 /src
parent50a6e9172ff4588d25b3fc44003c9542dd3703a1 (diff)
downloadayatana-indicator-session-537a40e055d701e5d735f1bf47a4875e3461df02.tar.gz
ayatana-indicator-session-537a40e055d701e5d735f1bf47a4875e3461df02.tar.bz2
ayatana-indicator-session-537a40e055d701e5d735f1bf47a4875e3461df02.zip
a step in merging the two menus: initial merge of the two menus
Diffstat (limited to 'src')
-rw-r--r--src/dbus-shared-names.h8
-rw-r--r--src/device-menu-mgr.c39
-rw-r--r--src/device-menu-mgr.h8
-rw-r--r--src/session-service.c16
-rw-r--r--src/user-menu-mgr.c32
-rw-r--r--src/user-menu-mgr.h7
6 files changed, 50 insertions, 60 deletions
diff --git a/src/dbus-shared-names.h b/src/dbus-shared-names.h
index 5f35903..876735a 100644
--- a/src/dbus-shared-names.h
+++ b/src/dbus-shared-names.h
@@ -38,10 +38,10 @@ typedef enum {
REAL
}TransactionType;
-#define INDICATOR_USERS_DBUS_NAME INDICATOR_SESSION_DBUS_NAME
-#define INDICATOR_USERS_DBUS_OBJECT "/com/canonical/indicator/users/menu"
-#define INDICATOR_USERS_SERVICE_DBUS_OBJECT "/org/gnome/DisplayManager/UserManager"
-#define INDICATOR_USERS_SERVICE_DBUS_INTERFACE "org.gnome.DisplayManager.UserManager"
+//#define INDICATOR_USERS_DBUS_NAME INDICATOR_SESSION_DBUS_NAME
+//#define INDICATOR_USERS_DBUS_OBJECT "/com/canonical/indicator/users/menu"
+//#define INDICATOR_USERS_SERVICE_DBUS_OBJECT "/org/gnome/DisplayManager/UserManager"
+//#define INDICATOR_USERS_SERVICE_DBUS_INTERFACE "org.gnome.DisplayManager.UserManager"
#define INDICATOR_SESSION_DBUS_NAME "com.canonical.indicator.session"
#define INDICATOR_SESSION_DBUS_OBJECT "/com/canonical/indicator/session/menu"
diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c
index 23a8dc0..ccf4107 100644
--- a/src/device-menu-mgr.c
+++ b/src/device-menu-mgr.c
@@ -40,7 +40,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
struct _DeviceMenuMgr
{
GObject parent_instance;
- DbusmenuMenuitem* root_item;
+ DbusmenuMenuitem * parent_mi;
SessionDbus* session_dbus_interface;
GSettings *lockdown_settings;
@@ -68,8 +68,6 @@ G_DEFINE_TYPE (DeviceMenuMgr, device_menu_mgr, G_TYPE_OBJECT);
static void
device_menu_mgr_init (DeviceMenuMgr *self)
{
- self->root_item = dbusmenu_menuitem_new ();
-
self->can_hibernate = TRUE;
self->can_suspend = TRUE;
self->allow_hibernate = TRUE;
@@ -328,14 +326,16 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode)
name = _("About This Computer");
mi = dbusmenu_menuitem_new ();
dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, name);
- dbusmenu_menuitem_child_append (self->root_item, mi);
+ dbusmenu_menuitem_child_append (self->parent_mi, mi);
+g_message ("appending About This Computer to %p", self->parent_mi);
+
g_signal_connect_swapped (mi, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK(spawn_command_line_async), "gnome-control-center info");
name = _("Ubuntu Help");
mi = dbusmenu_menuitem_new ();
dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, name);
- dbusmenu_menuitem_child_append (self->root_item, mi);
+ dbusmenu_menuitem_child_append (self->parent_mi, mi);
g_signal_connect_swapped (mi, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK(spawn_command_line_async), "yelp");
@@ -343,12 +343,12 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode)
{
mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
- dbusmenu_menuitem_child_append (self->root_item, mi);
+ dbusmenu_menuitem_child_append (self->parent_mi, mi);
name = _("System Settings…");
mi = dbusmenu_menuitem_new ();
dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, name);
- dbusmenu_menuitem_child_append (self->root_item, mi);
+ dbusmenu_menuitem_child_append (self->parent_mi, mi);
g_signal_connect_swapped (mi, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK(spawn_command_line_async), "gnome-control-center");
}
@@ -366,7 +366,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode)
self->lock_mi = mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, name);
update_screensaver_shortcut (mi, self->keybinding_settings);
- dbusmenu_menuitem_child_append (self->root_item, mi);
+ dbusmenu_menuitem_child_append (self->parent_mi, mi);
g_signal_connect (G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK(lock_screen), NULL);
}
@@ -377,7 +377,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode)
mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
- dbusmenu_menuitem_child_append (self->root_item, mi);
+ dbusmenu_menuitem_child_append (self->parent_mi, mi);
if (!greeter_mode)
{
@@ -385,7 +385,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode)
logout_mi = mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, name);
dbusmenu_menuitem_property_set_bool (mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_logout());
- dbusmenu_menuitem_child_append(self->root_item, mi);
+ dbusmenu_menuitem_child_append(self->parent_mi, mi);
g_signal_connect (G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK(show_dialog), "logout");
}
@@ -395,7 +395,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode)
name = _("Suspend");
self->suspend_mi = mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, name);
- dbusmenu_menuitem_child_append (self->root_item, mi);
+ dbusmenu_menuitem_child_append (self->parent_mi, mi);
g_signal_connect (G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK(machine_sleep_from_suspend), self);
}
@@ -405,7 +405,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode)
name = _("Hibernate");
self->hibernate_mi = mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, name);
- dbusmenu_menuitem_child_append(self->root_item, mi);
+ dbusmenu_menuitem_child_append(self->parent_mi, mi);
g_signal_connect (G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK(machine_sleep_from_hibernate), self);
}
@@ -413,14 +413,14 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode)
name = _("Restart");
mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, name);
- dbusmenu_menuitem_child_append (self->root_item, mi);
+ dbusmenu_menuitem_child_append (self->parent_mi, mi);
/* FIXME: not implemented */
name = supress_confirmations() ? _("Shut Down") : _("Shut Down\342\200\246");
shutdown_mi = mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, name);
dbusmenu_menuitem_property_set_bool (mi, DBUSMENU_MENUITEM_PROP_VISIBLE, show_shutdown());
- dbusmenu_menuitem_child_append (self->root_item, mi);
+ dbusmenu_menuitem_child_append (self->parent_mi, mi);
g_signal_connect (G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
#ifdef HAVE_GTKLOGOUTHELPER
G_CALLBACK(show_dialog), "shutdown");
@@ -446,18 +446,15 @@ device_menu_mgr_rebuild_items (DeviceMenuMgr* self)
self->can_suspend && self->allow_suspend);
}
-DbusmenuMenuitem*
-device_mgr_get_root_item (DeviceMenuMgr* self)
-{
- return self->root_item;
-}
-
/*
* Clean Entry Point
*/
-DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode)
+DeviceMenuMgr* device_menu_mgr_new (DbusmenuMenuitem * parent_mi,
+ SessionDbus * session_dbus,
+ gboolean greeter_mode)
{
DeviceMenuMgr* device_mgr = g_object_new (DEVICE_TYPE_MENU_MGR, NULL);
+ device_mgr->parent_mi = parent_mi;
device_mgr->session_dbus_interface = session_dbus;
device_menu_mgr_build_static_items (device_mgr, greeter_mode);
return device_mgr;
diff --git a/src/device-menu-mgr.h b/src/device-menu-mgr.h
index d3c3a5a..af84614 100644
--- a/src/device-menu-mgr.h
+++ b/src/device-menu-mgr.h
@@ -39,14 +39,14 @@ typedef struct _DeviceMenuMgr DeviceMenuMgr;
struct _DeviceMenuMgrClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
};
GType device_menu_mgr_get_type (void) G_GNUC_CONST;
-DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode);
-
-DbusmenuMenuitem* device_mgr_get_root_item (DeviceMenuMgr* self);
+DeviceMenuMgr* device_menu_mgr_new (DbusmenuMenuitem * parent_mi,
+ SessionDbus * session_dbus,
+ gboolean greeter_mode);
G_END_DECLS
diff --git a/src/session-service.c b/src/session-service.c
index 508887f..ece3a1d 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -98,17 +98,11 @@ main (int argc, char ** argv)
greeter_mode = get_greeter_mode();
- // Devices
- DeviceMenuMgr* device_mgr = device_menu_mgr_new (session_dbus, greeter_mode);
- DbusmenuServer * server = dbusmenu_server_new(INDICATOR_SESSION_DBUS_OBJECT);
- dbusmenu_server_set_root(server, device_mgr_get_root_item (device_mgr));
-
- if (!greeter_mode) {
- // Users
- UserMenuMgr* user_mgr = user_menu_mgr_new (session_dbus, greeter_mode);
- DbusmenuServer* users_server = dbusmenu_server_new (INDICATOR_USERS_DBUS_OBJECT);
- dbusmenu_server_set_root (users_server, user_mgr_get_root_item (user_mgr));
- }
+ DbusmenuMenuitem * root_item = dbusmenu_menuitem_new ();
+ device_menu_mgr_new (root_item, session_dbus, greeter_mode);
+ user_menu_mgr_new (root_item, session_dbus, greeter_mode);
+ DbusmenuServer* server = dbusmenu_server_new (INDICATOR_SESSION_DBUS_OBJECT);
+ dbusmenu_server_set_root (server, root_item);
mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(mainloop);
diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c
index 37aca14..cde3899 100644
--- a/src/user-menu-mgr.c
+++ b/src/user-menu-mgr.c
@@ -34,7 +34,7 @@ struct _UserMenuMgr
{
GObject parent_instance;
UsersServiceDbus* users_dbus_interface;
- DbusmenuMenuitem* root_item;
+ DbusmenuMenuitem* parent_mi;
DbusmenuMenuitem * guest_mi;
SessionDbus* session_dbus_interface;
GSettings * lockdown_settings;
@@ -82,7 +82,6 @@ user_menu_mgr_init (UserMenuMgr *self)
{
self->lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA);
self->users_dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL);
- self->root_item = dbusmenu_menuitem_new ();
g_signal_connect (self->users_dbus_interface, "user-list-changed",
G_CALLBACK (on_user_list_changed), self);
g_signal_connect (self->users_dbus_interface, "user-logged-in-changed",
@@ -274,16 +273,18 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self)
{
GList *u;
gboolean can_activate;
- GList *children;
/* Check to see which menu items we're allowed to have */
can_activate = users_service_dbus_can_activate_session (self->users_dbus_interface) &&
!g_settings_get_boolean (self->lockdown_settings, LOCKDOWN_KEY_USER);
/* Remove the old menu items if that makes sense */
- children = dbusmenu_menuitem_take_children (self->root_item);
+#warning FIXME
+#if 0
+ GList * children = dbusmenu_menuitem_take_children (self->root_item);
g_list_foreach (children, (GFunc)g_object_unref, NULL);
g_list_free (children);
+#endif
/* Set to NULL in case we don't end up building one */
self->guest_mi = NULL;
@@ -306,7 +307,8 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self)
dbusmenu_menuitem_property_set (switch_menuitem,
USER_ITEM_PROP_NAME,
_("Switch User Account…"));
- dbusmenu_menuitem_child_append (self->root_item, switch_menuitem);
+ dbusmenu_menuitem_child_append (self->parent_mi, switch_menuitem);
+g_message ("appending Switch button to %p", self->parent_mi);
g_signal_connect (G_OBJECT (switch_menuitem),
DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK (activate_new_session),
@@ -322,7 +324,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self)
USER_ITEM_PROP_NAME,
_("Guest Session"));
on_guest_logged_in_changed (self->users_dbus_interface, self);
- dbusmenu_menuitem_child_append (self->root_item, self->guest_mi);
+ dbusmenu_menuitem_child_append (self->parent_mi, self->guest_mi);
g_signal_connect (G_OBJECT (self->guest_mi),
DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK (activate_guest_session),
@@ -342,7 +344,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self)
AccountsUser * user = u->data;
DbusmenuMenuitem * mi = create_user_menuitem (self, user);
- dbusmenu_menuitem_child_append (self->root_item, mi);
+ dbusmenu_menuitem_child_append (self->parent_mi, mi);
const char * const user_name = accounts_user_get_user_name (user);
if (!g_strcmp0 (user_name, g_get_user_name()))
@@ -360,7 +362,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self)
dbusmenu_menuitem_property_set (separator1,
DBUSMENU_MENUITEM_PROP_TYPE,
DBUSMENU_CLIENT_TYPES_SEPARATOR);
- dbusmenu_menuitem_child_append (self->root_item, separator1);
+ dbusmenu_menuitem_child_append (self->parent_mi, separator1);
DbusmenuMenuitem * user_accounts_item = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set (user_accounts_item,
@@ -375,7 +377,7 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self)
G_CALLBACK (activate_user_accounts),
NULL);
- dbusmenu_menuitem_child_append (self->root_item, user_accounts_item);
+ dbusmenu_menuitem_child_append (self->parent_mi, user_accounts_item);
}
@@ -456,11 +458,6 @@ on_user_list_changed (UsersServiceDbus * service G_GNUC_UNUSED,
user_menu_mgr_rebuild_items (user_mgr);
}
-DbusmenuMenuitem*
-user_mgr_get_root_item (UserMenuMgr* self)
-{
- return self->root_item;
-}
/* Checks to see if we should show the guest session item.
System users shouldn't have guest account shown.
@@ -486,13 +483,14 @@ activate_guest_session (DbusmenuMenuitem * mi, guint timestamp, gpointer user_da
/*
* Clean Entry Point
*/
-UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_mode)
+UserMenuMgr* user_menu_mgr_new (DbusmenuMenuitem * parent_mi,
+ SessionDbus * session_dbus,
+ gboolean greeter_mode)
{
UserMenuMgr* user_mgr = g_object_new (USER_TYPE_MENU_MGR, NULL);
+ user_mgr->parent_mi = parent_mi;
user_mgr->greeter_mode = greeter_mode;
user_mgr->session_dbus_interface = session_dbus;
user_menu_mgr_rebuild_items (user_mgr);
return user_mgr;
}
-
-
diff --git a/src/user-menu-mgr.h b/src/user-menu-mgr.h
index 40f7b18..4b0fd3f 100644
--- a/src/user-menu-mgr.h
+++ b/src/user-menu-mgr.h
@@ -45,10 +45,11 @@ struct _UserMenuMgrClass
};
GType user_menu_mgr_get_type (void) G_GNUC_CONST;
-UserMenuMgr* user_menu_mgr_new (SessionDbus* session_dbus,
- gboolean greeter_mode);
-DbusmenuMenuitem* user_mgr_get_root_item (UserMenuMgr* self);
+UserMenuMgr* user_menu_mgr_new (DbusmenuMenuitem * parent,
+ SessionDbus * session_dbus,
+ gboolean greeter_mode);
+
G_END_DECLS
#endif /* _USER_MENU_MGR_H_ */