[nautilus-actions] Let the I/O provider set its specific data into NAObjectItem
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Let the I/O provider set its specific data into NAObjectItem
- Date: Tue, 22 Dec 2009 19:40:33 +0000 (UTC)
commit 4291200a8c64875d820d67fb945810b43d32c83f
Author: Pierre Wieser <pwieser trychlos org>
Date: Tue Dec 22 20:34:20 2009 +0100
Let the I/O provider set its specific data into NAObjectItem
ChangeLog | 14 +++++
TODO | 2 -
nautilus-actions/api/na-object-api.h | 2 +
nautilus-actions/private/na-object-item-fn.h | 2 +
nautilus-actions/private/na-object-item-priv.h | 1 +
nautilus-actions/private/na-object-item.c | 72 ++++++++++++++++++++++--
6 files changed, 85 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8f32009..0880fb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-12-22 Pierre Wieser <pwieser trychlos org>
+
+ Let the I/O provider set specific data into NAObjectItem.
+
+ * nautilus-actions/api/na-object-api.h
+ (na_object_get_provider_data, na_object_set_provider_data):
+ New aliases.
+
+ * nautilus-actions/private/na-object-item-fn.h:
+ * nautilus-actions/private/na-object-item-priv.h:
+ * nautilus-actions/private/na-object-item.c
+ (na_object_item_get_provider_data, na_object_item_set_provider_data):
+ New functions.
+
2009-12-21 Pierre Wieser <pwieser trychlos org>
* nautilus-actions/io-provider-desktop/nadp-xdg-data-dirs.c
diff --git a/TODO b/TODO
index fd507b9..39b950e 100644
--- a/TODO
+++ b/TODO
@@ -108,5 +108,3 @@
> remove in n-a-c-t
> remove in n-a-n
> remove in action class
-
-- desktop file is not deleted when the item is
diff --git a/nautilus-actions/api/na-object-api.h b/nautilus-actions/api/na-object-api.h
index 12d2c2e..b029d2f 100644
--- a/nautilus-actions/api/na-object-api.h
+++ b/nautilus-actions/api/na-object-api.h
@@ -93,6 +93,7 @@ G_BEGIN_DECLS
#define na_object_get_tooltip( object ) na_object_item_get_tooltip( NA_OBJECT_ITEM( object ))
#define na_object_get_icon( object ) na_object_item_get_icon( NA_OBJECT_ITEM( object ))
#define na_object_get_provider( object ) na_object_item_get_provider( NA_OBJECT_ITEM( object ))
+#define na_object_get_provider_data( object ) na_object_item_get_provider_data( NA_OBJECT_ITEM( object ))
#define na_object_is_enabled( object ) na_object_item_is_enabled( NA_OBJECT_ITEM( object ))
#define na_object_is_readonly( object ) na_object_item_is_readonly( NA_OBJECT_ITEM( object ))
#define na_object_get_item( object, id ) na_object_item_get_item( NA_OBJECT_ITEM( object ), ( id ))
@@ -102,6 +103,7 @@ G_BEGIN_DECLS
#define na_object_set_tooltip( object, tooltip ) na_object_item_set_tooltip( NA_OBJECT_ITEM( object ), ( tooltip ))
#define na_object_set_icon( object, icon ) na_object_item_set_icon( NA_OBJECT_ITEM( object ), ( icon ))
#define na_object_set_provider( object, provider ) na_object_item_set_provider( NA_OBJECT_ITEM( object ), ( provider ))
+#define na_object_set_provider_data( object, data ) na_object_item_set_provider_data( NA_OBJECT_ITEM( object ),( const void * )( data ))
#define na_object_set_enabled( object, enabled ) na_object_item_set_enabled( NA_OBJECT_ITEM( object ), ( enabled ))
#define na_object_set_readonly( object, readonly ) na_object_item_set_readonly( NA_OBJECT_ITEM( object ), ( readonly ))
#define na_object_set_items_list( object, list ) na_object_item_set_items_list( NA_OBJECT_ITEM( object ), ( list ))
diff --git a/nautilus-actions/private/na-object-item-fn.h b/nautilus-actions/private/na-object-item-fn.h
index 144c120..d7175a6 100644
--- a/nautilus-actions/private/na-object-item-fn.h
+++ b/nautilus-actions/private/na-object-item-fn.h
@@ -57,6 +57,7 @@ gchar *na_object_item_get_icon( const NAObjectItem *item );
GdkPixbuf *na_object_item_get_pixbuf( const NAObjectItem *object );
gint na_object_item_get_position( const NAObjectItem *object, const NAObject *child );
NAIIOProvider *na_object_item_get_provider( const NAObjectItem *item );
+void *na_object_item_get_provider_data( const NAObjectItem *item );
gboolean na_object_item_is_enabled( const NAObjectItem *item );
gboolean na_object_item_is_readonly( const NAObjectItem *action );
NAObject *na_object_item_get_item( const NAObjectItem *item, const gchar *id );
@@ -68,6 +69,7 @@ void na_object_item_count_items( GList *items, gint *menus, gint *acti
void na_object_item_set_tooltip( NAObjectItem *item, const gchar *tooltip );
void na_object_item_set_icon( NAObjectItem *item, const gchar *icon_name );
void na_object_item_set_provider( NAObjectItem *item, const NAIIOProvider *provider );
+void na_object_item_set_provider_data( NAObjectItem *item, const void *provider_data );
void na_object_item_set_enabled( NAObjectItem *item, gboolean enabled );
void na_object_item_set_readonly( NAObjectItem *action, gboolean readonly );
void na_object_item_set_items_list( NAObjectItem *item, GList *items );
diff --git a/nautilus-actions/private/na-object-item-priv.h b/nautilus-actions/private/na-object-item-priv.h
index 3ef1277..123981e 100644
--- a/nautilus-actions/private/na-object-item-priv.h
+++ b/nautilus-actions/private/na-object-item-priv.h
@@ -64,6 +64,7 @@ struct NAObjectItemPrivate {
* required to be able to edit/delete the item
*/
NAIIOProvider *provider;
+ void *provider_data;
};
G_END_DECLS
diff --git a/nautilus-actions/private/na-object-item.c b/nautilus-actions/private/na-object-item.c
index 9797d32..d118ba5 100644
--- a/nautilus-actions/private/na-object-item.c
+++ b/nautilus-actions/private/na-object-item.c
@@ -57,6 +57,7 @@ enum {
NAOBJECT_ITEM_PROP_ENABLED_ID,
NAOBJECT_ITEM_PROP_READONLY_ID,
NAOBJECT_ITEM_PROP_PROVIDER_ID,
+ NAOBJECT_ITEM_PROP_PROVIDER_DATA_ID,
NAOBJECT_ITEM_PROP_ITEMS_ID,
};
@@ -65,6 +66,7 @@ enum {
#define NAOBJECT_ITEM_PROP_ENABLED "na-object-item-enabled"
#define NAOBJECT_ITEM_PROP_READONLY "na-object-item-read-only"
#define NAOBJECT_ITEM_PROP_PROVIDER "na-object-item-provider"
+#define NAOBJECT_ITEM_PROP_PROVIDER_DATA "na-object-item-provider-data"
#define NAOBJECT_ITEM_PROP_ITEMS "na-object-item-items"
static NAObjectIdClass *st_parent_class = NULL;
@@ -175,6 +177,13 @@ class_init( NAObjectItemClass *klass )
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
g_object_class_install_property( object_class, NAOBJECT_ITEM_PROP_PROVIDER_ID, spec );
+ spec = g_param_spec_pointer(
+ NAOBJECT_ITEM_PROP_PROVIDER_DATA,
+ "Provider data",
+ "Data specific to the provider",
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
+ g_object_class_install_property( object_class, NAOBJECT_ITEM_PROP_PROVIDER_DATA_ID, spec );
+
klass->private = g_new0( NAObjectItemClassPrivate, 1 );
naobject_class = NA_OBJECT_CLASS( klass );
@@ -212,6 +221,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private->enabled = TRUE;
self->private->read_only = FALSE;
self->private->provider = NULL;
+ self->private->provider_data = NULL;
}
static void
@@ -245,6 +255,10 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
g_value_set_pointer( value, self->private->provider );
break;
+ case NAOBJECT_ITEM_PROP_PROVIDER_DATA_ID:
+ g_value_set_pointer( value, self->private->provider_data );
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
break;
@@ -285,6 +299,10 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
self->private->provider = g_value_get_pointer( value );
break;
+ case NAOBJECT_ITEM_PROP_PROVIDER_DATA_ID:
+ self->private->provider_data = g_value_get_pointer( value );
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
break;
@@ -483,6 +501,26 @@ na_object_item_get_provider( const NAObjectItem *item )
}
/**
+ * na_object_item_get_provider_data:
+ * @item: the #NAObjectItem object to be requested.
+ *
+ * Returns: the provider's specific data.
+ */
+void *
+na_object_item_get_provider_data( const NAObjectItem *item )
+{
+ void *provider_data = NULL;
+
+ g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), NULL );
+
+ if( !item->private->dispose_has_run ){
+ g_object_get( G_OBJECT( item ), NAOBJECT_ITEM_PROP_PROVIDER_DATA, &provider_data, NULL );
+ }
+
+ return( provider_data );
+}
+
+/**
* na_object_item_is_enabled:
* @item: the #NAObjectItem object to be requested.
*
@@ -710,6 +748,23 @@ na_object_item_set_provider( NAObjectItem *item, const NAIIOProvider *provider )
}
/**
+ * na_object_item_set_provider_data:
+ * @item: the #NAObjectItem object to be updated.
+ * @provider_data: a pointer to provider's specific data.
+ *
+ * Sets the I/O provider's data for this #NAObjectItem.
+ */
+void
+na_object_item_set_provider_data( NAObjectItem *item, const void *provider_data )
+{
+ g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
+
+ if( !item->private->dispose_has_run ){
+ g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_PROVIDER_DATA, provider_data, NULL );
+ }
+}
+
+/**
* na_object_item_set_enabled:
* @item: the #NAObjectItem object to be updated.
* @enabled: the indicator to be set.
@@ -981,11 +1036,12 @@ object_dump( const NAObject *item )
if( !NA_OBJECT_ITEM( item )->private->dispose_has_run ){
- g_debug( "%s: tooltip='%s'", thisfn, NA_OBJECT_ITEM( item )->private->tooltip );
- g_debug( "%s: icon='%s'", thisfn, NA_OBJECT_ITEM( item )->private->icon );
- g_debug( "%s: enabled='%s'", thisfn, NA_OBJECT_ITEM( item )->private->enabled ? "True" : "False" );
- g_debug( "%s: read-only='%s'", thisfn, NA_OBJECT_ITEM( item )->private->read_only ? "True" : "False" );
- g_debug( "%s: provider=%p", thisfn, ( void * ) NA_OBJECT_ITEM( item )->private->provider );
+ g_debug( "%s: tooltip='%s'", thisfn, NA_OBJECT_ITEM( item )->private->tooltip );
+ g_debug( "%s: icon='%s'", thisfn, NA_OBJECT_ITEM( item )->private->icon );
+ g_debug( "%s: enabled='%s'", thisfn, NA_OBJECT_ITEM( item )->private->enabled ? "True" : "False" );
+ g_debug( "%s: read-only='%s'", thisfn, NA_OBJECT_ITEM( item )->private->read_only ? "True" : "False" );
+ g_debug( "%s: provider=%p", thisfn, ( void * ) NA_OBJECT_ITEM( item )->private->provider );
+ g_debug( "%s: provider_data=%p", thisfn, ( void * ) NA_OBJECT_ITEM( item )->private->provider_data );
/* dump subitems */
g_debug( "%s: %d subitem(s) at %p",
@@ -1007,6 +1063,7 @@ object_copy( NAObject *target, const NAObject *source )
gboolean enabled;
gboolean readonly;
gpointer provider;
+ gpointer provider_data;
GList *subitems, *it;
g_return_if_fail( NA_IS_OBJECT_ITEM( target ));
@@ -1021,6 +1078,7 @@ object_copy( NAObject *target, const NAObject *source )
NAOBJECT_ITEM_PROP_ENABLED, &enabled,
NAOBJECT_ITEM_PROP_READONLY, &readonly,
NAOBJECT_ITEM_PROP_PROVIDER, &provider,
+ NAOBJECT_ITEM_PROP_PROVIDER_DATA, &provider_data,
NULL );
g_object_set( G_OBJECT( target ),
@@ -1029,6 +1087,7 @@ object_copy( NAObject *target, const NAObject *source )
NAOBJECT_ITEM_PROP_ENABLED, enabled,
NAOBJECT_ITEM_PROP_READONLY, readonly,
NAOBJECT_ITEM_PROP_PROVIDER, provider,
+ NAOBJECT_ITEM_PROP_PROVIDER_DATA, provider_data,
NULL );
g_free( tooltip );
@@ -1048,7 +1107,8 @@ object_copy( NAObject *target, const NAObject *source )
* @b: the object which has been initially duplicated from @a, and is
* being checked for modification status.
*
- * note 1: The provider is not considered as relevant here
+ * note 1: The provider is not considered as relevant here; neither is
+ * the provider_data
*
* note 2: as a particular case, this function is not recursive
* because the equality test will stop as soon as it fails, and we so
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]