~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy

« back to all changes in this revision

Viewing changes to logout/src/applet-notifications.c

Tags: upstream-3.0.0.0beta1
ImportĀ upstreamĀ versionĀ 3.0.0.0beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "applet-notifications.h"
26
26
 
27
27
 
 
28
CD_APPLET_ON_CLICK_BEGIN
 
29
 
 
30
        cd_logout_display_actions ();
 
31
 
 
32
CD_APPLET_ON_CLICK_END
 
33
 
 
34
                
28
35
static void _logout (void)
29
36
{
30
37
        if (myConfig.cUserAction != NULL)
60
67
        switch (iAction)
61
68
        {
62
69
                case CD_LOGOUT:
63
 
                default:
64
70
                        _logout ();
65
71
                break;
66
72
                case CD_SHUTDOWN:
69
75
                case CD_LOCK_SCREEN:
70
76
                        cairo_dock_fm_lock_screen ();
71
77
                break;
72
 
        }
73
 
}
74
 
 
75
 
CD_APPLET_ON_CLICK_BEGIN
76
 
{
77
 
        /**if (myIcon->Xid != 0)
78
 
        {
79
 
                if (cairo_dock_get_current_active_window () == myIcon->Xid && myTaskBar.bMinimizeOnClick)
80
 
                        cairo_dock_minimize_xwindow (myIcon->Xid);
81
 
                else
82
 
                        cairo_dock_show_xwindow (myIcon->Xid);
83
 
        }
84
 
        else*/
85
 
        {
86
 
                // on execute l'action meme si la fenetre est deja ouverte (ca lui redonne le focus), car si on avait deja execute l'autre action, ca empeche de faire celle-ci.
87
 
                _execute_action (myConfig.iActionOnClick);
88
 
        }
89
 
}
90
 
CD_APPLET_ON_CLICK_END
91
 
 
92
 
 
 
78
                case CD_POP_UP_MENU:
 
79
                default:
 
80
                        cd_logout_display_actions ();
 
81
                break;
 
82
        }
 
83
}
93
84
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
94
 
{
 
85
 
95
86
        _execute_action (myConfig.iActionOnMiddleClick);
96
 
}
 
87
 
97
88
CD_APPLET_ON_MIDDLE_CLICK_END
98
89
 
99
90
 
100
 
static void _cd_logout (GtkMenuItem *menu_item, gpointer data)
101
 
{
102
 
        CD_APPLET_ENTER;
103
 
        _logout ();
104
 
        CD_APPLET_LEAVE ();
105
 
}
106
 
static void _cd_shutdown (GtkMenuItem *menu_item, gpointer data)
107
 
{
108
 
        CD_APPLET_ENTER;
109
 
        _shutdown ();
110
 
        CD_APPLET_LEAVE ();
111
 
}
112
 
static void _cd_lock_screen (GtkMenuItem *menu_item, gpointer data)
113
 
{
114
 
        CD_APPLET_ENTER;
115
 
        cairo_dock_fm_lock_screen ();
116
 
        CD_APPLET_LEAVE ();
117
 
}
118
 
 
119
 
static void _cd_logout_guest_session (GtkMenuItem *menu_item, gpointer data)
120
 
{
121
 
        CD_APPLET_ENTER;
122
 
        cd_logout_launch_guest_session ();
123
 
        CD_APPLET_LEAVE ();
124
 
}
125
 
 
126
 
static void _cd_logout_program_shutdown (GtkMenuItem *menu_item, gpointer data)
127
 
