~cairo-dock-team/ubuntu/precise/cairo-dock-plug-ins/3.0.0.1

« back to all changes in this revision

Viewing changes to rame/src/applet-init.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne, Matthieu Baerts (matttbe), Julien Lavergne
  • Date: 2009-10-05 19:27:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20091005192717-mvqvb395guktr401
Tags: 2.0.9-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New upstream release (LP: #435590)
* debian/control: 
 - Remove ${shlibs:Depends} for integration plug-ins to avoid
   pulling shared libraries which are detected automatically.
 - Added curl as depends for cairo-dock-plug-ins
* debian/rules:
 - Add --enable-dnd2share and --enable-musicplayer to enable new applets.
 - Remove --enable-rhythmbox and --enable-nvidia to remove those applets,
   not maintained upstream.
* Update *.install to take all generated applets.

[ Julien Lavergne ]
* Adjust changelog with Daniel Holbach suggestions.
* cairo-dock-plug-ins.changelogs:  Install specific changelog for 2.0.9
* Build-depends on cairo-dock-dev (>= 2.0.9)

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
 
 
22
 
#include "applet-config.h"
23
 
#include "applet-notifications.h"
24
 
#include "applet-struct.h"
25
 
#include "applet-init.h"
26
 
#include "applet-rame.h"
27
 
 
28
 
CD_APPLET_DEFINITION ("ram-meter",
29
 
        1, 6, 3,
30
 
        CAIRO_DOCK_CATEGORY_ACCESSORY,
31
 
        N_("This applet shows you the amount of RAM and SWAP that is curently used\n"
32
 
        "Left-click to show a list of the most memory using programs"),
33
 
        "parAdOxxx_ZeRo");
34
 
 
35
 
CD_APPLET_INIT_BEGIN
36
 
        if (myDesklet != NULL) {
37
 
                CD_APPLET_SET_DESKLET_RENDERER ("Simple");
38
 
        }
39
 
        
40
 
        //Initialisation du rendu jauge/graphique.
41
 
        double fMaxScale = cairo_dock_get_max_scale (myContainer);
42
 
        if (myConfig.bUseGraphic)
43
 
        {
44
 
                myData.pGraph = cairo_dock_create_graph (myDrawContext,
45
 
                        20, myConfig.iGraphType | CAIRO_DOCK_DOUBLE_GRAPH | (myConfig.bMixGraph ? CAIRO_DOCK_MIX_DOUBLE_GRAPH : 0),
46
 
                        myIcon->fWidth * fMaxScale, myIcon->fHeight * fMaxScale,
47
 
                        myConfig.fLowColor, myConfig.fHigholor, myConfig.fBgColor, myConfig.fLowColor2, myConfig.fHigholor2);
48
 
                if (myConfig.cWatermarkImagePath != NULL)
49
 
                        cairo_dock_add_watermark_on_graph (myDrawContext, myData.pGraph, myConfig.cWatermarkImagePath, myConfig.fAlpha);
50
 
                CD_APPLET_RENDER_GRAPH (myData.pGraph);
51
 
        }
52
 
        else
53
 
        {
54
 
                myData.pGauge = cairo_dock_load_gauge(myDrawContext,myConfig.cGThemePath,myIcon->fWidth * fMaxScale, myIcon->fHeight * fMaxScale);
55
 
                if (myConfig.cWatermarkImagePath != NULL)
56
 
                        cairo_dock_add_watermark_on_gauge (myDrawContext, myData.pGauge, myConfig.cWatermarkImagePath, myConfig.fAlpha);
57
 
                CD_APPLET_RENDER_GAUGE (myData.pGauge, 0.);
58
 
        }
59
 
 
60
 
        //Initialisation du timer de mesure.
61
 
        myData.pTask = cairo_dock_new_task (myConfig.iCheckInterval,
62
 
                (CairoDockGetDataAsyncFunc) cd_rame_read_data,
63
 
                (CairoDockUpdateSyncFunc) cd_rame_update_from_data,
64
 
                myApplet);
65
 
        myData.bAcquisitionOK = TRUE;
66
 
        cairo_dock_launch_task (myData.pTask);
67
 
        
68
 
        CD_APPLET_REGISTER_FOR_CLICK_EVENT;
69
 
        CD_APPLET_REGISTER_FOR_BUILD_MENU_EVENT;
70
 
CD_APPLET_INIT_END
71
 
 
72
 
 
73
 
CD_APPLET_STOP_BEGIN
74
 
        //\_______________ On se desabonne de nos notifications.
75
 
        CD_APPLET_UNREGISTER_FOR_CLICK_EVENT;
76
 
        CD_APPLET_UNREGISTER_FOR_BUILD_MENU_EVENT;
77
 
CD_APPLET_STOP_END
78
 
 
79
 
 
80
 
CD_APPLET_RELOAD_BEGIN
81
 
        //\_______________ On recharge les donnees qui ont pu changer.
82
 
        if (myDesklet != NULL) {
83
 
                CD_APPLET_SET_DESKLET_RENDERER ("Simple");
84
 
        }
85
 
        
86
 
        double fMaxScale = cairo_dock_get_max_scale (myContainer);
87
 
        
88
 
        if (CD_APPLET_MY_CONFIG_CHANGED) {
89
 
                cairo_dock_free_gauge(myData.pGauge);
90
 
                cairo_dock_free_graph (myData.pGraph);
91
 
                if (myConfig.bUseGraphic)
92
 
                {
93
 
                        myData.pGauge = NULL;
94
 
                        myData.pGraph = cairo_dock_create_graph (myDrawContext,
95
 
                                20, myConfig.iGraphType | CAIRO_DOCK_DOUBLE_GRAPH | (myConfig.bMixGraph ? CAIRO_DOCK_MIX_DOUBLE_GRAPH : 0),
96
 
                                myIcon->fWidth * fMaxScale, myIcon->fHeight * fMaxScale,
97
 
                                myConfig.fLowColor, myConfig.fHigholor, myConfig.fBgColor, myConfig.fLowColor2, myConfig.fHigholor2);
98
 
                        if (myConfig.cWatermarkImagePath != NULL)
99
 
                                cairo_dock_add_watermark_on_graph (myDrawContext, myData.pGraph, myConfig.cWatermarkImagePath, myConfig.fAlpha);
100
 
                }
101
 
                else
102
 
                {
103
 
                        myData.pGraph = NULL;
104
 
                        myData.pGauge = cairo_dock_load_gauge(myDrawContext,
105
 
                                myConfig.cGThemePath,
106
 
                                myIcon->fWidth * fMaxScale,myIcon->fHeight * fMaxScale);
107
 
                        if (myConfig.cWatermarkImagePath != NULL)
108
 
                                cairo_dock_add_watermark_on_gauge (myDrawContext, myData.pGauge, myConfig.cWatermarkImagePath, myConfig.fAlpha);
109
 
                }
110
 
                
111
 
                if (myConfig.iInfoDisplay != CAIRO_DOCK_INFO_ON_ICON)
112
 
                {
113
 
                        CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL);
114
 
                }
115
 
                if (myConfig.iInfoDisplay != CAIRO_DOCK_INFO_ON_LABEL)
116
 
                {
117
 
                        CD_APPLET_SET_NAME_FOR_MY_ICON (myConfig.defaultTitle);
118
 
                }
119
 
                
120
 
                myData.fPrevRamPercent = 0;  // on force le redessin.
121
 
                cairo_dock_relaunch_task_immediately (myData.pTask, myConfig.iCheckInterval);
122
 
                
123
 
                if (cairo_dock_task_is_active (myData.pTopTask))
124
 
                {
125
 
                        cd_rame_clean_all_processes ();
126
 
                        cairo_dock_stop_task (myData.pTopTask);
127
 
                        g_free (myData.pTopList);
128
 
                        myData.pTopList = NULL;
129
 
                        g_free (myData.pPreviousTopList);
130
 
                        myData.pPreviousTopList = NULL;
131
 
                        cairo_dock_launch_task (myData.pTopTask);
132
 
                }
133
 
        }
