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

« back to all changes in this revision

Viewing changes to src/cairo-dock-gui-factory.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:
36
36
#include "cairo-dock-gauge.h"
37
37
#include "cairo-dock-config.h"
38
38
#include "cairo-dock-keyfile-utilities.h"
 
39
#include "cairo-dock-renderer-manager.h"
39
40
#include "cairo-dock-gui-factory.h"
 
41
#include "cairo-dock-task.h"
 
42
#include "cairo-dock-load.h"
 
43
#include "cairo-dock-callbacks.h" // cairo_dock_launch_command_sync
40
44
 
41
45
#define CAIRO_DOCK_GUI_MARGIN 4
42
46
#define CAIRO_DOCK_ICON_MARGIN 6
51
55
extern gchar *g_cConfFile;
52
56
extern gchar *g_cCurrentThemePath;
53
57
 
54
 
typedef enum {
55
 
        CAIRO_DOCK_MODEL_NAME = 0,
56
 
        CAIRO_DOCK_MODEL_RESULT,
57
 
        CAIRO_DOCK_MODEL_DESCRIPTION_FILE,
58
 
        CAIRO_DOCK_MODEL_ACTIVE,
59
 
        CAIRO_DOCK_MODEL_ORDER,
60
 
        CAIRO_DOCK_MODEL_IMAGE,
61
 
        CAIRO_DOCK_MODEL_ICON,
62
 
        CAIRO_DOCK_MODEL_ORDER2,
63
 
        CAIRO_DOCK_MODEL_NB_COLUMNS
64
 
        } _CairoDockModelColumns;
65
 
 
66
58
static GtkListStore *s_pRendererListStore = NULL;
67
59
static GtkListStore *s_pDecorationsListStore = NULL;
68
60
static GtkListStore *s_pDecorationsListStore2 = NULL;
70
62
static GtkListStore *s_pDialogDecoratorListStore = NULL;
71
63
static GtkListStore *s_pGaugeListStore = NULL;
72
64
static GtkListStore *s_pDocksListStore = NULL;
 
65
static GtkListStore *s_pIconThemeListStore = NULL;
73
66
 
74
67
#define _allocate_new_model(...)\
75
 
        gtk_list_store_new (CAIRO_DOCK_MODEL_NB_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_INT)
 
68
        gtk_list_store_new (CAIRO_DOCK_MODEL_NB_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT)
76
69
 
77
70
static void _cairo_dock_activate_one_element (GtkCellRendererToggle * cell_renderer, gchar * path, GtkTreeModel * model)
78
71
{
209
202
        g_free (cValue);
210
203
}
211
204
 
 
205
static gboolean on_delete_async_widget (GtkWidget *pMainWindow, GdkEvent *event, GtkWidget *pWidget)
 
206
{
 
207
        //g_print ("%s ()\n", __func__);
 
208
        CairoDockTask *pTask = g_object_get_data (G_OBJECT (pWidget), "cd-task");
 
209
        if (pTask != NULL)
 
210
        {
 
211
                cairo_dock_discard_task (pTask);
 
212
                g_object_set_data (G_OBJECT (pWidget), "cd-task", NULL);
 
213
        }
 
214
        g_object_unref (G_OBJECT (pWidget));
 
215
        return FALSE;
 
216
}
 
217
 
 
218
static inline void _set_preview_image (const gchar *cPreviewFilePath, GtkImage *pPreviewImage)
 
219
{
 
220
        int iPreviewWidth, iPreviewHeight;
 
221
        GdkPixbuf *pPreviewPixbuf = NULL;
 
222
        if (gdk_pixbuf_get_file_info (cPreviewFilePath, &iPreviewWidth, &iPreviewHeight) != NULL)
 
223
        {
 
224
                iPreviewWidth = MIN (iPreviewWidth, CAIRO_DOCK_PREVIEW_WIDTH);
 
225
                iPreviewHeight = MIN (iPreviewHeight, CAIRO_DOCK_PREVIEW_HEIGHT);
 
226
                 g_print ("preview : %dx%d\n", iPreviewWidth, iPreviewHeight); // 
 
227
                pPreviewPixbuf = gdk_pixbuf_new_from_file_at_size (cPreviewFilePath, iPreviewWidth, iPreviewHeight, NULL);
 
228
        }
 
229
        if (pPreviewPixbuf == NULL)
 
230
        {
 
231
                pPreviewPixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
 
232
                        TRUE,
 
233
                        8,
 
234
                        1,
 
235
                        1);
 
236
        }
 
237
        gtk_image_set_from_pixbuf (pPreviewImage, pPreviewPixbuf);
 
238
        gdk_pixbuf_unref (pPreviewPixbuf);
 
239
}
 
240
 
 
241
static void _on_got_readme (const gchar *cDescription, GtkWidget *pDescriptionLabel)
 
242
{
 
243
        //g_print ("%s ()\n", __func__);
 
244
        gtk_label_set_markup (GTK_LABEL (pDescriptionLabel), cDescription ? cDescription : "");
 
245
        
 
246
        CairoDockTask *pTask = g_object_get_data (G_OBJECT (pDescriptionLabel), "cd-task");
 
247
        if (pTask != NULL)
 
248
        {
 
249
                //g_print ("remove the task\n");
 
250
                cairo_dock_discard_task (pTask);
 
251
                g_object_set_data (G_OBJECT (pDescriptionLabel), "cd-task", NULL);
 
252
        }
 
253
}
 
254
static void _on_got_preview_file (const gchar *cPreviewFilePath, GtkWidget *pPreviewImage)
 
255
{
 
256
        if (cPreviewFilePath != NULL)
 
257
        {
 
258
                _set_preview_image (cPreviewFilePath, GTK_IMAGE (pPreviewImage));
 
259
                g_remove (cPreviewFilePath);
 
260
        }
 
261
        CairoDockTask *pTask = g_object_get_data (G_OBJECT (pPreviewImage), "cd-task");
 
262
        if (pTask != NULL)
 
263
        {
 
264
                cairo_dock_discard_task (pTask);
 
265
                g_object_set_data (G_OBJECT (pPreviewImage), "cd-task", NULL);
 
266
        }
 
267
}
212
268
static void _cairo_dock_selection_changed (GtkTreeModel *model, GtkTreeIter iter, gpointer *data)
213
269
{
214
270
        static gchar *s_cPrevPreview = NULL, *s_cPrevReadme = NULL;
215
271
        GtkLabel *pDescriptionLabel = data[0];
 
272
        gtk_label_set_justify (GTK_LABEL (pDescriptionLabel), GTK_JUSTIFY_FILL);
 
273
        gtk_label_set_line_wrap (pDescriptionLabel, TRUE);
216
274
        GtkImage *pPreviewImage = data[1];
217
275
        GError *erreur = NULL;
218
 
        gchar *cDescriptionFilePath = NULL, *cPreviewFilePath = NULL;
219
 
        //g_print ("iter:%d\n", iter);
 
276
        gchar *cDescriptionFilePath = NULL, *cPreviewFilePath = NULL, *cName = NULL;
220
277
        gtk_tree_model_get (model, &iter,
221
278
                CAIRO_DOCK_MODEL_DESCRIPTION_FILE, &cDescriptionFilePath,
222
279
                CAIRO_DOCK_MODEL_IMAGE, &cPreviewFilePath, -1);
223
 
        //g_print ("ok\n");
224
 
        
225
 
        
226
 
        if (cDescriptionFilePath != NULL && (!s_cPrevPreview || strcmp (s_cPrevPreview, cDescriptionFilePath) != 0))
 
280
        
 
281
        if (cDescriptionFilePath != NULL && (1 || !s_cPrevReadme || strcmp (s_cPrevReadme, cDescriptionFilePath) != 0))
227
282
        {
228
 
                g_free (s_cPrevPreview);
229
 
                s_cPrevPreview = g_strdup (cDescriptionFilePath);
230
 
                gchar *cDescription = NULL;
231
 
                if (strncmp (cDescriptionFilePath, "http://", 7) == 0)
 
283
                CairoDockTask *pTask = g_object_get_data (G_OBJECT (pDescriptionLabel), "cd-task");
 
284
                //g_print ("prev task : %x\n", pTask);
 
285
                if (pTask != NULL)
 
286
                {
 
287
                        cairo_dock_discard_task (pTask);
 
288
                        g_object_set_data (G_OBJECT (pDescriptionLabel), "cd-task", NULL);
 
289
                }
 
290
                g_free (s_cPrevReadme);
 
291
                s_cPrevReadme = g_strdup (cDescriptionFilePath);
 
292
                if (strncmp (cDescriptionFilePath, "http://", 7) == 0)  // fichier distant.
232
293
                {
233
294
                        cd_debug ("fichier readme distant (%s)", cDescriptionFilePath);
234
 
 
 
295
                        
235
296
                        gchar *str = strrchr (cDescriptionFilePath, '/');
236
297
                        g_return_if_fail (str != NULL);
237
298
                        *str = '\0';
238
 
                        cDescription = cairo_dock_get_distant_file_content (cDescriptionFilePath, "", str+1, 0, NULL);
 
299
                        
 
300
                        gtk_label_set_markup (pDescriptionLabel, "...");
 
301
                        pTask = cairo_dock_get_distant_file_content_async (cDescriptionFilePath, "", str+1, (GFunc) _on_got_readme, pDescriptionLabel);
 
302
                        g_object_set_data (G_OBJECT (pDescriptionLabel), "cd-task", pTask);
 
303
                        //g_print ("new task : %x\n", pTask);
239
304
                }
240
 
                else
 
305
                else if (*cDescriptionFilePath == '/')  // fichier local
241
306
                {
242
 
                        cd_debug ("fichier readme local (%s)", cDescriptionFilePath);
243
307
                        gsize length = 0;
244
 
                        g_file_get_contents  (cDescriptionFilePath,
 
308
                        gchar *cDescription = NULL;
 
309
                        g_file_get_contents (cDescriptionFilePath,
245
310
                                &cDescription,
246
311
                                &length,
247
312
                                NULL);
248
 
                }
249
 
                
250
 
                gtk_label_set_markup (pDescriptionLabel, cDescription ? cDescription : "");
251
 
                g_free (cDescription);
 
313
                        gtk_label_set_markup (pDescriptionLabel, cDescription ? cDescription : "");
 
314
                        g_free (cDescription);
 
315
                }
 
316
                else if (strcmp (cDescriptionFilePath, "none") != 0)  // texte de la description.
 
317
                {
 
318
                        gtk_label_set_markup (pDescriptionLabel, cDescriptionFilePath);
 
319
                }
 
320
                else  // rien.
 
321
                        gtk_label_set_markup (pDescriptionLabel, "");
252
322
        }
253
323
 
254
 
        if (cPreviewFilePath != NULL && (!s_cPrevReadme || strcmp (s_cPrevReadme, cPreviewFilePath) != 0))
 
324
        if (cPreviewFilePath != NULL && (1 || !s_cPrevPreview || strcmp (s_cPrevPreview, cPreviewFilePath) != 0))
255
325
        {
256
 
                g_free (s_cPrevReadme);
257
 
                s_cPrevReadme = g_strdup (cPreviewFilePath);
 
326
                g_free (s_cPrevPreview);
 
327
                s_cPrevPreview = g_strdup (cPreviewFilePath);
258
328
                
259
329
                gboolean bDistant = FALSE;
260
 
                if (strncmp (cPreviewFilePath, "http://", 7) == 0)
 
330
                if (strncmp (cPreviewFilePath, "http://", 7) == 0)  // fichier distant.
261
331
                {
262
332
                        cd_debug ("fichier preview distant (%s)", cPreviewFilePath);
263
333
                        
264
334
                        gchar *str = strrchr (cPreviewFilePath, '/');
265
335
                        g_return_if_fail (str != NULL);
266
336
                        *str = '\0';
267
 
                        gchar *cTmpFilePath = cairo_dock_download_file (cPreviewFilePath, "", str+1, 0, NULL, NULL);
268
 
                        
269
 
                        g_free (cPreviewFilePath);
270
 
                        cPreviewFilePath = cTmpFilePath;
271
 
                        bDistant = TRUE;
272
 
                }
273
 
                
274
 
                int iPreviewWidth, iPreviewHeight;
275
 
                GdkPixbuf *pPreviewPixbuf = NULL;
276
 
                if (gdk_pixbuf_get_file_info (cPreviewFilePath, &iPreviewWidth, &iPreviewHeight) != NULL)
277
 
                {
278
 
                        iPreviewWidth = MIN (iPreviewWidth, CAIRO_DOCK_PREVIEW_WIDTH);
279
 
                        iPreviewHeight = MIN (iPreviewHeight, CAIRO_DOCK_PREVIEW_HEIGHT);
280
 
                        g_print ("preview : %dx%d\n", iPreviewWidth, iPreviewHeight);
281
 
                        pPreviewPixbuf = gdk_pixbuf_new_from_file_at_size (cPreviewFilePath, iPreviewWidth, iPreviewHeight, NULL);
282
 
                }
283
 
                if (pPreviewPixbuf == NULL)
284
 
                {
285
 
                        pPreviewPixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
286
 
                                TRUE,
287
 
                                8,
288
 
                                1,
289
 
                                1);
290
 
                }
291
 
                gtk_image_set_from_pixbuf (pPreviewImage, pPreviewPixbuf);
292
 
                gdk_pixbuf_unref (pPreviewPixbuf);
293
 
                
294
 
                if (bDistant)
295
 
                {
296
 
                        g_remove (cPreviewFilePath);
297
 
                }
 
337
                        
 
338
                        CairoDockTask *pTask = g_object_get_data (G_OBJECT (pPreviewImage), "cd-task");
 
339
                        if (pTask != NULL)
 
340
                                cairo_dock_discard_task (pTask);
 
341
                        
 
342
                        pTask = cairo_dock_download_file_async (cPreviewFilePath, "", str+1, NULL, (GFunc) _on_got_preview_file, pPreviewImage);
 
343
                        g_object_set_data (G_OBJECT (pPreviewImage), "cd-task", pTask);
 
344
                }
 
345
                else  // fichier local ou rien.
 
346
                        _set_preview_image (cPreviewFilePath, pPreviewImage);
298
347
        }
299
348
 
300
349
        g_free (cDescriptionFilePath);
301
350
        g_free (cPreviewFilePath);
302
351
}
303
352
 
 
353
static void _cairo_dock_select_custom_item_in_combo (GtkComboBox *widget, gpointer *data)
 
354
{
 
355
        GtkTreeModel *model = gtk_combo_box_get_model (widget);
 
356
        g_return_if_fail (model != NULL);
 
357
 
 
358
        GtkTreeIter iter;
 
359
        if (!gtk_combo_box_get_active_iter (widget, &iter))
 
360
                return ;
 
361
        
 
362
        GtkWidget *parent = data[1];
 
363
        GtkWidget *pKeyBox = data[0];
 
364
        int iNbWidgets = GPOINTER_TO_INT (data[2]);
 
365
        GList *children = gtk_container_get_children (GTK_CONTAINER (parent));
 
366
        GList *c = g_list_find (children, pKeyBox);
 
367
        g_return_if_fail (c != NULL && c->next != NULL);
 
368
        
 
369
        gchar *cName = NULL;
 
370
        gtk_tree_model_get (model, &iter,
 
371
                CAIRO_DOCK_MODEL_RESULT, &cName, -1);
 
372
        
 
373
        gboolean bActive = (cName != NULL && strcmp (cName, "personnal") == 0);
 
374
        GtkWidget *w;
 
375
        int i;
 
376
        for (c = c->next, i = 0; c != NULL && i < iNbWidgets; c = c->next, i ++)
 
377
        {
 
378
                w = c->data;
 
379
                gtk_widget_set_sensitive (w, bActive);
 
380
        }
 
381
        
 
382
        g_list_free (children);
 
383
        g_free (cName);
 
384
}
 
385
 
304
386
static void _cairo_dock_select_one_item_in_combo (GtkComboBox *widget, gpointer *data)
305
387
{
306
388
        GtkTreeModel *model = gtk_combo_box_get_model (widget);
309
391
        GtkTreeIter iter;
310
392
        if (!gtk_combo_box_get_active_iter (widget, &iter))
311
393
                return ;
312
 
 
 
394
        
313
395
        _cairo_dock_selection_changed (model, iter, data);
314
396
}
315
397
 
325
407
        return TRUE;
