1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/**
* This file is a part of the Cairo-Dock project
*
* Copyright : (C) see the 'copyright' file.
* E-mail : see the 'copyright' file.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* 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 <stdlib.h>
#include <string.h>
#include <glib/gi18n.h>
#include "applet-struct.h"
#include "applet-notifications.h"
#include "applet-wifi.h"
#include "applet-draw.h"
CD_APPLET_ON_CLICK_BEGIN
cairo_dock_remove_dialog_if_any (myIcon);
cd_wifi_bubble();
CD_APPLET_ON_CLICK_END
static void _wifi_recheck_wireless_extension (GtkMenuItem *menu_item, gpointer data) {
cairo_dock_stop_task (myData.pTask);
cairo_dock_launch_task (myData.pTask);
}
static void _cd_wifi_show_config (GtkMenuItem *menu_item, gpointer data) { /// a mettre dans les plug-ins d'integration.
if (myConfig.cUserCommand != NULL) {
cairo_dock_launch_command (myConfig.cUserCommand);
return;
}
/*if (g_file_test ("/opt/wicd/daemon.py", G_FILE_TEST_EXISTS)) { //On détecte wicd
cairo_dock_launch_command ("/opt/wicd/gui.py");
return;
}*/
const gchar *cCommand = NULL;
if (g_iDesktopEnv == CAIRO_DOCK_GNOME || g_iDesktopEnv == CAIRO_DOCK_XFCE) {
int iMajor, iMinor, iMicro;
cairo_dock_get_gnome_version (&iMajor, &iMinor, &iMicro);
if (iMajor == 2 && iMinor < 22) {
cCommand = "gksu network-admin";
}
else {
if (iMajor == 2 && iMinor > 22)
cCommand = "nm-connection-editor";
else {
cCommand = "network-admin";
}
}
}
else if (g_iDesktopEnv == CAIRO_DOCK_KDE) { //Ajouter les lignes de KDE
//cCommand =
}
cairo_dock_launch_command (cCommand);
}
CD_APPLET_ON_BUILD_MENU_BEGIN
// Sub-Menu
GtkWidget *pSubMenu = CD_APPLET_CREATE_MY_SUB_MENU ();
if (! myData.bWirelessExt)
CD_APPLET_ADD_IN_MENU (D_("Check for Wireless Extension"), _wifi_recheck_wireless_extension, pSubMenu);
CD_APPLET_ADD_IN_MENU (D_("Network Administration"), _cd_wifi_show_config, pSubMenu);
CD_APPLET_ADD_SEPARATOR (pSubMenu);
CD_APPLET_ADD_ABOUT_IN_MENU (pSubMenu);
CD_APPLET_ON_BUILD_MENU_END
static void toggle_wlan(void)
{
DBusGProxy *dbus_proxy_nm = cairo_dock_create_new_system_proxy (
"org.freedesktop.NetworkManager",
"/org/freedesktop/NetworkManager",
"org.freedesktop.NetworkManager");
g_return_if_fail (dbus_proxy_nm != NULL);
guint state = 0;
dbus_g_proxy_call (dbus_proxy_nm, "state", NULL,
G_TYPE_INVALID,
G_TYPE_UINT, &state,
G_TYPE_INVALID);
cd_debug ("current network state : %d", state);
if (state == 3) // actif
{
dbus_g_proxy_call_no_reply (dbus_proxy_nm, "sleep",
G_TYPE_INVALID,
G_TYPE_INVALID);
}
else if (state == 1) // inactif
{
dbus_g_proxy_call_no_reply (dbus_proxy_nm, "wake",
G_TYPE_INVALID,
G_TYPE_INVALID);
}
g_object_unref (dbus_proxy_nm);
}
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
toggle_wlan ();
//cairo_dock_launch_task (myData.pTask);
//cairo_dock_remove_dialog_if_any (myIcon);
CD_APPLET_ON_MIDDLE_CLICK_END
|