~ubuntu-branches/ubuntu/maverick/cairo-dock-plugins/weird

« back to all changes in this revision

Viewing changes to powermanager/src/powermanager-draw.c

  • Committer: matttbe
  • Date: 2010-08-07 01:43:25 UTC
  • Revision ID: matttbe@gmail.com-20100807014325-36tmlrc8n1rrksk5
* New Upstream Version (LP: #614625)
* debian/rules:
 - Autotools has been replaced by CMake
 - cdbs is now used.
* debian/copyright:
 - Updated with the new applets
* debian/control:
 - Autotools has been replaced by CMake
 - Added libcurl4-gnutls-dev, libindicator-dev, libdbusmenu-glib-dev
   libido-0.1-dev, libical-dev, libdbusmenu-gtk-dev as Build-deps
 - Bump Standard-Version to 3.9.1
 - Wget is required for dnd2share applet
* debian/cairo-dock-plug-ins*.install:
 - All sonames are now installed into lib32 or lib64 (lib*)
* Fixed a few bugs on LP:
 - LP: #483963, LP: #485159, LP: #500677, LP: #500979
 - LP: #521531, LP: #519915, LP: #526138, LP: #531317
 - LP: #531319, LP: #537115, LP: #537943, LP: #538637
 - More details on the 'ChangeLog' file

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "powermanager-draw.h"
25
25
 
26
26
 
27
 
void iconWitness(int animationLenght)
28
 
{
29
 
        CD_APPLET_ANIMATE_MY_ICON (myConfig.batteryWitnessAnimation, animationLenght);
30
 
}
31
 
 
32
27
void update_icon(void)
33
28
{
34
29
        gboolean bNeedRedraw = FALSE;
143
138
        return cTimeString;
144
139
}
145
140
 
146
 
static void _cd_powermanager_dialog (GString *sInfo) {
147
 
        cd_debug ("%s", __func__);
148
 
        gchar *cIconPath = NULL;
 
141
static void _cd_powermanager_dialog (const gchar *cInfo, int iDuration)
 
142
{
 
143
        cairo_dock_remove_dialog_if_any (myIcon);
149
144
        
 
145
        const gchar *cIconPath;
150
146
        if (!myData.on_battery || !myData.battery_present)
151
 
                cIconPath = g_strdup_printf("%s/%s", MY_APPLET_SHARE_DATA_DIR, "sector.svg");
 
147
                cIconPath = MY_APPLET_SHARE_DATA_DIR"/sector.svg";
152
148
        else
153
 
                cIconPath = g_strdup_printf("%s/%s", MY_APPLET_SHARE_DATA_DIR, "default-battery.svg");
154
 
                
155
 
        cd_debug ("%s (%s)", sInfo->str, cIconPath);
156
 
        cairo_dock_show_temporary_dialog_with_icon (sInfo->str, myIcon, myContainer, 6000, cIconPath);
157
 
        g_free(cIconPath);
 
149
                cIconPath = MY_APPLET_SHARE_DATA_DIR"/default-battery.svg";
 
150
        
 
151
        cd_debug ("%s (%s)", cInfo, cIconPath);
 
152
        cairo_dock_show_temporary_dialog_with_icon (cInfo, myIcon, myContainer, 1000*iDuration, cIconPath);
158
153
}
159
154
 
160
155
void cd_powermanager_bubble (void)
161
156
{
162
 
        cd_debug ("%s", __func__);
163
157
        GString *sInfo = g_string_new ("");
164
158
        if(myData.battery_present)
165
159
        {
170
164
                        hms = g_strdup_printf ("%s", D_("Unknown"));
171
165
                if(myData.on_battery)
172
166
                {
173
 
                        g_string_printf (sInfo, "%s %.2f%% \n %s %s", D_("Laptop on Battery.\n Battery charged at:"), myData.battery_charge, D_("Estimated time with Charge:"), hms);
 
167
                        g_string_printf (sInfo, "%s %.2f%% \n %s %s", D_("Laptop on Battery.\n Battery charged at:"), myData.battery_charge, D_("Estimated time with charge:"), hms);
174
168
                }
175
169
                else
176
170
                {
177
 
                        g_string_printf (sInfo, "%s %.2f%% \n %s %s", D_("Laptop on Charge.\n Battery charged at:"), myData.battery_charge, D_("Estimated Charge time:"), hms);
 
171
                        g_string_printf (sInfo, "%s %.2f%% \n %s %s", D_("Laptop on Charge.\n Battery charged at:"), myData.battery_charge, D_("Estimated charge time:"), hms);
178
172
                }
179
173
                g_free (hms);
180
174
        }
181
175
        else
182
176
        {
183
 
                g_string_printf (sInfo, "%s", D_("No Battery found."));
 
177
                g_string_printf (sInfo, "%s", D_("No battery found."));
184
178
        }
185
179
        
186
 
        _cd_powermanager_dialog (sInfo);
 
180
        _cd_powermanager_dialog (sInfo->str, 6000);
187
181
        g_string_free (sInfo, TRUE);
188
182
}
189
183
 
200
194
                
201
195
        if ((alert == POWER_MANAGER_CHARGE_LOW && myConfig.lowBatteryWitness) || (alert == POWER_MANAGER_CHARGE_CRITICAL && myConfig.criticalBatteryWitness))
202
196
        {
203
 
                g_string_printf (sInfo, "%s (%.2f%%) \n %s %s \n %s", D_("PowerManager.\nBattery charge seems to be low"), myData.battery_charge, D_("Estimated time with Charge:"), hms, D_("Please put your Laptop on charge."));
204
 
                _cd_powermanager_dialog (sInfo);
 
197
                if (myConfig.iNotificationType != 1)
 
198
                {
 
199
                        g_string_printf (sInfo, "%s (%.2f%%) \n %s %s \n %s", D_("PowerManager.\nBattery charge seems to be low"), myData.battery_charge, D_("Estimated time with charge:"), hms, D_("Please put your laptop on charge."));
 
200
                        _cd_powermanager_dialog (sInfo->str, myConfig.iNotificationDuration);
 
201
                }
 
202
                if (myConfig.iNotificationType != 2)
 
203
                {
 
204
                        CD_APPLET_DEMANDS_ATTENTION (myConfig.cNotificationAnimation, myConfig.iNotificationDuration);
 
205
                }
 
206
                if (myConfig.cSoundPath[alert] != NULL)
 
207
                        cairo_dock_play_sound (myConfig.cSoundPath[alert]);
205
208
        }
206
 
        
207
209
        else if (alert == POWER_MANAGER_CHARGE_FULL && myConfig.highBatteryWitness)
208
210
        {
209
 
                g_string_printf (sInfo, "%s (%.2f%%) \n %s %s ", D_("PowerManager.\nYour battery is now Charged"), myData.battery_charge, D_("Estimated time with Charge:"), hms);
210
 
                _cd_powermanager_dialog (sInfo);
211
 
                if (myConfig.cSoundPath[POWER_MANAGER_CHARGE_FULL] != NULL)
212
 
                        cairo_dock_play_sound (myConfig.cSoundPath[POWER_MANAGER_CHARGE_FULL]);
213
 
        }
214
 
        if (myConfig.batteryWitness) 
215
 
        {
216
 
                CD_APPLET_ANIMATE_MY_ICON ("rotate", 3);
 
211
                if (myConfig.iNotificationType != 1)
 
212
                {
 
213
                        g_string_printf (sInfo, "%s (%.2f%%) \n %s %s ", D_("PowerManager.\nYour battery is now charged"), myData.battery_charge, D_("Estimated time with charge:"), hms);
 
214
                        _cd_powermanager_dialog (sInfo->str, myConfig.iNotificationDuration);
 
215
                }
 
216
                if (myConfig.iNotificationType != 2)
 
217
                {
 
218
                        CD_APPLET_DEMANDS_ATTENTION (myConfig.cNotificationAnimation, myConfig.iNotificationDuration);
 
219
                }
 
220
                if (myConfig.cSoundPath[alert] != NULL)
 
221
                        cairo_dock_play_sound (myConfig.cSoundPath[alert]);
217
222
        }
218
223
        
219
224
        g_free (hms);