~ubuntu-branches/ubuntu/oneiric/cairo-dock/oneiric-201106091216

« back to all changes in this revision

Viewing changes to src/cairo-dock-gui-manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe), Matthieu Baerts (matttbe), Didier Roche
  • Date: 2010-03-01 21:24:00 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100301212400-3a3csog6eonse3in
Tags: 2.1.3-6-0ubuntu1
[ Matthieu Baerts (matttbe) ]
* New Upstream Version. (LP: #521534)
* Updated debian/watch and debian/copyright with LP account.
* Removed debian/patches/02-merge-changelog.patch'
 - data/ChangeLog.txt has to respect a syntax and is used by CD.
* debian/cairo-dock.1:
 - Updated with the latest release.
 - The domain name 'cairo-dock.org' has changed to 'glx-dock.org'
* debian/control:
 - Changed the homepage and other links (glx-dock.org)
 - Updated cairo-dock-dev architecture to 'all' (it no longer contains compiled files)
* debian/cairo-dock-dev.install
 - libcairo-dock.a and libcairo-dock.so no longer exist
* debian/rules
 - removed uneeded changelog file
* Updated debian/patches/01-desktop-file-category.patch

[ Didier Roche ]
* Fix debian/watch
* Fix some issue in versionning
* debian/control: clean the packaging and add right -plugins depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "cairo-dock-modules.h"
29
29
#include "cairo-dock-log.h"
30
30
#include "cairo-dock-gui-factory.h"
31
 
#include "cairo-dock-gui-callbacks.h"
32
31
#include "cairo-dock-keyfile-utilities.h"
33
32
#include "cairo-dock-animations.h"
34
33
#include "cairo-dock-draw.h"
36
35
#include "cairo-dock-dock-manager.h"
37
36
#include "cairo-dock-container.h"
38
37
#include "cairo-dock-applications-manager.h"
39
 
#include "cairo-dock-gui-filter.h"
40
38
#include "cairo-dock-launcher-factory.h"
41
39
#include "cairo-dock-load.h"
42
 
#include "cairo-dock-internal-system.h"
43
40
#include "cairo-dock-internal-accessibility.h"
44
 
#include "cairo-dock-internal-icons.h"
45
41
#include "cairo-dock-desktop-file-factory.h"
46
 
#include "cairo-dock-file-manager.h"
 
42
#include "cairo-dock-gui-main.h"
 
43
#include "cairo-dock-gui-simple.h"
47
44
#include "cairo-dock-gui-manager.h"
48
45
 
49
 
#define CAIRO_DOCK_GROUP_ICON_SIZE 32
50
 
#define CAIRO_DOCK_CATEGORY_ICON_SIZE 32
51
 
#define CAIRO_DOCK_NB_BUTTONS_BY_ROW 4
52
 
#define CAIRO_DOCK_NB_BUTTONS_BY_ROW_MIN 3
53
46
#define CAIRO_DOCK_GUI_MARGIN 6
54
 
#define CAIRO_DOCK_TABLE_MARGIN 12
55
 
#define CAIRO_DOCK_CONF_PANEL_WIDTH 1150
56
 
#define CAIRO_DOCK_CONF_PANEL_WIDTH_MIN 800
57
 
#define CAIRO_DOCK_CONF_PANEL_HEIGHT 700
58
 
#define CAIRO_DOCK_PREVIEW_WIDTH 200
59
 
#define CAIRO_DOCK_PREVIEW_WIDTH_MIN 100
60
 
#define CAIRO_DOCK_PREVIEW_HEIGHT 250
61
 
#define CAIRO_DOCK_ICON_MARGIN 6
62
 
#define CAIRO_DOCK_TAB_ICON_SIZE 32
63
 
#define CAIRO_DOCK_LAUNCHER_PANEL_WIDTH 1000
64
 
#define CAIRO_DOCK_LAUNCHER_PANEL_HEIGHT 500
65
 
#
66
 
 
67
 
static CairoDockCategoryWidgetTable s_pCategoryWidgetTables[CAIRO_DOCK_NB_CATEGORY];
68
 
static GList *s_pGroupDescriptionList = NULL;
69
 
static GtkWidget *s_pPreviewImage = NULL;
70
 
static GtkWidget *s_pOkButton = NULL;
71
 
static GtkWidget *s_pApplyButton = NULL;
72
 
static GtkWidget *s_pBackButton = NULL;
73
 
static GtkWidget *s_pMainWindow = NULL;
74
 
static GtkWidget *s_pGroupsVBox = NULL;
75
 
static CairoDockGroupDescription *s_pCurrentGroup = NULL;
76
 
static GtkWidget *s_pCurrentGroupWidget = NULL;
77
 
static GSList *s_pCurrentWidgetList = NULL;
78
 
static GSList *s_pExtraCurrentWidgetList = NULL;
79
 
static GtkWidget *s_pToolBar = NULL;
80
 
static GtkWidget *s_pGroupFrame = NULL;
81
 
static GtkWidget *s_pFilterEntry = NULL;
82
 
static GtkWidget *s_pActivateButton = NULL;
83
 
static GtkWidget *s_pStatusBar = NULL;
84
 
static GSList *s_path = NULL;
85
 
static int s_iPreviewWidth, s_iNbButtonsByRow;
86
 
 
87
 
extern gchar *g_cConfFile;
 
47
 
88
48
extern CairoDock *g_pMainDock;
89
49
extern int g_iXScreenWidth[2], g_iXScreenHeight[2];
90
 
extern CairoDockDesktopEnv g_iDesktopEnv;
91
 
extern gchar *g_cCurrentLaunchersPath;
92
 
extern gboolean g_bEasterEggs;
93
 
 
94
 
const gchar *cCategoriesDescription[2*CAIRO_DOCK_NB_CATEGORY] = {
95
 
        N_("Behaviour"), "gtk-preferences",
96
 
        N_("Appearance"), "gtk-color-picker",
97
 
        N_("Accessories"), "gtk-dnd-multiple",
98
 
        N_("Desktop"), "gtk-file",
99
 
        N_("Controlers"), "gtk-zoom-fit",
100
 
        N_("Plug-ins"), "gtk-disconnect" };
101
 
 
 
50
extern gchar *g_cCairoDockDataDir;
 
51
 
 
52
static CairoDockGuiBackend *s_pGuiBackend = NULL;
 
53
static CairoDockLauncherGuiBackend *s_pLauncherGuiBackend = NULL;
 
54
 
 
55
  //////////////////////////
 
56
 // MAIN DOCK VISIBILITY //
 
57
//////////////////////////
102
58
 
103
59
static int iNbConfigDialogs = 0;
104
60
int cairo_dock_get_nb_dialog_windows (void)
105
61
{
106
62
        return iNbConfigDialogs;
107
63
}
 
64
 
108
65
void cairo_dock_dialog_window_destroyed (void)
109
66
{
110
67
        iNbConfigDialogs --;
115
72
                        cairo_dock_pop_down (g_pMainDock);
116
73
        }
117
74
        g_print ("iNbConfigDialogs <- %d\n", iNbConfigDialogs);
118
 
        
119
75
}
 
76
 
120
77
void cairo_dock_dialog_window_created (void)
121
78
{
122
79
        iNbConfigDialogs ++;
123
80
        g_print ("iNbConfigDialogs <- %d\n", iNbConfigDialogs);
124
 
        if (g_pMainDock != NULL)  // peut arriver au 1er lancement.
 
81
        if (g_pMainDock != NULL && cairo_dock_search_window_on_our_way (g_pMainDock, FALSE, TRUE) == NULL)  // peut arriver au 1er lancement.
125
82
                cairo_dock_pop_up (g_pMainDock);
126
83
}
127
84
 
128
85
 
129
 
static void _cairo_dock_reset_current_widget_list (void)
130
 
{
131
 
        cairo_dock_free_generated_widget_list (s_pCurrentWidgetList);
132
 
        s_pCurrentWidgetList = NULL;
133
 
        g_slist_foreach (s_pExtraCurrentWidgetList, (GFunc) cairo_dock_free_generated_widget_list, NULL);
134
 
        g_slist_free (s_pExtraCurrentWidgetList);
135
 
        s_pExtraCurrentWidgetList = NULL;
136
 
}
137
 
 
138
 
 
139
 
static void _cairo_dock_add_image_on_button (GtkWidget *pButton, const gchar *cImage, int iSize)
140
 
{
141
 
        if (cImage == NULL)
142
 
                return ;
143
 
        
144
 
        GtkWidget *pImage = NULL;
145
 
        if (*cImage != '/')
146
 
        {
147
 
                if (iSize >= 48)
148
 
                        iSize = GTK_ICON_SIZE_DIALOG;
149
 
                else if (iSize >= 32)
150
 
                        iSize = GTK_ICON_SIZE_LARGE_TOOLBAR;
151
 
                else
152
 
                        iSize = GTK_ICON_SIZE_BUTTON;
153
 
                pImage = gtk_image_new_from_stock (cImage, iSize);
154
 
        }
155
 
        else
156
 
        {
157
 
                GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size (cImage, iSize, iSize, NULL);
158
 
                if (pixbuf != NULL)
159
 
                {
160
 
                        pImage = gtk_image_new_from_pixbuf (pixbuf);
161
 
                        gdk_pixbuf_unref (pixbuf);
162
 
                }
163
 
        }
164
 
        if (pImage != NULL)
165
 
                gtk_button_set_image (GTK_BUTTON (pButton), pImage);  /// unref l'image ?...
166
 
}
167
 
static GtkToolItem *_cairo_dock_make_toolbutton (const gchar *cLabel, const gchar *cImage, int iSize)
168
 
{
169
 
        if (cImage == NULL)
170
 
                return gtk_tool_button_new (NULL, cLabel);
171
 
        
172
 
        GtkWidget *pImage = NULL;
173
 
        if (*cImage != '/')
174
 
        {
175
 
                if (iSize >= 48)
176
 
                        iSize = GTK_ICON_SIZE_DIALOG;
177
 
                else if (iSize >= 32)
178
 
                        iSize = GTK_ICON_SIZE_LARGE_TOOLBAR;
179
 
                else
180
 
                        iSize = GTK_ICON_SIZE_BUTTON;
181
 
                pImage = gtk_image_new_from_stock (cImage, iSize);
182
 
        }
183
 
        else
184
 
        {
185
 
                GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size (cImage, iSize, iSize, NULL);
186
 
                if (pixbuf != NULL)
187
 
                {
188
 
                        pImage = gtk_image_new_from_pixbuf (pixbuf);
189
 
                        gdk_pixbuf_unref (pixbuf);
190
 
                }
191
 
        }
192
 
        
193
 
        GtkToolItem *pWidget = gtk_tool_button_new (pImage, NULL);
194
 
        if (cLabel == NULL)
195
 
                return pWidget;
196
 
        
197
 
        GtkWidget *pLabel = gtk_label_new (NULL);
198
 
        gchar *cLabel2 = g_strdup_printf ("<span font_desc=\"Times New Roman 12\"><b>%s</b></span>", cLabel);  /// 16
199
 
        gtk_label_set_markup (GTK_LABEL (pLabel), cLabel2);
200
 
        g_free (cLabel2);
201
 
        
202
 
        GtkWidget *pAlign = gtk_alignment_new (0., 0.5, 0., 1.);
203
 
        gtk_alignment_set_padding (GTK_ALIGNMENT (pAlign), 0, 0, CAIRO_DOCK_GUI_MARGIN, 0);  /// *2
204
 
        gtk_container_add (GTK_CONTAINER (pAlign), pLabel);
205
 
        gtk_tool_button_set_label_widget (GTK_TOOL_BUTTON (pWidget), pAlign);
206
 
        
207
 
        return pWidget;
208
 
}
209
 
 
210
 
static inline CairoDockGroupDescription *_cairo_dock_add_group_button (const gchar *cGroupName, const gchar *cIcon, int iCategory, const gchar *cDescription, const gchar *cPreviewFilePath, int iActivation, gboolean bConfigurable, const gchar *cOriginalConfFilePath, const gchar *cGettextDomain, const gchar **cDependencies, GList *pExternalModules, const gchar *cInternalModule)
211
 
{
212
 
        //\____________ On garde une trace de ses caracteristiques.
213
 
        CairoDockGroupDescription *pGroupDescription = g_new0 (CairoDockGroupDescription, 1);
214
 
        pGroupDescription->cGroupName = g_strdup (cGroupName);
215
 
        pGroupDescription->cDescription = g_strdup (cDescription);
216
 
        pGroupDescription->iCategory = iCategory;
217
 
        pGroupDescription->cPreviewFilePath = g_strdup (cPreviewFilePath);
218
 
        pGroupDescription->cOriginalConfFilePath = g_strdup (cOriginalConfFilePath);
219
 
        pGroupDescription->cIcon = g_strdup (cIcon);
220
 
        pGroupDescription->cGettextDomain = cGettextDomain;
221
 
        pGroupDescription->cDependencies = cDependencies;
222
 
        pGroupDescription->pExternalModules = pExternalModules;
223
 
        pGroupDescription->cInternalModule = cInternalModule;
224
 
        
225
 
        s_pGroupDescriptionList = g_list_prepend (s_pGroupDescriptionList, pGroupDescription);
226
 
        if (cInternalModule != NULL)
227
 
                return pGroupDescription;
228
 
        
229
 
        //\____________ On construit le bouton du groupe.
230
 
        GtkWidget *pGroupHBox = gtk_hbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN);
231
 
        
232
 
        pGroupDescription->pActivateButton = gtk_check_button_new ();
233
 
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pGroupDescription->pActivateButton), iActivation);
234
 
        g_signal_connect (G_OBJECT (pGroupDescription->pActivateButton), "clicked", G_CALLBACK(on_click_activate_given_group), pGroupDescription);
235
 
        if (iActivation == -1)
236
 
                gtk_widget_set_sensitive (pGroupDescription->pActivateButton, FALSE);
237
 
        gtk_box_pack_start (GTK_BOX (pGroupHBox),
238
 
                pGroupDescription->pActivateButton,
239
 
                FALSE,
240
 
                FALSE,
241
 
                0);
242
 
        
243
 
        /// Essayer de regrouper le label et l'icone dans le bouton, et mettre a jour la recherche dans le nom du groupe...
244
 
        GtkWidget *pGroupButton = gtk_button_new ();
245
 
        if (bConfigurable)
246
 
                g_signal_connect (G_OBJECT (pGroupButton), "clicked", G_CALLBACK(on_click_group_button), pGroupDescription);
247
 
        else
248
 
                gtk_widget_set_sensitive (pGroupButton, FALSE);
249
 
        g_signal_connect (G_OBJECT (pGroupButton), "enter", G_CALLBACK(on_enter_group_button), pGroupDescription);
250
 
        g_signal_connect (G_OBJECT (pGroupButton), "leave", G_CALLBACK(on_leave_group_button), NULL);
251
 
        _cairo_dock_add_image_on_button (pGroupButton,
252
 
                cIcon,
253
 
                CAIRO_DOCK_GROUP_ICON_SIZE);
254
 
        gtk_box_pack_start (GTK_BOX (pGroupHBox),
255
 
                pGroupButton,
256
 
                FALSE,
257
 
                FALSE,
258
 
                0);
259
 
 
260
 
        pGroupDescription->pLabel = gtk_label_new (dgettext (pGroupDescription->cGettextDomain, cGroupName));
261
 
        gtk_box_pack_start (GTK_BOX (pGroupHBox),
262
 
                pGroupDescription->pLabel,
263
 
                FALSE,
264
 
                FALSE,
265
 
                0);
266
 
 
267
 
        //\____________ On place le bouton dans sa table.
268
 
        CairoDockCategoryWidgetTable *pCategoryWidget = &s_pCategoryWidgetTables[iCategory];
269
 
        if (pCategoryWidget->iNbItemsInCurrentRow == s_iNbButtonsByRow)
270
 
        {
271
 
                pCategoryWidget->iNbItemsInCurrentRow = 0;
272
 
                pCategoryWidget->iNbRows ++;
273
 
        }
274
 
        gtk_table_attach_defaults (GTK_TABLE (pCategoryWidget->pTable),
275
 
                pGroupHBox,
276
 
                pCategoryWidget->iNbItemsInCurrentRow,
277
 
                pCategoryWidget->iNbItemsInCurrentRow+1,
278
 
                pCategoryWidget->iNbRows,
279
 
                pCategoryWidget->iNbRows+1);
280
 
        pCategoryWidget->iNbItemsInCurrentRow ++;
281
 
        return pGroupDescription;
282
 
}
283
 
 
284
 
static gboolean _cairo_dock_add_one_module_widget (/*gchar *cModuleName, */CairoDockModule *pModule, const gchar *cActiveModules)
285
 
