summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorColomban Wendling <[email protected]>2019-06-27 11:49:12 +0200
committerlukefromdc <[email protected]>2019-07-08 23:30:28 +0000
commit7fb0ed47f1c0d472b89be358777f72dcc8bbbf89 (patch)
treede2ed892eabb91d4f994fff0a20e0d8a5cdbb53c /src
parent9a0031211ae0ac88053de91b429ecf3b8d6d2d17 (diff)
downloadcaja-7fb0ed47f1c0d472b89be358777f72dcc8bbbf89.tar.bz2
caja-7fb0ed47f1c0d472b89be358777f72dcc8bbbf89.tar.xz
Refactor custom CSS loading into a separate function
Diffstat (limited to 'src')
-rw-r--r--src/caja-application.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/caja-application.c b/src/caja-application.c
index ff3e6679..35053d6b 100644
--- a/src/caja-application.c
+++ b/src/caja-application.c
@@ -2024,43 +2024,38 @@ caja_application_local_command_line (GApplication *application,
return TRUE;
}
-
static void
-init_icons_and_styles (void)
+load_custom_css (const gchar *filename,
+ guint priority)
{
GtkCssProvider *provider;
GError *error = NULL;
+ gchar *path = g_build_filename (CAJA_DATADIR, filename, NULL);
- /* add our custom CSS provider */
provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_path (provider,
- CAJA_DATADIR G_DIR_SEPARATOR_S "caja.css", &error);
+ gtk_css_provider_load_from_path (provider, path, &error);
if (error != NULL) {
- g_warning ("Can't parse Caja' CSS custom description: %s\n", error->message);
+ g_warning ("Can't parse Caja' CSS custom description '%s': %s\n",
+ filename, error->message);
g_error_free (error);
} else {
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_THEME);
+ GTK_STYLE_PROVIDER (provider),
+ priority);
}
-/* add our desktop CSS provider, ensures the desktop background does not get covered */
- provider = gtk_css_provider_new ();
-
- gtk_css_provider_load_from_path (provider, CAJA_DATADIR G_DIR_SEPARATOR_S "caja-desktop.css", &error);
-
- if (error != NULL) {
- g_warning ("Can't parse Caja' CSS custom description: %s\n", error->message);
- g_error_free (error);
- } else {
- gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- }
-
-
g_object_unref (provider);
+ g_free (path);
+}
+
+static void
+init_icons_and_styles (void)
+{
+ /* add our custom CSS provider */
+ load_custom_css ("caja.css", GTK_STYLE_PROVIDER_PRIORITY_THEME);
+ /* add our desktop CSS provider, ensures the desktop background does not get covered */
+ load_custom_css ("caja-desktop.css", GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
/* initialize search path for custom icons */
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),