2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 3
10
* of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
#include <glib/gi18n.h>
24
#include "applet-struct.h"
25
#include "applet-notifications.h"
26
#include "applet-netspeed.h"
29
CD_APPLET_ON_CLICK_BEGIN
30
cairo_dock_remove_dialog_if_any (myIcon);
31
if (myData.bAcquisitionOK)
33
cairo_dock_show_temporary_dialog_with_icon ("%s :\n %s : %.2f%s\n %s : %.2f%s",
34
myIcon, myContainer, 6e3,
35
MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE,
36
D_("Total amount of data"),
37
D_("downloaded"), (double) myData.iReceivedBytes / (1024*1204), D_("MB"),
38
D_("uploaded"), (double) myData.iTransmittedBytes / (1024*1204), D_("MB"));
42
cairo_dock_show_temporary_dialog_with_icon (D_("Interface '%s' seems to not exist or is not readable.\n You may need to open the configuration panel of this applet, and choose the interface you wish to monitor."),
43
myIcon, myContainer, 8e3,
44
MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE,
47
CD_APPLET_ON_CLICK_END
50
static void _netspeed_recheck (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet) {
51
cairo_dock_stop_task (myData.pPeriodicTask);
52
cairo_dock_launch_task (myData.pPeriodicTask);
54
static void _show_monitor_system (GtkMenuItem *menu_item, CairoDockModuleInstance *myApplet)
56
if (myConfig.cSystemMonitorCommand != NULL)
58
cairo_dock_launch_command (myConfig.cSystemMonitorCommand);
60
else if (g_iDesktopEnv == CAIRO_DOCK_KDE)
62
int r = system ("kde-system-monitor &");
66
cairo_dock_fm_show_system_monitor ();
69
CD_APPLET_ON_BUILD_MENU_BEGIN
70
GtkWidget *pSubMenu = CD_APPLET_CREATE_MY_SUB_MENU ();
71
CD_APPLET_ADD_IN_MENU (D_("Monitor System"), _show_monitor_system, pSubMenu);
72
if (! myData.bAcquisitionOK) {
73
CD_APPLET_ADD_IN_MENU (D_("Re-check interface"), _netspeed_recheck, pSubMenu);
75
CD_APPLET_ADD_ABOUT_IN_MENU (pSubMenu);
76
CD_APPLET_ON_BUILD_MENU_END
79
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
81
if (myData.dbus_proxy_nm == NULL)
82
myData.dbus_proxy_nm = cairo_dock_create_new_system_proxy (
83
"org.freedesktop.NetworkManager",
84
"/org/freedesktop/NetworkManager",
85
"org.freedesktop.NetworkManager");
86
g_return_val_if_fail (myData.dbus_proxy_nm != NULL, CAIRO_DOCK_LET_PASS_NOTIFICATION);
89
dbus_g_proxy_call (myData.dbus_proxy_nm, "state", NULL,
93
cd_debug ("current network state : %d", state);
94
if (state == 3) // actif
96
dbus_g_proxy_call_no_reply (myData.dbus_proxy_nm, "sleep",
100
else if (state == 1) // inactif
102
dbus_g_proxy_call_no_reply (myData.dbus_proxy_nm, "wake",
107
CD_APPLET_ON_MIDDLE_CLICK_END