{
286
 
        const gchar *cModuleName = pModule->pVisitCard->cModuleName;
287
 
        if (pModule->cConfFilePath == NULL && ! g_bEasterEggs)
288
 
                pModule->cConfFilePath = cairo_dock_check_module_conf_file (pModule->pVisitCard);
289
 
        int iActive;
290
 
        if (! pModule->pInterface->stopModule)
291
 
                iActive = -1;
292
 
        else if (g_pMainDock == NULL && cActiveModules != NULL)  // avant chargement du theme.
293
 
        {
294
 
                gchar *str = g_strstr_len (cActiveModules, strlen (cActiveModules), cModuleName);
295
 
                iActive = (str != NULL &&
296
 
                        (str[strlen(cModuleName)] == '\0' || str[strlen(cModuleName)] == ';') &&
297
 
                        (str == cActiveModules || *(str-1) == ';'));
298
 
        }
299
 
        else
300
 
                iActive = (pModule->pInstancesList != NULL);
301
 
        
302
 
        CairoDockGroupDescription *pGroupDescription = _cairo_dock_add_group_button (cModuleName,
303
 
                pModule->pVisitCard->cIconFilePath,
304
 
                pModule->pVisitCard->iCategory,
305
 
                pModule->pVisitCard->cDescription,
306
 
                pModule->pVisitCard->cPreviewFilePath,
307
 
                iActive,
308
 
                pModule->cConfFilePath != NULL,
309
 
                NULL,
310
 
                pModule->pVisitCard->cGettextDomain,
311
 
                NULL,
312
 
                NULL,
313
 
                pModule->pVisitCard->cInternalModule);
314
 
        //g_print ("+ %s : %x;%x\n", cModuleName,pGroupDescription, pGroupDescription->pActivateButton);
315
 
        pGroupDescription->cOriginalConfFilePath = g_strdup_printf ("%s/%s", pModule->pVisitCard->cShareDataDir, pModule->pVisitCard->cConfFileName);  // petite optimisation, pour pas dupliquer la chaine 2 fois.
316
 
        pGroupDescription->load_custom_widget = pModule->pInterface->load_custom_widget;
317
 
        //return FALSE;
318
 
        return TRUE;  // continue.
319
 
}
320
 
 
321
 
 
322
 
static gboolean on_expose (GtkWidget *pWidget,
323
 
        GdkEventExpose *pExpose,
324
 
        gpointer data)
325
 
{
326
 
        if (! mySystem.bConfigPanelTransparency)
327
 
                return FALSE;
328
 
        cairo_t *pCairoContext = gdk_cairo_create (pWidget->window);
329
 
        int w, h;
330
 
        gtk_window_get_size (GTK_WINDOW (pWidget), &w, &h);
331
 
        cairo_pattern_t *pPattern = cairo_pattern_create_linear (0,0,
332
 
                w,
333
 
                h);
334
 
        cairo_pattern_set_extend (pPattern, CAIRO_EXTEND_REPEAT);
335
 
        cairo_pattern_add_color_stop_rgba   (pPattern,
336
 
                1.,
337
 
                0.,0.,0.,0.);
338
 
        cairo_pattern_add_color_stop_rgba   (pPattern,
339
 
                .25,
340
 
                241/255., 234/255., 255/255., 0.8);
341
 
        cairo_pattern_add_color_stop_rgba   (pPattern,
342
 
                0.,
343
 
                255/255., 255/255., 255/255., 0.9);
344
 
        cairo_set_source (pCairoContext, pPattern);
345
 
        
346
 
        cairo_set_operator (pCairoContext, CAIRO_OPERATOR_SOURCE);
347
 
        cairo_paint (pCairoContext);
348
 
        
349
 
        cairo_pattern_destroy (pPattern);
350
 
        cairo_destroy (pCairoContext);
351
 
        return FALSE;
352
 
}
353
 
GtkWidget *cairo_dock_build_main_ihm (const gchar *cConfFilePath, gboolean bMaintenanceMode)
354
 
{
355
 
        //\_____________ On construit la fenetre.
356
 
        if (s_pMainWindow != NULL)
357
 
        {
358
 
                gtk_window_present (GTK_WINDOW (s_pMainWindow));
359
 
                return s_pMainWindow;
360
 
        }
361
 
        s_pMainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
362
 
        //gtk_container_set_border_width (s_pMainWindow, CAIRO_DOCK_GUI_MARGIN);
363
 
        gchar *cIconPath = g_strdup_printf ("%s/%s", CAIRO_DOCK_SHARE_DATA_DIR, CAIRO_DOCK_ICON);
364
 
        gtk_window_set_icon_from_file (GTK_WINDOW (s_pMainWindow), cIconPath, NULL);
365
 
        g_free (cIconPath);
366
 
        
367
 
        GtkWidget *pMainHBox = gtk_hbox_new (FALSE, 0);  /// CAIRO_DOCK_GUI_MARGIN
368
 
        gtk_container_add (GTK_CONTAINER (s_pMainWindow), pMainHBox);
369
 
        ///gtk_container_set_border_width (GTK_CONTAINER (pMainHBox), CAIRO_DOCK_GUI_MARGIN);
370
 
        
371
 
        if (g_iXScreenWidth[CAIRO_DOCK_HORIZONTAL] > CAIRO_DOCK_CONF_PANEL_WIDTH)
372
 
        {
373
 
                s_iPreviewWidth = CAIRO_DOCK_PREVIEW_WIDTH;
374
 
                s_iNbButtonsByRow = CAIRO_DOCK_NB_BUTTONS_BY_ROW;
375
 
        }
376
 
        else if (g_iXScreenWidth[CAIRO_DOCK_HORIZONTAL] > CAIRO_DOCK_CONF_PANEL_WIDTH_MIN)
377
 
        {
378
 
                double a = 1.*(CAIRO_DOCK_PREVIEW_WIDTH - CAIRO_DOCK_PREVIEW_WIDTH_MIN) / (CAIRO_DOCK_CONF_PANEL_WIDTH - CAIRO_DOCK_CONF_PANEL_WIDTH_MIN);
379
 
                double b = CAIRO_DOCK_PREVIEW_WIDTH_MIN - CAIRO_DOCK_CONF_PANEL_WIDTH_MIN * a;
380
 
                s_iPreviewWidth = a * g_iXScreenWidth[CAIRO_DOCK_HORIZONTAL] + b;
381
 
                s_iNbButtonsByRow = CAIRO_DOCK_NB_BUTTONS_BY_ROW - 1;
382
 
        }
383
 
        else
384
 
        {
385
 
                s_iPreviewWidth = CAIRO_DOCK_PREVIEW_WIDTH_MIN;
386
 
                s_iNbButtonsByRow = CAIRO_DOCK_NB_BUTTONS_BY_ROW_MIN;
387
 
        }
388
 
        GtkWidget *pCategoriesVBox = gtk_vbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN);
389
 
        gtk_widget_set_size_request (pCategoriesVBox, s_iPreviewWidth+2*CAIRO_DOCK_GUI_MARGIN, CAIRO_DOCK_PREVIEW_HEIGHT);
390
 
        gtk_box_pack_start (GTK_BOX (pMainHBox),
391
 
                pCategoriesVBox,
392
 
                FALSE,
393
 
                FALSE,
394
 
                0);
395
 
        
396
 
        GtkWidget *pVBox = gtk_vbox_new (FALSE, 0);
397
 
        gtk_box_pack_start (GTK_BOX (pMainHBox),
398
 
                pVBox,
399
 
                TRUE,
400
 
                TRUE,
401
 
                0);
402
 
        s_pGroupsVBox = gtk_vbox_new (FALSE, CAIRO_DOCK_TABLE_MARGIN);
403
 
        GtkWidget *pScrolledWindow = gtk_scrolled_window_new (NULL, NULL);
404
 
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pScrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
405
 
        gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (pScrolledWindow), s_pGroupsVBox);
406
 
        gtk_box_pack_start (GTK_BOX (pVBox),
407
 
                pScrolledWindow,
408
 
                TRUE,
409
 
                TRUE,
410
 
                0);
411
 
        
412
 
        if (g_iDesktopEnv != CAIRO_DOCK_KDE && g_iDesktopEnv != CAIRO_DOCK_UNKNOWN_ENV && mySystem.bConfigPanelTransparency)
413
 
        {
414
 
                cairo_dock_set_colormap_for_window (s_pMainWindow);
415
 
                gtk_widget_set_app_paintable (s_pMainWindow, TRUE);
416
 
                g_signal_connect (G_OBJECT (s_pMainWindow),
417
 
                        "expose-event",
418
 
                        G_CALLBACK (on_expose),
419
 
                        NULL);
420
 
        }
421
 
        /*g_signal_connect (G_OBJECT (s_pGroupsVBox),
422
 
                "expose-event",
423
 
                G_CALLBACK (on_expose),
424
 
                NULL);*/
425
 
                
426
 
        //\_____________ On construit les boutons de chaque categorie.
427
 
        GtkWidget *pCategoriesFrame = gtk_frame_new (NULL);
428
 
        gtk_container_set_border_width (GTK_CONTAINER (pCategoriesFrame), CAIRO_DOCK_GUI_MARGIN);
429
 
        gtk_frame_set_shadow_type (GTK_FRAME (pCategoriesFrame), GTK_SHADOW_OUT);
430
 
        
431
 
        GtkWidget *pLabel;
432
 
        gchar *cLabel = g_strdup_printf ("<span font_desc=\"Times New Roman 12\" color=\"#81728C\"><b><u>%s :</u></b></span>", _("Categories"));
433
 
        pLabel = gtk_label_new (NULL);
434
 
        gtk_label_set_markup (GTK_LABEL (pLabel), cLabel);
435
 
        g_free (cLabel);
436
 
        gtk_frame_set_label_widget (GTK_FRAME (pCategoriesFrame), pLabel);
437
 
        
438
 
        gtk_box_pack_start (GTK_BOX (pCategoriesVBox),
439
 
                pCategoriesFrame,
440
 
                FALSE,
441
 
                FALSE,
442
 
                0);
443
 
        
444
 
        s_pToolBar = gtk_toolbar_new ();
445
 
        gtk_toolbar_set_orientation (GTK_TOOLBAR (s_pToolBar), GTK_ORIENTATION_VERTICAL);
446
 
        gtk_toolbar_set_style (GTK_TOOLBAR (s_pToolBar), GTK_TOOLBAR_BOTH_HORIZ);
447
 
        gtk_toolbar_set_show_arrow (GTK_TOOLBAR (s_pToolBar), FALSE);
448
 
        gtk_toolbar_set_icon_size (GTK_TOOLBAR (s_pToolBar), GTK_ICON_SIZE_LARGE_TOOLBAR);
449
 
        gtk_container_add (GTK_CONTAINER (pCategoriesFrame), s_pToolBar);
450
 
        
451
 
        GtkToolItem *pCategoryButton;
452
 
        pCategoryButton = _cairo_dock_make_toolbutton (_("All"),
453
 
                "gtk-file",
454
 
                CAIRO_DOCK_CATEGORY_ICON_SIZE);
455
 
        g_signal_connect (G_OBJECT (pCategoryButton), "clicked", G_CALLBACK(on_click_all_button), NULL);
456
 
        gtk_toolbar_insert (GTK_TOOLBAR (s_pToolBar) , pCategoryButton,-1);
457
 
        
458
 
        guint i;
459
 
        for (i = 0; i < CAIRO_DOCK_NB_CATEGORY; i ++)
460
 
        {
461
 
                pCategoryButton = _cairo_dock_make_toolbutton (gettext (cCategoriesDescription[2*i]),
462
 
                        cCategoriesDescription[2*i+1],
463
 
                        CAIRO_DOCK_CATEGORY_ICON_SIZE);
464
 
                g_signal_connect (G_OBJECT (pCategoryButton), "clicked", G_CALLBACK(on_click_category_button), GINT_TO_POINTER (i));
465
 
                gtk_toolbar_insert (GTK_TOOLBAR (s_pToolBar) , pCategoryButton,-1);
466
 
        }
467
 
        
468
 
        
469
 
        //\_____________ On construit les widgets table de chaque categorie.
470
 
        CairoDockCategoryWidgetTable *pCategoryWidget;
471
 
        for (i = 0; i < CAIRO_DOCK_NB_CATEGORY; i ++)
472
 
        {
473
 
                pCategoryWidget = &s_pCategoryWidgetTables[i];
474
 
                
475
 
                pCategoryWidget->pFrame = gtk_frame_new (NULL);
476
 
                gtk_container_set_border_width (GTK_CONTAINER (pCategoryWidget->pFrame), CAIRO_DOCK_GUI_MARGIN);
477
 
                gtk_frame_set_shadow_type (GTK_FRAME (pCategoryWidget->pFrame), GTK_SHADOW_OUT);
478
 
                
479
 
                pLabel = gtk_label_new (NULL);
480
 
                cLabel = g_strdup_printf ("<span font_desc=\"Times New Roman 12\"><b>%s</b></span>", gettext (cCategoriesDescription[2*i]));
481
 
                gtk_label_set_markup (GTK_LABEL (pLabel), cLabel);
482
 
                g_free (cLabel);
483
 
                gtk_frame_set_label_widget (GTK_FRAME (pCategoryWidget->pFrame), pLabel);
484
 
                
485
 
                pCategoryWidget->pTable = gtk_table_new (1,
486
 
                        s_iNbButtonsByRow,
487
 
                        TRUE);
488
 
                gtk_table_set_row_spacings (GTK_TABLE (pCategoryWidget->pTable), CAIRO_DOCK_GUI_MARGIN);
489
 
                gtk_table_set_col_spacings (GTK_TABLE (pCategoryWidget->pTable), CAIRO_DOCK_GUI_MARGIN);
490
 
                gtk_container_add (GTK_CONTAINER (pCategoryWidget->pFrame),
491
 
                        pCategoryWidget->pTable);
492
 
                gtk_box_pack_start (GTK_BOX (s_pGroupsVBox),
493
 
                        pCategoryWidget->pFrame,
494
 
                        FALSE,
495
 
                        FALSE,
496
 
                        0);
497
 
        }
498
 
        
499
 
        
500
 
        //\_____________ On remplit avec les groupes du fichier.
501
 
        GError *erreur = NULL;
502
 
        GKeyFile* pKeyFile = g_key_file_new();
503
 
        g_key_file_load_from_file (pKeyFile, cConfFilePath, 0, &erreur);  // inutile de garder les commentaires ici.
504
 
        if (erreur != NULL)
505
 
        {
506
 
                cd_warning ("while trying to load %s : %s", cConfFilePath, erreur->message);
507
 
                g_error_free (erreur);
508
 
                g_key_file_free (pKeyFile);
509
 
                return NULL;
510
 
        }
511
 
        
512
 
        gsize length = 0;
513
 
        gchar **pGroupList = g_key_file_get_groups (pKeyFile, &length);
514
 
        gchar *cGroupName;
515
 
        CairoDockInternalModule *pInternalModule;
516
 
        gchar *cOriginalConfFilePath = g_strdup_printf ("%s/%s", CAIRO_DOCK_SHARE_DATA_DIR, CAIRO_DOCK_CONF_FILE);
517
 
        for (i = 0; i < length; i ++)
518
 
        {
519
 
                cGroupName = pGroupList[i];
520
 
                pInternalModule = cairo_dock_find_internal_module_from_name (cGroupName);
521
 
                if (pInternalModule == NULL)
522
 
                        continue;
523
 
                
524
 
                _cairo_dock_add_group_button (cGroupName,
525
 
                        pInternalModule->cIcon,
526
 
                        pInternalModule->iCategory,
527
 
                        pInternalModule->cDescription,
528
 
                        NULL,  // pas de prevue
529
 
                        -1,  // <=> non desactivable
530
 
                        TRUE,  // <=> configurable
531
 
                        cOriginalConfFilePath,
532
 
                        NULL,  // domaine de traduction : celui du dock.
533
 
                        pInternalModule->cDependencies,
534
 
                        pInternalModule->pExternalModules,
535
 
                        NULL);
536
 
        }
537
 
        g_free (cOriginalConfFilePath);
538
 
        g_strfreev (pGroupList);
539
 
        
540
 
        
541
 
        //\_____________ On remplit avec les modules.
542
 
        gchar *cActiveModules = (g_pMainDock == NULL ? g_key_file_get_string (pKeyFile, "System", "modules", NULL) : NULL);
543
 
        cairo_dock_foreach_module_in_alphabetical_order ((GCompareFunc) _cairo_dock_add_one_module_widget, cActiveModules);
544
 
        g_free (cActiveModules);
545
 
        g_key_file_free (pKeyFile);
546
 
        
547
 
        
548
 
        //\_____________ On ajoute le cadre d'activation du module.
549
 
        s_pGroupFrame = gtk_frame_new ("pouet");
550
 
        gtk_container_set_border_width (GTK_CONTAINER (s_pGroupFrame), CAIRO_DOCK_GUI_MARGIN);
551
 
        gtk_frame_set_shadow_type (GTK_FRAME (s_pGroupFrame), GTK_SHADOW_OUT);
552
 
        gtk_box_pack_start (GTK_BOX (pCategoriesVBox),
553
 
                s_pGroupFrame,
554
 
                FALSE,
555
 
                FALSE,
556
 
                0);
557
 
        s_pActivateButton = gtk_check_button_new_with_label (_("Activate this module"));
558
 
        g_signal_connect (G_OBJECT (s_pActivateButton), "clicked", G_CALLBACK(on_click_activate_current_group), NULL);
