[nautilus-actions] Refactoring: properties are renamed
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Refactoring: properties are renamed
- Date: Fri, 11 Feb 2011 00:18:34 +0000 (UTC)
commit 300467291c3e542624109e11706d614ceca096ce
Author: Pierre Wieser <pwieser trychlos org>
Date: Mon Feb 7 06:14:42 2011 +0100
Refactoring: properties are renamed
ChangeLog | 30 ++
src/api/na-iduplicable.h | 5 +-
src/api/na-object-api.h | 6 +-
src/api/na-object.h | 6 +-
src/core/na-iduplicable.c | 116 +++---
src/core/na-object-item.c | 168 +++-----
src/core/na-object.c | 116 ++---
src/io-xml/naxml-reader.c | 4 +-
src/nact/nact-clipboard.c | 2 +-
src/nact/nact-iaction-tab.c | 32 +-
src/nact/nact-ibasenames-tab.c | 9 +-
src/nact/nact-icapabilities-tab.c | 2 +-
src/nact/nact-icommand-tab.c | 14 +-
src/nact/nact-ienvironment-tab.c | 30 +-
src/nact/nact-iexecution-tab.c | 16 +-
src/nact/nact-ifolders-tab.c | 5 +-
src/nact/nact-iproperties-tab.c | 12 +-
src/nact/nact-ischemes-tab.c | 7 +-
src/nact/nact-main-tab.c | 34 --
src/nact/nact-main-tab.h | 9 -
src/nact/nact-main-window.c | 184 +++++----
src/nact/nact-main-window.h | 20 +-
src/nact/nact-match-list.c | 14 +-
src/nact/nact-menubar-edit.c | 15 +-
src/nact/nact-menubar-file.c | 6 +-
src/nact/nact-menubar.c | 3 -
src/nact/nact-tree-ieditable.c | 845 ++++++++++++-------------------------
src/nact/nact-tree-ieditable.h | 9 +-
src/nact/nact-tree-model-dnd.c | 6 +-
src/nact/nact-tree-model.c | 39 +-
src/nact/nact-tree-model.h | 8 +-
src/nact/nact-tree-view.c | 35 +--
src/nact/nact-tree-view.h | 1 -
33 files changed, 728 insertions(+), 1080 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fec2902..280f5e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2011-02-07 Pierre Wieser <pwieser trychlos org>
+
+ * src/api/na-iduplicable.h:
+ * src/core/na-iduplicable.c:
+ Deprecate NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED signal.
+ Define new IDUPLICABLE_SIGNAL_MODIFIED_CHANGED and IDUPLICABLE_SIGNAL_VALID_CHANGED.
+
+ * src/api/na-object-api.h:
+ * src/core/na-object.c:
+ * src/core/na-object-item.c:
+ * src/core/na-object-item.h:
+ Deprecated na_object_check_status_up macro.
+ Merge na_object_item_check_status() and na_object_item_check_status_up().
+
+ * src/nact/nact-iaction-tab.c:
+ * src/nact/nact-ibasenames-tab.c:
+ * src/nact/nact-icapabilities-tab.c:
+ * src/nact/nact-icommand-tab.c:
+ * src/nact/nact-ienvironment-tab.c:
+ * src/nact/nact-iexecution-tab.c:
+ * src/nact/nact-ifolders-tab.c:
+ * src/nact/nact-iproperties-tab.c:
+ * src/nact/nact-ischemes-tab.c:
+ * src/nact/nact-main-window.c:
+ * src/nact/nact-main-window.h:
+ * src/nact/nact-match-list.c: Properties are renamed.
+
+ * src/nact/nact-main-tab.c:
+ * src/nact/nact-main-tab.h (nact_main_tab_get_context): Removed function.
+
2011-02-03 Pierre Wieser <pwieser trychlos org>
In the process of replacing NactIActionsList interface with:
diff --git a/src/api/na-iduplicable.h b/src/api/na-iduplicable.h
index 61b5d47..034674b 100644
--- a/src/api/na-iduplicable.h
+++ b/src/api/na-iduplicable.h
@@ -69,7 +69,7 @@
* <para>
* Check for edition status, which positions modification and validity
* status, is not recursive ; it is the responsability of the
- * implementation to check for edition status of childs of object..
+ * implementation to check for edition status of children of object..
* </para>
* </listitem>
* </itemizedlist>
@@ -184,7 +184,8 @@ typedef struct {
}
NAIDuplicableInterface;
-#define NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED "iduplicable-status-changed"
+#define IDUPLICABLE_SIGNAL_MODIFIED_CHANGED "iduplicable-modified-changed"
+#define IDUPLICABLE_SIGNAL_VALID_CHANGED "iduplicable-valid-changed"
GType na_iduplicable_get_type( void );
diff --git a/src/api/na-object-api.h b/src/api/na-object-api.h
index becbd26..5a622fb 100644
--- a/src/api/na-object-api.h
+++ b/src/api/na-object-api.h
@@ -55,14 +55,14 @@ G_BEGIN_DECLS
/* NAIDuplicable
*/
#define na_object_duplicate( obj ) na_iduplicable_duplicate( NA_IDUPLICABLE( obj ))
-#define na_object_check_status( obj ) na_object_object_check_status( NA_OBJECT( obj ))
-#define na_object_check_status_up( obj ) na_object_object_check_status_up( NA_OBJECT( obj ))
+#define na_object_check_status( obj ) na_object_object_check_status_rec( NA_OBJECT( obj ))
#define na_object_get_origin( obj ) na_iduplicable_get_origin( NA_IDUPLICABLE( obj ))
#define na_object_is_valid( obj ) na_iduplicable_is_valid( NA_IDUPLICABLE( obj ))
#define na_object_is_modified( obj ) na_iduplicable_is_modified( NA_IDUPLICABLE( obj ))
#define na_object_set_origin( obj, origin ) na_iduplicable_set_origin( NA_IDUPLICABLE( obj ), ( NAIDuplicable * )( origin ))
+#define na_object_set_modified( obj, modified ) na_iduplicable_set_modified( NA_IDUPLICABLE( obj ), ( modified ))
#define na_object_reset_origin( obj, origin ) na_object_object_reset_origin( NA_OBJECT( obj ), ( NAObject * )( origin ))
/* NAObject
@@ -131,7 +131,7 @@ G_BEGIN_DECLS
#define na_object_remove_item( obj, child ) na_object_item_remove_item( NA_OBJECT_ITEM( obj ), NA_OBJECT_ID( child ))
#define na_object_get_items_count( obj ) na_object_item_get_items_count( NA_OBJECT_ITEM( obj ))
-#define na_object_count_items( list, cm, ca, cp, brec ) na_object_item_count_items( list, ( cm ), ( ca ), ( cp ), ( brec ))
+#define na_object_count_items( list, cm, ca, cp ) na_object_item_count_items( list, ( cm ), ( ca ), ( cp ), TRUE )
#define na_object_copyref_items( tree ) na_object_item_copyref_items( tree )
#define na_object_free_items( tree ) na_object_item_free_items( tree )
diff --git a/src/api/na-object.h b/src/api/na-object.h
index 257b973..4c77cef 100644
--- a/src/api/na-object.h
+++ b/src/api/na-object.h
@@ -40,6 +40,9 @@
* This is the base class of all our data object hierarchy. #NAObject is
* supposed to be used as a pure virtual base class, i.e. should only be
* derived.
+ *
+ * All the API described here is rather private. External code should
+ * use the API described in <na-object-api.h>.
*/
#include <glib-object.h>
@@ -159,8 +162,7 @@ typedef struct {
GType na_object_object_get_type( void );
-void na_object_object_check_status ( const NAObject *object );
-gboolean na_object_object_check_status_up( const NAObject *object );
+void na_object_object_check_status_rec( const NAObject *object );
void na_object_object_reset_origin ( NAObject *object, const NAObject *origin );
diff --git a/src/core/na-iduplicable.c b/src/core/na-iduplicable.c
index ef30b75..316b357 100644
--- a/src/core/na-iduplicable.c
+++ b/src/core/na-iduplicable.c
@@ -54,7 +54,8 @@ typedef struct {
/* signals emitted on NAIDuplicable when a status changes
*/
enum {
- STATUS_CHANGED,
+ MODIFIED_CHANGED,
+ VALID_CHANGED,
LAST_SIGNAL
};
@@ -73,8 +74,9 @@ static gboolean v_is_valid( const NAIDuplicable *object );
static DuplicableStr *get_duplicable_str( const NAIDuplicable *object );
-static void on_status_changed_class_handler( NAIDuplicable *instance );
-static void propagate_signal_to_consumers( NAIDuplicable *instance, const gchar *signal );
+static void on_modified_changed_class_handler( NAIDuplicable *instance, gboolean is_modified );
+static void on_valid_changed_class_handler( NAIDuplicable *instance, gboolean is_valid );
+static void propagate_signal_to_consumers( NAIDuplicable *instance, const gchar *signal, gboolean new_status );
static void release_signal_consumers( GList *consumers );
GType
@@ -134,29 +136,56 @@ interface_base_init( NAIDuplicableInterface *klass )
klass->is_valid = NULL;
/**
- * NAIDuplicable::status-changed:
+ * NAIDuplicable::modified-changed:
*
* This signal is emitted by #NAIDuplicable when the modification
- * or the validity status of an object has been modified.
+ * status of an object has been modified.
*
* The default class handler propagates the signal to registered
* consumers.
*
- * Signal args: None
+ * Signal args: New modification status
*
* Handler prototype:
- * void ( *handler )( NAIDuplicable *duplicable, gpointer user_data );
+ * void ( *handler )( NAIDuplicable *duplicable, gboolean is_modified, gpointer user_data );
*/
- st_signals[ STATUS_CHANGED ] = g_signal_new_class_handler(
- NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED,
+ st_signals[ MODIFIED_CHANGED ] = g_signal_new_class_handler(
+ IDUPLICABLE_SIGNAL_MODIFIED_CHANGED,
G_TYPE_OBJECT,
G_SIGNAL_RUN_LAST,
- G_CALLBACK( on_status_changed_class_handler ),
+ G_CALLBACK( on_modified_changed_class_handler ),
NULL,
NULL,
- g_cclosure_marshal_VOID__VOID,
+ g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE,
- 0 );
+ 1,
+ G_TYPE_BOOLEAN );
+
+ /**
+ * NAIDuplicable::valid-changed:
+ *
+ * This signal is emitted by #NAIDuplicable when the validity
+ * status of an object has been modified.
+ *
+ * The default class handler propagates the signal to registered
+ * consumers.
+ *
+ * Signal args: Newvalidity status
+ *
+ * Handler prototype:
+ * void ( *handler )( NAIDuplicable *duplicable, gboolean is_valid, gpointer user_data );
+ */
+ st_signals[ VALID_CHANGED ] = g_signal_new_class_handler(
+ IDUPLICABLE_SIGNAL_VALID_CHANGED,
+ G_TYPE_OBJECT,
+ G_SIGNAL_RUN_LAST,
+ G_CALLBACK( on_valid_changed_class_handler ),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_BOOLEAN );
st_interface = klass;
@@ -307,7 +336,7 @@ na_iduplicable_duplicate( const NAIDuplicable *object )
* That is, the modification and validity status are only set on the
* specified object.
* #NAObject implementation has chosen to handle itself the recursivity:
- * na_object_check_status() so first check status for childs, before
+ * na_object_check_status() so first check status for children, before
* calling this function.
*
* Since: 2.30
@@ -318,7 +347,6 @@ na_iduplicable_check_status( const NAIDuplicable *object )
static const gchar *thisfn = "na_iduplicable_check_status";
DuplicableStr *str;
gboolean was_modified, was_valid;
- gboolean changed;
g_return_if_fail( NA_IS_IDUPLICABLE( object ));
@@ -330,7 +358,6 @@ na_iduplicable_check_status( const NAIDuplicable *object )
was_modified = str->modified;
was_valid = str->valid;
- changed = FALSE;
if( str->origin ){
g_debug( "%s: vs. origin=%p (%s)", thisfn, ( void * ) str->origin, G_OBJECT_TYPE_NAME( str->origin ));
@@ -341,37 +368,19 @@ na_iduplicable_check_status( const NAIDuplicable *object )
str->modified = TRUE;
}
- str->valid = v_is_valid( object );
-
- if( was_modified && !str->modified ){
- g_debug( "%s: %p (%s) status changed to non-modified",
- thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
- changed = TRUE;
- } else if ( !was_modified && str->modified ){
- g_debug( "%s: %p (%s) status changed to modified",
- thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
- changed = TRUE;
+ if( was_modified != str->modified ){
+ g_debug( "%s: %p (%s) status changed to modified=%s",
+ thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ), str->modified ? "True":"False" );
+ g_signal_emit_by_name( G_OBJECT( object ), IDUPLICABLE_SIGNAL_MODIFIED_CHANGED, str->modified );
}
- if( was_valid && !str->valid ){
- g_debug( "%s: %p (%s) status changed to non-valid",
- thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
- changed = TRUE;
- } else if( !was_valid && str->valid ){
- g_debug( "%s: %p (%s) status changed to valid",
- thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
- changed = TRUE;
- }
+ str->valid = v_is_valid( object );
- if( changed ){
- g_signal_emit_by_name( G_OBJECT( object ), NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED );
+ if( was_valid != str->valid ){
+ g_debug( "%s: %p (%s) status changed to valid=%s",
+ thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ), str->valid ? "True":"False" );
+ g_signal_emit_by_name( G_OBJECT( object ), IDUPLICABLE_SIGNAL_VALID_CHANGED, str->valid );
}
-
-#if 0
- g_debug( "%s: object=%p (%s), modified=%s, valid=%s", thisfn,
- ( void * ) object, G_OBJECT_TYPE_NAME( object ),
- modified ? "True":"False", valid ? "True":"False" );
-#endif
}
}
@@ -508,11 +517,7 @@ na_iduplicable_set_modified( NAIDuplicable *object, gboolean modified )
if( st_initialized && !st_finalized ){
str = get_duplicable_str( object );
-
- if( str->modified != modified ){
- str->modified = modified;
- g_signal_emit_by_name( G_OBJECT( object ), NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED );
- }
+ str->modified = modified;
}
}
@@ -567,18 +572,19 @@ na_iduplicable_register_consumer( GObject *consumer )
}
static void
-on_status_changed_class_handler( NAIDuplicable *instance )
+on_modified_changed_class_handler( NAIDuplicable *instance, gboolean is_modified )
{
- /*
- static const gchar *thisfn = "na_iduplicable_on_status_changed_class_handler";
- g_debug( "%s: instance=%p (%s)", thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ));
- */
+ propagate_signal_to_consumers( instance, IDUPLICABLE_SIGNAL_MODIFIED_CHANGED, is_modified );
+}
- propagate_signal_to_consumers( instance, NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED );
+static void
+on_valid_changed_class_handler( NAIDuplicable *instance, gboolean is_valid )
+{
+ propagate_signal_to_consumers( instance, IDUPLICABLE_SIGNAL_VALID_CHANGED, is_valid );
}
static void
-propagate_signal_to_consumers( NAIDuplicable *instance, const gchar *signal )
+propagate_signal_to_consumers( NAIDuplicable *instance, const gchar *signal, gboolean new_status )
{
static const gchar *thisfn = "na_iduplicable_propagate_signals_to_consumers";
GList *ic;
@@ -589,7 +595,7 @@ propagate_signal_to_consumers( NAIDuplicable *instance, const gchar *signal )
g_debug( "%s: instance=%p, signal=%s", thisfn, ( void * ) instance, signal );
for( ic = st_interface->private->consumers ; ic ; ic = ic->next ){
- g_signal_emit_by_name( ic->data, signal );
+ g_signal_emit_by_name( ic->data, signal, new_status );
}
}
}
diff --git a/src/core/na-object-item.c b/src/core/na-object-item.c
index e9dc935..e83ede5 100644
--- a/src/core/na-object-item.c
+++ b/src/core/na-object-item.c
@@ -71,18 +71,20 @@ struct _NAObjectItemPrivate {
static NAObjectIdClass *st_parent_class = NULL;
-static GType register_type( void );
-static void class_init( NAObjectItemClass *klass );
-static void instance_init( GTypeInstance *instance, gpointer klass );
-static void instance_dispose( GObject *object );
-static void instance_finalize( GObject *object );
+static GType register_type( void );
+static void class_init( NAObjectItemClass *klass );
+static void instance_init( GTypeInstance *instance, gpointer klass );
+static void instance_dispose( GObject *object );
+static void instance_finalize( GObject *object );
-static void object_copy( NAObject*target, const NAObject *source, gboolean recursive );
-static void object_dump( const NAObject *object );
+static void object_copy( NAObject*target, const NAObject *source, gboolean recursive );
+static void object_dump( const NAObject *object );
-static gchar *object_id_new_id( const NAObjectId *item, const NAObjectId *new_parent );
+static gchar *object_id_new_id( const NAObjectId *item, const NAObjectId *new_parent );
-static void copy_children( NAObjectItem *target, const NAObjectItem *source );
+static void count_items_rec( GList *items, gint *menus, gint *actions, gint *profiles, gboolean recurse );
+static GSList *get_children_slist( const NAObjectItem *item );
+static void copy_children( NAObjectItem *target, const NAObjectItem *source );
GType
na_object_item_get_type( void )
@@ -316,13 +318,10 @@ object_id_new_id( const NAObjectId *item, const NAObjectId *new_parent )
gboolean
na_object_item_are_equal( const NAObjectItem *a, const NAObjectItem *b )
{
- static const gchar *thisfn = "na_object_item_are_equal";
+ /*static const gchar *thisfn = "na_object_item_are_equal";*/
gboolean equal;
- GList *a_children, *b_children, *it;
- gchar *first_id, *second_id;
- NAObjectId *first_obj, *second_obj;
- gint first_pos, second_pos;
- GList *second_list;
+ GSList *a_slist, *b_slist;
+ gchar *a_list, *b_list;
g_return_val_if_fail( NA_IS_OBJECT_ITEM( a ), FALSE );
g_return_val_if_fail( NA_IS_OBJECT_ITEM( b ), FALSE );
@@ -332,81 +331,18 @@ na_object_item_are_equal( const NAObjectItem *a, const NAObjectItem *b )
if( !NA_OBJECT_ITEM( a )->private->dispose_has_run &&
!NA_OBJECT_ITEM( b )->private->dispose_has_run ){
- equal = TRUE;
-
- if( equal ){
- a_children = na_object_get_items( a );
- b_children = na_object_get_items( b );
- equal = ( g_list_length( a_children ) == g_list_length( b_children ));
- if( !equal ){
- g_debug( "%s: %p (%s) not equal as g_list_length not equal",
- thisfn, ( void * ) b, G_OBJECT_TYPE_NAME( b ));
- g_debug( "a=%p children_count=%u", ( void * ) a, g_list_length( a_children ));
- for( it = a_children ; it ; it = it->next ){
- g_debug( "a_child=%p", ( void * ) it->data );
- }
- g_debug( "b=%p children_count=%u", ( void * ) b, g_list_length( b_children ));
- for( it = b_children ; it ; it = it->next ){
- g_debug( "b_child=%p", ( void * ) it->data );
- }
- }
- }
+ a_slist = get_children_slist( a );
+ a_list = na_core_utils_slist_join_at_end( a_slist, ";" );
+ na_core_utils_slist_free( a_slist );
- if( equal ){
- for( it = a_children ; it && equal ; it = it->next ){
- first_id = na_object_get_id( it->data );
- second_obj = na_object_get_item( b, first_id );
- first_pos = -1;
- second_pos = -1;
-
- if( second_obj ){
- first_pos = g_list_position( a_children, it );
- second_list = g_list_find( b_children, second_obj );
- second_pos = g_list_position( b_children, second_list );
-
- if( first_pos != second_pos ){
- equal = FALSE;
- g_debug( "%s: %p (%s) not equal as child %s is at pos %u",
- thisfn, ( void * ) b, G_OBJECT_TYPE_NAME( b ), first_id, second_pos );
- }
-
- } else {
- equal = FALSE;
- g_debug( "%s: %p (%s) not equal as child %s removed",
- thisfn, ( void * ) b, G_OBJECT_TYPE_NAME( b ), first_id );
- }
+ b_slist = get_children_slist( b );
+ b_list = na_core_utils_slist_join_at_end( b_slist, ";" );
+ na_core_utils_slist_free( b_slist );
- g_free( first_id );
- }
- }
-
- if( equal ){
- for( it = b_children ; it && equal ; it = it->next ){
- second_id = na_object_get_id( it->data );
- first_obj = na_object_get_item( a, second_id );
-
- if( !first_obj ){
- equal = FALSE;
- g_debug( "%s: %p (%s) not equal as child %s added",
- thisfn, ( void * ) b, G_OBJECT_TYPE_NAME( b ), second_id );
+ equal = ( strcmp( a_list, b_list ) == 0 );
- } else {
- equal = !na_object_is_modified( it->data );
-
- if( !equal ){
- g_debug( "%s: %p (%s) not equal as child %s modified",
- thisfn, ( void * ) b, G_OBJECT_TYPE_NAME( b ), second_id );
- }
- }
-
- g_free( second_id );
- }
- }
-
- /*g_debug( "na_object_item_object_are_equal: a=%p (%s), b=%p (%s), are_equal=%s",
- ( void * ) a, G_OBJECT_TYPE_NAME( a ),
- ( void * ) b, G_OBJECT_TYPE_NAME( b ),
- equal ? "True":"False" );*/
+ g_free( a_list );
+ g_free( b_list );
}
return( equal );
@@ -427,7 +363,7 @@ na_object_item_are_equal( const NAObjectItem *a, const NAObjectItem *b )
NAObjectId *
na_object_item_get_item( const NAObjectItem *item, const gchar *id )
{
- GList *childs, *it;
+ GList *children, *it;
NAObjectId *found = NULL;
NAObjectId *isub;
gchar *isubid;
@@ -436,8 +372,8 @@ na_object_item_get_item( const NAObjectItem *item, const gchar *id )
if( !item->private->dispose_has_run ){
- childs = na_object_get_items( item );
- for( it = childs ; it && !found ; it = it->next ){
+ children = na_object_get_items( item );
+ for( it = children ; it && !found ; it = it->next ){
isub = NA_OBJECT_ID( it->data );
isubid = na_object_get_id( isub );
if( !strcmp( id, isubid )){
@@ -646,15 +582,15 @@ guint
na_object_item_get_items_count( const NAObjectItem *item )
{
guint count = 0;
- GList *childs;
+ GList *children;
/*g_debug( "na_object_item_get_items_count: item=%p (%s)", ( void * ) item, G_OBJECT_TYPE_NAME( item ));*/
g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), 0 );
if( !item->private->dispose_has_run ){
- childs = na_object_get_items( item );
- count = childs ? g_list_length( childs ) : 0;
+ children = na_object_get_items( item );
+ count = children ? g_list_length( children ) : 0;
}
return( count );
@@ -679,17 +615,24 @@ na_object_item_get_items_count( const NAObjectItem *item )
void
na_object_item_count_items( GList *items, gint *menus, gint *actions, gint *profiles, gboolean recurse )
{
- GList *it;
+ *menus = 0;
+ *actions = 0;
+ *profiles = 0;
- /*g_debug( "na_object_item_count_items: items=%p (count=%d), menus=%d, actions=%d, profiles=%d",
- ( void * ) items, items ? g_list_length( items ) : 0, *menus, *actions, *profiles );*/
+ count_items_rec( items, menus, actions, profiles, recurse );
+}
+
+static void
+count_items_rec( GList *items, gint *menus, gint *actions, gint *profiles, gboolean recurse )
+{
+ GList *it;
for( it = items ; it ; it = it->next ){
if( recurse ){
if( NA_IS_OBJECT_ITEM( it->data )){
GList *subitems = na_object_get_items( it->data );
- na_object_count_items( subitems, menus, actions, profiles, recurse );
+ count_items_rec( subitems, menus, actions, profiles, recurse );
}
}
@@ -797,26 +740,35 @@ void
na_object_item_rebuild_children_slist( NAObjectItem *item )
{
GSList *slist;
- GList *subitems, *it;
- gchar *id;
na_object_set_items_slist( item, NULL );
if( !item->private->dispose_has_run ){
- subitems = na_object_get_items( item );
- slist = NULL;
+ slist = get_children_slist( item );
+ na_object_set_items_slist( item, slist );
+ na_core_utils_slist_free( slist );
+ }
+}
- for( it = subitems ; it ; it = it->next ){
- id = na_object_get_id( it->data );
- slist = g_slist_prepend( slist, id );
- }
- slist = g_slist_reverse( slist );
+/*
+ */
+static GSList *
+get_children_slist( const NAObjectItem *item )
+{
+ GSList *slist;
+ GList *subitems, *it;
+ gchar *id;
- na_object_set_items_slist( item, slist );
+ slist = NULL;
+ subitems = na_object_get_items( item );
- na_core_utils_slist_free( slist );
+ for( it = subitems ; it ; it = it->next ){
+ id = na_object_get_id( it->data );
+ slist = g_slist_prepend( slist, id );
}
+
+ return( g_slist_reverse( slist ));
}
static void
diff --git a/src/core/na-object.c b/src/core/na-object.c
index dfe7a8e..b089221 100644
--- a/src/core/na-object.c
+++ b/src/core/na-object.c
@@ -83,7 +83,8 @@ static gboolean iduplicable_are_equal_iter( GObjectClass *class, const NAObject
static gboolean iduplicable_is_valid( const NAIDuplicable *object );
static gboolean iduplicable_is_valid_iter( GObjectClass *class, const NAObject *a, HierarchyIter *str );
-static void push_modified_status_up( const NAObject *object, gboolean is_modified );
+static void check_status_down_rec( const NAObject *object );
+static void check_status_up_rec( const NAObject *object, gboolean was_modified, gboolean was_valid );
static gboolean object_copy_iter( GObjectClass *class, const NAObject *source, CopyIter *data );
static gboolean dump_class_hierarchy_iter( GObjectClass *class, const NAObject *object, void *user_data );
static void dump_tree( GList *tree, gint level );
@@ -359,16 +360,16 @@ iduplicable_is_valid_iter( GObjectClass *class, const NAObject *a, HierarchyIter
}
/**
- * na_object_object_check_status:
+ * na_object_object_check_status_rec:
* @object: the #NAObject -derived object to be checked.
*
- * Recursively checks for the edition status of @object and its childs
+ * Recursively checks for the edition status of @object and its children
* (if any).
*
* Internally set some properties which may be requested later. This
* two-steps check-request let us optimize some work in the UI.
*
- * na_object_object_check_status( object )
+ * na_object_object_check_status_rec( object )
* +- na_iduplicable_check_status( object )
* +- get_origin( object )
* +- modified_status = v_are_equal( origin, object ) -> interface <structfield>NAObjectClass::are_equal</structfield>
@@ -378,94 +379,69 @@ iduplicable_is_valid_iter( GObjectClass *class, const NAObject *a, HierarchyIter
* that edition status of children is actually checked before those of
* the parent.
*
+ * As of 3.1.0:
+ * - when the modification status of a NAObjectProfile changes, then its
+ * NAObjectAction parent is rechecked;
+ * - when the validity status of an object is changed, then its parent is
+ * also rechecked.
+ *
* Since: 2.30
*/
void
-na_object_object_check_status( const NAObject *object )
+na_object_object_check_status_rec( const NAObject *object )
{
- static const gchar *thisfn = "na_object_object_check_status";
+ static const gchar *thisfn = "na_object_object_check_status_rec";
+ gboolean was_modified, was_valid;
g_return_if_fail( NA_IS_OBJECT( object ));
if( !object->private->dispose_has_run ){
g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
- if( NA_IS_OBJECT_ITEM( object )){
- g_list_foreach( na_object_get_items( object ), ( GFunc ) na_object_object_check_status, NULL );
- }
-
- na_iduplicable_check_status( NA_IDUPLICABLE( object ));
+ was_modified = na_object_is_modified( object );
+ was_valid = na_object_is_valid( object );
+ check_status_down_rec( object );
+ check_status_up_rec( object, was_modified, was_valid );
}
}
-/**
- * na_object_object_check_status_up:
- * @object: the object at the start of the hierarchy.
- *
- * Checks for modification and validity status of the @object, its
- * parent, the parent of its parent, etc. up to the top of the hierarchy.
- *
- * Checking the modification of any of the status should be more
- * efficient that systematically force the display of the item.
- *
- * Returns: %TRUE if at least one of the status has changed, %FALSE else.
- *
- * Since: 2.30
+/*
+ * recursively checks the status downstream
*/
-gboolean
-na_object_object_check_status_up( const NAObject *object )
+static void
+check_status_down_rec( const NAObject *object )
{
- gboolean changed;
- gboolean was_modified, is_modified;
- gboolean was_valid, is_valid;
- NAObjectItem *parent;
-
- g_return_val_if_fail( NA_OBJECT( object ), FALSE );
-
- changed = FALSE;
-
- if( !object->private->dispose_has_run ){
+ if( NA_IS_OBJECT_ITEM( object )){
+ g_list_foreach( na_object_get_items( object ), ( GFunc ) check_status_down_rec, NULL );
+ }
- was_modified = na_object_is_modified( object );
- was_valid = na_object_is_valid( object );
+ na_iduplicable_check_status( NA_IDUPLICABLE( object ));
+}
- na_iduplicable_check_status( NA_IDUPLICABLE( object ));
+/*
+ * if the status appears changed, then rechecks the parent
+ * recurse upstream while there is a parent, and its status changes
+ */
+static void
+check_status_up_rec( const NAObject *object, gboolean was_modified, gboolean was_valid )
+{
+ gboolean is_modified, is_valid;
+ NAObjectItem *parent;
- is_modified = na_object_is_modified( object );
- is_valid = na_object_is_valid( object );
+ is_modified = na_object_is_modified( object );
+ is_valid = na_object_is_valid( object );
- /* if a child becomes modified, then we can safely push this 'modified'
- * status up to all its parent hierarchy
- */
- if( !was_modified && is_modified ){
- push_modified_status_up( object, is_modified );
- }
+ if(( NA_IS_OBJECT_PROFILE( object ) && was_modified != is_modified ) ||
+ was_valid != is_valid ){
- /* but if a child becomes non modified, or its validity status changes,
- * then we have to recompute these status for all the parent hierarchy
- */
- changed = (( was_valid && !is_valid ) ||
- ( !was_valid && is_valid ) ||
- ( was_modified && !is_modified ));
-
- if( changed ){
parent = na_object_get_parent( object );
+
if( parent ){
- na_object_check_status_up( parent );
+ was_modified = na_object_is_modified( parent );
+ was_valid = na_object_is_valid( parent );
+ na_iduplicable_check_status( NA_IDUPLICABLE( parent ));
+ check_status_up_rec( NA_OBJECT( parent ), was_modified, was_valid );
}
- }
- }
-
- return( changed );
-}
-
-static void
-push_modified_status_up( const NAObject *object, gboolean is_modified )
-{
- NAObject *parent = ( NAObject * ) na_object_get_parent( object );
- if( parent ){
- na_iduplicable_set_modified( NA_IDUPLICABLE( parent ), is_modified );
- push_modified_status_up( parent, is_modified );
}
}
@@ -521,7 +497,7 @@ object_copy_iter( GObjectClass *class, const NAObject *source, CopyIter *data )
*
* The recursivity is dealt with here because, if we would let
* #NAObjectItem do this, the dump of #NAObjectItem -derived object
- * would be splitted, childs being inserted inside.
+ * would be splitted, children being inserted inside.
*
* na_object_dump() doesn't modify the reference count of the dumped
* object.
diff --git a/src/io-xml/naxml-reader.c b/src/io-xml/naxml-reader.c
index 2051fdc..e897f59 100644
--- a/src/io-xml/naxml-reader.c
+++ b/src/io-xml/naxml-reader.c
@@ -474,8 +474,8 @@ iter_on_root_children( NAXMLReader *reader, xmlNode *root )
* this first pass is also used to check nodes
*
* - for each node, check that
- * > 'schema/entry' childs are in the list of known schema/entry child nodes
- * > 'schema/entry' childs appear only once per node
+ * > 'schema/entry' children are in the list of known schema/entry child nodes
+ * > 'schema/entry' children appear only once per node
* -> this requires a per-node 'found' flag which is reset for each node
* > schema has an 'applyto' child node
* -> only checkable at the end of the schema
diff --git a/src/nact/nact-clipboard.c b/src/nact/nact-clipboard.c
index 5832d59..e2dffb9 100644
--- a/src/nact/nact-clipboard.c
+++ b/src/nact/nact-clipboard.c
@@ -685,7 +685,7 @@ nact_clipboard_primary_set( NactClipboard *clipboard, GList *items, gint mode )
clear_primary_clipboard( clipboard );
}
- na_object_count_items( items,
+ na_object_item_count_items( items,
( gint * ) &user_data->nb_menus,
( gint * ) &user_data->nb_actions,
( gint * ) &user_data->nb_profiles,
diff --git a/src/nact/nact-iaction-tab.c b/src/nact/nact-iaction-tab.c
index 62b6fe7..ecec9f8 100644
--- a/src/nact/nact-iaction-tab.c
+++ b/src/nact/nact-iaction-tab.c
@@ -391,8 +391,8 @@ on_main_selection_changed( NactIActionTab *instance, GList *selected_items, gpoi
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
- TAB_UPDATABLE_PROP_EDITABLE, &editable,
+ MAIN_PROP_ITEM, &item,
+ MAIN_PROP_EDITABLE, &editable,
NULL );
target_selection =
@@ -491,8 +491,8 @@ on_target_selection_toggled( GtkToggleButton *button, NactIActionTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
- TAB_UPDATABLE_PROP_EDITABLE, &editable,
+ MAIN_PROP_ITEM, &item,
+ MAIN_PROP_EDITABLE, &editable,
NULL );
g_debug( "%s: item=%p (%s), editable=%s",
@@ -529,8 +529,8 @@ on_target_location_toggled( GtkToggleButton *button, NactIActionTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
- TAB_UPDATABLE_PROP_EDITABLE, &editable,
+ MAIN_PROP_ITEM, &item,
+ MAIN_PROP_EDITABLE, &editable,
NULL );
g_debug( "%s: item=%p (%s), editable=%s",
@@ -571,7 +571,7 @@ check_for_label( NactIActionTab *instance, GtkEntry *entry, const gchar *label )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
+ MAIN_PROP_ITEM, &item,
NULL );
if( item && g_utf8_strlen( label, -1 ) == 0 ){
@@ -595,7 +595,7 @@ on_label_changed( GtkEntry *entry, NactIActionTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
+ MAIN_PROP_ITEM, &item,
NULL );
if( item ){
@@ -645,8 +645,8 @@ on_target_toolbar_toggled( GtkToggleButton *button, NactIActionTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
- TAB_UPDATABLE_PROP_EDITABLE, &editable,
+ MAIN_PROP_ITEM, &item,
+ MAIN_PROP_EDITABLE, &editable,
NULL );
g_debug( "%s: item=%p (%s), editable=%s",
@@ -686,8 +686,8 @@ on_toolbar_same_label_toggled( GtkToggleButton *button, NactIActionTab *instance
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
- TAB_UPDATABLE_PROP_EDITABLE, &editable,
+ MAIN_PROP_ITEM, &item,
+ MAIN_PROP_EDITABLE, &editable,
NULL );
g_debug( "%s: item=%p (%s), editable=%s",
@@ -757,7 +757,7 @@ on_toolbar_label_changed( GtkEntry *entry, NactIActionTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
+ MAIN_PROP_ITEM, &item,
NULL );
if( item && NA_IS_OBJECT_ACTION( item )){
@@ -788,7 +788,7 @@ on_tooltip_changed( GtkEntry *entry, NactIActionTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
+ MAIN_PROP_ITEM, &item,
NULL );
if( item ){
@@ -810,7 +810,7 @@ on_icon_browse( GtkButton *button, NactIActionTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
+ MAIN_PROP_ITEM, &item,
NULL );
if( item ){
@@ -841,7 +841,7 @@ on_icon_changed( GtkEntry *icon_entry, NactIActionTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
+ MAIN_PROP_ITEM, &item,
NULL );
if( item ){
diff --git a/src/nact/nact-ibasenames-tab.c b/src/nact/nact-ibasenames-tab.c
index c966b30..da198ba 100644
--- a/src/nact/nact-ibasenames-tab.c
+++ b/src/nact/nact-ibasenames-tab.c
@@ -246,7 +246,10 @@ on_main_selection_changed( BaseWindow *window, GList *selected_items, gpointer u
if( st_initialized && !st_finalized ){
count_selected = g_list_length( selected_items );
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( window ), &editable );
+
+ g_object_get( G_OBJECT( window ),
+ MAIN_PROP_CONTEXT, &context, MAIN_PROP_EDITABLE, &editable,
+ NULL );
st_on_selection_change = TRUE;
@@ -269,7 +272,9 @@ on_matchcase_toggled( GtkToggleButton *button, BaseWindow *window )
gboolean matchcase;
if( !st_on_selection_change ){
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( window ), &editable );
+ g_object_get( G_OBJECT( window ),
+ MAIN_PROP_CONTEXT, &context, MAIN_PROP_EDITABLE, &editable,
+ NULL );
if( context ){
matchcase = gtk_toggle_button_get_active( button );
diff --git a/src/nact/nact-icapabilities-tab.c b/src/nact/nact-icapabilities-tab.c
index 58fb475..32fa859 100644
--- a/src/nact/nact-icapabilities-tab.c
+++ b/src/nact/nact-icapabilities-tab.c
@@ -218,7 +218,7 @@ on_add_clicked( GtkButton *button, BaseWindow *window )
GSList *capabilities;
gchar *new_cap;
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( window ), NULL );
+ g_object_get( G_OBJECT( window ), MAIN_PROP_CONTEXT, &context, NULL );
if( context ){
capabilities = nact_match_list_get_rows( window, ITAB_NAME );
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index 0c52c18..7c5f4b9 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -353,8 +353,8 @@ on_main_selection_changed( NactICommandTab *instance, GList *selected_items, gpo
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
- TAB_UPDATABLE_PROP_EDITABLE, &editable,
+ MAIN_PROP_PROFILE, &profile,
+ MAIN_PROP_EDITABLE, &editable,
NULL );
enable_tab = ( profile != NULL );
@@ -500,7 +500,7 @@ on_label_changed( GtkEntry *entry, NactICommandTab *instance )
if( !st_on_selection_change ){
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
+ MAIN_PROP_PROFILE, &profile,
NULL );
if( profile ){
@@ -538,7 +538,7 @@ on_parameters_changed( GtkEntry *entry, NactICommandTab *instance )
if( !st_on_selection_change ){
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
+ MAIN_PROP_PROFILE, &profile,
NULL );
if( profile ){
@@ -566,7 +566,7 @@ on_path_changed( GtkEntry *entry, NactICommandTab *instance )
if( !st_on_selection_change ){
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
+ MAIN_PROP_PROFILE, &profile,
NULL );
if( profile ){
@@ -585,7 +585,7 @@ on_wdir_browse( GtkButton *button, NactICommandTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
+ MAIN_PROP_PROFILE, &profile,
NULL );
if( profile ){
@@ -604,7 +604,7 @@ on_wdir_changed( GtkEntry *entry, NactICommandTab *instance )
if( !st_on_selection_change ){
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
+ MAIN_PROP_PROFILE, &profile,
NULL );
if( profile ){
diff --git a/src/nact/nact-ienvironment-tab.c b/src/nact/nact-ienvironment-tab.c
index 69e79d0..49dd865 100644
--- a/src/nact/nact-ienvironment-tab.c
+++ b/src/nact/nact-ienvironment-tab.c
@@ -361,7 +361,9 @@ on_main_selection_changed( NactIEnvironmentTab *instance, GList *selected_items,
g_debug( "%s: instance=%p, selected_items=%p (count=%d)",
thisfn, ( void * ) instance, ( void * ) selected_items, g_list_length( selected_items ));
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( instance ), &editable );
+ g_object_get( G_OBJECT( instance ),
+ MAIN_PROP_CONTEXT, &context, MAIN_PROP_EDITABLE, &editable,
+ NULL );
enable_tab = ( context != NULL );
nact_main_tab_enable_page( NACT_MAIN_WINDOW( instance ), TAB_ENVIRONMENT, enable_tab );
@@ -487,7 +489,7 @@ on_selection_count_changed( NactIEnvironmentTab *instance )
gchar *selcount;
if( !st_on_selection_change ){
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( instance ), NULL );
+ g_object_get( G_OBJECT( instance ), MAIN_PROP_CONTEXT, &context, NULL );
if( context ){
selcount = get_selection_count_selection( instance );
@@ -525,7 +527,9 @@ on_show_always_toggled( GtkToggleButton *toggle_button, NactIEnvironmentTab *ins
( void * ) toggle_button, gtk_toggle_button_get_active( toggle_button ) ? "True":"False",
( void * ) instance );
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( instance ), &editable );
+ g_object_get( G_OBJECT( instance ),
+ MAIN_PROP_CONTEXT, &context, MAIN_PROP_EDITABLE, &editable,
+ NULL );
if( context ){
active = gtk_toggle_button_get_active( toggle_button );
@@ -562,7 +566,9 @@ on_only_show_toggled( GtkToggleButton *toggle_button, NactIEnvironmentTab *insta
( void * ) toggle_button, gtk_toggle_button_get_active( toggle_button ) ? "True":"False",
( void * ) instance );
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( instance ), &editable );
+ g_object_get( G_OBJECT( instance ),
+ MAIN_PROP_CONTEXT, &context, MAIN_PROP_EDITABLE, &editable,
+ NULL );
if( context ){
active = gtk_toggle_button_get_active( toggle_button );
@@ -601,7 +607,9 @@ on_do_not_show_toggled( GtkToggleButton *toggle_button, NactIEnvironmentTab *ins
( void * ) toggle_button, gtk_toggle_button_get_active( toggle_button ) ? "True":"False",
( void * ) instance );
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( instance ), &editable );
+ g_object_get( G_OBJECT( instance ),
+ MAIN_PROP_CONTEXT, &context, MAIN_PROP_EDITABLE, &editable,
+ NULL );
if( context ){
active = gtk_toggle_button_get_active( toggle_button );
@@ -643,7 +651,9 @@ on_desktop_toggled( GtkCellRendererToggle *renderer, gchar *path, BaseWindow *wi
g_debug( "%s: renderer=%p, path=%s, window=%p", thisfn, ( void * ) renderer, path, ( void * ) window );
if( !st_on_selection_change ){
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( window ), &editable );
+ g_object_get( G_OBJECT( window ),
+ MAIN_PROP_CONTEXT, &context, MAIN_PROP_EDITABLE, &editable,
+ NULL );
if( context ){
if( editable ){
@@ -681,7 +691,7 @@ on_try_exec_changed( GtkEntry *entry, NactIEnvironmentTab *instance )
NAIContext *context;
const gchar *text;
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( instance ), NULL );
+ g_object_get( G_OBJECT( instance ), MAIN_PROP_CONTEXT, &context, NULL );
if( context ){
text = gtk_entry_get_text( entry );
@@ -709,7 +719,7 @@ on_show_if_registered_changed( GtkEntry *entry, NactIEnvironmentTab *instance )
NAIContext *context;
const gchar *text;
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( instance ), NULL );
+ g_object_get( G_OBJECT( instance ), MAIN_PROP_CONTEXT, &context, NULL );
if( context ){
text = gtk_entry_get_text( entry );
@@ -724,7 +734,7 @@ on_show_if_true_changed( GtkEntry *entry, NactIEnvironmentTab *instance )
NAIContext *context;
const gchar *text;
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( instance ), NULL );
+ g_object_get( G_OBJECT( instance ), MAIN_PROP_CONTEXT, &context, NULL );
if( context ){
text = gtk_entry_get_text( entry );
@@ -739,7 +749,7 @@ on_show_if_running_changed( GtkEntry *entry, NactIEnvironmentTab *instance )
NAIContext *context;
const gchar *text;
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( instance ), NULL );
+ g_object_get( G_OBJECT( instance ), MAIN_PROP_CONTEXT, &context, NULL );
if( context ){
text = gtk_entry_get_text( entry );
diff --git a/src/nact/nact-iexecution-tab.c b/src/nact/nact-iexecution-tab.c
index 7fa0064..4c7ee87 100644
--- a/src/nact/nact-iexecution-tab.c
+++ b/src/nact/nact-iexecution-tab.c
@@ -245,8 +245,8 @@ on_main_selection_changed( NactIExecutionTab *instance, GList *selected_items, g
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
- TAB_UPDATABLE_PROP_EDITABLE, &editable,
+ MAIN_PROP_PROFILE, &profile,
+ MAIN_PROP_EDITABLE, &editable,
NULL );
enable_tab = ( profile != NULL );
@@ -344,8 +344,8 @@ execution_mode_toggle( NactIExecutionTab *instance, GtkToggleButton *toggle_butt
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
- TAB_UPDATABLE_PROP_EDITABLE, &editable,
+ MAIN_PROP_PROFILE, &profile,
+ MAIN_PROP_EDITABLE, &editable,
NULL );
if( profile ){
@@ -379,8 +379,8 @@ on_startup_notify_toggled( GtkToggleButton *toggle_button, NactIExecutionTab *in
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
- TAB_UPDATABLE_PROP_EDITABLE, &editable,
+ MAIN_PROP_PROFILE, &profile,
+ MAIN_PROP_EDITABLE, &editable,
NULL );
if( profile ){
@@ -406,7 +406,7 @@ on_startup_class_changed( GtkEntry *entry, NactIExecutionTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
+ MAIN_PROP_PROFILE, &profile,
NULL );
if( profile ){
@@ -424,7 +424,7 @@ on_execute_as_changed( GtkEntry *entry, NactIExecutionTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
+ MAIN_PROP_PROFILE, &profile,
NULL );
if( profile ){
diff --git a/src/nact/nact-ifolders-tab.c b/src/nact/nact-ifolders-tab.c
index b3b9129..c8b8fe4 100644
--- a/src/nact/nact-ifolders-tab.c
+++ b/src/nact/nact-ifolders-tab.c
@@ -231,7 +231,10 @@ on_main_selection_changed( NactIFoldersTab *instance, GList *selected_items, gpo
count_selected = g_list_length( selected_items );
nact_match_list_on_selection_changed( BASE_WINDOW( instance ), ITAB_NAME, count_selected );
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( instance ), &editable );
+ g_object_get( G_OBJECT( instance ),
+ MAIN_PROP_CONTEXT, &context, MAIN_PROP_EDITABLE, &editable,
+ NULL );
+
button = base_window_get_widget( BASE_WINDOW( instance ), "FolderBrowseButton" );
base_gtk_utils_set_editable( G_OBJECT( button ), editable );
}
diff --git a/src/nact/nact-iproperties-tab.c b/src/nact/nact-iproperties-tab.c
index 3a37dbe..2dadaad 100644
--- a/src/nact/nact-iproperties-tab.c
+++ b/src/nact/nact-iproperties-tab.c
@@ -245,8 +245,8 @@ on_main_selection_changed( NactIPropertiesTab *instance, GList *selected_items,
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
- TAB_UPDATABLE_PROP_EDITABLE, &editable,
+ MAIN_PROP_ITEM, &item,
+ MAIN_PROP_EDITABLE, &editable,
NULL );
g_return_if_fail( !item || NA_IS_OBJECT_ITEM( item ));
@@ -344,8 +344,8 @@ on_enabled_toggled( GtkToggleButton *button, NactIPropertiesTab *instance )
if( !st_on_selection_change ){
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
- TAB_UPDATABLE_PROP_EDITABLE, &editable,
+ MAIN_PROP_ITEM, &item,
+ MAIN_PROP_EDITABLE, &editable,
NULL );
if( item && NA_IS_OBJECT_ITEM( item )){
@@ -452,7 +452,7 @@ on_description_changed( GtkTextBuffer *buffer, NactIPropertiesTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
+ MAIN_PROP_ITEM, &item,
NULL );
if( item ){
@@ -471,7 +471,7 @@ on_shortcut_clicked( GtkButton *button, NactIPropertiesTab *instance )
g_object_get(
G_OBJECT( instance ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
+ MAIN_PROP_ITEM, &item,
NULL );
if( item ){
diff --git a/src/nact/nact-ischemes-tab.c b/src/nact/nact-ischemes-tab.c
index b716677..3ea89f9 100644
--- a/src/nact/nact-ischemes-tab.c
+++ b/src/nact/nact-ischemes-tab.c
@@ -223,7 +223,10 @@ on_main_selection_changed( BaseWindow *window, GList *selected_items, gpointer u
nact_match_list_on_selection_changed( window, ITAB_NAME, g_list_length( selected_items ));
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( window ), &editable );
+ g_object_get( G_OBJECT( window ),
+ MAIN_PROP_CONTEXT, &context, MAIN_PROP_EDITABLE, &editable,
+ NULL );
+
button = base_window_get_widget( window, "AddFromDefaultButton" );
base_gtk_utils_set_editable( G_OBJECT( button ), editable );
}
@@ -235,7 +238,7 @@ on_add_from_defaults( GtkButton *button, BaseWindow *window )
gchar *new_scheme;
NAIContext *context;
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( window ), NULL );
+ g_object_get( G_OBJECT( window ), MAIN_PROP_CONTEXT, &context, NULL );
g_return_if_fail( context );
schemes = nact_match_list_get_rows( window, ITAB_NAME );
diff --git a/src/nact/nact-main-tab.c b/src/nact/nact-main-tab.c
index c2901c1..3933bcd 100644
--- a/src/nact/nact-main-tab.c
+++ b/src/nact/nact-main-tab.c
@@ -90,37 +90,3 @@ nact_main_tab_is_page_enabled( NactMainWindow *window, gint num_page )
return( is_sensitive );
}
-
-/**
- * nact_main_tab_get_context:
- * @window: the #NactMainWindow.
- * @editable: if not %NULL, will be set with the current editability
- * status of the returned #NAIContext (or of its parent).
- *
- * Returns: the current relevant #NAIContext, or %NULL.
- */
-NAIContext *
-nact_main_tab_get_context( NactMainWindow *window, gboolean *editable )
-{
- NAObjectItem *item;
- NAObjectProfile *profile;
- NAIContext *context;
- gboolean status;
-
- g_return_val_if_fail( NACT_IS_MAIN_WINDOW( window ), NULL );
-
- g_object_get(
- G_OBJECT( window ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
- TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
- TAB_UPDATABLE_PROP_EDITABLE, &status,
- NULL );
-
- context = profile ? NA_ICONTEXT( profile ) : ( NAIContext * ) item;
-
- if( editable ){
- *editable = status;
- }
-
- return( context );
-}
diff --git a/src/nact/nact-main-tab.h b/src/nact/nact-main-tab.h
index 1713a3d..682ea65 100644
--- a/src/nact/nact-main-tab.h
+++ b/src/nact/nact-main-tab.h
@@ -43,13 +43,6 @@
* Here as defined signals and properties common to all tabs.
*/
-/* properties set against the GObject instance
- */
-#define TAB_UPDATABLE_PROP_SELECTED_ITEM "nact-tab-updatable-selected-item"
-#define TAB_UPDATABLE_PROP_SELECTED_PROFILE "nact-tab-updatable-selected-profile"
-#define TAB_UPDATABLE_PROP_EDITABLE "nact-tab-updatable-editable"
-#define TAB_UPDATABLE_PROP_REASON "nact-tab-updatable-reason"
-
/* signals
*/
#define TAB_UPDATABLE_SIGNAL_ITEM_UPDATED "nact-tab-updatable-item-updated"
@@ -74,8 +67,6 @@ enum {
void nact_main_tab_enable_page ( NactMainWindow *window, gint page, gboolean enabled );
gboolean nact_main_tab_is_page_enabled( NactMainWindow *window, gint page );
-NAIContext *nact_main_tab_get_context ( NactMainWindow *window, gboolean *editable );
-
G_END_DECLS
#endif /* __NACT_MAIN_TAB_H__ */
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 8bd6bc4..f96e7f1 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -73,58 +73,69 @@ struct _NactMainWindowPrivate {
NAUpdater *updater;
- /* TODO: this will have to be replaced with undo-manager */
- GList *deleted;
-
/**
- * Currently selected action or menu.
+ * Current action or menu.
*
* This is the action or menu which is displayed in tabs Action/Menu
* and Properties ; it may be different of the exact row being currently
* selected, e.g. when a sub-profile is edited.
*
- * Can be null, and this implies that @selected_profile is also null,
- * e.g. when the list is empty or in case of multiple selection.
+ * Can be null, and this implies that @current_profile is also null,
+ * e.g. when the list is empty or in the case of a multiple selection.
*
- * 'editable' property is computed on selection change;
- * This is the real writability status of the item at this time.
+ * 'editable' property is set on selection change;
+ * This is the actual current writability status of the item at this time.
*/
- NAObjectItem *selected_item;
+ NAObjectItem *current_item;
gboolean editable;
guint reason;
/**
- * Currently selected profile.
+ * Current profile.
*
* This is the profile which is displayed in tab Command;
- * it may be different of the exact row being currently selected.
+ * it may be different of the exact row being currently selected,
+ * e.g. when an action with only one profile is selected.
*
- * Can be null if @selected_item is a menu, or an action with more
- * than one profile and action is selected, or an action without
- * any profile, or the list is empty, or in case of multiple selection.
+ * Can be null if @current_item is a menu, or an action with more
+ * than one profile is selected, or the list is empty, or in the
+ * case of a multiple selection.
*
* In other words, it is not null if:
* a) a profile is selected,
* b) an action is selected and it has exactly one profile.
*/
- NAObjectProfile *selected_profile;
+ NAObjectProfile *current_profile;
+
+ /**
+ * Current context.
+ *
+ * This is the #NAIContext data which corresponds to @current_profile
+ * or @current_item, depending of which one is actually selected.
+ */
+ NAIContext *current_context;
/**
- * Some convenience objects.
+ * Some convenience objects and data.
*/
NactTreeView *items_view;
NactClipboard *clipboard;
guint count_modified;
};
-/* action properties
- * these are set when selection changes as an optimization try
+/* properties set against the main window
+ * these are set on selection changes
*/
enum {
- PROP_EDITED_ITEM = 1,
- PROP_EDITED_PROFILE,
- PROP_EDITABLE,
- PROP_REASON
+ MAIN_PROP_0 = 0,
+
+ MAIN_PROP_ITEM_ID,
+ MAIN_PROP_PROFILE_ID,
+ MAIN_PROP_CONTEXT_ID,
+ MAIN_PROP_EDITABLE_ID,
+ MAIN_PROP_REASON_ID,
+
+ MAIN_PROP_N_PROPERTIES
};
/* signals
@@ -185,8 +196,8 @@ static gboolean on_delete_event( GtkWidget *toplevel, GdkEvent *event, NactMainW
static gboolean warn_modified( NactMainWindow *window );
/* *** */
-static gboolean actually_delete_item( NactMainWindow *window, NAObject *item, NAUpdater *updater, GList **not_deleted, GSList **messages );
#if 0
+static gboolean actually_delete_item( NactMainWindow *window, NAObject *item, NAUpdater *updater, GList **not_deleted, GSList **messages );
static void on_main_window_level_zero_order_changed( NactMainWindow *window, gpointer user_data );
#endif
static void on_tab_updatable_item_updated( NactMainWindow *window, gpointer user_data, gboolean force_display );
@@ -326,7 +337,6 @@ class_init( NactMainWindowClass *klass )
static const gchar *thisfn = "nact_main_window_class_init";
GObjectClass *object_class;
BaseWindowClass *base_class;
- GParamSpec *spec;
g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
@@ -339,33 +349,40 @@ class_init( NactMainWindowClass *klass )
object_class->dispose = instance_dispose;
object_class->finalize = instance_finalize;
- spec = g_param_spec_pointer(
- TAB_UPDATABLE_PROP_SELECTED_ITEM,
- "Edited NAObjectItem",
- "A pointer to the edited NAObjectItem, an action or a menu",
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, PROP_EDITED_ITEM, spec );
-
- spec = g_param_spec_pointer(
- TAB_UPDATABLE_PROP_SELECTED_PROFILE,
- "Edited NAObjectProfile",
- "A pointer to the edited NAObjectProfile",
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, PROP_EDITED_PROFILE, spec );
-
- spec = g_param_spec_boolean(
- TAB_UPDATABLE_PROP_EDITABLE,
- "Editable item ?",
- "Whether the item will be able to be updated against its I/O provider", FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, PROP_EDITABLE, spec );
-
- spec = g_param_spec_int(
- TAB_UPDATABLE_PROP_REASON,
- "No edition reason",
- "Why is this item not editable", 0, 255, 0,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
- g_object_class_install_property( object_class, PROP_REASON, spec );
+ g_object_class_install_property( object_class, MAIN_PROP_ITEM_ID,
+ g_param_spec_pointer(
+ MAIN_PROP_ITEM,
+ "Edited NAObjectItem",
+ "A pointer to the edited NAObjectItem, an action or a menu",
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+
+ g_object_class_install_property( object_class, MAIN_PROP_PROFILE_ID,
+ g_param_spec_pointer(
+ MAIN_PROP_PROFILE,
+ "Edited NAObjectProfile",
+ "A pointer to the edited NAObjectProfile",
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+
+ g_object_class_install_property( object_class, MAIN_PROP_CONTEXT_ID,
+ g_param_spec_pointer(
+ MAIN_PROP_CONTEXT,
+ "Current NAIContext",
+ "The currently edited NAIContext",
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+
+ g_object_class_install_property( object_class, MAIN_PROP_EDITABLE_ID,
+ g_param_spec_boolean(
+ MAIN_PROP_EDITABLE,
+ "Editable item ?",
+ "Whether the item will be able to be updated against its I/O provider", FALSE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+
+ g_object_class_install_property( object_class, MAIN_PROP_REASON_ID,
+ g_param_spec_int(
+ MAIN_PROP_REASON,
+ "No edition reason",
+ "Why is this item not editable", 0, 255, 0,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
klass->private = g_new0( NactMainWindowClassPrivate, 1 );
@@ -583,19 +600,23 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
if( !self->private->dispose_has_run ){
switch( property_id ){
- case PROP_EDITED_ITEM:
- g_value_set_pointer( value, self->private->selected_item );
+ case MAIN_PROP_ITEM_ID:
+ g_value_set_pointer( value, self->private->current_item );
break;
- case PROP_EDITED_PROFILE:
- g_value_set_pointer( value, self->private->selected_profile );
+ case MAIN_PROP_PROFILE_ID:
+ g_value_set_pointer( value, self->private->current_profile );
break;
- case PROP_EDITABLE:
+ case MAIN_PROP_CONTEXT_ID:
+ g_value_set_pointer( value, self->private->current_context );
+ break;
+
+ case MAIN_PROP_EDITABLE_ID:
g_value_set_boolean( value, self->private->editable );
break;
- case PROP_REASON:
+ case MAIN_PROP_REASON_ID:
g_value_set_int( value, self->private->reason );
break;
@@ -617,19 +638,23 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
if( !self->private->dispose_has_run ){
switch( property_id ){
- case PROP_EDITED_ITEM:
- self->private->selected_item = g_value_get_pointer( value );
+ case MAIN_PROP_ITEM_ID:
+ self->private->current_item = g_value_get_pointer( value );
+ break;
+
+ case MAIN_PROP_PROFILE_ID:
+ self->private->current_profile = g_value_get_pointer( value );
break;
- case PROP_EDITED_PROFILE:
- self->private->selected_profile = g_value_get_pointer( value );
+ case MAIN_PROP_CONTEXT_ID:
+ self->private->current_context = g_value_get_pointer( value );
break;
- case PROP_EDITABLE:
+ case MAIN_PROP_EDITABLE_ID:
self->private->editable = g_value_get_boolean( value );
break;
- case PROP_REASON:
+ case MAIN_PROP_REASON_ID:
self->private->reason = g_value_get_int( value );
break;
@@ -707,7 +732,6 @@ instance_dispose( GObject *window )
NactMainWindow *self;
GtkWidget *pane;
gint pos;
- GList *it;
NASettings *settings;
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
@@ -727,11 +751,6 @@ instance_dispose( GObject *window )
pos = gtk_paned_get_position( GTK_PANED( pane ));
na_settings_set_uint( settings, NA_IPREFS_MAIN_PANED, pos );
- for( it = self->private->deleted ; it ; it = it->next ){
- g_debug( "nact_main_window_instance_dispose: deleted=%p (%s)", ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ));
- }
- na_object_free_items( self->private->deleted );
-
nact_sort_buttons_dispose( BASE_WINDOW( self ));
nact_iaction_tab_dispose( NACT_IACTION_TAB( window ));
@@ -1050,8 +1069,9 @@ on_selection_changed_cleanup_handler( BaseWindow *window, GList *selected_items
static void
raz_selection_properties( NactMainWindow *window )
{
- window->private->selected_item = NULL;
- window->private->selected_profile = NULL;
+ window->private->current_item = NULL;
+ window->private->current_profile = NULL;
+ window->private->current_context = NULL;
window->private->editable = FALSE;
window->private->reason = 0;
@@ -1069,19 +1089,21 @@ setup_current_selection( NactMainWindow *window, NAObjectId *selected_row )
GList *profiles;
if( NA_IS_OBJECT_PROFILE( selected_row )){
- window->private->selected_profile = NA_OBJECT_PROFILE( selected_row );
- window->private->selected_item = NA_OBJECT_ITEM( na_object_get_parent( selected_row ));
+ window->private->current_profile = NA_OBJECT_PROFILE( selected_row );
+ window->private->current_context = NA_ICONTEXT( selected_row );
+ window->private->current_item = NA_OBJECT_ITEM( na_object_get_parent( selected_row ));
} else {
g_return_if_fail( NA_IS_OBJECT_ITEM( selected_row ));
- window->private->selected_item = NA_OBJECT_ITEM( selected_row );
+ window->private->current_item = NA_OBJECT_ITEM( selected_row );
+ window->private->current_context = NA_ICONTEXT( selected_row );
if( NA_IS_OBJECT_ACTION( selected_row )){
nb_profiles = na_object_get_items_count( selected_row );
if( nb_profiles == 1 ){
profiles = na_object_get_items( selected_row );
- window->private->selected_profile = NA_OBJECT_PROFILE( profiles->data );
+ window->private->current_profile = NA_OBJECT_PROFILE( profiles->data );
}
}
}
@@ -1108,8 +1130,8 @@ setup_dialog_title( NactMainWindow *window )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
title = base_application_get_application_name( BASE_APPLICATION( application ));
- if( window->private->selected_item ){
- label = na_object_get_label( window->private->selected_item );
+ if( window->private->current_item ){
+ label = na_object_get_label( window->private->current_item );
tmp = g_strdup_printf( "%s - %s", label, title );
g_free( label );
g_free( title );
@@ -1130,9 +1152,9 @@ setup_dialog_title( NactMainWindow *window )
static void
setup_writability_status( NactMainWindow *window )
{
- g_return_if_fail( NA_IS_OBJECT_ITEM( window->private->selected_item ));
+ g_return_if_fail( NA_IS_OBJECT_ITEM( window->private->current_item ));
- window->private->editable = na_updater_is_item_writable( window->private->updater, window->private->selected_item, &window->private->reason );
+ window->private->editable = na_updater_is_item_writable( window->private->updater, window->private->current_item, &window->private->reason );
nact_main_statusbar_set_locked( window, !window->private->editable, window->private->reason );
}
@@ -1233,8 +1255,6 @@ reload_items( NactMainWindow *window )
raz_selection_properties( window );
- window->private->deleted = na_object_free_items( window->private->deleted );
-
tree = na_updater_load_items( window->private->updater );
nact_tree_view_fill( window->private->items_view, tree );
}
@@ -1337,6 +1357,7 @@ warn_modified( NactMainWindow *window )
return( confirm );
}
+#if 0
/**
* nact_main_window_move_to_deleted:
* @window: this #NactMainWindow instance.
@@ -1467,7 +1488,6 @@ actually_delete_item( NactMainWindow *window, NAObject *item, NAUpdater *updater
return( delete_ok );
}
-#if 0
static void
on_main_window_level_zero_order_changed( NactMainWindow *window, gpointer user_data )
{
diff --git a/src/nact/nact-main-window.h b/src/nact/nact-main-window.h
index ede30df..d1d1a0c 100644
--- a/src/nact/nact-main-window.h
+++ b/src/nact/nact-main-window.h
@@ -80,7 +80,19 @@ typedef struct {
}
NactMainWindowClass;
-#define MAIN_SIGNAL_SELECTION_CHANGED "main-selection-changed"
+/**
+ * Signals emitted by the main window
+ */
+#define MAIN_SIGNAL_SELECTION_CHANGED "main-selection-changed"
+
+/**
+ * Properties set against the main window
+ */
+#define MAIN_PROP_ITEM "main-current-item"
+#define MAIN_PROP_PROFILE "main-current-profile"
+#define MAIN_PROP_CONTEXT "main-current-context"
+#define MAIN_PROP_EDITABLE "main-editable"
+#define MAIN_PROP_REASON "main-reason"
#define MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED "main-window-level-zero-order-changed"
@@ -91,11 +103,9 @@ NactMainWindow *nact_main_window_new ( const NactApplication *applicat
NactClipboard *nact_main_window_get_clipboard ( const NactMainWindow *window );
NactTreeView *nact_main_window_get_items_view( const NactMainWindow *window );
-void nact_main_window_move_to_deleted ( NactMainWindow *window, GList *items );
-void nact_main_window_reload ( NactMainWindow *window );
-gboolean nact_main_window_remove_deleted ( NactMainWindow *window, GSList **messages );
+void nact_main_window_reload( NactMainWindow *window );
-gboolean nact_main_window_quit ( NactMainWindow *window );
+gboolean nact_main_window_quit ( NactMainWindow *window );
G_END_DECLS
diff --git a/src/nact/nact-match-list.c b/src/nact/nact-match-list.c
index db5c3f9..f0e1619 100644
--- a/src/nact/nact-match-list.c
+++ b/src/nact/nact-match-list.c
@@ -331,7 +331,9 @@ nact_match_list_on_selection_changed( BaseWindow *window, const gchar *tab_name,
data = ( MatchListStr * ) g_object_get_data( G_OBJECT( window ), tab_name );
g_return_if_fail( data != NULL );
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( window ), &data->editable_item );
+ g_object_get( G_OBJECT( window ),
+ MAIN_PROP_CONTEXT, &context, MAIN_PROP_EDITABLE, &data->editable_item,
+ NULL );
enable_tab = ( context != NULL );
nact_main_tab_enable_page( NACT_MAIN_WINDOW( data->window ), data->tab_id, enable_tab );
@@ -470,7 +472,7 @@ on_filter_edited( GtkCellRendererText *renderer, const gchar *path_str, const gc
g_return_if_fail( data->editable_filter );
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( data->window ), NULL );
+ g_object_get( G_OBJECT( data->window ), MAIN_PROP_CONTEXT, &context, NULL );
g_return_if_fail( NA_IS_ICONTEXT( context ));
model = gtk_tree_view_get_model( data->listview );
@@ -593,7 +595,7 @@ on_must_match_toggled( GtkCellRendererToggle *cell_renderer, gchar *path_str, Ma
if( data->editable_item ){
if( !active ){
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( data->window ), NULL );
+ g_object_get( G_OBJECT( data->window ), MAIN_PROP_CONTEXT, &context, NULL );
g_return_if_fail( NA_IS_ICONTEXT( context ));
set_match_status( path_str, TRUE, FALSE, data );
@@ -645,7 +647,7 @@ on_must_not_match_toggled( GtkCellRendererToggle *cell_renderer, gchar *path_str
if( data->editable_item ){
if( !active ){
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( data->window ), NULL );
+ g_object_get( G_OBJECT( data->window ), MAIN_PROP_CONTEXT, &context, NULL );
g_return_if_fail( NA_IS_ICONTEXT( context ));
set_match_status( path_str, FALSE, TRUE, data );
@@ -693,7 +695,7 @@ add_filter( MatchListStr *data, const gchar *filter, const gchar *prefix )
GSList *filters;
gchar *to_add;
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( data->window ), NULL );
+ g_object_get( G_OBJECT( data->window ), MAIN_PROP_CONTEXT, &context, NULL );
if( context ){
filters = ( *data->pget )( context );
@@ -746,7 +748,7 @@ delete_current_row( MatchListStr *data )
delete_row_at_path( data->listview, model, path );
- context = nact_main_tab_get_context( NACT_MAIN_WINDOW( data->window ), NULL );
+ g_object_get( G_OBJECT( data->window ), MAIN_PROP_CONTEXT, &context, NULL );
if( context ){
filters = ( *data->pget )( context );
diff --git a/src/nact/nact-menubar-edit.c b/src/nact/nact-menubar-edit.c
index e6da878..3d61e31 100644
--- a/src/nact/nact-menubar-edit.c
+++ b/src/nact/nact-menubar-edit.c
@@ -177,6 +177,15 @@ nact_menubar_edit_on_update_sensitivities( const NactMenubar *bar )
* @gtk_action: the #GtkAction action.
* @window: the #BaseWindow main window.
*
+ * Cut objects are installed both in the clipboard and in the deleted list.
+ * Parent pointer is reset to %NULL.
+ * Old parent status is re-checked by the tree model delete operation.
+ * When pasting later these cut objects:
+ * - the first time, we paste the very same object, removing it from the
+ * deleted list, attaching it to a new parent
+ * the object itself is not modified, but the parent is.
+ * - the following times, we paste a copy of this object with a new identifier
+ *
* cuts the visible selection
* - (tree) get new refs on selected items
* - (main) add selected items to main list of deleted,
@@ -214,7 +223,6 @@ nact_menubar_edit_on_cut( GtkAction *gtk_action, BaseWindow *window )
}
if( to_delete ){
- nact_main_window_move_to_deleted( NACT_MAIN_WINDOW( window ), to_delete );
clipboard = nact_main_window_get_clipboard( NACT_MAIN_WINDOW( window ));
nact_clipboard_primary_set( clipboard, to_delete, CLIPBOARD_MODE_CUT );
update_clipboard_counters( window );
@@ -321,7 +329,7 @@ nact_menubar_edit_on_paste_into( GtkAction *gtk_action, BaseWindow *window )
items = prepare_for_paste( window );
if( items ){
view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
- nact_tree_ieditable_insert_items_into( NACT_TREE_IEDITABLE( window ), items );
+ nact_tree_ieditable_insert_into( NACT_TREE_IEDITABLE( window ), items );
na_object_free_items( items );
}
}
@@ -348,7 +356,7 @@ prepare_for_paste( BaseWindow *window )
if( NA_IS_OBJECT_PROFILE( it->data )){
if( !action ){
- g_object_get( G_OBJECT( window ), TAB_UPDATABLE_PROP_SELECTED_ITEM, &action, NULL );
+ g_object_get( G_OBJECT( window ), MAIN_PROP_ITEM, &action, NULL );
g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), NULL );
}
}
@@ -466,7 +474,6 @@ nact_menubar_edit_on_delete( GtkAction *gtk_action, BaseWindow *window )
}
if( to_delete ){
- /*nact_main_window_move_to_deleted( NACT_MAIN_WINDOW( window ), to_delete );*/
view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
nact_tree_ieditable_delete( NACT_TREE_IEDITABLE( view ), to_delete, TRUE );
}
diff --git a/src/nact/nact-menubar-file.c b/src/nact/nact-menubar-file.c
index 491d235..6fd30c7 100644
--- a/src/nact/nact-menubar-file.c
+++ b/src/nact/nact-menubar-file.c
@@ -52,7 +52,9 @@ static guint st_event_autosave = 0;
static gchar *st_save_error = N_( "Save error" );
static gchar *st_save_warning = N_( "Some items may not have been saved" );
static gchar *st_level_zero_write = N_( "Unable to rewrite the level-zero items list" );
+#if 0
static gchar *st_delete_error = N_( "Some items cannot have been deleted" );
+#endif
static gboolean save_item( BaseWindow *window, NAUpdater *updater, NAObjectItem *item, GSList **messages );
static void on_autosave_prefs_changed( const gchar *group, const gchar *key, gconstpointer new_value, gpointer user_data );
@@ -167,7 +169,7 @@ nact_menubar_file_on_new_profile( GtkAction *gtk_action, BaseWindow *window )
g_object_get(
G_OBJECT( window ),
- TAB_UPDATABLE_PROP_SELECTED_ITEM, &action,
+ MAIN_PROP_ITEM, &action,
NULL );
profile = na_object_profile_new_with_defaults();
@@ -283,6 +285,7 @@ nact_menubar_file_save_items( BaseWindow *window )
/* remove deleted items
* so that new actions with same id do not risk to be deleted later
*/
+#if 0
if( !nact_main_window_remove_deleted( NACT_MAIN_WINDOW( window ), &messages )){
if( g_slist_length( messages )){
msg = na_core_utils_slist_join_at_end( messages, "\n" );
@@ -294,6 +297,7 @@ nact_menubar_file_save_items( BaseWindow *window )
na_core_utils_slist_free( messages );
return;
}
+#endif
/* recursively save the modified items
* check is useless here if item was not modified, but not very costly;
diff --git a/src/nact/nact-menubar.c b/src/nact/nact-menubar.c
index 521a9fd..a2396b0 100644
--- a/src/nact/nact-menubar.c
+++ b/src/nact/nact-menubar.c
@@ -740,9 +740,6 @@ on_tree_view_selection_changed( BaseWindow *window, NactTreeView *view, GList *s
*/
bar->private->count_selected = g_list_length( selected );
- bar->private->selected_menus = 0;
- bar->private->selected_actions = 0;
- bar->private->selected_profiles = 0;
if( selected ){
na_object_item_count_items( selected, &bar->private->selected_menus, &bar->private->selected_actions, &bar->private->selected_profiles, FALSE );
g_debug( "%s: selected_menus=%d, selected_actions=%d, selected_profiles=%d",
diff --git a/src/nact/nact-tree-ieditable.c b/src/nact/nact-tree-ieditable.c
index 379469a..f5534c4 100644
--- a/src/nact/nact-tree-ieditable.c
+++ b/src/nact/nact-tree-ieditable.c
@@ -36,7 +36,9 @@
#include <core/na-updater.h>
+#include "base-keysyms.h"
#include "nact-application.h"
+#include "nact-main-window.h"
#include "nact-tree-ieditable.h"
#include "nact-tree-model.h"
@@ -49,9 +51,12 @@ struct _NactTreeIEditableInterfacePrivate {
/* data attached to the NactTreeView
*/
typedef struct {
- NAUpdater *updater;
- GtkTreeView *treeview;
- guint count_modified;
+ NAUpdater *updater;
+ BaseWindow *window;
+ GtkTreeView *treeview;
+ NactTreeModel *model;
+ guint count_modified;
+ GList *deleted;
}
IEditableData;
@@ -64,13 +69,15 @@ static GType register_type( void );
static void interface_base_init( NactTreeIEditableInterface *klass );
static void interface_base_finalize( NactTreeIEditableInterface *klass );
-static void do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTreePath *insert_path, GList **list_parents );
-static NAObject *do_insert_into_first( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTreePath *insert_path, GtkTreePath **new_path );
+static gboolean on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseWindow *window );
+static void on_label_edited( GtkCellRendererText *renderer, const gchar *path_str, const gchar *text, BaseWindow *window );
+static void do_insert_before( NactTreeIEditable *view, IEditableData *ied, GList *items, GtkTreePath *insert_path );
+static GtkTreePath *do_insert_into( NactTreeIEditable *view, IEditableData *ied, GList *items, GtkTreePath *insert_path );
+static void increment_count_items( NactTreeIEditable *view, IEditableData *ied, GList *items );
static GtkTreePath *get_selection_first_path( GtkTreeView *treeview );
static IEditableData *get_instance_data( NactTreeIEditable *view );
static void decrement_counters( NactTreeIEditable *instance, IEditableData *ialid, GList *items );
-static void increment_counters( NactTreeIEditable *view, IEditableData *ied, GList *items );
-static void increment_counters_modified( NAObject *object, IEditableData *ied );
+static void inline_edition( BaseWindow *window );
GType
nact_tree_ieditable_get_type( void )
@@ -151,14 +158,89 @@ nact_tree_ieditable_initialize( NactTreeIEditable *instance, GtkTreeView *treevi
static const gchar *thisfn = "nact_tree_ieditable_initialize";
IEditableData *ied;
NactApplication *application;
+ GtkTreeViewColumn *column;
+ GList *renderers;
- g_debug( "%s: instance=%p, window=%p", thisfn, ( void * ) instance, ( void * ) window );
+ g_debug( "%s: instance=%p, treeview=%p, window=%p",
+ thisfn, ( void * ) instance, ( void * ) treeview, ( void * ) window );
ied = get_instance_data( instance );
+ ied->window = window;
ied->treeview = treeview;
+ ied->model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
application = NACT_APPLICATION( base_window_get_application( window ));
ied->updater = nact_application_get_updater( application );
+
+ /* expand/collapse with the keyboard */
+ base_window_signal_connect( window,
+ G_OBJECT( treeview ), "key-press-event", G_CALLBACK( on_key_pressed_event ));
+
+ /* label edition: inform the corresponding tab */
+ column = gtk_tree_view_get_column( treeview, TREE_COLUMN_LABEL );
+ renderers = gtk_cell_layout_get_cells( GTK_CELL_LAYOUT( column ));
+ base_window_signal_connect( window,
+ G_OBJECT( renderers->data ), "edited", G_CALLBACK( on_label_edited ));
+}
+
+/**
+ * nact_tree_ieditable_terminate:
+ * @instance: the #NactTreeView which implements this interface.
+ *
+ * Free the data when application quits.
+ */
+void
+nact_tree_ieditable_terminate( NactTreeIEditable *instance )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_terminate";
+ IEditableData *ied;
+
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+
+ ied = get_instance_data( instance );
+
+ g_list_free( ied->deleted );
+}
+
+static gboolean
+on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseWindow *window )
+{
+ gboolean stop = FALSE;
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ if( event->keyval == NACT_KEY_F2 ){
+ inline_edition( window );
+ stop = TRUE;
+ }
+ }
+
+ return( stop );
+}
+
+/*
+ * path: path of the edited row, as a string
+ * text: new text
+ *
+ * - inform tabs so that they can update their fields
+ * data = object_at_row + new_label
+ */
+static void
+on_label_edited( GtkCellRendererText *renderer, const gchar *path_str, const gchar *text, BaseWindow *window )
+{
+ NactTreeView *items_view;
+ IEditableData *ied;
+ NAObject *object;
+ GtkTreePath *path;
+ gchar *new_text;
+
+ items_view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
+ ied = ( IEditableData * ) g_object_get_data( G_OBJECT( items_view ), VIEW_DATA_IEDITABLE );
+ path = gtk_tree_path_new_from_string( path_str );
+ object = nact_tree_model_object_at_path( ied->model, path );
+ new_text = g_strdup( text );
+
+ g_signal_emit_by_name( window, TREE_SIGNAL_CONTENT_CHANGED, items_view, object );
}
/**
@@ -171,13 +253,19 @@ nact_tree_ieditable_initialize( NactTreeIEditable *instance, GtkTreeView *treevi
*
* This function takes care of repositionning a new selection if
* possible, and refilter the display model.
+ *
+ * Deleted NAObjectItems are added to the 'deleted' list attached to the
+ * view, so that they will be actually deleted from the storage subsystem
+ * on save.
+ *
+ * Deleted NAObjectProfiles are not added to the list, because the deletion
+ * will be recorded when saving the action.
*/
void
nact_tree_ieditable_delete( NactTreeIEditable *instance, GList *items, gboolean select_at_end )
{
static const gchar *thisfn = "nact_tree_ieditable_delete";
IEditableData *ied;
- GtkTreeModel *model;
GtkTreePath *path = NULL;
GList *it;
@@ -188,7 +276,6 @@ nact_tree_ieditable_delete( NactTreeIEditable *instance, GList *items, gboolean
thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ), select_at_end ? "True":"False" );
ied = get_instance_data( instance );
- model = gtk_tree_view_get_model( ied->treeview );
decrement_counters( instance, ied, items );
@@ -197,7 +284,7 @@ nact_tree_ieditable_delete( NactTreeIEditable *instance, GList *items, gboolean
gtk_tree_path_free( path );
}
- path = nact_tree_model_delete( NACT_TREE_MODEL( model ), NA_OBJECT( it->data ));
+ path = nact_tree_model_delete( ied->model, NA_OBJECT( it->data ));
/*ialid->modified_items = nact_iactions_list_remove_rec( ialid->modified_items, NA_OBJECT( it->data ));*/
@@ -205,7 +292,7 @@ nact_tree_ieditable_delete( NactTreeIEditable *instance, GList *items, gboolean
( 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 ));
+ gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( ied->model ));
if( path ){
if( select_at_end ){
@@ -217,46 +304,6 @@ nact_tree_ieditable_delete( NactTreeIEditable *instance, GList *items, gboolean
}
/**
- * nact_tree_ieditable_insert_at_path:
- * @instance: this #NactTreeIEditable instance.
- * @items: a list of items to be inserted (e.g. from a paste).
- * @path: insertion path.
- *
- * Inserts the provided @items list in the treeview.
- *
- * This function takes care of repositionning a new selection if
- * possible, and refilter the display model.
- */
-void
-nact_tree_ieditable_insert_at_path( NactTreeIEditable *instance, GList *items, GtkTreePath *insert_path )
-{
- static const gchar *thisfn = "nact_tree_ieditable_insert_at_path";
- IEditableData *ied;
- GtkTreeModel *model;
- GList *parents;
-
- g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
-
- if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
- g_debug( "%s: instance=%p, items=%p (count=%d)",
- thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ));
-
- ied = get_instance_data( instance );
- model = gtk_tree_view_get_model( ied->treeview );
- g_return_if_fail( NACT_IS_TREE_MODEL( model ));
-
- increment_counters( instance, ied, items );
- do_insert_items( ied->treeview, model, items, insert_path, &parents );
-
- g_list_foreach( parents, ( GFunc ) na_object_object_check_status, NULL );
- g_list_free( parents );
-
- gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
- nact_tree_view_select_row_at_path( NACT_TREE_VIEW( instance ), insert_path );
- }
-}
-
-/**
* nact_tree_ieditable_insert_items:
* @instance: this #NactTreeIEditable instance.
* @items: a list of items to be inserted (e.g. from a paste).
@@ -284,7 +331,6 @@ nact_tree_ieditable_insert_items( NactTreeIEditable *instance, GList *items, NAO
{
static const gchar *thisfn = "nact_tree_ieditable_insert_items";
IEditableData *ied;
- GtkTreeModel *model;
GtkTreePath *insert_path;
NAObject *object, *parent;
@@ -296,21 +342,19 @@ nact_tree_ieditable_insert_items( NactTreeIEditable *instance, GList *items, NAO
insert_path = NULL;
ied = get_instance_data( instance );
- model = gtk_tree_view_get_model( ied->treeview );
- g_return_if_fail( NACT_IS_TREE_MODEL( model ));
if( sibling ){
- insert_path = nact_tree_model_object_to_path( NACT_TREE_MODEL( model ), sibling );
+ insert_path = nact_tree_model_object_to_path( ied->model, sibling );
} else {
insert_path = get_selection_first_path( ied->treeview );
- object = nact_tree_model_object_at_path( NACT_TREE_MODEL( model ), insert_path );
+ object = nact_tree_model_object_at_path( ied->model, insert_path );
g_debug( "%s: current object at insertion path is %p", thisfn, ( void * ) object );
/* as a particular case, insert a new profile _into_ current action
*/
if( NA_IS_OBJECT_ACTION( object ) && NA_IS_OBJECT_PROFILE( items->data )){
- nact_tree_ieditable_insert_items_into( instance, items );
+ nact_tree_ieditable_insert_into( instance, items );
gtk_tree_path_free( insert_path );
return;
}
@@ -320,7 +364,7 @@ nact_tree_ieditable_insert_items( NactTreeIEditable *instance, GList *items, NAO
if( NA_IS_OBJECT_PROFILE( object ) && NA_IS_OBJECT_ITEM( items->data )){
parent = ( NAObject * ) na_object_get_parent( object );
gtk_tree_path_free( insert_path );
- insert_path = nact_tree_model_object_to_path( NACT_TREE_MODEL( model ), parent );
+ insert_path = nact_tree_model_object_to_path( ied->model, parent );
}
}
@@ -330,33 +374,22 @@ nact_tree_ieditable_insert_items( NactTreeIEditable *instance, GList *items, NAO
}
/**
- * nact_tree_ieditable_insert_items_into:
+ * nact_tree_ieditable_insert_at_path:
* @instance: this #NactTreeIEditable instance.
* @items: a list of items to be inserted (e.g. from a paste).
+ * @path: insertion path.
*
- * Inserts the provided @items list as first children of the current item.
- *
- * The provided @items list is supposed to be homogeneous, i.e. referes
- * to only profiles, or only actions or menus.
- *
- * If the @items list contains only profiles, they can only be inserted
- * into an action, and the profiles will eventually be renumbered.
- *
- * If new item is a #NAObjectMenu or a #NAObjectAction, it will be inserted
- * as first children of the current menu.
+ * Inserts the provided @items list in the treeview.
*
- * This function takes care of repositionning a new selection as the
- * last inserted item, and refilter the display model.
+ * This function takes care of repositionning a new selection if
+ * possible, and refilter the display model.
*/
void
-nact_tree_ieditable_insert_items_into( NactTreeIEditable *instance, GList *items )
+nact_tree_ieditable_insert_at_path( NactTreeIEditable *instance, GList *items, GtkTreePath *insert_path )
{
- static const gchar *thisfn = "nact_tree_ieditable_insert_items_into";
+ static const gchar *thisfn = "nact_tree_ieditable_insert_at_path";
IEditableData *ied;
- GtkTreeModel *model;
- GtkTreePath *insert_path;
- GtkTreePath *new_path;
- NAObject *parent;
+ guint prev_count;
g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
@@ -364,110 +397,194 @@ nact_tree_ieditable_insert_items_into( NactTreeIEditable *instance, GList *items
g_debug( "%s: instance=%p, items=%p (count=%d)",
thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ));
- insert_path = NULL;
ied = get_instance_data( instance );
- model = gtk_tree_view_get_model( ied->treeview );
- insert_path = get_selection_first_path( ied->treeview );
+ prev_count = ied->count_modified;
- increment_counters( instance, ied, items );
- parent = do_insert_into_first( ied->treeview, model, items, insert_path, &new_path );
- gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
- nact_tree_view_select_row_at_path( NACT_TREE_VIEW( instance ), new_path );
+ do_insert_before( instance, ied, items, insert_path );
- gtk_tree_path_free( new_path );
- gtk_tree_path_free( insert_path );
+ /* post insertion
+ */
+ increment_count_items( instance, ied, items );
+ if( ied->count_modified != prev_count ){
+ g_signal_emit_by_name( G_OBJECT( ied->window ),
+ TREE_SIGNAL_MODIFIED_COUNT_CHANGED, NACT_TREE_VIEW( instance ), ied->count_modified );
+ }
+ gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( ied->model ));
+ nact_tree_view_select_row_at_path( NACT_TREE_VIEW( instance ), insert_path );
}
}
static void
-do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTreePath *insert_path, GList **list_parents )
+do_insert_before( NactTreeIEditable *view, IEditableData *ied, GList *items, GtkTreePath *insert_path )
{
- static const gchar *thisfn = "nact_tree_ieditable_do_insert_items";
+ static const gchar *thisfn = "nact_tree_ieditable_do_insert_before";
GList *reversed;
GList *it;
- GList *subitems;
- NAObject *obj_parent;
- gpointer updatable;
GtkTreePath *inserted_path;
- obj_parent = NULL;
- if( list_parents ){
- *list_parents = NULL;
- }
-
reversed = g_list_reverse( g_list_copy( items ));
for( it = reversed ; it ; it = it->next ){
- inserted_path = nact_tree_model_insert( NACT_TREE_MODEL( model ), NA_OBJECT( it->data ), insert_path, &obj_parent );
-
+ inserted_path = nact_tree_model_insert_before( ied->model, NA_OBJECT( it->data ), insert_path );
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 ){
- updatable = obj_parent ? obj_parent : it->data;
- if( !g_list_find( *list_parents, updatable )){
- *list_parents = g_list_prepend( *list_parents, updatable );
- }
- }
+ /* after the item has been inserted, and attached to its new parent
+ * increment modified counters
+ */
/* recursively insert subitems
*/
- if( NA_IS_OBJECT_ITEM( it->data ) && na_object_get_items_count( it->data )){
- subitems = na_object_get_items( it->data );
- do_insert_into_first( treeview, model, subitems, inserted_path, NULL );
+ if( NA_IS_OBJECT_ITEM( it->data )){
+ do_insert_into( view, ied, na_object_get_items( it->data ), inserted_path );
}
+ na_object_check_status( it->data );
gtk_tree_path_free( inserted_path );
}
g_list_free( reversed );
}
-static NAObject *
-do_insert_into_first( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTreePath *insert_path, GtkTreePath **new_path )
+/**
+ * nact_tree_ieditable_insert_into:
+ * @instance: this #NactTreeIEditable instance.
+ * @items: a list of items to be inserted (e.g. from a paste).
+ *
+ * Inserts the provided @items list as first children of the current item.
+ *
+ * The provided @items list is supposed to be homogeneous, i.e. referes
+ * to only profiles, or only actions or menus.
+ *
+ * If the @items list contains only profiles, they can only be inserted
+ * into an action, and the profiles will eventually be renumbered.
+ *
+ * If new item is a #NAObjectMenu or a #NAObjectAction, it will be inserted
+ * as first children of the current menu.
+ *
+ * This function takes care of repositionning a new selection as the
+ * last inserted item, and refilter the display model.
+ */
+void
+nact_tree_ieditable_insert_into( NactTreeIEditable *instance, GList *items )
{
- static const gchar *thisfn = "nact_tree_ieditable_do_insert_into_first";
+ static const gchar *thisfn = "nact_tree_ieditable_insert_into";
+ IEditableData *ied;
+ GtkTreePath *insert_path;
+ GtkTreePath *new_path;
+ guint prev_count;
+
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+ g_debug( "%s: instance=%p, items=%p (count=%d)",
+ thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ));
+
+ insert_path = NULL;
+ ied = get_instance_data( instance );
+ prev_count = ied->count_modified;
+ insert_path = get_selection_first_path( ied->treeview );
+
+ new_path = do_insert_into( instance, ied, items, insert_path );
+
+ /* post insertion
+ */
+ increment_count_items( instance, ied, items );
+ if( ied->count_modified != prev_count ){
+ g_signal_emit_by_name( G_OBJECT( ied->window ),
+ TREE_SIGNAL_MODIFIED_COUNT_CHANGED, NACT_TREE_VIEW( instance ), ied->count_modified );
+ }
+ gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( ied->model ));
+ nact_tree_view_select_row_at_path( NACT_TREE_VIEW( instance ), new_path );
+
+ gtk_tree_path_free( new_path );
+ gtk_tree_path_free( insert_path );
+ }
+}
+
+/*
+ * inserting a list of children into an object is as:
+ * - inserting the last child into the object
+ * - then inserting other children just before the last insertion path
+ *
+ * Returns the actual insertion path suitable for the next selection.
+ * This path should be gtk_tree_path_free() by the caller.
+ */
+static GtkTreePath *
+do_insert_into( NactTreeIEditable *view, IEditableData *ied, GList *items, GtkTreePath *insert_path )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_do_insert_into";
GList *copy;
GList *last;
- NAObject *parent;
gchar *insert_path_str;
GtkTreePath *inserted_path;
- GList *subitems;
insert_path_str = gtk_tree_path_to_string( insert_path );
- g_debug( "%s: treeview=%p, model=%p, items=%p (count=%d), insert_path=%p (%s), new_path=%p",
+ g_debug( "%s: view=%p, ied=%p, items=%p (count=%d), insert_path=%p (%s)",
thisfn,
- ( void * ) treeview, ( void * ) model, ( void * ) items, g_list_length( items ),
- ( void * ) insert_path, insert_path_str, ( void * ) new_path );
+ ( void * ) view, ( void * ) ied, ( void * ) items, g_list_length( items ),
+ ( void * ) insert_path, insert_path_str );
g_free( insert_path_str );
- parent = NULL;
copy = g_list_copy( items );
last = g_list_last( copy );
copy = g_list_remove_link( copy, last );
- inserted_path = nact_tree_model_insert_into( NACT_TREE_MODEL( model ), NA_OBJECT( last->data ), insert_path, &parent );
- gtk_tree_view_expand_to_path( treeview, inserted_path );
-
- /* recursively insert subitems
+ /* insert the last child into the wished path
+ * and recursively all its children
*/
- if( NA_IS_OBJECT_ITEM( last->data ) && na_object_get_items_count( last->data )){
- subitems = na_object_get_items( last->data );
- do_insert_into_first( treeview, model, subitems, inserted_path, NULL );
- }
-
- do_insert_items( treeview, model, copy, inserted_path, NULL );
+ inserted_path = nact_tree_model_insert_into( ied->model, NA_OBJECT( last->data ), insert_path );
+ gtk_tree_view_expand_to_path( ied->treeview, inserted_path );
- if( new_path ){
- *new_path = gtk_tree_path_copy( inserted_path );
+ if( NA_IS_OBJECT_ITEM( last->data )){
+ do_insert_into( view, ied, na_object_get_items( last->data ), inserted_path );
+ na_object_check_status( last->data );
}
+ /* then insert other objects
+ */
+ do_insert_before( view, ied, copy, inserted_path );
+
g_list_free( copy );
- gtk_tree_path_free( inserted_path );
- return( parent );
+ return( inserted_path );
}
+/*
+ * we pass here after each insertion operation (apart initial fill)
+ */
+static void
+increment_count_items( NactTreeIEditable *view, IEditableData *ied, GList *items )
+{
+ static const gchar *thisfn = "nact_tre_ieditablet_increment_count_items";
+ gint menus, actions, profiles;
+
+ g_debug( "%s: view=%p, ied=%p, items=%p (count=%d)",
+ thisfn, ( void * ) view, ( void * ) ied, ( void * ) items, items ? g_list_length( items ) : 0 );
+
+ na_object_count_items( items, &menus, &actions, &profiles );
+ g_signal_emit_by_name( G_OBJECT( ied->window ), TREE_SIGNAL_COUNT_CHANGED, view, FALSE, menus, actions, profiles );
+}
+
+#if 0
+static void
+increment_counters_modified( NAObject *object, IEditableData *ied )
+{
+ gboolean writable;
+ guint reason;
+
+ if( NA_IS_OBJECT_ITEM( object )){
+
+ if( !na_object_get_provider( object )){
+ ied->count_modified += 1;
+ }
+
+ writable = na_updater_is_item_writable( ied->updater, NA_OBJECT_ITEM( object ), &reason );
+ na_object_set_writability_status( object, writable, reason );
+ }
+}
+#endif
+
static GtkTreePath *
get_selection_first_path( GtkTreeView *treeview )
{
@@ -512,476 +629,42 @@ decrement_counters( NactTreeIEditable *view, IEditableData *ied, GList *items )
{
static const gchar *thisfn = "nact_tree_editable_decrement_counters";
gint menus, actions, profiles;
- BaseWindow *window;
g_debug( "%s: view=%p, ied=%p, items=%p",
thisfn, ( void * ) view, ( void * ) ied, ( void * ) items );
- menus = 0;
- actions = 0;
- profiles = 0;
- na_object_item_count_items( items, &menus, &actions, &profiles, TRUE );
+ na_object_count_items( items, &menus, &actions, &profiles );
menus *= -1;
actions *= -1;
profiles *= -1;
- window = nact_tree_view_get_window( NACT_TREE_VIEW( view ));
- g_signal_emit_by_name( G_OBJECT( window ), TREE_SIGNAL_COUNT_CHANGED, view, FALSE, menus, actions, profiles );
+ g_signal_emit_by_name( G_OBJECT( ied->window ), TREE_SIGNAL_COUNT_CHANGED, view, FALSE, menus, actions, profiles );
}
/*
- * we pass here before each insertion operation (apart initial fill)
+ * triggered by 'F2' key
+ * let thelabel be edited
*/
static void
-increment_counters( NactTreeIEditable *view, IEditableData *ied, GList *items )
-{
- static const gchar *thisfn = "nact_tre_ieditablet_increment_counters";
- guint modified_prev;
- gint menus, actions, profiles;
- BaseWindow *window;
-
- g_debug( "%s: view=%p, ied=%p, items=%p (count=%d)",
- thisfn, ( void * ) view, ( void * ) ied, ( void * ) items, items ? g_list_length( items ) : 0 );
-
- menus = 0;
- actions = 0;
- profiles = 0;
- na_object_item_count_items( items, &menus, &actions, &profiles, TRUE );
- window = nact_tree_view_get_window( NACT_TREE_VIEW( view ));
- g_signal_emit_by_name( G_OBJECT( window ), TREE_SIGNAL_COUNT_CHANGED, view, FALSE, menus, actions, profiles );
-
- modified_prev = ied->count_modified;
- g_list_foreach( items, ( GFunc ) increment_counters_modified, ied );
- if( ied->count_modified != modified_prev ){
- g_signal_emit_by_name( G_OBJECT( window ), TREE_SIGNAL_MODIFIED_COUNT_CHANGED, view, ied->count_modified );
- }
-}
-
-static void
-increment_counters_modified( NAObject *object, IEditableData *ied )
-{
- gboolean writable;
- guint reason;
-
- if( NA_IS_OBJECT_ITEM( object )){
-
- if( !na_object_get_provider( object )){
- ied->count_modified += 1;
- }
-
- writable = na_updater_is_item_writable( ied->updater, NA_OBJECT_ITEM( object ), &reason );
- na_object_set_writability_status( object, writable, reason );
- }
-}
-
-#if 0
-
-/* iter on selection prototype
- */
-typedef gboolean ( *FnIterOnSelection )( NactIActionsList *, GtkTreeView *, GtkTreeModel *, GtkTreeIter *, NAObject *, gpointer );
-
-/**
- * nact_iactions_list_bis_clear_selection:
- * @instance: this instance of the #NactIActionsList interface.
- * @treeview: the #GtkTreeView.
- *
- * Clears the current selection.
- */
-void
-nact_iactions_list_bis_clear_selection( NactIActionsList *instance, GtkTreeView *treeview )
+inline_edition( BaseWindow *window )
{
+ NactTreeView *items_view;
+ IEditableData *ied;
GtkTreeSelection *selection;
-
- selection = gtk_tree_view_get_selection( treeview );
- gtk_tree_selection_unselect_all( selection );
-}
-
-/**
- * nact_iactions_list_bis_collapse_to_parent:
- * @instance: this instance of the #NactIActionsList interface.
- *
- * On left arrow, if we are on a first child, then collapse and go to
- * the parent.
- */
-void
-nact_iactions_list_bis_collapse_to_parent( NactIActionsList *instance )
-{
- static const gchar *thisfn = "nact_iactions_list_bis_collapse_to_parent";
- IActionsListInstanceData *ialid;
- GtkTreeView *treeview;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GList *listrows;
- GtkTreePath *path;
- gint *indices;
- GtkTreePath *parent_path;
-
- g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
- g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
-
- ialid = nact_iactions_list_priv_get_instance_data( instance );
- if( ialid->management_mode == IACTIONS_LIST_MANAGEMENT_MODE_EDITION ){
-
- treeview = nact_iactions_list_priv_get_actions_list_treeview( instance );
- selection = gtk_tree_view_get_selection( treeview );
- listrows = gtk_tree_selection_get_selected_rows( selection, &model );
- if( g_list_length( listrows ) == 1 ){
-
- path = ( GtkTreePath * ) listrows->data;
- /*g_debug( "%s: path_depth=%d", thisfn, gtk_tree_path_get_depth( path ));*/
- if( gtk_tree_path_get_depth( path ) > 1 ){
-
- indices = gtk_tree_path_get_indices( path );
- if( indices[ gtk_tree_path_get_depth( path )-1 ] == 0 ){
-
- parent_path = gtk_tree_path_copy( path );
- gtk_tree_path_up( parent_path );
- nact_iactions_list_bis_select_row_at_path( instance, treeview, model, parent_path );
- gtk_tree_view_collapse_row( treeview, parent_path );
- gtk_tree_path_free( parent_path );
- }
- }
- }
-
- g_list_foreach( listrows, ( GFunc ) gtk_tree_path_free, NULL );
- g_list_free( listrows );
- }
-}
-
-/**
- * nact_iactions_list_bis_expand_to_first_child:
- * @instance: this #NactIActionsList interface.
- *
- * On right arrow, expand the parent if it has childs, and select the
- * first child.
- */
-void
-nact_iactions_list_bis_expand_to_first_child( NactIActionsList *instance )
-{
- static const gchar *thisfn = "nact_iactions_list_bis_expand_to_first_child";
- IActionsListInstanceData *ialid;
- GtkTreeView *treeview;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
GList *listrows;
GtkTreePath *path;
- GtkTreeIter iter;
- GtkTreePath *child_path;
-
- g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
- g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
-
- ialid = nact_iactions_list_priv_get_instance_data( instance );
- if( ialid->management_mode == IACTIONS_LIST_MANAGEMENT_MODE_EDITION ){
- treeview = nact_iactions_list_priv_get_actions_list_treeview( instance );
- selection = gtk_tree_view_get_selection( treeview );
- listrows = gtk_tree_selection_get_selected_rows( selection, &model );
-
- if( g_list_length( listrows ) == 1 ){
- path = ( GtkTreePath * ) listrows->data;
- gtk_tree_model_get_iter( model, &iter, path );
- if( gtk_tree_model_iter_has_child( model, &iter )){
- child_path = gtk_tree_path_copy( path );
- gtk_tree_path_append_index( child_path, 0 );
- gtk_tree_view_expand_row( treeview, child_path, FALSE );
- nact_iactions_list_bis_select_row_at_path( instance, treeview, model, child_path );
- gtk_tree_path_free( child_path );
- }
- }
-
- g_list_foreach( listrows, ( GFunc ) gtk_tree_path_free, NULL );
- g_list_free( listrows );
- }
-}
-
-/**
- * nact_iactions_list_bis_get_selected_items:
- * @window: this #NactIActionsList instance.
- *
- * Returns: the currently selected rows as a list of #NAObjects.
- *
- * We acquire here a new reference on objects corresponding to actually
- * selected rows, and their childs.
- *
- * The caller may safely call na_object_free_items() on the
- * returned list.
- */
-GList *
-nact_iactions_list_bis_get_selected_items( NactIActionsList *instance )
-{
- GList *items = NULL;
- GtkTreeView *treeview;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GList *it, *listrows;
- NAObject *object;
- GtkTreePath *path;
-
- g_return_val_if_fail( NACT_IS_IACTIONS_LIST( instance ), NULL );
-
- if( st_iactions_list_initialized && !st_iactions_list_finalized ){
-
- treeview = nact_iactions_list_priv_get_actions_list_treeview( instance );
- selection = gtk_tree_view_get_selection( treeview );
- listrows = gtk_tree_selection_get_selected_rows( selection, &model );
-
- for( it = listrows ; it ; it = it->next ){
- path = ( GtkTreePath * ) it->data;
- gtk_tree_model_get_iter( model, &iter, path );
- gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
- g_debug( "nact_iactions_list_get_selected_items: object=%p", ( void * ) object );
- items = g_list_prepend( items, na_object_ref( object ));
- g_object_unref( object );
- }
-
- g_list_foreach( listrows, ( GFunc ) gtk_tree_path_free, NULL );
- g_list_free( listrows );
-
- items = g_list_reverse( items );
- }
-
- return( items );
-}
-
-/**
- * nact_iactions_list_bis_list_modified_items:
- * @instance: this #NactIActionsList instance.
- *
- * Dumps the modified items list.
- */
-void
-nact_iactions_list_bis_list_modified_items( NactIActionsList *instance )
-{
- static const gchar *thisfn = "nact_iactions_list_bis_list_modified_items";
- IActionsListInstanceData *ialid;
- GList *it;
-
- g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
- g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
-
- if( st_iactions_list_initialized && !st_iactions_list_finalized ){
-
- ialid = nact_iactions_list_priv_get_instance_data( instance );
-
- g_debug( "%s: raw list", thisfn );
- for( it = ialid->modified_items ; it ; it = it->next ){
- g_debug( "%s: %p (%s)", thisfn, ( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ));
- }
-
- g_debug( "%s: detailed list", thisfn );
- for( it = ialid->modified_items ; it ; it = it->next ){
- na_object_dump( it->data );
- }
- }
-}
-
-/**
- * nact_iactions_list_bis_remove_modified:
- * @instance: this #NactIActionsList instance.
- *
- * Removes the saved item from the modified items list.
- */
-void
-nact_iactions_list_bis_remove_modified( NactIActionsList *instance, const NAObjectItem *item )
-{
- IActionsListInstanceData *ialid;
-
- g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
-
- if( st_iactions_list_initialized && !st_iactions_list_finalized ){
-
- ialid = nact_iactions_list_priv_get_instance_data( instance );
- ialid->modified_items = g_list_remove( ialid->modified_items, item );
-
- if( g_list_length( ialid->modified_items ) == 0 ){
- g_list_free( ialid->modified_items );
- ialid->modified_items = NULL;
- }
- }
-}
-
-/**
- * nact_iactions_list_bis_toggle_collapse:
- * @instance: this #NactIActionsList interface.
- *
- * Toggle or collapse the current subtree.
- */
-void
-nact_iactions_list_bis_toggle_collapse( NactIActionsList *instance )
-{
- int toggle = TOGGLE_UNDEFINED;
-
- iter_on_selection( instance, ( FnIterOnSelection ) toggle_collapse_iter, &toggle );
-}
-
-/**
- * nact_iactions_list_bis_toggle_collapse_object:
- * @instance: the current instance of the #NactIActionsList interface.
- * @item: the item to be toggled/collapsed.
- *
- * Collapse / expand if actions has more than one profile.
- */
-void
-nact_iactions_list_bis_toggle_collapse_object( NactIActionsList *instance, const NAObject *item )
-{
- static const gchar *thisfn = "nact_iactions_list_bis_toggle_collapse";
- GtkTreeView *treeview;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean iterok, stop;
- NAObject *iter_object;
-
- g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
- g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
-
- if( st_iactions_list_initialized && !st_iactions_list_finalized ){
-
- treeview = nact_iactions_list_priv_get_actions_list_treeview( instance );
- model = gtk_tree_view_get_model( treeview );
- iterok = gtk_tree_model_get_iter_first( model, &iter );
- stop = FALSE;
-
- while( iterok && !stop ){
-
- gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &iter_object, -1 );
- if( iter_object == item ){
-
- if( na_object_get_items_count( item ) > 1 ){
-
- GtkTreePath *path = gtk_tree_model_get_path( model, &iter );
-
- if( gtk_tree_view_row_expanded( GTK_TREE_VIEW( treeview ), path )){
- gtk_tree_view_collapse_row( GTK_TREE_VIEW( treeview ), path );
- g_debug( "%s: action=%p collapsed", thisfn, ( void * ) item );
-
- } else {
- gtk_tree_view_expand_row( GTK_TREE_VIEW( treeview ), path, TRUE );
- g_debug( "%s: action=%p expanded", thisfn, ( void * ) item );
- }
-
- gtk_tree_path_free( path );
- }
- stop = TRUE;
- }
-
- g_object_unref( iter_object );
- iterok = gtk_tree_model_iter_next( model, &iter );
- }
- }
-}
-
-/*
- * when expanding a selected row which has childs
- */
-static void
-extend_selection_to_childs( NactIActionsList *instance, GtkTreeView *treeview, GtkTreeModel *model, GtkTreeIter *parent )
-{
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- gboolean ok;
-
- selection = gtk_tree_view_get_selection( treeview );
-
- ok = gtk_tree_model_iter_children( model, &iter, parent );
-
- while( ok ){
- GtkTreePath *path = gtk_tree_model_get_path( model, &iter );
- gtk_tree_selection_select_path( selection, path );
- gtk_tree_path_free( path );
- ok = gtk_tree_model_iter_next( model, &iter );
- }
-}
-
-static void
-iter_on_selection( NactIActionsList *instance, FnIterOnSelection fn_iter, gpointer user_data )
-{
- GtkTreeView *treeview;
- GtkTreeSelection *selection;
- GtkTreeModel *model;
- GList *listrows, *ipath;
- GtkTreePath *path;
- GtkTreeIter iter;
- NAObject *object;
- gboolean stop = FALSE;
-
- treeview = nact_iactions_list_priv_get_actions_list_treeview( instance );
- selection = gtk_tree_view_get_selection( treeview );
- listrows = gtk_tree_selection_get_selected_rows( selection, &model );
- listrows = g_list_reverse( listrows );
+ GtkTreeViewColumn *column;
- for( ipath = listrows ; !stop && ipath ; ipath = ipath->next ){
+ items_view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
+ ied = ( IEditableData * ) g_object_get_data( G_OBJECT( items_view ), VIEW_DATA_IEDITABLE );
+ selection = gtk_tree_view_get_selection( ied->treeview );
+ listrows = gtk_tree_selection_get_selected_rows( selection, NULL );
- path = ( GtkTreePath * ) ipath->data;
- gtk_tree_model_get_iter( model, &iter, path );
- gtk_tree_model_get( model, &iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
-
- stop = fn_iter( instance, treeview, model, &iter, object, user_data );
-
- g_object_unref( object );
+ if( g_list_length( listrows ) == 1 ){
+ path = ( GtkTreePath * ) listrows->data;
+ column = gtk_tree_view_get_column( ied->treeview, TREE_COLUMN_LABEL );
+ gtk_tree_view_set_cursor( ied->treeview, path, column, TRUE );
}
g_list_foreach( listrows, ( GFunc ) gtk_tree_path_free, NULL );
g_list_free( listrows );
}
-
-static gboolean
-toggle_collapse_iter( NactIActionsList *instance,
- GtkTreeView *treeview,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- NAObject *object,
- gpointer user_data )
-{
- guint count;
- guint *toggle;
-
- toggle = ( guint * ) user_data;
-
- if( NA_IS_OBJECT_ITEM( object )){
-
- GtkTreePath *path = gtk_tree_model_get_path( model, iter );
-
- if( NA_IS_OBJECT_ITEM( object )){
- count = na_object_get_items_count( object );
-
- if(( count > 1 && NA_IS_OBJECT_ACTION( object )) ||
- ( count > 0 && NA_IS_OBJECT_MENU( object ))){
-
- toggle_collapse_row( treeview, path, toggle );
- }
- }
-
- gtk_tree_path_free( path );
-
- /* do not extend selection */
- if( *toggle == TOGGLE_EXPAND && FALSE ){
- extend_selection_to_childs( instance, treeview, model, iter );
- }
- }
-
- /* do not stop iteration */
- return( FALSE );
-}
-
-/*
- * toggle mode can be undefined, collapse or expand
- * it is set on the first row
- */
-static void
-toggle_collapse_row( GtkTreeView *treeview, GtkTreePath *path, guint *toggle )
-{
- if( *toggle == TOGGLE_UNDEFINED ){
- *toggle = gtk_tree_view_row_expanded( treeview, path ) ? TOGGLE_COLLAPSE : TOGGLE_EXPAND;
- }
-
- if( *toggle == TOGGLE_COLLAPSE ){
- if( gtk_tree_view_row_expanded( treeview, path )){
- gtk_tree_view_collapse_row( treeview, path );
- }
- } else {
- if( !gtk_tree_view_row_expanded( treeview, path )){
- gtk_tree_view_expand_row( treeview, path, TRUE );
- }
- }
-}
-#endif
diff --git a/src/nact/nact-tree-ieditable.h b/src/nact/nact-tree-ieditable.h
index fc4024d..df0be59 100644
--- a/src/nact/nact-tree-ieditable.h
+++ b/src/nact/nact-tree-ieditable.h
@@ -71,11 +71,12 @@ typedef struct {
GType nact_tree_ieditable_get_type( void );
void nact_tree_ieditable_initialize( NactTreeIEditable *instance, GtkTreeView *treeview, BaseWindow *window );
+void nact_tree_ieditable_terminate ( NactTreeIEditable *instance );
-void nact_tree_ieditable_delete ( NactTreeIEditable *instance, GList *items, gboolean select_at_end );
-void nact_tree_ieditable_insert_at_path ( NactTreeIEditable *instance, GList *items, GtkTreePath *path );
-void nact_tree_ieditable_insert_items ( NactTreeIEditable *instance, GList *items, NAObject *sibling );
-void nact_tree_ieditable_insert_items_into( NactTreeIEditable *instance, GList *items );
+void nact_tree_ieditable_delete ( NactTreeIEditable *instance, GList *items, gboolean select_at_end );
+void nact_tree_ieditable_insert_items ( NactTreeIEditable *instance, GList *items, NAObject *sibling );
+void nact_tree_ieditable_insert_at_path( NactTreeIEditable *instance, GList *items, GtkTreePath *path );
+void nact_tree_ieditable_insert_into ( NactTreeIEditable *instance, GList *items );
#if 0
void nact_tree_ieditable_brief_tree_dump( NactTreeIEditable *instance );
diff --git a/src/nact/nact-tree-model-dnd.c b/src/nact/nact-tree-model-dnd.c
index b7b83eb..3b8c418 100644
--- a/src/nact/nact-tree-model-dnd.c
+++ b/src/nact/nact-tree-model-dnd.c
@@ -127,7 +127,7 @@ static void drop_inside_move_dest( NactTreeModel *model, GList *rows, G
static gboolean drop_uri_list( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData *selection_data );
static NAObjectItem *is_dropped_already_exists( const NAObjectItem *importing, const NactMainWindow *window );
static char *get_xds_atom_value( GdkDragContext *context );
-static gboolean is_parent_accept_new_childs( NactApplication *application, NactMainWindow *window, NAObjectItem *parent );
+static gboolean is_parent_accept_new_children( NactApplication *application, NactMainWindow *window, NAObjectItem *parent );
static guint target_atom_to_id( GdkAtom atom );
/**
@@ -713,7 +713,7 @@ is_drop_possible( NactTreeModel *model, GtkTreePath *dest, NAObjectItem **parent
}
if( drop_ok ){
- drop_ok = is_parent_accept_new_childs( application, main_window, parent_dest );
+ drop_ok = is_parent_accept_new_children( application, main_window, parent_dest );
}
if( drop_ok && parent ){
@@ -1133,7 +1133,7 @@ get_xds_atom_value( GdkDragContext *context )
* to register the new child
*/
static gboolean
-is_parent_accept_new_childs( NactApplication *application, NactMainWindow *window, NAObjectItem *parent )
+is_parent_accept_new_children( NactApplication *application, NactMainWindow *window, NAObjectItem *parent )
{
gboolean accept_ok;
NAUpdater *updater;
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index b64901a..b96f830 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -584,7 +584,7 @@ nact_tree_model_fill( NactTreeModel *model, GList *items )
}
/**
- * nact_tree_model_insert:
+ * nact_tree_model_insert_before:
* @model: this #NactTreeModel instance.
* @object: a #NAObject-derived object to be inserted.
* @path: the #GtkTreePath which specifies the insertion path.
@@ -600,9 +600,9 @@ nact_tree_model_fill( NactTreeModel *model, GList *items )
* asked insertion path if tree is sorted.
*/
GtkTreePath *
-nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePath *path, NAObject **parent )
+nact_tree_model_insert_before( NactTreeModel *model, const NAObject *object, GtkTreePath *path )
{
- static const gchar *thisfn = "nact_tree_model_insert";
+ static const gchar *thisfn = "nact_tree_model_insert_before";
GtkTreeModel *store;
gchar *path_str;
GtkTreeIter iter;
@@ -616,11 +616,11 @@ nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePat
gboolean has_sibling;
path_str = gtk_tree_path_to_string( path );
- g_debug( "%s: model=%p, object=%p (%s, ref_count=%d), path=%p (%s), parent=%p",
+ g_debug( "%s: model=%p, object=%p (%s, ref_count=%d), path=%p (%s)",
thisfn,
( void * ) model,
( void * ) object, G_OBJECT_TYPE_NAME( object ), G_OBJECT( object )->ref_count,
- ( void * ) path, path_str, ( void * ) parent );
+ ( void * ) path, path_str );
g_free( path_str );
g_return_val_if_fail( NACT_IS_TREE_MODEL( model ), NULL );
g_return_val_if_fail( NA_IS_OBJECT( object ), NULL );
@@ -655,10 +655,6 @@ nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePat
gtk_tree_model_get( store, &parent_iter, TREE_COLUMN_NAOBJECT, &parent_obj, -1 );
g_object_unref( parent_obj );
- if( parent && !*parent ){
- *parent = parent_obj;
- }
-
if( has_sibling ){
na_object_insert_item( parent_obj, object, sibling_obj );
} else {
@@ -684,13 +680,18 @@ nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePat
/**
* nact_tree_model_insert_into:
- * @model:
- * @object:
- * @path:
- * @parent:
+ * @model: this #NactTreeModel instance.
+ * @object: the #NAObject to be inserted.
+ * @path: the wished #GtkTreePath path.
+ *
+ * Insert the @object at ou near the wished @path, and attaches the object
+ * to its new parent.
+ *
+ * Returns the actual insertion path, wchich should be gtk_tree_path_free()
+ * by the caller.
*/
GtkTreePath *
-nact_tree_model_insert_into( NactTreeModel *model, const NAObject *object, GtkTreePath *path, NAObject **parent )
+nact_tree_model_insert_into( NactTreeModel *model, const NAObject *object, GtkTreePath *path )
{
static const gchar *thisfn = "nact_tree_model_insert_into";
GtkTreeModel *store;
@@ -698,6 +699,7 @@ nact_tree_model_insert_into( NactTreeModel *model, const NAObject *object, GtkTr
GtkTreeIter parent_iter;
GtkTreePath *new_path;
gchar *path_str;
+ NAObject *parent;
path_str = gtk_tree_path_to_string( path );
g_debug( "%s: model=%p, object=%p (%s, ref_count=%d), path=%p (%s), parent=%p",
@@ -721,11 +723,11 @@ nact_tree_model_insert_into( NactTreeModel *model, const NAObject *object, GtkTr
g_free( path_str );
return( NULL );
}
- gtk_tree_model_get( store, &parent_iter, TREE_COLUMN_NAOBJECT, parent, -1 );
- g_object_unref( *parent );
- na_object_insert_item( *parent, object, NULL );
- na_object_set_parent( object, *parent );
+ gtk_tree_model_get( store, &parent_iter, TREE_COLUMN_NAOBJECT, &parent, -1 );
+ g_object_unref( parent );
+ na_object_insert_item( parent, object, NULL );
+ na_object_set_parent( object, parent );
gtk_tree_store_insert_after( GTK_TREE_STORE( store ), &iter, &parent_iter, NULL );
gtk_tree_store_set( GTK_TREE_STORE( store ), &iter, TREE_COLUMN_NAOBJECT, object, -1 );
@@ -796,6 +798,7 @@ nact_tree_model_get_items( const NactTreeModel *model, guint mode )
ngi.items = NULL;
store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
iter_on_store( model, GTK_TREE_MODEL( store ), NULL, ( FnIterOnStore ) get_items_iter, &ngi );
+ items = ngi.items;
}
return( items );
diff --git a/src/nact/nact-tree-model.h b/src/nact/nact-tree-model.h
index c9a9ca2..b326261 100644
--- a/src/nact/nact-tree-model.h
+++ b/src/nact/nact-tree-model.h
@@ -99,10 +99,10 @@ GType nact_tree_model_get_type( void );
NactTreeModel *nact_tree_model_new( BaseWindow *window, GtkTreeView *view, NactTreeMode mode );
-GtkTreePath *nact_tree_model_delete ( NactTreeModel *model, NAObject *object );
-void nact_tree_model_fill ( NactTreeModel *model, GList *items );
-GtkTreePath *nact_tree_model_insert ( NactTreeModel *model, const NAObject *object, GtkTreePath *path, NAObject **parent );
-GtkTreePath *nact_tree_model_insert_into( NactTreeModel *model, const NAObject *object, GtkTreePath *path, NAObject **parent );
+GtkTreePath *nact_tree_model_delete ( NactTreeModel *model, NAObject *object );
+void nact_tree_model_fill ( NactTreeModel *model, GList *items );
+GtkTreePath *nact_tree_model_insert_before( NactTreeModel *model, const NAObject *object, GtkTreePath *path );
+GtkTreePath *nact_tree_model_insert_into ( NactTreeModel *model, const NAObject *object, GtkTreePath *path );
NAObjectItem *nact_tree_model_get_item_by_id( const NactTreeModel *model, const gchar *id );
GList *nact_tree_model_get_items ( const NactTreeModel *model, guint mode );
diff --git a/src/nact/nact-tree-view.c b/src/nact/nact-tree-view.c
index 3c9d78e..da777da 100644
--- a/src/nact/nact-tree-view.c
+++ b/src/nact/nact-tree-view.c
@@ -571,6 +571,8 @@ instance_dispose( GObject *object )
self->private->dispose_has_run = TRUE;
+ nact_tree_ieditable_terminate( NACT_TREE_IEDITABLE( self ));
+
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
G_OBJECT_CLASS( st_parent_class )->dispose( object );
@@ -907,11 +909,9 @@ nact_tree_view_fill( NactTreeView *view, GList *items )
if( view->private->notify_allowed ){
g_signal_emit_by_name( view->private->window, TREE_SIGNAL_CONTENT_CHANGED, view, NULL );
-
- nb_menus = nb_actions = nb_profiles = 0;
- na_object_item_count_items( items, &nb_menus, &nb_actions, &nb_profiles, TRUE );
- g_signal_emit_by_name( view->private->window,
- TREE_SIGNAL_COUNT_CHANGED, view, TRUE, nb_menus, nb_actions, nb_profiles );
+ na_object_count_items( items, &nb_menus, &nb_actions, &nb_profiles );
+ g_signal_emit_by_name( view->private->window, TREE_SIGNAL_COUNT_CHANGED, view, TRUE, nb_menus, nb_actions, nb_profiles );
+ g_signal_emit_by_name( view->private->window, TREE_SIGNAL_MODIFIED_COUNT_CHANGED, view, 0 );
}
select_row_at_path_by_string( view, "0" );
@@ -1008,29 +1008,6 @@ nact_tree_view_get_items( const NactTreeView *view )
}
/**
- * nact_tree_view_get_window:
- * @view: this #NactTreeView instance.
- *
- * Returns: the #BaseWindow.
- */
-BaseWindow *
-nact_tree_view_get_window( const NactTreeView *view )
-{
- BaseWindow *window;
-
- g_return_val_if_fail( NACT_IS_TREE_VIEW( view ), NULL );
-
- window = NULL;
-
- if( !view->private->dispose_has_run ){
-
- window = view->private->window;
- }
-
- return( window );
-}
-
-/**
* nact_tree_view_select_row_at_path:
*
*
@@ -1145,7 +1122,7 @@ display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *m
}
/*
- * when expanding a selected row which has childs
+ * when expanding a selected row which has children
*/
static void
extend_selection_to_children( NactTreeView *view, GtkTreeModel *model, GtkTreeIter *parent )
diff --git a/src/nact/nact-tree-view.h b/src/nact/nact-tree-view.h
index 0f4883b..4c51e03 100644
--- a/src/nact/nact-tree-view.h
+++ b/src/nact/nact-tree-view.h
@@ -112,7 +112,6 @@ void nact_tree_view_collapse_all ( const NactTreeView *view );
void nact_tree_view_expand_all ( const NactTreeView *view );
NAObjectItem *nact_tree_view_get_item_by_id( const NactTreeView *view, const gchar *id );
GList *nact_tree_view_get_items ( const NactTreeView *view );
-BaseWindow *nact_tree_view_get_window ( const NactTreeView *view );
void nact_tree_view_select_row_at_path( NactTreeView *view, GtkTreePath *path );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]