{
128
 
        CD_APPLET_ENTER;
129
 
        cd_logout_program_shutdown ();
130
 
        CD_APPLET_LEAVE ();
 
91
static void cd_logout_manage_users (GtkMenuItem *menu_item, gchar *cUserName)
 
92
{
 
93
        GError * error = NULL;
 
94
        if (! g_spawn_command_line_async("gnome-control-center user-accounts", &error))  // Gnome3
 
95
        {
 
96
                cd_warning ("Couldn't launch 'gnome-control-center user-accounts': %s", error->message);
 
97
                g_error_free(error);
 
98
        }  /// TODO: handle other DE ...
131
99
}
132
100
CD_APPLET_ON_BUILD_MENU_BEGIN
133
 
{
134
 
        GtkWidget *pSubMenu = CD_APPLET_CREATE_MY_SUB_MENU ();
135
 
        
136
 
        gchar *cLabel;
137
 
        if (! myData.bCapabilitiesChecked)  // if we're using our own logout methods, they are all accessible from the left-click, so no need to add the following actions in the right-click menu.
138
 
        {
139
 
                if (myConfig.iActionOnClick != CD_LOGOUT)  // logout action not on click => put it in the menu
140
 
                {
141
 
                        if (myConfig.iActionOnMiddleClick == CD_LOGOUT)  // logout action on middle-click
142
 
                                cLabel = g_strdup_printf ("%s (%s)", D_("Log out"), D_("middle-click"));
143
 
                        else
144
 
                                cLabel = g_strdup (D_("Log out"));
145
 
                        CD_APPLET_ADD_IN_MENU_WITH_STOCK (cLabel, MY_APPLET_SHARE_DATA_DIR"/system-log-out.svg", _cd_logout, CD_APPLET_MY_MENU);
146
 
                        g_free (cLabel);
147
 
                }
148
 
                if (myConfig.iActionOnClick != CD_SHUTDOWN)  // shutdown action not on click => put it in the menu
149
 
                {
150
 
                        if (myConfig.iActionOnMiddleClick == CD_SHUTDOWN)  // logout action on middle-click
151
 
                                cLabel = g_strdup_printf ("%s (%s)", D_("Shut down"), D_("middle-click"));
152
 
                        else
153
 
                                cLabel = g_strdup (D_("Shut down"));
154
 
                        CD_APPLET_ADD_IN_MENU_WITH_STOCK (cLabel, MY_APPLET_SHARE_DATA_DIR"/system-shutdown.svg", _cd_shutdown, CD_APPLET_MY_MENU);
155
 
                        g_free (cLabel);
156
 
                }
157
 
                if (myConfig.iActionOnClick != CD_LOCK_SCREEN)  // lockscreen action not on click => put it in the menu
158
 
                {
159
 
                        if (myConfig.iActionOnMiddleClick == CD_LOCK_SCREEN)  // lockscreen action on middle-click
160
 
                                cLabel = g_strdup_printf ("%s (%s)", D_("Lock screen"), D_("middle-click"));
161
 
                        else
162
 
                                cLabel = g_strdup (D_("Lock screen"));
163
 
                        CD_APPLET_ADD_IN_MENU_WITH_STOCK (cLabel, MY_APPLET_SHARE_DATA_DIR"/locked.svg", _cd_lock_screen, CD_APPLET_MY_MENU);
164
 
                        g_free (cLabel);
165
 
                }
166
 
        }
167
 
        if (cd_logout_have_guest_session ()) // Guest Session
168
 
        {
169
 
                CD_APPLET_ADD_IN_MENU_WITH_STOCK (D_("Guest session"), MY_APPLET_SHARE_DATA_DIR"/system-guest.svg", _cd_logout_guest_session, CD_APPLET_MY_MENU);
170
 
        }
171
 
        
172
 
        CD_APPLET_ADD_IN_MENU_WITH_STOCK (D_("Program an automatic shut-down"), MY_APPLET_SHARE_DATA_DIR"/icon-scheduling.svg", _cd_logout_program_shutdown, CD_APPLET_MY_MENU);  // pas beaucoup d'entrees => on le met dans le menu global.
173
 
        
174
 
        CD_APPLET_ADD_ABOUT_IN_MENU (pSubMenu);
175
 
}
 
101
        if (g_iDesktopEnv == CAIRO_DOCK_GNOME)
 
102
        {
 
103
                CD_APPLET_ADD_IN_MENU_WITH_STOCK (D_("Manage users"), GTK_STOCK_EDIT, cd_logout_manage_users, CD_APPLET_MY_MENU);
 
104
        }
176
105
CD_APPLET_ON_BUILD_MENU_END
 
106
 
 
107
 
 
108
void cd_logout_on_keybinding_pull (const gchar *keystring, gpointer user_data)
 
109
{
 
110
        cairo_dock_fm_lock_screen ();
 
111
}
 
112
 
 
113
void cd_logout_on_keybinding_pull2 (const gchar *keystring, gpointer user_data)
 
114
{
 
115
        cd_logout_display_actions ();
 
116
}