~helene-verhaeghe27/cairo-dock-core/bugfix

« back to all changes in this revision

Viewing changes to src/cairo-dock-widget-themes.c

  • Committer: Fabrice Rey
  • Date: 2012-08-07 00:03:31 UTC
  • Revision ID: fabounet03@gmail.com-20120807000331-hwwsd18aafbfouwr
GUI: moved the user themes selector outside of the core

Show diffs side-by-side

added added

removed removed

Lines of Context:
482
482
{
483
483
        //\______________ get the group/key widget
484
484
        GSList *pWidgetList = pThemesWidget->widget.pWidgetList;
485
 
        GtkWindow *pMainWindow = pThemesWidget->pMainWindow;
486
485
        CairoDockGroupKeyWidget *myWidget = cairo_dock_gui_find_group_key_widget_in_list (pWidgetList, "Load theme", "chosen theme");
487
486
        g_return_if_fail (myWidget != NULL);
488
487
        
532
531
        
533
532
        //\______________ add a preview widget next to the treeview
534
533
        GtkWidget *pPreviewBox = cairo_dock_gui_make_preview_box (GTK_WIDGET (pThemesWidget->pMainWindow), pOneWidget, FALSE, 2, NULL, CAIRO_DOCK_SHARE_DATA_DIR"/images/"CAIRO_DOCK_LOGO, pDataGarbage);
535
 
        // vertical packaging.
536
534
        GtkWidget *pWidgetBox = _gtk_hbox_new (CAIRO_DOCK_GUI_MARGIN);
537
535
        gtk_box_pack_start (GTK_BOX (pWidgetBox), pScrolledWindow, TRUE, TRUE, 0);
538
536
        gtk_box_pack_start (GTK_BOX (pWidgetBox), pPreviewBox, TRUE, TRUE, 0);
539
537
        
540
 
        //\______________ get the local, shared and distant themes.
 
538
        //\______________ get the user, shared and distant themes.
541
539
        _fill_treeview_with_themes (pThemesWidget);
542
540
        
543
541
        //\______________ insert the widget.
545
543
        gtk_box_pack_start (GTK_BOX (myWidget->pKeyBox), pWidgetBox, FALSE, FALSE, 0);
546
544
}
547
545
 
 
546
static gboolean _ignore_server_themes (const gchar *cThemeName, CairoDockPackage *pTheme, gpointer data)
 
547
{
 
548
        gchar *cVersionFile = g_strdup_printf ("%s/last-modif", pTheme->cPackagePath);
 
549
        gboolean bRemove = g_file_test (cVersionFile, G_FILE_TEST_EXISTS);
 
550
        g_free (cVersionFile);
 
551
        return bRemove;
 
552
}
 
553
static void _make_combo_for_user_themes (ThemesWidget *pThemesWidget, GPtrArray *pDataGarbage, GKeyFile* pKeyFile)
 
554
{
 
555
        //\______________ get the group/key widget
 
556
        GSList *pWidgetList = pThemesWidget->widget.pWidgetList;
 
557
        CairoDockGroupKeyWidget *myWidget = cairo_dock_gui_find_group_key_widget_in_list (pWidgetList, "Save", "theme name");
 
558
        g_return_if_fail (myWidget != NULL);
 
559
        
 
560
        //\______________ build the combo-box.
 
561
        GtkWidget *pOneWidget = cairo_dock_gui_make_combo (TRUE);
 
562
        
 
563
        //\______________ get the user themes.
 
564
        const gchar *cUserThemesDir = g_cThemesDirPath;
 
565
        GHashTable *pThemeTable = cairo_dock_list_packages (NULL, cUserThemesDir, NULL, NULL);
 
566
        g_hash_table_foreach_remove (pThemeTable, (GHRFunc)_ignore_server_themes, NULL);  // ignore themes coming from the server
 
567
        GtkTreeModel *pModel = gtk_combo_box_get_model (GTK_COMBO_BOX (pOneWidget));
 
568
        cairo_dock_fill_model_with_themes (GTK_LIST_STORE (pModel), pThemeTable, NULL); 
 
569
        
 
570
        //\______________ insert the widget.
 
571
        GtkWidget *pHBox = _gtk_hbox_new (CAIRO_DOCK_GUI_MARGIN);
 
572
        GtkWidget *pLabel = gtk_label_new (_("Save as:"));
 
573
        
 
574
        //\______________ add a preview widget under to the combo
 
575
        GtkWidget *pPreviewBox = cairo_dock_gui_make_preview_box (GTK_WIDGET (pThemesWidget->pMainWindow), pOneWidget, FALSE, 1, NULL, NULL, pDataGarbage);
 
576
        GtkWidget *pWidgetBox = _gtk_vbox_new (CAIRO_DOCK_GUI_MARGIN);
 
577
        
 
578
        /*gtk_box_pack_start (GTK_BOX (pHBox), pLabel, FALSE, FALSE, 0);
 
579
        gtk_box_pack_end (GTK_BOX (pHBox), pOneWidget, FALSE, FALSE, 0);
 
580
        gtk_box_pack_start (GTK_BOX (pWidgetBox), pHBox, FALSE, FALSE, 0);
 
581
        gtk_box_pack_start (GTK_BOX (pWidgetBox), pPreviewBox, FALSE, FALSE, 0);
 
582
        gtk_box_pack_start (GTK_BOX (myWidget->pKeyBox), pWidgetBox, FALSE, FALSE, 0);*/
 
583
        
 
584
        GtkWidget *pAlign = gtk_alignment_new (0, 0, 1, 0);
 
585
        gtk_container_add (GTK_CONTAINER (pAlign), pLabel);
 
586
        gtk_box_pack_start (GTK_BOX (pHBox), pAlign, FALSE, FALSE, 0);
 
587
        gtk_box_pack_end (GTK_BOX (pHBox), pWidgetBox, FALSE, FALSE, 0);
 
588
        gtk_box_pack_start (GTK_BOX (pWidgetBox), pOneWidget, FALSE, FALSE, 0);
 
589
        gtk_box_pack_start (GTK_BOX (pWidgetBox), pPreviewBox, FALSE, FALSE, 0);
 
590
        gtk_box_pack_start (GTK_BOX (myWidget->pKeyBox), pHBox, TRUE, TRUE, 0);
 
591
        
 
592
        myWidget->pSubWidgetList = g_slist_append (myWidget->pSubWidgetList, pOneWidget);
 
593
}
548
594
static void _build_themes_widget (ThemesWidget *pThemesWidget)
549
595
{
550
596
        GtkWindow *pMainWindow = pThemesWidget->pMainWindow;
568
614
        
569
615
        // complete the widget
570
616
        _make_tree_view_for_themes (pThemesWidget, pDataGarbage, pKeyFile);
 
617
        _make_combo_for_user_themes (pThemesWidget, pDataGarbage, pKeyFile);
571
618
        
572
619
        g_key_file_free (pKeyFile);
573
620
}