326
408
}
327
409
 
 
410
static void _cairo_dock_select_one_item_in_control_combo (GtkComboBox *widget, gpointer *data)
 
411
{
 
412
        GtkTreeModel *model = gtk_combo_box_get_model (widget);
 
413
        g_return_if_fail (model != NULL);
 
414
        
 
415
        GtkTreeIter iter;
 
416
        if (!gtk_combo_box_get_active_iter (widget, &iter))
 
417
                return ;
 
418
        
 
419
        int iNumItem = gtk_combo_box_get_active (widget);
 
420
        //gtk_tree_model_get (model, &iter, CAIRO_DOCK_MODEL_ORDER, &iNumItem, -1);
 
421
        
 
422
        GtkWidget *parent = data[1];
 
423
        GtkWidget *pKeyBox = data[0];
 
424
        int iNbWidgets = GPOINTER_TO_INT (data[2]);
 
425
        GList *children = gtk_container_get_children (GTK_CONTAINER (parent));
 
426
        GList *c = g_list_find (children, pKeyBox);
 
427
        g_return_if_fail (c != NULL);
 
428
        
 
429
        GtkWidget *w;
 
430
        int i;
 
431
        for (c = c->next, i = 0; c != NULL && i < iNbWidgets; c = c->next, i ++)
 
432
        {
 
433
                w = c->data;
 
434
                //g_print (" %d/%d -> %d\n", i, iNbWidgets, i == iNumItem);
 
435
                if (GTK_IS_EXPANDER (w))
 
436
                {
 
437
                        gtk_expander_set_expanded (GTK_EXPANDER (w), i == iNumItem);
 
438
                }
 
439
                else
 
440
                {
 
441
                        gtk_widget_set_sensitive (w, i == iNumItem);
 
442
                }
 
443
        }
 
444
        
 
445
        g_list_free (children);
 
446
}
 
447
static void _cairo_dock_select_one_item_in_control_combo_selective (GtkComboBox *widget, gpointer *data)
 
448
{
 
449
        GtkTreeModel *model = gtk_combo_box_get_model (widget);
 
450
        g_return_if_fail (model != NULL);
 
451
        
 
452
        GtkTreeIter iter;
 
453
        if (!gtk_combo_box_get_active_iter (widget, &iter))
 
454
                return ;
 
455
        
 
456
        int iOrder1, iOrder2;
 
457
        gtk_tree_model_get (model, &iter,
 
458
                CAIRO_DOCK_MODEL_ORDER, &iOrder1,
 
459
                CAIRO_DOCK_MODEL_ORDER2, &iOrder2, -1);
 
460
        
 
461
        GtkWidget *parent = data[1];
 
462
        GtkWidget *pKeyBox = data[0];
 
463
        int iNbWidgets = GPOINTER_TO_INT (data[2]);
 
464
        //g_print ("%s (%d, %d / %d)\n", __func__, iOrder1, iOrder2, iNbWidgets);
 
465
        GList *children = gtk_container_get_children (GTK_CONTAINER (parent));
 
466
        GList *c = g_list_find (children, pKeyBox);
 
467
        g_return_if_fail (c != NULL);
 
468
        
 
469
        GtkWidget *w;
 
470
        int i;
 
471
        for (c = c->next, i = 0; c != NULL && i < iNbWidgets; c = c->next, i ++)
 
472
        {
 
473
                w = c->data;
 
474
                //g_print ("%d in ]%d;%d[\n", i, iOrder1, iOrder1 + iOrder2);
 
475
                gtk_widget_set_sensitive (w, i >= iOrder1 - 1 && i < iOrder1 + iOrder2 - 1);
 
476
        }
 
477
        
 
478
        g_list_free (children);
 
479
}
328
480
 
329
481
static void _cairo_dock_show_image_preview (GtkFileChooser *pFileChooser, GtkImage *pPreviewImage)
330
482
{
426
578
                
427
579
                g_free (fValuesList);
428
580
        }
 
581
        else if (GTK_IS_COLOR_BUTTON (pOneWidget))
 
582
        {
 
583
                double *fValuesList = g_key_file_get_double_list (pKeyFile, cGroupName, cKeyName, &length, &erreur);
 
584
                
 
585
                if (length > 2)
 
586
                {
 
587
                        GdkColor gdkColor;
 
588
                        gdkColor.red = fValuesList[0] * 65535;
 
589
                        gdkColor.green = fValuesList[1] * 65535;
 
590
                        gdkColor.blue = fValuesList[2] * 65535;
 
591
                        gtk_color_button_set_color (GTK_COLOR_BUTTON (pOneWidget), &gdkColor);
 
592
                        
 
593
                        if (length > 3 && gtk_color_button_get_use_alpha (GTK_COLOR_BUTTON (pOneWidget)))
 
594
                                gtk_color_button_set_alpha (GTK_COLOR_BUTTON (pOneWidget), fValuesList[3] * 65535);
 
595
                }
 
596
                g_free (fValuesList);
 
597
        }
429
598
        g_key_file_free (pKeyFile);
430
599
}
431
600
 
474
643
        g_signal_connect (GTK_WIDGET(pParentWindow), "key-press-event", GTK_SIGNAL_FUNC(_cairo_dock_key_grab_cb), pEntry);
475
644
}
476
645
 
477
 
static void _cairo_dock_set_font (GtkFontButton *widget, GtkEntry *pEntry)
478
 
{
479
 
        const gchar *cFontName = gtk_font_button_get_font_name (GTK_FONT_BUTTON (widget));
480
 
        cd_message (" -> %s\n", cFontName);
481
 
        PangoFontDescription *fd = pango_font_description_from_string (cFontName);
482
 
        g_print ("familly : %s\n", pango_font_description_get_family (fd));
483
 
        g_print ("style : %d\n", pango_font_description_get_style (fd));
484
 
        g_print ("weight : %d\n", pango_font_description_get_weight (fd));
485
 
        g_print ("size : %d\n", pango_font_description_get_size (fd));
486
 
        
487
 
        if (cFontName != NULL)
488
 
                gtk_entry_set_text (pEntry, cFontName);
489
 
}
490
 
 
491
 
static void _cairo_dock_set_color (GtkColorButton *pColorButton, GSList *pWidgetList)
492
 
{
493
 
        GdkColor gdkColor;
494
 
        gtk_color_button_get_color (pColorButton, &gdkColor);
495
 
 
496
 
        GtkSpinButton *pSpinButton;
497
 
        GSList *pList = pWidgetList;
498
 
        if (pList == NULL)
499
 
                return;
500
 
        pSpinButton = pList->data;
501
 
        gtk_spin_button_set_value (pSpinButton, 1. * gdkColor.red / 65535);
502
 
        pList = pList->next;
503
 
 
504
 
        if (pList == NULL)
505
 
                return;
506
 
        pSpinButton = pList->data;
507
 
        gtk_spin_button_set_value (pSpinButton, 1. * gdkColor.green / 65535);
508
 
        pList = pList->next;
509
 
 
510
 
        if (pList == NULL)
511
 
                return;
512
 
        pSpinButton = pList->data;
513
 
        gtk_spin_button_set_value (pSpinButton, 1. * gdkColor.blue / 65535);
514
 
        pList = pList->next;
515
 
 
516
 
        if (gtk_color_button_get_use_alpha (pColorButton))
517
 
        {
518
 
                if (pList == NULL)
519
 
                return;
520
 
                pSpinButton = pList->data;
521
 
                gtk_spin_button_set_value (pSpinButton, 1. * gtk_color_button_get_alpha (pColorButton) / 65535);
522
 
        }
523
 
}
524
 
 
525
 
static void _cairo_dock_get_current_color (GtkColorButton *pColorButton, GSList *pWidgetList)
526
 
{
527
 
        GtkSpinButton *pSpinButton;
528
 
        int i, color[4] = {0,0,0,0};
529
 
        GSList *c;
530
 
        for (c = pWidgetList, i = 0; c != NULL && i < 4; c = c->next, i ++)
531
 
        {
532
 
                pSpinButton = c->data;
533
 
                color[i] = gtk_spin_button_get_value (pSpinButton) * 65535;
534
 
        }
535
 
        
536
 
        GdkColor gdkColor;
537
 
        gdkColor.red = color[0];
538
 
        gdkColor.green = color[1];
539
 
        gdkColor.blue = color[2];
540
 
        gtk_color_button_set_color (pColorButton, &gdkColor);
541
 
        
542
 
        if (gtk_color_button_get_use_alpha (pColorButton))
543
 
                gtk_color_button_set_alpha (pColorButton, color[3]);
 
646
static void _cairo_dock_key_grab_class (GtkButton *button, gpointer *data)
 
647
{
 
648
        GtkEntry *pEntry = data[0];
 
649
        GtkWindow *pParentWindow = data[1];
 
650
 
 
651
        cd_message ("clicked\n");
 
652
        gtk_widget_set_sensitive (GTK_WIDGET(pEntry), FALSE); // locked (plus zoli :) )
 
653
 
 
654
        gchar *cProp = cairo_dock_launch_command_sync ("xprop"); // avec "| grep CLASS | cut -d\\\" -f2", ca ne fonctionne pas et Fab n'aime pas les g_spawn_command_line_sync :) --> c'est surtout que c'est g_spawn_command_line_sync qui n'aime pas les grep.
 
655
 
 
656
        gchar *str = g_strstr_len (cProp, -1, "WM_CLASS(STRING)"); // str pointant sur WM_
 
657
        gchar *cResult = NULL; // NON CE N'EST PAS MA MOYENNE DE POINT !!!!
 
658
        if (str != NULL)
 
659
        {
 
660
                // WM_CLASS(STRING) = "gnome-terminal", "Gnome-terminal" \\ => utiliser le 2è
 
661
                str = strchr (str, ',');
 
662
                str += 3;
 
663
                gchar *max = strchr (str, '"'); // on pointe le 2e "
 
664
                if (max != NULL)
 
665
                        cResult = g_strndup (str, max - str); // on prend ce qui est entre ""
 
666
        }
 
667
        if (cResult == NULL)
 
668
                cd_warning ("couldn't find the class of this window.");
 
669
        
 
670
        gtk_widget_set_sensitive (GTK_WIDGET(pEntry), TRUE); // unlocked
 
671
        gtk_entry_set_text (pEntry, cResult); // on ajoute le txt dans le box des accuses
 
672
        g_free (cProp); // Ah, mnt C Propr' !
 
673
        g_free (cResult); // Ou qu'elle est la poulette ???
544
674
}
545
675
 
546
676
void _cairo_dock_set_value_in_pair (GtkSpinButton *pSpinButton, gpointer *data)
558
688
        }
559
689
}
560
690
 
 
691
static void _cairo_dock_toggle_control_button (GtkCheckButton *pButton, gpointer *data)
 
692
{
 
693
        GtkWidget *parent = data[1];
 
694
        GtkWidget *pKeyBox = data[0];
 
695
        int iNbWidgets = GPOINTER_TO_INT (data[2]);
 
696
        
 
697
        GList *children = gtk_container_get_children (GTK_CONTAINER (parent));
 
698
        GList *c = g_list_find (children, pKeyBox);
 
699
        g_return_if_fail (c != NULL);
 
700
        
 
701
        gboolean bActive = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pButton));
 
702
        GtkWidget *w;
 
703
        int i;
 
704
        for (c = c->next, i = 0; c != NULL && i < iNbWidgets; c = c->next, i ++)
 
705
        {
 
706
                w = c->data;
 
707
                g_print (" %d/%d -> %d\n", i, iNbWidgets, bActive);
 
708
                gtk_widget_set_sensitive (w, bActive);
 
709
        }
 
710
        
 
711
        g_list_free (children);
 
712
}
 
713
 
 
714
static void _list_icon_theme_in_dir (const gchar *cDirPath, GHashTable *pHashTable)
 
715
{
 
716
        GError *erreur = NULL;
 
717
        GDir *dir = g_dir_open (cDirPath, 0, &erreur);
 
718
        if (erreur != NULL)
 
719
        {
 
720
                cd_warning ("%s\n", erreur->message);
 
721
                g_error_free (erreur);
 
722
                return ;
 
723
        }
 
724
        
 
725
        const gchar *cFileName;
 
726
        gchar *cContent;
 
727
        gsize length;
 
728
        GString *sIndexFile = g_string_new ("");
 
729
        while ((cFileName = g_dir_read_name (dir)) != NULL)
 
730
        {
 
731
                g_string_printf (sIndexFile, "%s/%s/index.theme", cDirPath, cFileName);
 
732
                if (! g_file_test (sIndexFile->str, G_FILE_TEST_EXISTS))
 
733
                        continue;
 
734
                        
 
735
                GKeyFile *pKeyFile = cairo_dock_open_key_file (sIndexFile->str);
 
736
                if (pKeyFile == NULL)
 
737
                        continue;
 
738
                
 
739
                if (! g_key_file_get_boolean (pKeyFile, "Icon Theme", "Hidden", NULL) && g_key_file_has_key (pKeyFile, "Icon Theme", "Directories", NULL))
 
740
                {
 
741
                        gchar *cName = g_key_file_get_string (pKeyFile, "Icon Theme", "Name", NULL);
 
742
                        if (cName != NULL)
 
743
                        {
 
744
                                g_hash_table_insert (pHashTable, cName, g_strdup (cName));
 
745
                        }
 
746
                }
 
747
                
 
748
                g_key_file_free (pKeyFile);
 
749
        }
 
750
        g_string_free (sIndexFile, TRUE);
 
751
        g_dir_close (dir);
 
752
}
 
753
 
 
754
static GHashTable *_cairo_dock_build_icon_themes_list (const gchar **cDirs)
 
755
{
 
756
        GHashTable *pHashTable = g_hash_table_new_full (g_str_hash,
 
757
                g_str_equal,
 
758
                g_free,
 
759
                g_free);
 
760
        gchar *cName = g_strdup (N_("_Custom Icons_"));
 
761
        g_hash_table_insert (pHashTable, cName, g_strdup (gettext (cName)));
 
762
        
 
763
        int i;
 
764
        for (i = 0; cDirs[i] != NULL; i ++)
 
765
        {
 
766
                _list_icon_theme_in_dir (cDirs[i], pHashTable);
 
767
        }
 
768
        return pHashTable;
 
769
}
 
770
 
 
771
static gboolean _add_module_to_modele (gchar *cModuleName, CairoDockModule *pModule, gpointer *data)
 
772
{
 
773
        int iCategory = GPOINTER_TO_INT (data[0]);
 
774
        if (pModule->pVisitCard->iCategory == iCategory || (iCategory == -1 && pModule->pVisitCard->iCategory != CAIRO_DOCK_CATEGORY_SYSTEM && pModule->pVisitCard->iCategory != CAIRO_DOCK_CATEGORY_THEME && ! cairo_dock_module_is_auto_loaded (pModule)))
 
775
        {
 
776
                //g_print (" + %s\n",  pModule->pVisitCard->cIconFilePath);
 
777
                GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size (pModule->pVisitCard->cIconFilePath, 32, 32, NULL);
 
778
                GtkListStore *pModele = data[1];
 
779
                GtkTreeIter iter;
 
780
                memset (&iter, 0, sizeof (GtkTreeIter));
 
781
                gtk_list_store_append (GTK_LIST_STORE (pModele), &iter);
 
782
                gtk_list_store_set (GTK_LIST_STORE (pModele), &iter,
 
783
                        CAIRO_DOCK_MODEL_NAME, dgettext (pModule->pVisitCard->cGettextDomain, pModule->pVisitCard->cModuleName),  /// cTitle ?...
 
784
                        CAIRO_DOCK_MODEL_RESULT, cModuleName,
 
785
                        CAIRO_DOCK_MODEL_DESCRIPTION_FILE, dgettext (pModule->pVisitCard->cGettextDomain, pModule->pVisitCard->cDescription),
 
786
                        CAIRO_DOCK_MODEL_IMAGE, pModule->pVisitCard->cPreviewFilePath,
 
787
                        CAIRO_DOCK_MODEL_ICON, pixbuf,
 
788
                        CAIRO_DOCK_MODEL_STATE, pModule->pVisitCard->iCategory,
 
789
                        CAIRO_DOCK_MODEL_ACTIVE, (pModule->pInstancesList != NULL), -1);
 
790
                g_object_unref (pixbuf);
 
791
        }
 
792
        return FALSE;
 
793
}
 
