summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis@xfce.org>2010-01-06 10:32:31 +0100
committerJannis Pohlmann <jannis@xfce.org>2010-01-06 10:34:23 +0100
commitcc815dd0ed2e90efbdbaffa5a6f594d95dcee332 (patch)
treec9bd3b6221a1d0fe97c9287cd4fb45fd01519eaa
parent549c7b3bc44d2d67a94776bb49ce21a61d1aed28 (diff)
downloadtumbler-jannis/plugin-supported-changed.tar.gz
Squashme: Allow supported type changes in plugins.jannis/plugin-supported-changed
-rw-r--r--docs/reference/tumbler/tumbler-sections.txt5
-rw-r--r--tumbler/tumbler-abstract-thumbnailer.c120
-rw-r--r--tumbler/tumbler-abstract-thumbnailer.h2
-rw-r--r--tumbler/tumbler-marshal.list6
-rw-r--r--tumbler/tumbler-thumbnailer.c24
-rw-r--r--tumbler/tumbler-thumbnailer.h17
-rw-r--r--tumblerd/tumbler-registry.c43
7 files changed, 149 insertions, 68 deletions
diff --git a/docs/reference/tumbler/tumbler-sections.txt b/docs/reference/tumbler/tumbler-sections.txt
index db113d5..110ba0b 100644
--- a/docs/reference/tumbler/tumbler-sections.txt
+++ b/docs/reference/tumbler/tumbler-sections.txt
@@ -68,6 +68,7 @@ TumblerThumbnailerIface
tumbler_thumbnailer_create
tumbler_thumbnailer_get_hash_keys
tumbler_thumbnailer_get_mime_types
+tumbler_thumbnailer_set_mime_types
tumbler_thumbnailer_get_uri_schemes
tumbler_thumbnailer_supports_hash_key
tumbler_thumbnailer_array_copy
@@ -220,11 +221,11 @@ tumbler_util_get_supported_uri_schemes
<SECTION>
<FILE>tumbler-marshal</FILE>
tumbler_marshal_VOID__STRING_INT_STRING
-tumbler_marshal_VOID__UINT_STRING_INT_STRING
tumbler_marshal_VOID__UINT_POINTER_INT_STRING_STRING
+tumbler_marshal_VOID__UINT_POINTER_INT_STRING
tumbler_marshal_VOID__UINT_POINTER_STRING
+tumbler_marshal_VOID__UINT_STRING_INT_STRING
tumbler_marshal_VOID__UINT_STRING
-tumbler_marshal_VOID__UINT_POINTER_INT_STRING
</SECTION>
<SECTION>
diff --git a/tumbler/tumbler-abstract-thumbnailer.c b/tumbler/tumbler-abstract-thumbnailer.c
index 31a8f79..6433912 100644
--- a/tumbler/tumbler-abstract-thumbnailer.c
+++ b/tumbler/tumbler-abstract-thumbnailer.c
@@ -46,20 +46,21 @@ enum
-static void tumbler_abstract_thumbnailer_thumbnailer_init (TumblerThumbnailerIface *iface);
-static void tumbler_abstract_thumbnailer_constructed (GObject *object);
-static void tumbler_abstract_thumbnailer_finalize (GObject *object);
-static void tumbler_abstract_thumbnailer_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void tumbler_abstract_thumbnailer_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void tumbler_abstract_thumbnailer_create (TumblerThumbnailer *thumbnailer,
- GCancellable *cancellable,
- TumblerFileInfo *info);
+static void tumbler_abstract_thumbnailer_thumbnailer_init (TumblerThumbnailerIface *iface);
+static void tumbler_abstract_thumbnailer_constructed (GObject *object);
+static void tumbler_abstract_thumbnailer_finalize (GObject *object);
+static void tumbler_abstract_thumbnailer_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void tumbler_abstract_thumbnailer_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void tumbler_abstract_thumbnailer_create (TumblerThumbnailer *thumbnailer,
+ GCancellable *cancellable,
+ TumblerFileInfo *info);
+static void tumbler_abstract_thumbnailer_update_hash_keys (TumblerAbstractThumbnailer *thumbnailer);
@@ -121,45 +122,16 @@ static void
tumbler_abstract_thumbnailer_constructed (GObject *object)
{
TumblerAbstractThumbnailer *thumbnailer = TUMBLER_ABSTRACT_THUMBNAILER (object);
- gchar *hash_key;
- guint num_hash_keys;
- guint num_mime_types;
- guint num_uri_schemes;
- guint i;
- guint j;
g_return_if_fail (TUMBLER_IS_ABSTRACT_THUMBNAILER (thumbnailer));
g_return_if_fail (thumbnailer->priv->mime_types != NULL);
g_return_if_fail (thumbnailer->priv->uri_schemes != NULL);
- g_return_if_fail (thumbnailer->priv->hash_keys == NULL);
/* chain up to parent classes */
if (G_OBJECT_CLASS (tumbler_abstract_thumbnailer_parent_class)->constructed != NULL)
(G_OBJECT_CLASS (tumbler_abstract_thumbnailer_parent_class)->constructed) (object);
- /* determine the size of both arrays */
- num_uri_schemes = g_strv_length (thumbnailer->priv->uri_schemes);
- num_mime_types = g_strv_length (thumbnailer->priv->mime_types);
-
- /* compute the number of hash keys to generate */
- num_hash_keys = num_uri_schemes * num_mime_types;
-
- /* allocate and NULL-terminate the hash key array */
- thumbnailer->priv->hash_keys = g_new0 (gchar *, num_hash_keys + 1);
- thumbnailer->priv->hash_keys[num_hash_keys] = NULL;
-
- /* iterate over all pairs of URIs and MIME types */
- for (i = 0; thumbnailer->priv->uri_schemes[i] != NULL; ++i)
- for (j = 0; thumbnailer->priv->mime_types[j] != NULL; ++j)
- {
- /* generate a hash key for the current pair */
- hash_key = g_strdup_printf ("%s-%s",
- thumbnailer->priv->uri_schemes[i],
- thumbnailer->priv->mime_types[j]);
-
- /* add the key to the array */
- thumbnailer->priv->hash_keys[(j*num_uri_schemes)+i] = hash_key;
- }
+ tumbler_abstract_thumbnailer_update_hash_keys (thumbnailer);
}
@@ -217,9 +189,19 @@ tumbler_abstract_thumbnailer_set_property (GObject *object,
{
case PROP_MIME_TYPES:
thumbnailer->priv->mime_types = g_strdupv (g_value_get_pointer (value));
+ if (thumbnailer->priv->mime_types != NULL
+ && thumbnailer->priv->uri_schemes != NULL)
+ {
+ tumbler_abstract_thumbnailer_update_hash_keys (thumbnailer);
+ }
break;
case PROP_URI_SCHEMES:
thumbnailer->priv->uri_schemes = g_strdupv (g_value_get_pointer (value));
+ if (thumbnailer->priv->mime_types != NULL
+ && thumbnailer->priv->uri_schemes != NULL)
+ {
+ tumbler_abstract_thumbnailer_update_hash_keys (thumbnailer);
+ }
break;
case PROP_HASH_KEYS:
thumbnailer->priv->hash_keys = g_strdupv (g_value_get_pointer (value));
@@ -244,3 +226,53 @@ tumbler_abstract_thumbnailer_create (TumblerThumbnailer *thumbnailer,
TUMBLER_ABSTRACT_THUMBNAILER_GET_CLASS (thumbnailer)->create (TUMBLER_ABSTRACT_THUMBNAILER (thumbnailer),
cancellable, info);
}
+
+
+
+static void
+tumbler_abstract_thumbnailer_update_hash_keys (TumblerAbstractThumbnailer *thumbnailer)
+{
+ gchar *hash_key;
+ guint num_hash_keys;
+ guint num_mime_types;
+ guint num_uri_schemes;
+ guint i;
+ guint j;
+
+ g_return_if_fail (TUMBLER_IS_ABSTRACT_THUMBNAILER (thumbnailer));
+
+ if (thumbnailer->priv->hash_keys != NULL)
+ {
+ g_strfreev (thumbnailer->priv->hash_keys);
+ thumbnailer->priv->hash_keys = NULL;
+ }
+
+ /* determine the size of both arrays */
+ num_uri_schemes = g_strv_length (thumbnailer->priv->uri_schemes);
+ num_mime_types = g_strv_length (thumbnailer->priv->mime_types);
+
+ /* compute the number of hash keys to generate */
+ num_hash_keys = num_uri_schemes * num_mime_types;
+
+ /* allocate and NULL-terminate the hash key array */
+ thumbnailer->priv->hash_keys = g_new0 (gchar *, num_hash_keys + 1);
+ thumbnailer->priv->hash_keys[num_hash_keys] = NULL;
+
+ /* iterate over all pairs of URIs and MIME types */
+ for (i = 0; thumbnailer->priv->uri_schemes[i] != NULL; ++i)
+ for (j = 0; thumbnailer->priv->mime_types[j] != NULL; ++j)
+ {
+ /* generate a hash key for the current pair */
+ hash_key = g_strdup_printf ("%s-%s",
+ thumbnailer->priv->uri_schemes[i],
+ thumbnailer->priv->mime_types[j]);
+
+ /* add the key to the array */
+ thumbnailer->priv->hash_keys[(j*num_uri_schemes)+i] = hash_key;
+ }
+
+ g_object_notify (G_OBJECT (thumbnailer), "hash-keys");
+}
+
+
+
diff --git a/tumbler/tumbler-abstract-thumbnailer.h b/tumbler/tumbler-abstract-thumbnailer.h
index f4435c4..b1ea5f3 100644
--- a/tumbler/tumbler-abstract-thumbnailer.h
+++ b/tumbler/tumbler-abstract-thumbnailer.h
@@ -60,7 +60,7 @@ struct _TumblerAbstractThumbnailer
TumblerAbstractThumbnailerPrivate *priv;
};
-GType tumbler_abstract_thumbnailer_get_type (void) G_GNUC_CONST;
+GType tumbler_abstract_thumbnailer_get_type (void) G_GNUC_CONST;
G_END_DECLS;
diff --git a/tumbler/tumbler-marshal.list b/tumbler/tumbler-marshal.list
index a963dd8..6233a66 100644
--- a/tumbler/tumbler-marshal.list
+++ b/tumbler/tumbler-marshal.list
@@ -1,7 +1,7 @@
VOID:STRING,INT,STRING
-VOID:UINT,STRING,INT,STRING
-VOID:UINT,POINTER,INT,STRING,STRING
VOID:STRING,INT,STRING
+VOID:UINT,POINTER,INT,STRING,STRING
+VOID:UINT,POINTER,INT,STRING
VOID:UINT,POINTER,STRING
+VOID:UINT,STRING,INT,STRING
VOID:UINT,STRING
-VOID:UINT,POINTER,INT,STRING
diff --git a/tumbler/tumbler-thumbnailer.c b/tumbler/tumbler-thumbnailer.c
index cc350da..6010ba0 100644
--- a/tumbler/tumbler-thumbnailer.c
+++ b/tumbler/tumbler-thumbnailer.c
@@ -34,6 +34,7 @@ enum
SIGNAL_READY,
SIGNAL_ERROR,
SIGNAL_UNREGISTER,
+ SIGNAL_SUPPORTED_CHANGED,
LAST_SIGNAL,
};
@@ -132,6 +133,17 @@ tumbler_thumbnailer_class_init (TumblerThumbnailerIface *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+
+ tumbler_thumbnailer_signals[SIGNAL_SUPPORTED_CHANGED] =
+ g_signal_new ("supported-changed",
+ TUMBLER_TYPE_THUMBNAILER,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (TumblerThumbnailerIface, supported_changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
@@ -178,6 +190,18 @@ tumbler_thumbnailer_get_mime_types (TumblerThumbnailer *thumbnailer)
+void
+tumbler_thumbnailer_set_mime_types (TumblerThumbnailer *thumbnailer,
+ const gchar *const *mime_types)
+{
+ g_return_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer));
+ g_return_if_fail (mime_types != NULL);
+
+ g_object_set (thumbnailer, "mime-types", mime_types, NULL);
+}
+
+
+
GStrv
tumbler_thumbnailer_get_uri_schemes (TumblerThumbnailer *thumbnailer)
{
diff --git a/tumbler/tumbler-thumbnailer.h b/tumbler/tumbler-thumbnailer.h
index 36adf6d..8e7fecf 100644
--- a/tumbler/tumbler-thumbnailer.h
+++ b/tumbler/tumbler-thumbnailer.h
@@ -45,13 +45,14 @@ struct _TumblerThumbnailerIface
GTypeInterface __parent__;
/* signals */
- void (*ready) (TumblerThumbnailer *thumbnailer,
- const gchar *uri);
- void (*error) (TumblerThumbnailer *thumbnailer,
- const gchar *failed_uri,
- gint error_code,
- const gchar *message);
- void (*unregister) (TumblerThumbnailer *thumbnailer);
+ void (*ready) (TumblerThumbnailer *thumbnailer,
+ const gchar *uri);
+ void (*error) (TumblerThumbnailer *thumbnailer,
+ const gchar *failed_uri,
+ gint error_code,
+ const gchar *message);
+ void (*unregister) (TumblerThumbnailer *thumbnailer);
+ void (*supported_changed) (TumblerThumbnailer *thumbnailer);
/* virtual methods */
void (*create) (TumblerThumbnailer *thumbnailer,
@@ -67,6 +68,8 @@ void tumbler_thumbnailer_create (TumblerThumbnailer
GStrv tumbler_thumbnailer_get_hash_keys (TumblerThumbnailer *thumbnailer);
GStrv tumbler_thumbnailer_get_mime_types (TumblerThumbnailer *thumbnailer);
+void tumbler_thumbnailer_set_mime_types (TumblerThumbnailer *thumbnailer,
+ const gchar *const *mime_types);
GStrv tumbler_thumbnailer_get_uri_schemes (TumblerThumbnailer *thumbnailer);
gboolean tumbler_thumbnailer_supports_hash_key (TumblerThumbnailer *thumbnailer,
const gchar *hash_key);
diff --git a/tumblerd/tumbler-registry.c b/tumblerd/tumbler-registry.c
index 9450e6a..8c25255 100644
--- a/tumblerd/tumbler-registry.c
+++ b/tumblerd/tumbler-registry.c
@@ -32,16 +32,18 @@
-static void tumbler_registry_finalize (GObject *object);
-static void tumbler_registry_remove_thumbnailer (const gchar *key,
- GList **list,
- TumblerThumbnailer *thumbnailer);
-static void tumbler_registry_list_free (gpointer data);
-static GList *tumbler_registry_get_thumbnailers_internal (TumblerRegistry *registry);
-static gint tumbler_registry_compare (TumblerThumbnailer *a,
- TumblerThumbnailer *b);
-TumblerThumbnailer *tumbler_registry_lookup (TumblerRegistry *registry,
- const gchar *hash_key);
+static void tumbler_registry_finalize (GObject *object);
+static void tumbler_registry_remove_thumbnailer (const gchar *key,
+ GList **list,
+ TumblerThumbnailer *thumbnailer);
+static void tumbler_registry_list_free (gpointer data);
+static GList *tumbler_registry_get_thumbnailers_internal (TumblerRegistry *registry);
+static gint tumbler_registry_compare (TumblerThumbnailer *a,
+ TumblerThumbnailer *b);
+static TumblerThumbnailer *tumbler_registry_lookup (TumblerRegistry *registry,
+ const gchar *hash_key);
+static void tumbler_registry_thumbnailer_supported_changed (TumblerRegistry *registry,
+ TumblerThumbnailer *thumbnailer);
@@ -277,7 +279,7 @@ tumbler_registry_get_thumbnailers_internal (TumblerRegistry *registry)
-TumblerThumbnailer *
+static TumblerThumbnailer *
tumbler_registry_lookup (TumblerRegistry *registry,
const gchar *hash_key)
{
@@ -307,6 +309,22 @@ tumbler_registry_lookup (TumblerRegistry *registry,
+static void
+tumbler_registry_thumbnailer_supported_changed (TumblerRegistry *registry,
+ TumblerThumbnailer *thumbnailer)
+{
+ g_return_if_fail (TUMBLER_IS_REGISTRY (registry));
+ g_return_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer));
+
+ g_debug ("supported of %s changed\n", G_OBJECT_TYPE_NAME (thumbnailer));
+
+ tumbler_registry_remove (registry, thumbnailer);
+ tumbler_registry_add (registry, thumbnailer);
+ tumbler_registry_update_supported (registry);
+}
+
+
+
TumblerRegistry *
tumbler_registry_new (void)
{
@@ -375,6 +393,9 @@ tumbler_registry_add (TumblerRegistry *registry,
/* connect to the unregister signal of the thumbnailer */
g_signal_connect_swapped (thumbnailer, "unregister",
G_CALLBACK (tumbler_registry_remove), registry);
+ g_signal_connect_swapped (thumbnailer, "supported-changed",
+ G_CALLBACK (tumbler_registry_thumbnailer_supported_changed),
+ registry);
g_strfreev (hash_keys);