[nautilus-actions] No more define loadable set at NAPivot allocation
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] No more define loadable set at NAPivot allocation
- Date: Fri, 26 Feb 2010 00:42:37 +0000 (UTC)
commit cb134830f5f4655968127d19571a4f8368695d16
Author: Pierre Wieser <pwieser trychlos org>
Date: Sun Feb 21 21:22:25 2010 +0100
No more define loadable set at NAPivot allocation
ChangeLog | 15 +++++++
TODO | 11 +++++
src/core/na-pivot.c | 80 +++++++++++++++++++-----------------
src/core/na-pivot.h | 27 +++++++-----
src/core/na-updater.c | 6 +--
src/core/na-updater.h | 2 +-
src/nact/nact-application.c | 4 +-
src/nact/nact-main-window.c | 2 +-
src/plugin-menu/nautilus-actions.c | 8 +---
src/test/test-reader.c | 2 +-
src/utils/nautilus-actions-new.c | 2 +-
src/utils/nautilus-actions-run.c | 4 +-
12 files changed, 95 insertions(+), 68 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 93e11fe..4aeb013 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2009-02-21 Pierre Wieser <pwieser trychlos org>
+
+ * src/core/na-pivot.c:
+ * src/core/na-pivot.h:
+ * src/core/na-updater.c:
+ * src/core/na-updater.h:
+ * src/nact/nact-application.c:
+ * src/nact/nact-main-window.c:
+ * src/plugin-menu/nautilus-actions.c:
+ * src/test/test-reader.c:
+ * src/utils/nautilus-actions-new.c:
+ * src/utils/nautilus-actions-run.c:
+ No more define the loadable set at NAPivot construction time,
+ but deffer this when actually loading items.
+
2009-02-20 Pierre Wieser <pwieser trychlos org>
* po/POTFILES.in:
diff --git a/TODO b/TODO
index d96eb62..ffff0ac 100644
--- a/TODO
+++ b/TODO
@@ -160,3 +160,14 @@
depending of available formats provided by NAIExporter modules
- one should be able to import/export menus
+
+- icon: is defined as localestring in desktop entry spec
+ but path is defined as string in this same spec
+ and icon may be a path -> so what to do with this ?
+
+- NAIDataFactory -> NAIObjectFactory
+ NADataFactory -> NAObjectFactory
+ NADataElement -> NADataFactory
+ NadfIdType -> NADataDef
+ na-idata-factory-enum -> na-idata-factory-def + merge na-idata-factory-str
+ NADataDef: id is suppressed, use name instead
diff --git a/src/core/na-pivot.c b/src/core/na-pivot.c
index ae3bc1f..971a4b5 100644
--- a/src/core/na-pivot.c
+++ b/src/core/na-pivot.c
@@ -52,44 +52,44 @@ struct NAPivotClassPrivate {
/* private instance data
*/
struct NAPivotPrivate {
- gboolean dispose_has_run;
+ gboolean dispose_has_run;
- NAPivotLoadableSet loadable_set;
+ guint loadable_set;
/* dynamically loaded modules (extension plugins)
*/
- GList *modules;
+ GList *modules;
/* list of instances to be notified of configuration updates
* these are called 'consumers' of NAPivot
*/
- GList *consumers;
+ GList *consumers;
/* configuration tree of actions and menus
*/
- GList *tree;
+ GList *tree;
/* whether to automatically reload the whole configuration tree
* when a modification is detected in one of the underlying I/O
* storage subsystems
* defaults to FALSE
*/
- gboolean automatic_reload;
- GTimeVal last_event;
- guint event_source_id;
+ gboolean automatic_reload;
+ GTimeVal last_event;
+ guint event_source_id;
/* list of monitoring objects on runtime preferences
*/
- GList *monitors;
+ GList *monitors;
};
/* NAPivot properties
*/
enum {
- NAPIVOT_PROP_LOADABLE_SET_ID = 1,
- NAPIVOT_PROP_TREE_ID,
+ NAPIVOT_PROP_TREE_ID = 1,
};
+
static GObjectClass *st_parent_class = NULL;
static gint st_timeout_msec = 100;
static gint st_timeout_usec = 100000;
@@ -184,21 +184,14 @@ class_init( NAPivotClass *klass )
object_class->dispose = instance_dispose;
object_class->finalize = instance_finalize;
- klass->private = g_new0( NAPivotClassPrivate, 1 );
-
- spec = g_param_spec_uint(
- NAPIVOT_PROP_LOADABLE_SET,
- "Loadable population set",
- "Nature of population to be loaded", 0, UINT_MAX, 0,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, NAPIVOT_PROP_LOADABLE_SET_ID, spec );
-
spec = g_param_spec_pointer(
NAPIVOT_PROP_TREE,
"Items tree",
"Hierarchical tree of items",
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
g_object_class_install_property( object_class, NAPIVOT_PROP_TREE_ID, spec );
+
+ klass->private = g_new0( NAPivotClassPrivate, 1 );
}
static void
@@ -215,7 +208,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private = g_new0( NAPivotPrivate, 1 );
self->private->dispose_has_run = FALSE;
- self->private->loadable_set = 0;
+ self->private->loadable_set = PIVOT_LOAD_NONE;
self->private->modules = NULL;
self->private->consumers = NULL;
self->private->tree = NULL;
@@ -263,10 +256,6 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
if( !self->private->dispose_has_run ){
switch( property_id ){
- case NAPIVOT_PROP_LOADABLE_SET_ID:
- g_value_set_uint( value, self->private->loadable_set );
- break;
-
case NAPIVOT_PROP_TREE_ID:
g_value_set_pointer( value, self->private->tree );
break;
@@ -289,10 +278,6 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
if( !self->private->dispose_has_run ){
switch( property_id ){
- case NAPIVOT_PROP_LOADABLE_SET_ID:
- self->private->loadable_set = g_value_get_uint( value );
- break;
-
case NAPIVOT_PROP_TREE_ID:
self->private->tree = g_value_get_pointer( value );
break;
@@ -373,21 +358,16 @@ iprefs_iface_init( NAIPrefsInterface *iface )
* na_pivot_new:
*
* Returns: a newly allocated #NAPivot object.
- *
- * The returned #NAPivot is initialized with the current list of
- * #NAObjectItem-derived object.
*/
NAPivot *
-na_pivot_new( NAPivotLoadableSet loadable )
+na_pivot_new( void )
{
static const gchar *thisfn = "na_pivot_new";
NAPivot *pivot;
g_debug( "%s", thisfn );
- pivot = g_object_new( NA_PIVOT_TYPE,
- NAPIVOT_PROP_LOADABLE_SET, GUINT_TO_POINTER( loadable ),
- NULL );
+ pivot = g_object_new( NA_PIVOT_TYPE, NULL );
return( pivot );
}
@@ -551,11 +531,35 @@ na_pivot_get_items( const NAPivot *pivot )
/**
* na_pivot_load_items:
* @pivot: this #NAPivot instance.
+ * @loadable: the loadable set of items population.
*
* Loads the hierarchical list of items from I/O providers.
*/
void
-na_pivot_load_items( NAPivot *pivot )
+na_pivot_load_items( NAPivot *pivot, guint loadable )
+{
+ static const gchar *thisfn = "na_pivot_load_items";
+
+ g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
+ g_return_if_fail( NA_IS_PIVOT( pivot ));
+
+ if( !pivot->private->dispose_has_run ){
+
+ pivot->private->loadable_set = loadable;
+
+ na_pivot_reload_items( pivot );
+ }
+}
+
+/**
+ * na_pivot_reload_items:
+ * @pivot: this #NAPivot instance.
+ *
+ * Reloads the hierarchical list of items from I/O providers, using
+ * the same loadable set that the previous time.
+ */
+void
+na_pivot_reload_items( NAPivot *pivot )
{
static const gchar *thisfn = "na_pivot_load_items";
GSList *messages, *im;
@@ -637,7 +641,7 @@ on_item_changed_timeout( NAPivot *pivot )
}
if( pivot->private->automatic_reload ){
- na_pivot_load_items( pivot );
+ na_pivot_reload_items( pivot );
}
for( ic = pivot->private->consumers ; ic ; ic = ic->next ){
diff --git a/src/core/na-pivot.h b/src/core/na-pivot.h
index a7dbccb..25c3c57 100644
--- a/src/core/na-pivot.h
+++ b/src/core/na-pivot.h
@@ -38,8 +38,12 @@
*
* A consuming program should allocate one new NAPivot object in its
* startup phase. The class takes care of declaring the I/O interfaces,
- * while registering the known providers. The object will then load
- * itself the existing list of actions.
+ * while registering the known providers.
+ * NAPivot *pivot = na_pivot_new();
+ *
+ * With this newly allocated #NAPivot object, the consuming program
+ * is then able to ask for loading the items.
+ * na_pivot_load_items( pivot, PIVOT_LOADABLE_SET );
*
* Notification system.
*
@@ -104,24 +108,22 @@ typedef struct {
GType na_pivot_get_type( void );
+/* properties
+ */
+#define NAPIVOT_PROP_TREE "na-pivot-prop-tree"
+
/* Loadable population
* NACT management user interface defaults to PIVOT_LOAD_ALL
* N-A plugin set the loadable population to !PIVOT_LOAD_DISABLED & !PIVOT_LOAD_INVALID
*/
-typedef enum {
+enum {
PIVOT_LOAD_NONE = 0,
PIVOT_LOAD_DISABLED = 1 << 0,
PIVOT_LOAD_INVALID = 1 << 1,
PIVOT_LOAD_ALL = 0xff
-}
- NAPivotLoadableSet;
-
-/* properties
- */
-#define NAPIVOT_PROP_LOADABLE_SET "na-pivot-prop-loadable-set"
-#define NAPIVOT_PROP_TREE "na-pivot-prop-tree"
+};
-NAPivot *na_pivot_new( NAPivotLoadableSet loadable );
+NAPivot *na_pivot_new( void );
void na_pivot_dump( const NAPivot *pivot );
/* providers management of any NAIxxxxProvider interface
@@ -133,7 +135,8 @@ void na_pivot_free_providers( GList *providers );
*/
NAObjectItem *na_pivot_get_item( const NAPivot *pivot, const gchar *id );
GList *na_pivot_get_items( const NAPivot *pivot );
-void na_pivot_load_items( NAPivot *pivot );
+void na_pivot_load_items( NAPivot *pivot, guint loadable );
+void na_pivot_reload_items( NAPivot *pivot );
void na_pivot_item_changed_handler( NAIIOProvider *provider, const gchar *id, NAPivot *pivot );
diff --git a/src/core/na-updater.c b/src/core/na-updater.c
index 26c91d6..17ee530 100644
--- a/src/core/na-updater.c
+++ b/src/core/na-updater.c
@@ -173,16 +173,14 @@ instance_finalize( GObject *object )
* Returns: a newly allocated #NAUpdater object.
*/
NAUpdater *
-na_updater_new( NAPivotLoadableSet loadable )
+na_updater_new( void )
{
static const gchar *thisfn = "na_updater_new";
NAUpdater *updater;
g_debug( "%s", thisfn );
- updater = g_object_new( NA_UPDATER_TYPE,
- NAPIVOT_PROP_LOADABLE_SET, GUINT_TO_POINTER( loadable ),
- NULL );
+ updater = g_object_new( NA_UPDATER_TYPE, NULL );
return( updater );
}
diff --git a/src/core/na-updater.h b/src/core/na-updater.h
index 68a9452..096894a 100644
--- a/src/core/na-updater.h
+++ b/src/core/na-updater.h
@@ -69,7 +69,7 @@ typedef struct {
GType na_updater_get_type( void );
-NAUpdater *na_updater_new( NAPivotLoadableSet loadable );
+NAUpdater *na_updater_new( void );
/* update the tree in memory
*/
diff --git a/src/nact/nact-application.c b/src/nact/nact-application.c
index ad01189..c649040 100644
--- a/src/nact/nact-application.c
+++ b/src/nact/nact-application.c
@@ -392,8 +392,8 @@ appli_initialize_application( BaseApplication *application )
g_debug( "%s: application=%p", thisfn, ( void * ) application );
- NACT_APPLICATION( application )->private->updater = na_updater_new( PIVOT_LOAD_ALL );
- na_pivot_load_items( NA_PIVOT( NACT_APPLICATION( application )->private->updater ));
+ NACT_APPLICATION( application )->private->updater = na_updater_new();
+ na_pivot_load_items( NA_PIVOT( NACT_APPLICATION( application )->private->updater ), PIVOT_LOAD_ALL );
/* call parent class */
ok = BASE_APPLICATION_CLASS( st_parent_class )->initialize_application( application );
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 2433a92..8b944eb 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -1399,7 +1399,7 @@ reload( NactMainWindow *window )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
updater = nact_application_get_updater( application );
- na_pivot_load_items( NA_PIVOT( updater ));
+ na_pivot_reload_items( NA_PIVOT( updater ));
nact_iactions_list_fill( NACT_IACTIONS_LIST( window ), na_pivot_get_items( NA_PIVOT( updater )));
nact_iactions_list_bis_select_first_row( NACT_IACTIONS_LIST( window ));
diff --git a/src/plugin-menu/nautilus-actions.c b/src/plugin-menu/nautilus-actions.c
index cc5e29b..ddbc1ca 100644
--- a/src/plugin-menu/nautilus-actions.c
+++ b/src/plugin-menu/nautilus-actions.c
@@ -185,11 +185,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
self->private = g_new0( NautilusActionsPrivate, 1 );
self->private->dispose_has_run = FALSE;
-
- /* initialize NAPivot and load actions through NAIIOProvider interface
- * forwarding notification messages from NAPivot to NautilusActions
- */
- self->private->pivot = na_pivot_new( !PIVOT_LOAD_DISABLED & !PIVOT_LOAD_INVALID );
}
static void
@@ -207,9 +202,10 @@ instance_constructed( GObject *object )
if( !self->private->dispose_has_run ){
+ self->private->pivot = na_pivot_new();
na_pivot_register_consumer( self->private->pivot, NA_IPIVOT_CONSUMER( self ));
na_pivot_set_automatic_reload( self->private->pivot, TRUE );
- na_pivot_load_items( self->private->pivot );
+ na_pivot_load_items( self->private->pivot, !PIVOT_LOAD_DISABLED & !PIVOT_LOAD_INVALID );
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->constructed ){
diff --git a/src/test/test-reader.c b/src/test/test-reader.c
index 8b48310..381bf5e 100755
--- a/src/test/test-reader.c
+++ b/src/test/test-reader.c
@@ -38,7 +38,7 @@ main( int argc, char **argv )
{
g_type_init();
- NAPivot *pivot = na_pivot_new( PIVOT_LOAD_NONE );
+ NAPivot *pivot = na_pivot_new();
GSList *msg = NULL;
gchar *uri = "file:///net/pierre/eclipse/nautilus-actions/exports/config_0af5a47e-96d9-441c-a3b8-d1185ced0351.schemas";
NAObjectItem *item = na_importer_import( pivot, uri, IMPORTER_MODE_ASK, NULL, NULL, &msg );
diff --git a/src/utils/nautilus-actions-new.c b/src/utils/nautilus-actions-new.c
index fb04f02..f81212f 100644
--- a/src/utils/nautilus-actions-new.c
+++ b/src/utils/nautilus-actions-new.c
@@ -376,7 +376,7 @@ write_to_gconf( NAObjectAction *action, GSList **msg )
NAUpdater *updater;
guint ret;
- updater = na_updater_new( PIVOT_LOAD_NONE );
+ updater = na_updater_new();
ret = na_updater_write_item( updater, NA_OBJECT_ITEM( action ), msg );
diff --git a/src/utils/nautilus-actions-run.c b/src/utils/nautilus-actions-run.c
index 1731021..45d86f7 100644
--- a/src/utils/nautilus-actions-run.c
+++ b/src/utils/nautilus-actions-run.c
@@ -213,8 +213,8 @@ get_action( const gchar *id )
action = NULL;
- pivot = na_pivot_new( !PIVOT_LOAD_DISABLED & !PIVOT_LOAD_INVALID );
- na_pivot_load_items( pivot );
+ pivot = na_pivot_new();
+ na_pivot_load_items( pivot, !PIVOT_LOAD_DISABLED & !PIVOT_LOAD_INVALID );
action = ( NAObjectAction * ) na_pivot_get_item( pivot, id );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]