app: include system gtkrc file in themerc

Include the system-wide gtkrc file, in addition to the user-
specific gtkrc file, in the generated themerc file, instead of
copying the former into the latter when creating the user's
gimpdir.  This allows us to modify the system-wide gtkrc file, and
having the changes take effect in existing installations.
This commit is contained in:
Ell
2019-03-27 18:01:34 -04:00
parent f19ebb6269
commit 7edbad3144
2 changed files with 60 additions and 35 deletions

View File

@ -88,7 +88,6 @@ static const struct
} }
gimp_user_install_items[] = gimp_user_install_items[] =
{ {
{ "gtkrc", USER_INSTALL_COPY },
{ "menurc", USER_INSTALL_COPY }, { "menurc", USER_INSTALL_COPY },
{ "brushes", USER_INSTALL_MKDIR }, { "brushes", USER_INSTALL_MKDIR },
{ "dynamics", USER_INSTALL_MKDIR }, { "dynamics", USER_INSTALL_MKDIR },

View File

@ -296,48 +296,77 @@ themes_apply_theme (Gimp *gimp,
} }
else else
{ {
GFile *theme_dir = themes_get_theme_dir (gimp, theme_name); GFile *theme_dir = themes_get_theme_dir (gimp, theme_name);
GFile *gtkrc_theme; GFile *gtkrc_user;
GFile *gtkrc_user; GSList *gtkrc_files = NULL;
gchar *esc_gtkrc_theme; GSList *iter;
gchar *esc_gtkrc_user;
gchar *tmp;
if (theme_dir) if (theme_dir)
{ {
gtkrc_theme = g_file_get_child (theme_dir, "gtkrc"); gtkrc_files = g_slist_prepend (
gtkrc_files,
g_file_get_child (theme_dir, "gtkrc"));
} }
else else
{ {
/* get the hardcoded default theme gtkrc */ /* get the hardcoded default theme gtkrc */
gtkrc_theme = g_file_new_for_path (gimp_gtkrc ()); gtkrc_files = g_slist_prepend (
gtkrc_files,
g_file_new_for_path (gimp_gtkrc ()));
} }
gtkrc_user = gimp_directory_file ("gtkrc", NULL); gtkrc_files = g_slist_prepend (
gtkrc_files,
gimp_sysconf_directory_file ("gtkrc", NULL));
tmp = g_file_get_path (gtkrc_theme); gtkrc_user = gimp_directory_file ("gtkrc", NULL);
esc_gtkrc_theme = g_strescape (tmp, NULL); gtkrc_files = g_slist_prepend (
g_free (tmp); gtkrc_files,
gtkrc_user);
tmp = g_file_get_path (gtkrc_user); gtkrc_files = g_slist_reverse (gtkrc_files);
esc_gtkrc_user = g_strescape (tmp, NULL);
g_free (tmp);
if (! g_output_stream_printf g_output_stream_printf (
(output, NULL, NULL, &error, output, NULL, NULL, &error,
"# GIMP themerc\n" "# GIMP themerc\n"
"#\n" "#\n"
"# This file is written on GIMP startup and on every theme change.\n" "# This file is written on GIMP startup and on every theme change.\n"
"# It is NOT supposed to be edited manually. Edit your personal\n" "# It is NOT supposed to be edited manually. Edit your personal\n"
"# gtkrc file instead (%s).\n" "# gtkrc file instead (%s).\n"
"\n" "\n",
"include \"%s\"\n" gimp_file_get_utf8_name (gtkrc_user));
"include \"%s\"\n"
"\n" for (iter = gtkrc_files; ! error && iter; iter = g_slist_next (iter))
"# end of themerc\n", {
gimp_file_get_utf8_name (gtkrc_user), GFile *file = iter->data;
esc_gtkrc_theme,
esc_gtkrc_user)) if (g_file_query_exists (file, NULL))
{
gchar *path;
gchar *esc_path;
path = g_file_get_path (file);
esc_path = g_strescape (path, NULL);
g_free (path);
g_output_stream_printf (
output, NULL, NULL, &error,
"include \"%s\"\n",
esc_path);
g_free (esc_path);
}
}
if (! error)
{
g_output_stream_printf (
output, NULL, NULL, &error,
"\n"
"# end of themerc\n");
}
if (error)
{ {
GCancellable *cancellable = g_cancellable_new (); GCancellable *cancellable = g_cancellable_new ();
@ -359,10 +388,7 @@ themes_apply_theme (Gimp *gimp,
g_clear_error (&error); g_clear_error (&error);
} }
g_free (esc_gtkrc_theme); g_slist_free_full (gtkrc_files, g_object_unref);
g_free (esc_gtkrc_user);
g_object_unref (gtkrc_theme);
g_object_unref (gtkrc_user);
g_object_unref (output); g_object_unref (output);
} }