~ubuntu-branches/ubuntu/oneiric/cairo-dock-plug-ins/oneiric-updates

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe), Matthieu Baerts (matttbe), Iain Lane
  • Date: 2011-10-09 00:19:16 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20111009001916-9czstskx2t6l0b3x
Tags: 2.4.0~2-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New upstream bug fix release. (LP: #859984)
* Upstream (short) ChangeLog (2.4.0~0beta2 -> 2.4.0~1):
 - Powermanager: correctly release the reference on the device object
 - logout: now works if there is no session-manager
 - Status-Notifier: fixed a small bug
    (wrong callback in cairo_dock_stop_watching_dbus_name_owner)
 - Folders: fixed the positionning of the new icon
    and the dialog when dropping a folder inside the dock
    and fixed the icon-rendering
 - Dustbin: use the default theme if no icon is found
 - Impulse: the default context seems to be ok and not an error
 - Status-Notifier: On Ubuntu Oneiric (with indicator-0.4)
    the ApplicationAdded signal has changed and has a new parameter
 - Disable MeMenu on Oneiric (no longer available with indicator-0.4)
 - CMakeLists.txt: Improved output messages
 - Slide view: fixed a small offset in vertical view
 - musicPlayer:
  + split MPRIS 1.0 and 2.0 to help debugging and finding the right
     name of the bug.
  + 'rhythmbox-client' tool is no longer available: used MPRIS
  + Disable Amazon service (it no longer work)
  + Cover: fixed corrupted icons: some players (e.g. the latest version
     of RB) copy covers on their cache forlder but it takes a few time.
  + Fixed the update the icon and its name if the player is stopped.
  + Prevent a crash if the name given by MPRIS is NULL
 - Powermanager: try to prevent to have a few dialogues at the same time
 - PowerManager and AlsaMixer: hidden gnome2 or 3 apps if not available
 - Messaging-Menu: Updated for Natty and Oneiric
    (dbus-menu gives us GVariant instead of GValue objects)
 - Alsamixer: fixed a small bug on reload
 - Dbus: Bash interface: Fixed a typo with emblem positions
 - Sys-monitor: fixed a bug which prevented from getting
    the CPU temperature in some cases
 - Compiz (0.9): type filter: replaced type=utility by type=Utility
 - Updated the version of all applets that have gauges
   in order to use the right directory
 - Wifi: Fixed the status if we are not connected
 - Dbus: removed a conflict with the Help applet
 - Messaging-Menu: updated applet-menu.c => Memory leaks on pixbufs
 - Dbus: Fixed a crash when changing dock theme if a 'third-party' applet
    is running
 - Netspeed: in /proc/net/dev, there are 8 values to drop after the card id
    except if there is whitespaces just after this ':' character
    and fixed order and value for ON_ICON display
 - dock-rendering/toto: removed a useless file
 - Clipper: fixed the loading of the remembered items
    (they had the wrong type) and fixed a bug if we reduce the list of items
 - Folders, dustbin, Network-Monitor: tried to not use cast if it's possible
 - Code cleaned and re-organised a few functions
   (e.g. emblem references has been renamed)
 - Removed useless files: powermanager-dbus*
 - Updating translations
 - Fixed a few warnings at the compilation
 - Removed a few useless output messages
 - Fixed these LP bugs:
  + Empty trash from the trashcan does not delete files
     from usb harddisks: LP: #658681
  + Switcher applet doesn't respect desktop numbers LP: #626782
* Upstream (short) ChangeLog (2.4.0~1 -> 2.4.0~2):
 - Messaging-Menu: fixed a wrong g_object_unref (double free)
    and a small memory leak
 - Folders: fixed a tiny warning at the compilation (32bits)
 - switcher: removed an unnecessary config parameter
 - Folders: file size: used English instead of French translation.
 - Indicator applet: Forced a cast to remove an annoying warning
    due to clumsy dbusmenu_gtkmenu_new() declaration
 - Fixed the detection of the screensaver
 - Fixed tiny warnings at the compilation (with CAIRO_CONTAINER)
* debian/control:
 - Updated the version of cairo-dock-[core;data;dev].
 - Added gvfs as 'Suggests' for cairo-dock-plug-ins-integration
    (Used for managing files)
 - Removed 'libthunar-vfs-1-dev' (libthunar-vfs is no longer installed
    by default since XFCE 4.8 and it is replaced by gvfs)
 - Removed 'indicator-me' (no longer available
    and the installation of Cairo-Dock produces an error)
 - Moved 'indicator-messages' to 'Recommends'
* debian/rules:
 - Updated the name of CMake extras flags
* debian/cairo-dock-plug-ins-data.lintian-overrides:
 - Deleted (now useless)
* debian/cairo-dock-plug-ins.lintian-overrides:
 - Cairo-Dock Plug-Ins are not linked to gldi
 - shlib-without-versioned-soname: forwarded to upstream.
* debian/cairo-dock-plug-ins-integration.lintian-overrides:
 - Cairo-Dock Plug-Ins are not linked to gldi
 - ldconfig and shlibs are not needed
* debian/cairo-dock-plug-ins.install:
 - Fixed lintian errors: package-installs-python-bytecode
* debian/control: Fixed lintian warnings:
 - python-script-but-no-python-dep
 - description-synopsis-starts-with-article
* debian/changelog:
 - Fixed lintian warning: old-fsf-address-in-copyright-file
* debian/patches/01-switcher-force-compact-view.patch: 
 - Forced the compact view because the other doesn't work

[ Iain Lane ]
* Fix Mono/CLI build to be ~policy compliant and use correct compiler

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
void update_icon (void)
33
33
{
34
34
        gboolean bNeedRedraw = FALSE;
35
 
        cd_message ("%s (on battery: %d -> %d; time:%.1f -> %.1f ; charge:%.1f -> %.1f)", __func__, myData.bPrevOnBattery, myData.bOnBattery, (double)myData.iPrevTime, (double)myData.iTime, (double)myData.iPrevPercentage, (double)myData.iPercentage);
 
35
        cd_debug ("%s (on battery: %d -> %d; time:%.1f -> %.1f ; charge:%.1f -> %.1f)", __func__, myData.bPrevOnBattery, myData.bOnBattery, (double)myData.iPrevTime, (double)myData.iTime, (double)myData.iPrevPercentage, (double)myData.iPercentage);
36
36
        
 
37
        // no information available, draw a default icon.
37
38
        if (myData.cBatteryStateFilePath == NULL && myData.pUPowerClient == NULL)
38
39
        {
39
 
                CD_APPLET_SET_LOCAL_IMAGE_ON_MY_ICON ("sector.svg");
 
40
                CD_APPLET_SET_IMAGE_ON_MY_ICON (MY_APPLET_SHARE_DATA_DIR"/sector.svg");
40
41
                CD_APPLET_REDRAW_MY_ICON;
41
42
                return;
42
43
        }
 
44
        
 
45
        // hide the icon when not on battery
 
46
        if (myConfig.bHideNotOnBattery && ! myData.bOnBattery && myDock)
 
47
        {
 
48
                if (! myData.bIsHidden)
 
49
                { // we remove the icon
 
50
                        cairo_dock_detach_icon_from_dock (myIcon, myDock, myIconsParam.iSeparateIcons);
 
51
                        myData.bIsHidden = TRUE;
 
52
                        cairo_dock_update_dock_size (myDock);
 
53
                        cairo_dock_redraw_container (CAIRO_CONTAINER (myDock)); // dock refresh forced
 
54
                }
 
55
                return; // no need any redraw if the icon is hidden, and can't display the dialog properly without the icon.
 
56
        }
 
57
        else if (myData.bIsHidden && myData.bOnBattery && myDock) // if the icon is hidden but we are now on battery, we (re-)insert the icon.
 
58
        {
 
59
                cd_debug ("Re-insert the icon");
 
60
                cairo_dock_insert_icon_in_dock (myIcon, myDock, CAIRO_DOCK_UPDATE_DOCK_SIZE, CAIRO_DOCK_ANIMATE_ICON);
 
61
                cairo_dock_redraw_container (CAIRO_CONTAINER (myDock)); // dock refresh forced
 
62
                myData.bIsHidden = FALSE;
 
63
        }
 
64
 
43
65
        // on prend en compte la nouvelle charge.
44
66
        if (myData.bPrevOnBattery != myData.bOnBattery || myData.iPrevPercentage != myData.iPercentage || myData.iTime != myData.iPrevTime)
45
67
        {
46
 
                if (myData.bPrevOnBattery != myData.bOnBattery)
47
 
                {
48
 
                        myData.bPrevOnBattery = myData.bOnBattery;
49
 
                        myData.bAlerted = FALSE;  // On a change de statut, donc on reinitialise les alertes
50
 
                        myData.bCritical = FALSE;
51
 
                }
52
 
                
53
68
                // on redessine l'icone.
54
69
                if (myConfig.iDisplayType == CD_POWERMANAGER_GAUGE || myConfig.iDisplayType == CD_POWERMANAGER_GRAPH)
55
70
                {
56
 
                        double fPercent = (double) myData.iPercentage / 100.;
 
71
                        double fPercent;
 
72
                        if (myConfig.iDisplayType == CD_POWERMANAGER_GAUGE && ! myData.bBatteryPresent)
 
73
                                fPercent = CAIRO_DATA_RENDERER_UNDEF_VALUE;
 
74
                        else
 
75
                                fPercent = (double) myData.iPercentage / 100.;
57
76
                        CD_APPLET_RENDER_NEW_DATA_ON_MY_ICON (&fPercent);
58
77
                        bNeedRedraw = FALSE;
59
78
                }
62
81
                        cd_powermanager_draw_icon_with_effect (myData.bOnBattery);
63
82
                        bNeedRedraw = FALSE;
64
83
                }
 
84
                if (! myData.bOnBattery)
 
85
                {
 
86
                        CD_APPLET_DRAW_EMBLEM_ON_MY_ICON (myData.pEmblem);
 
87
                }  // else emblem is implicitely erased.
65
88
                
66
89
                // on declenche les alarmes.
67
90
                if (myData.bOnBattery)
68
91
                {
69
 
                        // Alert when battery charge is under a configured value in %
70
 
                        if (myData.iPercentage <= myConfig.lowBatteryValue && ! myData.bAlerted)
 
92
                        // Alert when battery charge goes under a configured value in %
 
93
                        if (myData.iPrevPercentage > myConfig.lowBatteryValue && myData.iPercentage <= myConfig.lowBatteryValue)
71
94
                        {
72
95
                                cd_powermanager_alert(POWER_MANAGER_CHARGE_LOW);
73
96
                                if (myConfig.cSoundPath[POWER_MANAGER_CHARGE_LOW] != NULL)
74
97
                                        cairo_dock_play_sound (myConfig.cSoundPath[POWER_MANAGER_CHARGE_LOW]);
75
98
                        }
76
99
                        // Alert when battery charge is under 4%
77
 
                        if (myData.iPercentage <= 4 && ! myData.bCritical)
 
100
                        if (myData.iPrevPercentage > 4 && myData.iPercentage <= 4)
78
101
                        {
79
 
                                myData.bCritical = TRUE;
80
102
                                cd_powermanager_alert (POWER_MANAGER_CHARGE_CRITICAL);
81
103
                                if (myConfig.cSoundPath[POWER_MANAGER_CHARGE_CRITICAL] != NULL)
82
104
                                        cairo_dock_play_sound (myConfig.cSoundPath[POWER_MANAGER_CHARGE_CRITICAL]);
83
105
                        }
84
 
                        // emblem is implicitely erased.
85
106
                }
86
107
                else
87
108
                {
88
109
                        // Alert when battery is charged
89
 
                        if(myData.iPercentage == 100 && ! myData.bAlerted)
 
110
                        if(myData.iPrevPercentage < 100 && myData.iPercentage == 100)
90
111
                                cd_powermanager_alert (POWER_MANAGER_CHARGE_FULL);
91
 
                                
92
 
                        CD_APPLET_DRAW_EMBLEM_ON_MY_ICON (myData.pEmblem);
93
112
                }
94
113
                
 
114
                // update the icon's label.
95
115
                if (myConfig.defaultTitle == NULL || *myConfig.defaultTitle == '\0')
96
116
                {
97
117
                        if (! myData.bOnBattery && myData.iPercentage > 99.9)
246
266
                        g_string_printf (sInfo, "%s (%d%%)", D_("PowerManager.\nYour battery is now charged"), (int)myData.iPercentage);
247
267
                        _cd_powermanager_dialog (sInfo->str, myConfig.iNotificationDuration);
248
268
                }
249
 
                if (myConfig.iNotificationType != 2)
 
269
                if (! myData.bIsHidden && myConfig.iNotificationType != 2)
250
270
                {
251
271
                        CD_APPLET_DEMANDS_ATTENTION (myConfig.cNotificationAnimation, myConfig.iNotificationDuration);
252
272
                }
256
276
        
257
277
        g_free (hms);
258
278
        g_string_free (sInfo, TRUE);
259
 
        myData.bAlerted = TRUE;
260
279
        return FALSE;
261
280
}
262
281
 
326
345
                        int time = myData.iTime;
327
346
                        int hours = time / 3600;
328
347
                        int minutes = (time % 3600) / 60;
329
 
                        g_print ("time: %d -> %d;%d\n", time, hours, minutes);
 
348
                        cd_debug ("time: %d -> %d;%d", time, hours, minutes);
330
349
                        if (hours != 0)
331
350
                                snprintf (cFormatBuffer, iBufferLength, "%dh%02d", hours, abs (minutes));
332
351
                        else