559
 
        gtk_container_add (GTK_CONTAINER (s_pGroupFrame), s_pActivateButton);
560
 
        gtk_widget_show_all (s_pActivateButton);
561
 
        
562
 
        //\_____________ On ajoute la zone de prevue.
563
 
        GtkWidget *pInfoVBox = gtk_vbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN);
564
 
        gtk_box_pack_start (GTK_BOX (pCategoriesVBox),
565
 
                pInfoVBox,
566
 
                FALSE,
567
 
                FALSE,
568
 
                0);
569
 
        
570
 
        s_pPreviewImage = gtk_image_new_from_pixbuf (NULL);
571
 
        gtk_container_add (GTK_CONTAINER (pInfoVBox), s_pPreviewImage);
572
 
        
573
 
        //\_____________ On ajoute le filtre.
574
 
        GtkWidget *pFilterFrame = gtk_frame_new (NULL);
575
 
        cLabel = g_strdup_printf ("<span font_desc=\"Times New Roman 12\" color=\"#81728C\"><b><u>%s :</u></b></span>", _("Filter"));
576
 
        pLabel = gtk_label_new (NULL);
577
 
        gtk_label_set_markup (GTK_LABEL (pLabel), cLabel);
578
 
        g_free (cLabel);
579
 
        gtk_frame_set_label_widget (GTK_FRAME (pFilterFrame), pLabel);
580
 
        gtk_container_set_border_width (GTK_CONTAINER (s_pGroupFrame), CAIRO_DOCK_GUI_MARGIN);
581
 
        gtk_frame_set_shadow_type (GTK_FRAME (s_pGroupFrame), GTK_SHADOW_OUT);
582
 
        gtk_box_pack_start (GTK_BOX (pCategoriesVBox),
583
 
                pFilterFrame,
584
 
                FALSE,
585
 
                FALSE,
586
 
                0);
587
 
        GtkWidget *pOptionVBox = gtk_vbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN);
588
 
        gtk_container_add (GTK_CONTAINER (pFilterFrame), pOptionVBox);
589
 
        
590
 
        GtkWidget *pFilterBox = gtk_hbox_new (FALSE, 0);
591
 
        gtk_box_pack_start (GTK_BOX (pOptionVBox),
592
 
                pFilterBox,
593
 
                FALSE,
594
 
                FALSE,
595
 
                0);
596
 
        s_pFilterEntry = gtk_entry_new ();
597
 
        g_signal_connect (s_pFilterEntry, "activate", G_CALLBACK (cairo_dock_activate_filter), NULL);
598
 
        gtk_box_pack_start (GTK_BOX (pFilterBox),
599
 
                s_pFilterEntry,
600
 
                FALSE,
601
 
                FALSE,
602
 
                0);
603
 
        GtkWidget *pClearButton = gtk_button_new ();
604
 
        _cairo_dock_add_image_on_button (pClearButton,
605
 
                GTK_STOCK_CLEAR,
606
 
                16);
607
 
        g_signal_connect (pClearButton, "clicked", G_CALLBACK (cairo_dock_clear_filter), s_pFilterEntry);
608
 
        gtk_box_pack_start (GTK_BOX (pFilterBox),
609
 
                pClearButton,
610
 
                FALSE,
611
 
                FALSE,
612
 
                0);
613
 
        
614
 
        cairo_dock_reset_filter_state ();
615
 
        GtkWidget *pOptionButton = gtk_check_button_new_with_label (_("All words"));
616
 
        g_signal_connect (pOptionButton, "toggled", G_CALLBACK (cairo_dock_toggle_all_words), NULL);
617
 
        gtk_box_pack_start (GTK_BOX (pOptionVBox),
618
 
                pOptionButton,
619
 
                FALSE,
620
 
                FALSE,
621
 
                0);
622
 
        pOptionButton = gtk_check_button_new_with_label (_("Highlight words"));
623
 
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pOptionButton), TRUE);
624
 
        g_signal_connect (pOptionButton, "toggled", G_CALLBACK (cairo_dock_toggle_highlight_words), NULL);
625
 
        gtk_box_pack_start (GTK_BOX (pOptionVBox),
626
 
                pOptionButton,
627
 
                FALSE,
628
 
                FALSE,
629
 
                0);
630
 
        pOptionButton = gtk_check_button_new_with_label (_("Hide others"));
631
 
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pOptionButton), TRUE);
632
 
        g_signal_connect (pOptionButton, "toggled", G_CALLBACK (cairo_dock_toggle_hide_others), NULL);
633
 
        gtk_box_pack_start (GTK_BOX (pOptionVBox),
634
 
                pOptionButton,
635
 
                FALSE,
636
 
                FALSE,
637
 
                0);
638
 
        pOptionButton = gtk_check_button_new_with_label (_("Search in description"));
639
 
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pOptionButton), TRUE);
640
 
        g_signal_connect (pOptionButton, "toggled", G_CALLBACK (cairo_dock_toggle_search_in_tooltip), NULL);
641
 
        gtk_box_pack_start (GTK_BOX (pOptionVBox),
642
 
                pOptionButton,
643
 
                FALSE,
644
 
                FALSE,
645
 
                0);
646
 
        
647
 
        //\_____________ On ajoute les boutons.
648
 
        GtkWidget *pButtonsHBox = gtk_hbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN);
649
 
        gtk_box_pack_end (GTK_BOX (pVBox),
650
 
                pButtonsHBox,
651
 
                FALSE,
652
 
                FALSE,
653
 
                0);
654
 
        
655
 
        GtkWidget *pQuitButton = gtk_button_new_from_stock (GTK_STOCK_QUIT);
656
 
        g_signal_connect (G_OBJECT (pQuitButton), "clicked", G_CALLBACK(on_click_quit), s_pMainWindow);
657
 
        gtk_box_pack_end (GTK_BOX (pButtonsHBox),
658
 
                pQuitButton,
659
 
                FALSE,
660
 
                FALSE,
661
 
                0);
662
 
        
663
 
        s_pBackButton = gtk_button_new_from_stock (GTK_STOCK_GO_BACK);
664
 
        g_signal_connect (G_OBJECT (s_pBackButton), "clicked", G_CALLBACK(on_click_back_button), NULL);
665
 
        gtk_box_pack_end (GTK_BOX (pButtonsHBox),
666
 
                s_pBackButton,
667
 
                FALSE,
668
 
                FALSE,
669
 
                0);
670
 
        
671
 
        s_pOkButton = gtk_button_new_from_stock (GTK_STOCK_OK);
672
 
        g_signal_connect (G_OBJECT (s_pOkButton), "clicked", G_CALLBACK(on_click_ok), s_pMainWindow);
673
 
        gtk_box_pack_end (GTK_BOX (pButtonsHBox),
674
 
                s_pOkButton,
675
 
                FALSE,
676
 
                FALSE,
677
 
                0);
678
 
        
679
 
        s_pApplyButton = gtk_button_new_from_stock (GTK_STOCK_APPLY);
680
 
        g_signal_connect (G_OBJECT (s_pApplyButton), "clicked", G_CALLBACK(on_click_apply), NULL);
681
 
        gtk_box_pack_end (GTK_BOX (pButtonsHBox),
682
 
                s_pApplyButton,
683
 
                FALSE,
684
 
                FALSE,
685
 
                0);
686
 
        
687
 
        //\_____________ On ajoute la barre de status a la fin.
688
 
        s_pStatusBar = gtk_statusbar_new ();
689
 
        gtk_box_pack_start (GTK_BOX (pButtonsHBox),
690
 
                s_pStatusBar,
691
 
                TRUE,
692
 
                TRUE,
693
 
                0);
694
 
        
695
 
        gtk_window_resize (GTK_WINDOW (s_pMainWindow),
696
 
                MIN (CAIRO_DOCK_CONF_PANEL_WIDTH, g_iXScreenWidth[CAIRO_DOCK_HORIZONTAL]),
697
 
                MIN (CAIRO_DOCK_CONF_PANEL_HEIGHT, g_iXScreenHeight[CAIRO_DOCK_HORIZONTAL] - (g_pMainDock && g_pMainDock->container.bIsHorizontal ? g_pMainDock->iMaxDockHeight : 0)));
698
 
        
699
 
        if (g_pMainDock != NULL && ! myAccessibility.bReserveSpace)  // evitons d'empieter sur le dock.
700
 
        {
701
 
                if (g_pMainDock->container.bIsHorizontal)
702
 
                {
703
 
                        if (g_pMainDock->container.bDirectionUp)
704
 
                                gtk_window_move (GTK_WINDOW (s_pMainWindow), 0, 0);
705
 
                        else
706
 
                                gtk_window_move (GTK_WINDOW (s_pMainWindow), 0, g_pMainDock->iMaxDockHeight);
707
 
                }
708
 
        }
709
 
        
710
 
        gtk_widget_show_all (s_pMainWindow);
711
 
        gtk_widget_hide (s_pApplyButton);
712
 
        gtk_widget_hide (s_pOkButton);
713
 
        gtk_widget_hide (s_pGroupFrame);
714
 
        gtk_widget_hide (s_pPreviewImage);
715
 
        
716
 
        cairo_dock_dialog_window_created ();
717
 
        
718
 
        if (bMaintenanceMode)
719
 
        {
720
 
                gtk_window_set_title (GTK_WINDOW (s_pMainWindow), _("< Maintenance mode >"));
721
 
                GMainLoop *pBlockingLoop = g_main_loop_new (NULL, FALSE);
722
 
                g_object_set_data (G_OBJECT (s_pMainWindow), "loop", pBlockingLoop);
723
 
                g_signal_connect (s_pMainWindow,
724
 
                        "delete-event",
725
 
                        G_CALLBACK (on_delete_main_gui),
726
 
                        pBlockingLoop);
727
 
                
728
 
                g_print ("debut de boucle bloquante ...\n");
729
 
                GDK_THREADS_LEAVE ();
730
 
                g_main_loop_run (pBlockingLoop);
731
 
                GDK_THREADS_ENTER ();
732
 
                g_print ("fin de boucle bloquante\n");
733
 
                
734
 
                g_main_loop_unref (pBlockingLoop);
735
 
        }
736
 
        else
737
 
        {
738
 
                gtk_window_set_title (GTK_WINDOW (s_pMainWindow), _("Configuration of Cairo-Dock"));
739
 
                g_signal_connect (G_OBJECT (s_pMainWindow),
740
 
                        "delete-event",
741
 
                        G_CALLBACK (on_delete_main_gui),
742
 
                        NULL);
743
 
        }
744
 
        return s_pMainWindow;
745
 
}
746
 
 
747
 
 
748
 
GtkWidget *cairo_dock_get_preview_image (int *iPreviewWidth)
749
 
{
750
 
        *iPreviewWidth = s_iPreviewWidth;
751
 
        return s_pPreviewImage;
752
 
}
753
 
 
754
 
GtkWidget *cairo_dock_get_main_window (void)
755
 
{
756
 
        return s_pMainWindow;
757
 
}
758
 
 
759
 
CairoDockGroupDescription *cairo_dock_get_current_group (void)
760
 
{
761
 
        return s_pCurrentGroup;
762
 
}
763
 
 
764
 
GSList *cairo_dock_get_current_widget_list (void)
765
 
{
766
 
        return s_pCurrentWidgetList;
767
 
}
768
 
 
769
 
 
770
 
void cairo_dock_hide_all_categories (void)
771
 
{
772
 
        CairoDockCategoryWidgetTable *pCategoryWidget;
773
 
        int i;
774
 
        for (i = 0; i < CAIRO_DOCK_NB_CATEGORY; i ++)
775
 
        {
776
 
                pCategoryWidget = &s_pCategoryWidgetTables[i];
777
 
                gtk_widget_hide (pCategoryWidget->pFrame);
778
 
        }
779
 
        
780
 
        gtk_widget_show (s_pOkButton);
781
 
        gtk_widget_show (s_pApplyButton);
782
 
}
783
 
 
784
 
void cairo_dock_show_all_categories (void)
785
 
{
786
 
        if (s_pStatusBar)
787
 
                gtk_statusbar_pop (GTK_STATUSBAR (s_pStatusBar), 0);
788
 
        
789
 
        //\_______________ On detruit le widget du groupe courant.
790
 
        if (s_pCurrentGroupWidget != NULL)
791
 
        {
792
 
                gtk_widget_destroy (s_pCurrentGroupWidget);
793
 
                s_pCurrentGroupWidget = NULL;
794
 
                _cairo_dock_reset_current_widget_list ();
795
 
                
796
 
                s_pCurrentGroup = NULL;
797
 
        }
798
 
 
799
 
        //\_______________ On montre chaque module.
800
 
        CairoDockCategoryWidgetTable *pCategoryWidget;
801
 
        int i;
802
 
        for (i = 0; i < CAIRO_DOCK_NB_CATEGORY; i ++)
803
 
        {
804
 
                pCategoryWidget = &s_pCategoryWidgetTables[i];
805
 
                gtk_widget_show_all (pCategoryWidget->pFrame);
806
 
        }
807
 
        gtk_widget_hide (s_pOkButton);
808
 
        gtk_widget_hide (s_pApplyButton);
809
 
        gtk_widget_hide (s_pGroupFrame);
810
 
        
811
 
        //\_______________ On actualise le titre de la fenetre.
812
 
        gtk_window_set_title (GTK_WINDOW (cairo_dock_get_main_window ()), _("Configuration of Cairo-Dock"));
813
 
        if (s_path == NULL || s_path->data != GINT_TO_POINTER (0))
814
 
                s_path = g_slist_prepend (s_path, GINT_TO_POINTER (0));
815
 
 
816
 
        //\_______________ On declenche le filtre.
817
 
        cairo_dock_trigger_current_filter ();
818
 
}
819
 
 
820
 
void cairo_dock_show_one_category (int iCategory)
821
 
{
822
 
        if (s_pStatusBar)
823
 
                gtk_statusbar_pop (GTK_STATUSBAR (s_pStatusBar), 0);
824
 
        
825
 
        //\_______________ On detruit le widget du groupe courant.
826
 
        if (s_pCurrentGroupWidget != NULL)
827
 
        {
828
 
                gtk_widget_destroy (s_pCurrentGroupWidget);
829
 
                s_pCurrentGroupWidget = NULL;
830
 
                _cairo_dock_reset_current_widget_list ();
831
 
                s_pCurrentGroup = NULL;
832
 
        }
833
 
 
834
 
        //\_______________ On montre chaque module de la categorie.
835
 
        CairoDockCategoryWidgetTable *pCategoryWidget;
836
 
        int i;
837
 
        for (i = 0; i < CAIRO_DOCK_NB_CATEGORY; i ++)
838
 
        {
839
 
                pCategoryWidget = &s_pCategoryWidgetTables[i];
840
 
                if (i != iCategory)
841
 
                        gtk_widget_hide (pCategoryWidget->pFrame);
842
 
                else
843
 
                        gtk_widget_show_all (pCategoryWidget->pFrame);
844
 
        }
845
 
        gtk_widget_hide (s_pOkButton);
846
 
        gtk_widget_hide (s_pApplyButton);
847
 
        gtk_widget_hide (s_pGroupFrame);
848
 
        
849
 
        //\_______________ On actualise le titre de la fenetre.
850
 
        gtk_window_set_title (GTK_WINDOW (cairo_dock_get_main_window ()), gettext (cCategoriesDescription[2*iCategory]));
851
 
        if (s_path == NULL || s_path->data != GINT_TO_POINTER (iCategory+1))
852
 
                s_path = g_slist_prepend (s_path, GINT_TO_POINTER (iCategory+1));
853
 
 
854
 
        //\_______________ On declenche le filtre.
855
 
        cairo_dock_trigger_current_filter ();
856
 
}
857
 
 
858
 
void cairo_dock_insert_extern_widget_in_gui (GtkWidget *pWidget)
859
 
{
860
 
        if (s_pCurrentGroupWidget != NULL)
861
 
                gtk_widget_destroy (s_pCurrentGroupWidget);
862
 
        s_pCurrentGroupWidget = pWidget;
863
 
        
864
 
        gtk_box_pack_start (GTK_BOX (s_pGroupsVBox),
865
 
                pWidget,
866
 
                TRUE,
867
 
                TRUE,
868
 
                CAIRO_DOCK_GUI_MARGIN);
869
 
        gtk_widget_show_all (pWidget);
870
 
}
871
 
 
872
 
GtkWidget *cairo_dock_present_group_widget (const gchar *cConfFilePath, CairoDockGroupDescription *pGroupDescription, gboolean bSingleGroup, CairoDockModuleInstance *pInstance)
873
 
