Commit a4e0a8f9 authored by Jehan's avatar Jehan

app: extensions can now install themes.

parent 7d611e71
......@@ -56,6 +56,7 @@ struct _GimpExtensionPrivate
GList *palette_paths;
GList *tool_preset_paths;
GList *splash_paths;
GList *theme_paths;
/* Extension metadata: plug-in entry points. */
GList *plug_in_paths;
......@@ -444,6 +445,13 @@ gimp_extension_run (GimpExtension *extension,
value, TRUE,
error);
}
if (! (*error))
{
value = g_hash_table_lookup (metadata, "GIMP::theme-path");
extension->p->theme_paths = gimp_extension_validate_paths (extension,
value, TRUE,
error);
}
if (*error)
gimp_extension_clean (extension);
......@@ -512,6 +520,12 @@ gimp_extension_get_splash_paths (GimpExtension *extension)
return extension->p->splash_paths;
}
GList *
gimp_extension_get_theme_paths (GimpExtension *extension)
{
return extension->p->theme_paths;
}
GList *
gimp_extension_get_plug_in_paths (GimpExtension *extension)
{
......@@ -574,6 +588,8 @@ gimp_extension_clean (GimpExtension *extension)
extension->p->plug_in_paths = NULL;
g_list_free_full (extension->p->splash_paths, g_object_unref);
extension->p->splash_paths = NULL;
g_list_free_full (extension->p->theme_paths, g_object_unref);
extension->p->theme_paths = NULL;
}
/**
......
......@@ -70,6 +70,7 @@ GList * gimp_extension_get_gradient_paths (GimpExtension *extensio
GList * gimp_extension_get_palette_paths (GimpExtension *extension);
GList * gimp_extension_get_tool_preset_paths (GimpExtension *extension);
GList * gimp_extension_get_splash_paths (GimpExtension *extension);
GList * gimp_extension_get_theme_paths (GimpExtension *extension);
GList * gimp_extension_get_plug_in_paths (GimpExtension *extension);
gint gimp_extension_cmp (GimpExtension *extension1,
......
......@@ -54,6 +54,7 @@ enum
PROP_PALETTE_PATHS,
PROP_TOOL_PRESET_PATHS,
PROP_SPLASH_PATHS,
PROP_THEME_PATHS,
PROP_PLUG_IN_PATHS,
};
......@@ -78,6 +79,7 @@ struct _GimpExtensionManagerPrivate
GList *palette_paths;
GList *tool_preset_paths;
GList *splash_paths;
GList *theme_paths;
GList *plug_in_paths;
};
......@@ -166,6 +168,10 @@ gimp_extension_manager_class_init (GimpExtensionManagerClass *klass)
g_param_spec_pointer ("splash-paths",
NULL, NULL,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_THEME_PATHS,
g_param_spec_pointer ("theme-paths",
NULL, NULL,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_PLUG_IN_PATHS,
g_param_spec_pointer ("plug-in-paths",
NULL, NULL,
......@@ -407,6 +413,9 @@ gimp_extension_manager_set_property (GObject *object,
case PROP_SPLASH_PATHS:
manager->p->splash_paths = g_value_get_pointer (value);
break;
case PROP_THEME_PATHS:
manager->p->theme_paths = g_value_get_pointer (value);
break;
case PROP_PLUG_IN_PATHS:
manager->p->plug_in_paths = g_value_get_pointer (value);
break;
......@@ -454,6 +463,9 @@ gimp_extension_manager_get_property (GObject *object,
case PROP_SPLASH_PATHS:
g_value_set_pointer (value, manager->p->splash_paths);
break;
case PROP_THEME_PATHS:
g_value_set_pointer (value, manager->p->theme_paths);
break;
case PROP_PLUG_IN_PATHS:
g_value_set_pointer (value, manager->p->plug_in_paths);
break;
......@@ -707,6 +719,7 @@ gimp_extension_manager_refresh (GimpExtensionManager *manager)
GList *palette_paths = NULL;
GList *tool_preset_paths = NULL;
GList *splash_paths = NULL;
GList *theme_paths = NULL;
GList *plug_in_paths = NULL;
g_hash_table_iter_init (&iter, manager->p->running_extensions);
......@@ -747,6 +760,10 @@ gimp_extension_manager_refresh (GimpExtensionManager *manager)
(GCopyFunc) g_object_ref, NULL);
splash_paths = g_list_concat (splash_paths, new_paths);
new_paths = g_list_copy_deep (gimp_extension_get_theme_paths (extension),
(GCopyFunc) g_object_ref, NULL);
theme_paths = g_list_concat (theme_paths, new_paths);
new_paths = g_list_copy_deep (gimp_extension_get_plug_in_paths (extension),
(GCopyFunc) g_object_ref, NULL);
plug_in_paths = g_list_concat (plug_in_paths, new_paths);
......@@ -762,6 +779,7 @@ gimp_extension_manager_refresh (GimpExtensionManager *manager)
"tool-preset-paths", tool_preset_paths,
"plug-in-paths", plug_in_paths,
"splash-paths", splash_paths,
"theme-paths", theme_paths,
NULL);
}
......
......@@ -48,6 +48,9 @@ static gint themes_name_compare (const void *p1,
static void themes_theme_change_notify (GimpGuiConfig *config,
GParamSpec *pspec,
Gimp *gimp);
static void themes_theme_paths_notify (GimpExtensionManager *manager,
GParamSpec *pspec,
Gimp *gimp);
/* private variables */
......@@ -67,66 +70,11 @@ themes_init (Gimp *gimp)
config = GIMP_GUI_CONFIG (gimp->config);
themes_hash = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
g_object_unref);
if (config->theme_path)
{
GList *path;
GList *list;
path = gimp_config_path_expand_to_files (config->theme_path, NULL);
for (list = path; list; list = g_list_next (list))
{
GFile *dir = list->data;
GFileEnumerator *enumerator;
enumerator =
g_file_enumerate_children (dir,
G_FILE_ATTRIBUTE_STANDARD_NAME ","
G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN ","
G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NONE,
NULL, NULL);
if (enumerator)
{
GFileInfo *info;
while ((info = g_file_enumerator_next_file (enumerator,
NULL, NULL)))
{
if (! g_file_info_get_is_hidden (info) &&
g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
{
GFile *file;
const gchar *name;
gchar *basename;
file = g_file_enumerator_get_child (enumerator, info);
name = gimp_file_get_utf8_name (file);
basename = g_path_get_basename (name);
if (gimp->be_verbose)
g_print ("Adding theme '%s' (%s)\n",
basename, name);
g_hash_table_insert (themes_hash, basename, file);
}
g_object_unref (info);
}
g_object_unref (enumerator);
}
}
g_list_free_full (path, (GDestroyNotify) g_object_unref);
}
/* Check for theme extensions. */
themes_theme_paths_notify (gimp->extension_manager, NULL, gimp);
g_signal_connect (gimp->extension_manager, "notify::theme-paths",
G_CALLBACK (themes_theme_paths_notify),
gimp);
themes_style_provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
......@@ -406,3 +354,82 @@ themes_theme_change_notify (GimpGuiConfig *config,
gtk_style_context_reset_widgets (gdk_screen_get_default ());
}
static void
themes_theme_paths_notify (GimpExtensionManager *manager,
GParamSpec *pspec,
Gimp *gimp)
{
GimpGuiConfig *config;
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (themes_hash)
g_hash_table_remove_all (themes_hash);
else
themes_hash = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
g_object_unref);
config = GIMP_GUI_CONFIG (gimp->config);
if (config->theme_path)
{
GList *path;
GList *list;
g_object_get (gimp->extension_manager,
"theme-paths", &path,
NULL);
path = g_list_copy_deep (path, (GCopyFunc) g_object_ref, NULL);
path = g_list_concat (path, gimp_config_path_expand_to_files (config->theme_path, NULL));
for (list = path; list; list = g_list_next (list))
{
GFile *dir = list->data;
GFileEnumerator *enumerator;
enumerator =
g_file_enumerate_children (dir,
G_FILE_ATTRIBUTE_STANDARD_NAME ","
G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN ","
G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NONE,
NULL, NULL);
if (enumerator)
{
GFileInfo *info;
while ((info = g_file_enumerator_next_file (enumerator,
NULL, NULL)))
{
if (! g_file_info_get_is_hidden (info) &&
g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
{
GFile *file;
const gchar *name;
gchar *basename;
file = g_file_enumerator_get_child (enumerator, info);
name = gimp_file_get_utf8_name (file);
basename = g_path_get_basename (name);
if (gimp->be_verbose)
g_print ("Adding theme '%s' (%s)\n",
basename, name);
g_hash_table_insert (themes_hash, basename, file);
}
g_object_unref (info);
}
g_object_unref (enumerator);
}
}
g_list_free_full (path, (GDestroyNotify) g_object_unref);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment