[nautilus-actions] Fix load of the hierarchy when level-zero list is empty
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Fix load of the hierarchy when level-zero list is empty
- Date: Sat, 26 Sep 2009 22:49:06 +0000 (UTC)
commit f13bdbee003cc743143b5a591b63a53e89725203
Author: Pierre Wieser <pwieser trychlos org>
Date: Mon Sep 21 22:49:39 2009 +0200
Fix load of the hierarchy when level-zero list is empty
src/common/na-iio-provider.c | 43 ++++++++++++++++++++++++++++++++++++----
src/nact/nact-iactions-list.c | 9 ++++---
src/nact/nact-tree-model.c | 9 +++++--
3 files changed, 49 insertions(+), 12 deletions(-)
---
diff --git a/src/common/na-iio-provider.c b/src/common/na-iio-provider.c
index 5e003d3..4e59c29 100644
--- a/src/common/na-iio-provider.c
+++ b/src/common/na-iio-provider.c
@@ -52,9 +52,11 @@ static GType register_type( void );
static void interface_base_init( NAIIOProviderInterface *klass );
static void interface_base_finalize( NAIIOProviderInterface *klass );
-static GList *build_hierarchy( GList *tree, GSList *level_zero );
+static GList *build_hierarchy( GList *tree, GSList *level_zero, gboolean list_if_empty );
static gint search_item( const NAObject *obj, const gchar *uuid );
static GList *get_merged_items_list( const NAPivot *pivot, GSList *providers );
+static void dump_hierarchy( GList *tree, gint level );
+
static guint try_write_item( const NAIIOProvider *instance, NAObject *item, gchar **message );
static gboolean do_is_willing_to_write( const NAIIOProvider *instance );
@@ -170,7 +172,7 @@ na_iio_provider_get_items_tree( const NAPivot *pivot )
na_pivot_free_providers( providers );
level_zero = na_iprefs_get_level_zero_items( NA_IPREFS( pivot ));
- hierarchy = build_hierarchy( merged, level_zero );
+ hierarchy = build_hierarchy( merged, level_zero, TRUE );
na_utils_free_string_list( level_zero );
na_object_free_items( merged );
@@ -178,6 +180,8 @@ na_iio_provider_get_items_tree( const NAPivot *pivot )
hierarchy = sort_tree( pivot, hierarchy );
}
+ dump_hierarchy( hierarchy, 0 );
+
return( hierarchy );
}
@@ -188,7 +192,7 @@ na_iio_provider_get_items_tree( const NAPivot *pivot )
* when releasing initial merged tree
*/
static GList *
-build_hierarchy( GList *tree, GSList *level_zero )
+build_hierarchy( GList *tree, GSList *level_zero, gboolean list_if_empty )
{
GList *hierarchy, *it;
GSList *ilevel;
@@ -208,7 +212,7 @@ build_hierarchy( GList *tree, GSList *level_zero )
if( NA_IS_OBJECT_MENU( it->data )){
subitems_ids = na_object_menu_get_items_list( NA_OBJECT_MENU( it->data ));
- subitems = build_hierarchy( tree, subitems_ids );
+ subitems = build_hierarchy( tree, subitems_ids, FALSE );
na_object_set_items( it->data, subitems );
na_object_free_items( subitems );
na_utils_free_string_list( subitems_ids );
@@ -218,7 +222,7 @@ build_hierarchy( GList *tree, GSList *level_zero )
}
/* if level-zero list is empty, we consider that all actions go to it
*/
- else {
+ else if( list_if_empty ){
for( it = tree ; it ; it = it->next ){
hierarchy = g_list_append( hierarchy, g_object_ref( it->data ));
}
@@ -276,6 +280,35 @@ get_merged_items_list( const NAPivot *pivot, GSList *providers )
return( merged );
}
+static void
+dump_hierarchy( GList *tree, gint level )
+{
+ GString *prefix;
+ gint i;
+ GList *subitems, *it;
+ gchar *id;
+
+ prefix = g_string_new( "" );
+ for( i = 0 ; i < level ; ++i ){
+ g_string_append_printf( prefix, " " );
+ }
+
+ for( it = tree ; it ; it = it->next ){
+ id = na_object_get_id( it->data );
+ g_debug( "nact_iio_provider_dump_hierarchy: %s%p (%s) %s",
+ prefix->str, ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ), id );
+ g_free( id );
+
+ if( NA_IS_OBJECT_ITEM( it->data )){
+ subitems = na_object_get_items( it->data );
+ dump_hierarchy( subitems, level+1 );
+ na_object_free_items( subitems );
+ }
+ }
+
+ g_string_free( prefix, TRUE );
+}
+
/**
* na_iio_provider_write_item:
* @pivot: the #NAPivot object which owns the list of registered I/O
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index aa97bfa..f20980b 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -1261,11 +1261,12 @@ on_edition_status_changed( NactIActionsList *instance, NAIDuplicable *object )
GtkTreeView *treeview;
NactTreeModel *model;
- g_debug( "nact_iactions_list_on_edition_status_changed: instance=%p (%s), object=%p (%s)",
- ( void * ) instance, G_OBJECT_TYPE_NAME( instance ),
- ( void * ) object, G_OBJECT_TYPE_NAME( object ));
-
if( is_selection_changed_authorized( instance )){
+
+ g_debug( "nact_iactions_list_on_edition_status_changed: instance=%p (%s), object=%p (%s)",
+ ( void * ) instance, G_OBJECT_TYPE_NAME( instance ),
+ ( void * ) object, G_OBJECT_TYPE_NAME( object ));
+
g_return_if_fail( NA_IS_OBJECT( object ));
treeview = get_actions_list_treeview( instance );
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index 74432ac..de492bc 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -580,7 +580,7 @@ static void
fill_tree_store( GtkTreeStore *model, GtkTreeView *treeview,
GList *items, gboolean only_actions, GtkTreeIter *parent )
{
- static const gchar *thisfn = "nact_tree_model_fill_tree_store";
+ /*static const gchar *thisfn = "nact_tree_model_fill_tree_store";*/
GList *subitems, *it;
NAObject *object;
NAObject *duplicate;
@@ -588,13 +588,14 @@ fill_tree_store( GtkTreeStore *model, GtkTreeView *treeview,
for( it = items ; it ; it = it->next ){
object = NA_OBJECT( it->data );
- g_debug( "%s: object=%p(%s)", thisfn
- , ( void * ) object, G_OBJECT_TYPE_NAME( object ));
+ /*g_debug( "%s: object=%p(%s)", thisfn
+ , ( void * ) object, G_OBJECT_TYPE_NAME( object ));*/
if( NA_IS_OBJECT_MENU( object )){
duplicate = object;
if( !only_actions ){
duplicate = parent ? g_object_ref( object ) : na_object_duplicate( object );
+ /*g_debug( "%s: appending duplicate=%p (%s)", thisfn, ( void * ) duplicate, G_OBJECT_TYPE_NAME( duplicate ));*/
append_item( model, treeview, parent, &iter, duplicate );
g_object_unref( duplicate );
}
@@ -605,6 +606,7 @@ fill_tree_store( GtkTreeStore *model, GtkTreeView *treeview,
if( NA_IS_OBJECT_ACTION( object )){
duplicate = parent ? g_object_ref( object ) : na_object_duplicate( object );
+ /*g_debug( "%s: appending duplicate=%p (%s)", thisfn, ( void * ) duplicate, G_OBJECT_TYPE_NAME( duplicate ));*/
append_item( model, treeview, parent, &iter, duplicate );
g_object_unref( duplicate );
if( !only_actions ){
@@ -618,6 +620,7 @@ fill_tree_store( GtkTreeStore *model, GtkTreeView *treeview,
if( NA_IS_OBJECT_PROFILE( object )){
g_assert( !only_actions );
+ /*g_debug( "%s: appending object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));*/
append_item( model, treeview, parent, &iter, object );
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]