{
874
 
        cd_debug ("%s (%s, %s)", __func__, cConfFilePath, pGroupDescription->cGroupName);
875
 
        //cairo_dock_set_status_message (NULL, "");
876
 
        if (s_pStatusBar)
877
 
                gtk_statusbar_pop (GTK_STATUSBAR (s_pStatusBar), 0);
878
 
        g_free (pGroupDescription->cConfFilePath);
879
 
        pGroupDescription->cConfFilePath = g_strdup (cConfFilePath);
880
 
        
881
 
        //\_______________ On cree le widget du groupe.
882
 
        GKeyFile* pKeyFile = cairo_dock_open_key_file (cConfFilePath);
883
 
        g_return_val_if_fail (pKeyFile != NULL, NULL);
884
 
        
885
 
        _cairo_dock_reset_current_widget_list ();
886
 
        
887
 
        GPtrArray *pDataGarbage = g_ptr_array_new ();
888
 
        GtkWidget *pWidget;
889
 
        if (bSingleGroup)
890
 
        {
891
 
                pWidget = cairo_dock_build_group_widget (pKeyFile,
892
 
                        pGroupDescription->cGroupName,
893
 
                        pGroupDescription->cGettextDomain,
894
 
                        cairo_dock_get_main_window (),
895
 
                        &s_pCurrentWidgetList,
896
 
                        pDataGarbage,
897
 
                        pGroupDescription->cOriginalConfFilePath);
898
 
        }
899
 
        else
900
 
        {
901
 
                pWidget = cairo_dock_build_key_file_widget (pKeyFile,
902
 
                        pGroupDescription->cGettextDomain,
903
 
                        cairo_dock_get_main_window (),
904
 
                        &s_pCurrentWidgetList,
905
 
                        pDataGarbage,
906
 
                        pGroupDescription->cOriginalConfFilePath);
907
 
        }
908
 
        
909
 
        //\_______________ On complete avec les modules additionnels.
910
 
        if (pGroupDescription->pExternalModules != NULL)
911
 
        {
912
 
                // on cree les widgets de tous les modules externes dans un meme notebook.
913
 
                g_print ("on cree les widgets de tous les modules externes\n");
914
 
                GtkWidget *pNoteBook = NULL;
915
 
                GKeyFile* pExtraKeyFile;
916
 
                CairoDockModule *pModule;
917
 
                CairoDockModuleInstance *pExtraInstance;
918
 
                GSList *pExtraCurrentWidgetList = NULL;
919
 
                CairoDockGroupDescription *pExtraGroupDescription;
920
 
                GList *p;
921
 
                for (p = pGroupDescription->pExternalModules; p != NULL; p = p->next)
922
 
                {
923
 
                        //g_print (" + %s\n", p->data);
924
 
                        pModule = cairo_dock_find_module_from_name (p->data);
925
 
                        if (pModule == NULL)
926
 
                                continue;
927
 
                        if (pModule->cConfFilePath == NULL)  // on n'est pas encore passe par la dans le cas ou le plug-in n'a pas ete active; mais on veut pouvoir configurer un plug-in meme lorsqu'il est inactif.
928
 
                        {
929
 
                                pModule->cConfFilePath = cairo_dock_check_module_conf_file (pModule->pVisitCard);
930
 
                        }
931
 
                        //g_print (" + %s\n", pModule->cConfFilePath);
932
 
 
933
 
                        pExtraGroupDescription = cairo_dock_find_module_description (p->data);
934
 
                        //g_print (" pExtraGroupDescription : %x\n", pExtraGroupDescription);
935
 
                        if (pExtraGroupDescription == NULL)
936
 
                                continue;
937
 
 
938
 
                        pExtraKeyFile = cairo_dock_open_key_file (pModule->cConfFilePath);
939
 
                        if (pExtraKeyFile == NULL)
940
 
                                continue;
941
 
                        
942
 
                        pExtraCurrentWidgetList = NULL;
943
 
                        pNoteBook = cairo_dock_build_key_file_widget (pExtraKeyFile,
944
 
                                pExtraGroupDescription->cGettextDomain,
945
 
                                cairo_dock_get_main_window (),
946
 
                                &pExtraCurrentWidgetList,
947
 
                                pDataGarbage,
948
 
                                pExtraGroupDescription->cOriginalConfFilePath);  /// TODO : fournir pNoteBook a la fonction.
949
 
                        s_pExtraCurrentWidgetList = g_slist_prepend (s_pExtraCurrentWidgetList, pExtraCurrentWidgetList);
950
 
                        
951
 
                        pExtraInstance = (pModule->pInstancesList ? pModule->pInstancesList->data : NULL);  // il y'a la une limitation : les modules attaches a un module interne ne peuvent etre instancie plus d'une fois. Dans la pratique ca ne pose aucun probleme.
952
 
                        if (pExtraInstance != NULL && pExtraGroupDescription->load_custom_widget != NULL)
953
 
                                pExtraGroupDescription->load_custom_widget (pExtraInstance, pKeyFile);
954
 
                        g_key_file_free (pExtraKeyFile);
955
 
                }
956
 
                
957
 
                // on rajoute la page du module interne en 1er dans le notebook.
958
 
                if (pNoteBook != NULL)
959
 
                {
960
 
                        GtkWidget *pLabel = gtk_label_new (dgettext (pGroupDescription->cGettextDomain, pGroupDescription->cGroupName));
961
 
                        GtkWidget *pLabelContainer = NULL;
962
 
                        GtkWidget *pAlign = NULL;
963
 
                        if (pGroupDescription->cIcon != NULL && *pGroupDescription->cIcon != '\0')
964
 
                        {
965
 
                                pLabelContainer = gtk_hbox_new (FALSE, CAIRO_DOCK_ICON_MARGIN);
966
 
                                pAlign = gtk_alignment_new (0., 0.5, 0., 0.);
967
 
                                gtk_container_add (GTK_CONTAINER (pAlign), pLabelContainer);
968
 
 
969
 
                                GtkWidget *pImage = gtk_image_new ();
970
 
                                GdkPixbuf *pixbuf;
971
 
                                if (*pGroupDescription->cIcon != '/')
972
 
                                        pixbuf = gtk_widget_render_icon (pImage,
973
 
                                                pGroupDescription->cIcon ,
974
 
                                                GTK_ICON_SIZE_BUTTON,
975
 
                                                NULL);
976
 
                                else
977
 
                                        pixbuf = gdk_pixbuf_new_from_file_at_size (pGroupDescription->cIcon, CAIRO_DOCK_TAB_ICON_SIZE, CAIRO_DOCK_TAB_ICON_SIZE, NULL);
978
 
                                if (pixbuf != NULL)
979
 
                                {
980
 
                                        gtk_image_set_from_pixbuf (GTK_IMAGE (pImage), pixbuf);
981
 
                                        gdk_pixbuf_unref (pixbuf);
982
 
                                }
983
 
                                gtk_container_add (GTK_CONTAINER (pLabelContainer),
984
 
                                        pImage);
985
 
                                gtk_container_add (GTK_CONTAINER (pLabelContainer), pLabel);
986
 
                                gtk_widget_show_all (pLabelContainer);
987
 
                        }
988
 
                        
989
 
                        GtkWidget *pScrolledWindow = gtk_scrolled_window_new (NULL, NULL);
990
 
                        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pScrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
991
 
                        gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (pScrolledWindow), pWidget);
992
 
                        
993
 
                        gtk_notebook_prepend_page (GTK_NOTEBOOK (pNoteBook), pScrolledWindow, (pAlign != NULL ? pAlign : pLabel));
994
 
                        pWidget = pNoteBook;
995
 
                }
996
 
        }
997
 
        
998
 
        if (pInstance != NULL && pGroupDescription->load_custom_widget != NULL)
999
 
                pGroupDescription->load_custom_widget (pInstance, pKeyFile);
1000
 
        g_key_file_free (pKeyFile);
1001
 
 
1002
 
        //\_______________ On affiche le widget du groupe dans l'interface.
1003
 
        cairo_dock_hide_all_categories ();
1004
 
        
1005
 
        cairo_dock_insert_extern_widget_in_gui (pWidget);  // devient le widget courant.
1006
 
        
1007
 
        s_pCurrentGroup = pGroupDescription;
1008
 
        
1009
 
        gtk_window_set_title (GTK_WINDOW (cairo_dock_get_main_window ()), gettext (pGroupDescription->cGroupName));
1010
 
        
1011
 
        //\_______________ On met a jour la frame du groupe (label + check-button).
1012
 
        GtkWidget *pLabel = gtk_label_new (NULL);
1013
 
        gchar *cLabel = g_strdup_printf ("<span font_desc=\"Times New Roman 12\" color=\"#81728C\"><u><b>%s</b></u></span>", pGroupDescription->cGroupName);
1014
 
        gtk_label_set_markup (GTK_LABEL (pLabel), cLabel);
1015
 
        g_free (cLabel);
1016
 
        gtk_frame_set_label_widget (GTK_FRAME (s_pGroupFrame), pLabel);
1017
 
        gtk_widget_show_all (s_pGroupFrame);
1018
 
        
1019
 
        g_signal_handlers_block_by_func (s_pActivateButton, on_click_activate_current_group, NULL);
1020
 
        CairoDockModule *pModule = cairo_dock_find_module_from_name (pGroupDescription->cGroupName);
1021
 
        if (pModule != NULL && pModule->pInterface->stopModule != NULL)
1022
 
        {
1023
 
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (s_pActivateButton), pModule->pInstancesList != NULL);
1024
 
                gtk_widget_set_sensitive (s_pActivateButton, TRUE);
1025
 
        }
1026
 
        else
1027
 
        {
1028
 
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (s_pActivateButton), TRUE);
1029
 
                gtk_widget_set_sensitive (s_pActivateButton, FALSE);
1030
 
        }
1031
 
        g_signal_handlers_unblock_by_func (s_pActivateButton, on_click_activate_current_group, NULL);
1032
 
        if (s_path == NULL || s_path->data != pGroupDescription)
1033
 
                s_path = g_slist_prepend (s_path, pGroupDescription);
1034
 
        
1035
 
        //\_______________ On declenche le filtre.
1036
 
        cairo_dock_trigger_current_filter ();
1037
 
        
1038
 
        //\_______________ On gere les dependances.
1039
 
        if (pGroupDescription->cDependencies != NULL && ! pGroupDescription->bIgnoreDependencies && g_pMainDock != NULL)
1040
 
        {
1041
 
                pGroupDescription->bIgnoreDependencies = TRUE;  // cette fonction re-entrante.
1042
 
                gboolean bReload = FALSE;
1043
 
                const gchar *cModuleName, *cMessage;
1044
 
                CairoDockModule *pDependencyModule;
1045
 
                GError *erreur = NULL;
1046
 
                int i;
1047
 
                for (i = 0; pGroupDescription->cDependencies[i] != NULL; i += 2)
1048
 
                {
1049
 
                        cModuleName = pGroupDescription->cDependencies[i];
1050
 
                        cMessage = pGroupDescription->cDependencies[i+1];
1051
 
                        
1052
 
                        pDependencyModule = cairo_dock_find_module_from_name (cModuleName);
1053
 
                        if (pDependencyModule == NULL)
1054
 
                        {
1055
 
                                Icon *pIcon = cairo_dock_get_current_active_icon ();
1056
 
                                if (pIcon == NULL)
1057
 
                                        pIcon = cairo_dock_get_dialogless_icon ();
1058
 
                                CairoDock *pDock = cairo_dock_search_dock_from_name (pIcon != NULL ? pIcon->cParentDockName : NULL);
1059
 
                                cairo_dock_show_temporary_dialog_with_icon (_("The module '%s' is not present. You need to install it or its dependencies to make the most of this module."), pIcon, CAIRO_CONTAINER (pDock), 10, "same icon");
1060
 
                        }
1061
 
                        else if (pDependencyModule != pModule)
1062
 
                        {
1063
 
                                if (pDependencyModule->pInstancesList == NULL && pDependencyModule->pInterface->initModule != NULL)
1064
 
                                {
1065
 
                                        gchar *cWarning = g_strdup_printf (_("The module '%s' is not activated."), cModuleName);
1066
 
                                        gchar *cQuestion = g_strdup_printf ("%s\n%s\n%s", cWarning, gettext (cMessage), _("Do you want to activate it now ?"));
1067
 
                                        int iAnswer = cairo_dock_ask_general_question_and_wait (cQuestion);
1068
 
                                        g_free (cQuestion);
1069
 
                                        g_free (cWarning);
1070
 
                                        
1071
 
                                        if (iAnswer == GTK_RESPONSE_YES)
1072
 
                                        {
1073
 
                                                cairo_dock_activate_module (pDependencyModule, &erreur);
1074
 
                                                if (erreur != NULL)
1075
 
                                                {
1076
 
                                                        cd_warning (erreur->message);
1077
 
                                                        g_error_free (erreur);
1078
 
                                                        erreur = NULL;
1079
 
                                                }
1080
 
                                                else
1081
 
                                                        bReload = TRUE;
1082
 
                                        }
1083
 
                                }
1084
 
                        }
1085
 
                }
1086
 
                if (bReload)
1087
 
                        cairo_dock_reload_current_group_widget (NULL);
1088
 
                pGroupDescription->bIgnoreDependencies = FALSE;
1089
 
        }
1090
 
        
1091
 
        return pWidget;
1092
 
}
1093
 
 
1094
 
 
1095
 
CairoDockGroupDescription *cairo_dock_find_module_description (const gchar *cModuleName)
1096
 