794
 
 
795
static void _cairo_dock_activate_one_module (GtkCellRendererToggle * cell_renderer, gchar * path, GtkTreeModel * model)
 
796
{
 
797
        GtkTreeIter iter;
 
798
        if (! gtk_tree_model_get_iter_from_string (model, &iter, path))
 
799
                return ;
 
800
        gchar *cModuleName = NULL;
 
801
        gboolean bState;
 
802
        gtk_tree_model_get (model, &iter,
 
803
                CAIRO_DOCK_MODEL_RESULT, &cModuleName,
 
804
                CAIRO_DOCK_MODEL_ACTIVE, &bState, -1);
 
805
        
 
806
        bState = !bState;
 
807
        gtk_list_store_set (GTK_LIST_STORE (model), &iter, CAIRO_DOCK_MODEL_ACTIVE, bState, -1);
 
808
        
 
809
        /// passer en gras ?...
 
810
        
 
811
        CairoDockModule *pModule = cairo_dock_find_module_from_name (cModuleName);
 
812
        if (g_pMainDock == NULL)
 
813
        {
 
814
                cairo_dock_add_remove_element_to_key (g_cConfFile, "System", "modules", cModuleName, bState);
 
815
        }
 
816
        else if (pModule->pInstancesList == NULL)
 
817
        {
 
818
                cairo_dock_activate_module_and_load (cModuleName);
 
819
        }
 
820
        else
 
821
        {
 
822
                cairo_dock_deactivate_module_and_unload (cModuleName);
 
823
        }
 
824
        g_free (cModuleName);
 
825
}
561
826
 
562
827
#define _build_list_for_gui(pListStore, cEmptyItem, pHashTable, pHFunction) do { \
563
828
        if (pListStore != NULL)\
588
853
}
589
854
static void _cairo_dock_add_one_decoration_item (const gchar *cName, CairoDeskletDecoration *pDecoration, GtkListStore *pModele)
590
855
{
591
 
        cd_debug ("%s (%s)", __func__, cName);
592
856
        GtkTreeIter iter;
593
857
        memset (&iter, 0, sizeof (GtkTreeIter));
594
858
        gtk_list_store_append (GTK_LIST_STORE (pModele), &iter);
595
859
        gtk_list_store_set (GTK_LIST_STORE (pModele), &iter,
596
 
                CAIRO_DOCK_MODEL_NAME, cName,
 
860
                CAIRO_DOCK_MODEL_NAME, (pDecoration && pDecoration->cDisplayedName && *pDecoration->cDisplayedName != '\0' ? pDecoration->cDisplayedName : cName),
597
861
                CAIRO_DOCK_MODEL_RESULT, cName,
598
862
                CAIRO_DOCK_MODEL_DESCRIPTION_FILE, "none"/*(pRenderer != NULL ? pRenderer->cReadmeFilePath : "none")*/,
599
863
                CAIRO_DOCK_MODEL_IMAGE, "none"/*(pRenderer != NULL ? pRenderer->cPreviewFilePath : "none")*/, -1);
606
870
{
607
871
        _build_list_for_gui (s_pDecorationsListStore2, "default", pHashTable, _cairo_dock_add_one_decoration_item);
608
872
}
609
 
static void _cairo_dock_add_one_animation_item (const gchar *cName, gpointer data, GtkListStore *pModele)
 
873
static void _cairo_dock_add_one_animation_item (const gchar *cName, CairoDockAnimationRecord *pRecord, GtkListStore *pModele)
610
874
{
611
 
        gint iAnimationID = GPOINTER_TO_INT (data);
612
875
        GtkTreeIter iter;
613
876
        memset (&iter, 0, sizeof (GtkTreeIter));
614
877
        gtk_list_store_append (GTK_LIST_STORE (pModele), &iter);
615
878
        gtk_list_store_set (GTK_LIST_STORE (pModele), &iter,
616
 
                CAIRO_DOCK_MODEL_NAME, (cName != NULL && *cName != '\0' ? gettext (cName) : cName),
 
879
                CAIRO_DOCK_MODEL_NAME, (pRecord && pRecord->cDisplayedName != NULL && *pRecord->cDisplayedName != '\0' ? pRecord->cDisplayedName : cName),
617
880
                CAIRO_DOCK_MODEL_RESULT, cName,
618
881
                CAIRO_DOCK_MODEL_DESCRIPTION_FILE, "none",
619
882
                CAIRO_DOCK_MODEL_IMAGE, "none", -1);
662
925
                Icon *pPointingIcon = cairo_dock_search_icon_pointing_on_dock (pDock, NULL);
663
926
                if (CAIRO_DOCK_IS_APPLET (pPointingIcon) || CAIRO_DOCK_IS_MULTI_APPLI (pPointingIcon))
664
927
                        return ;
665
 
        }
 
928
        }       
666
929
        GtkTreeIter iter;
667
930
        memset (&iter, 0, sizeof (GtkTreeIter));
668
931
        gtk_list_store_append (GTK_LIST_STORE (pModele), &iter);
681
944
        cairo_dock_foreach_docks ((GHFunc) _cairo_dock_add_one_dock_item, s_pDocksListStore);
682
945
}
683
946
 
684
 
static void _cairo_dock_fill_modele_with_themes (const gchar *cThemeName, CairoDockTheme *pTheme, GtkListStore *pModele)
 
947
static void _cairo_dock_add_one_icon_theme_item (const gchar *cName, const gchar *cDisplayedName, GtkListStore *pModele)
 
948
{
 
949
        GtkTreeIter iter;
 
950
        memset (&iter, 0, sizeof (GtkTreeIter));
 
951
        gtk_list_store_append (GTK_LIST_STORE (pModele), &iter);
 
952
        //g_print ("+ %s (%s)\n", cName, cDisplayedName);
 
953
        gtk_list_store_set (GTK_LIST_STORE (pModele), &iter,
 
954
                CAIRO_DOCK_MODEL_NAME, cDisplayedName,
 
955
                CAIRO_DOCK_MODEL_RESULT, cName,
 
956
                CAIRO_DOCK_MODEL_DESCRIPTION_FILE, "none",
 
957
                CAIRO_DOCK_MODEL_IMAGE, "none", -1);
 
958
}
 
959
static void cairo_dock_build_icon_theme_list_for_gui (GHashTable *pHashTable)
 
960
{
 
961
        _build_list_for_gui (s_pIconThemeListStore, "", pHashTable, _cairo_dock_add_one_icon_theme_item);
 
962
}
 
963
 
 
964
static inline void _fill_modele_with_themes (const gchar *cThemeName, CairoDockTheme *pTheme, GtkListStore *pModele, gboolean bShowState, gboolean bInsertState)
685
965
{
686
966
        GtkTreeIter iter;
687
967
        memset (&iter, 0, sizeof (GtkTreeIter));
688
968
        gtk_list_store_append (GTK_LIST_STORE (pModele), &iter);
689
969
        gchar *cReadmePath = g_strdup_printf ("%s/readme", pTheme->cThemePath);
690
970
        gchar *cPreviewPath = g_strdup_printf ("%s/preview", pTheme->cThemePath);
 
971
        gchar *cResult = (bInsertState ? g_strdup_printf ("%s[%d]", cThemeName, pTheme->iType) : NULL);
 
972
        gchar *cDisplayedName = NULL;
 
973
        if (bShowState)
 
974
        {
 
975
                const gchar *cType;
 
976
                switch (pTheme->iType)
 
977
                {
 
978
                        case CAIRO_DOCK_LOCAL_THEME: cType              = "(Local)  "; break;
 
979
                        case CAIRO_DOCK_USER_THEME: cType               = "(User)   "; break;
 
980
                        case CAIRO_DOCK_DISTANT_THEME: cType    = "(Net)    "; break;
 
981
                        case CAIRO_DOCK_NEW_THEME: cType                = "(New)    "; break;
 
982
                        case CAIRO_DOCK_UPDATED_THEME: cType    = "(Updated)"; break;
 
983
                        default: cType = ""; break;
 
984
                }
 
985
                cDisplayedName = g_strconcat (cType, pTheme->cDisplayedName, NULL);
 
986
        }
691
987
        gtk_list_store_set (GTK_LIST_STORE (pModele), &iter,
692
 
                CAIRO_DOCK_MODEL_NAME, pTheme->cDisplayedName,
693
 
                CAIRO_DOCK_MODEL_RESULT, cThemeName,
 
988
                CAIRO_DOCK_MODEL_NAME, cDisplayedName ? cDisplayedName : pTheme->cDisplayedName,
 
989
                CAIRO_DOCK_MODEL_RESULT, cResult ? cResult : cThemeName,
694
990
                CAIRO_DOCK_MODEL_ACTIVE, FALSE,
695
991
                CAIRO_DOCK_MODEL_DESCRIPTION_FILE, cReadmePath,
696
992
                CAIRO_DOCK_MODEL_IMAGE, cPreviewPath, 
697
993
                CAIRO_DOCK_MODEL_ORDER, pTheme->iRating,
698
 
                CAIRO_DOCK_MODEL_ORDER2, pTheme->iSobriety, -1);
699
 
}
 
994
                CAIRO_DOCK_MODEL_ORDER2, pTheme->iSobriety,
 
995
                CAIRO_DOCK_MODEL_STATE, pTheme->iType, -1);
 
996
        g_free (cReadmePath);
 
997
        g_free (cPreviewPath);
 
998
        g_free (cResult);
 
999
        if (bShowState)
 
1000
                g_free (cDisplayedName);
 
1001
}
 
1002
static void _cairo_dock_fill_modele_with_themes (const gchar *cThemeName, CairoDockTheme *pTheme, GtkListStore *pModele)
 
1003
{
 
1004
        _fill_modele_with_themes (cThemeName, pTheme, pModele, FALSE, TRUE);
 
1005
}
 
1006
static void _cairo_dock_fill_modele_with_short_themes (const gchar *cThemeName, CairoDockTheme *pTheme, GtkListStore *pModele)
 
1007
{
 
1008
        _fill_modele_with_themes (cThemeName, pTheme, pModele, TRUE, TRUE);
 
1009
}
 
1010
 
 
1011
static void _got_themes_list (GHashTable *pThemeTable, gpointer *data)
 
1012
{
 
1013
        if (pThemeTable == NULL)
 
1014
        {
 
1015
                cairo_dock_set_status_message (data[1], "Couldn't list available themes (is connection alive ?)");
 
1016
                return ;
 
1017
        }
 
1018
        else
 
1019
                cairo_dock_set_status_message (data[1], "");
 
1020
        GtkWidget *pTreeView = data[0];
 
1021
        GtkListStore *modele = gtk_tree_view_get_model (GTK_TREE_VIEW (pTreeView));
 
1022
        g_hash_table_foreach (pThemeTable, (GHFunc)_cairo_dock_fill_modele_with_themes, modele);
 
1023
}
 
1024
 
 
1025
static void _got_themes_combo_list (GHashTable *pThemeTable, gpointer *data)
 
1026
{
 
1027
        if (pThemeTable == NULL)
 
1028
        {
 
1029
                cairo_dock_set_status_message (data[1], "Couldn't list available themes (is connection alive ?)");
 
1030
                return ;
 
1031
        }
 
1032
        else
 
1033
                cairo_dock_set_status_message (data[1], "");
 
1034
        GtkWidget *pCombo = data[0];
 
1035
        
 
1036
        gchar *cValue = data[2];
 
1037
        cairo_dock_fill_combo_with_themes (pCombo, pThemeTable, cValue);
 
1038
        g_free (cValue);
 
1039
        data[2] = NULL;
 
1040
}
 
1041
 
700
1042
static gboolean _cairo_dock_test_one_name (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer *data)
701
1043
{
702
1044
        gchar *cName = NULL, *cResult = NULL;
703
1045
        gtk_tree_model_get (model, iter, CAIRO_DOCK_MODEL_RESULT, &cResult, -1);
704
1046
        if (cResult == NULL)
705
1047
                gtk_tree_model_get (model, iter, CAIRO_DOCK_MODEL_NAME, &cName, -1);
 
1048
        else if (data[3])
 
1049
                cairo_dock_extract_theme_type_from_name (cResult);
706
1050
        if ((cResult && strcmp (data[0], cResult) == 0) || (cName && strcmp (data[0], cName) == 0))
707
1051
        {
708
1052
                GtkTreeIter *iter_to_fill = data[1];
717
1061
        g_free (cResult);
718
1062
        return FALSE;
719
1063
}
720
 
static gboolean _cairo_dock_find_iter_from_name (GtkListStore *pModele, const gchar *cName, GtkTreeIter *iter)
 
1064
static gboolean _cairo_dock_find_iter_from_name (GtkListStore *pModele, const gchar *cName, GtkTreeIter *iter, gboolean bIsTheme)
721
1065
{
722
1066
        //g_print ("%s (%s)\n", __func__, cName);
723
1067
        if (cName == NULL)
724
1068
                return FALSE;
725
1069
        gboolean bFound = FALSE;
726
 
        gconstpointer data[3] = {cName, iter, &bFound};
 
1070
        gconstpointer data[4] = {cName, iter, &bFound, GINT_TO_POINTER (bIsTheme)};
727
1071
        gtk_tree_model_foreach (GTK_TREE_MODEL (pModele), (GtkTreeModelForeachFunc) _cairo_dock_test_one_name, data);
728
1072
        return bFound;
729
1073
}
730
1074
 
 
1075
static void _cairo_dock_render_module_name (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model,GtkTreeIter *iter, gpointer data)
 
1076
{
 
1077
        gboolean bActive = FALSE;
 
1078
        gtk_tree_model_get (model, iter, CAIRO_DOCK_MODEL_ACTIVE, &bActive, -1);
 
1079
        
 
1080
        if (bActive)
 
1081
                g_object_set (cell, "weight", 800, "weight-set", TRUE, NULL);
 
1082
        else
 
1083
                g_object_set (cell, "weight", 400, "weight-set", FALSE, NULL);
 
1084
}
 
1085
 
 
1086
static void _cairo_dock_render_category (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model,GtkTreeIter *iter, gpointer data)
 
1087
{
 
1088
        const gchar *cCategory=NULL;
 
1089
        gint iCategory = 0;
 
1090
        gtk_tree_model_get (model, iter, CAIRO_DOCK_MODEL_STATE, &iCategory, -1);
 
1091
        switch (iCategory)
 
1092
        {
 
1093
                case CAIRO_DOCK_CATEGORY_APPLET_ACCESSORY:
 
1094
                        cCategory = _("Accessory");
 
1095
                        g_object_set (cell, "foreground", "#900009", NULL);  // rouge
 
1096
                        g_object_set (cell, "foreground-set", TRUE, NULL);
 
1097
                break;
 
1098
                case CAIRO_DOCK_CATEGORY_APPLET_DESKTOP:
 
1099
                        cCategory = _("Desktop");
 
1100
                        g_object_set (cell, "foreground", "#116E08", NULL);  // vert
 
1101
                        g_object_set (cell, "foreground-set", TRUE, NULL);
 
1102
                break;
 
1103
                case CAIRO_DOCK_CATEGORY_APPLET_CONTROLER:
 
1104
                        cCategory = _("Controler");
 
1105
                        g_object_set (cell, "foreground", "#004EA1", NULL);  // bleu
 
1106
                        g_object_set (cell, "foreground-set", TRUE, NULL);
 
1107
                break;
 
1108
                case CAIRO_DOCK_CATEGORY_PLUG_IN:
 
1109
                        cCategory = _("Plug-in");
 
1110
                        g_object_set (cell, "foreground", "#A58B0D", NULL);  // jaune
 
1111
                        g_object_set (cell, "foreground-set", TRUE, NULL);
 
1112
                break;
 
1113
        }
 
1114
        if (cCategory != NULL)
 
1115
        {
 
1116
                g_object_set (cell, "text", cCategory, NULL);
 
1117
        }
 
1118
}
 
1119
 
731
1120
#define CD_MAX_RATING 5
732
1121
static inline void _render_rating (GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, int iColumnIndex)
733
1122
{
748
1137
        }
749
1138
        else
750
1139
        {
751
 
                g_object_set (cell, "text", iColumnIndex == CAIRO_DOCK_MODEL_ORDER ? "rate me" : "-", NULL);
 
1140
                g_object_set (cell, "text", iColumnIndex == CAIRO_DOCK_MODEL_ORDER ? _("rate me") : "-", NULL);
752
1141
        }
753
1142
}
754
1143
static void _cairo_dock_render_sobriety (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model,GtkTreeIter *iter, gpointer data)
760
1149
        /// ignorer les themes "default"...
