[nautilus-actions] Display I/O provider as an item property
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Display I/O provider as an item property
- Date: Tue, 1 Dec 2009 23:36:35 +0000 (UTC)
commit ea62399352a84201eb4483df5d3bb436ea7b2e34
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Dec 2 00:36:56 2009 +0100
Display I/O provider as an item property
ChangeLog | 18 +++++++
TODO | 6 +-
nautilus-actions/nact/nact-iaction-tab.c | 22 +++++++++
.../nact/nautilus-actions-config-tool.ui | 42 +++++++++++++----
nautilus-actions/runtime/na-io-provider.c | 17 +++++++
nautilus-actions/runtime/na-io-provider.h | 6 ++-
nautilus-actions/runtime/na-module.c | 49 +++++++++++++++++++-
nautilus-actions/runtime/na-module.h | 2 +
nautilus-actions/runtime/na-pivot.c | 18 +++++++
nautilus-actions/runtime/na-pivot.h | 2 +
10 files changed, 167 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0e987f4..b3aae59 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2009-12-01 Pierre Wieser <pwieser trychlos org>
+ * nautilus-actions/nact/nact-iaction-tab.c
+ (on_tab_updatable_selection_changed): Display I/O provider name.
+
+ * nautilus-actions/nact/nautilus-actions-config-tool.ui:
+ Display I/O provider name.
+
+ * nautilus-actions/runtime/na-io-provider.c:
+ * nautilus-actions/runtime/na-io-provider.h
+ (na_io_provider_get_name): New function.
+
+ * nautilus-actions/runtime/na-module.c:
+ * nautilus-actions/runtime/na-module.h
+ (na_module_get_name_for_object): New function.
+
+ * nautilus-actions/runtime/na-pivot.c:
+ * nautilus-actions/runtime/na-pivot.h
+ (na_pivot_get_module_name): New function.
+
* nautilus-actions/io-provider-desktop/nadp-write.c
(nadp_iio_provider_is_writable): Do not handle menus yet.
diff --git a/TODO b/TODO
index 3dd132c..5036e61 100644
--- a/TODO
+++ b/TODO
@@ -91,12 +91,12 @@
- have a preference to record order of IO Providers
-- nact: add provider orig to displayed item properties
-
-- may we have a read-only menu ?
+- do we may have a read-only menu ?
this implies dnd of an action inside of the menu would be forbidden
id. for reordering if subitems
- nact: if item is read-only, all fields should be disabled
- nact: new action assistant
+
+- check that having an id which is not a UUID is supported
diff --git a/nautilus-actions/nact/nact-iaction-tab.c b/nautilus-actions/nact/nact-iaction-tab.c
index 966d399..73c8f0d 100644
--- a/nautilus-actions/nact/nact-iaction-tab.c
+++ b/nautilus-actions/nact/nact-iaction-tab.c
@@ -37,6 +37,8 @@
#include <api/na-object-api.h>
+#include <runtime/na-io-provider.h>
+
#include "base-window.h"
#include "nact-application.h"
#include "nact-main-statusbar.h"
@@ -359,6 +361,8 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
{
static const gchar *thisfn = "nact_iaction_tab_on_tab_updatable_selection_changed";
NAObjectItem *item;
+ NAPivot *pivot;
+ NactApplication *application;
gboolean enable_tab;
gboolean target_selection, target_background, target_toolbar;
gboolean enable_label;
@@ -368,6 +372,7 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
GtkButton *enabled_button;
gboolean enabled_item;
GtkToggleButton *toggle;
+ NAIIOProvider *provider;
g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
g_return_if_fail( BASE_IS_WINDOW( instance ));
@@ -375,6 +380,9 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
if( st_initialized && !st_finalized ){
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( instance )));
+ pivot = nact_application_get_pivot( application );
+
g_object_get(
G_OBJECT( instance ),
TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
@@ -455,6 +463,20 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
gtk_label_set_text( GTK_LABEL( label_widget ), label );
g_free( label );
+ label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionItemProvider" );
+ label = NULL;
+ if( item ){
+ provider = na_object_get_provider( item );
+ if( provider ){
+ label = na_io_provider_get_name( pivot, provider );
+ }
+ }
+ if( !label ){
+ label = g_strdup( "" );
+ }
+ gtk_label_set_text( GTK_LABEL( label_widget ), label );
+ g_free( label );
+
/* TODO: manage read-only flag */
}
}
diff --git a/nautilus-actions/nact/nautilus-actions-config-tool.ui b/nautilus-actions/nact/nautilus-actions-config-tool.ui
index 0eb0d19..dafd747 100644
--- a/nautilus-actions/nact/nautilus-actions-config-tool.ui
+++ b/nautilus-actions/nact/nautilus-actions-config-tool.ui
@@ -417,7 +417,7 @@
<child>
<object class="GtkTable" id="table4">
<property name="visible">True</property>
- <property name="n_rows">3</property>
+ <property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">5</property>
<child>
@@ -489,6 +489,30 @@
</packing>
</child>
<child>
+ <object class="GtkLabel" id="label19">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">I/O provider :</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="ActionItemProvider">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
<placeholder/>
</child>
</object>
@@ -1300,8 +1324,8 @@ Defining several profiles lets you have several commands, each applying with a d
<object class="GtkFileChooserWidget" id="ImportFileChooser">
<property name="visible">True</property>
<property name="local_only">False</property>
- <property name="use_preview_label">False</property>
<property name="preview_widget_active">False</property>
+ <property name="use_preview_label">False</property>
<property name="select_multiple">True</property>
</object>
<packing>
@@ -2888,24 +2912,24 @@ Be warned: this mode may be dangerous. You will not be prompted another time.</p
</object>
<object class="GtkSizeGroup" id="CommandLabelSizeGroup">
<widgets>
- <widget name="CommandParametersLabel"/>
- <widget name="CommandPathLabel"/>
<widget name="ProfileLabelLabel"/>
+ <widget name="CommandPathLabel"/>
+ <widget name="CommandParametersLabel"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="CommandButtonSizeGroup">
<widgets>
- <widget name="CommandLegendButton"/>
<widget name="CommandPathButton"/>
+ <widget name="CommandLegendButton"/>
</widgets>
</object>
<object class="GtkSizeGroup" id="ActionLabelSizeGroup">
<widgets>
- <widget name="ActionIconLabel"/>
- <widget name="ActionTooltipLabel"/>
- <widget name="ActionIdLabel"/>
- <widget name="ActionMenuLabelLabel"/>
<widget name="ActionIconLabelLabel"/>
+ <widget name="ActionMenuLabelLabel"/>
+ <widget name="ActionIdLabel"/>
+ <widget name="ActionTooltipLabel"/>
+ <widget name="ActionIconLabel"/>
</widgets>
</object>
</interface>
diff --git a/nautilus-actions/runtime/na-io-provider.c b/nautilus-actions/runtime/na-io-provider.c
index 1faa093..5c38075 100644
--- a/nautilus-actions/runtime/na-io-provider.c
+++ b/nautilus-actions/runtime/na-io-provider.c
@@ -75,6 +75,23 @@ na_io_provider_register_callbacks( const NAPivot *pivot )
}
/**
+ * na_io_provider_get_name:
+ * @provider: the #NAIIOProvider whose name is to be returned.
+ *
+ * Returns: a displayble name for the provider, as a newly allocated
+ * string which should be g_free() by the caller.
+ */
+gchar *
+na_io_provider_get_name( const NAPivot *pivot, const NAIIOProvider *provider )
+{
+ gchar *name;
+
+ name = na_pivot_get_module_name( pivot, G_OBJECT( provider ));
+
+ return( name );
+}
+
+/**
* na_io_provider_read_items:
* @pivot: the #NAPivot object which owns the list of registered I/O
* storage providers.
diff --git a/nautilus-actions/runtime/na-io-provider.h b/nautilus-actions/runtime/na-io-provider.h
index 196504c..a184caf 100644
--- a/nautilus-actions/runtime/na-io-provider.h
+++ b/nautilus-actions/runtime/na-io-provider.h
@@ -46,8 +46,10 @@ G_BEGIN_DECLS
void na_io_provider_register_callbacks( const NAPivot *pivot );
-GList *na_io_provider_read_items ( const NAPivot *pivot, GSList **messages );
-guint na_io_provider_write_item ( const NAPivot *pivot, NAObjectItem *item, GSList **messages );
+gchar *na_io_provider_get_name( const NAPivot *pivot, const NAIIOProvider *provider );
+
+GList *na_io_provider_read_items( const NAPivot *pivot, GSList **messages );
+guint na_io_provider_write_item( const NAPivot *pivot, NAObjectItem *item, GSList **messages );
guint na_io_provider_delete_item( const NAPivot *pivot, const NAObjectItem *item, GSList **messages );
G_END_DECLS
diff --git a/nautilus-actions/runtime/na-module.c b/nautilus-actions/runtime/na-module.c
index c7241f9..7e886e4 100644
--- a/nautilus-actions/runtime/na-module.c
+++ b/nautilus-actions/runtime/na-module.c
@@ -76,6 +76,8 @@ static void object_weak_notify( NAModule *module, GObject *object );
static void module_unload( GTypeModule *gmodule );
+static NAModule *find_module_for_object( GList *modules, GObject *object, GType *type );
+
GType
na_module_get_type( void )
{
@@ -363,6 +365,7 @@ add_module_type( NAModule *module, GType type )
GObject *object;
object = g_object_new( type, NULL );
+ g_object_set_data( object, "na-module-type", ( gpointer ) type );
g_object_weak_ref( object,
( GWeakNotify ) object_weak_notify,
@@ -456,7 +459,7 @@ na_module_free_extensions_list( GList *extensions )
* na_module_get_name:
* @module: the #NAModule instance corresponding to a dynamically
* loaded library.
- * @type: one the #GType this @module advertizes it implements.
+ * @type: one of the #GType this @module advertizes it implements.
*
* Returns: the name the #NAModule @module applies to itself for this
* @type, as a newly allocated string which should be g_free() by the
@@ -475,6 +478,50 @@ na_module_get_name( NAModule *module, GType type )
}
/**
+ * na_module_get_name_for_object:
+ * @modules: the list of dynamically loaded modules.
+ * @object: an object instantiated by one of these modules.
+ *
+ * Returns: the name of the #NAModule for this @object, as a newly
+ * allocated string which should be g_free() by the caller.
+ */
+gchar *
+na_module_get_name_for_object( GList *modules, GObject *object )
+{
+ gchar *name;
+ GType type;
+ NAModule *module;
+
+ name = NULL;
+ type = ( GType ) 0;
+ module = find_module_for_object( modules, object, &type );
+ if( type ){
+ name = na_module_get_name( module, type );
+ }
+
+ return( name );
+}
+
+static NAModule *
+find_module_for_object( GList *modules, GObject *object, GType *type )
+{
+ GList *im;
+ GList *io;
+ NAModule *module = NULL;
+
+ for( im = modules ; im && !module ; im = im->next ){
+ for( io = NA_MODULE( im->data )->private->objects ; io && !module ; io = io->next ){
+ if( io->data == object ){
+ module = NA_MODULE( im->data );
+ *type = ( GType ) g_object_get_data( object, "na-module-type" );
+ }
+ }
+ }
+
+ return( module );
+}
+
+/**
* na_module_release_modules:
* @modules: the list of loaded modules.
*
diff --git a/nautilus-actions/runtime/na-module.h b/nautilus-actions/runtime/na-module.h
index 24a71b0..de44513 100644
--- a/nautilus-actions/runtime/na-module.h
+++ b/nautilus-actions/runtime/na-module.h
@@ -80,6 +80,8 @@ GList *na_module_get_extensions_for_type( GList *modules, GType type );
void na_module_free_extensions_list ( GList *extensions );
gchar *na_module_get_name ( NAModule *module, GType type );
+gchar *na_module_get_name_for_object ( GList *modules, GObject *object );
+
void na_module_release_modules ( GList *modules );
G_END_DECLS
diff --git a/nautilus-actions/runtime/na-pivot.c b/nautilus-actions/runtime/na-pivot.c
index 32e646a..906dedb 100644
--- a/nautilus-actions/runtime/na-pivot.c
+++ b/nautilus-actions/runtime/na-pivot.c
@@ -395,6 +395,24 @@ na_pivot_item_changed_handler( NAIIOProvider *provider, const gchar *id, NAPivot
}
/**
+ * na_pivot_get_module_name:
+ * @pivot: this #NAPivot instance.
+ * @provider: a #GObject as instantiated by a #NAModule.
+ *
+ * Returns: the name of the #NAModule, as a newly allocated string which
+ * should be g_free() by the caller.
+ */
+gchar *
+na_pivot_get_module_name( const NAPivot *pivot, GObject *provider )
+{
+ gchar *name;
+
+ name = na_module_get_name_for_object( pivot->private->modules, provider );
+
+ return( name );
+}
+
+/**
* na_pivot_get_providers:
* @pivot: this #NAPivot instance.
* @type: the type of searched interface.
diff --git a/nautilus-actions/runtime/na-pivot.h b/nautilus-actions/runtime/na-pivot.h
index 81edfa4..44a42c0 100644
--- a/nautilus-actions/runtime/na-pivot.h
+++ b/nautilus-actions/runtime/na-pivot.h
@@ -115,6 +115,8 @@ void na_pivot_dump( const NAPivot *pivot );
void na_pivot_item_changed_handler( NAIIOProvider *provider, const gchar *id, NAPivot *pivot );
+gchar *na_pivot_get_module_name( const NAPivot *pivot, GObject *provider );
+
GList *na_pivot_get_providers( const NAPivot *pivot, GType type );
GObject *na_pivot_get_provider( const NAPivot *pivot, GType type );
void na_pivot_release_provider( const GObject *provider );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]