~cairo-dock-team/cairo-dock-plug-ins/plug-ins

« back to all changes in this revision

Viewing changes to System-Monitor/src/applet-notifications.c

  • Committer: Matthieu Baerts
  • Date: 2014-10-19 00:26:10 UTC
  • Revision ID: matttbe@gmail.com-20141019002610-ulf26s9b4c4rw10r
We just switched from BZR to Git.
Follow us on Github: https://github.com/Cairo-Dock

Note: we will only use Github to manage our source code and all pull requests.
Please continue to report your bugs/ideas/messages on our forum or Launchpad! 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
* This file is a part of the Cairo-Dock project
3
 
*
4
 
* Copyright : (C) see the 'copyright' file.
5
 
* E-mail    : see the 'copyright' file.
6
 
*
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.
11
 
*
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/>.
18
 
*/
19
 
 
20
 
#include <stdlib.h>
21
 
#include <string.h>
22
 
 
23
 
#include "applet-struct.h"
24
 
#include "applet-cpusage.h"
25
 
#include "applet-rame.h"
26
 
#include "applet-nvidia.h"
27
 
#include "applet-top.h"
28
 
#include "applet-sensors.h"
29
 
#include "applet-notifications.h"
30
 
 
31
 
 
32
 
CD_APPLET_ON_CLICK_BEGIN
33
 
        if (myData.bAcquisitionOK)
34
 
        {
35
 
                cd_sysmonitor_start_top_dialog (myApplet);
36
 
        }
37
 
        else
38
 
        {
39
 
                gldi_dialogs_remove_on_icon (myIcon);
40
 
                gldi_dialog_show_temporary_with_icon (D_("The acquisition of one or more data has failed.\nYou should remove the data that couldn't be fetched."), myIcon, myContainer, 6e3, MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE);
41
 
        }
42
 
CD_APPLET_ON_CLICK_END
43
 
 
44
 
 
45
 
static void _pop_up_dialog_info (GldiModuleInstance *myApplet)
46
 
{
47
 
        if (myData.pTopDialog != NULL)  // we shouldn't get the click event anyway
48
 
                return;
49
 
        gldi_dialogs_remove_on_icon (myIcon);
50
 
        
51
 
        GString *pInfo = g_string_new ("");
52
 
        
53
 
        // CPU
54
 
        cd_sysmonitor_get_cpu_info (myApplet, pInfo);
55
 
        
56
 
        // uptime
57
 
        cd_sysmonitor_get_uptime_info (pInfo);
58
 
        
59
 
        // RAM
60
 
        cd_sysmonitor_get_ram_info (myApplet, pInfo);
61
 
        
62
 
        // CG
63
 
        cd_sysmonitor_get_nivdia_info (myApplet, pInfo);
64
 
        
65
 
        // sensors
66
 
        cd_sysmonitor_get_sensors_info (myApplet, pInfo);
67
 
        
68
 
        // On affiche tout ca.
69
 
        gldi_dialog_show_temporary_with_icon (pInfo->str,
70
 
                myIcon, myContainer,
71
 
                15e3,
72
 
                MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE);
73
 
        
74
 
        g_string_free (pInfo, TRUE);
75
 
}
76
 
 
77
 
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
78
 
        if (myData.bInitialized && myData.bAcquisitionOK)
79
 
        {
80
 
                _pop_up_dialog_info (myApplet);
81
 
        }
82
 
        else
83
 
        {
84
 
                gldi_dialog_show_temporary_with_icon (D_("The acquisition of one or more data has failed.\nYou should remove the data that couldn't be fetched."), myIcon, myContainer, 5e3, MY_APPLET_SHARE_DATA_DIR"/"MY_APPLET_ICON_FILE);
85
 
        }
86
 
CD_APPLET_ON_MIDDLE_CLICK_END
87
 
 
88
 
 
89
 
static void _open_system_monitor (GtkMenuItem *menu_item, GldiModuleInstance *myApplet)
90
 
{
91
 
        if (myConfig.cSystemMonitorCommand != NULL)
92
 
        {
93
 
                cairo_dock_launch_command (myConfig.cSystemMonitorCommand);
94
 
        }
95
 
        else
96
 
        {
97
 
                cairo_dock_fm_show_system_monitor ();
98
 
        }
99
 
}
100
 
static void _show_info (GtkMenuItem *menu_item, GldiModuleInstance *myApplet)
101
 
{
102
 
        _pop_up_dialog_info (myApplet);
103
 
}
104
 
CD_APPLET_ON_BUILD_MENU_BEGIN
105
 
        CD_APPLET_ADD_IN_MENU_WITH_STOCK (D_("Open the System-Monitor"), GLDI_ICON_NAME_EXECUTE, _open_system_monitor, CD_APPLET_MY_MENU);
106
 
        
107
 
        gchar *cLabel = g_strdup_printf ("%s (%s)", D_("Show info"), D_("middle-click"));
108
 
        CD_APPLET_ADD_IN_MENU_WITH_STOCK (cLabel, GLDI_ICON_NAME_DIALOG_INFO, _show_info, CD_APPLET_MY_MENU);
109
 
        g_free (cLabel);
110
 
CD_APPLET_ON_BUILD_MENU_END