761
1150
        _render_rating (cell, model, iter, CAIRO_DOCK_MODEL_ORDER);
762
1151
}
 
1152
static void _cairo_dock_render_state (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model,GtkTreeIter *iter, gpointer data)
 
1153
{
 
1154
        const gchar *cState=NULL;
 
1155
        gint iState = 0;
 
1156
        gtk_tree_model_get (model, iter, CAIRO_DOCK_MODEL_STATE, &iState, -1);
 
1157
        switch (iState)
 
1158
        {
 
1159
                case CAIRO_DOCK_LOCAL_THEME:
 
1160
                        cState = _("Local");
 
1161
                        g_object_set (cell, "foreground-set", FALSE, NULL);
 
1162
                break;
 
1163
                case CAIRO_DOCK_USER_THEME:
 
1164
                        cState = _("User");
 
1165
                        g_object_set (cell, "foreground-set", FALSE, NULL);
 
1166
                break;
 
1167
                case CAIRO_DOCK_DISTANT_THEME:
 
1168
                        cState = _("Net");
 
1169
                        g_object_set (cell, "foreground-set", FALSE, NULL);
 
1170
                break;
 
1171
                case CAIRO_DOCK_NEW_THEME:
 
1172
                        cState = _("New");
 
1173
                        g_object_set (cell, "foreground", "#FF0000", NULL);  // "red"
 
1174
                        g_object_set (cell, "foreground-set", TRUE, NULL);
 
1175
                break;
 
1176
                case CAIRO_DOCK_UPDATED_THEME:
 
1177
                        cState = _("Updated");
 
1178
                        g_object_set (cell, "foreground", "#FF0000", NULL);  // "red"
 
1179
                        g_object_set (cell, "foreground-set", TRUE, NULL);
 
1180
                break;
 
1181
                default:
 
1182
                break;
 
1183
        }
 
1184
        if (cState != NULL)
 
1185
        {
 
1186
                g_object_set (cell, "text", cState, NULL);
 
1187
        }
 
1188
}
763
1189
static GtkListStore *_make_note_list_store (void)
764
1190
{
765
1191
        GString *s = g_string_sized_new (CD_MAX_RATING*4+1);
806
1232
        } while (1);
807
1233
        //g_print ("iRating : %d\n", iRating);
808
1234
        
809
 
        gchar *cDisplayedName = NULL, *cThemeName = NULL;
810
 
        gtk_tree_model_get (model, &it, CAIRO_DOCK_MODEL_NAME, &cDisplayedName, CAIRO_DOCK_MODEL_RESULT, &cThemeName, -1);
811
 
        g_return_if_fail (cDisplayedName != NULL && cThemeName != NULL);
 
1235
        gchar /** *cDisplayedName = NULL, */*cThemeName = NULL;
 
1236
        gint iState;
 
1237
        gtk_tree_model_get (model, &it,
 
1238
                ///CAIRO_DOCK_MODEL_NAME, &cDisplayedName,
 
1239
                CAIRO_DOCK_MODEL_RESULT, &cThemeName,
 
1240
                CAIRO_DOCK_MODEL_STATE, &iState, -1);
 
1241
        g_return_if_fail (/**cDisplayedName != NULL && */cThemeName != NULL);
812
1242
        //g_print ("theme : %s / %s\n", cThemeName, cDisplayedName);
813
1243
        
814
1244
        gchar *cRatingDir = g_strdup_printf ("%s/%s/.rating", g_cCairoDockDataDir, "themes");  // il y'a un probleme ici, on ne connait pas le repertoire utilisateur des themes. donc ce code ne marche que pour les themes du dock (et n'est utilise que pour ca)
815
1245
        gchar *cRatingFile = g_strdup_printf ("%s/%s", cRatingDir, cThemeName);
816
1246
        //g_print ("on ecrit dans %s\n", cRatingFile);
817
 
        if (strncmp (cDisplayedName, CAIRO_DOCK_PREFIX_NET_THEME, strlen (CAIRO_DOCK_PREFIX_NET_THEME)) != 0 || g_file_test (cRatingFile, G_FILE_TEST_EXISTS))  // ca n'est pas un theme distant, ou l'utilisateur a deja vote auparavant pour ce theme.
 
1247
        if (iState == CAIRO_DOCK_USER_THEME || iState == CAIRO_DOCK_LOCAL_THEME/**strncmp (cDisplayedName, CAIRO_DOCK_PREFIX_NET_THEME, strlen (CAIRO_DOCK_PREFIX_NET_THEME)) != 0*/ || g_file_test (cRatingFile, G_FILE_TEST_EXISTS))  // ca n'est pas un theme distant, ou l'utilisateur a deja vote auparavant pour ce theme.
818
1248
        {
819
1249
                if (!g_file_test (cRatingDir, G_FILE_TEST_IS_DIR))
820
1250
                {
844
1274
                else
845
1275
                        cairo_dock_show_general_message (_("You have to try the theme before you can rate it."), 3000);
846
1276
        }
847
 
        g_free (cDisplayedName);
 
1277
        ///g_free (cDisplayedName);
848
1278
        g_free (cThemeName);
849
1279
        g_free (cRatingFile);
850
1280
        g_free (cRatingDir);
871
1301
                else
872
1302
                        cairo_dock_show_general_message (cMessage, iDuration);
873
1303
        }
 
1304
        else if (pModule != NULL && pModule->pInstancesList == NULL)
 
1305
        {
 
1306
                cMessage = g_strdup_printf (_("The '%s' plug-in is not active.\nBe sure to activate it to enjoy these features."), cModuleName);
 
1307
                int iDuration = 8e3;
 
1308
                if (pIcon != NULL && pDock != NULL)
 
1309
                        cairo_dock_show_temporary_dialog_with_icon (cMessage, pIcon, CAIRO_CONTAINER (pDock), iDuration, "same icon");
 
1310
        }
874
1311
        else
875
1312
        {
876
 
                CairoDockGroupDescription *pGroupDescription = cairo_dock_find_module_description (cModuleName);
877
 
                if (pGroupDescription == NULL)
878
 
                {
879
 
                        cairo_dock_build_main_ihm (g_cConfFile, FALSE);
880
 
                        pGroupDescription = cairo_dock_find_module_description (cModuleName);
881
 
                        g_return_if_fail (pGroupDescription != NULL);
882
 
                }
883
 
                if (pModule != NULL && pModule->pInstancesList == NULL)
884
 
                {
885
 
                        cMessage = g_strdup_printf (_("The '%s' plug-in is not active.\nBe sure to activate it to enjoy these features."), cModuleName);
886
 
                        int iDuration = 8e3;
887
 
                        if (pIcon != NULL && pDock != NULL)
888
 
                                cairo_dock_show_temporary_dialog_with_icon (cMessage, pIcon, CAIRO_CONTAINER (pDock), iDuration, "same icon");
889
 
                        else
890
 
                                cairo_dock_show_general_message (cMessage, 8000);
891
 
                }
892
 
                cairo_dock_show_group (pGroupDescription);
 
1313
                cairo_dock_show_module_gui (cModuleName);
893
1314
        }
894
1315
        g_free (cMessage);
895
1316
}
902
1323
#define _pack_subwidget(pSubWidget) do {\
903
1324
        pSubWidgetList = g_slist_append (pSubWidgetList, pSubWidget);\
904
1325
        _pack_in_widget_box (pSubWidget); } while (0)
 
1326
#define _pack_hscale(pSubWidget) do {\
 
1327
        GtkWidget *pExtendedWidget;\
 
1328
        if (pAuthorizedValuesList != NULL && pAuthorizedValuesList[0] != NULL && pAuthorizedValuesList[1] != NULL && pAuthorizedValuesList[2] != NULL && pAuthorizedValuesList[3] != NULL) {\
 
1329
                pExtendedWidget = gtk_hbox_new (FALSE, 0);\
 
1330
                GtkWidget *label = gtk_label_new (dgettext (cGettextDomain, pAuthorizedValuesList[2]));\
 
1331
                GtkWidget *pAlign = gtk_alignment_new (1., 1., 0., 0.);\
 
1332
                gtk_container_add (GTK_CONTAINER (pAlign), label);\
 
1333
                gtk_box_pack_start (GTK_BOX (pExtendedWidget), pAlign, FALSE, FALSE, 0);\
 
1334
                gtk_box_pack_start (GTK_BOX (pExtendedWidget), pSubWidget, FALSE, FALSE, 0);\
 
1335
                label = gtk_label_new (dgettext (cGettextDomain, pAuthorizedValuesList[3]));\
 
1336
                pAlign = gtk_alignment_new (1., 1., 0., 0.);\
 
1337
                gtk_container_add (GTK_CONTAINER (pAlign), label);\
 
1338
                gtk_box_pack_start (GTK_BOX (pExtendedWidget), pAlign, FALSE, FALSE, 0); }\
 
1339
        else {\
 
1340
                pExtendedWidget = pOneWidget; }\
 
1341
        pSubWidgetList = g_slist_append (pSubWidgetList, pSubWidget);\
 
1342
        _pack_in_widget_box (pExtendedWidget); } while (0)
905
1343
#define _add_combo_from_modele(modele, bAddPreviewWidgets, bWithEntry) do {\
906
1344
        if (modele == NULL) { \
907
1345
                pOneWidget = gtk_combo_box_entry_new ();\
908
1346
                _pack_subwidget (pOneWidget); }\
909
1347
        else {\
910
1348
                cValue = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL);\
911
 
                pOneWidget = (bWithEntry ? gtk_combo_box_entry_new_with_model (GTK_TREE_MODEL (modele), CAIRO_DOCK_MODEL_NAME) : gtk_combo_box_new_with_model (GTK_TREE_MODEL (modele)));\
912
 
                rend = gtk_cell_renderer_text_new ();\
913
 
                gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (pOneWidget), rend, FALSE);\
914
 
                gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (pOneWidget), rend, "text", CAIRO_DOCK_MODEL_NAME, NULL);\
 
1349
                if (bWithEntry) {\
 
1350
                        pOneWidget = gtk_combo_box_entry_new_with_model (GTK_TREE_MODEL (modele), CAIRO_DOCK_MODEL_NAME); }\
 
1351
                else {\
 
1352
                        pOneWidget = gtk_combo_box_new_with_model (GTK_TREE_MODEL (modele));\
 
1353
                        rend = gtk_cell_renderer_text_new ();\
 
1354
                        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (pOneWidget), rend, FALSE);\
 
1355
                        gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (pOneWidget), rend, "text", CAIRO_DOCK_MODEL_NAME, NULL);}\
915
1356
                if (bAddPreviewWidgets) {\
916
1357
                        pDescriptionLabel = gtk_label_new (NULL);\
 
1358
                        g_signal_connect (pMainWindow, "destroy-event", G_CALLBACK (on_delete_async_widget), pDescriptionLabel);\
 
1359
                        g_object_ref (pDescriptionLabel);\
917
1360
                        gtk_label_set_use_markup  (GTK_LABEL (pDescriptionLabel), TRUE);\
 
1361
                        gtk_widget_set_size_request (pDescriptionLabel, 500, CAIRO_DOCK_PREVIEW_HEIGHT);\
 
1362
                        gtk_label_set_justify (GTK_LABEL (pDescriptionLabel), GTK_JUSTIFY_LEFT);\
 
1363
                        gtk_label_set_line_wrap (GTK_LABEL (pDescriptionLabel), TRUE);\
918
1364
                        pPreviewImage = gtk_image_new_from_pixbuf (NULL);\
 
1365
                        g_signal_connect (pMainWindow, "delete-event", G_CALLBACK (on_delete_async_widget), pPreviewImage);\
 
1366
                        g_object_ref (pPreviewImage);\
 
1367
                        gtk_widget_set (pPreviewImage, "height-request", CAIRO_DOCK_PREVIEW_HEIGHT, "width-request", CAIRO_DOCK_PREVIEW_WIDTH, NULL);\
919
1368
                        _allocate_new_buffer;\
920
1369
                        data[0] = pDescriptionLabel;\
921
1370
                        data[1] = pPreviewImage;\
924
1373
                        gtk_box_pack_start (GTK_BOX (pAdditionalItemsVBox ? pAdditionalItemsVBox : pKeyBox), pPreviewBox, FALSE, FALSE, 0);\
925
1374
                        gtk_box_pack_start (GTK_BOX (pPreviewBox), pPreviewImage, FALSE, FALSE, 0);\
926
1375
                        gtk_box_pack_start (GTK_BOX (pPreviewBox), pDescriptionLabel, FALSE, FALSE, 0); }\
927
 
                if (_cairo_dock_find_iter_from_name (modele, cValue, &iter))\
 
1376
                if (_cairo_dock_find_iter_from_name (modele, cValue, &iter, FALSE))\
928
1377
                        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (pOneWidget), &iter);\
929
1378
                _pack_subwidget (pOneWidget);\
930
1379
                g_free (cValue); } } while (0)
1060
1509
        GtkTreeIter iter;
1061
1510
        GtkTreeSelection *selection;
1062
1511
        GtkWidget *pBackButton;
1063
 
        gchar *cGroupComment, *cKeyName, *cKeyComment, *cUsefulComment, *cAuthorizedValuesChain, *pTipString, **pAuthorizedValuesList, *cSmallGroupIcon=NULL, *cDisplayedGroupName=NULL;
 
1512
        GtkWidget *pControlContainer = NULL;
 
1513
        int iFirstSensitiveWidget = 0, iNbControlledWidgets = 0, iNbSensitiveWidgets = 0;
 
1514
        gchar *cGroupComment, *cKeyName, *cKeyComment, *cUsefulComment, *cAuthorizedValuesChain, *cTipString, **pAuthorizedValuesList, *cSmallGroupIcon=NULL, *cDisplayedGroupName=NULL;  // ne pas effacer 'cTipString' et 'cUsefulComment', ils pointent dans cKeyComment.
1064
1515
        gpointer *pGroupKeyWidget;
1065
1516
        int i, j;
1066
1517
        guint k, iNbElements;
1080
1531
        pGroupBox = NULL;
1081
1532
        pFrame = NULL;
1082
1533
        pFrameVBox = NULL;
 
1534
        pControlContainer = NULL;
1083
1535
        cGroupComment  = g_key_file_get_comment (pKeyFile, cGroupName, NULL, NULL);
1084
1536
        if (cGroupComment != NULL)
1085
1537
        {
1096
1548
                        {
1097
1549
                                *str = '\0';
1098
1550
                                cDisplayedGroupName = str + 1;
1099
 
                        }       
 
1551
                        }
1100
1552
                }
1101
1553
        }
1102
1554
        
1107
1559
                cKeyName = pKeyList[j];
1108
1560
                
1109
1561
                //\______________ On parse le commentaire.
 
1562
                pAuthorizedValuesList = NULL;
 
1563
                cTipString = NULL;
 
1564
                iNbElements = 0;
1110
1565
                cKeyComment =  g_key_file_get_comment (pKeyFile, cGroupName, cKeyName, NULL);
1111
 
                cUsefulComment = cairo_dock_parse_key_comment (cKeyComment, &iElementType, &iNbElements, &pAuthorizedValuesList, &bIsAligned, &pTipString);
 
1566
                cUsefulComment = cairo_dock_parse_key_comment (cKeyComment, &iElementType, &iNbElements, &pAuthorizedValuesList, &bIsAligned, &cTipString);
1112
1567
                if (cUsefulComment == NULL)
1113
1568
                {
1114
1569
                        g_free (cKeyComment);
1115
1570
                        continue;
1116
1571
                }
 
1572
                if (iElementType == '[')  // on gere le bug de la Glib, qui rajoute les nouvelles cles apres le commentaire du groupe suivant !
 
1573
                {
 
1574
                        g_free (cKeyComment);
 
1575
                        continue;
 
1576
                }
1117
1577
                
1118
1578
                //\______________ On cree la boite du groupe si c'est la 1ere cle valide.
1119
1579
                if (pGroupBox == NULL)  // maintenant qu'on a au moins un element dans ce groupe, on cree sa page dans le notebook.
1175
1635
                        else
