summaryrefslogtreecommitdiff
path: root/src/gui/core/theme.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/core/theme.c')
-rw-r--r--src/gui/core/theme.c92
1 files changed, 80 insertions, 12 deletions
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. *
* *