{
1097
 
        g_return_val_if_fail (cModuleName != NULL, NULL);
1098
 
        CairoDockGroupDescription *pGroupDescription = NULL;
1099
 
        GList *pElement = NULL;
1100
 
        for (pElement = s_pGroupDescriptionList; pElement != NULL; pElement = pElement->next)
1101
 
        {
1102
 
                pGroupDescription = pElement->data;
1103
 
                if (strcmp (pGroupDescription->cGroupName, cModuleName) == 0)
1104
 
                        return pGroupDescription ;
 
86
  //////////////////////////
 
87
 // DYNAMIC CONFIG PANEL //
 
88
//////////////////////////
 
89
 
 
90
GtkWidget *cairo_dock_get_widget_from_name (const gchar *cGroupName, const gchar *cKeyName)
 
91
{
 
92
        if (s_pGuiBackend && s_pGuiBackend->get_widgets_from_name)
 
93
        {
 
94
                GSList *pList = s_pGuiBackend->get_widgets_from_name (cGroupName, cKeyName);
 
95
                if (pList != NULL)
 
96
                        return pList->data;
1105
97
        }
1106
98
        return NULL;
1107
99
}
1108
100
 
1109
 
void cairo_dock_present_module_gui (CairoDockModule *pModule)
1110
 
{
1111
 
        g_return_if_fail (pModule != NULL);
1112
 
        
1113
 
        CairoDockGroupDescription *pGroupDescription = cairo_dock_find_module_description (pModule->pVisitCard->cModuleName);
1114
 
        if (pGroupDescription == NULL)
1115
 
                return ;
1116
 
        
1117
 
        CairoDockModuleInstance *pModuleInstance = (pModule->pInstancesList != NULL ? pModule->pInstancesList->data : NULL);
1118
 
        gchar *cConfFilePath = (pModuleInstance != NULL ? pModuleInstance->cConfFilePath : pModule->cConfFilePath);
1119
 
        cairo_dock_present_group_widget (cConfFilePath, pGroupDescription, FALSE, pModuleInstance);
1120
 
}
1121
 
 
1122
 
void cairo_dock_present_module_instance_gui (CairoDockModuleInstance *pModuleInstance)
1123
 
{
1124
 
        g_return_if_fail (pModuleInstance != NULL);
1125
 
        
1126
 
        CairoDockGroupDescription *pGroupDescription = cairo_dock_find_module_description (pModuleInstance->pModule->pVisitCard->cModuleName);
1127
 
        if (pGroupDescription == NULL)
1128
 
                return ;
1129
 
        
1130
 
        cairo_dock_present_group_widget (pModuleInstance->cConfFilePath, pGroupDescription, FALSE, pModuleInstance);
1131
 
}
1132
 
 
1133
 
void cairo_dock_show_group (CairoDockGroupDescription *pGroupDescription)
1134
 
{
1135
 
        g_return_if_fail (pGroupDescription != NULL);
1136
 
        gboolean bSingleGroup;
1137
 
        gchar *cConfFilePath;
1138
 
        CairoDockModuleInstance *pModuleInstance = NULL;
1139
 
        CairoDockModule *pModule = cairo_dock_find_module_from_name (pGroupDescription->cGroupName);
1140
 
        if (pModule == NULL)  // c'est un groupe du fichier de conf principal.
1141
 
        {
1142
 
                cConfFilePath = g_cConfFile;
1143
 
                bSingleGroup = TRUE;
1144
 
        }
1145
 
        else  // c'est un module, on recupere son fichier de conf en entier.
1146
 
        {
1147
 
                if (pModule->cConfFilePath == NULL)  // on n'est pas encore passe par la dans le cas ou le plug-in n'a pas ete active; mais on veut pouvoir configurer un plug-in meme lorsqu'il est inactif.
1148
 
                {
1149
 
                        pModule->cConfFilePath = cairo_dock_check_module_conf_file (pModule->pVisitCard);
1150
 
                }
1151
 
                if (pModule->cConfFilePath == NULL)
1152
 
                {
1153
 
                        cd_warning ("couldn't load a conf file for this module => can't configure it.");
1154
 
                        return;
1155
 
                }
1156
 
                
1157
 
                pModuleInstance = (pModule->pInstancesList != NULL ? pModule->pInstancesList->data : NULL);
1158
 
                cConfFilePath = (pModuleInstance != NULL ? pModuleInstance->cConfFilePath : pModule->cConfFilePath);
1159
 
                
1160
 
                bSingleGroup = FALSE;
1161
 
        }
1162
 
        
1163
 
        cairo_dock_present_group_widget (cConfFilePath, pGroupDescription, bSingleGroup, pModuleInstance);
1164
 
}
1165
 
 
1166
 
void cairo_dock_free_categories (void)
1167
 
{
1168
 
        memset (s_pCategoryWidgetTables, 0, sizeof (s_pCategoryWidgetTables));  // les widgets a l'interieur sont detruits avec la fenetre.
1169
 
        
1170
 
        CairoDockGroupDescription *pGroupDescription;
1171
 
        GList *pElement;
1172
 
        for (pElement = s_pGroupDescriptionList; pElement != NULL; pElement = pElement->next)  /// utile de supprimer cette liste ? ...
1173
 
        {
1174
 
                pGroupDescription = pElement->data;
1175
 
                g_free (pGroupDescription->cGroupName);
1176
 
                g_free (pGroupDescription->cDescription);
1177
 
                g_free (pGroupDescription->cPreviewFilePath);
1178
 
        }
1179
 
        g_list_free (s_pGroupDescriptionList);
1180
 
        s_pGroupDescriptionList = NULL;
1181
 
        
1182
 
        s_pPreviewImage = NULL;
1183
 
        
1184
 
        s_pOkButton = NULL;
1185
 
        s_pApplyButton = NULL;
1186
 
        
1187
 
        s_pMainWindow = NULL;
1188
 
        s_pToolBar = NULL;
1189
 
        s_pStatusBar = NULL;
1190
 
        
1191
 
        if (s_pCurrentGroup != NULL)
1192
 
        {
1193
 
                g_free (s_pCurrentGroup->cConfFilePath);
1194
 
                s_pCurrentGroup->cConfFilePath = NULL;
1195
 
                s_pCurrentGroup = NULL;
1196
 
        }
1197
 
        _cairo_dock_reset_current_widget_list ();
1198
 
        s_pCurrentGroupWidget = NULL;  // detruit en meme temps que la fenetre.
1199
 
        g_slist_free (s_path);
1200
 
        s_path = NULL;
1201
 
}
1202
 
 
1203
 
 
1204
 
 
1205
 
void cairo_dock_write_current_group_conf_file (gchar *cConfFilePath, CairoDockModuleInstance *pInstance)
1206
 
{
1207
 
        g_return_if_fail (cConfFilePath != NULL && s_pCurrentWidgetList != NULL);
1208
 
        GKeyFile *pKeyFile = cairo_dock_open_key_file (cConfFilePath);
1209
 
        if (pKeyFile == NULL)
1210
 
                return ;
1211
 
 
1212
 
        cairo_dock_update_keyfile_from_widget_list (pKeyFile, s_pCurrentWidgetList);
1213
 
        if (pInstance != NULL && pInstance->pModule->pInterface->save_custom_widget != NULL)
1214
 
                pInstance->pModule->pInterface->save_custom_widget (pInstance, pKeyFile);
1215
 
        cairo_dock_write_keys_to_file (pKeyFile, cConfFilePath);
1216
 
        g_key_file_free (pKeyFile);
1217
 
}
1218
 
 
1219
 
void cairo_dock_write_extra_group_conf_file (gchar *cConfFilePath, CairoDockModuleInstance *pInstance, int iNumExtraModule)
1220
 
{
1221
 
        g_return_if_fail (cConfFilePath != NULL && s_pExtraCurrentWidgetList != NULL);
1222
 
        GSList *pWidgetList = g_slist_nth_data  (s_pExtraCurrentWidgetList, iNumExtraModule);
1223
 
        g_return_if_fail (pWidgetList != NULL);
1224
 
 
1225
 
        GKeyFile *pKeyFile = cairo_dock_open_key_file (cConfFilePath);
1226
 
        if (pKeyFile == NULL)
1227
 
                return ;
1228
 
        
1229
 
        cairo_dock_update_keyfile_from_widget_list (pKeyFile, pWidgetList);
1230
 
        if (pInstance != NULL && pInstance->pModule->pInterface->save_custom_widget != NULL)
1231
 
                pInstance->pModule->pInterface->save_custom_widget (pInstance, pKeyFile);
1232
 
        cairo_dock_write_keys_to_file (pKeyFile, cConfFilePath);
1233
 
        g_key_file_free (pKeyFile);
1234
 
}
1235
 
 
1236
 
 
1237
 
 
1238
 
gboolean cairo_dock_build_normal_gui (gchar *cConfFilePath, const gchar *cGettextDomain, const gchar *cTitle, int iWidth, int iHeight, CairoDockApplyConfigFunc pAction, gpointer pUserData, GFreeFunc pFreeUserData, GtkWidget **pWindow)
1239
 
{
1240
 
        //\_____________ On construit la fenetre.
1241
 
        GtkWidget *pMainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1242
 
        gtk_window_set_icon_from_file (GTK_WINDOW (pMainWindow), CAIRO_DOCK_SHARE_DATA_DIR"/"CAIRO_DOCK_ICON, NULL);
1243
 
        if (cTitle != NULL)
1244
 
                gtk_window_set_title (GTK_WINDOW (pMainWindow), cTitle);
1245
 
        
1246
 
        GtkWidget *pMainVBox = gtk_vbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN);
1247
 
        gtk_container_add (GTK_CONTAINER (pMainWindow), pMainVBox);
1248
 
        
1249
 
        //\_____________ On construit l'IHM du fichier de conf.
1250
 
        GSList *pWidgetList = NULL;
1251
 
        GPtrArray *pDataGarbage = g_ptr_array_new ();
1252
 
        GtkWidget *pNoteBook = cairo_dock_build_conf_file_widget (cConfFilePath,
1253
 
                cGettextDomain,
1254
 
                pMainWindow,
1255
 
                &pWidgetList,
1256
 
                pDataGarbage,
1257
 
                NULL);
1258
 
        gtk_box_pack_start (GTK_BOX (pMainVBox),
1259
 
                pNoteBook,
1260
 
                TRUE,
1261
 
                TRUE,
1262
 
                0);
1263
 
        
1264
 
        //\_____________ On ajoute les boutons.
1265
 
        GtkWidget *pButtonsHBox = gtk_hbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN*2);
1266
 
        gtk_box_pack_end (GTK_BOX (pMainVBox),
1267
 
                pButtonsHBox,
1268
 
                FALSE,
1269
 
                FALSE,
1270
 
                0);
1271
 
        
1272
 
        GtkWidget *pQuitButton = gtk_button_new_from_stock (GTK_STOCK_QUIT);
1273
 
        g_signal_connect (G_OBJECT (pQuitButton), "clicked", G_CALLBACK(on_click_normal_quit), pMainWindow);
1274
 
        gtk_box_pack_end (GTK_BOX (pButtonsHBox),
1275
 
                pQuitButton,
1276
 
                FALSE,
1277
 
                FALSE,
1278
 
                0);
1279
 
        
1280
 
        if (pAction != NULL)
1281
 
        {
1282
 
                GtkWidget *pApplyButton = gtk_button_new_from_stock (GTK_STOCK_APPLY);
1283
 
                g_signal_connect (G_OBJECT (pApplyButton), "clicked", G_CALLBACK(on_click_normal_apply), pMainWindow);
1284
 
                gtk_box_pack_end (GTK_BOX (pButtonsHBox),
1285
 
                        pApplyButton,
1286
 
                        FALSE,
1287
 
                        FALSE,
1288
 
                        0);
 
101
void cairo_dock_reload_current_module_widget_full (CairoDockModuleInstance *pInstance, int iShowPage)
 
102
{
 
103
        g_return_if_fail (pInstance != NULL);
 
104
        if (pInstance->pModule->pVisitCard->cInternalModule != NULL)
 
105
        {
 
106
                cairo_dock_show_module_gui (pInstance->pModule->pVisitCard->cInternalModule);
1289
107
        }
1290
108
        else
1291
109
        {
1292
 
                GtkWidget *pOkButton = gtk_button_new_from_stock (GTK_STOCK_OK);
1293
 
                g_signal_connect (G_OBJECT (pOkButton), "clicked", G_CALLBACK(on_click_normal_ok), pMainWindow);
1294
 
                gtk_box_pack_end (GTK_BOX (pButtonsHBox),
1295
 
                        pOkButton,
1296
 
                        FALSE,
1297
 
                        FALSE,
1298
 
                        0);
1299
 
        }
1300
 
        
1301
 
        //\_____________ On ajoute la barre d'etat a la fin.
1302
 
        GtkWidget *pStatusBar = gtk_statusbar_new ();
1303
 
        gtk_box_pack_start (GTK_BOX (pButtonsHBox),  // pMainVBox
1304
 
                pStatusBar,
1305
 
                FALSE,
1306
 
                FALSE,
1307
 
                0);
1308
 
        g_object_set_data (G_OBJECT (pMainWindow), "status-bar", pStatusBar);
1309
 
        
1310
 
        gtk_window_resize (GTK_WINDOW (pMainWindow), iWidth, iHeight);
1311
 
        
1312
 
        gtk_widget_show_all (pMainWindow);
1313
 
        cairo_dock_dialog_window_created ();
1314
 
        
1315
 
        g_object_set_data (G_OBJECT (pMainWindow), "conf-file", g_strdup (cConfFilePath));
1316
 
        g_object_set_data (G_OBJECT (pMainWindow), "widget-list", pWidgetList);
1317
 
        g_object_set_data (G_OBJECT (pMainWindow), "garbage", pDataGarbage);
1318
 
        int iResult = 0;
1319
 
        if (pAction != NULL)
1320
 
        {
1321
 
                g_object_set_data (G_OBJECT (pMainWindow), "action", pAction);
1322
 
                g_object_set_data (G_OBJECT (pMainWindow), "action-data", pUserData);
1323
 
                g_object_set_data (G_OBJECT (pMainWindow), "free-data", pFreeUserData);
1324
 
                g_signal_connect (G_OBJECT (pMainWindow),
1325
 
                        "delete-event",
1326
 
                        G_CALLBACK (on_delete_normal_gui),
1327
 
                        NULL);
1328
 
                if (pWindow)
1329
 
                        *pWindow = pMainWindow;
1330
 
        }
1331
 
        else  // on bloque.
1332
 
        {
1333
 
                gtk_window_set_modal (GTK_WINDOW (pMainWindow), TRUE);
1334
 
                GMainLoop *pBlockingLoop = g_main_loop_new (NULL, FALSE);
1335
 
                g_object_set_data (G_OBJECT (pMainWindow), "loop", pBlockingLoop);
1336
 
                g_signal_connect (G_OBJECT (pMainWindow),
1337
 
                        "delete-event",
1338
 
                        G_CALLBACK (on_delete_normal_gui),
1339
 
                        pBlockingLoop);
1340
 
 
1341
 
                g_print ("debut de boucle bloquante ...\n");
1342
 
                GDK_THREADS_LEAVE ();
1343
 
                g_main_loop_run (pBlockingLoop);
1344
 
                GDK_THREADS_ENTER ();
1345
 
                g_print ("fin de boucle bloquante\n");
1346
 
                
1347
 
                g_main_loop_unref (pBlockingLoop);
1348
 
                g_object_set_data (G_OBJECT (pMainWindow), "loop", NULL);
1349
 
                
1350
 
                iResult = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (pMainWindow), "result"));
1351
 
                cd_debug ("iResult : %d", iResult);
1352
 
                gtk_widget_destroy (pMainWindow);
1353
 
                if (pWindow)
1354
 
                        *pWindow = NULL;
1355
 
        }
1356
 
        
1357
 
        return iResult;
1358
 
}
1359
 
 
1360
 
 
1361
 
gpointer cairo_dock_get_previous_widget (void)
1362
 
{
1363
 
        if (s_path == NULL || s_path->next == NULL)
1364
 
        {
1365
 
                if (s_path != NULL)  // utile ?...
1366
 
                {
1367
 
                        g_slist_free (s_path);
1368
 
                        s_path = NULL;
1369
 
                }
1370
 
                return 0;
1371
 
        }
1372
 
        
1373
 
        //s_path = g_list_delete_link (s_path, s_path);
1374
 
        GSList *tmp = s_path;
1375
 
        s_path = s_path->next;
1376
 
        tmp->next = NULL;
1377
 
        g_slist_free (tmp);
1378
 
        
1379
 
        return s_path->data;
1380
 
}
1381
 
 
1382
 
gpointer cairo_dock_get_current_widget (void)
1383
 
{
1384
 
        if (s_path == NULL)
1385
 
        {
1386
 
                return 0;
1387
 
        }
1388
 
        
1389
 
        return s_path->data;
1390
 
}
1391
 
 
1392
 
 
1393
 
 
1394
 
void cairo_dock_reload_current_group_widget_full (CairoDockModuleInstance *pInstance, int iShowPage)
1395
 
{
1396
 
        g_return_if_fail (s_pCurrentGroupWidget != NULL && s_pCurrentGroup != NULL && s_pCurrentWidgetList != NULL);
 
110
                cairo_dock_show_module_instance_gui (pInstance, iShowPage);
 
111
        }
 
112
        /**g_return_if_fail (s_pCurrentGroupWidget != NULL && s_pCurrentGroup != NULL && cairo_dock_get_current_widget_list () != NULL);
1397
113
        
1398
114
        int iNotebookPage = (GTK_IS_NOTEBOOK (s_pCurrentGroupWidget) ? 
1399
115
                (iShowPage >= 0 ?
1404
120
        gtk_widget_destroy (s_pCurrentGroupWidget);
1405
121
        s_pCurrentGroupWidget = NULL;
1406
122
        
1407
 
        _cairo_dock_reset_current_widget_list ();
 
123
        cairo_dock_reset_current_widget_list ();
1408
124
        
1409
125
        CairoDockModule *pModule = cairo_dock_find_module_from_name (s_pCurrentGroup->cGroupName);
1410
126
        GtkWidget *pWidget;
1419
135
        if (iNotebookPage != -1)
1420
136
        {
1421
137
                gtk_notebook_set_current_page (GTK_NOTEBOOK (s_pCurrentGroupWidget), iNotebookPage);
1422
 
        }
1423
 
}
1424
 
 
1425
 
GtkWidget *cairo_dock_get_widget_from_name (const gchar *cGroupName, const gchar *cKeyName)
1426
 
{
1427
 
        g_return_val_if_fail (s_pCurrentWidgetList != NULL, NULL);
1428
 
        GtkWidget *pWidget = cairo_dock_find_widget_from_name (s_pCurrentWidgetList, cGroupName, cKeyName);
1429
 
        if (pWidget == NULL && s_pExtraCurrentWidgetList != NULL)
1430
 
        {
1431
 
                GSList *l;
1432
 
                for (l = s_pExtraCurrentWidgetList; l != NULL; l = l->next)
1433
 
                {
1434
 
                        pWidget = cairo_dock_find_widget_from_name (l->data, cGroupName, cKeyName);
1435
 
                        if (pWidget != NULL)
1436
 
                                break ;
1437
 
                }
1438
 
        }
1439
 
        return pWidget;
1440
 
}
1441
 
 
1442
 
 
1443
 
 
1444
 
void cairo_dock_apply_current_filter (gchar **pKeyWords, gboolean bAllWords, gboolean bSearchInToolTip, gboolean bHighLightText, gboolean bHideOther)
1445
 
{
1446
 
        cd_debug ("");
1447
 
        if (s_pCurrentGroup != NULL)
1448
 
        {
1449
 
                cairo_dock_apply_filter_on_group_widget (pKeyWords, bAllWords, bSearchInToolTip, bHighLightText, bHideOther, s_pCurrentWidgetList);
1450
 
                if (s_pExtraCurrentWidgetList != NULL)
1451
 
                {
1452
 
                        GSList *l;
1453
 
                        for (l = s_pExtraCurrentWidgetList; l != NULL; l = l->next)
1454
 
                        {
1455
 
                                cairo_dock_apply_filter_on_group_widget (pKeyWords, bAllWords, bSearchInToolTip, bHighLightText, bHideOther, l->data);
1456
 
                        }
1457
 
                }
1458
 
        }
1459
 
        else
1460
 
        {
1461
 
                cairo_dock_apply_filter_on_group_list (pKeyWords, bAllWords, bSearchInToolTip, bHighLightText, bHideOther, s_pGroupDescriptionList);
1462
 
        }
1463
 
}
1464
 
 
1465
 
void cairo_dock_trigger_current_filter (void)
1466
 
{
1467
 
        gboolean bReturn;
1468
 
        g_signal_emit_by_name (s_pFilterEntry, "activate", NULL, &bReturn);
1469
 
}
1470
 
 
 
138
        }*/
 
139
}
1471
140
 
1472
141
 
