diff options
author | Colomban Wendling <[email protected]> | 2019-06-27 11:49:12 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2022-07-20 18:47:25 +0200 |
commit | 9ead522d48b09816db5e1a12e65e8d57b8e5651f (patch) | |
tree | d9d7b3920546ecc7ff5aaa20c41825c35b36c1f4 | |
parent | cef4f470e7678a9eb836dfb28f9965d41e92bba1 (diff) | |
download | caja-9ead522d48b09816db5e1a12e65e8d57b8e5651f.tar.bz2 caja-9ead522d48b09816db5e1a12e65e8d57b8e5651f.tar.xz |
Refactor custom CSS loading into a separate function
-rw-r--r-- | src/caja-application.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/caja-application.c b/src/caja-application.c index 7bb3a030..a69af758 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 (), |