1176
1636
                        {
1177
1637
                                pKeyBox = (bIsAligned ? gtk_hbox_new : gtk_vbox_new) (FALSE, CAIRO_DOCK_GUI_MARGIN);
1178
 
                                gtk_box_pack_start (pFrameVBox != NULL ? GTK_BOX (pFrameVBox) :  GTK_BOX (pGroupBox),
 
1638
                                gtk_box_pack_start (pFrameVBox != NULL ? GTK_BOX (pFrameVBox) : GTK_BOX (pGroupBox),
1179
1639
                                        pKeyBox,
1180
1640
                                        FALSE,
1181
1641
                                        FALSE,
1182
1642
                                        0);
1183
 
                        }
1184
 
                        if (pTipString != NULL)
1185
 
                        {
1186
 
                                gtk_widget_set_tooltip_text (pKeyBox, dgettext (cGettextDomain, pTipString));
 
1643
                                
 
1644
                        }
 
1645
                        if (cTipString != NULL)
 
1646
                        {
 
1647
                                gtk_widget_set_tooltip_text (pKeyBox, dgettext (cGettextDomain, cTipString));
 
1648
                        }
 
1649
                        if (iNbControlledWidgets > 0 && pControlContainer != NULL)
 
1650
                        {
 
1651
                                //g_print ("ctrl (%d widgets)\n", iNbControlledWidgets);
 
1652
                                if (pControlContainer == (pFrameVBox ? pFrameVBox : pGroupBox))
 
1653
                                {
 
1654
                                        //g_print ("ctrl (iNbControlledWidgets:%d, iFirstSensitiveWidget:%d, iNbSensitiveWidgets:%d)\n", iNbControlledWidgets, iFirstSensitiveWidget, iNbSensitiveWidgets);
 
1655
                                        iNbControlledWidgets --;
 
1656
                                        if (iFirstSensitiveWidget > 0)
 
1657
                                                iFirstSensitiveWidget --;
 
1658
                                        
 
1659
                                        GtkWidget *w = (pAdditionalItemsVBox ? pAdditionalItemsVBox : pKeyBox);
 
1660
                                        if (iFirstSensitiveWidget == 0 && iNbSensitiveWidgets > 0)
 
1661
                                        {
 
1662
                                                //g_print (" => sensitive\n");
 
1663
                                                iNbSensitiveWidgets --;
 
1664
                                                if (GTK_IS_EXPANDER (w))
 
1665
                                                        gtk_expander_set_expanded (GTK_EXPANDER (w), TRUE);
 
1666
                                        }
 
1667
                                        else
 
1668
                                        {
 
1669
                                                //g_print (" => unsensitive\n");
 
1670
                                                if (!GTK_IS_EXPANDER (w))
 
1671
                                                        gtk_widget_set_sensitive (w, FALSE);
 
1672
                                        }
 
1673
                                }
1187
1674
                        }
1188
1675
                        
1189
1676
                        //\______________ On cree le label descriptif et la boite du widget.
1190
1677
                        if (iElementType != CAIRO_DOCK_WIDGET_EMPTY_WIDGET)
1191
1678
                        {
1192
 
                                if (*cUsefulComment != '\0' && strcmp (cUsefulComment, "...") != 0)
 
1679
                                pLabel = NULL;
 
1680
                                if (iElementType == CAIRO_DOCK_WIDGET_HANDBOOK)
 
1681
                                {
 
1682
                                        cValue = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL);
 
1683
                                        CairoDockModule *pModule = cairo_dock_find_module_from_name (cValue);
 
1684
                                        if (pModule != NULL)
 
1685
                                        {
 
1686
                                                gchar *cDescription = g_strdup_printf ("%s (v%s) by %s\n%s",
 
1687
                                                        pModule->pVisitCard->cModuleName,
 
1688
                                                        pModule->pVisitCard->cModuleVersion,
 
1689
                                                        pModule->pVisitCard->cAuthor,
 
1690
                                                        dgettext (pModule->pVisitCard->cGettextDomain,
 
1691
                                                                pModule->pVisitCard->cDescription));
 
1692
                                                pLabel = gtk_label_new (cDescription);
 
1693
                                                gtk_widget_set (pLabel, "width-request", 500, NULL);  // CAIRO_DOCK_PREVIEW_WIDTH
 
1694
                                                gtk_label_set_justify (GTK_LABEL (pLabel), GTK_JUSTIFY_LEFT);
 
1695
                                                gtk_label_set_line_wrap (GTK_LABEL (pLabel), TRUE);
 
1696
                                                g_free (cDescription);
 
1697
                                        }
 
1698
                                        g_free (cValue);
 
1699
                                }
 
1700
                                else if (*cUsefulComment != '\0' && strcmp (cUsefulComment, "...") != 0)
1193
1701
                                {
1194
1702
                                        pLabel = gtk_label_new (NULL);
1195
1703
                                        gtk_label_set_use_markup  (GTK_LABEL (pLabel), TRUE);
1196
1704
                                        gtk_label_set_markup (GTK_LABEL (pLabel), dgettext (cGettextDomain, cUsefulComment));
 
1705
                                }
 
1706
                                if (pLabel != NULL)
 
1707
                                {
1197
1708
                                        GtkWidget *pAlign = gtk_alignment_new (0., 0.5, 0., 0.);
1198
1709
                                        gtk_container_add (GTK_CONTAINER (pAlign), pLabel);
1199
1710
                                        gtk_box_pack_start (GTK_BOX (pKeyBox),
1219
1730
                switch (iElementType)
1220
1731
                {
1221
1732
                        case CAIRO_DOCK_WIDGET_CHECK_BUTTON :  // boolean
 
1733
                        case CAIRO_DOCK_WIDGET_CHECK_CONTROL_BUTTON :  // boolean qui controle le widget suivant
1222
1734
                                length = 0;
1223
1735
                                bValueList = g_key_file_get_boolean_list (pKeyFile, cGroupName, cKeyName, &length, NULL);
1224
 
 
 
1736
                                
1225
1737
                                for (k = 0; k < iNbElements; k ++)
1226
1738
                                {
1227
1739
                                        bValue =  (k < length ? bValueList[k] : FALSE);
1228
1740
                                        pOneWidget = gtk_check_button_new ();
1229
1741
                                        gtk_toggle_button_set_active  (GTK_TOGGLE_BUTTON (pOneWidget), bValue);
1230
 
 
 
1742
                                        
 
1743
                                        if (iElementType == CAIRO_DOCK_WIDGET_CHECK_CONTROL_BUTTON)
 
1744
                                        {
 
1745
                                                _allocate_new_buffer;
 
1746
                                                data[0] = pKeyBox;
 
1747
                                                data[1] = pFrameVBox != NULL ? pFrameVBox : pGroupBox;
 
1748
                                                if (pAuthorizedValuesList != NULL && pAuthorizedValuesList[0] != NULL)
 
1749
                                                        iNbControlledWidgets = g_ascii_strtod (pAuthorizedValuesList[0], NULL);
 
1750
                                                else
 
1751
                                                        iNbControlledWidgets = 1;
 
1752
                                                data[2] = GINT_TO_POINTER (iNbControlledWidgets);
 
1753
                                                g_signal_connect (G_OBJECT (pOneWidget), "toggled", G_CALLBACK(_cairo_dock_toggle_control_button), data);
 
1754
                                                if (! bValue)  // les widgets suivants seront inactifs.
 
1755
                                                {
 
1756
                                                        iNbSensitiveWidgets = 0;
 
1757
                                                        iFirstSensitiveWidget = 1;
 
1758
                                                        pControlContainer = pFrameVBox != NULL ? pFrameVBox : pGroupBox;
 
1759
                                                }
 
1760
                                                else
 
1761
                                                        iNbControlledWidgets = 0;
 
1762
                                        }
 
1763
                                        
1231
1764
                                        _pack_subwidget (pOneWidget);
1232
1765
                                }
1233
1766
                                g_free (bValueList);
1270
1803
                                                1,
1271
1804
                                                MAX (1, (iMaxValue - iMinValue) / 20),
1272
1805
                                                0);
1273
 
 
 
1806
                                        
1274
1807
                                        if (iElementType == CAIRO_DOCK_WIDGET_HSCALE_INTEGER)
1275
1808
                                        {
1276
1809
                                                pOneWidget = gtk_hscale_new (GTK_ADJUSTMENT (pAdjustment));
1277
1810
                                                gtk_scale_set_digits (GTK_SCALE (pOneWidget), 0);
1278
1811
                                                gtk_widget_set (pOneWidget, "width-request", 150, NULL);
 
1812
                                                
 
1813
                                                _pack_hscale (pOneWidget);
1279
1814
                                        }
1280
1815
                                        else
1281
1816
                                        {
1282
1817
                                                pOneWidget = gtk_spin_button_new (GTK_ADJUSTMENT (pAdjustment), 1., 0);
 
1818
                                                
 
1819
                                                _pack_subwidget (pOneWidget);
1283
1820
                                        }
1284
1821
                                        g_object_set (pAdjustment, "lower", (double) iMinValue, "upper", (double) iMaxValue, NULL); // le 'width-request' sur un GtkHScale avec 'fMinValue' non nul plante ! Donc on les met apres...
1285
1822
                                        gtk_adjustment_set_value (GTK_ADJUSTMENT (pAdjustment), iValue);
1286
 
 
1287
 
                                        _pack_subwidget (pOneWidget);
 
1823
                                        
1288
1824
                                        if (iElementType == CAIRO_DOCK_WIDGET_SIZE_INTEGER && k+1 < iNbElements)  // on rajoute le separateur.
1289
1825
                                        {
1290
1826
                                                GtkWidget *pLabelX = gtk_label_new ("x");
1315
1851
                        break;
1316
1852
 
1317
1853
                        case CAIRO_DOCK_WIDGET_SPIN_DOUBLE :  // float.
1318
 
                        case CAIRO_DOCK_WIDGET_COLOR_SELECTOR_RGB :  // float x3 avec un bouton de choix de couleur.
1319
 
                        case CAIRO_DOCK_WIDGET_COLOR_SELECTOR_RGBA :  // float x4 avec un bouton de choix de couleur.
1320
1854
                        case CAIRO_DOCK_WIDGET_HSCALE_DOUBLE :  // float dans un HScale.
1321
 
                                if (iElementType == CAIRO_DOCK_WIDGET_COLOR_SELECTOR_RGB || iElementType == CAIRO_DOCK_WIDGET_COLOR_SELECTOR_RGBA)  // couleur
1322
 
                                {
 
1855
                                if (pAuthorizedValuesList != NULL && pAuthorizedValuesList[0] != NULL)
 
1856
                                        fMinValue = g_ascii_strtod (pAuthorizedValuesList[0], NULL);
 
1857
                                else
1323
1858
                                        fMinValue = 0;
1324
 
                                        fMaxValue = 1;
1325
 
                                        if (iNbElements == 1)  // nbre d'elements non precise
1326
 
                                        {
1327
 
                                                iNbElements = (iElementType == CAIRO_DOCK_WIDGET_COLOR_SELECTOR_RGB ? 3 : 4);
1328
 
                                        }
1329
 
                                }
 
1859
                                if (pAuthorizedValuesList != NULL && pAuthorizedValuesList[1] != NULL)
 
1860
                                        fMaxValue = g_ascii_strtod (pAuthorizedValuesList[1], NULL);
1330
1861
                                else
1331
 
                                {
1332
 
                                        if (pAuthorizedValuesList != NULL && pAuthorizedValuesList[0] != NULL)
1333
 
                                                fMinValue = g_ascii_strtod (pAuthorizedValuesList[0], NULL);
1334
 
                                        else
1335
 
                                                fMinValue = 0;
1336
 
                                        if (pAuthorizedValuesList != NULL && pAuthorizedValuesList[1] != NULL)
1337
 
                                                fMaxValue = g_ascii_strtod (pAuthorizedValuesList[1], NULL);
1338
 
                                        else
1339
 
                                                fMaxValue = 9999;
1340
 
                                }
 
1862
                                        fMaxValue = 9999;
1341
1863
                                length = 0;
1342
1864
                                fValueList = g_key_file_get_double_list (pKeyFile, cGroupName, cKeyName, &length, NULL);
1343
1865
                                for (k = 0; k < iNbElements; k ++)
1344
1866
                                {
1345
1867
                                        fValue =  (k < length ? fValueList[k] : 0);
1346
 
 
 
1868
                                        
1347
1869
                                        GtkObject *pAdjustment = gtk_adjustment_new (fValue,
1348
1870
                                                0,
1349
1871
                                                1,
1350
1872
                                                (fMaxValue - fMinValue) / 20.,
1351
1873
                                                (fMaxValue - fMinValue) / 10.,
1352
1874
                                                0);
1353
 
 
 
1875
                                        
1354
1876
                                        if (iElementType == CAIRO_DOCK_WIDGET_HSCALE_DOUBLE)
1355
1877
                                        {
1356
1878
                                                pOneWidget = gtk_hscale_new (GTK_ADJUSTMENT (pAdjustment));
1357
1879
                                                gtk_scale_set_digits (GTK_SCALE (pOneWidget), 3);
1358
1880
                                                gtk_widget_set (pOneWidget, "width-request", 150, NULL);
 
1881
                                                
 
1882
                                                _pack_hscale (pOneWidget);
1359
1883
                                        }
1360
1884
                                        else
1361
1885
                                        {
1362
1886
                                                pOneWidget = gtk_spin_button_new (GTK_ADJUSTMENT (pAdjustment),
1363
1887
                                                        1.,
1364
1888
                                                        3);
 
1889
                                                _pack_subwidget (pOneWidget);
1365
1890
                                        }
1366
1891
                                        g_object_set (pAdjustment, "lower", fMinValue, "upper", fMaxValue, NULL); // le 'width-request' sur un GtkHScale avec 'fMinValue' non nul plante ! Donc on les met apres...
1367
1892
                                        gtk_adjustment_set_value (GTK_ADJUSTMENT (pAdjustment), fValue);
1368
 
 
1369
 
                                        _pack_subwidget (pOneWidget);
1370
 
                                }
1371
 
                                if (iElementType == CAIRO_DOCK_WIDGET_COLOR_SELECTOR_RGB || iElementType == CAIRO_DOCK_WIDGET_COLOR_SELECTOR_RGBA)
1372
 
                                {
1373
 
                                        if (length > 2)
1374
 
                                        {
1375
 
                                                gdkColor.red = fValueList[0] * 65535;
1376
 
                                                gdkColor.green = fValueList[1] * 65535;
1377
 
                                                gdkColor.blue = fValueList[2] * 65535;
1378
 
                                        }
1379
 
                                        pColorButton = gtk_color_button_new_with_color (&gdkColor);
1380
 
                                        if (iNbElements > 3)
1381
 
                                        {
1382
 
                                                gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (pColorButton), TRUE);
1383
 
                                                if (length > 3)
1384
 
                                                        gtk_color_button_set_alpha (GTK_COLOR_BUTTON (pColorButton), fValueList[3] * 65535);
1385
 
                                                else
1386
 
                                                        gtk_color_button_set_alpha (GTK_COLOR_BUTTON (pColorButton), 65535);
1387
 
                                        }
 
1893
                                }
 
1894
                                bAddBackButton = TRUE,
 
1895
                                g_free (fValueList);
 
1896
                        break;
 
1897
                        
 
1898
                        case CAIRO_DOCK_WIDGET_COLOR_SELECTOR_RGB :  // float x3 avec un bouton de choix de couleur.
 
1899
                        case CAIRO_DOCK_WIDGET_COLOR_SELECTOR_RGBA :  // float x4 avec un bouton de choix de couleur.
 
1900
                                iNbElements = (iElementType == CAIRO_DOCK_WIDGET_COLOR_SELECTOR_RGB ? 3 : 4);
 
1901
                                length = 0;
 
1902
                                fValueList = g_key_file_get_double_list (pKeyFile, cGroupName, cKeyName, &length, NULL);
 
1903
                                if (length > 2)
 
1904
                                {
 
1905
                                        gdkColor.red = fValueList[0] * 65535;
 
1906
                                        gdkColor.green = fValueList[1] * 65535;
 
1907
                                        gdkColor.blue = fValueList[2] * 65535;
 
1908
                                }
 
1909
                                pOneWidget = gtk_color_button_new_with_color (&gdkColor);
 
1910
                                if (iElementType == CAIRO_DOCK_WIDGET_COLOR_SELECTOR_RGBA)
 
1911
                                {
 
1912
                                        gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (pOneWidget), TRUE);
 
1913
                                        if (length > 3)
 
1914
                                                gtk_color_button_set_alpha (GTK_COLOR_BUTTON (pOneWidget), fValueList[3] * 65535);
1388
1915
                                        else
1389
 
                                                gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (pColorButton), FALSE);
1390
 
 
1391
 
                                        _pack_in_widget_box (pColorButton);
1392
 
                                        g_signal_connect (G_OBJECT (pColorButton), "color-set", G_CALLBACK(_cairo_dock_set_color), pSubWidgetList);
1393
 
                                        g_signal_connect (G_OBJECT (pColorButton), "clicked", G_CALLBACK(_cairo_dock_get_current_color), pSubWidgetList);
 
1916
                                                gtk_color_button_set_alpha (GTK_COLOR_BUTTON (pOneWidget), 65535);
1394
1917
                                }
 
1918
                                else
 
1919
                                        gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (pOneWidget), FALSE);
 
