~cairo-dock-team/ubuntu/precise/cairo-dock-plug-ins/3.0.0.0rc1

« back to all changes in this revision

Viewing changes to nVidia/src/applet-draw.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
 
#include <stdio.h>
22
 
#include <string.h>
23
 
#include <glib/gi18n.h>
24
 
 
25
 
#include "applet-struct.h"
26
 
#include "applet-nvidia.h"
27
 
#include "applet-draw.h"
28
 
 
29
 
 
30
 
 
31
 
void cd_nvidia_draw_no_data (void) {
32
 
        if (myData.pGPUData.iGPUTemp != myData.iPreviousGPUTemp) {
33
 
                myData.iPreviousGPUTemp = myData.pGPUData.iGPUTemp;
34
 
                CD_APPLET_SET_NAME_FOR_MY_ICON(myConfig.defaultTitle);
35
 
                CD_APPLET_SET_QUICK_INFO_ON_MY_ICON ("N/A");
36
 
                CD_APPLET_SET_USER_IMAGE_ON_MY_ICON (myConfig.cBrokenUserImage, "broken.svg");
37
 
        }
38
 
}
39
 
 
40
 
void cd_nvidia_draw_icon (void) {
41
 
        if (myData.pGPUData.iGPUTemp == myData.iPreviousGPUTemp) { // aucun changement.
42
 
                if (myData.pGauge)
43
 
                        return ;
44
 
                else {
45
 
                        double fTempPercent;
46
 
                        if (myData.pGPUData.iGPUTemp <= myConfig.iLowerLimit) {
47
 
                                fTempPercent = 0;
48
 
                        }
49
 
                        else if (myData.pGPUData.iGPUTemp >= myConfig.iUpperLimit ) {
50
 
                                fTempPercent = 1;
51
 
                        }
52
 
                        else {
53
 
                                fTempPercent = 1. * (myData.pGPUData.iGPUTemp - myConfig.iLowerLimit) / (myConfig.iUpperLimit - myConfig.iLowerLimit);
54
 
                        }
55
 
                        CD_APPLET_RENDER_GRAPH_NEW_VALUE (myData.pGraph, fTempPercent);
56
 
                }
57
 
        }
58
 
        
59
 
        if (myData.bAlerted == TRUE && myData.pGPUData.iGPUTemp < myConfig.iAlertLimit)
60
 
                myData.bAlerted = FALSE; //On réinitialise l'alert quand la température descend en dessou de la limite.
61
 
        
62
 
        if (myData.bAlerted == FALSE && myData.pGPUData.iGPUTemp >= myConfig.iAlertLimit)
63
 
                cd_nvidia_alert ();
64
 
 
65
 
        switch (myConfig.iDrawTemp) {
66
 
                case MY_APPLET_TEMP_NONE :
67
 
                        if (myIcon->cQuickInfo != NULL)
68
 
                                CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL);
69
 
                break;
70
 
                case MY_APPLET_TEMP_ON_QUICKINFO :
71
 
                        //if (myDock)
72
 
                                CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("%d°C", myData.pGPUData.iGPUTemp);
73
 
                        //else
74
 
                                //CD_APPLET_SET_QUICK_INFO_ON_MY_ICON_PRINTF ("nVidia:%d°C", myData.pGPUData.iGPUTemp)
75
 
                break;
76
 
                case MY_APPLET_TEMP_ON_NAME :
77
 
                        CD_APPLET_SET_NAME_FOR_MY_ICON_PRINTF ("%s: %d°C", myData.pGPUData.cGPUName, myData.pGPUData.iGPUTemp);
78
 
                break;
79
 
                case MY_APPLET_TEMP_ON_ICON : /*Abandonné pour le moment
80
 
                        /// c'est quoi que tu veux dessiner ?
81
 
                        //TODO Dessin manuel, copier sur clock le dessin de la Date avec libpango
82
 
                        
83
 
                        gchar *cTemp = g_strdup_printf ("%d°C", myData.pGPUData.iGPUTemp);
84
 
                        g_free (cTemp);
85
 
                        
86
 
                        if (myIcon->cQuickInfo != NULL)
87
 
                                CD_APPLET_SET_QUICK_INFO_ON_MY_ICON (NULL);*/
88
 
                break;
89
 
        }
