17
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
/*********************************************************************************
22
This file is a part of the cairo-dock program,
23
released under the terms of the GNU General Public License.
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
27
*********************************************************************************/
28
20
#include <string.h>
29
21
#include <mntent.h>
30
22
#include <sys/types.h>
71
63
if (pIcon->iType != 6)
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)
76
68
if (pElement != NULL)
75
//g_print ("+ %s\n", pIcon->cCommand);
83
76
pDiskUsage = g_new0 (CDDiskUsage, 1);
84
77
myData.pDiskUsageList = g_list_append (myData.pDiskUsageList, pDiskUsage);
87
cd_shortcuts_get_fs_stat (pIcon->acCommand, pDiskUsage);
80
cd_shortcuts_get_fs_stat (pIcon->cCommand, pDiskUsage);
94
87
g_return_val_if_fail (myData.pDiskUsageList != NULL, TRUE);
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;
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);
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);
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);
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);
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);
140
134
cairo_dock_set_icon_surface_with_bar (pIconContext, pSurface, fValue, pIcon, pContainer);
169
165
if (myData.pDiskTask == NULL)
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,
176
172
cairo_dock_launch_task (myData.pDiskTask);