/* Log Out */ static void panel_action_logout (GtkWidget *widget) { PanelSessionManager *manager; gboolean prompt = TRUE; if (mate_gsettings_schema_exists (MATE_SESSION_SCHEMA)) { GSettings *msm_settings; msm_settings = g_settings_new (MATE_SESSION_SCHEMA); prompt = g_settings_get_boolean (msm_settings, MATE_SESSION_LOGOUT_PROMPT_KEY); g_object_unref (msm_settings); } manager = panel_session_manager_get (); if (!prompt) panel_session_manager_request_logout (manager, PANEL_SESSION_MANAGER_LOGOUT_MODE_NO_CONFIRMATION); else /* FIXME: we need to use widget to get the screen for the * confirmation dialog, see * http://bugzilla.gnome.org/show_bug.cgi?id=536914 */ panel_session_manager_request_logout (manager, PANEL_SESSION_MANAGER_LOGOUT_MODE_NORMAL); }
static void panel_action_shutdown (GtkWidget *widget) { PanelSessionManager *manager; manager = panel_session_manager_get (); panel_session_manager_request_shutdown (manager); }
GtkWidget * panel_desktop_menu_item_new (gboolean use_image, gboolean append_lock_logout) { PanelDesktopMenuItem *menuitem; char *name; #ifdef HAVE_TELEPATHY_GLIB PanelSessionManager *manager; #endif menuitem = g_object_new (PANEL_TYPE_DESKTOP_MENU_ITEM, NULL); name = panel_util_get_user_name (); if (use_image) { #ifdef HAVE_TELEPATHY_GLIB setup_menu_item_with_icon (GTK_WIDGET (menuitem), panel_menu_icon_get_size (), PANEL_ICON_USER_AVAILABLE, NULL, NULL, name); gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE); #else setup_menu_item_with_icon (GTK_WIDGET (menuitem), panel_menu_icon_get_size (), PANEL_ICON_COMPUTER, NULL, NULL, name); #endif } else setup_menuitem (GTK_WIDGET (menuitem), GTK_ICON_SIZE_INVALID, NULL, name); g_free (name); menuitem->priv->menu = panel_desktop_menu_item_create_menu (menuitem, append_lock_logout); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menuitem->priv->menu); #ifdef HAVE_TELEPATHY_GLIB manager = panel_session_manager_get (); menuitem->priv->presence_changed_id = g_signal_connect (manager, "presence-changed", G_CALLBACK (panel_desktop_menu_item_on_presence_changed), menuitem); panel_desktop_menu_item_on_presence_changed (manager, panel_session_manager_get_presence (manager), menuitem); #endif return GTK_WIDGET (menuitem); }
/* Log Out */ static void panel_action_logout (GtkWidget *widget) { /* FIXME: we need to use widget to get the screen for the * confirmation dialog, see * http://bugzilla.gnome.org/show_bug.cgi?id=536914 */ panel_session_manager_request_logout (panel_session_manager_get (), PANEL_SESSION_MANAGER_LOGOUT_MODE_NORMAL); }
static gboolean panel_action_shutdown_reboot_is_disabled (void) { PanelSessionManager *manager; if (panel_lockdown_get_disable_log_out()) return TRUE; manager = panel_session_manager_get (); return (!panel_session_manager_is_shutdown_available (manager)); }
static void panel_menu_item_activate_presence (GtkWidget *menuitem, TpAccountManager *account_manager) { PanelSessionManagerPresenceType presence_type; TpConnectionPresenceType tp_presence_type; const char *status; char *message; presence_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem), "panel-menu-presence")); panel_session_manager_set_presence (panel_session_manager_get (), presence_type); tp_presence_type = tp_account_manager_get_most_available_presence (account_manager, NULL, &message); if (tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_UNSET || tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_OFFLINE || tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_UNKNOWN || tp_presence_type == TP_CONNECTION_PRESENCE_TYPE_ERROR) goto free_message; if (presence_type == PANEL_SESSION_MANAGER_PRESENCE_AVAILABLE) { tp_presence_type = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE; status = "available"; } else if (presence_type == PANEL_SESSION_MANAGER_PRESENCE_BUSY) { tp_presence_type = TP_CONNECTION_PRESENCE_TYPE_BUSY; status = "busy"; } else goto free_message; tp_account_manager_set_all_requested_presences (account_manager, tp_presence_type, status, message); free_message: g_free (message); }
static void panel_desktop_menu_item_finalize (GObject *object) { PanelDesktopMenuItem *menuitem = (PanelDesktopMenuItem *) object; #ifdef HAVE_TELEPATHY_GLIB g_list_free (menuitem->priv->presence_items); menuitem->priv->presence_items = NULL; if (menuitem->priv->presence_changed_id != 0) g_signal_handler_disconnect (panel_session_manager_get (), menuitem->priv->presence_changed_id); menuitem->priv->presence_changed_id = 0; if (menuitem->priv->account_manager != NULL) g_object_unref (menuitem->priv->account_manager); menuitem->priv->account_manager = NULL; #endif G_OBJECT_CLASS (panel_desktop_menu_item_parent_class)->finalize (object); }
/* Log Out */ static void panel_action_logout (GtkWidget *widget) { PanelSessionManager *manager; gboolean not_prompt; not_prompt = mateconf_client_get_bool (panel_mateconf_get_client (), LOGOUT_PROMPT_KEY, NULL); /* this avoids handling errors from mateconf since prompting is * safer */ not_prompt = !not_prompt; manager = panel_session_manager_get (); if (not_prompt) panel_session_manager_request_logout (manager, PANEL_SESSION_MANAGER_LOGOUT_MODE_NO_CONFIRMATION); else /* FIXME: we need to use widget to get the screen for the * confirmation dialog, see * http://bugzilla.gnome.org/show_bug.cgi?id=536914 */ panel_session_manager_request_logout (manager, PANEL_SESSION_MANAGER_LOGOUT_MODE_NORMAL); }
void panel_menu_items_append_lock_logout (GtkWidget *menu) { GList *children; GList *last; GtkWidget *item; children = gtk_container_get_children (GTK_CONTAINER (menu)); last = g_list_last (children); if (last != NULL && GTK_IS_SEPARATOR (last->data)) item = GTK_WIDGET (last->data); else item = add_menu_separator (menu); g_list_free (children); panel_lockdown_on_notify (panel_lockdown_get (), NULL, G_OBJECT (item), panel_menu_items_lock_logout_separator_notified, item); panel_menu_items_lock_logout_separator_notified (panel_lockdown_get (), item); item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOCK, NULL, NULL, TRUE); if (item != NULL) { gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_object_bind_property (panel_lockdown_get (), "disable-lock-screen", item, "visible", G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN); } item = panel_menu_items_create_switch_user (FALSE); if (item != NULL) { gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_object_bind_property (panel_lockdown_get (), "disable-switch-user", item, "visible", G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN); } item = panel_menu_items_create_action_item_full (PANEL_ACTION_LOGOUT, NULL, NULL, TRUE); if (item != NULL) { gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_object_bind_property (panel_lockdown_get (), "disable-log-out", item, "visible", G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN); } /* FIXME: should be dynamic */ if (panel_session_manager_is_shutdown_available (panel_session_manager_get ())) { item = panel_menu_items_create_action_item_full (PANEL_ACTION_SHUTDOWN, NULL, NULL, TRUE); if (item != NULL) { GtkWidget *sep; sep = add_menu_separator (menu); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); g_object_bind_property (panel_lockdown_get (), "disable-log-out", sep, "visible", G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN); g_object_bind_property (panel_lockdown_get (), "disable-log-out", item, "visible", G_BINDING_SYNC_CREATE|G_BINDING_INVERT_BOOLEAN); } } }