90
 
        
91
 
        double fTempPercent;
92
 
        if (myData.pGPUData.iGPUTemp <= myConfig.iLowerLimit) {
93
 
                fTempPercent = 0;
94
 
        }
95
 
        else if (myData.pGPUData.iGPUTemp >= myConfig.iUpperLimit ) {
96
 
                fTempPercent = 1;
97
 
        }
98
 
        else {
99
 
                fTempPercent = 1. * (myData.pGPUData.iGPUTemp - myConfig.iLowerLimit) / (myConfig.iUpperLimit - myConfig.iLowerLimit);
100
 
        }
101
 
        cd_debug("nVidia - Value has changed, redraw (%f)", fTempPercent);
102
 
        
103
 
        if (myData.pGauge) {
104
 
                CD_APPLET_RENDER_GAUGE (myData.pGauge, fTempPercent);
105
 
        }
106
 
        else {
107
 
                CD_APPLET_RENDER_GRAPH_NEW_VALUE (myData.pGraph, fTempPercent);
108
 
        }
109
 
        
110
 
        myData.iPreviousGPUTemp = myData.pGPUData.iGPUTemp;
111
 
}
112
 
 
113
 
static void _nvidia_temporary_dialog (gchar *cInfo) {
114
 
        gchar *cIconPath = g_strdup_printf("%s/%s", MY_APPLET_SHARE_DATA_DIR, MY_APPLET_ICON_FILE);
115
 
        cairo_dock_show_temporary_dialog_with_icon (cInfo, myIcon, myContainer, 8000, cIconPath);
116
 
        g_free(cIconPath);
117
 
}
118
 
 
119
 
void cd_nvidia_bubble (void) {
120
 
        if (myData.bAcquisitionOK) {
121
 
                gchar *cInfo = g_strdup_printf ("nVidia.\n %s %s\n %s %dMB \n %s %s\n %s %d°C", D_("GPU Name:"), myData.pGPUData.cGPUName, D_("Video Ram:"), myData.pGPUData.iVideoRam, D_("Driver Version:"), myData.pGPUData.cDriverVersion, D_("Core Temparature:"), myData.pGPUData.iGPUTemp);
122
 
                _nvidia_temporary_dialog (cInfo);
123
 
                g_free (cInfo);
124
 
        }
125
 
        else if (myData.bSettingsTooOld) {
126
 
                _nvidia_temporary_dialog (D_("nVidia \nYour version of 'nvidia-settings' is too old\n You need at least the 1.0.0 version"));
127
 
        }
128
 
        else {
129
 
                _nvidia_temporary_dialog (D_("nVidia \nCouldn't acquire GPU temperature\n is 'nvidia-settings' installed on your system\n and configured to monitor GPU temperature ?"));
130
 
        }
131
 
}
132
 
 
133
 
void cd_nvidia_alert (void) {
134
 
        if (myData.bAlerted || ! myConfig.bAlert)
135
 
                return;
136
 
        
137
 
        gchar *cInfo = g_strdup_printf ("nVidia %s\n %s %s\n %s %d°C", D_("Alert!"), myData.pGPUData.cGPUName, D_("passed alert temperature level"), D_("Core Temparature:"), myData.pGPUData.iGPUTemp);
138
 
        _nvidia_temporary_dialog (cInfo);
139
 
        g_free (cInfo);
140
 
        
141
 
        if (myConfig.bAlertSound)
142
 
                cairo_dock_play_sound (myConfig.cSoundPath);
143
 
        
144
 
        myData.bAlerted = TRUE;
145
 
}