diff options
author | Ted Gould <ted@gould.cx> | 2012-02-07 21:11:18 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2012-02-07 21:11:18 -0600 |
commit | 455f5df69319c0feb5e64317bef16925623e8ac5 (patch) | |
tree | 80591e7172255d17c54787082791730675afb062 /src/device-menu-mgr.c | |
parent | dadd9430e33c73e1a007f280694bc5e908472757 (diff) | |
parent | 6975e8a7aab320c77f3cb3de345415b9f26ba5cd (diff) | |
download | ayatana-indicator-session-455f5df69319c0feb5e64317bef16925623e8ac5.tar.gz ayatana-indicator-session-455f5df69319c0feb5e64317bef16925623e8ac5.tar.bz2 ayatana-indicator-session-455f5df69319c0feb5e64317bef16925623e8ac5.zip |
Import upstream version 0.3.90
Diffstat (limited to 'src/device-menu-mgr.c')
-rw-r--r-- | src/device-menu-mgr.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c index 5a63be3..f8f0696 100644 --- a/src/device-menu-mgr.c +++ b/src/device-menu-mgr.c @@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <config.h> #include <libdbusmenu-glib/client.h> -#include <libdbusmenu-gtk3/menuitem.h> #include "device-menu-mgr.h" #include "settings-helper.h" @@ -26,7 +26,11 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "dbusmenu-shared.h" #include "lock-helper.h" #include "upower-client.h" + +#ifdef HAVE_APT #include "apt-watcher.h" +#endif /* HAVE_APT */ + #include "udev-mgr.h" #define UP_ADDRESS "org.freedesktop.UPower" @@ -40,7 +44,9 @@ struct _DeviceMenuMgr GObject parent_instance; DbusmenuMenuitem* root_item; SessionDbus* session_dbus_interface; +#ifdef HAVE_APT AptWatcher* apt_watcher; +#endif /* HAVE_APT */ UdevMgr* udev_mgr; }; @@ -50,7 +56,9 @@ static DbusmenuMenuitem *lock_menuitem = NULL; static DbusmenuMenuitem *system_settings_menuitem = NULL; static DbusmenuMenuitem *display_settings_menuitem = NULL; static DbusmenuMenuitem *login_settings_menuitem = NULL; +#ifdef HAVE_APT static DbusmenuMenuitem *software_updates_menuitem = NULL; +#endif /* HAVE_APT */ static DbusmenuMenuitem *printers_menuitem = NULL; static DbusmenuMenuitem *scanners_menuitem = NULL; static DbusmenuMenuitem *webcam_menuitem = NULL; @@ -74,7 +82,6 @@ static DBusGProxy * up_prop_proxy = NULL; static void device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self); static void setup_up (DeviceMenuMgr* self); static void device_menu_mgr_rebuild_items (DeviceMenuMgr *self); -static void lock_if_possible (DeviceMenuMgr* self); static void machine_sleep_with_context (DeviceMenuMgr* self, gchar* type); static void show_system_settings_with_context (DbusmenuMenuitem * mi, @@ -102,7 +109,9 @@ G_DEFINE_TYPE (DeviceMenuMgr, device_menu_mgr, G_TYPE_OBJECT); static void device_menu_mgr_init (DeviceMenuMgr *self) { +#ifdef HAVE_APT self->apt_watcher = NULL; +#endif /* HAVE_APT */ self->root_item = dbusmenu_menuitem_new (); setup_up(self); g_idle_add(lock_screen_setup, NULL); @@ -162,27 +171,6 @@ keybinding_changed (GSettings *settings, return; } -/* Check to see if the lockdown key is protecting from - locking the screen. If not, lock it. */ -static void -lock_if_possible (DeviceMenuMgr* self) { - device_menu_mgr_ensure_settings_client (self); - - if (!g_settings_get_boolean (lockdown_settings, LOCKDOWN_KEY_SCREENSAVER)) { - lock_screen (NULL, 0, NULL); - } - return; -} - -/* A return from the command to sleep the system. Make sure - that we unthrottle the screensaver. */ -static void -sleep_response (DBusGProxy * proxy, DBusGProxyCall * call, gpointer data) -{ - screensaver_unthrottle(); - return; -} - static void machine_sleep_from_suspend (DbusmenuMenuitem * mi, guint timestamp, @@ -210,11 +198,9 @@ machine_sleep_with_context (DeviceMenuMgr* self, gchar* type) g_warning("Can not %s as no upower proxy", type); } - screensaver_throttle(type); - lock_if_possible (self); dbus_g_proxy_begin_call(up_main_proxy, type, - sleep_response, + NULL, NULL, NULL, G_TYPE_INVALID); @@ -410,7 +396,11 @@ static void show_dialog (DbusmenuMenuitem * mi, guint timestamp, gchar * type) { +#ifdef HAVE_GTKLOGOUTHELPER gchar * helper = g_build_filename(LIBEXECDIR, "gtk-logout-helper", NULL); +#else + gchar * helper = g_build_filename("gnome-session-quit", NULL); +#endif /* HAVE_GTKLOGOUTHELPER */ gchar * dialog_line = g_strdup_printf("%s --%s", helper, type); g_free(helper); @@ -480,12 +470,14 @@ static void device_menu_mgr_show_simple_scan (DbusmenuMenuitem * mi, { g_warning("Unable to launch simple-scan: %s", error->message); g_error_free(error); +#ifdef HAVE_APT if (!g_spawn_command_line_async("software-center simple-scan", &error)) { g_warning ("Unable to launch software-centre simple-scan: %s", error->message); g_error_free(error); } +#endif /* HAVE_APT */ } } @@ -498,12 +490,14 @@ static void device_menu_mgr_show_cheese (DbusmenuMenuitem * mi, { g_warning("Unable to launch cheese: %s", error->message); g_error_free(error); +#ifdef HAVE_APT if (!g_spawn_command_line_async("software-center cheese", &error)) { g_warning ("Unable to launch software-centre cheese: %s", error->message); g_error_free(error); } +#endif /* HAVE_APT */ } } @@ -542,6 +536,7 @@ device_menu_mgr_build_settings_items (DeviceMenuMgr* self) dbusmenu_menuitem_child_add_position(self->root_item, login_settings_menuitem, 2); +#ifdef HAVE_APT software_updates_menuitem = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (software_updates_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -549,6 +544,7 @@ device_menu_mgr_build_settings_items (DeviceMenuMgr* self) dbusmenu_menuitem_child_add_position(self->root_item, software_updates_menuitem, 3); +#endif /* HAVE_APT */ DbusmenuMenuitem * separator1 = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (separator1, @@ -726,7 +722,11 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode) dbusmenu_menuitem_child_append (self->root_item, shutdown_mi); g_signal_connect (G_OBJECT(shutdown_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, +#ifdef HAVE_GTKLOGOUTHELPER G_CALLBACK(show_dialog), "shutdown"); +#else + G_CALLBACK(show_dialog), "power-off"); +#endif /* HAVE_GTKLOGOUTHELPER */ RestartShutdownLogoutMenuItems * restart_shutdown_logout_mi = g_new0 (RestartShutdownLogoutMenuItems, 1); restart_shutdown_logout_mi->logout_mi = logout_mi; @@ -778,9 +778,11 @@ DeviceMenuMgr* device_menu_mgr_new (SessionDbus* session_dbus, gboolean greeter_ DeviceMenuMgr* device_mgr = g_object_new (DEVICE_TYPE_MENU_MGR, NULL); device_mgr->session_dbus_interface = session_dbus; device_menu_mgr_build_static_items (device_mgr, greeter_mode); +#ifdef HAVE_APT if (software_updates_menuitem != NULL) { device_mgr->apt_watcher = apt_watcher_new (session_dbus, software_updates_menuitem); } +#endif /* HAVE_APT */ return device_mgr; } |