summaryrefslogtreecommitdiff
path: root/src/gui/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/core')
-rw-r--r--src/gui/core/core.c13
-rw-r--r--src/gui/core/theme.c92
2 files changed, 88 insertions, 17 deletions
diff --git a/src/gui/core/core.c b/src/gui/core/core.c
index 2cb75b1..8783783 100644
--- a/src/gui/core/core.c
+++ b/src/gui/core/core.c
@@ -55,11 +55,9 @@ bool load_all_gui_components(void)
GMenuBar *bar; /* Gestion des menus */
GtkMenuItem *submenuitem; /* Sous-élément de menu */
- load_main_panels();
-
- load_extra_gtk_theme();
+ result = true;
- result = load_segment_rendering_parameters();
+ load_main_panels();
/**
* Charge une liste initiale pour activer les raccourcis clavier.
@@ -95,6 +93,10 @@ bool complete_loading_of_all_gui_components(GGenConfig *config)
GtkTiledGrid *grid; /* Composant d'affichage */
GPanelItem *welcome; /* Panneau d'accueil */
+ load_extra_gtk_theme();
+
+ result = load_segment_rendering_parameters();
+
grid = get_tiled_grid();
welcome = get_panel_item_by_name(PANEL_WELCOME_ID);
@@ -112,7 +114,8 @@ bool complete_loading_of_all_gui_components(GGenConfig *config)
* Donc on doit sauter ce panneau d'accueil lors de l'appel suivant.
*/
- result = _browse_all_item_panels(true, (handle_panel_item_fc)gtk_panel_item_apply_configuration, config);
+ if (result)
+ result = _browse_all_item_panels(true, (handle_panel_item_fc)gtk_panel_item_apply_configuration, config);
gtk_tiled_grid_restore_positions(grid, config);
diff --git a/src/gui/core/theme.c b/src/gui/core/theme.c
index be060be..daf0bfe 100644
--- a/src/gui/core/theme.c
+++ b/src/gui/core/theme.c
@@ -43,6 +43,7 @@
#include "../../common/xdg.h"
#include "../../core/logs.h"
#include "../../core/params.h"
+#include "../../plugins/pglist.h"
@@ -55,6 +56,9 @@ static char *look_for_named_theme(const char *, const char *, gboolean);
/* Ajoute les définitions CSS à partir d'un chemin donné. */
static void load_css_partial_content(char **, const char *, gboolean);
+/* Parcourt tous les greffons à la recherche de définitions CSS. */
+static void prepend_plugins_themes(char **, gboolean);
+
/* Etend le thème courant de GTK. */
static void activate_css_content(GdkScreen *, const char *);
@@ -106,6 +110,8 @@ bool load_extra_gtk_theme(void)
if (content != NULL)
{
+ prepend_plugins_themes(&content, dark);
+
activate_css_content(screen, content);
free(content);
@@ -257,33 +263,43 @@ static char *look_for_named_theme(const char *dirname, const char *name, gboolea
static void load_css_partial_content(char **content, const char *path, gboolean dark)
{
bool got_it; /* Version sombre présente ? */
- char *dark_path; /* Version sombre du chemin */
GtkCssProvider *provider; /* Nouveau fournisseur CSS */
+ char *dark_path; /* Version sombre du chemin */
+ GFile *file; /* Fichier à charger */
GError *error; /* Relevé d'éventuelles erreurs*/
- char *extra; /* Contenu d'une feuille */
+ char *css; /* Contenu d'une feuille */
got_it = false;
if (dark)
{
+ provider = gtk_css_provider_new();
+
+ error = NULL;
+
dark_path = strdup(path);
dark_path = strrpl(dark_path, ".css", "-dark.css");
- provider = gtk_css_provider_new();
+ if (strstr(path, "://") != NULL)
+ file = g_file_new_for_uri(dark_path);
+ else
+ file = g_file_new_for_path(dark_path);
- error = NULL;
+ free(dark_path);
- gtk_css_provider_load_from_path(provider, dark_path, &error);
+ gtk_css_provider_load_from_file(provider, file, &error);
+
+ g_object_unref(G_OBJECT(file));
if (error == NULL)
{
log_variadic_message(LMT_INFO, _("Loaded CSS definitions from '%s'"), dark_path);
- extra = gtk_css_provider_to_string(provider);
+ css = gtk_css_provider_to_string(provider);
- *content = stradd(*content, extra);
+ *content = stradd(*content, css);
- free(extra);
+ free(css);
got_it = true;
@@ -301,17 +317,24 @@ static void load_css_partial_content(char **content, const char *path, gboolean
error = NULL;
- gtk_css_provider_load_from_path(provider, path, &error);
+ if (strstr(path, "://") != NULL)
+ file = g_file_new_for_uri(path);
+ else
+ file = g_file_new_for_path(path);
+
+ gtk_css_provider_load_from_file(provider, file, &error);
+
+ g_object_unref(G_OBJECT(file));
if (error == NULL)
{
log_variadic_message(LMT_INFO, _("Loaded CSS definitions from '%s'"), path);
- extra = gtk_css_provider_to_string(provider);
+ css = gtk_css_provider_to_string(provider);
- *content = stradd(*content, extra);
+ *content = stradd(*content, css);
- free(extra);
+ free(css);
}
else
@@ -329,6 +352,51 @@ static void load_css_partial_content(char **content, const char *path, gboolean
/******************************************************************************
* *
+* Paramètres : content = définitions CSS à compléter. [OUT] *
+* dark = indique une préférence pour la variante foncée. *
+* *
+* Description : Parcourt tous les greffons à la recherche de définitions CSS.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void prepend_plugins_themes(char **content, gboolean dark)
+{
+ char *extra; /* Nouvelles définitions CSS */
+ char **resources; /* Fichiers supplémentaires */
+ size_t count; /* Nombre de ces fichiers */
+ size_t i; /* Boucle de parcours */
+
+ extra = NULL;
+
+ resources = NULL;
+ count = 0;
+
+ include_plugin_theme(&resources, &count);
+
+ for (i = 0; i < count; i++)
+ {
+ load_css_partial_content(&extra, resources[i], dark);
+ free(resources[i]);
+ }
+
+ if (resources != NULL)
+ free(resources);
+
+ if (extra != NULL)
+ {
+ *content = strprep(*content, extra);
+ free(extra);
+ }
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : screen = écran concerné par les éventuels chargements. *
* content = contenu CSS reconstitué à charger. *
* *