summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-07-22 20:39:36 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-07-22 20:39:36 (GMT)
commit3688ebc981037f6aabea06298aa28dd7c9163894 (patch)
treed0ab50e08247ab46919a85e440d9ca97de8ccc92 /src/gui
parent6a8385724c74b07cf9ed4cb9052f1af1816e3ea5 (diff)
Allowed plugins to extend the current theme.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/core/theme.c54
-rw-r--r--src/gui/theme.c32
2 files changed, 36 insertions, 50 deletions
diff --git a/src/gui/core/theme.c b/src/gui/core/theme.c
index 83bcf4e..1c3ad12 100644
--- a/src/gui/core/theme.c
+++ b/src/gui/core/theme.c
@@ -43,16 +43,12 @@
#include "../../common/extstr.h"
#include "../../common/xdg.h"
#include "../../core/logs.h"
-#include "../../plugins/pglist.h"
/* Parcourt un répertoire donné à la recherche de thèmes. */
static void look_for_editor_themes(const char *);
-/* Parcourt tous les greffons à la recherche de définitions CSS. */
-static bool extend_with_plugins_themes(GdkScreen *, gboolean);
-
/* Répertoires de recherche */
static const char *_themes_directories[] = {
@@ -239,7 +235,10 @@ bool apply_gtk_theme(const char *name)
break;
}
- if (result)
+ if (!result)
+ log_variadic_message(LMT_ERROR, _("Theme '%s' not found!"), name);
+
+ else
{
screen = gdk_screen_get_default();
@@ -321,48 +320,3 @@ GtkCssProvider *load_css_content(GdkScreen *screen, const char *path)
return result;
}
-
-
-/******************************************************************************
-* *
-* Paramètres : screen = écran visé par le chargement d'un thème. *
-* dark = indique une préférence pour la variante foncée. *
-* *
-* Description : Parcourt tous les greffons à la recherche de définitions CSS.*
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool extend_with_plugins_themes(GdkScreen *screen, gboolean dark)
-{
- bool result; /* Bilan à renvoyer */
- char **resources; /* Fichiers supplémentaires */
- size_t count; /* Nombre de ces fichiers */
- size_t i; /* Boucle de parcours */
- GtkCssProvider *provider; /* Nouveau fournisseur CSS */
-
- result = true;
-
- resources = NULL;
- count = 0;
-
- include_plugin_theme(&resources, &count);
-
- for (i = 0; i < count && result; i++)
- {
- provider = load_css_content(screen, resources[i]);
- g_clear_object(&provider);
-
- free(resources[i]);
-
- }
-
- if (resources != NULL)
- free(resources);
-
- return result;
-
-}
diff --git a/src/gui/theme.c b/src/gui/theme.c
index dc3d1bb..3ed294a 100644
--- a/src/gui/theme.c
+++ b/src/gui/theme.c
@@ -33,6 +33,7 @@
#include "core/theme.h"
#include "../common/xml.h"
+#include "../plugins/pglist.h"
@@ -393,6 +394,13 @@ static void g_editor_theme_load_section(GEditorTheme *theme, GdkScreen *screen,
void g_editor_theme_load(GEditorTheme *theme, GdkScreen *screen, gboolean dark)
{
+ char **resources; /* Fichiers supplémentaires */
+ size_t count; /* Nombre de ces fichiers */
+ size_t i; /* Boucle de parcours */
+ GtkCssProvider *provider; /* Nouveau fournisseur CSS */
+
+ /* Chargement du thème global courant */
+
g_editor_theme_load_section(theme, screen, dark, "common");
if (dark)
@@ -400,4 +408,28 @@ void g_editor_theme_load(GEditorTheme *theme, GdkScreen *screen, gboolean dark)
else
g_editor_theme_load_section(theme, screen, dark, "light");
+ /* Chargement des thèmes des greffons */
+
+ resources = NULL;
+ count = 0;
+
+ include_plugin_theme(dark, &resources, &count);
+
+ for (i = 0; i < count; i++)
+ {
+ provider = load_css_content(screen, resources[i]);
+
+ if (provider != NULL)
+ {
+ theme->providers = realloc(theme->providers, ++theme->count * sizeof(GtkCssProvider *));
+ theme->providers[theme->count - 1] = provider;
+ }
+
+ free(resources[i]);
+
+ }
+
+ if (resources != NULL)
+ free(resources);
+
}