[nautilus-actions] Move parent pointer from NAObjectProfile to NAObjectId class
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Move parent pointer from NAObjectProfile to NAObjectId class
- Date: Fri, 9 Oct 2009 00:16:04 +0000 (UTC)
commit ff2905b6b91dcbaf2d3b291a858a487edf289ea6
Author: pierre <pierre vfedora10 virtuals pwi>
Date: Thu Oct 8 14:35:51 2009 +0200
Move parent pointer from NAObjectProfile to NAObjectId class
ChangeLog | 29 ++++++++++++++
src/common/na-object-action-fn.h | 2 +
src/common/na-object-action.c | 19 +++++++++
src/common/na-object-id-fn.h | 6 +-
src/common/na-object-id.c | 8 +---
src/nact/nact-clipboard.c | 2 +-
src/nact/nact-iactions-list.c | 20 +++++++--
src/nact/nact-main-menubar.c | 43 ++++++++++++++++++---
src/nact/nact-main-window.c | 53 ++++++++------------------
src/nact/nact-tree-model.c | 22 +++++++----
src/plugin/nautilus-actions.c | 2 +-
src/runtime/na-object-action-fn.h | 1 +
src/runtime/na-object-action-priv.h | 5 ++
src/runtime/na-object-action.c | 48 +++++++++++++++++++----
src/runtime/na-object-api.h | 2 +
src/runtime/na-object-id-class.h | 1 +
src/runtime/na-object-id-fn.h | 14 ++++---
src/runtime/na-object-id-priv.h | 8 ++-
src/runtime/na-object-id.c | 43 ++++++++++++++++++++-
src/runtime/na-object-item.c | 13 ++++--
src/runtime/na-object-profile-fn.h | 2 -
src/runtime/na-object-profile-priv.h | 4 --
src/runtime/na-object-profile.c | 68 +---------------------------------
src/runtime/na-object.c | 3 +-
src/runtime/na-pivot.c | 2 +-
25 files changed, 254 insertions(+), 166 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 573dedb..4dc35ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2009-10-08 Pierre Wieser <pwieser trychlos org>
+
+ Move parent pointer from NAObjectProfile to NAObjectId class.
+
+ * src/common/na-object-action-fn.h:
+ * src/common/na-object-action.c:
+ * src/common/na-object-id-fn.h:
+ * src/common/na-object-id.c:
+ * src/nact/nact-clipboard.c:
+ * src/nact/nact-iactions-list.c:
+ * src/nact/nact-main-menubar.c:
+ * src/nact/nact-main-window.c:
+ * src/nact/nact-tree-model.c:
+ * src/plugin/nautilus-actions.c:
+ * src/runtime/na-object-action-fn.h:
+ * src/runtime/na-object-action-priv.h:
+ * src/runtime/na-object-action.c:
+ * src/runtime/na-object-api.h:
+ * src/runtime/na-object-id-class.h:
+ * src/runtime/na-object-id-fn.h:
+ * src/runtime/na-object-id-priv.h:
+ * src/runtime/na-object-id.c:
+ * src/runtime/na-object-item.c:
+ * src/runtime/na-object-profile-fn.h:
+ * src/runtime/na-object-profile-priv.h:
+ * src/runtime/na-object-profile.c:
+ * src/runtime/na-object.c:
+ * src/runtime/na-pivot.c: Updated accordingly.
+
2009-10-05 Pierre Wieser <pwieser trychlos org>
Restaure and fix 'Copy of' relabeling of pasted items.
diff --git a/src/common/na-object-action-fn.h b/src/common/na-object-action-fn.h
index 64db65b..e0a5a26 100644
--- a/src/common/na-object-action-fn.h
+++ b/src/common/na-object-action-fn.h
@@ -49,6 +49,8 @@ NAObjectAction *na_object_action_new_with_profile( void );
gboolean na_object_action_is_readonly( const NAObjectAction *action );
+void na_object_action_reset_last_allocated( NAObjectAction *action );
+
G_END_DECLS
#endif /* __NA_COMMON_OBJECT_ACTION_FN_H__ */
diff --git a/src/common/na-object-action.c b/src/common/na-object-action.c
index 1b9e3dc..4511287 100644
--- a/src/common/na-object-action.c
+++ b/src/common/na-object-action.c
@@ -86,3 +86,22 @@ na_object_action_is_readonly( const NAObjectAction *action )
return( readonly );
}
+
+/**
+ * na_object_action_reset_last_allocated:
+ * @action: the #NAObjectAction object.
+ *
+ * Resets the last_allocated counter for computing new profile names.
+ *
+ * This should be called after having successfully saved the action.
+ */
+void
+na_object_action_reset_last_allocated( NAObjectAction *action )
+{
+ g_return_if_fail( NA_IS_OBJECT_ACTION( action ));
+
+ if( !action->private->dispose_has_run ){
+
+ action->private->last_allocated = 0;
+ }
+}
diff --git a/src/common/na-object-id-fn.h b/src/common/na-object-id-fn.h
index 9cbaefa..6b7b74b 100644
--- a/src/common/na-object-id-fn.h
+++ b/src/common/na-object-id-fn.h
@@ -43,13 +43,13 @@
* in na-object-api.h
*/
-#include <runtime/na-object-id-class.h>
+#include <runtime/na-object-action-class.h>
#include <runtime/na-pivot.h>
G_BEGIN_DECLS
-void na_object_id_prepare_for_paste( NAObjectId *object, NAPivot *pivot, gboolean renumber, NAObjectAction *action );
-void na_object_id_set_copy_of_label( NAObjectId *object );
+void na_object_id_prepare_for_paste( NAObjectId *object, NAPivot *pivot, gboolean renumber, NAObjectAction *action );
+void na_object_id_set_copy_of_label( NAObjectId *object );
G_END_DECLS
diff --git a/src/common/na-object-id.c b/src/common/na-object-id.c
index 607379e..48f641f 100644
--- a/src/common/na-object-id.c
+++ b/src/common/na-object-id.c
@@ -41,12 +41,6 @@
#include "na-object-api.h"
#include "na-iprefs.h"
-/* private class data
- */
-struct NAObjectIdClassPrivate {
- void *empty; /* so that gcc -pedantic is happy */
-};
-
/**
* na_object_id_prepare_for_paste:
* @object: the #NAObjectId object to be pasted.
@@ -92,7 +86,7 @@ na_object_id_prepare_for_paste( NAObjectId *object, NAPivot *pivot, gboolean ren
}
if( NA_IS_OBJECT_PROFILE( object )){
- na_object_profile_set_action( NA_OBJECT_PROFILE( object ), action );
+ na_object_set_parent( object, action );
na_object_set_new_id( object, action );
if( renumber && user_relabel ){
na_object_set_copy_of_label( object );
diff --git a/src/nact/nact-clipboard.c b/src/nact/nact-clipboard.c
index 2da1ac3..9df9541 100644
--- a/src/nact/nact-clipboard.c
+++ b/src/nact/nact-clipboard.c
@@ -495,7 +495,7 @@ get_action_xml_buffer( const NAObject *object, GList **exported, NAObjectAction
*action = NA_OBJECT_ACTION( object );
}
if( NA_IS_OBJECT_PROFILE( object )){
- *action = na_object_profile_get_action( NA_OBJECT_PROFILE( object ));
+ *action = NA_OBJECT_ACTION( na_object_get_parent( NA_OBJECT_PROFILE( object )));
}
if( *action ){
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 7fbe3c0..58cbce7 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -541,12 +541,15 @@ nact_iactions_list_collapse_all( NactIActionsList *instance )
void
nact_iactions_list_delete( NactIActionsList *instance, GList *items )
{
+ static const gchar *thisfn = "nact_iactions_list_delete";
GtkTreeView *treeview;
GtkTreeModel *model;
GtkTreePath *path = NULL;
GList *it;
IActionsListInstanceData *ialid;
+ g_debug( "%s: instance=%p, items=%p (count=%d)",
+ thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ));
g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
if( st_initialized && !st_finalized ){
@@ -563,7 +566,11 @@ nact_iactions_list_delete( NactIActionsList *instance, GList *items )
if( path ){
gtk_tree_path_free( path );
}
+
path = nact_tree_model_remove( NACT_TREE_MODEL( model ), NA_OBJECT( it->data ));
+
+ g_debug( "%s: object=%p (%s, ref_count=%d)", thisfn,
+ ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ), G_OBJECT( it->data )->ref_count );
}
gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
@@ -926,8 +933,8 @@ nact_iactions_list_insert_items( NactIActionsList *instance, GList *items, NAObj
GtkTreePath *insert_path;
NAObject *object;
- g_debug( "%s: instance=%p, items=%p (%d items)",
- thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ));
+ g_debug( "%s: instance=%p, items=%p (%d items), sibling=%p",
+ thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ), ( void * ) sibling );
g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
g_return_if_fail( NACT_IS_WINDOW( instance ));
@@ -944,7 +951,7 @@ nact_iactions_list_insert_items( NactIActionsList *instance, GList *items, NAObj
} else {
insert_path = get_selection_first_path( treeview );
- /* as a particular case, insert profiles into current action
+ /* as a particular case, insert profiles _into_ current action
*/
object = nact_tree_model_object_at_path( NACT_TREE_MODEL( model ), insert_path );
/*g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
@@ -1048,7 +1055,7 @@ get_selection_first_path( GtkTreeView *treeview )
static void
do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTreePath *insert_path, GList **list_parents )
{
- /*static const gchar *thisfn = "nact_iactions_list_do_insert_items";*/
+ static const gchar *thisfn = "nact_iactions_list_do_insert_items";
GList *reversed;
GList *it;
GList *subitems;
@@ -1065,6 +1072,9 @@ do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTr
nact_tree_model_insert( NACT_TREE_MODEL( model ), NA_OBJECT( it->data ), insert_path, &obj_parent );
+ g_debug( "%s: object=%p (%s, ref_count=%d)", thisfn,
+ ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ), G_OBJECT( it->data )->ref_count );
+
if( list_parents && obj_parent ){
if( !g_list_find( *list_parents, obj_parent )){
*list_parents = g_list_prepend( *list_parents, obj_parent );
@@ -1735,7 +1745,7 @@ on_tab_updatable_item_updated( NactIActionsList *instance, NAObject *object )
item = object;
if( NA_IS_OBJECT_PROFILE( object )){
- item = NA_OBJECT( na_object_profile_get_action( NA_OBJECT_PROFILE( object )));
+ item = NA_OBJECT( na_object_get_parent( object ));
}
na_object_check_edition_status( item );
diff --git a/src/nact/nact-main-menubar.c b/src/nact/nact-main-menubar.c
index 30c417e..962751d 100644
--- a/src/nact/nact-main-menubar.c
+++ b/src/nact/nact-main-menubar.c
@@ -507,7 +507,7 @@ on_new_profile_activated( GtkAction *gtk_action, NactMainWindow *window )
profile = na_object_profile_new();
name = na_object_action_get_new_profile_name( action );
- na_object_profile_set_action( profile, action );
+ na_object_set_parent( profile, action );
na_object_set_id( profile, name );
na_object_check_edition_status( profile );
@@ -601,6 +601,10 @@ save_item( NactMainWindow *window, NAPivot *pivot, NAObjectItem *item )
if( nact_window_save_item( NACT_WINDOW( window ), item )){
+ if( NA_IS_OBJECT_ACTION( item )){
+ na_object_action_reset_last_allocated( NA_OBJECT_ACTION( item ));
+ }
+
/* do not use NA_OBJECT_ITEM macro as this may return a
* (valid) NULL value
*/
@@ -612,6 +616,11 @@ save_item( NactMainWindow *window, NAPivot *pivot, NAObjectItem *item )
dup_pivot = NA_OBJECT_ITEM( na_object_duplicate( item ));
na_object_reset_origin( item, dup_pivot );
+ g_debug( "un" );
+ na_object_dump( item );
+ g_debug( "deux" );
+ na_object_dump( dup_pivot );
+ g_debug( "trois" );
na_pivot_add_item( pivot, NA_OBJECT( dup_pivot ));
na_object_check_edition_status( item );
@@ -646,9 +655,11 @@ on_quit_activated( GtkAction *gtk_action, NactMainWindow *window )
static void
on_cut_activated( GtkAction *gtk_action, NactMainWindow *window )
{
+ static const gchar *thisfn = "nact_main_menubar_on_cut_activated";
GList *items;
NactClipboard *clipboard;
+ g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
g_return_if_fail( GTK_IS_ACTION( gtk_action ));
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
@@ -659,7 +670,8 @@ on_cut_activated( GtkAction *gtk_action, NactMainWindow *window )
update_clipboard_counters( window );
nact_iactions_list_delete( NACT_IACTIONS_LIST( window ), items );
- /* do not unref selected items as the ref has been moved to main_deleted
+ /* do not unref selected items as the list has been concatenated
+ * to main_deleted
*/
/*g_list_free( items );*/
}
@@ -675,9 +687,11 @@ on_cut_activated( GtkAction *gtk_action, NactMainWindow *window )
static void
on_copy_activated( GtkAction *gtk_action, NactMainWindow *window )
{
+ static const gchar *thisfn = "nact_main_menubar_on_copy_activated";
GList *items;
NactClipboard *clipboard;
+ g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
g_return_if_fail( GTK_IS_ACTION( gtk_action ));
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
@@ -705,8 +719,11 @@ on_copy_activated( GtkAction *gtk_action, NactMainWindow *window )
static void
on_paste_activated( GtkAction *gtk_action, NactMainWindow *window )
{
+ static const gchar *thisfn = "nact_main_menubar_on_paste_activated";
GList *items;
+ g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
+
items = prepare_for_paste( window );
nact_iactions_list_insert_items( NACT_IACTIONS_LIST( window ), items, NULL );
na_object_free_items( items );
@@ -727,8 +744,11 @@ on_paste_activated( GtkAction *gtk_action, NactMainWindow *window )
static void
on_paste_into_activated( GtkAction *gtk_action, NactMainWindow *window )
{
+ static const gchar *thisfn = "nact_main_menubar_on_paste_into_activated";
GList *items;
+ g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
+
items = prepare_for_paste( window );
nact_iactions_list_insert_into( NACT_IACTIONS_LIST( window ), items );
na_object_free_items( items );
@@ -737,6 +757,7 @@ on_paste_into_activated( GtkAction *gtk_action, NactMainWindow *window )
static GList *
prepare_for_paste( NactMainWindow *window )
{
+ static const gchar *thisfn = "nact_main_menubar_prepare_for_paste";
GList *items, *it;
NactClipboard *clipboard;
NAObjectAction *action;
@@ -754,15 +775,20 @@ prepare_for_paste( NactMainWindow *window )
/* if pasted items are profiles, then setup the target action
*/
for( it = items ; it ; it = it->next ){
+
if( NA_IS_OBJECT_PROFILE( it->data )){
if( !action ){
g_object_get( G_OBJECT( window ), TAB_UPDATABLE_PROP_EDITED_ACTION, &action, NULL );
g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), NULL );
}
}
- na_object_prepare_for_paste( NA_OBJECT_ITEM( it->data ), pivot, renumber, action );
+
+ na_object_prepare_for_paste( it->data, pivot, renumber, action );
}
+ g_debug( "%s: action=%p (%s)",
+ thisfn, ( void * ) action, action ? G_OBJECT_TYPE_NAME( action ): "(null)" );
+
return( items );
}
@@ -777,6 +803,7 @@ prepare_for_paste( NactMainWindow *window )
static void
on_duplicate_activated( GtkAction *gtk_action, NactMainWindow *window )
{
+ static const gchar *thisfn = "nact_main_menubar_on_duplicate_activated";
NactApplication *application;
NAPivot *pivot;
NAObjectAction *action;
@@ -784,6 +811,7 @@ on_duplicate_activated( GtkAction *gtk_action, NactMainWindow *window )
GList *dup;
NAObject *obj;
+ g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
g_return_if_fail( GTK_IS_ACTION( gtk_action ));
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
@@ -799,7 +827,7 @@ on_duplicate_activated( GtkAction *gtk_action, NactMainWindow *window )
* as we insert in sibling mode, the parent doesn't change
*/
if( NA_IS_OBJECT_PROFILE( obj )){
- action = na_object_profile_get_action( NA_OBJECT_PROFILE( obj ));
+ action = NA_OBJECT_ACTION( na_object_get_parent( NA_OBJECT_PROFILE( obj )));
}
na_object_prepare_for_paste( obj, pivot, TRUE, action );
@@ -823,20 +851,23 @@ on_duplicate_activated( GtkAction *gtk_action, NactMainWindow *window )
static void
on_delete_activated( GtkAction *gtk_action, NactMainWindow *window )
{
+ static const gchar *thisfn = "nact_main_menubar_on_delete_activated";
GList *items;
GList *it;
+ g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
g_return_if_fail( GTK_IS_ACTION( gtk_action ));
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
items = nact_iactions_list_get_selected_items( NACT_IACTIONS_LIST( window ));
for( it = items ; it ; it = it->next ){
- g_debug( "on_delete_activated: items=%p (%s)", ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ));
+ g_debug( "%s: item=%p (%s)", thisfn, ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ));
}
nact_main_window_move_to_deleted( window, items );
nact_iactions_list_delete( NACT_IACTIONS_LIST( window ), items );
- /* do not unref selected items as the ref has been moved to main_deleted
+ /* do not unref selected items as the list has been concatenated
+ * to main_deleted
*/
/*g_list_free( items );*/
}
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 6883708..de4dc9e 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -87,8 +87,7 @@ struct NactMainWindowPrivate {
* Conditions and Advanced ; it may be different of the row being
* currently selected.
*
- * Can be null and this implies that the edited item is a menu
- * (because an action cannot have zero profile).
+ * Can be null if @edited_item is a menu or an invalid action.
*/
NAObjectProfile *edited_profile;
@@ -102,7 +101,6 @@ struct NactMainWindowPrivate {
*/
enum {
PROP_EDITED_ITEM = 1,
- PROP_ITEM_EDITION_ENABLED,
PROP_EDITED_PROFILE
};
@@ -676,6 +674,8 @@ nact_main_window_get_clipboard( const NactMainWindow *window )
* we can create any new actions, deleting them, and so on
* if we have eventually deleted all newly created actions, then the
* final count of modified actions should be zero... don't it ?
+ *
+ * Note also that we don't count invalid items as they are not saveable.
*/
gboolean
nact_main_window_has_modified_items( const NactMainWindow *window )
@@ -718,15 +718,22 @@ nact_main_window_has_modified_items( const NactMainWindow *window )
void
nact_main_window_move_to_deleted( NactMainWindow *window, GList *items )
{
+ static const gchar *thisfn = "nact_main_window_move_to_deleted";
GList *it;
+ g_debug( "%s: window=%p, items=%p (%d items)",
+ thisfn, ( void * ) window, ( void * ) items, g_list_length( items ));
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
if( !window->private->dispose_has_run ){
- window->private->deleted = g_list_concat( window->private->deleted, items );
- for( it = window->private->deleted ; it ; it = it->next ){
- g_debug( "nact_main_window_move_to_deleted: %p (%s)", ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ));
+
+ for( it = items ; it ; it = it->next ){
+ g_debug( "%s: %p (%s, ref_count=%d)", thisfn,
+ ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ), G_OBJECT( it->data )->ref_count );
}
+
+ window->private->deleted = g_list_concat( window->private->deleted, items );
+ g_debug( "%s: main_deleted has %d items", thisfn, g_list_length( window->private->deleted ));
}
}
@@ -781,6 +788,7 @@ nact_main_window_remove_deleted( NactMainWindow *window )
actually_delete_item( window, item, pivot );
}
+ g_debug( "nact_main_window_remove_deleted: before free deleted" );
na_object_free_items( window->private->deleted );
window->private->deleted = NULL;
}
@@ -984,6 +992,7 @@ on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected
/*
* update the notebook when selection changes in ActionsList
* if there is only one profile, we also setup the profile
+ * count_profiles may be null (invalid action)
*/
static void
set_current_object_item( NactMainWindow *window, GSList *selected_items )
@@ -1004,7 +1013,7 @@ set_current_object_item( NactMainWindow *window, GSList *selected_items )
NA_IS_OBJECT_ACTION( window->private->edited_item )){
count_profiles = na_object_get_items_count( NA_OBJECT_ACTION( window->private->edited_item ));
- g_return_if_fail( count_profiles >= 1 );
+ /*g_return_if_fail( count_profiles >= 1 );*/
if( count_profiles == 1 ){
profiles = na_object_get_items( window->private->edited_item );
@@ -1013,34 +1022,6 @@ set_current_object_item( NactMainWindow *window, GSList *selected_items )
}
}
- /* do the profile tabs (ICommandTab, IConditionsTab and IAdvancedTab)
- * will be editable ?
- * yes if we have an action with only one profile, or the selected
- * item is itself a profile
- */
- /*window->private->edition_enabled = ( window->private->edited_item != NULL );
-
- if( window->private->edition_enabled ){
- g_assert( selected_items );
- if( g_slist_length( selected_items ) > 1 ){
- window->private->edition_enabled = FALSE;
- }
- }
-
- if( window->private->edition_enabled && NA_IS_OBJECT_MENU( window->private->edited_item )){
- window->private->edition_enabled = FALSE;
- }
-
- if( window->private->edition_enabled ){
- g_assert( NA_IS_ACTION( window->private->edited_item ));
- current = NA_OBJECT( selected_items->data );
- if( NA_IS_OBJECT_ACTION( current)){
- if( na_object_action_get_profiles_count( NA_ACTION( window->private->edited_item )) > 1 ){
- window->private->edition_enabled = FALSE;
- }
- }
- }*/
-
set_current_profile( window, FALSE, selected_items );
}
@@ -1053,7 +1034,7 @@ set_current_profile( NactMainWindow *window, gboolean set_action, GSList *select
thisfn, ( void * ) window, set_action ? "True":"False", ( void * ) selected_items );
if( window->private->edited_profile && set_action ){
- NAObjectAction *action = NA_OBJECT_ACTION( na_object_profile_get_action( window->private->edited_profile ));
+ NAObjectAction *action = NA_OBJECT_ACTION( na_object_get_parent( window->private->edited_profile ));
window->private->edited_item = NA_OBJECT_ITEM( action );
}
}
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index cfcdce4..cc135c2 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -893,9 +893,11 @@ nact_tree_model_object_at_path( NactTreeModel *model, GtkTreePath *path )
if( !model->private->dispose_has_run ){
store = gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model ));
- gtk_tree_model_get_iter( store, &iter, path );
- gtk_tree_model_get( store, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
- g_object_unref( object );
+
+ if( gtk_tree_model_get_iter( store, &iter, path )){
+ gtk_tree_model_get( store, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
+ g_object_unref( object );
+ }
}
return( object );
@@ -913,12 +915,15 @@ nact_tree_model_object_at_path( NactTreeModel *model, GtkTreePath *path )
GtkTreePath *
nact_tree_model_remove( NactTreeModel *model, NAObject *object )
{
+ static const gchar *thisfn = "nact_tree_model_remove";
GtkTreeIter iter;
GtkTreeStore *store;
GList *parents = NULL;
GList *it;
GtkTreePath *path = NULL;
+ g_debug( "%s: model=%p, object=%p (%s)",
+ thisfn, ( void * ) model, ( void * ) object, object ? G_OBJECT_TYPE_NAME( object ) : "(null)" );
g_return_val_if_fail( NACT_IS_TREE_MODEL( model ), NULL );
if( !model->private->dispose_has_run ){
@@ -1013,8 +1018,9 @@ dump_store( NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmDumpSt
id = na_object_get_id( object );
label = na_object_get_label( object );
- g_debug( "%s: %s%s at %p \"[%s] %s\"",
- ntm->fname, prefix->str, G_OBJECT_TYPE_NAME( object ), ( void * ) object, id, label );
+ g_debug( "%s: %s%s at %p (ref_count=%d) \"[%s] %s\"",
+ ntm->fname, prefix->str,
+ G_OBJECT_TYPE_NAME( object ), ( void * ) object, G_OBJECT( object )->ref_count, id, label );
g_free( label );
g_free( id );
@@ -1414,7 +1420,7 @@ idrag_dest_drag_data_received( GtkTreeDragDest *drag_dest, GtkTreePath *dest, Gt
g_debug( "%s: current object at dest is %s", thisfn, G_OBJECT_TYPE_NAME( current ));
if( NA_IS_OBJECT_PROFILE( current )){
inside_an_action = TRUE;
- parent = na_object_profile_get_action( NA_OBJECT_PROFILE( current ));
+ parent = NA_OBJECT_ACTION( na_object_get_parent( current ));
}
g_object_unref( current );
}
@@ -1448,7 +1454,7 @@ idrag_dest_drag_data_received( GtkTreeDragDest *drag_dest, GtkTreePath *dest, Gt
if( gtk_tree_model_get_iter( GTK_TREE_MODEL( drag_dest ), &iter, path )){
gtk_tree_model_get( GTK_TREE_MODEL( drag_dest ), &iter, IACTIONS_LIST_NAOBJECT_COLUMN, ¤t, -1 );
if( copy_data ){
- na_object_prepare_for_paste( NA_OBJECT_ITEM( current ), pivot, TRUE, parent );
+ na_object_prepare_for_paste( current, pivot, TRUE, parent );
}
object_list = g_list_prepend( object_list, current );
g_object_unref( current );
@@ -1772,7 +1778,7 @@ filter_visible( GtkTreeModel *store, GtkTreeIter *iter, NactTreeModel *model )
}
if( NA_IS_OBJECT_PROFILE( object )){
- action = na_object_profile_get_action( NA_OBJECT_PROFILE( object ));
+ action = NA_OBJECT_ACTION( na_object_get_parent( object ));
g_object_unref( object );
count = na_object_get_items_count( action );
/*g_debug( "action=%p: count=%d", ( void * ) action, count );*/
diff --git a/src/plugin/nautilus-actions.c b/src/plugin/nautilus-actions.c
index b8f3757..4a7ecab 100644
--- a/src/plugin/nautilus-actions.c
+++ b/src/plugin/nautilus-actions.c
@@ -433,7 +433,7 @@ create_item_from_profile( NAObjectProfile *profile, GList *files )
NAObjectAction *action;
NAObjectProfile *dup4menu;
- action = na_object_profile_get_action( profile );
+ action = NA_OBJECT_ACTION( na_object_get_parent( profile ));
item = create_menu_item( NA_OBJECT_ITEM( action ));
diff --git a/src/runtime/na-object-action-fn.h b/src/runtime/na-object-action-fn.h
index 508d7da..4695f1a 100644
--- a/src/runtime/na-object-action-fn.h
+++ b/src/runtime/na-object-action-fn.h
@@ -48,6 +48,7 @@ G_BEGIN_DECLS
*/
#define NAACTION_PROP_VERSION "na-action-version"
#define NAACTION_PROP_READONLY "na-action-read-only"
+#define NAACTION_PROP_LAST_ALLOCATED "na-action-last-allocated"
/* i18n: default label for a newly created action */
#define NA_OBJECT_ACTION_DEFAULT_LABEL _( "New Nautilus action" )
diff --git a/src/runtime/na-object-action-priv.h b/src/runtime/na-object-action-priv.h
index 0d5db13..77bed3d 100644
--- a/src/runtime/na-object-action-priv.h
+++ b/src/runtime/na-object-action-priv.h
@@ -49,6 +49,11 @@ struct NAObjectActionPrivate {
* defaults to FALSE unless a write has already returned an error
*/
gboolean read_only;
+
+ /* last allocated profile name in na_object_action_get_new_profile_name()
+ * reset to zero when saving the action
+ */
+ gint last_allocated;
};
G_END_DECLS
diff --git a/src/runtime/na-object-action.c b/src/runtime/na-object-action.c
index 0d74235..9666ab5 100644
--- a/src/runtime/na-object-action.c
+++ b/src/runtime/na-object-action.c
@@ -49,7 +49,8 @@ struct NAObjectActionClassPrivate {
*/
enum {
NAACTION_PROP_VERSION_ID = 1,
- NAACTION_PROP_READONLY_ID
+ NAACTION_PROP_READONLY_ID,
+ NAACTION_PROP_LAST_ALLOCATED_ID
};
static NAObjectItemClass *st_parent_class = NULL;
@@ -134,6 +135,13 @@ class_init( NAObjectActionClass *klass )
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
g_object_class_install_property( object_class, NAACTION_PROP_READONLY_ID, spec );
+ spec = g_param_spec_int(
+ NAACTION_PROP_LAST_ALLOCATED,
+ "Last allocated counter",
+ "Last counter used in new profile name computing", 0, INT_MAX, 0,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
+ g_object_class_install_property( object_class, NAACTION_PROP_LAST_ALLOCATED_ID, spec );
+
klass->private = g_new0( NAObjectActionClassPrivate, 1 );
naobject_class = NA_OBJECT_CLASS( klass );
@@ -163,6 +171,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
*/
self->private->version = g_strdup( NAUTILUS_ACTIONS_CONFIG_VERSION );
self->private->read_only = FALSE;
+ self->private->last_allocated = 0;
}
static void
@@ -184,6 +193,10 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
g_value_set_boolean( value, self->private->read_only );
break;
+ case NAACTION_PROP_LAST_ALLOCATED_ID:
+ g_value_set_int( value, self->private->last_allocated );
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
break;
@@ -211,6 +224,10 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
self->private->read_only = g_value_get_boolean( value );
break;
+ case NAACTION_PROP_LAST_ALLOCATED_ID:
+ self->private->last_allocated = g_value_get_int( value );
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, spec );
break;
@@ -364,12 +381,16 @@ na_object_action_set_readonly( NAObjectAction *action, gboolean readonly )
* Returns a name suitable as a new profile name.
*
* The search is made by iterating over the standard profile name
- * prefix : basically, we increment a counter until finding a unique
- * name. The provided name is so only suitable for the specified
- * @action.
+ * prefix : basically, we increment a counter until finding a name
+ * which is not yet allocated. The provided name is so only suitable
+ * for the specified @action.
*
* Returns: a newly allocated profile name, which should be g_free() by
* the caller.
+ *
+ * When inserting a list of profiles in the action, we iter first for
+ * new names, before actually do the insertion. We so keep the last
+ * allocated name to avoid to allocate the same one twice.
*/
gchar *
na_object_action_get_new_profile_name( const NAObjectAction *action )
@@ -382,11 +403,14 @@ na_object_action_get_new_profile_name( const NAObjectAction *action )
if( !action->private->dispose_has_run ){
- for( i=1 ; !ok ; ++i ){
+ for( i = action->private->last_allocated + 1 ; !ok ; ++i ){
+
g_free( candidate );
candidate = g_strdup_printf( "%s%d", OBJECT_PROFILE_PREFIX, i );
+
if( !na_object_get_item( action, candidate )){
ok = TRUE;
+ action->private->last_allocated = i;
}
}
@@ -415,7 +439,7 @@ na_object_action_attach_profile( NAObjectAction *action, NAObjectProfile *profil
if( !action->private->dispose_has_run ){
na_object_append_item( action, profile );
- na_object_profile_set_action( profile, action );
+ na_object_set_parent( profile, action );
}
}
@@ -430,8 +454,9 @@ object_dump( const NAObject *action )
if( !self->private->dispose_has_run ){
- g_debug( "%s: version='%s'", thisfn, self->private->version );
- g_debug( "%s: read-only='%s'", thisfn, self->private->read_only ? "True" : "False" );
+ g_debug( "%s: version='%s'", thisfn, self->private->version );
+ g_debug( "%s: read-only='%s'", thisfn, self->private->read_only ? "True" : "False" );
+ g_debug( "%s: last-allocated=%d", thisfn, self->private->last_allocated );
}
}
@@ -446,6 +471,7 @@ object_copy( NAObject *target, const NAObject *source )
{
gchar *version;
gboolean readonly;
+ gint last_allocated;
GList *profiles, *ip;
g_return_if_fail( NA_IS_OBJECT_ACTION( target ));
@@ -457,11 +483,13 @@ object_copy( NAObject *target, const NAObject *source )
g_object_get( G_OBJECT( source ),
NAACTION_PROP_VERSION, &version,
NAACTION_PROP_READONLY, &readonly,
+ NAACTION_PROP_LAST_ALLOCATED, &last_allocated,
NULL );
g_object_set( G_OBJECT( target ),
NAACTION_PROP_VERSION, version,
NAACTION_PROP_READONLY, readonly,
+ NAACTION_PROP_LAST_ALLOCATED, last_allocated,
NULL );
g_free( version );
@@ -471,7 +499,7 @@ object_copy( NAObject *target, const NAObject *source )
*/
profiles = na_object_get_items( target );
for( ip = profiles ; ip ; ip = ip->next ){
- na_object_profile_set_action( NA_OBJECT_PROFILE( ip->data ), NA_OBJECT_ACTION( target ));
+ na_object_set_parent( ip->data, target );
}
na_object_free_items( profiles );
}
@@ -483,6 +511,8 @@ object_copy( NAObject *target, const NAObject *source )
* note 2: when checking for equality of profiles, we know that NAObjectItem
* has already checked their edition status, and that the two profiles lists
* were the sames ; we so only report the modification status to the action
+ *
+ * note 3: last_allocated counter is not relevant for equality test
*/
static gboolean
object_are_equal( const NAObject *a, const NAObject *b )
diff --git a/src/runtime/na-object-api.h b/src/runtime/na-object-api.h
index 5b518c1..acfcf39 100644
--- a/src/runtime/na-object-api.h
+++ b/src/runtime/na-object-api.h
@@ -70,10 +70,12 @@ G_BEGIN_DECLS
*/
#define na_object_get_id( object ) na_object_id_get_id( NA_OBJECT_ID( object ))
#define na_object_get_label( object ) na_object_id_get_label( NA_OBJECT_ID( object ))
+#define na_object_get_parent( object ) na_object_id_get_parent( NA_OBJECT_ID( object ))
#define na_object_set_id( object, id ) na_object_id_set_id( NA_OBJECT_ID( object ), id )
#define na_object_set_new_id( object, parent ) na_object_id_set_new_id( NA_OBJECT_ID( object ), ( NAObjectId * ) parent )
#define na_object_set_label( object, label ) na_object_id_set_label( NA_OBJECT_ID( object ), label )
+#define na_object_set_parent( object, parent ) na_object_id_set_parent( NA_OBJECT_ID( object ), ( NAObjectItem * ) parent )
/* NAObjectItem
*/
diff --git a/src/runtime/na-object-id-class.h b/src/runtime/na-object-id-class.h
index 5bbc643..fa1f5b5 100644
--- a/src/runtime/na-object-id-class.h
+++ b/src/runtime/na-object-id-class.h
@@ -72,6 +72,7 @@ typedef struct {
* new_id:
* @object: a #NAObjectId object.
* @new_parent: possibly the new #NAObjectId parent, or NULL.
+ * If not NULL, this should actually be a #NAObjectItem.
*
* Returns: a new id suitable for this @object.
*
diff --git a/src/runtime/na-object-id-fn.h b/src/runtime/na-object-id-fn.h
index 6bd9e79..45485d6 100644
--- a/src/runtime/na-object-id-fn.h
+++ b/src/runtime/na-object-id-fn.h
@@ -42,16 +42,18 @@
* in na-object-api.h
*/
-#include "na-object-id-class.h"
+#include "na-object-item-class.h"
G_BEGIN_DECLS
-gchar *na_object_id_get_id( const NAObjectId *object );
-void na_object_id_set_new_id( NAObjectId *object, const NAObjectId *new_parent );
-gchar *na_object_id_get_label( const NAObjectId *object );
+gchar *na_object_id_get_id( const NAObjectId *object );
+void na_object_id_set_new_id( NAObjectId *object, const NAObjectId *new_parent );
+gchar *na_object_id_get_label( const NAObjectId *object );
+NAObjectItem *na_object_id_get_parent( NAObjectId *object );
-void na_object_id_set_id( NAObjectId *object, const gchar *id );
-void na_object_id_set_label( NAObjectId *object, const gchar *label );
+void na_object_id_set_id( NAObjectId *object, const gchar *id );
+void na_object_id_set_label( NAObjectId *object, const gchar *label );
+void na_object_id_set_parent( NAObjectId *object, NAObjectItem *parent );
G_END_DECLS
diff --git a/src/runtime/na-object-id-priv.h b/src/runtime/na-object-id-priv.h
index bb8764a..6ab8623 100644
--- a/src/runtime/na-object-id-priv.h
+++ b/src/runtime/na-object-id-priv.h
@@ -32,15 +32,17 @@
#define __NA_RUNTIME_OBJECT_ID_PRIV_H__
#include "na-object-id-class.h"
+#include "na-object-item-class.h"
G_BEGIN_DECLS
/* private instance data
*/
struct NAObjectIdPrivate {
- gboolean dispose_has_run;
- gchar *id;
- gchar *label;
+ gboolean dispose_has_run;
+ NAObjectItem *parent;
+ gchar *id;
+ gchar *label;
};
G_END_DECLS
diff --git a/src/runtime/na-object-id.c b/src/runtime/na-object-id.c
index 1d7a26d..73c8f8e 100644
--- a/src/runtime/na-object-id.c
+++ b/src/runtime/na-object-id.c
@@ -314,6 +314,26 @@ na_object_id_get_label( const NAObjectId *object )
}
/**
+ * na_object_id_get_parent:
+ * @object: the #NAObjectId whose parent is to be retrieved.
+ *
+ * Returns: the #NAObjectItem parent, or NULL.
+ */
+NAObjectItem *
+na_object_id_get_parent( NAObjectId *object )
+{
+ NAObjectItem *parent = NULL;
+
+ g_return_val_if_fail( NA_IS_OBJECT_ID( object ), NULL );
+
+ if( !object->private->dispose_has_run ){
+ parent = object->private->parent;
+ }
+
+ return( parent );
+}
+
+/**
* na_object_id_set_id:
* @object: the #NAObjectId object whose internal identifiant is to be
* set.
@@ -379,6 +399,24 @@ na_object_id_set_label( NAObjectId *object, const gchar *label )
}
}
+/**
+ * na_object_id_set_parent:
+ * @object: this #NAObjectId object.
+ * @parent: the #NAObjectItem parent to be set, or NULL.
+ *
+ * Store a pointer to the parent.
+ */
+void
+na_object_id_set_parent( NAObjectId *object, NAObjectItem *parent )
+{
+ g_return_if_fail( NA_IS_OBJECT_ID( object ));
+ g_return_if_fail( NA_IS_OBJECT_ITEM( parent ) || !parent );
+
+ if( !object->private->dispose_has_run ){
+ object->private->parent = parent;
+ }
+}
+
static void
object_dump( const NAObject *object )
{
@@ -388,8 +426,9 @@ object_dump( const NAObject *object )
if( !NA_OBJECT_ID( object )->private->dispose_has_run ){
- g_debug( "%s: id=%s", thisfn, NA_OBJECT_ID( object )->private->id );
- g_debug( "%s: label=%s", thisfn, NA_OBJECT_ID( object )->private->label );
+ g_debug( "%s: parent=%p", thisfn, ( void * ) NA_OBJECT_ID( object )->private->parent );
+ g_debug( "%s: id=%s", thisfn, NA_OBJECT_ID( object )->private->id );
+ g_debug( "%s: label=%s", thisfn, NA_OBJECT_ID( object )->private->label );
}
}
diff --git a/src/runtime/na-object-item.c b/src/runtime/na-object-item.c
index c9a578d..b74d25d 100644
--- a/src/runtime/na-object-item.c
+++ b/src/runtime/na-object-item.c
@@ -279,10 +279,10 @@ instance_dispose( GObject *object )
if( !self->private->dispose_has_run ){
- na_object_item_free_items( self->private->items );
-
self->private->dispose_has_run = TRUE;
+ na_object_item_free_items( self->private->items );
+
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
G_OBJECT_CLASS( st_parent_class )->dispose( object );
@@ -487,9 +487,12 @@ na_object_item_free_items( GList *items )
for( it = items ; it ; it = it->next ){
if( G_IS_OBJECT( it->data )){
+ g_debug( "na_object_item_free_items: items=%p, it_data=%p (%s, ref_count=%d)",
+ ( void * ) items,
+ ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ), G_OBJECT( it->data )->ref_count);
g_object_unref( it->data );
- /*} else {
- g_warning( "na_object_item_free_items: %p not an object", ( void * ) it->data );*/
+ } else {
+ g_debug( "na_object_item_free_items: %p not an object", ( void * ) it->data );
}
}
@@ -501,7 +504,7 @@ na_object_item_free_items( GList *items )
* @item: the #NAObjectItem object to be requested.
*
* Is the specified item enabled ?
- * When disabled, the item, not its subitems if any, is/are never
+ * When disabled, the item, nor its subitems if any, is/are never
* candidate to any selection.
*
* Returns: %TRUE if the item is enabled, %FALSE else.
diff --git a/src/runtime/na-object-profile-fn.h b/src/runtime/na-object-profile-fn.h
index f0aa9cd..85afcfe 100644
--- a/src/runtime/na-object-profile-fn.h
+++ b/src/runtime/na-object-profile-fn.h
@@ -55,7 +55,6 @@ G_BEGIN_DECLS
NAObjectProfile *na_object_profile_new( void );
-NAObjectAction *na_object_profile_get_action( const NAObjectProfile *profile );
gchar *na_object_profile_get_path( const NAObjectProfile *profile );
gchar *na_object_profile_get_parameters( const NAObjectProfile *profile );
GSList *na_object_profile_get_basenames( const NAObjectProfile *profile );
@@ -66,7 +65,6 @@ gboolean na_object_profile_get_is_dir( const NAObjectProfile *profile );
gboolean na_object_profile_get_multiple( const NAObjectProfile *profile );
GSList *na_object_profile_get_schemes( const NAObjectProfile *profile );
-void na_object_profile_set_action( NAObjectProfile *profile, const NAObjectAction *action );
void na_object_profile_set_path( NAObjectProfile *profile, const gchar *path );
void na_object_profile_set_parameters( NAObjectProfile *profile, const gchar *parameters );
void na_object_profile_set_basenames( NAObjectProfile *profile, GSList *basenames );
diff --git a/src/runtime/na-object-profile-priv.h b/src/runtime/na-object-profile-priv.h
index 41044ca..8f34971 100644
--- a/src/runtime/na-object-profile-priv.h
+++ b/src/runtime/na-object-profile-priv.h
@@ -40,10 +40,6 @@ G_BEGIN_DECLS
struct NAObjectProfilePrivate {
gboolean dispose_has_run;
- /* the NAObjectAction object
- */
- NAObjectAction *action;
-
/* profile properties
*/
gchar *path;
diff --git a/src/runtime/na-object-profile.c b/src/runtime/na-object-profile.c
index 0346bbb..8935877 100644
--- a/src/runtime/na-object-profile.c
+++ b/src/runtime/na-object-profile.c
@@ -51,8 +51,7 @@ struct NAObjectProfileClassPrivate {
/* profile properties
*/
enum {
- NAPROFILE_PROP_ACTION_ID = 1,
- NAPROFILE_PROP_PATH_ID,
+ NAPROFILE_PROP_PATH_ID = 1,
NAPROFILE_PROP_PARAMETERS_ID,
NAPROFILE_PROP_BASENAMES_ID,
NAPROFILE_PROP_MATCHCASE_ID,
@@ -63,7 +62,6 @@ enum {
NAPROFILE_PROP_SCHEMES_ID
};
-#define NAPROFILE_PROP_ACTION "na-profile-action"
#define NAPROFILE_PROP_PATH "na-profile-path"
#define NAPROFILE_PROP_PARAMETERS "na-profile-parameters"
#define NAPROFILE_PROP_BASENAMES "na-profile-basenames"
@@ -146,13 +144,6 @@ class_init( NAObjectProfileClass *klass )
object_class->set_property = instance_set_property;
object_class->get_property = instance_get_property;
- spec = g_param_spec_pointer(
- NAPROFILE_PROP_ACTION,
- "NAAction attachment",
- "The NAAction action to which this profile belongs",
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, NAPROFILE_PROP_ACTION_ID, spec );
-
spec = g_param_spec_string(
NAPROFILE_PROP_PATH,
"Command path",
@@ -270,10 +261,6 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
if( !self->private->dispose_has_run ){
switch( property_id ){
- case NAPROFILE_PROP_ACTION_ID:
- g_value_set_pointer( value, self->private->action );
- break;
-
case NAPROFILE_PROP_PATH_ID:
g_value_set_string( value, self->private->path );
break;
@@ -331,10 +318,6 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
if( !self->private->dispose_has_run ){
switch( property_id ){
- case NAPROFILE_PROP_ACTION_ID:
- self->private->action = g_value_get_pointer( value );
- break;
-
case NAPROFILE_PROP_PATH_ID:
g_free( self->private->path );
self->private->path = g_value_dup_string( value );
@@ -449,32 +432,6 @@ na_object_profile_new( void )
}
/**
- * na_object_profile_get_action:
- * @profile: the #NAObjectProfile to be requested.
- *
- * Returns a pointer to the action to which this profile is attached,
- * or NULL if the profile has never been attached.
- *
- * Returns: a #NAAction pointer.
- *
- * Note that the returned #NAAction pointer is owned by the profile.
- * The caller should not try to g_free() nor g_object_unref() it.
- */
-NAObjectAction *
-na_object_profile_get_action( const NAObjectProfile *profile )
-{
- NAObjectAction *action = NULL;
-
- g_return_val_if_fail( NA_IS_OBJECT_PROFILE( profile ), NULL );
-
- if( !profile->private->dispose_has_run ){
- g_object_get( G_OBJECT( profile ), NAPROFILE_PROP_ACTION, &action, NULL );
- }
-
- return( action );
-}
-
-/**
* na_object_profile_get_path:
* @profile: the #NAObjectProfile to be requested.
*
@@ -701,26 +658,6 @@ na_object_profile_get_schemes( const NAObjectProfile *profile )
}
/**
- * na_object_profile_set_action:
- * @profile: the #NAObjectProfile to be updated.
- * @action: the #NAAction action to which this profile is attached.
- *
- * Sets the action to which this profile is attached.
- *
- * The reference count of the @action is not modified.
- */
-void
-na_object_profile_set_action( NAObjectProfile *profile, const NAObjectAction *action )
-{
- g_return_if_fail( NA_IS_OBJECT_PROFILE( profile ));
- g_return_if_fail( NA_IS_OBJECT_ACTION( action ));
-
- if( !profile->private->dispose_has_run ){
- g_object_set( G_OBJECT( profile ), NAPROFILE_PROP_ACTION, action, NULL );
- }
-}
-
-/**
* na_object_profile_set_path:
* @profile: the #NAObjectProfile to be updated.
* @path: the command path to be set.
@@ -1412,7 +1349,6 @@ object_dump( const NAObject *object )
if( !self->private->dispose_has_run ){
- g_debug( "%s: action=%p", thisfn, ( void * ) self->private->action );
g_debug( "%s: path='%s'", thisfn, self->private->path );
g_debug( "%s: parameters='%s'", thisfn, self->private->parameters );
g_debug( "%s: accept_multiple='%s'", thisfn, self->private->accept_multiple ? "True" : "False" );
@@ -1569,7 +1505,7 @@ object_id_new_id( const NAObjectId *item, const NAObjectId *new_parent )
gchar *id = NULL;
g_return_val_if_fail( NA_IS_OBJECT_PROFILE( item ), NULL );
- g_return_val_if_fail( item && NA_IS_OBJECT_ACTION( item ), NULL );
+ g_return_val_if_fail( new_parent && NA_IS_OBJECT_ACTION( new_parent ), NULL );
if( !NA_OBJECT_PROFILE( item )->private->dispose_has_run ){
diff --git a/src/runtime/na-object.c b/src/runtime/na-object.c
index 2945ab1..7e2dd92 100644
--- a/src/runtime/na-object.c
+++ b/src/runtime/na-object.c
@@ -589,7 +589,8 @@ do_dump( const NAObject *object )
{
static const char *thisfn = "na_object_do_dump";
- g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
+ g_debug( "%s: object=%p (%s, ref_count=%d)", thisfn,
+ ( void * ) object, G_OBJECT_TYPE_NAME( object ), G_OBJECT( object )->ref_count );
na_iduplicable_dump( NA_IDUPLICABLE( object ));
}
diff --git a/src/runtime/na-pivot.c b/src/runtime/na-pivot.c
index 2a2ad8c..b6d2d4c 100644
--- a/src/runtime/na-pivot.c
+++ b/src/runtime/na-pivot.c
@@ -511,7 +511,7 @@ na_pivot_remove_item( NAPivot *pivot, NAObject *item )
pivot->private->tree = g_list_remove( pivot->private->tree, ( gconstpointer ) item );
- if( NA_IS_OBJECT( item )){
+ if( G_IS_OBJECT( item )){
g_object_unref( item );
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]