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

« back to all changes in this revision

Viewing changes to shortcuts/src/applet-disk-usage.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:
17
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
*/
19
19
 
20
 
/*********************************************************************************
21
 
 
22
 
This file is a part of the cairo-dock program, 
23
 
released under the terms of the GNU General Public License.
24
 
 
25
 
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
26
 
 
27
 
*********************************************************************************/
28
20
#include <string.h>
29
21
#include <mntent.h>
30
22
#include <sys/types.h>
70
62
                pIcon = ic->data;
71
63
                if (pIcon->iType != 6)
72
64
                        break;
73
 
                //g_print ("%s () : %s\n", __func__, pIcon->acCommand);
74
 
                if (pIcon->acCommand != NULL)
 
65
                //g_print ("%s () : %s\n", __func__, pIcon->cCommand);
 
66
                if (pIcon->cCommand != NULL)
75
67
                {
76
68
                        if (pElement != NULL)
77
69
                        {
80
72
                        }
81
73
                        else
82
74
                        {
 
75
                                //g_print ("+ %s\n", pIcon->cCommand);
83
76
                                pDiskUsage = g_new0 (CDDiskUsage, 1);
84
77
                                myData.pDiskUsageList = g_list_append (myData.pDiskUsageList, pDiskUsage);
85
78
                        }
86
79
                        
87
 
                        cd_shortcuts_get_fs_stat (pIcon->acCommand, pDiskUsage);
 
80
                        cd_shortcuts_get_fs_stat (pIcon->cCommand, pDiskUsage);
88
81
                }
89
82
        }
90
83
}
94
87
        g_return_val_if_fail (myData.pDiskUsageList != NULL, TRUE);
95
88
        
96
89
        CairoContainer *pContainer = CD_APPLET_MY_ICONS_LIST_CONTAINER;
 
90
        cairo_t *ctx = (0 ? myDrawContext : cairo_dock_create_context_from_container (pContainer));
97
91
        GList *pElement = myData.pDiskUsageList;
98
92
        CDDiskUsage *pDiskUsage;
99
93
        Icon *pIcon;
105
99
                pIcon = ic->data;
106
100
                if (pIcon->iType != 6)
107
101
                        break;
108
 
                if (pIcon->acCommand != NULL && pElement != NULL)
 
102
                if (pIcon->cCommand != NULL && pElement != NULL)
109
103
                {
110
104
                        pDiskUsage = pElement->data;
111
105
                        if (pDiskUsage->iPrevAvail != pDiskUsage->iAvail)
114
108
                                {
115
109
                                        case CD_SHOW_FREE_SPACE :
116
110
                                                fValue = (double) pDiskUsage->iAvail / pDiskUsage->iTotal;
117
 
                                                cairo_dock_set_size_as_quick_info (myDrawContext, pIcon, pContainer, pDiskUsage->iAvail);
 
111
                                                cairo_dock_set_size_as_quick_info (ctx, pIcon, pContainer, pDiskUsage->iAvail);
118
112
                                        break ;
119
113
                                        case CD_SHOW_USED_SPACE :
120
114
                                                fValue = (double) - pDiskUsage->iUsed / pDiskUsage->iTotal;  // <0 => du vert au rouge.
121
 
                                                cairo_dock_set_size_as_quick_info (myDrawContext, pIcon, pContainer, pDiskUsage->iUsed);
 
115
                                                cairo_dock_set_size_as_quick_info (ctx, pIcon, pContainer, pDiskUsage->iUsed);
122
116
                                        break ;
123
117
                                        case CD_SHOW_FREE_SPACE_PERCENT :
124
118
                                                fValue = (double) pDiskUsage->iAvail / pDiskUsage->iTotal;
125
 
                                                cairo_dock_set_quick_info_full (myDrawContext, pIcon, pContainer, "%.1f%%", 100.*fValue);
 
119
                                                cairo_dock_set_quick_info_full (ctx, pIcon, pContainer, "%.1f%%", 100.*fValue);
126
120
                                        break ;
127
121
                                        case CD_SHOW_USED_SPACE_PERCENT :
128
122
                                                fValue = (double) - pDiskUsage->iUsed / pDiskUsage->iTotal;  // <0 => du vert au rouge.
129
 
                                                cairo_dock_set_quick_info_full (myDrawContext, pIcon, pContainer, "%.1f%%", -100.*fValue);
 
123
                                                cairo_dock_set_quick_info_full (ctx, pIcon, pContainer, "%.1f%%", -100.*fValue);
130
124
                                        break ;
131
125
                                }
132
126
                                
134
128
                                {
135
129
                                        int iWidth, iHeight;
136
130
                                        cairo_dock_get_icon_extent (pIcon, pContainer, &iWidth, &iHeight);
137
 
                                        cairo_surface_t *pSurface = cairo_dock_create_surface_for_icon (pIcon->acFileName, myDrawContext, iWidth, iHeight);;
 
131
                                        cairo_surface_t *pSurface = cairo_dock_create_surface_for_icon (pIcon->cFileName, ctx, iWidth, iHeight);
138
132
                                        cairo_t *pIconContext = cairo_create (pIcon->pIconBuffer);
139
133
                                        
140
134
                                        cairo_dock_set_icon_surface_with_bar (pIconContext, pSurface, fValue, pIcon, pContainer);
149
143
                        pElement = pElement->next;
150
144
                }
151
145
        }
 
146
        if (ctx != myDrawContext)
 
147
                cairo_destroy (ctx);
152
148
        
153
149
        return TRUE;
154
150
}
169
165
                if (myData.pDiskTask == NULL)
170
166
                {
171
167
                        myData.pDiskTask = cairo_dock_new_task (myConfig.iCheckInterval,
172
 
                                (CairoDockGetDataAsyncFunc) cd_shortcuts_get_disk_usage, 
173
 
                                (CairoDockUpdateSyncFunc) cd_shortcuts_update_disk_usage, 
 
168
                                (CairoDockGetDataAsyncFunc) cd_shortcuts_get_disk_usage,
 
169
                                (CairoDockUpdateSyncFunc) cd_shortcuts_update_disk_usage,
174
170
                                myApplet);
175
171
                }
176
172
                cairo_dock_launch_task (myData.pDiskTask);