~cairo-dock-team/ubuntu/precise/cairo-dock-plug-ins/984054

« back to all changes in this revision

Viewing changes to stack/src/applet-stack.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-10 00:05:57 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810000557-pfxoz5w7hbyclcqh
Tags: 2.2.0~0beta4-0ubuntu1
* New Upstream Version (LP: #614625)
* Fixed a few bugs on LP:
 - LP: #483963: Dustbin applet does not display trashes on all volumes
 - LP: #485159: Some apps have problem with Systray
 - LP: #500677: ~/.xsession-errors is too much used by CD
 - LP: #500979: Shortcuts: the order gets messed up
 - LP: #521531: Mail: crashes on Maildir
 - LP: #519915: GTG: create a new applet to control GTG
 - LP: #526138: GMenu doesn't handle desktop file exec strings properly
 - LP: #531317: CMake: Added an error if the prefix of 'cairo-dock-plugins'
                 is not the same 'cairo-dock-core'
 - LP: #531319: CMake: check the version of 'cairo-dock' when building
                 'cairo-dock-plugins'
 - LP: #537115: Click at the position where icon lavel was, the icon
                 and dock still receive the event
 - LP: #537943: Terminal applet shortkey behaviour
 - LP: #538637: Trash applet doesn't create .trashinfo files on XFCE
 - More details on the 'ChangeLog' file
* 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
 - Added the exact realease for 'cairo-dock-dev' in order to prevent any
    build error if this package is not already available (thx to didrocks)
* debian/cairo-dock-plug-ins*.install:
 - All sonames are now installed into lib32 or lib64 (lib*)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
void cd_stack_check_local (CairoDockModuleInstance *myApplet, GKeyFile *pKeyFile) {
29
29
        
 
30
        if (! g_file_test (myConfig.cStackDir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE))
 
31
        {
 
32
                g_free (myConfig.cStackDir);
 
33
                myConfig.cStackDir = NULL;
 
34
        }
30
35
        if (myConfig.cStackDir == NULL)  // applet nouvellement instanciee.
31
36
        {
32
37
                GString *sDirPath = g_string_new ("");
39
44
                        else
40
45
                                g_string_printf (sDirPath, "%s/stack-%d", g_cCairoDockDataDir, i);
41
46
                        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));
44
49
                
45
50
                myConfig.cStackDir = sDirPath->str;
72
77
        g_remove (cFilePath);
73
78
        g_free (cFilePath);
74
79
        
75
 
        if (myDock)
76
 
        {
77
 
                cairo_dock_detach_icon_from_dock (pIcon, myIcon->pSubDock, FALSE);
78
 
                cairo_dock_update_dock_size (myIcon->pSubDock);
79
 
        }
80
 
        else
81
 
        {
82
 
                myDesklet->icons = g_list_remove (myDesklet->icons, pIcon);
83
 
                gtk_widget_queue_draw (myDesklet->container.pWidget);
84
 
        }
85
 
        cairo_dock_free_icon (pIcon);
86
 
}
87
 
 
88
 
 
89
 
 
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.
 
81
}
 
82
 
 
83
 
 
84
static void _set_icon_order (Icon *pIcon, CairoDockModuleInstance *myApplet, GCompareFunc comp)
 
85
{
 
86
        GList *pIconsList = CD_APPLET_MY_ICONS_LIST;
 
87
        Icon *icon;
 
88
        GList *ic;
 
89
        for (ic = pIconsList; ic != NULL; ic = ic->next)
 
90
        {
 
91
                icon = ic->data;
 
92
                if (comp (icon, pIcon) < 0)
 
93
                {
 
94
                        if (ic->next != NULL)
 
95
                        {
 
96
                                Icon *next_icon = ic->next->data;
 
97
                                pIcon->fOrder = (icon->fOrder + next_icon->fOrder) / 2;
 
98
                        }
 
99
                        else
 
100
                        {
 
101
                                pIcon->fOrder = icon->fOrder + 1;
 
102
                        }
 
103
                }
 
104
        }
 
105
}
 
106
static Icon *_cd_stack_create_new_item (CairoDockModuleInstance *myApplet, const gchar *cContent)
91
107
{
92
108
        gchar *cName;
93
109
        double fOrder = 0;
94
110
        int iDate;
95
111
        
 
112
        //\_______________________ On lui trouve un petit nom.
96
113
        if (cairo_dock_string_is_adress (cContent) || *cContent == '/')
97
114
        {
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, '?');
102
119
                        if (str != NULL)
103
 
                        {
104
120
                                *str = '\0';
105
 
                                str ++;
106
 
                        }
107
 
                        else
108
 
                                str = buf;
 
121
                        
 
122
                        str = buf;
109
123
                        if (str[strlen(str)-1] == '/')
110
124
                                str[strlen(str)-1] = '\0';
111
125
                        str = strrchr (buf, '/');
132
146
        }
133
147
        g_return_val_if_fail (cName != NULL, NULL);
134
148
        
135
 
        GList *pIconsList = (myDock ? (myIcon->pSubDock != NULL ? myIcon->pSubDock->icons : NULL) : myDesklet->icons);
136
 
        GList *ic;
137
 
        Icon *icon;
138
 
        for (ic = pIconsList; ic != NULL; ic = ic->next)
139
 
        {
140
 
                icon = ic->data;
141
 
                fOrder = MAX (fOrder, icon->fOrder);
142
 
        }
 
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);
 
152
        if (icon)
 
153
                fOrder = icon->fOrder + 1;
143
154
        
144
155
        iDate = time (NULL);
145
156
        
168
179
        do
169
180
        {
170
181
                if (i == 0)
171
 
                        g_string_printf (sConfFilePath, "%s/%s", cStackDirectory, cName);
 
182
                        g_string_printf (sConfFilePath, "%s/%s", myConfig.cStackDir, cName);
172
183
                else
173
 
                        g_string_printf (sConfFilePath, "%s/%s.%d", cStackDirectory, cName, i);
 
184
                        g_string_printf (sConfFilePath, "%s/%s.%d", myConfig.cStackDir, cName, i);
174
185
                i ++;
175
186
        } while (g_file_test (sConfFilePath->str, G_FILE_TEST_EXISTS));
176
187
        
177
188
        cairo_dock_write_keys_to_file (pKeyFile, sConfFilePath->str);
178
189
        
 
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)
 
193
        {
181
194
                pIcon->cDesktopFileName = g_path_get_basename (sConfFilePath->str);
 
195
                
 
196
                if (myConfig.iSortType == CD_STACK_SORT_BY_NAME)
 
197
                {
 
198
                        _set_icon_order (pIcon, myApplet, (GCompareFunc) cairo_dock_compare_icons_name);
 
199
                }
 
200
                else if (myConfig.iSortType == CD_STACK_SORT_BY_TYPE)
 
201
                {
 
202
                        _set_icon_order (pIcon, myApplet, (GCompareFunc) cairo_dock_compare_icons_extension);
 
203
                }
 
204
        }
182
205
        
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)
189
212
{
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.
193
216
                return ;
194
217
        
195
218
        //\_______________________ On le charge et on le rajoute au container.
196
 
        if (myDock)
197
 
        {
198
 
                if (myIcon->pSubDock == NULL)
199
 
                {
200
 
                        GList *pStacksIconList = NULL;
201
 
                        pStacksIconList = g_list_prepend (pStacksIconList, pIcon);
202
 
                        CD_APPLET_CREATE_MY_SUBDOCK (pStacksIconList, myConfig.cRenderer);
203
 
                }
204
 
                else
205
 
                {
206
 
                        cairo_dock_load_one_icon_from_scratch (pIcon, CAIRO_CONTAINER (myIcon->pSubDock));
207
 
                        GCompareFunc pCompareFunc = NULL;
208
 
                        switch (myConfig.iSortType)
209
 
                        {
210
 
                                case CD_STACK_SORT_BY_DATE :
211
 
                                case CD_STACK_SORT_MANUALLY :
212
 
                                        pCompareFunc = (GCompareFunc) cairo_dock_compare_icons_order;
213
 
                                break;
214
 
                                case CD_STACK_SORT_BY_NAME :
215
 
                                        pCompareFunc = (GCompareFunc) cairo_dock_compare_icons_name;
216
 
                                break;
217
 
                                case CD_STACK_SORT_BY_TYPE :
218
 
                                default :
219
 
                                        pCompareFunc = (GCompareFunc) cairo_dock_compare_icons_extension;
220
 
                                break;
221
 
                        }
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);
223
 
                }
224
 
        }
225
 
        else
226
 
        {
227
 
                GList *pStacksIconList = myDesklet->icons;
228
 
                pStacksIconList = cd_stack_insert_icon_in_list (myApplet, pStacksIconList, pIcon);
229
 
                
230
 
                //cairo_dock_load_one_icon_from_scratch (pIcon, CAIRO_CONTAINER (myDesklet));
231
 
                
232
 
                myDesklet->icons = pStacksIconList;
233
 
                
234
 
                const gchar *cDeskletRendererName = NULL;
235
 
                switch (myConfig.iDeskletRendererType)
236
 
                {
237
 
                        case CD_DESKLET_SLIDE :
238
 
                        default :
239
 
                                cDeskletRendererName = "Slide";
240
 
                        break ;
241
 
                        
242
 
                        case CD_DESKLET_TREE :
243
 
                                cDeskletRendererName = "Tree";
244
 
                        break ;
245
 
                }
246
 
                CD_APPLET_SET_DESKLET_RENDERER_WITH_DATA (cDeskletRendererName, NULL);
247
 
                CAIRO_DOCK_REDRAW_MY_CONTAINER;
248
 
        }
 
219
        CD_APPLET_ADD_ICON_IN_MY_ICONS_LIST (pIcon);
249
220
}
250
221
 
251
222
void cd_stack_set_item_name (const gchar *cDesktopFilePath, const gchar *cName)