1920
                                _pack_subwidget (pOneWidget);
1395
1921
                                bAddBackButton = TRUE,
1396
1922
                                g_free (fValueList);
1397
1923
                        break;
1398
 
 
 
1924
                        
1399
1925
                        case CAIRO_DOCK_WIDGET_VIEW_LIST :  // liste des vues.
1400
1926
                                _add_combo_from_modele (s_pRendererListStore, TRUE, FALSE);
1401
1927
                        break ;
1404
1930
                        case CAIRO_DOCK_WIDGET_THEME_LIST_ENTRY :  // idem mais avec une combo-entry.
1405
1931
                                //\______________ On construit le widget de visualisation de themes.
1406
1932
                                modele = _allocate_new_model ();
1407
 
                                gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (modele), CAIRO_DOCK_MODEL_NAME, GTK_SORT_ASCENDING);
 
1933
                                gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (modele), CAIRO_DOCK_MODEL_RESULT, GTK_SORT_ASCENDING);
1408
1934
                                
1409
1935
                                _add_combo_from_modele (modele, TRUE, iElementType == CAIRO_DOCK_WIDGET_THEME_LIST_ENTRY);
1410
1936
                                
1414
1940
                                        gchar *cShareThemesDir = NULL, *cUserThemesDir = NULL, *cDistantThemesDir = NULL;
1415
1941
                                        if (pAuthorizedValuesList[0] != NULL)
1416
1942
                                        {
1417
 
                                                cShareThemesDir = (*pAuthorizedValuesList[0] != '\0' ? pAuthorizedValuesList[0] : NULL);
 
1943
                                                cShareThemesDir = (*pAuthorizedValuesList[0] != '\0' ? cairo_dock_generate_file_path (pAuthorizedValuesList[0]) : NULL);  // on autorise les ~/blabla.
1418
1944
                                                if (pAuthorizedValuesList[1] != NULL)
1419
1945
                                                {
1420
1946
                                                        cUserThemesDir = g_strdup_printf ("%s/%s/%s", g_cCairoDockDataDir, CAIRO_DOCK_EXTRAS_DIR, pAuthorizedValuesList[1]);
1421
1947
                                                        cDistantThemesDir = pAuthorizedValuesList[2];
1422
1948
                                                }
1423
1949
                                        }
1424
 
                                        GHashTable *pThemeTable = cairo_dock_list_themes (cShareThemesDir, cUserThemesDir, cDistantThemesDir);
 
1950
                                        cairo_dock_set_status_message_printf (pMainWindow, _("Listing themes in '%s' ..."), cDistantThemesDir);
 
1951
                                        _allocate_new_buffer;
 
1952
                                        data[0] = pOneWidget;
 
1953
                                        data[1] = pMainWindow;
 
1954
                                        data[2] = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL);
 
1955
                                        CairoDockTask *pTask = cairo_dock_list_themes_async (cShareThemesDir, cUserThemesDir, cDistantThemesDir, (GFunc) _got_themes_combo_list, data);
 
1956
                                        g_object_set_data (G_OBJECT (pOneWidget), "cd-task", pTask);
 
1957
                                        g_signal_connect (pMainWindow, "delete-event", G_CALLBACK (on_delete_async_widget), pOneWidget);
 
1958
                                        g_object_ref (pOneWidget);  // on prend une reference pour que le widget reste en vie lorsqu'on recharge la fenetre (sinon le widget serait detruit sans que la fenetre ne le soit, et lors de la destruction de celle-ci, le signal delete-event serait emis, et la callback appelee avec un widget deja detruit).
1425
1959
                                        g_free (cUserThemesDir);
1426
 
                                        
1427
 
                                        cValue = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL);
1428
 
                                        cairo_dock_fill_combo_with_themes (pOneWidget, pThemeTable, cValue);
1429
 
                                        g_hash_table_destroy (pThemeTable);
1430
 
                                        g_free (cValue);
 
1960
                                        g_free (cShareThemesDir);
1431
1961
                                }
1432
1962
                        break ;
1433
1963
                        
1478
2008
                        
1479
2009
                        case CAIRO_DOCK_WIDGET_DESKLET_DECORATION_LIST :  // liste des decorations de desklet.
1480
2010
                        case CAIRO_DOCK_WIDGET_DESKLET_DECORATION_LIST_WITH_DEFAULT :  // idem mais avec le choix "defaut" en plus.
 
2011
                        {
1481
2012
                                _add_combo_from_modele ((iElementType == CAIRO_DOCK_WIDGET_DESKLET_DECORATION_LIST ? s_pDecorationsListStore : s_pDecorationsListStore2), FALSE, FALSE);
 
2013
                                
 
2014
                                _allocate_new_buffer;
 
2015
                                data[0] = pKeyBox;
 
2016
                                data[1] = pFrameVBox != NULL ? pFrameVBox : pGroupBox;
 
2017
                                iNbControlledWidgets = 9;
 
2018
                                data[2] = GINT_TO_POINTER (iNbControlledWidgets);
 
2019
                                iNbControlledWidgets --;  // car dans cette fonction, on ne compte pas le separateur.
 
2020
                                g_signal_connect (G_OBJECT (pOneWidget), "changed", G_CALLBACK (_cairo_dock_select_custom_item_in_combo), data);
 
2021
                                
 
2022
                                GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (pOneWidget));
 
2023
                                GtkTreeIter iter;
 
2024
                                if (pOneWidget && gtk_combo_box_get_active_iter (GTK_COMBO_BOX (pOneWidget), &iter))
 
2025
                                {
 
2026
                                        gchar *cName = NULL;
 
2027
                                        gtk_tree_model_get (model, &iter,
 
2028
                                                CAIRO_DOCK_MODEL_RESULT, &cName, -1);
 
2029
                                        if (! cName || strcmp (cName, "personnal") != 0)
 
2030
                                        {
 
2031
                                                iNbSensitiveWidgets = 0;
 
2032
                                                iFirstSensitiveWidget = 1;
 
2033
                                                pControlContainer = pFrameVBox != NULL ? pFrameVBox : pGroupBox;
 
2034
                                        }
 
2035
                                        else
 
2036
                                                iNbControlledWidgets = 0;
 
2037
                                        g_free (cName);
 
2038
                                }
 
2039
                        }
1482
2040
                        break ;
1483
2041
                        
1484
2042
                        case CAIRO_DOCK_WIDGET_GAUGE_LIST :  // liste des themes de jauge.
1498
2056
                                
1499
2057
                                cValue = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL);
1500
2058
                                GtkTreeIter iter;
1501
 
                                if (_cairo_dock_find_iter_from_name (modele, cValue, &iter))
 
2059
                                if (_cairo_dock_find_iter_from_name (modele, cValue, &iter, FALSE))
1502
2060
                                        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (pOneWidget), &iter);
1503
2061
                                g_free (cValue);
1504
2062
                                
1505
2063
                                _pack_subwidget (pOneWidget);
1506
2064
                        break ;
1507
2065
                        
 
2066
                        case CAIRO_DOCK_WIDGET_ICON_THEME_LIST :
 
2067
                        {
 
2068
                                gchar *cUserPath = g_strdup_printf ("%s/.icons", g_getenv ("HOME"));
 
2069
                                const gchar *path[3];
 
2070
                                path[0] = (const gchar *)cUserPath;
 
2071
                                path[1] = "/usr/share/icons";
 
2072
                                path[2] = NULL;
 
2073
                                
 
2074
                                if (s_pIconThemeListStore != NULL)
 
2075
                                {
 
2076
                                        gtk_list_store_clear (s_pIconThemeListStore);
 
2077
                                        s_pIconThemeListStore = NULL;
 
2078
                                }
 
2079
                                
 
2080
                                GHashTable *pHashTable = _cairo_dock_build_icon_themes_list (path);
 
2081
                                g_free (cUserPath);
 
2082
                                
 
2083
                                cairo_dock_build_icon_theme_list_for_gui (pHashTable);
 
2084
                                
 
2085
                                g_hash_table_destroy (pHashTable);
 
2086
                                _add_combo_from_modele (s_pIconThemeListStore, FALSE, FALSE);
 
2087
                                
 
2088
                                _pack_subwidget (pOneWidget);
 
2089
                        }
 
2090
                        break ;
 
2091
                        
 
2092
                        case CAIRO_DOCK_WIDGET_MODULE_LIST :
 
2093
                        {
 
2094
                                //\______________ On remplit un modele avec les modules de la categorie.
 
2095
                                int iCategory = -1;
 
2096
                                if (pAuthorizedValuesList && pAuthorizedValuesList[0] != NULL)
 
2097
                                        iCategory = atoi (pAuthorizedValuesList[0]);
 
2098
                                modele = _allocate_new_model ();
 
2099
                                gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (modele), CAIRO_DOCK_MODEL_NAME, GTK_SORT_ASCENDING);
 
2100
                                _allocate_new_buffer;
 
2101
                                data[0] = GINT_TO_POINTER (iCategory);
 
2102
                                data[1] = modele;
 
2103
                                cairo_dock_foreach_module ((GHRFunc) _add_module_to_modele, data);
 
2104
                                
 
2105
                                //\______________ On construit le treeview des modules.
 
2106
                                gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (modele), CAIRO_DOCK_MODEL_NAME, GTK_SORT_ASCENDING);
 
2107
                                pOneWidget = gtk_tree_view_new ();
 
2108
                                gtk_tree_view_set_model (GTK_TREE_VIEW (pOneWidget), GTK_TREE_MODEL (modele));
 
2109
                                gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (pOneWidget), TRUE);
 
2110
                                gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (pOneWidget), TRUE);
 
2111
                                GtkTreeViewColumn* col;
 
2112
                                // case a cocher
 
2113
                                rend = gtk_cell_renderer_toggle_new ();
 
2114
                                col = gtk_tree_view_column_new_with_attributes (NULL, rend, "active", CAIRO_DOCK_MODEL_ACTIVE, NULL);
 
2115
                                gtk_tree_view_column_set_sort_column_id (col, CAIRO_DOCK_MODEL_ACTIVE);
 
2116
                                gtk_tree_view_append_column (GTK_TREE_VIEW (pOneWidget), col);
 
2117
                                g_signal_connect (G_OBJECT (rend), "toggled", (GCallback) _cairo_dock_activate_one_module, modele);
 
2118
                                // icone
 
2119
                                rend = gtk_cell_renderer_pixbuf_new ();
 
2120
                                gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (pOneWidget), -1, NULL, rend, "pixbuf", CAIRO_DOCK_MODEL_ICON, NULL);
 
2121
                                // nom
 
2122
                                rend = gtk_cell_renderer_text_new ();
 
2123
                                col = gtk_tree_view_column_new_with_attributes (_("module"), rend, "text", CAIRO_DOCK_MODEL_NAME, NULL);
 
2124
                                gtk_tree_view_column_set_cell_data_func (col, rend, (GtkTreeCellDataFunc)_cairo_dock_render_module_name, NULL, NULL);
 
2125
                                gtk_tree_view_column_set_sort_column_id (col, CAIRO_DOCK_MODEL_NAME);
 
2126
                                gtk_tree_view_append_column (GTK_TREE_VIEW (pOneWidget), col);
 
2127
                                // categorie
 
2128
                                rend = gtk_cell_renderer_text_new ();
 
2129
                                col = gtk_tree_view_column_new_with_attributes (_("category"), rend, "text", CAIRO_DOCK_MODEL_STATE, NULL);
 
2130
                                gtk_tree_view_column_set_cell_data_func (col, rend, (GtkTreeCellDataFunc)_cairo_dock_render_category, NULL, NULL);
 
2131
                                gtk_tree_view_column_set_sort_column_id (col, CAIRO_DOCK_MODEL_STATE);
 
2132
                                gtk_tree_view_append_column (GTK_TREE_VIEW (pOneWidget), col);
 
2133
                                
 
2134
                                selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pOneWidget));
 
2135
                                gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
 
2136
                                
 
2137
                                pScrolledWindow = gtk_scrolled_window_new (NULL, NULL);
 
2138
                                gtk_widget_set (pScrolledWindow, "height-request", 2*CAIRO_DOCK_PREVIEW_HEIGHT, NULL);
 
2139
                                gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pScrolledWindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
 
2140
                                gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (pScrolledWindow), pOneWidget);
 
2141
                                pSubWidgetList = g_slist_append (pSubWidgetList, pOneWidget);
 
2142
                                _pack_in_widget_box (pScrolledWindow);
 
2143
                                
 
2144
                                //\______________ On construit le widget de prevue et on le rajoute a la suite.
 
2145
                                pDescriptionLabel = gtk_label_new (NULL);
 
2146
                                g_signal_connect (pMainWindow, "delete-event", G_CALLBACK (on_delete_async_widget), pDescriptionLabel);
 
2147
                                g_object_ref (pDescriptionLabel);
 
2148
                                gtk_label_set_use_markup  (GTK_LABEL (pDescriptionLabel), TRUE);
 
2149
                                gtk_widget_set (pDescriptionLabel,
 
2150
                                        "width-request", CAIRO_DOCK_PREVIEW_WIDTH, NULL);
 
2151
                                gtk_label_set_justify (GTK_LABEL (pDescriptionLabel), GTK_JUSTIFY_LEFT);
 
2152
                                gtk_label_set_line_wrap (GTK_LABEL (pDescriptionLabel), TRUE);
 
2153
                                pPreviewImage = gtk_image_new_from_pixbuf (NULL);
 
2154
                                g_signal_connect (pMainWindow, "delete-event", G_CALLBACK (on_delete_async_widget), pPreviewImage);
 
2155
                                g_object_ref (pPreviewImage);
 
2156
                                gtk_widget_set (pPreviewImage,
 
2157
                                        "height-request", CAIRO_DOCK_PREVIEW_HEIGHT,
 
2158
                                        "width-request", CAIRO_DOCK_PREVIEW_WIDTH, NULL);
 
2159
                                _allocate_new_buffer;
 
2160
                                data[0] = pDescriptionLabel;
 
2161
                                data[1] = pPreviewImage;
 
2162
                                gtk_tree_selection_set_select_function (selection,
 
2163
                                        (GtkTreeSelectionFunc) _cairo_dock_select_one_item_in_tree,
 
2164
                                        data,
 
2165
                                        NULL);
 
2166
                                pPreviewBox = gtk_vbox_new (FALSE, CAIRO_DOCK_GUI_MARGIN);
 
2167
                                gtk_box_pack_start (GTK_BOX (pPreviewBox), pPreviewImage, FALSE, FALSE, 0);
 
2168
                                gtk_box_pack_start (GTK_BOX (pPreviewBox), pDescriptionLabel, FALSE, FALSE, 0);
 
2169
                                _pack_in_widget_box (pPreviewBox);
 
2170
                                
 
2171
                                //\______________ On affiche un message par defaut.
 
2172
                                gchar *cDefaultMessage = g_strdup_printf ("<b><span font_desc=\"Sans 14\">%s</span></b>", _("Click on an applet in order to have a preview and a description of it."));
 
2173
                                gtk_label_set_markup (GTK_LABEL (pDescriptionLabel), cDefaultMessage);
 
2174
                                g_free (cDefaultMessage);
 
2175
                                _set_preview_image (CAIRO_DOCK_SHARE_DATA_DIR"/"CAIRO_DOCK_LOGO, GTK_IMAGE (pPreviewImage));
 
2176
                        }
 
