mirror of https://github.com/GNOME/gimp.git
app: keep the theme directories around a GFiles
and change gimp_get_theme_dir() to return a GFile.
This commit is contained in:
parent
32f29db8b0
commit
14c39816d8
|
@ -254,7 +254,7 @@ gimp_get_user_time (Gimp *gimp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
GFile *
|
||||||
gimp_get_theme_dir (Gimp *gimp)
|
gimp_get_theme_dir (Gimp *gimp)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||||
|
|
|
@ -48,7 +48,7 @@ struct _GimpGui
|
||||||
gint *monitor);
|
gint *monitor);
|
||||||
guint32 (* get_user_time) (Gimp *gimp);
|
guint32 (* get_user_time) (Gimp *gimp);
|
||||||
|
|
||||||
const gchar * (* get_theme_dir) (Gimp *gimp);
|
GFile * (* get_theme_dir) (Gimp *gimp);
|
||||||
|
|
||||||
GimpObject * (* get_window_strategy) (Gimp *gimp);
|
GimpObject * (* get_window_strategy) (Gimp *gimp);
|
||||||
GimpObject * (* get_empty_display) (Gimp *gimp);
|
GimpObject * (* get_empty_display) (Gimp *gimp);
|
||||||
|
@ -152,7 +152,7 @@ gchar * gimp_get_display_name (Gimp *gimp,
|
||||||
GObject **screen,
|
GObject **screen,
|
||||||
gint *monitor);
|
gint *monitor);
|
||||||
guint32 gimp_get_user_time (Gimp *gimp);
|
guint32 gimp_get_user_time (Gimp *gimp);
|
||||||
const gchar * gimp_get_theme_dir (Gimp *gimp);
|
GFile * gimp_get_theme_dir (Gimp *gimp);
|
||||||
|
|
||||||
gboolean gimp_pdb_dialog_new (Gimp *gimp,
|
gboolean gimp_pdb_dialog_new (Gimp *gimp,
|
||||||
GimpContext *context,
|
GimpContext *context,
|
||||||
|
|
|
@ -1510,12 +1510,13 @@ prefs_dialog_new (Gimp *gimp,
|
||||||
|
|
||||||
for (i = 0; i < n_themes; i++)
|
for (i = 0; i < n_themes; i++)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
GFile *theme_dir = themes_get_theme_dir (gimp, themes[i]);
|
||||||
|
|
||||||
gtk_list_store_append (list_store, &iter);
|
gtk_list_store_append (list_store, &iter);
|
||||||
gtk_list_store_set (list_store, &iter,
|
gtk_list_store_set (list_store, &iter,
|
||||||
0, themes[i],
|
0, themes[i],
|
||||||
1, themes_get_theme_dir (gimp, themes[i]),
|
1, gimp_file_get_utf8_name (theme_dir),
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
if (GIMP_GUI_CONFIG (object)->theme &&
|
if (GIMP_GUI_CONFIG (object)->theme &&
|
||||||
|
@ -1533,8 +1534,7 @@ prefs_dialog_new (Gimp *gimp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (themes)
|
g_strfreev (themes);
|
||||||
g_strfreev (themes);
|
|
||||||
|
|
||||||
g_signal_connect (sel, "changed",
|
g_signal_connect (sel, "changed",
|
||||||
G_CALLBACK (prefs_theme_select_callback),
|
G_CALLBACK (prefs_theme_select_callback),
|
||||||
|
|
|
@ -102,7 +102,7 @@ static gchar * gui_get_display_name (Gimp *gimp,
|
||||||
GObject **screen,
|
GObject **screen,
|
||||||
gint *monitor);
|
gint *monitor);
|
||||||
static guint32 gui_get_user_time (Gimp *gimp);
|
static guint32 gui_get_user_time (Gimp *gimp);
|
||||||
static const gchar * gui_get_theme_dir (Gimp *gimp);
|
static GFile * gui_get_theme_dir (Gimp *gimp);
|
||||||
static GimpObject * gui_get_window_strategy (Gimp *gimp);
|
static GimpObject * gui_get_window_strategy (Gimp *gimp);
|
||||||
static GimpObject * gui_get_empty_display (Gimp *gimp);
|
static GimpObject * gui_get_empty_display (Gimp *gimp);
|
||||||
static GimpObject * gui_display_get_by_ID (Gimp *gimp,
|
static GimpObject * gui_display_get_by_ID (Gimp *gimp,
|
||||||
|
@ -291,7 +291,7 @@ gui_get_user_time (Gimp *gimp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar *
|
static GFile *
|
||||||
gui_get_theme_dir (Gimp *gimp)
|
gui_get_theme_dir (Gimp *gimp)
|
||||||
{
|
{
|
||||||
return themes_get_theme_dir (gimp, GIMP_GUI_CONFIG (gimp->config)->theme);
|
return themes_get_theme_dir (gimp, GIMP_GUI_CONFIG (gimp->config)->theme);
|
||||||
|
|
|
@ -71,7 +71,7 @@ themes_init (Gimp *gimp)
|
||||||
themes_hash = g_hash_table_new_full (g_str_hash,
|
themes_hash = g_hash_table_new_full (g_str_hash,
|
||||||
g_str_equal,
|
g_str_equal,
|
||||||
g_free,
|
g_free,
|
||||||
g_free);
|
g_object_unref);
|
||||||
|
|
||||||
if (config->theme_path)
|
if (config->theme_path)
|
||||||
{
|
{
|
||||||
|
@ -143,7 +143,7 @@ themes_list_themes (Gimp *gimp,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
GFile *
|
||||||
themes_get_theme_dir (Gimp *gimp,
|
themes_get_theme_dir (Gimp *gimp,
|
||||||
const gchar *theme_name)
|
const gchar *theme_name)
|
||||||
{
|
{
|
||||||
|
@ -155,51 +155,57 @@ themes_get_theme_dir (Gimp *gimp,
|
||||||
return g_hash_table_lookup (themes_hash, theme_name);
|
return g_hash_table_lookup (themes_hash, theme_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
GFile *
|
||||||
themes_get_theme_file (Gimp *gimp,
|
themes_get_theme_file (Gimp *gimp,
|
||||||
const gchar *first_component,
|
const gchar *first_component,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
GimpGuiConfig *gui_config;
|
GimpGuiConfig *gui_config;
|
||||||
gchar *file;
|
GFile *file;
|
||||||
gchar *component;
|
const gchar *component;
|
||||||
gchar *path;
|
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||||
g_return_val_if_fail (first_component != NULL, NULL);
|
g_return_val_if_fail (first_component != NULL, NULL);
|
||||||
|
|
||||||
file = g_strdup (first_component);
|
gui_config = GIMP_GUI_CONFIG (gimp->config);
|
||||||
|
|
||||||
|
file = g_object_ref (themes_get_theme_dir (gimp, gui_config->theme));
|
||||||
|
component = first_component;
|
||||||
|
|
||||||
va_start (args, first_component);
|
va_start (args, first_component);
|
||||||
|
|
||||||
while ((component = va_arg (args, gchar *)))
|
do
|
||||||
{
|
{
|
||||||
gchar *tmp;
|
GFile *tmp = g_file_get_child (file, component);
|
||||||
|
g_object_unref (file);
|
||||||
tmp = g_build_filename (file, component, NULL);
|
|
||||||
g_free (file);
|
|
||||||
file = tmp;
|
file = tmp;
|
||||||
}
|
}
|
||||||
|
while ((component = va_arg (args, gchar *)));
|
||||||
|
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
|
||||||
gui_config = GIMP_GUI_CONFIG (gimp->config);
|
if (! g_file_query_exists (file, NULL))
|
||||||
|
|
||||||
path = g_build_filename (themes_get_theme_dir (gimp, gui_config->theme),
|
|
||||||
file, NULL);
|
|
||||||
|
|
||||||
if (! g_file_test (path, G_FILE_TEST_EXISTS))
|
|
||||||
{
|
{
|
||||||
g_free (path);
|
g_object_unref (file);
|
||||||
|
|
||||||
path = g_build_filename (themes_get_theme_dir (gimp, NULL),
|
file = g_object_ref (themes_get_theme_dir (gimp, NULL));
|
||||||
file, NULL);
|
component = first_component;
|
||||||
|
|
||||||
|
va_start (args, first_component);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
GFile *tmp = g_file_get_child (file, component);
|
||||||
|
g_object_unref (file);
|
||||||
|
file = tmp;
|
||||||
|
}
|
||||||
|
while ((component = va_arg (args, gchar *)));
|
||||||
|
|
||||||
|
va_end (args);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (file);
|
return file;
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,26 +238,32 @@ themes_apply_theme (Gimp *gimp,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const gchar *theme_dir = themes_get_theme_dir (gimp, theme_name);
|
GFile *theme_dir = themes_get_theme_dir (gimp, theme_name);
|
||||||
gchar *gtkrc_theme;
|
GFile *gtkrc_theme;
|
||||||
gchar *gtkrc_user;
|
GFile *gtkrc_user;
|
||||||
gchar *esc_gtkrc_theme;
|
gchar *esc_gtkrc_theme;
|
||||||
gchar *esc_gtkrc_user;
|
gchar *esc_gtkrc_user;
|
||||||
|
gchar *tmp;
|
||||||
|
|
||||||
if (theme_dir)
|
if (theme_dir)
|
||||||
{
|
{
|
||||||
gtkrc_theme = g_build_filename (theme_dir, "gtkrc", NULL);
|
gtkrc_theme = g_file_get_child (theme_dir, "gtkrc");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* get the hardcoded default theme gtkrc */
|
/* get the hardcoded default theme gtkrc */
|
||||||
gtkrc_theme = g_strdup (gimp_gtkrc ());
|
gtkrc_theme = g_file_new_for_path (gimp_gtkrc ());
|
||||||
}
|
}
|
||||||
|
|
||||||
gtkrc_user = gimp_personal_rc_file ("gtkrc");
|
gtkrc_user = gimp_personal_rc_gfile ("gtkrc");
|
||||||
|
|
||||||
esc_gtkrc_theme = g_strescape (gtkrc_theme, NULL);
|
tmp = g_file_get_path (gtkrc_theme);
|
||||||
esc_gtkrc_user = g_strescape (gtkrc_user, NULL);
|
esc_gtkrc_theme = g_strescape (tmp, NULL);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
tmp = g_file_get_path (gtkrc_user);
|
||||||
|
esc_gtkrc_user = g_strescape (tmp, NULL);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
if (! gimp_output_stream_printf
|
if (! gimp_output_stream_printf
|
||||||
(output, NULL, NULL, &error,
|
(output, NULL, NULL, &error,
|
||||||
|
@ -265,9 +277,10 @@ themes_apply_theme (Gimp *gimp,
|
||||||
"include \"%s\"\n"
|
"include \"%s\"\n"
|
||||||
"\n"
|
"\n"
|
||||||
"# end of themerc\n",
|
"# end of themerc\n",
|
||||||
gtkrc_user,
|
gimp_file_get_utf8_name (gtkrc_user),
|
||||||
esc_gtkrc_theme,
|
esc_gtkrc_theme,
|
||||||
esc_gtkrc_user))
|
esc_gtkrc_user) ||
|
||||||
|
! g_output_stream_close (output, NULL, &error))
|
||||||
{
|
{
|
||||||
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR,
|
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR,
|
||||||
_("Error writing '%s': %s"),
|
_("Error writing '%s': %s"),
|
||||||
|
@ -277,9 +290,8 @@ themes_apply_theme (Gimp *gimp,
|
||||||
|
|
||||||
g_free (esc_gtkrc_theme);
|
g_free (esc_gtkrc_theme);
|
||||||
g_free (esc_gtkrc_user);
|
g_free (esc_gtkrc_user);
|
||||||
g_free (gtkrc_theme);
|
g_object_unref (gtkrc_theme);
|
||||||
g_free (gtkrc_user);
|
g_object_unref (gtkrc_user);
|
||||||
|
|
||||||
g_object_unref (output);
|
g_object_unref (output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +311,7 @@ themes_directories_foreach (const GimpDatafileData *file_data,
|
||||||
|
|
||||||
g_hash_table_insert (themes_hash,
|
g_hash_table_insert (themes_hash,
|
||||||
g_strdup (file_data->basename),
|
g_strdup (file_data->basename),
|
||||||
g_strdup (file_data->filename));
|
g_file_new_for_path (file_data->filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -19,16 +19,16 @@
|
||||||
#define __THEMES_H__
|
#define __THEMES_H__
|
||||||
|
|
||||||
|
|
||||||
void themes_init (Gimp *gimp);
|
void themes_init (Gimp *gimp);
|
||||||
void themes_exit (Gimp *gimp);
|
void themes_exit (Gimp *gimp);
|
||||||
|
|
||||||
gchar ** themes_list_themes (Gimp *gimp,
|
gchar ** themes_list_themes (Gimp *gimp,
|
||||||
gint *n_themes);
|
gint *n_themes);
|
||||||
const gchar * themes_get_theme_dir (Gimp *gimp,
|
GFile * themes_get_theme_dir (Gimp *gimp,
|
||||||
const gchar *theme_name);
|
const gchar *theme_name);
|
||||||
gchar * themes_get_theme_file (Gimp *gimp,
|
GFile * themes_get_theme_file (Gimp *gimp,
|
||||||
const gchar *first_component,
|
const gchar *first_component,
|
||||||
...) G_GNUC_NULL_TERMINATED;
|
...) G_GNUC_NULL_TERMINATED;
|
||||||
|
|
||||||
|
|
||||||
#endif /* __THEMES_H__ */
|
#endif /* __THEMES_H__ */
|
||||||
|
|
|
@ -184,7 +184,10 @@ get_theme_dir_invoker (GimpProcedure *procedure,
|
||||||
GimpValueArray *return_vals;
|
GimpValueArray *return_vals;
|
||||||
gchar *theme_dir = NULL;
|
gchar *theme_dir = NULL;
|
||||||
|
|
||||||
theme_dir = g_strdup (gimp_get_theme_dir (gimp));
|
GFile *file = gimp_get_theme_dir (gimp);
|
||||||
|
|
||||||
|
if (file)
|
||||||
|
theme_dir = g_file_get_path (file);
|
||||||
|
|
||||||
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
|
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
|
||||||
g_value_take_string (gimp_value_array_index (return_vals, 1), theme_dir);
|
g_value_take_string (gimp_value_array_index (return_vals, 1), theme_dir);
|
||||||
|
|
|
@ -184,7 +184,10 @@ sub get_theme_dir {
|
||||||
%invoke = (
|
%invoke = (
|
||||||
code => <<'CODE'
|
code => <<'CODE'
|
||||||
{
|
{
|
||||||
theme_dir = g_strdup (gimp_get_theme_dir (gimp));
|
GFile *file = gimp_get_theme_dir (gimp);
|
||||||
|
|
||||||
|
if (file)
|
||||||
|
theme_dir = g_file_get_path (file);
|
||||||
}
|
}
|
||||||
CODE
|
CODE
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue