~cairo-dock-team/ubuntu/precise/cairo-dock/988102

« back to all changes in this revision

Viewing changes to src/gldit/cairo-dock-launcher-manager.c

  • Committer: Kees Cook
  • Date: 2011-08-11 19:31:26 UTC
  • mfrom: (19.1.1 cairo-dock)
  • Revision ID: kees@outflux.net-20110811193126-wh97aamdqx5gaf2f
Tags: 2.4.0~0beta2-0ubuntu1
releasing version 2.4.0~0beta2-0ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#include "cairo-dock-keyfile-utilities.h"
43
43
#include "cairo-dock-themes-manager.h"  // cairo_dock_mark_current_theme_as_modified
44
44
#include "cairo-dock-dock-facility.h"  // cairo_dock_update_dock_size
45
 
///#include "cairo-dock-gui-manager.h"  // cairo_dock_trigger_refresh_launcher_gui
46
45
#include "cairo-dock-animations.h"  // cairo_dock_launch_animation
47
46
#include "cairo-dock-launcher-factory.h"  // cairo_dock_new_launcher_icon
48
47
#include "cairo-dock-separator-manager.h"  // cairo_dock_create_separator_surface
146
145
        }
147
146
}
148
147
 
149
 
static gboolean _delete_user_separator (Icon *icon)
150
 
{
151
 
        if (icon->cDesktopFileName != NULL)
152
 
        {
153
 
                gchar *cDesktopFilePath = g_strdup_printf ("%s/%s", g_cCurrentLaunchersPath, icon->cDesktopFileName);
154
 
                g_remove (cDesktopFilePath);
155
 
                g_free (cDesktopFilePath);
156
 
                return TRUE;
157
 
        }
158
 
        return FALSE;
159
 
}
160
 
 
161
148
static gboolean _delete_launcher (Icon *icon)
162
149
{
163
150
        gboolean r = FALSE;
164
 
        if (icon->cDesktopFileName != NULL)
 
151
        if (icon->cDesktopFileName != NULL && icon->cDesktopFileName[0] != '/')
165
152
        {
166
153
                gchar *cDesktopFilePath = g_strdup_printf ("%s/%s", g_cCurrentLaunchersPath, icon->cDesktopFileName);
167
154
                g_remove (cDesktopFilePath);
169
156
                r = TRUE;
170
157
        }
171
158
        
172
 
        if (icon->pSubDock != NULL && icon->cClass == NULL)
 
159
        if (CAIRO_DOCK_ICON_TYPE_IS_CONTAINER (icon) && icon->pSubDock != NULL)  /// really useful ?...
173
160
        {
174
161
                Icon *pSubIcon;
175
162
                GList *ic;
203
190
        if (icon->iTrueType == CAIRO_DOCK_ICON_TYPE_SEPARATOR)
204
191
        {
205
192
                icon->iface.load_image = _load_user_separator;
206
 
                icon->iface.on_delete = _delete_user_separator;
207
193
        }
208
194
        else
209
195
        {
210
196
                icon->iface.load_image = _load_launcher;
211
 
                icon->iface.on_delete = _delete_launcher;
212
197
                icon->iface.action_on_drag_hover = _show_appli_for_drop;
213
198
        }
 
199
        icon->iface.on_delete = _delete_launcher;
214
200
        
215
201
        //\____________ On gere son dock et sous-dock.
216
202
        CairoDock *pParentDock = _cairo_dock_handle_container (icon, cRendererName);
219
205
        //\____________ On remplit ses buffers.
220
206
        cairo_dock_trigger_load_icon_buffers (icon, CAIRO_CONTAINER (pParentDock));
221
207
        
 
208
        //\____________ On gere son role d'inhibiteur.
222
209
        cd_message ("+ %s/%s", icon->cName, icon->cClass);
223
210
        if (icon->cClass != NULL)
224
211
        {
294
281
                return ;
295
282
        }
296
283
        
297
 
        //\_____________ On assure la coherence du nouveau fichier de conf.
298
 
        if (CAIRO_DOCK_ICON_TYPE_IS_LAUNCHER (icon) || CAIRO_DOCK_ICON_TYPE_IS_CONTAINER (icon))
 
284
        //\_____________ Ensure sub-dock's name unicity.
 
285
        if (CAIRO_DOCK_ICON_TYPE_IS_CONTAINER (icon))
299
286
        {
300
287
                gchar *cDesktopFilePath = g_strdup_printf ("%s/%s", g_cCurrentLaunchersPath, icon->cDesktopFileName);
301
288
                GKeyFile* pKeyFile = cairo_dock_open_key_file (cDesktopFilePath);
321
308
                        }
322
309
                        g_free (cName);
323
310
                }
324
 
                if (CAIRO_DOCK_ICON_TYPE_IS_LAUNCHER (icon))  // pas vraiment utile mais bon.
325
 
                {
326
 
                        gchar *cCommand = g_key_file_get_string (pKeyFile, "Desktop Entry", "Exec", NULL);
327
 
                        if (cCommand == NULL || *cCommand == '\0')
328
 
                        {
329
 
                                cCommand = g_strdup ("enter a command");
330
 
                                g_key_file_set_string (pKeyFile, "Desktop Entry", "Exec", cCommand);
331
 
                                cairo_dock_write_keys_to_file (pKeyFile, cDesktopFilePath);
332
 
                        }
333
 
                        g_free (cCommand);
334
 
                }
335
311
                
336
312
                g_key_file_free (pKeyFile);
337
313
                g_free (cDesktopFilePath);
528
504
{
529
505
        int r;
530
506
        r = system (cCommand);
 
507
        if (r != 0)
 
508
                cd_warning ("couldn't launch this command (%s)", cCommand);
531
509
        g_free (cCommand);
532
510
        return NULL;
533
511
}