2177
                        break ;
 
2178
                        
1508
2179
                        case CAIRO_DOCK_WIDGET_JUMP_TO_MODULE :  // bouton raccourci vers un autre module
1509
2180
                        case CAIRO_DOCK_WIDGET_JUMP_TO_MODULE_IF_EXISTS :  // idem mais seulement affiche si le module existe.
1510
2181
                                if (pAuthorizedValuesList == NULL || pAuthorizedValuesList[0] == NULL || *pAuthorizedValuesList[0] == '\0')
1522
2193
                                        else
1523
2194
                                        {
1524
2195
                                                if (iElementType == CAIRO_DOCK_WIDGET_JUMP_TO_MODULE_IF_EXISTS)
 
2196
                                                {
 
2197
                                                        gtk_widget_set_sensitive (pLabel, FALSE);
1525
2198
                                                        break ;
 
2199
                                                }
1526
2200
                                                cd_warning ("module '%s' not found", pAuthorizedValuesList[0]);
1527
 
                                                cModuleName = g_strdup (pAuthorizedValuesList[0]);  // petite fuite memoire dans ce cas tres precis ...
 
2201
                                                cModuleName = g_strdup (pAuthorizedValuesList[0]);  // petite fuite memoire dans ce cas tres rare ...
1528
2202
                                        }
1529
2203
                                }
1530
2204
                                pOneWidget = gtk_button_new_from_stock (GTK_STOCK_JUMP_TO);
1541
2215
                        
1542
2216
                        case CAIRO_DOCK_WIDGET_LIST :  // a list of strings.
1543
2217
                        case CAIRO_DOCK_WIDGET_NUMBERED_LIST :  // a list of numbered strings.
 
2218
                        case CAIRO_DOCK_WIDGET_NUMBERED_CONTROL_LIST :  // a list of numbered strings whose current choice defines the sensitivity of the widgets below.
 
2219
                        case CAIRO_DOCK_WIDGET_NUMBERED_CONTROL_LIST_SELECTIVE :  // a list of numbered strings whose current choice defines the sensitivity of the widgets below given in the list.
1544
2220
                        case CAIRO_DOCK_WIDGET_LIST_WITH_ENTRY :  // a list of strings with possibility to select a non-existing one.
 
2221
                                if ((iElementType == CAIRO_DOCK_WIDGET_NUMBERED_CONTROL_LIST || iElementType == CAIRO_DOCK_WIDGET_NUMBERED_CONTROL_LIST_SELECTIVE) && pAuthorizedValuesList == NULL)
 
2222
                                {
 
2223
                                        pControlContainer = NULL;
 
2224
                                        iNbControlledWidgets = 0;
 
2225
                                        break;
 
2226
                                }
1545
2227
                                cValue = g_key_file_get_locale_string (pKeyFile, cGroupName, cKeyName, NULL, NULL);  // nous permet de recuperer les ';' aussi.
1546
2228
                                // on construit la combo.
1547
2229
                                modele = _allocate_new_model ();
1561
2243
                                if (pAuthorizedValuesList != NULL)
1562
2244
                                {
1563
2245
                                        k = 0;
1564
 
                                        int iSelectedItem = -1;
1565
 
                                        if (iElementType == CAIRO_DOCK_WIDGET_NUMBERED_LIST)
 
2246
                                        int iSelectedItem = -1, iOrder1, iOrder2;
 
2247
                                        gboolean bNumberedList = (iElementType == CAIRO_DOCK_WIDGET_NUMBERED_LIST || iElementType == CAIRO_DOCK_WIDGET_NUMBERED_CONTROL_LIST || iElementType == CAIRO_DOCK_WIDGET_NUMBERED_CONTROL_LIST_SELECTIVE);
 
2248
                                        if (bNumberedList)
1566
2249
                                                iSelectedItem = atoi (cValue);
1567
 
                                        gchar *cResult = (iElementType == CAIRO_DOCK_WIDGET_NUMBERED_LIST ? g_new0 (gchar , 10) : NULL);
1568
 
                                        for (k = 0; pAuthorizedValuesList[k] != NULL; k ++)  // on ajoute toutes les chaines possibles a la combo.
 
2250
                                        gchar *cResult = (bNumberedList ? g_new0 (gchar , 10) : NULL);
 
2251
                                        int dk = (iElementType == CAIRO_DOCK_WIDGET_NUMBERED_CONTROL_LIST_SELECTIVE ? 3 : 1);
 
2252
                                        iNbControlledWidgets = 0;
 
2253
                                        for (k = 0; pAuthorizedValuesList[k] != NULL; k += dk)  // on ajoute toutes les chaines possibles a la combo.
1569
2254
                                        {
1570
2255
                                                GtkTreeIter iter;
1571
2256
                                                gtk_list_store_append (GTK_LIST_STORE (modele), &iter);
1572
2257
                                                if (iSelectedItem == -1 && cValue && strcmp (cValue, pAuthorizedValuesList[k]) == 0)
1573
 
                                                        iSelectedItem = k;
1574
 
 
 
2258
                                                        iSelectedItem = k/dk;
 
2259
                                                
1575
2260
                                                if (cResult != NULL)
1576
 
                                                        snprintf (cResult, 9, "%d", k);
 
2261
                                                        snprintf (cResult, 9, "%d", k/dk);
 
2262
                                                
 
2263
                                                if (iElementType == CAIRO_DOCK_WIDGET_NUMBERED_CONTROL_LIST_SELECTIVE)
 
2264
                                                {
 
2265
                                                        iOrder1 = atoi (pAuthorizedValuesList[k+1]);
 
2266
                                                        iOrder2 = atoi (pAuthorizedValuesList[k+2]);
 
2267
                                                        iNbControlledWidgets = MAX (iNbControlledWidgets, iOrder1 + iOrder2 - 1);
 
2268
                                                        //g_print ("iSelectedItem:%d ; k/dk:%d\n", iSelectedItem , k/dk);
 
2269
                                                        if (iSelectedItem == k/dk)
 
2270
                                                        {
 
2271
                                                                iFirstSensitiveWidget = iOrder1;
 
2272
                                                                iNbSensitiveWidgets = iOrder2;
 
2273
                                                        }
 
2274
                                                }
 
2275
                                                else
 
2276
                                                {
 
2277
                                                        iOrder1 = iOrder2 = k;
 
2278
                                                }
1577
2279
                                                gtk_list_store_set (GTK_LIST_STORE (modele), &iter,
1578
 
                                                        CAIRO_DOCK_MODEL_NAME, (iElementType == 'l' ? dgettext (cGettextDomain, pAuthorizedValuesList[k]) : pAuthorizedValuesList[k]),
1579
 
                                                        CAIRO_DOCK_MODEL_RESULT, (cResult != NULL ? cResult : pAuthorizedValuesList[k]), -1);
1580
 
 
 
2280
                                                        CAIRO_DOCK_MODEL_NAME, (bNumberedList ? dgettext (cGettextDomain, pAuthorizedValuesList[k]) : pAuthorizedValuesList[k]),
 
2281
                                                        CAIRO_DOCK_MODEL_RESULT, (cResult != NULL ? cResult : pAuthorizedValuesList[k]),
 
2282
                                                        CAIRO_DOCK_MODEL_ORDER, iOrder1,
 
2283
                                                        CAIRO_DOCK_MODEL_ORDER2, iOrder2, -1);
1581
2284
                                        }
1582
2285
                                        g_free (cResult);
1583
2286
                                        
1586
2289
                                                iSelectedItem = 0;
1587
2290
                                        if (k != 0)  // rien dans le gtktree => plantage.
1588
2291
                                                gtk_combo_box_set_active (GTK_COMBO_BOX (pOneWidget), iSelectedItem);
 
2292
                                        if (iElementType == CAIRO_DOCK_WIDGET_NUMBERED_CONTROL_LIST || iElementType == CAIRO_DOCK_WIDGET_NUMBERED_CONTROL_LIST_SELECTIVE)
 
2293
                                        {
 
2294
                                                pControlContainer = (pFrameVBox != NULL ? pFrameVBox : pGroupBox);
 
2295
                                                _allocate_new_buffer;
 
2296
                                                data[0] = pKeyBox;
 
2297
                                                data[1] = pControlContainer;
 
2298
                                                if (iElementType == CAIRO_DOCK_WIDGET_NUMBERED_CONTROL_LIST)
 
2299
                                                {
 
2300
                                                        iNbControlledWidgets = k;
 
2301
                                                        data[2] = GINT_TO_POINTER (iNbControlledWidgets);
 
2302
                                                        g_signal_connect (G_OBJECT (pOneWidget), "changed", G_CALLBACK (_cairo_dock_select_one_item_in_control_combo), data);
 
2303
                                                        iFirstSensitiveWidget = iSelectedItem+1;  // on decroit jusqu'a 0.
 
2304
                                                        iNbSensitiveWidgets = 1;
 
2305
                                                        //g_print ("CONTROL : %d,%d,%d\n", iNbControlledWidgets, iFirstSensitiveWidget, iNbSensitiveWidgets);
 
2306
                                                }
 
2307
                                                else
 
2308
                                                {
 
2309
                                                        data[2] = GINT_TO_POINTER (iNbControlledWidgets);
 
2310
                                                        g_signal_connect (G_OBJECT (pOneWidget), "changed", G_CALLBACK (_cairo_dock_select_one_item_in_control_combo_selective), data);
 
2311
                                                }
 
2312
                                                //g_print (" pControlContainer:%x\n", pControlContainer);
 
2313
                                        }
1589
2314
                                }
1590
2315
                                _pack_subwidget (pOneWidget);
1591
2316
                                g_free (cValue);
1617
2342
                                pSubWidgetList = g_slist_append (pSubWidgetList, pOneWidget);
1618
2343
                                
1619
2344
                                pScrolledWindow = gtk_scrolled_window_new (NULL, NULL);
1620
 
                                gtk_widget_set (pScrolledWindow, "height-request", 100, NULL);
 
2345
                                g_print ("length:%d\n", length);
 
2346
                                int k;
 
2347
                                if (pAuthorizedValuesList != NULL && pAuthorizedValuesList[0] != NULL)
 
2348
                                        for (k = 0; pAuthorizedValuesList[k] != NULL; k++);
 
2349
                                else
 
2350
                                        k = 1;
 
2351
                                gtk_widget_set (pScrolledWindow, "height-request", (iElementType == CAIRO_DOCK_WIDGET_TREE_VIEW_SORT_AND_MODIFY ? 100 : MIN (100, k * 25)), NULL);
1621
2352
                                gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pScrolledWindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1622
2353
                                gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (pScrolledWindow), pOneWidget);
1623
2354
                                _pack_in_widget_box (pScrolledWindow);
1626
2357
                                {
1627
2358
                                        pSmallVBox = gtk_vbox_new (FALSE, 3);
1628
2359
                                        _pack_in_widget_box (pSmallVBox);
1629
 
 
 
2360
                                        
1630
2361
                                        pButtonUp = gtk_button_new_from_stock (GTK_STOCK_GO_UP);
1631
2362
                                        g_signal_connect (G_OBJECT (pButtonUp),
1632
2363
                                                "clicked",
1637
2368
                                                FALSE,
1638
2369
                                                FALSE,
1639
2370
                                                0);
1640
 
 
 
2371
                                        
1641
2372
                                        pButtonDown = gtk_button_new_from_stock (GTK_STOCK_GO_DOWN);
1642
2373
                                        g_signal_connect (G_OBJECT (pButtonDown),
1643
2374
                                                "clicked",
1782
2513
                                }
1783
2514
                        break ;
1784
2515
                        
1785
 
                        case CAIRO_DOCK_WIDGET_THEME_SELECTOR :  // tree view with 3 sortable columns.
 
2516
                        case CAIRO_DOCK_WIDGET_THEME_SELECTOR :  // tree view with 4 sortable columns.
1786
2517
                                //\______________ On construit le treeview des themes.
1787
2518
                                modele = _allocate_new_model ();
1788
2519
                                gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (modele), CAIRO_DOCK_MODEL_NAME, GTK_SORT_ASCENDING);
1793
2524
                                selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pOneWidget));
1794
2525
                                gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
1795
2526
                                g_object_set_data (G_OBJECT (pOneWidget), "get-active-line-only", GINT_TO_POINTER (1));
 
2527
                                GtkTreeViewColumn* col;
 
2528
                                // etat
 
2529
                                rend = gtk_cell_renderer_text_new ();
 
2530
                                col = gtk_tree_view_column_new_with_attributes (_("state"), rend, "text", CAIRO_DOCK_MODEL_STATE, NULL);
 
2531
                                gtk_tree_view_column_set_sort_column_id (col, CAIRO_DOCK_MODEL_STATE);
 
2532
                                gtk_tree_view_column_set_cell_data_func (col, rend, (GtkTreeCellDataFunc)_cairo_dock_render_state, NULL, NULL);
 
2533
                                gtk_tree_view_append_column (GTK_TREE_VIEW (pOneWidget), col);
1796
2534
                                // nom du theme
1797
2535
                                rend = gtk_cell_renderer_text_new ();
1798
 
                                GtkTreeViewColumn* col = gtk_tree_view_column_new_with_attributes (_("theme"), rend, "text", CAIRO_DOCK_MODEL_NAME, NULL);
 
2536
                                col = gtk_tree_view_column_new_with_attributes (_("theme"), rend, "text", CAIRO_DOCK_MODEL_NAME, NULL);
1799
2537
                                gtk_tree_view_column_set_sort_column_id (col, CAIRO_DOCK_MODEL_NAME);
1800
2538
                                gtk_tree_view_append_column (GTK_TREE_VIEW (pOneWidget), col);
1801
2539
                                // note
1828
2566
                                pSubWidgetList = g_slist_append (pSubWidgetList, pOneWidget);
1829
2567
                                _pack_in_widget_box (pScrolledWindow);
1830
2568
                                
1831
 
                                //\______________ On construit le widget de prevue et on le rajoute a la suite. 
 
2569
                                //\______________ On construit le widget de prevue et on le rajoute a la suite.
1832
2570
                                pDescriptionLabel = gtk_label_new (NULL);
 
2571
                                g_signal_connect (pMainWindow, "delete-event", G_CALLBACK (on_delete_async_widget), pDescriptionLabel);
 
2572
                                g_object_ref (pDescriptionLabel);
1833
2573
                                gtk_label_set_use_markup  (GTK_LABEL (pDescriptionLabel), TRUE);
 
2574
                                gtk_widget_set (pDescriptionLabel,
 
2575
                                        "width-request", CAIRO_DOCK_PREVIEW_WIDTH, NULL);
 
2576
                                gtk_label_set_justify (GTK_LABEL (pDescriptionLabel), GTK_JUSTIFY_LEFT);
 
2577
                                gtk_label_set_line_wrap (GTK_LABEL (pDescriptionLabel), TRUE);
1834
2578
                                pPreviewImage = gtk_image_new_from_pixbuf (NULL);
 
2579
                                g_signal_connect (pMainWindow, "delete-event", G_CALLBACK (on_delete_async_widget), pPreviewImage);
 
2580
                                g_object_ref (pPreviewImage);
 
2581
                                gtk_widget_set (pPreviewImage,
 
2582
                                        "height-request", CAIRO_DOCK_PREVIEW_HEIGHT,
 
2583
                                        "width-request", CAIRO_DOCK_PREVIEW_WIDTH, NULL);
1835
2584
                                _allocate_new_buffer;
1836
2585
                                data[0] = pDescriptionLabel;
1837
2586
                                data[1] = pPreviewImage;
1857
2606
                                                        cDistantThemesDir = pAuthorizedValuesList[2];
1858
2607
                                                }
1859
2608
                                        }
1860
 
                                        GHashTable *pThemeTable = cairo_dock_list_themes (cShareThemesDir, cUserThemesDir, cDistantThemesDir);
 
2609
                                        
 
2610
                                        _allocate_new_buffer;
 
2611
                                        data[0] = pOneWidget;
 
2612
                                        data[1] = pMainWindow;
 
2613
                                        CairoDockTask *pTask = cairo_dock_list_themes_async (cShareThemesDir, cUserThemesDir, cDistantThemesDir, (GFunc) _got_themes_list, data);
 
2614
                                        g_object_set_data (G_OBJECT (pOneWidget), "cd-task", pTask);
 