134
 
        else {  // on redessine juste l'icone.
135
 
                if (myData.pGauge != NULL)
136
 
                        cairo_dock_reload_gauge (myDrawContext, myData.pGauge, myIcon->fWidth * fMaxScale, myIcon->fHeight * fMaxScale);
137
 
                else if (myData.pGraph != NULL)
138
 
                        cairo_dock_reload_graph (myDrawContext, myData.pGraph, myIcon->fWidth * fMaxScale, myIcon->fHeight * fMaxScale);
139
 
                else if (myConfig.bUseGraphic)
140
 
                        myData.pGraph = cairo_dock_create_graph (myDrawContext,
141
 
                                20, myConfig.iGraphType | CAIRO_DOCK_DOUBLE_GRAPH | (myConfig.bMixGraph ? CAIRO_DOCK_MIX_DOUBLE_GRAPH : 0),
142
 
                                myIcon->fWidth * fMaxScale, myIcon->fHeight * fMaxScale,
143
 
                                myConfig.fLowColor, myConfig.fHigholor, myConfig.fBgColor, myConfig.fLowColor2, myConfig.fHigholor2);
144
 
                else
145
 
                        myData.pGauge = cairo_dock_load_gauge(myDrawContext,
146
 
                                myConfig.cGThemePath,
147
 
                                myIcon->fWidth * fMaxScale, myIcon->fHeight * fMaxScale);
148
 
                if (myConfig.cWatermarkImagePath != NULL)
149
 
                {
150
 
                        if (myData.pGauge != NULL)
151
 
                                cairo_dock_add_watermark_on_gauge (myDrawContext, myData.pGauge, myConfig.cWatermarkImagePath, myConfig.fAlpha);
152
 
                        else
153
 
                                cairo_dock_add_watermark_on_graph (myDrawContext, myData.pGraph, myConfig.cWatermarkImagePath, myConfig.fAlpha);
154
 
                }
155
 
                
156
 
                CairoDockLabelDescription *pOldLabelDescription = myConfig.pTopTextDescription;  // on recupere le nouveau style des etiquettes en cas de changement de la config du dock.
157
 
                myConfig.pTopTextDescription = cairo_dock_duplicate_label_description (&myDialogs.dialogTextDescription);
158
 
                memcpy (myConfig.pTopTextDescription->fColorStart, pOldLabelDescription->fColorStart, 3*sizeof (double));
159
 
                memcpy (myConfig.pTopTextDescription->fColorStop, pOldLabelDescription->fColorStop, 3*sizeof (double));
160
 
                myConfig.pTopTextDescription->bVerticalPattern = TRUE;
161
 
                cairo_dock_free_label_description (pOldLabelDescription);
162
 
                
163
 
                myData.fPrevRamPercent = 0;  // on force le redessin.
164
 
                cd_rame_update_from_data (myApplet);
165
 
        }
166
 
CD_APPLET_RELOAD_END