1473
142
void cairo_dock_deactivate_module_in_gui (const gchar *cModuleName)
1474
143
{
1475
 
        if (s_pMainWindow == NULL || cModuleName == NULL)
1476
 
                return ;
1477
 
        
1478
 
        if (s_pCurrentGroup != NULL && s_pCurrentGroup->cGroupName != NULL && strcmp (cModuleName, s_pCurrentGroup->cGroupName) == 0)  // on est en train d'editer ce module dans le panneau de conf.
1479
 
        {
1480
 
                g_signal_handlers_block_by_func (s_pActivateButton, on_click_activate_current_group, NULL);
1481
 
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (s_pActivateButton), FALSE);
1482
 
                g_signal_handlers_unblock_by_func (s_pActivateButton, on_click_activate_current_group, NULL);
1483
 
        }
1484
 
        
1485
 
        CairoDockGroupDescription *pGroupDescription = cairo_dock_find_module_description (cModuleName);
1486
 
        g_return_if_fail (pGroupDescription != NULL && pGroupDescription->pActivateButton != NULL);
1487
 
        g_signal_handlers_block_by_func (pGroupDescription->pActivateButton, on_click_activate_given_group, pGroupDescription);
1488
 
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pGroupDescription->pActivateButton), FALSE);
1489
 
        g_signal_handlers_unblock_by_func (pGroupDescription->pActivateButton, on_click_activate_given_group, pGroupDescription);
1490
 
}
1491
 
 
1492
 
void cairo_dock_update_desklet_size_in_gui (const gchar *cModuleName, int iWidth, int iHeight)
1493
 
{
1494
 
        if (s_pMainWindow == NULL || cModuleName == NULL || s_pCurrentGroup == NULL || s_pCurrentGroup->cGroupName == NULL || s_pCurrentWidgetList == NULL)
1495
 
                return ;
1496
 
        
1497
 
        if (strcmp (cModuleName, s_pCurrentGroup->cGroupName) == 0)  // on est en train d'editer ce module dans le panneau de conf.
1498
 
        {
 
144
        if (s_pGuiBackend && s_pGuiBackend->deactivate_module_in_gui)
 
145
                s_pGuiBackend->deactivate_module_in_gui (cModuleName);
 
146
}
 
147
 
 
148
static gboolean _cairo_dock_module_is_opened (CairoDockModuleInstance *pModuleInstance)
 
149
{
 
150
        if (s_pGuiBackend && s_pGuiBackend->module_is_opened)
 
151
                return s_pGuiBackend->module_is_opened (pModuleInstance);
 
152
        else
 
153
                return FALSE;
 
154
}
 
155
 
 
156
void cairo_dock_update_desklet_size_in_gui (CairoDockModuleInstance *pModuleInstance, int iWidth, int iHeight)
 
157
{
 
158
        if (_cairo_dock_module_is_opened (pModuleInstance))  // on est en train d'editer ce module dans le panneau de conf.
 
159
        {
 
160
                GSList *pSubWidgetList = NULL;
1499
161
                GtkWidget *pOneWidget;
1500
 
                GSList *pSubWidgetList = cairo_dock_find_widgets_from_name (s_pCurrentWidgetList, "Desklet", "size");
 
162
                if (s_pGuiBackend && s_pGuiBackend->get_widgets_from_name)
 
163
                        pSubWidgetList = s_pGuiBackend->get_widgets_from_name ("Desklet", "size");
 
164
                
1501
165
                if (pSubWidgetList != NULL)
1502
166
                {
1503
167
                        pOneWidget = pSubWidgetList->data;
1525
189
        }
1526
190
}
1527
191
 
1528
 
void cairo_dock_update_desklet_position_in_gui (const gchar *cModuleName, int x, int y)
 
192
void cairo_dock_update_desklet_position_in_gui (CairoDockModuleInstance *pModuleInstance, int x, int y)
1529
193
{
1530
 
        if (s_pMainWindow == NULL || cModuleName == NULL || s_pCurrentGroup == NULL || s_pCurrentGroup->cGroupName == NULL || s_pCurrentWidgetList == NULL)
1531
 
                return ;
1532
 
        
1533
 
        if (strcmp (cModuleName, s_pCurrentGroup->cGroupName) == 0)  // on est en train d'editer ce module dans le panneau de conf.
 
194
        if (_cairo_dock_module_is_opened (pModuleInstance))  // on est en train d'editer ce module dans le panneau de conf.
1534
195
        {
1535
196
                GtkWidget *pOneWidget;
1536
197
                pOneWidget = cairo_dock_get_widget_from_name ("Desklet", "x position");
1542
203
        }
1543
204
}
1544
205
 
 
206
void cairo_dock_update_desklet_detached_state_in_gui (CairoDockModuleInstance *pModuleInstance, gboolean bIsDetached)
 
207
{
 
208
        if (_cairo_dock_module_is_opened (pModuleInstance))  // on est en train d'editer ce module dans le panneau de conf.
 
209
        {
 
210
                GtkWidget *pOneWidget = cairo_dock_get_widget_from_name ("Desklet", "initially detached");
 
211
                if (pOneWidget != NULL)
 
212
                        gtk_toggle_button_set_active  (GTK_TOGGLE_BUTTON (pOneWidget), bIsDetached);
 
213
        }
 
214
}
 
215
 
 
216
 
1545
217
void cairo_dock_set_status_message (GtkWidget *pWindow, const gchar *cMessage)
1546
218
{
 
219
        g_print ("%s (%s)\n", __func__, cMessage);
1547
220
        GtkWidget *pStatusBar;
1548
 
        if (pWindow == NULL)
1549
 
                pStatusBar = s_pStatusBar;
1550
 
        else
 
221
        if (pWindow != NULL)
 
222
        {
1551
223
                pStatusBar = g_object_get_data (G_OBJECT (pWindow), "status-bar");
1552
 
        if (pStatusBar == NULL)
1553
 
                return ;
1554
 
        //g_print ("%s (%s sur %x/%x)\n", __func__, cMessage, pWindow, pStatusBar);
1555
 
        gtk_statusbar_pop (GTK_STATUSBAR (pStatusBar), 0);  // clear any previous message, underflow is allowed.
1556
 
        gtk_statusbar_push (GTK_STATUSBAR (pStatusBar), 0, cMessage);
1557
 
        while (gtk_events_pending ())
1558
 
                gtk_main_iteration ();
 
224
                if (pStatusBar == NULL)
 
225
                        return ;
 
226
                //g_print ("%s (%s sur %x/%x)\n", __func__, cMessage, pWindow, pStatusBar);
 
227
                gtk_statusbar_pop (GTK_STATUSBAR (pStatusBar), 0);  // clear any previous message, underflow is allowed.
 
228
                gtk_statusbar_push (GTK_STATUSBAR (pStatusBar), 0, cMessage);
 
229
        }
 
230
        else
 
231
        {
 
232
                if (s_pGuiBackend && s_pGuiBackend->set_status_message_on_gui)
 
233
                        s_pGuiBackend->set_status_message_on_gui (cMessage);
 
234
        }
1559
235
}
 
236
 
1560
237
void cairo_dock_set_status_message_printf (GtkWidget *pWindow, const gchar *cFormat, ...)
1561
238
{
1562
 
        if (pWindow == NULL && s_pStatusBar == NULL)
1563
 
                return ;
1564
239
        g_return_if_fail (cFormat != NULL);
1565
240
        va_list args;
1566
241
        va_start (args, cFormat);
1571
246
}
1572
247
 
1573
248
 
1574
 
 
1575
 
static GtkWidget *s_pLauncherWindow = NULL;
1576
 
static GtkWidget *s_pCurrentLauncherWidget = NULL;
1577
 
static GtkWidget *s_pLauncherTreeView = NULL;
1578
 
static GtkWidget *s_pLauncherPane = NULL;
1579
 
static GtkWidget *s_pLauncherScrolledWindow = NULL;
1580
 
 
1581
 
static gboolean _search_icon_in_line (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer *data)
1582
 
{
1583
 
        Icon *pIcon = NULL;
1584
 
        gtk_tree_model_get (model, iter,
1585
 
                2, &pIcon, -1);
1586
 
        if (pIcon == data[0])
1587
 
        {
1588
 
                g_print (" found !\n");
1589
 
                memcpy (data[1], iter, sizeof (GtkTreeIter));
1590
 
                data[2] = GINT_TO_POINTER (TRUE);
1591
 
                return TRUE;  // stop iterating.
1592
 
        }
1593
 
        return FALSE;
1594
 
}
1595
 
static gboolean _search_icon_in_model (GtkWidget *pTreeView, Icon *pIcon, GtkTreeIter *iter)
1596
 
{
1597
 
        if (pIcon == NULL)
1598
 
                return FALSE;
1599
 
        g_print ("%s (%s)\n", __func__, pIcon->cName);
1600
 
        GtkTreeModel * model = gtk_tree_view_get_model (GTK_TREE_VIEW (pTreeView));
1601
 
        gpointer data[3] = {pIcon, iter, GINT_TO_POINTER (FALSE)};
1602
 
        gtk_tree_model_foreach (model,
1603
 
                (GtkTreeModelForeachFunc) _search_icon_in_line,
1604
 
                data);
1605
 
        return GPOINTER_TO_INT (data[2]);
1606
 
}
1607
 
 
1608
 
static gboolean _cairo_dock_select_one_launcher_in_tree (GtkTreeSelection * selection, GtkTreeModel * model, GtkTreePath * path, gboolean path_currently_selected, gpointer data)
1609
 
{
1610
 
        g_print ("%s (path_currently_selected:%d)\n", __func__, path_currently_selected);
1611
 
        if (path_currently_selected)
1612
 
                return TRUE;
1613
 
        GtkTreeIter iter;
1614
 
        if (! gtk_tree_model_get_iter (model, &iter, path))
1615
 
                return FALSE;
1616
 
        
1617
 
        cairo_dock_delete_current_launcher_widget ();
1618
 
        
1619
 
        gchar *cName = NULL;
1620
 
        Icon *pIcon = NULL;
1621
 
        gtk_tree_model_get (model, &iter,
1622
 
                0, &cName,
1623
 
                2, &pIcon, -1);
1624
 
        gtk_window_set_title (GTK_WINDOW (s_pLauncherWindow), cName);
1625
 
        g_free (cName);
1626
 
        if (pIcon == NULL)  // ligne correspondante a un dock principal.
1627
 
                return TRUE;
1628
 
        
1629
 
        // on charge son .conf
1630
 
        if (pIcon->cDesktopFileName != NULL)
1631
 
        {
1632
 
                g_print ("on presente %s...\n", pIcon->cDesktopFileName);
1633
 
                gchar *cConfFilePath = (*pIcon->cDesktopFileName == '/' ? g_strdup (pIcon->cDesktopFileName) : g_strdup_printf ("%s/%s", g_cCurrentLaunchersPath, pIcon->cDesktopFileName));
1634
 
                
1635
 
                CairoDockDesktopFileType iLauncherType;
1636
 
                if (CAIRO_DOCK_IS_URI_LAUNCHER (pIcon))
1637
 
                        iLauncherType = CAIRO_DOCK_DESKTOP_FILE_FOR_FILE;
1638
 
                else if (CAIRO_DOCK_IS_SEPARATOR (pIcon))
1639
 
                        iLauncherType = CAIRO_DOCK_DESKTOP_FILE_FOR_SEPARATOR;
1640
 
                else if (pIcon->pSubDock != NULL && pIcon->cClass == NULL)
1641
 
                        iLauncherType = CAIRO_DOCK_DESKTOP_FILE_FOR_CONTAINER;
1642
 
                else 
1643
 
                        iLauncherType = CAIRO_DOCK_DESKTOP_FILE_FOR_LAUNCHER;
1644
 
                cairo_dock_update_launcher_desktop_file (cConfFilePath, iLauncherType);
1645
 
                
1646
 
                GSList *pWidgetList = NULL;
1647
 
                GPtrArray *pDataGarbage = g_ptr_array_new ();
1648
 
                s_pCurrentLauncherWidget = cairo_dock_build_conf_file_widget (cConfFilePath,
1649
 
                        NULL,
1650
 
                        s_pLauncherWindow,
1651
 
                        &pWidgetList,
1652
 
                        pDataGarbage,
1653
 
                        NULL);
1654
 
                
1655
 
                gtk_paned_pack2 (GTK_PANED (s_pLauncherPane), s_pCurrentLauncherWidget, TRUE, FALSE);
1656
 
                
1657
 
                g_object_set_data (G_OBJECT (s_pLauncherWindow), "widget-list", pWidgetList);
1658
 
                g_object_set_data (G_OBJECT (s_pLauncherWindow), "garbage", pDataGarbage);
1659
 
                g_object_set_data (G_OBJECT (s_pLauncherWindow), "current-icon", pIcon);
1660
 
                
1661
 
                g_free (cConfFilePath);
1662
 
                gtk_widget_show_all (s_pCurrentLauncherWidget);
1663
 
        }
1664
 
        else if (CAIRO_DOCK_IS_APPLET (pIcon))
1665
 
        {
1666
 
                GSList *pWidgetList = NULL;
1667
 
                GPtrArray *pDataGarbage = g_ptr_array_new ();
1668
 
                
1669
 
                GKeyFile* pKeyFile = cairo_dock_open_key_file (pIcon->pModuleInstance->cConfFilePath);
1670
 
                g_return_val_if_fail (pKeyFile != NULL, FALSE);
1671
 
                
1672
 
                gchar *cOriginalConfFilePath = g_strdup_printf ("%s/%s", pIcon->pModuleInstance->pModule->pVisitCard->cShareDataDir, pIcon->pModuleInstance->pModule->pVisitCard->cConfFileName);
1673
 
                s_pCurrentLauncherWidget = cairo_dock_build_group_widget (pKeyFile, "Icon", pIcon->pModuleInstance->pModule->pVisitCard->cGettextDomain, s_pLauncherWindow, &pWidgetList, pDataGarbage, cOriginalConfFilePath);
1674
 
                g_free (cOriginalConfFilePath);
1675
 
                
1676
 
                gtk_paned_pack2 (GTK_PANED (s_pLauncherPane), s_pCurrentLauncherWidget, TRUE, FALSE);
1677
 
                
1678
 
                g_object_set_data (G_OBJECT (s_pLauncherWindow), "widget-list", pWidgetList);
1679
 
                g_object_set_data (G_OBJECT (s_pLauncherWindow), "garbage", pDataGarbage);
1680
 
                g_object_set_data (G_OBJECT (s_pLauncherWindow), "current-icon", pIcon);
1681
 
                gtk_widget_show_all (s_pCurrentLauncherWidget);
1682
 
        }
1683
 
        return TRUE;
1684
 
}
1685
 
 
1686
 
static void _cairo_dock_add_one_sub_dock_to_model (CairoDock *pDock, GtkTreeStore *model, GtkTreeIter *pParentIter)
1687
 
{
1688
 
        GtkTreeIter iter;
1689
 
        GList *ic;
1690
 
        Icon *pIcon;
1691
 
        GError *erreur = NULL;
1692
 
        GdkPixbuf *pixbuf = NULL;
1693
 
        gchar *cImagePath = NULL;
1694
 
        for (ic = pDock->icons; ic != NULL; ic = ic->next)
1695
 
        {
1696
 
                pIcon = ic->data;
1697
 
                if (! CAIRO_DOCK_IS_LAUNCHER (pIcon) && ! CAIRO_DOCK_IS_USER_SEPARATOR (pIcon) && ! CAIRO_DOCK_IS_APPLET (pIcon))
1698
 
                        continue;
1699
 
                
1700
 
                if (pIcon->fPersonnalScale > 0)
1701
 
                        continue;
1702
 
                
1703
 
                if (pIcon->cFileName != NULL)
1704
 
                {
1705
 
                        cImagePath = cairo_dock_search_icon_s_path (pIcon->cFileName);
1706
 
                }
1707
 
                if (cImagePath == NULL || ! g_file_test (cImagePath, G_FILE_TEST_EXISTS))
1708
 
                {
1709
 
                        g_free (cImagePath);
1710
 
                        if (CAIRO_DOCK_IS_SEPARATOR (pIcon))
1711
 
                        {
1712
 
                                cImagePath = cairo_dock_generate_file_path (myIcons.cSeparatorImage);
1713
 
                        }
1714
 
                        else
1715
 
                        {
1716
 
                                cImagePath = cairo_dock_generate_file_path (CAIRO_DOCK_DEFAULT_ICON_NAME);
1717
 
                                if (cImagePath == NULL || ! g_file_test (cImagePath, G_FILE_TEST_EXISTS))
1718
 
                                {
1719
 
                                        g_free (cImagePath);
1720
 
                                        cImagePath = g_strdup (CAIRO_DOCK_SHARE_DATA_DIR"/"CAIRO_DOCK_DEFAULT_ICON_NAME);
1721
 
                                }
1722
 
                        }
1723
 
                }
1724
 
                
1725
 
                if (cImagePath != NULL)
1726
 
                {
1727
 
                        pixbuf = gdk_pixbuf_new_from_file_at_size (cImagePath, 32, 32, &erreur);
1728
 
                        if (erreur != NULL)
1729
 
                        {
1730
 
                                cd_warning (erreur->message);
1731
 
                                g_error_free (erreur);
1732
 
                                erreur = NULL;
1733
 
                        }
1734
 
                }
1735
 
                
1736
 
                gtk_tree_store_append (model, &iter, pParentIter);
1737
 
                gtk_tree_store_set (model, &iter,
1738
 
                        0, CAIRO_DOCK_IS_USER_SEPARATOR (pIcon) ? "separator" : (pIcon->cInitialName ? pIcon->cInitialName : pIcon->cName),
1739
 
                        1, pixbuf,
1740
 
                        2, pIcon,
1741
 
                        -1);
1742
 
                
1743
 
                if (CAIRO_DOCK_IS_LAUNCHER (pIcon) && pIcon->pSubDock != NULL && ! CAIRO_DOCK_IS_URI_LAUNCHER (pIcon))
1744
 
                {
1745
 
                        _cairo_dock_add_one_sub_dock_to_model (pIcon->pSubDock, model, &iter);
1746
 
                }
1747
 
                
1748
 
                g_free (cImagePath);
1749
 
                cImagePath = NULL;
1750
 
                if (pixbuf)
1751
 
                        g_object_unref (pixbuf);
1752
 
                pixbuf = NULL;
1753
 
        }
1754
 
}
1755
 
static void _cairo_dock_add_one_root_dock_to_model (const gchar *cName, CairoDock *pDock, GtkTreeStore *model)
1756
 
{
1757
 
        if (pDock->iRefCount != 0)
1758
 
                return ;
1759
 
        GtkTreeIter iter;
1760
 
        
1761
 
        // on ajoute une ligne pour le dock.
1762
 
        gtk_tree_store_append (model, &iter, NULL);
1763
 
    gtk_tree_store_set (model, &iter,
1764
 
                        0, cName,
1765
 
                        2, NULL,
1766
 
                        -1);
1767
 
        
1768
 
        // on ajoute chaque lanceur.
1769
 
        _cairo_dock_add_one_sub_dock_to_model (pDock, model, &iter);
1770
 
}
1771
 
static GtkTreeModel *_cairo_dock_build_tree_model (void)
1772
 
{
1773
 
        GtkTreeStore *model = gtk_tree_store_new (3,
1774
 
                G_TYPE_STRING,
1775
 
                GDK_TYPE_PIXBUF,
1776
 
                G_TYPE_POINTER);  // nom du lanceur, image, Icon.
1777
 
        cairo_dock_foreach_docks ((GHFunc) _cairo_dock_add_one_root_dock_to_model, model);
1778
 
        return GTK_TREE_MODEL (model);
1779
 
}
1780
 
 
1781
 
static inline void _select_item (Icon *pIcon)
1782
 
{
1783
 
        GtkTreeIter iter;
1784
 
        if (_search_icon_in_model (s_pLauncherTreeView, pIcon, &iter))
1785
 
        {
1786
 
                GtkTreeModel * model = gtk_tree_view_get_model (GTK_TREE_VIEW (s_pLauncherTreeView));
1787
 
                GtkTreePath *path =  gtk_tree_model_get_path (model, &iter);
1788
 
                gtk_tree_view_expand_to_path (GTK_TREE_VIEW (s_pLauncherTreeView), path);
1789
 
                gtk_tree_path_free (path);
1790
 
                
1791
 
                GtkTreeSelection *pSelection = gtk_tree_view_get_selection (GTK_TREE_VIEW (s_pLauncherTreeView));
1792
 
                gtk_tree_selection_select_iter (pSelection, &iter);
1793
 
        }
1794
 
        else
1795
 
        {
1796
 
                gtk_window_set_title (GTK_WINDOW (s_pLauncherWindow), _("Configuration of the launchers"));
1797
 
        }
1798
 
}
 
249
  /////////////////
 
250
 // GUI BACKEND //
 
251
/////////////////
 
252
 
 
253
void cairo_dock_register_gui_backend (CairoDockGuiBackend *pBackend)
 
254
{
 
255
        g_free (s_pGuiBackend);
 
256
        s_pGuiBackend = pBackend;
 
257
}
 
258
 
 
259
GtkWidget *cairo_dock_show_main_gui (void)
 
260
{
 
261
        GtkWidget *pWindow = NULL;
 
262
        if (s_pGuiBackend && s_pGuiBackend->show_main_gui)
 
263
                pWindow = s_pGuiBackend->show_main_gui ();
 
264
        if (pWindow && g_pMainDock != NULL && ! myAccessibility.bReserveSpace)  // evitons d'empieter sur le dock.
 
265
        {
 
266
                if (g_pMainDock->container.bIsHorizontal)
 
267
                {
 
268
                        if (g_pMainDock->container.bDirectionUp)
 
269
                                gtk_window_move (GTK_WINDOW (pWindow), 0, 0);
 
270
                        else
 
271
                                gtk_window_move (GTK_WINDOW (pWindow), 0, g_pMainDock->iMinDockHeight+10);
 
272
                }
 
273
                else
 
274
                {
 
275
                        if (g_pMainDock->container.bDirectionUp)
 
276
                                gtk_window_move (GTK_WINDOW (pWindow), 0, 0);
 
277
                        else
 
278
                                gtk_window_move (GTK_WINDOW (pWindow), g_pMainDock->iMinDockHeight+10, 0);
 
279
                }
 
280
        }
 
281
        
 
282
        gchar *cModeFile = g_strdup_printf ("%s/%s", g_cCairoDockDataDir, ".config-mode");
 
283
        if (! g_file_test (cModeFile, G_FILE_TEST_EXISTS))
 
284
        {
 
285
                g_file_set_contents (cModeFile,
 
286
                        "0",
 
287
                        -1,
 
288
                        NULL);
 
289
                Icon *pIcon = cairo_dock_get_dialogless_icon ();
 
290
                cairo_dock_show_temporary_dialog_with_default_icon (_("This is the simple config panel of Cairo-Dock.\n After you got familiar with it, and if you want to customise your theme\n, you can switch to an advanced mode.\n You can switch from a mode to another at any time."), pIcon, CAIRO_CONTAINER (g_pMainDock), 15000);
 
291
        }
 
292
        g_free (cModeFile);
 
293
        return pWindow;
 
294
}
 
295
 
 
296
void cairo_dock_show_module_instance_gui (CairoDockModuleInstance *pModuleInstance, int iShowPage)
 
297
{
 
298
        if (s_pGuiBackend && s_pGuiBackend->show_module_instance_gui)
 
299
                s_pGuiBackend->show_module_instance_gui (pModuleInstance, iShowPage);
 
300
}
 
301
 
 
302
void cairo_dock_show_module_gui (const gchar *cModuleName)
 
303
{
 
304
        if (s_pGuiBackend && s_pGuiBackend->show_module_gui)
 
305
                s_pGuiBackend->show_module_gui (cModuleName);
 
306
}
 
307
 
 
308
void cairo_dock_close_gui (void)
 
309
{
 
310
        if (s_pGuiBackend && s_pGuiBackend->close_gui)
 
311
                s_pGuiBackend->close_gui ();
 
312
}
 
313
 
 
314
 
 
315
  ////////////////
 
316
 // NORMAL GUI //
 
317
////////////////
 
318
 
 
319
static gboolean on_delete_generic_gui (GtkWidget *pWidget, GdkEvent *event, GMainLoop *pBlockingLoop)
 
320
{
 
321
        g_print ("%s ()\n", __func__);
 
322
        if (pBlockingLoop != NULL && g_main_loop_is_running (pBlockingLoop))
 
323
        {
 
324
                g_main_loop_quit (pBlockingLoop);
 
325
        }
 
326
        
 
327
        gpointer pUserData = g_object_get_data (G_OBJECT (pWidget), "action-data");
 
328
        GFreeFunc pFreeUserData = g_object_get_data (G_OBJECT (pWidget), "free-data");
 
329
        if (pFreeUserData != NULL)
 
330
                pFreeUserData (pUserData);
 
331
        
 
332
        GSList *pWidgetList = g_object_get_data (G_OBJECT (pWidget), "widget-list");
 
333
        cairo_dock_free_generated_widget_list (pWidgetList);
 
334
        
 
335
        GPtrArray *pDataGarbage = g_object_get_data (G_OBJECT (pWidget), "garbage");
 
336
        /// nettoyer.
 
337
        
 
338
        gchar *cConfFilePath = g_object_get_data (G_OBJECT (pWidget), "conf-file");
 
339
        g_free (cConfFilePath);
 
340
        
 
341
        cairo_dock_dialog_window_destroyed ();
 
342
        
 
343
        return (pBlockingLoop != NULL);  // TRUE <=> ne pas detruire la fenetre.
 
344
}
 
345
 
 
346
static void on_click_generic_apply (GtkButton *button, GtkWidget *pWindow)
 
347
{
 
348
        //g_print ("%s ()\n", __func__);
 
349
        GSList *pWidgetList = g_object_get_data (G_OBJECT (pWindow), "widget-list");
 
350
        gchar *cConfFilePath = g_object_get_data (G_OBJECT (pWindow), "conf-file");
 
351
        GKeyFile *pKeyFile = cairo_dock_open_key_file (cConfFilePath);
 
352
        g_return_if_fail (pKeyFile != NULL);
 
353
        
 
354
        cairo_dock_update_keyfile_from_widget_list (pKeyFile, pWidgetList);
 
355
        cairo_dock_write_keys_to_file (pKeyFile, cConfFilePath);
 
356
        g_key_file_free (pKeyFile);
 
357
        
 
358
        CairoDockApplyConfigFunc pAction = g_object_get_data (G_OBJECT (pWindow), "action");
 
359
        gpointer pUserData = g_object_get_data (G_OBJECT (pWindow), "action-data");
 
360
        
 
361
        if (pAction != NULL)
 
362
        {
 
363
                gboolean bKeepWindow = pAction (pUserData);
 
364
                if (!bKeepWindow)  // on recharge la fenetre.
 
365
                {
 
366
                        cairo_dock_reload_generic_gui (pWindow);
 
367
                }
 
368
        }
 
369
        else
 
370
                g_object_set_data (G_OBJECT (pWindow), "result", GINT_TO_POINTER (1));
 
371
}
 
372
 
 
373
static void on_click_generic_quit (GtkButton *button, GtkWidget *pWindow)
 
374
{
 
375
        g_print ("%s ()\n", __func__);
 
376
        GMainLoop *pBlockingLoop = g_object_get_data (G_OBJECT (pWindow), "loop");
 
377
        
 
378
        gboolean bReturn;
 
379
        g_signal_emit_by_name (pWindow, "delete-event", NULL, &bReturn);
 
380
        ///on_delete_generic_gui (pWindow, NULL, pBlockingLoop);
 
381
        
 
382
        if (pBlockingLoop == NULL)
 
383
                gtk_widget_destroy (pWindow);
 
384
}
 
385
 
 
386
static void on_click_generic_ok (GtkButton *button, GtkWidget *pWindow)
 
387
{
 
388
        //g_print ("%s ()\n", __func__);
 
389
        
 
390
        on_click_generic_apply (button, pWindow);
 
391
        on_click_generic_quit (button, pWindow);
 
392
}
 
393
 
 
394
GtkWidget *cairo_dock_build_generic_gui_window (const gchar *cTitle, int iWidth, int iHeight, CairoDockApplyConfigFunc pAction, gpointer pUserData, GFreeFunc pFreeUserData)
 
395
{
 
396
        //\_____________ On construit la fenetre.
 
397
        GtkWidget *pMainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
398
        gtk_window_set_icon_from_file (GTK_WINDOW (pMainWindow), CAIRO_DOCK_SHARE_DATA_DIR"/"CAIRO_DOCK_ICON, NULL);
 
399
        if (cTitle != NULL)
 
400
                gtk_window_set_title (GTK_WINDOW (pMainWindow), cTitle);
 
401
        
 
402
        GtkWidget *pMainVBox = gtk_vbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN);
 
403
        gtk_container_add (GTK_CONTAINER (pMainWindow), pMainVBox);
 
404
        
 
405
        //\_____________ On ajoute les boutons.
 
406
        GtkWidget *pButtonsHBox = gtk_hbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN*2);
 
407
        gtk_box_pack_end (GTK_BOX (pMainVBox),
 
408
                pButtonsHBox,
 
409
                FALSE,
 
410
                FALSE,
 
411
                0);
 
412
        
 
413
        GtkWidget *pQuitButton = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
 
414
        g_signal_connect (G_OBJECT (pQuitButton), "clicked", G_CALLBACK(on_click_generic_quit), pMainWindow);
 
415
        gtk_box_pack_end (GTK_BOX (pButtonsHBox),
 
416
                pQuitButton,
 
417
                FALSE,
 
418
                FALSE,
 
419
                0);
 
420
        
 
421
        if (pAction != NULL)
 
422
        {
 
423
                GtkWidget *pApplyButton = gtk_button_new_from_stock (GTK_STOCK_APPLY);
 
424
                g_signal_connect (G_OBJECT (pApplyButton), "clicked", G_CALLBACK(on_click_generic_apply), pMainWindow);
 
425
                gtk_box_pack_end (GTK_BOX (pButtonsHBox),
 
426
                        pApplyButton,
 
427
                        FALSE,
 
428
                        FALSE,
 
429
                        0);
 
430
        }
 
431
        else
 
432
        {
 
433
                GtkWidget *pApplyButton = gtk_button_new_from_stock (GTK_STOCK_OK);
 
434
                g_signal_connect (G_OBJECT (pApplyButton), "clicked", G_CALLBACK(on_click_generic_ok), pMainWindow);
 
435
                gtk_box_pack_end (GTK_BOX (pButtonsHBox),
 
436
                        pApplyButton,
 
437
                        FALSE,
 
438
                        FALSE,
 
439
                        0);
 
440
        }
 
441
        
 
442
        //\_____________ On ajoute la barre d'etat a la fin.
 
443
        GtkWidget *pStatusBar = gtk_statusbar_new ();
 
444
        gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (pStatusBar), FALSE);
 
