~psusi/ubuntu/natty/indicator-session/sleep

« back to all changes in this revision

Viewing changes to src/session-service.c

  • Committer: Bazaar Package Importer
  • Author(s): Ted Gould
  • Date: 2010-08-12 11:41:45 UTC
  • mfrom: (1.1.20 upstream)
  • Revision ID: james.westby@ubuntu.com-20100812114145-9ty4fvfpgxkhxc41
Tags: 0.2.10-0ubuntu1
* New upstream release.
  * Fix to lock screen so that the menu item is always to lock
    the screen. (LP: #599848)
  * Fix capitalization of complete update message.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include <libdbusmenu-glib/server.h>
37
37
#include <libdbusmenu-glib/menuitem.h>
38
38
#include <libdbusmenu-glib/client.h>
 
39
#include <libdbusmenu-gtk/menuitem.h>
39
40
 
40
41
#include <libindicator/indicator-service.h>
41
42
 
61
62
#define LOCKDOWN_KEY_USER         LOCKDOWN_DIR "/disable_user_switching"
62
63
#define LOCKDOWN_KEY_SCREENSAVER  LOCKDOWN_DIR "/disable_lock_screen"
63
64
 
 
65
#define KEYBINDING_DIR            "/apps/gnome_settings_daemon/keybindings"
 
66
#define KEY_LOCK_SCREEN           KEYBINDING_DIR "/screensaver"
 
67
 
64
68
typedef struct _ActivateData ActivateData;
65
69
struct _ActivateData
66
70
{
119
123
        return;
120
124
}
121
125
 
 
126
static void
 
127
keybinding_changed (GConfClient *client,
 
128
                    guint        cnxd_id,
 
129
                    GConfEntry  *entry,
 
130
                    gpointer     user_data)
 
131
{
 
132
        GConfValue  *value = gconf_entry_get_value (entry);
 
133
        const gchar *key   = gconf_entry_get_key (entry);
 
134
 
 
135
        if (value == NULL || key == NULL) {
 
136
                return;
 
137
        }
 
138
 
 
139
        if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) {
 
140
                g_debug("Keybinding changed to: %s", gconf_value_get_string(value));
 
141
                if (lock_menuitem != NULL) {
 
142
                        dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, gconf_value_get_string(value));
 
143
                }
 
144
        }
 
145
 
 
146
        return;
 
147
}
 
148
 
122
149
/* Ensures that we have a GConf client and if we build one
123
150
   set up the signal handler. */
124
151
static void
126
153
{
127
154
        if (!gconf_client) {
128
155
                gconf_client = gconf_client_get_default ();
 
156
 
129
157
                gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
130
158
                gconf_client_notify_add(gconf_client, LOCKDOWN_DIR, lockdown_changed, NULL, NULL, NULL);
 
159
 
 
160
                gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
 
161
                gconf_client_notify_add(gconf_client, KEYBINDING_DIR, keybinding_changed, NULL, NULL, NULL);
131
162
        }
132
163
        return;
133
164
}
516
547
  /* Lock screen item */
517
548
  if (can_lockscreen) {
518
549
        lock_menuitem = dbusmenu_menuitem_new();
519
 
        if (will_lock_screen()) {
520
 
                dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen"));
 
550
        dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen"));
 
551
 
 
552
        gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL);
 
553
        if (shortcut != NULL) {
 
554
                g_debug("Lock screen shortcut: %s", shortcut);
 
555
                dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut);
 
556
                g_free(shortcut);
521
557
        } else {
522
 
                dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Start Screensaver"));
 
558
                g_debug("Unable to get lock screen shortcut.");
523
559
        }
 
560
 
524
561
        g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL);
525
562
        dbusmenu_menuitem_child_append(root, lock_menuitem);
526
 
        lock_screen_update_item(lock_menuitem);
527
563
  }
528
564
 
529
565
  /* Set to NULL just incase we don't end up building one */
728
764
 
729
765
        if (restart_required) {
730
766
                if (supress_confirmations()) {
731
 
                        dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart To Complete Update"));
 
767
                        dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart to Complete Update"));
732
768
                } else {
733
 
                        dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart To Complete Update\342\200\246"));
 
769
                        dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart to Complete Update\342\200\246"));
734
770
                }
735
771
                dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_ICON, "system-restart-panel");
736
772
                if (session_dbus != NULL) {