2615
                                        g_signal_connect (pMainWindow, "delete-event", G_CALLBACK (on_delete_async_widget), pOneWidget);
 
2616
                                        g_object_ref (pOneWidget);
 
2617
                                        /**GHashTable *pThemeTable = cairo_dock_list_themes (cShareThemesDir, cUserThemesDir, cDistantThemesDir);
 
2618
                                        g_hash_table_foreach (pThemeTable, (GHFunc)_cairo_dock_fill_modele_with_themes, modele);
 
2619
                                        g_hash_table_destroy (pThemeTable);*/
1861
2620
                                        g_free (cUserThemesDir);
1862
 
 
1863
 
                                        g_hash_table_foreach (pThemeTable, (GHFunc)_cairo_dock_fill_modele_with_themes, modele);
1864
 
                                        g_hash_table_destroy (pThemeTable);
1865
2621
                                }
1866
2622
                        break ;
1867
2623
                        
1876
2632
                                gtk_font_button_set_show_size (GTK_FONT_BUTTON (pOneWidget), TRUE);
1877
2633
                                gtk_font_button_set_use_size (GTK_FONT_BUTTON (pOneWidget), TRUE);
1878
2634
                                gtk_font_button_set_use_font (GTK_FONT_BUTTON (pOneWidget), TRUE);
1879
 
                                /*g_signal_connect (G_OBJECT (pFontButton),
1880
 
                                        "font-set",
1881
 
                                        G_CALLBACK (_cairo_dock_set_font),
1882
 
                                        pEntry);*/
1883
 
                                _pack_in_widget_box (pOneWidget);
1884
 
                                _pack_subwidget (pOneWidget);
1885
 
                                g_free (cValue);
1886
 
                        break;
1887
 
                        
1888
 
                        case CAIRO_DOCK_WIDGET_STRING_ENTRY :  // string
 
2635
                                _pack_subwidget (pOneWidget);
 
2636
                                g_free (cValue);
 
2637
                        break;
 
2638
                        
 
2639
                        case CAIRO_DOCK_WIDGET_LINK :  // string avec un lien internet a cote.
 
2640
                                cValue = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL);
 
2641
                                pOneWidget = gtk_link_button_new_with_label (cValue, pAuthorizedValuesList && pAuthorizedValuesList[0] ? pAuthorizedValuesList[0] : _("link"));
 
2642
                                _pack_subwidget (pOneWidget);
 
2643
                                g_free (cValue);
 
2644
                        break;
 
2645
                        
 
2646
                        
 
2647
                        case CAIRO_DOCK_WIDGET_STRING_ENTRY :  // string (Merci Fab !) :-P
1889
2648
                        case CAIRO_DOCK_WIDGET_PASSWORD_ENTRY :  // string de type "password", crypte dans le .conf et cache dans l'UI (Merci Tofe !) :-)
1890
2649
                        case CAIRO_DOCK_WIDGET_FILE_SELECTOR :  // string avec un selecteur de fichier a cote du GtkEntry.
1891
2650
                        case CAIRO_DOCK_WIDGET_FOLDER_SELECTOR :  // string avec un selecteur de repertoire a cote du GtkEntry.
1892
2651
                        case CAIRO_DOCK_WIDGET_SOUND_SELECTOR :  // string avec un selecteur de fichier a cote du GtkEntry et un boutton play.
1893
2652
                        case CAIRO_DOCK_WIDGET_SHORTKEY_SELECTOR :  // string avec un selecteur de touche clavier (Merci Ctaf !)
 
2653
                        case CAIRO_DOCK_WIDGET_CLASS_SELECTOR :  // string avec un selecteur de class (Merci Matttbe !)
1894
2654
                                // on construit l'entree de texte.
1895
2655
                                cValue = g_key_file_get_locale_string (pKeyFile, cGroupName, cKeyName, NULL, NULL);  // nous permet de recuperer les ';' aussi.
1896
2656
                                pOneWidget = gtk_entry_new ();
1929
2689
                                                _pack_in_widget_box (pButtonPlay);
1930
2690
                                        }
1931
2691
                                }
1932
 
                                /*else if (iElementType == CAIRO_DOCK_WIDGET_FONT_SELECTOR)  // on ajoute un selecteur de font.
1933
 
                                {
1934
 
                                        pFontButton = gtk_font_button_new_with_font (gtk_entry_get_text (GTK_ENTRY (pEntry)));
1935
 
                                        gtk_font_button_set_show_style (GTK_FONT_BUTTON (pFontButton), TRUE);
1936
 
                                        gtk_font_button_set_show_size (GTK_FONT_BUTTON (pFontButton), TRUE);
1937
 
                                        gtk_font_button_set_use_size (GTK_FONT_BUTTON (pFontButton), TRUE);
1938
 
                                        gtk_font_button_set_use_font (GTK_FONT_BUTTON (pFontButton), TRUE);
1939
 
                                        g_signal_connect (G_OBJECT (pFontButton),
1940
 
                                                "font-set",
1941
 
                                                G_CALLBACK (_cairo_dock_set_font),
1942
 
                                                pEntry);
1943
 
                                        _pack_in_widget_box (pFontButton);
1944
 
                                }*/
1945
 
                                else if (iElementType == CAIRO_DOCK_WIDGET_SHORTKEY_SELECTOR)  // on ajoute un selecteur de touches.
 
2692
                                else if (iElementType == CAIRO_DOCK_WIDGET_SHORTKEY_SELECTOR || iElementType == CAIRO_DOCK_WIDGET_CLASS_SELECTOR)  // on ajoute un selecteur de touches/classe.
1946
2693
                                {
1947
2694
                                        GtkWidget *pGrabKeyButton = gtk_button_new_with_label(_("grab"));
1948
 
 
1949
2695
                                        _allocate_new_buffer;
1950
2696
                                        data[0] = pOneWidget;
1951
2697
                                        data[1] = pMainWindow;
1952
2698
                                        gtk_widget_add_events(pMainWindow, GDK_KEY_PRESS_MASK);
1953
 
                                        g_signal_connect (G_OBJECT (pGrabKeyButton),
1954
 
                                                "clicked",
1955
 
                                                G_CALLBACK (_cairo_dock_key_grab_clicked),
1956
 
                                                data);
1957
 
                                        
 
2699
                                        if (iElementType == CAIRO_DOCK_WIDGET_CLASS_SELECTOR)
 
2700
                                        {
 
2701
                                                g_signal_connect (G_OBJECT (pGrabKeyButton),
 
2702
                                                        "clicked",
 
2703
                                                        G_CALLBACK (_cairo_dock_key_grab_class),
 
2704
                                                        data);
 
2705
                                        }
 
2706
                                        else
 
2707
                                        {
 
2708
                                                g_signal_connect (G_OBJECT (pGrabKeyButton),
 
2709
                                                        "clicked",
 
2710
                                                        G_CALLBACK (_cairo_dock_key_grab_clicked),
 
2711
                                                        data);
 
2712
                                        }
1958
2713
                                        _pack_in_widget_box (pGrabKeyButton);
1959
2714
                                }
1960
2715
                                g_free (cValue);
1973
2728
                        case CAIRO_DOCK_WIDGET_TEXT_LABEL :  // juste le label de texte.
1974
2729
                        break ;
1975
2730
                        
 
2731
                        case CAIRO_DOCK_WIDGET_HANDBOOK :  // le label contenant le manuel de l'applet, il a ete place avant.
 
2732
                                cValue = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL);
 
2733
                                CairoDockModule *pModule = cairo_dock_find_module_from_name (cValue);
 
2734
                                if (pModule == NULL)
 
2735
                                        break;  
 
2736
                                
 
2737
                                int iPreviewWidth, iPreviewHeight;
 
2738
                                GdkPixbuf *pPreviewPixbuf = NULL;
 
2739
                                int w=200, h=200;
 
2740
                                if (gdk_pixbuf_get_file_info (pModule->pVisitCard->cPreviewFilePath, &iPreviewWidth, &iPreviewHeight) != NULL)  // The return value is owned by GdkPixbuf and should not be freed.
 
2741
                                {
 
2742
                                        if (iPreviewWidth > w)
 
2743
                                        {
 
2744
                                                iPreviewHeight *= 1.*w/iPreviewWidth;
 
2745
                                                iPreviewWidth = w;
 
2746
                                        }
 
2747
                                        if (iPreviewHeight > h)
 
2748
                                        {
 
2749
                                                iPreviewWidth *= 1.*h/iPreviewHeight;
 
2750
                                                iPreviewHeight = h;
 
2751
                                        }
 
2752
                                        pPreviewPixbuf = gdk_pixbuf_new_from_file_at_size (pModule->pVisitCard->cPreviewFilePath, iPreviewWidth, iPreviewHeight, NULL);
 
2753
                                }
 
2754
                                if (pPreviewPixbuf != NULL)
 
2755
                                {
 
2756
                                        pPreviewImage = gtk_image_new_from_pixbuf (NULL);
 
2757
                                        gtk_image_set_from_pixbuf (GTK_IMAGE (pPreviewImage), pPreviewPixbuf);
 
2758
                                        gdk_pixbuf_unref (pPreviewPixbuf);
 
2759
                                        _pack_in_widget_box (pPreviewImage);
 
2760
                                }
 
2761
                        break ;
 
2762
                        
1976
2763
                        case CAIRO_DOCK_WIDGET_FRAME :  // frame.
1977
2764
                        case CAIRO_DOCK_WIDGET_EXPANDER :  // frame dans un expander.
1978
2765
                                if (pAuthorizedValuesList == NULL)
2055
2842
                                        
2056
2843
                                        if (pAuthorizedValuesList[0] == NULL || *pAuthorizedValuesList[0] == '\0')
2057
2844
                                                g_free (cValue);
 
2845
                                        
 
2846
                                        
 
2847
                                        if (iNbControlledWidgets > 0 && pControlContainer != NULL)
 
2848
                                        {
 
2849
                                                g_print ("ctrl\n");
 
2850
                                                if (pControlContainer == pGroupBox)
 
2851
                                                {
 
2852
                                                        g_print ("ctrl (iNbControlledWidgets:%d, iFirstSensitiveWidget:%d, iNbSensitiveWidgets:%d)\n", iNbControlledWidgets, iFirstSensitiveWidget, iNbSensitiveWidgets);
 
2853
                                                        iNbControlledWidgets --;
 
2854
                                                        if (iFirstSensitiveWidget > 0)
 
2855
                                                                iFirstSensitiveWidget --;
 
2856
                                                        
 
2857
                                                        GtkWidget *w = pExternFrame;
 
2858
                                                        if (iFirstSensitiveWidget == 0 && iNbSensitiveWidgets > 0)
 
2859
                                                        {
 
2860
                                                                g_print (" => sensitive\n");
 
2861
                                                                iNbSensitiveWidgets --;
 
2862
                                                                if (GTK_IS_EXPANDER (w))
 
2863
                                                                        gtk_expander_set_expanded (GTK_EXPANDER (w), TRUE);
 
2864
                                                        }
 
2865
                                                        else
 
2866
                                                        {
 
2867
                                                                g_print (" => unsensitive\n");
 
2868
                                                                if (!GTK_IS_EXPANDER (w))
 
2869
                                                                        gtk_widget_set_sensitive (w, FALSE);
 
2870
                                                        }
 
2871
                                                }
 
2872
                                        }
2058
2873
                                }
2059
2874
                                break;
2060
2875
 
2061
2876
                        case CAIRO_DOCK_WIDGET_SEPARATOR :  // separateur.
2062
2877
                        {
2063
 
                                GtkWidget *pAlign = gtk_alignment_new (.5, 0., 0.5, 0.);
 
2878
                                GtkWidget *pAlign = gtk_alignment_new (.5, 0., 0.8, 0.);
2064
2879
                                pOneWidget = gtk_hseparator_new ();
2065
2880
                                gtk_container_add (GTK_CONTAINER (pAlign), pOneWidget);
2066
2881
                                gtk_box_pack_start (GTK_BOX (pFrameVBox != NULL ? pFrameVBox : pGroupBox),
2095
2910
                                _pack_in_widget_box (pBackButton);
2096
2911
                        }
2097
2912
                }
2098
 
 
2099
 
                g_strfreev (pAuthorizedValuesList);
 
2913
                
 
2914
                if (pAuthorizedValuesList != NULL)
 
2915
                        g_strfreev (pAuthorizedValuesList);
2100
2916
                g_free (cKeyComment);
2101
2917
        }
2102
2918
        g_free (cGroupComment);  // cSmallGroupIcon et cDisplayedGroupName pointaient dessus.
2103
2919
        g_free (pKeyList);  // on libere juste la liste de chaines, pas les chaines a l'interieur.
2104
2920
        
 
2921
        if (iNbControlledWidgets > 0)
 
2922
                cd_warning ("this conf file has an invalid combo list somewhere !");
 
2923
        
2105
2924
        return pGroupBox;
2106
2925
}
2107
2926
 
2336
3155
                const gchar *cFontName = gtk_font_button_get_font_name (GTK_FONT_BUTTON (pOneWidget));
2337
3156
                g_key_file_set_string (pKeyFile, cGroupName, cKeyName, cFontName);
2338
3157
        }
 
3158
        else if (GTK_IS_COLOR_BUTTON (pOneWidget))
 
3159
        {
 
3160
                GdkColor gdkColor;
 
3161
                gtk_color_button_get_color (GTK_COLOR_BUTTON (pOneWidget), &gdkColor);
 
3162
                double col[4];
 
3163
                int iNbColors;
 
3164
                col[0] = (double) gdkColor.red / 65535.;
 
3165
                col[1] = (double) gdkColor.green / 65535.;
 
3166
                col[2] = (double) gdkColor.blue / 65535.;
 
3167
                if (gtk_color_button_get_use_alpha (GTK_COLOR_BUTTON (pOneWidget)))
 
3168
                {
 
3169
                        iNbColors = 4;
 
3170
                        col[3] = (double) gtk_color_button_get_alpha (GTK_COLOR_BUTTON (pOneWidget)) / 65535.;
 
3171
                }
 
3172
                else
 
3173
                {
 
3174
                        iNbColors = 3;
 
3175
                }
 
3176
                g_key_file_set_double_list (pKeyFile, cGroupName, cKeyName, col, iNbColors);
 
3177
        }
2339
3178
        else if (GTK_IS_ENTRY (pOneWidget))
2340
3179
        {
2341
3180
                gchar *cValue = NULL;
2481
3320
{
2482
3321
        GtkTreeModel *modele = gtk_combo_box_get_model (GTK_COMBO_BOX (pCombo));
2483
3322
        g_return_if_fail (modele != NULL);
2484
 
        g_hash_table_foreach (pThemeTable, (GHFunc)_cairo_dock_fill_modele_with_themes, modele);
 
3323
        g_hash_table_foreach (pThemeTable, (GHFunc)_cairo_dock_fill_modele_with_short_themes, modele);
2485
3324
        
2486
3325
        GtkTreeIter iter;
2487
 
        if (_cairo_dock_find_iter_from_name (GTK_LIST_STORE (modele), cActiveTheme, &iter))
 
3326
        cairo_dock_extract_theme_type_from_name (cActiveTheme);
 
3327
        if (_cairo_dock_find_iter_from_name (GTK_LIST_STORE (modele), cActiveTheme, &iter, TRUE))
 
3328
        {
2488
3329
                gtk_combo_box_set_active_iter (GTK_COMBO_BOX (pCombo), &iter);
 
3330
                gboolean bReturn;
 
3331
                g_signal_emit_by_name (pCombo, "changed", NULL, &bReturn);
 
3332
                g_print ("%s found \n", cActiveTheme);
 
3333
        }
2489
3334
}
2490
3335
 
2491
3336
void cairo_dock_fill_combo_with_list (GtkWidget *pCombo, GList *pElementList, const gchar *cActiveElement)
2507
3352
                        CAIRO_DOCK_MODEL_IMAGE, "none", -1);
2508
3353
        }
2509
3354
        
2510
 
        if (cActiveElement != NULL && _cairo_dock_find_iter_from_name (GTK_LIST_STORE (pModele), cActiveElement, &iter))
 
3355
        if (cActiveElement != NULL && _cairo_dock_find_iter_from_name (GTK_LIST_STORE (pModele), cActiveElement, &iter, FALSE))
2511
3356
                gtk_combo_box_set_active_iter (GTK_COMBO_BOX (pCombo), &iter);
2512
3357
}