445
        gtk_box_pack_start (GTK_BOX (pButtonsHBox),  // pMainVBox
 
446
                pStatusBar,
 
447
                FALSE,
 
448
                FALSE,
 
449
                0);
 
450
        g_object_set_data (G_OBJECT (pMainWindow), "status-bar", pStatusBar);
 
451
        
 
452
        gtk_window_resize (GTK_WINDOW (pMainWindow), iWidth, iHeight);
 
453
        
 
454
        gtk_widget_show_all (pMainWindow);
 
455
        cairo_dock_dialog_window_created ();
 
456
        
 
457
        int iResult = 0;
 
458
        if (pAction != NULL)
 
459
        {
 
460
                g_object_set_data (G_OBJECT (pMainWindow), "action", pAction);
 
461
                g_object_set_data (G_OBJECT (pMainWindow), "action-data", pUserData);
 
462
                g_object_set_data (G_OBJECT (pMainWindow), "free-data", pFreeUserData);
 
463
                g_signal_connect (G_OBJECT (pMainWindow),
 
464
                        "delete-event",
 
465
                        G_CALLBACK (on_delete_generic_gui),
 
466
                        NULL);
 
467
        }
 
468
        return pMainWindow;
 
469
}
 
470
 
 
471
gboolean cairo_dock_build_generic_gui (const gchar *cConfFilePath, const gchar *cGettextDomain, const gchar *cTitle, int iWidth, int iHeight, CairoDockApplyConfigFunc pAction, gpointer pUserData, GFreeFunc pFreeUserData, GtkWidget **pWindow)
 
