28
28
void cd_stack_check_local (CairoDockModuleInstance *myApplet, GKeyFile *pKeyFile) {
30
if (! g_file_test (myConfig.cStackDir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE))
32
g_free (myConfig.cStackDir);
33
myConfig.cStackDir = NULL;
30
35
if (myConfig.cStackDir == NULL) // applet nouvellement instanciee.
32
37
GString *sDirPath = g_string_new ("");
40
45
g_string_printf (sDirPath, "%s/stack-%d", g_cCairoDockDataDir, i);
42
g_print ("stack : test de %s\n", sDirPath->str);
47
cd_debug ("stack : test de %s\n", sDirPath->str);
43
48
} while (g_file_test (sDirPath->str, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE));
45
50
myConfig.cStackDir = sDirPath->str;
72
77
g_remove (cFilePath);
73
78
g_free (cFilePath);
77
cairo_dock_detach_icon_from_dock (pIcon, myIcon->pSubDock, FALSE);
78
cairo_dock_update_dock_size (myIcon->pSubDock);
82
myDesklet->icons = g_list_remove (myDesklet->icons, pIcon);
83
gtk_widget_queue_draw (myDesklet->container.pWidget);
85
cairo_dock_free_icon (pIcon);
90
Icon *cd_stack_create_item (CairoDockModuleInstance *myApplet, const gchar *cStackDirectory, const gchar *cContent)
80
CD_APPLET_REMOVE_ICON_FROM_MY_ICONS_LIST (pIcon); // detruit l'icone.
84
static void _set_icon_order (Icon *pIcon, CairoDockModuleInstance *myApplet, GCompareFunc comp)
86
GList *pIconsList = CD_APPLET_MY_ICONS_LIST;
89
for (ic = pIconsList; ic != NULL; ic = ic->next)
92
if (comp (icon, pIcon) < 0)
96
Icon *next_icon = ic->next->data;
97
pIcon->fOrder = (icon->fOrder + next_icon->fOrder) / 2;
101
pIcon->fOrder = icon->fOrder + 1;
106
static Icon *_cd_stack_create_new_item (CairoDockModuleInstance *myApplet, const gchar *cContent)
93
109
double fOrder = 0;
112
//\_______________________ On lui trouve un petit nom.
96
113
if (cairo_dock_string_is_adress (cContent) || *cContent == '/')
98
115
if (strncmp (cContent, "http://", 7) == 0 || strncmp (cContent, "www", 3) == 0 || strncmp (cContent, "https://", 8) == 0)
100
117
gchar *buf = g_strdup (cContent);
101
118
gchar *str = strchr (buf, '?');
109
123
if (str[strlen(str)-1] == '/')
110
124
str[strlen(str)-1] = '\0';
111
125
str = strrchr (buf, '/');
133
147
g_return_val_if_fail (cName != NULL, NULL);
135
GList *pIconsList = (myDock ? (myIcon->pSubDock != NULL ? myIcon->pSubDock->icons : NULL) : myDesklet->icons);
138
for (ic = pIconsList; ic != NULL; ic = ic->next)
141
fOrder = MAX (fOrder, icon->fOrder);
149
//\_______________________ On ecrit toutes les infos dans un fichier de conf.
150
GList *pIconsList = CD_APPLET_MY_ICONS_LIST;
151
Icon *icon = cairo_dock_get_last_icon (pIconsList);
153
fOrder = icon->fOrder + 1;
144
155
iDate = time (NULL);
171
g_string_printf (sConfFilePath, "%s/%s", cStackDirectory, cName);
182
g_string_printf (sConfFilePath, "%s/%s", myConfig.cStackDir, cName);
173
g_string_printf (sConfFilePath, "%s/%s.%d", cStackDirectory, cName, i);
184
g_string_printf (sConfFilePath, "%s/%s.%d", myConfig.cStackDir, cName, i);
175
186
} while (g_file_test (sConfFilePath->str, G_FILE_TEST_EXISTS));
177
188
cairo_dock_write_keys_to_file (pKeyFile, sConfFilePath->str);
190
//\_______________________ On cree une icone a partir du fichier de cle precedemment remplit.
179
191
Icon *pIcon = cd_stack_build_one_icon (myApplet, pKeyFile);
180
192
if (pIcon != NULL)
181
194
pIcon->cDesktopFileName = g_path_get_basename (sConfFilePath->str);
196
if (myConfig.iSortType == CD_STACK_SORT_BY_NAME)
198
_set_icon_order (pIcon, myApplet, (GCompareFunc) cairo_dock_compare_icons_name);
200
else if (myConfig.iSortType == CD_STACK_SORT_BY_TYPE)
202
_set_icon_order (pIcon, myApplet, (GCompareFunc) cairo_dock_compare_icons_extension);
183
206
g_key_file_free (pKeyFile);
184
207
g_string_free (sConfFilePath, TRUE);
188
211
void cd_stack_create_and_load_item (CairoDockModuleInstance *myApplet, const gchar *cContent)
190
213
//\_______________________ On cree l'item.
191
Icon *pIcon = cd_stack_create_item (myApplet, myConfig.cStackDir, cContent);
214
Icon *pIcon = _cd_stack_create_new_item (myApplet, cContent);
192
215
if (pIcon == NULL) // peut arriver si l'icone est filtree.
195
218
//\_______________________ On le charge et on le rajoute au container.
198
if (myIcon->pSubDock == NULL)
200
GList *pStacksIconList = NULL;
201
pStacksIconList = g_list_prepend (pStacksIconList, pIcon);
202
CD_APPLET_CREATE_MY_SUBDOCK (pStacksIconList, myConfig.cRenderer);
206
cairo_dock_load_one_icon_from_scratch (pIcon, CAIRO_CONTAINER (myIcon->pSubDock));
207
GCompareFunc pCompareFunc = NULL;
208
switch (myConfig.iSortType)
210
case CD_STACK_SORT_BY_DATE :
211
case CD_STACK_SORT_MANUALLY :
212
pCompareFunc = (GCompareFunc) cairo_dock_compare_icons_order;
214
case CD_STACK_SORT_BY_NAME :
215
pCompareFunc = (GCompareFunc) cairo_dock_compare_icons_name;
217
case CD_STACK_SORT_BY_TYPE :
219
pCompareFunc = (GCompareFunc) cairo_dock_compare_icons_extension;
222
cairo_dock_insert_icon_in_dock_full (pIcon, myIcon->pSubDock, CAIRO_DOCK_UPDATE_DOCK_SIZE, CAIRO_DOCK_ANIMATE_ICON, ! CAIRO_DOCK_INSERT_SEPARATOR, pCompareFunc);
227
GList *pStacksIconList = myDesklet->icons;
228
pStacksIconList = cd_stack_insert_icon_in_list (myApplet, pStacksIconList, pIcon);
230
//cairo_dock_load_one_icon_from_scratch (pIcon, CAIRO_CONTAINER (myDesklet));
232
myDesklet->icons = pStacksIconList;
234
const gchar *cDeskletRendererName = NULL;
235
switch (myConfig.iDeskletRendererType)
237
case CD_DESKLET_SLIDE :
239
cDeskletRendererName = "Slide";
242
case CD_DESKLET_TREE :
243
cDeskletRendererName = "Tree";
246
CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA (cDeskletRendererName, NULL);
247
CAIRO_DOCK_REDRAW_MY_CONTAINER;
219
CD_APPLET_ADD_ICON_IN_MY_ICONS_LIST (pIcon);
251
222
void cd_stack_set_item_name (const gchar *cDesktopFilePath, const gchar *cName)