472
{
 
473
        //\_____________ On construit la fenetre.
 
474
        GtkWidget *pMainWindow = cairo_dock_build_generic_gui_window (cTitle, iWidth, iHeight, pAction, pUserData, pFreeUserData);
 
475
        
 
476
        //\_____________ On construit l'IHM du fichier de conf.
 
477
        GSList *pWidgetList = NULL;
 
478
        GPtrArray *pDataGarbage = g_ptr_array_new ();
 
479
        GtkWidget *pNoteBook = cairo_dock_build_conf_file_widget (cConfFilePath,
 
480
                cGettextDomain,
 
481
                pMainWindow,
 
482
                &pWidgetList,
 
483
                pDataGarbage,
 
484
                NULL);
 
485
        
 
486
        //\_____________ On l'insere dans la fenetre.
 
487
        GtkWidget *pMainVBox = gtk_bin_get_child (GTK_BIN (pMainWindow));
 
488
        gtk_box_pack_start (GTK_BOX (pMainVBox),
 
489
                pNoteBook,
 
490
                TRUE,
 
491
                TRUE,
 
492
                0);
 
493
        gtk_widget_show_all (pMainWindow);
 
494
        
 
495
        g_object_set_data (G_OBJECT (pMainWindow), "conf-file", g_strdup (cConfFilePath));
 
496
        g_object_set_data (G_OBJECT (pMainWindow), "widget-list", pWidgetList);
 
497
        g_object_set_data (G_OBJECT (pMainWindow), "garbage", pDataGarbage);
 
498
        
 
499
        int iResult = 0;
 
500
        if (pAction != NULL)
 
501
        {
 
502
                if (pWindow)
 
503
                        *pWindow = pMainWindow;
 
504
        }
 
505
        else  // on bloque.
 
506
        {
 
507
                GList *children = gtk_container_get_children (GTK_CONTAINER (pMainVBox));
 
508
                GList *w = g_list_last (children);
 
509
                g_return_val_if_fail (w != NULL, FALSE);
 
510
                GtkWidget *pButtonsHBox = w->data;
 
511
                
 
512
                GtkWidget *pOkButton = gtk_button_new_from_stock (GTK_STOCK_OK);
 
513
                g_signal_connect (G_OBJECT (pOkButton), "clicked", G_CALLBACK(on_click_generic_ok), pMainWindow);
 
514
                gtk_box_pack_end (GTK_BOX (pButtonsHBox),
 
515
                        pOkButton,
 
516
                        FALSE,
 
517
                        FALSE,
 
518
                        0);
 
519
                
 
520
                gtk_window_set_modal (GTK_WINDOW (pMainWindow), TRUE);
 
521
                GMainLoop *pBlockingLoop = g_main_loop_new (NULL, FALSE);
 
522
                g_object_set_data (G_OBJECT (pMainWindow), "loop", pBlockingLoop);
 
523
                g_signal_connect (G_OBJECT (pMainWindow),
 
524
                        "delete-event",
 
525
                        G_CALLBACK (on_delete_generic_gui),
 
526
                        pBlockingLoop);
 
527
 
 
528
                g_print ("debut de boucle bloquante ...\n");
 
529
                GDK_THREADS_LEAVE ();
 
530
                g_main_loop_run (pBlockingLoop);
 
531
                GDK_THREADS_ENTER ();
 
532
                g_print ("fin de boucle bloquante\n");
 
533
                
 
534
                g_main_loop_unref (pBlockingLoop);
 
535
                g_object_set_data (G_OBJECT (pMainWindow), "loop", NULL);
 
536
                
 
537
                iResult = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (pMainWindow), "result"));
 
538
                cd_debug ("iResult : %d", iResult);
 
539
                gtk_widget_destroy (pMainWindow);
 
540
                if (pWindow)
 
541
                        *pWindow = NULL;
 
542
        }
 
543
        
 
544
        return iResult;
 
545
}
 
546
 
 
547
void cairo_dock_reload_generic_gui (GtkWidget *pWindow)
 
548
{
 
549
        //g_print ("%s ()", __func__);
 
550
        GSList *pWidgetList = g_object_get_data (G_OBJECT (pWindow), "widget-list");
 
551
        cairo_dock_free_generated_widget_list (pWidgetList);
 
552
        pWidgetList = NULL;
 
553
        g_object_set_data (G_OBJECT (pWindow), "widget-list", NULL);
 
554
        
 
555
        GPtrArray *pDataGarbage = g_object_get_data (G_OBJECT (pWindow), "garbage");
 
556
        /// nettoyer...
 
557
        g_object_set_data (G_OBJECT (pWindow), "garbage", NULL);
 
558
        
 
559
        GtkWidget *pMainVBox = gtk_bin_get_child (GTK_BIN (pWindow));
 
560
        GList *children = gtk_container_get_children (GTK_CONTAINER (pMainVBox));
 
561
        g_return_if_fail (children != NULL);
 
562
        GtkWidget *pNoteBook = children->data;
 
563
        gtk_widget_destroy (pNoteBook);
 
564
        
 
565
        gchar *cConfFilePath = g_object_get_data (G_OBJECT (pWindow), "conf-file");
 
566
        pNoteBook = cairo_dock_build_conf_file_widget (cConfFilePath, NULL, pWindow, &pWidgetList, pDataGarbage, cConfFilePath);
 
567
        gtk_box_pack_start (GTK_BOX (pMainVBox),
 
568
                pNoteBook,
 
569
                TRUE,
 
570
                TRUE,
 
571
                0);
 
572
        gtk_widget_show_all (pNoteBook);
 
573
        g_object_set_data (G_OBJECT (pWindow), "widget-list", pWidgetList);
 
574
        g_object_set_data (G_OBJECT (pWindow), "garbage", pDataGarbage);
 
575
}
 
576
 
 
577
 
 
578
  //////////////////////////
 
579
 // LAUNCHER GUI BACKEND //
 
580
//////////////////////////
 
581
 
 
582
void cairo_dock_register_launcher_gui_backend (CairoDockLauncherGuiBackend *pBackend)
 
583
{
 
584
        g_free (s_pLauncherGuiBackend);
 
585
        s_pLauncherGuiBackend = pBackend;
 
586
}
 
587
 
1799
588
GtkWidget *cairo_dock_build_launcher_gui (Icon *pIcon)
1800
589
{
1801
 
        g_print ("%s ()\n", __func__);
1802
 
        //\_____________ On construit la fenetre.
1803
 
        if (s_pLauncherWindow != NULL)
1804
 
        {
1805
 
                cairo_dock_delete_current_launcher_widget ();
1806
 
                
1807
 
                _select_item (pIcon);
1808
 
                
1809
 
                gtk_window_present (GTK_WINDOW (s_pLauncherWindow));
1810
 
                return s_pLauncherWindow;
1811
 
        }
1812
 
        s_pLauncherWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1813
 
        gtk_window_set_icon_from_file (GTK_WINDOW (s_pLauncherWindow), CAIRO_DOCK_SHARE_DATA_DIR"/"CAIRO_DOCK_ICON, NULL);
1814
 
        
1815
 
        GtkWidget *pMainVBox = gtk_vbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN);
1816
 
        gtk_container_add (GTK_CONTAINER (s_pLauncherWindow), pMainVBox);
1817
 
        
1818
 
        s_pLauncherPane = gtk_hpaned_new ();
1819
 
        gtk_box_pack_start (GTK_BOX (pMainVBox),
1820
 
                s_pLauncherPane,
1821
 
                TRUE,
1822
 
                TRUE,
1823
 
                0);
1824
 
        
1825
 
        //\_____________ On construit l'arbre des launceurs.
1826
 
        GtkTreeModel *model = _cairo_dock_build_tree_model();
1827
 
        
1828
 
        //\_____________ On construit le tree-view avec.
1829
 
        s_pLauncherTreeView = gtk_tree_view_new_with_model (model);
1830
 
        g_object_unref (model);
1831
 
        gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (s_pLauncherTreeView), FALSE);
1832
 
        gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (s_pLauncherTreeView), TRUE);
1833
 
    //g_signal_connect (s_pLauncherTreeView, "realize", G_CALLBACK (gtk_tree_view_expand_all), NULL);
1834
 
    
1835
 
        GtkTreeSelection *pSelection = gtk_tree_view_get_selection (GTK_TREE_VIEW (s_pLauncherTreeView));
1836
 
        gtk_tree_selection_set_mode (pSelection, GTK_SELECTION_SINGLE);
1837
 
        gtk_tree_selection_set_select_function (pSelection,
1838
 
                (GtkTreeSelectionFunc) _cairo_dock_select_one_launcher_in_tree,
1839
 
                NULL,
1840
 
                NULL);
1841
 
        
1842
 
        GtkCellRenderer *rend;
1843
 
        rend = gtk_cell_renderer_text_new ();
1844
 
        gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (s_pLauncherTreeView), -1, NULL, rend, "text", 0, NULL);
1845
 
        rend = gtk_cell_renderer_pixbuf_new ();
1846
 
        gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (s_pLauncherTreeView), -1, NULL, rend, "pixbuf", 1, NULL);
1847
 
        
1848
 
        s_pLauncherScrolledWindow = gtk_scrolled_window_new (NULL, NULL);
1849
 
        gtk_widget_set (s_pLauncherScrolledWindow, "height-request", CAIRO_DOCK_LAUNCHER_PANEL_HEIGHT - 30, NULL);
1850
 
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (s_pLauncherScrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1851
 
        gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (s_pLauncherScrolledWindow), s_pLauncherTreeView);
1852
 
        gtk_paned_pack1 (GTK_PANED (s_pLauncherPane), s_pLauncherScrolledWindow, TRUE, FALSE);
1853
 
        
1854
 
        //\_____________ On ajoute les boutons.
1855
 
        GtkWidget *pButtonsHBox = gtk_hbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN*2);
1856
 
        gtk_box_pack_end (GTK_BOX (pMainVBox),
1857
 
                pButtonsHBox,
1858
 
                FALSE,
1859
 
                FALSE,
1860
 
                0);
1861
 
        
1862
 
        GtkWidget *pQuitButton = gtk_button_new_from_stock (GTK_STOCK_QUIT);
1863
 
        g_signal_connect (G_OBJECT (pQuitButton), "clicked", G_CALLBACK(on_click_launcher_quit), s_pLauncherWindow);
1864
 
        gtk_box_pack_end (GTK_BOX (pButtonsHBox),
1865
 
                pQuitButton,
1866
 
                FALSE,
1867
 
                FALSE,
1868
 
                0);
1869
 
        
1870
 
        GtkWidget *pApplyButton = gtk_button_new_from_stock (GTK_STOCK_APPLY);
1871
 
        g_signal_connect (G_OBJECT (pApplyButton), "clicked", G_CALLBACK(on_click_launcher_apply), s_pLauncherWindow);
1872
 
        gtk_box_pack_end (GTK_BOX (pButtonsHBox),
1873
 
                pApplyButton,
1874
 
                FALSE,
1875
 
                FALSE,
1876
 
                0);
1877
 
        
1878
 
        //\_____________ On ajoute la barre d'etat.
1879
 
        GtkWidget *pStatusBar = gtk_statusbar_new ();
1880
 
        gtk_box_pack_start (GTK_BOX (pButtonsHBox),  // pMainVBox
1881
 
                pStatusBar,
1882
 
                FALSE,
1883
 
                FALSE,
1884
 
                0);
1885
 
        g_object_set_data (G_OBJECT (s_pLauncherWindow), "status-bar", pStatusBar);
1886
 
        
1887
 
        gtk_window_resize (GTK_WINDOW (s_pLauncherWindow), CAIRO_DOCK_LAUNCHER_PANEL_WIDTH, CAIRO_DOCK_LAUNCHER_PANEL_HEIGHT);
1888
 
        
1889
 
        gtk_widget_show_all (s_pLauncherWindow);
1890
 
        cairo_dock_dialog_window_created ();
1891
 
        
1892
 
        g_signal_connect (G_OBJECT (s_pLauncherWindow),
1893
 
                "delete-event",
1894
 
                G_CALLBACK (on_delete_launcher_gui),
1895
 
                NULL);
1896
 
        
1897
 
        //\_____________ On selectionne l'entree courante.
1898
 
        _select_item (pIcon);
1899
 
        
1900
 
        return s_pLauncherWindow;
1901
 
}
1902
 
 
1903
 
void cairo_dock_free_launcher_gui (void)
1904
 
{
1905
 
        s_pLauncherWindow = NULL;
1906
 
        s_pCurrentLauncherWidget = NULL;
1907
 
        s_pLauncherPane = NULL;
1908
 
        s_pLauncherTreeView = NULL;
1909
 
        s_pLauncherScrolledWindow = NULL;
1910
 
}
1911
 
 
1912
 
void cairo_dock_delete_current_launcher_widget (void)
1913
 
{
1914
 
        g_return_if_fail (s_pLauncherWindow != NULL);
1915
 
        
1916
 
        if (s_pCurrentLauncherWidget != NULL)
1917
 
        {
1918
 
                gtk_widget_destroy (s_pCurrentLauncherWidget);
1919
 
                s_pCurrentLauncherWidget = NULL;
1920
 
        }
1921
 
        GSList *pWidgetList = g_object_get_data (G_OBJECT (s_pLauncherWindow), "widget-list");
1922
 
        if (pWidgetList != NULL)
1923
 
        {
1924
 
                cairo_dock_free_generated_widget_list (pWidgetList);
1925
 
                g_object_set_data (G_OBJECT (s_pLauncherWindow), "widget-list", NULL);
1926
 
        }
1927
 
        GPtrArray *pDataGarbage = g_object_get_data (G_OBJECT (s_pLauncherWindow), "garbage");
1928
 
        if (pDataGarbage != NULL)
1929
 
        {
1930
 
                /// nettoyer ...
1931
 
                g_object_set_data (G_OBJECT (s_pLauncherWindow), "garbage", NULL);
1932
 
        }
1933
 
        
1934
 
        g_object_set_data (G_OBJECT (s_pLauncherWindow), "current-icon", NULL);
1935
 
}
1936
 
 
 
590
        if (s_pLauncherGuiBackend && s_pLauncherGuiBackend->show_gui)
 
591
                s_pLauncherGuiBackend->show_gui (pIcon);
 
592
}
 
593
 
 
594
static guint s_iSidRefreshGUI = 0;
 
595
static gboolean _refresh_launcher_gui (gpointer data)
 
596
{
 
597
        if (s_pLauncherGuiBackend && s_pLauncherGuiBackend->refresh_gui)
 
598
                s_pLauncherGuiBackend->refresh_gui ();
 
599
        
 
600
        s_iSidRefreshGUI = 0;
 
601
        return FALSE;
 
602
}
1937
603
void cairo_dock_refresh_launcher_gui (void)
1938
604
{
1939
 
        if (cairo_dock_is_loading ())
 
605
        if (s_iSidRefreshGUI != 0)
1940
606
                return;
1941
 
        g_print ("%s ()\n", __func__);
1942
 
        if (s_pLauncherWindow == NULL)
1943
 
                return ;
1944
 
        Icon *pCurrentIcon = g_object_get_data (G_OBJECT (s_pLauncherWindow), "current-icon");
1945
 
        
1946
 
        cairo_dock_delete_current_launcher_widget ();
1947
 
        
1948
 
        GtkTreeModel *model = _cairo_dock_build_tree_model();
1949
 
        
1950
 
        gtk_tree_view_set_model (GTK_TREE_VIEW (s_pLauncherTreeView), GTK_TREE_MODEL (model));
1951
 
        g_object_unref (model);
1952
 
        
1953
 
        _select_item (pCurrentIcon);
1954
 
        
1955
 
        gtk_widget_show_all (s_pLauncherWindow);
1956
 
        g_object_set_data (G_OBJECT (s_pLauncherWindow), "current-icon", pCurrentIcon);
 
607
        
 
608
        s_iSidRefreshGUI = g_idle_add ((GSourceFunc) _refresh_launcher_gui, NULL);
 
609
}
 
610
 
 
611
 
 
612
  ////////////////////////
 
613
 // CONFIG MODE SWITCH //
 
614
////////////////////////
 
615
 
 
616
static gboolean s_bAdvancedMode = FALSE;
 
617
void cairo_dock_load_user_gui_backend (void)
 
618
{
 
619
        gchar *cModeFile = g_strdup_printf ("%s/%s", g_cCairoDockDataDir, ".config-mode");
 
620
        gsize length = 0;
 
621
        gchar *cContent = NULL;
 
622
        g_file_get_contents (cModeFile,
 
623
                &cContent,
 
624
                &length,
 
625
                NULL);
 
626
        
 
627
        if (!cContent || atoi (cContent) == 0)
 
628
        {
 
629
                cairo_dock_register_simple_gui_backend ();
 
630
                s_bAdvancedMode = FALSE;
 
631
        }
 
632
        else
 
633
        {
 
634
                cairo_dock_register_main_gui_backend ();
 
635
                s_bAdvancedMode = TRUE;
 
636
        }
 
637
        g_free (cModeFile);
 
638
}
 
639
 
 
640
static void on_click_switch_mode (GtkButton *button, gpointer data)
 
641
{
 
642
        cairo_dock_close_gui ();
 
643
        
 
644
        s_bAdvancedMode = !s_bAdvancedMode;
 
645
        gchar *cModeFile = g_strdup_printf ("%s/%s", g_cCairoDockDataDir, ".config-mode");
 
646
        gchar *cMode = g_strdup_printf ("%d", s_bAdvancedMode);
 
647
        g_file_set_contents (cModeFile,
 
648
                cMode,
 
649
                -1,
 
650
                NULL);
 
651
        
 
652
        if (s_bAdvancedMode)
 
653
                cairo_dock_register_main_gui_backend ();
 
654
        else
 
655
                cairo_dock_register_simple_gui_backend ();
 
656
        g_free (cMode);
 
657
        g_free (cModeFile);
 
658
        
 
659
        cairo_dock_show_main_gui ();
 
660
}
 
661
GtkWidget *cairo_dock_make_switch_gui_button (void)
 
662
{
 
663
        GtkWidget *pSwitchButton = gtk_button_new_with_label (s_bAdvancedMode ? _("Simple Mode") : _("Advanced Mode"));
 
664
        if (!s_bAdvancedMode)
 
665
                gtk_widget_set_tooltip_text (pSwitchButton, _("The advanced mode lets you tweak every single parameter of the dock. It is a powerful tool to customize your current theme."));
 
666
        
 
667
        GtkWidget *pImage = gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
 
668
        gtk_button_set_image (GTK_BUTTON (pSwitchButton), pImage);
 
669
        g_signal_connect (G_OBJECT (pSwitchButton), "clicked", G_CALLBACK(on_click_switch_mode), NULL);
 
670
        return pSwitchButton;
1957
671
}