[nautilus-actions] NactIActionsList refactoring: remove deprecated references
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] NactIActionsList refactoring: remove deprecated references
- Date: Fri, 11 Feb 2011 00:18:19 +0000 (UTC)
commit 5248adefe09b81f736feb3943835ada4271236d2
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Feb 4 01:54:04 2011 +0100
NactIActionsList refactoring: remove deprecated references
ChangeLog | 8 +
src/core/na-boxed.c | 2 +-
src/core/na-marshal.def | 2 +-
src/nact/Makefile.am | 10 +-
src/nact/nact-assistant-export.c | 6 +-
src/nact/nact-assistant-import.c | 7 +-
src/nact/nact-iaction-tab.c | 17 +-
src/nact/nact-iactions-list-priv.c | 7 -
src/nact/nact-icommand-tab.c | 17 +-
src/nact/nact-main-toolbar.c | 8 +-
src/nact/nact-main-toolbar.h | 2 +-
src/nact/nact-main-window.c | 526 +++++++----------
src/nact/nact-main-window.h | 12 +-
src/nact/nact-marshal.def | 10 +-
src/nact/nact-menubar-edit.c | 107 ++--
src/nact/nact-menubar-file.c | 91 ++--
src/nact/nact-menubar-help.c | 10 +-
src/nact/nact-menubar-maintainer.c | 41 +-
src/nact/nact-menubar-priv.h | 85 ++--
src/nact/nact-menubar-tools.c | 10 +-
src/nact/nact-menubar-view.c | 45 +-
src/nact/nact-menubar.c | 286 +++++----
src/nact/nact-menubar.h | 7 +-
src/nact/nact-sort-buttons.c | 44 +-
src/nact/nact-sort-buttons.h | 14 +-
src/nact/nact-tree-ieditable.c | 1211 ++++++++++++++++++++++++++++++++++++
src/nact/nact-tree-ieditable.h | 118 ++++
src/nact/nact-tree-model-dnd.c | 13 +-
src/nact/nact-tree-model-dnd.h | 64 --
src/nact/nact-tree-model-priv.h | 33 +-
src/nact/nact-tree-model.c | 448 +++++++-------
src/nact/nact-tree-model.h | 47 ++-
src/nact/nact-tree-view.c | 394 ++++++++++---
src/nact/nact-tree-view.h | 47 +-
src/nact/nact-window.c | 31 -
src/nact/nact-window.h | 2 -
36 files changed, 2643 insertions(+), 1139 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2d7b339..fec2902 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-02-03 Pierre Wieser <pwieser trychlos org>
+
+ In the process of replacing NactIActionsList interface with:
+ - the NactTreeView class
+ - plus the NactTreeIEditable interface.
+
+ Almost all NACT files modified. Compilation is OK.
+
2011-02-02 Pierre Wieser <pwieser trychlos org>
* src/nact/nact-tree-model.c:
diff --git a/src/core/na-boxed.c b/src/core/na-boxed.c
index cde7fbb..e9ff67a 100644
--- a/src/core/na-boxed.c
+++ b/src/core/na-boxed.c
@@ -987,7 +987,7 @@ uint_list_dump( const NABoxed *boxed )
if( strlen( str->str )){
str = g_string_append( str, "," );
}
- g_string_append_printf( str, "%u", ( guint ) i->data );
+ g_string_append_printf( str, "%u", GPOINTER_TO_UINT( i->data ));
}
return( g_string_free( str, FALSE ));
diff --git a/src/core/na-marshal.def b/src/core/na-marshal.def
index 7551e1c..d061759 100644
--- a/src/core/na-marshal.def
+++ b/src/core/na-marshal.def
@@ -1,2 +1,2 @@
-# NASettings::settings-key-changed
+# NASettings:: SETTINGS_SIGNAL_KEY_CHANGED
VOID:STRING,STRING,POINTER,BOOLEAN
diff --git a/src/nact/Makefile.am b/src/nact/Makefile.am
index 446b7de..5c01e36 100644
--- a/src/nact/Makefile.am
+++ b/src/nact/Makefile.am
@@ -88,11 +88,6 @@ nautilus_actions_config_tool_SOURCES = \
nact-export-ask.h \
nact-export-format.c \
nact-export-format.h \
- nact-iactions-list.c \
- nact-iactions-list.h \
- nact-iactions-list-bis.c \
- nact-iactions-list-priv.c \
- nact-iactions-list-priv.h \
nact-iaction-tab.c \
nact-iaction-tab.h \
nact-ibasenames-tab.c \
@@ -142,11 +137,12 @@ nautilus_actions_config_tool_SOURCES = \
nact-schemes-list.h \
nact-sort-buttons.c \
nact-sort-buttons.h \
+ nact-tree-ieditable.c \
+ nact-tree-ieditable.h \
nact-tree-model.c \
nact-tree-model.h \
- nact-tree-model-dnd.c \
- nact-tree-model-dnd.h \
nact-tree-model-priv.h \
+ nact-tree-model-dnd.c \
nact-tree-view.c \
nact-tree-view.h \
nact-window.c \
diff --git a/src/nact/nact-assistant-export.c b/src/nact/nact-assistant-export.c
index 2fb2e98..5831ccb 100644
--- a/src/nact/nact-assistant-export.c
+++ b/src/nact/nact-assistant-export.c
@@ -296,7 +296,7 @@ nact_assistant_export_run( BaseWindow *main_window )
BASE_PROP_WARN_ON_ESCAPE, esc_confirm,
NULL );
- assistant->private->items_view = nact_tree_view_new( BASE_WINDOW( assistant ), "ActionsList" );
+ assistant->private->items_view = nact_tree_view_new( BASE_WINDOW( assistant ), "ActionsList", TREE_MODE_SELECTION );
base_window_run( BASE_WINDOW( assistant ));
}
@@ -356,6 +356,7 @@ on_base_all_widgets_showed( NactAssistantExport *dialog, gpointer user_data )
{
static const gchar *thisfn = "nact_assistant_export_on_base_all_widgets_showed";
NactMainWindow *main_window;
+ NactTreeView *main_items_view;
GList *items;
g_return_if_fail( NACT_IS_ASSISTANT_EXPORT( dialog ));
@@ -367,7 +368,8 @@ on_base_all_widgets_showed( NactAssistantExport *dialog, gpointer user_data )
* have connected their signal handlers
*/
main_window = NACT_MAIN_WINDOW( base_window_get_parent( BASE_WINDOW( dialog )));
- items = nact_main_window_get_current_items( main_window );
+ main_items_view = nact_main_window_get_items_view( main_window );
+ items = nact_tree_view_get_items( main_items_view );
nact_tree_view_fill( dialog->private->items_view, items );
}
}
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index a76d34d..c8318fc 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -42,7 +42,6 @@
#include <core/na-iprefs.h>
#include "nact-application.h"
-#include "nact-iactions-list.h"
#include "nact-assistant-import.h"
#include "nact-main-window.h"
@@ -679,7 +678,9 @@ assistant_apply( BaseAssistant *wnd, GtkAssistant *assistant )
* assuring that actions will be inserted in the same order as uris
*/
imported_items = g_list_reverse( imported_items );
+#if 0
nact_iactions_list_bis_insert_items( NACT_IACTIONS_LIST( main_window ), imported_items, NULL );
+#endif
na_object_free_items( imported_items );
}
@@ -687,6 +688,7 @@ static NAObjectItem *
check_for_existence( const NAObjectItem *item, NactMainWindow *window )
{
static const gchar *thisfn = "nact_assistant_import_check_for_existence";
+ NactTreeView *items_view;
NAObjectItem *exists;
gchar *importing_id;
@@ -694,7 +696,8 @@ check_for_existence( const NAObjectItem *item, NactMainWindow *window )
g_debug( "%s: item=%p (%s), importing_id=%s",
thisfn, ( void * ) item, G_OBJECT_TYPE_NAME( item ), importing_id );
- exists = nact_main_window_get_item( window, importing_id );
+ items_view = nact_main_window_get_items_view( window );
+ exists = nact_tree_view_get_item_by_id( items_view, importing_id );
g_free( importing_id );
diff --git a/src/nact/nact-iaction-tab.c b/src/nact/nact-iaction-tab.c
index b13cdca..5a93388 100644
--- a/src/nact/nact-iaction-tab.c
+++ b/src/nact/nact-iaction-tab.c
@@ -44,7 +44,6 @@
#include "nact-application.h"
#include "nact-main-statusbar.h"
#include "base-gtk-utils.h"
-#include "nact-iactions-list.h"
#include "nact-main-tab.h"
#include "nact-iaction-tab.h"
#include "nact-icon-chooser.h"
@@ -67,7 +66,7 @@ static GType register_type( void );
static void interface_base_init( NactIActionTabInterface *klass );
static void interface_base_finalize( NactIActionTabInterface *klass );
-static void on_iactions_list_column_edited( NactIActionTab *instance, NAObject *object, gchar *text, gint column );
+static void on_tree_view_content_changed( NactIActionTab *instance, NactTreeView *view, NAObject *object, gpointer user_data );
static void on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selected );
static void on_target_selection_toggled( GtkToggleButton *button, NactIActionTab *instance );
@@ -224,11 +223,8 @@ nact_iaction_tab_runtime_init_toplevel( NactIActionTab *instance )
MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
G_CALLBACK( on_tab_updatable_selection_changed ));
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- IACTIONS_LIST_SIGNAL_COLUMN_EDITED,
- G_CALLBACK( on_iactions_list_column_edited ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), TREE_SIGNAL_CONTENT_CHANGED, G_CALLBACK( on_tree_view_content_changed ));
button = base_window_get_widget( BASE_WINDOW( instance ), "ActionTargetSelectionButton" );
base_window_signal_connect(
@@ -349,9 +345,10 @@ nact_iaction_tab_has_label( NactIActionTab *instance )
}
static void
-on_iactions_list_column_edited( NactIActionTab *instance, NAObject *object, gchar *text, gint column )
+on_tree_view_content_changed( NactIActionTab *instance, NactTreeView *view, NAObject *object, gpointer user_data )
{
GtkWidget *label_widget;
+ gchar *label;
g_return_if_fail( NACT_IS_IACTION_TAB( instance ));
@@ -359,7 +356,9 @@ on_iactions_list_column_edited( NactIActionTab *instance, NAObject *object, gcha
if( object && NA_IS_OBJECT_ITEM( object )){
label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionMenuLabelEntry" );
- gtk_entry_set_text( GTK_ENTRY( label_widget ), text );
+ label = na_object_get_label( object );
+ gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
+ g_free( label );
}
}
}
diff --git a/src/nact/nact-iactions-list-priv.c b/src/nact/nact-iactions-list-priv.c
index d300693..af8421a 100644
--- a/src/nact/nact-iactions-list-priv.c
+++ b/src/nact/nact-iactions-list-priv.c
@@ -34,7 +34,6 @@
#include "base-window.h"
#include "nact-iactions-list-priv.h"
-#include "nact-tree-view.h"
#define IACTIONS_LIST_DATA_INSTANCE "nact-iactions-list-instance-data"
@@ -71,7 +70,6 @@ IActionsListInstanceData *
nact_iactions_list_priv_get_instance_data( NactIActionsList *instance )
{
IActionsListInstanceData *ialid;
- NactTreeView *view;
ialid = ( IActionsListInstanceData * ) g_object_get_data( G_OBJECT( instance ), IACTIONS_LIST_DATA_INSTANCE );
@@ -80,11 +78,6 @@ nact_iactions_list_priv_get_instance_data( NactIActionsList *instance )
g_object_set_data( G_OBJECT( instance ), IACTIONS_LIST_DATA_INSTANCE, ialid );
}
- view = ( NactTreeView * ) g_object_get_data( G_OBJECT( instance ), "window-data-tree-view" );
- if( view && NACT_IS_TREE_VIEW( view )){
- nact_tree_view_setup_ialid( view, ialid );
- }
-
return( ialid );
}
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index d9e27f0..b3feee7 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -46,7 +46,6 @@
#include "nact-application.h"
#include "nact-main-statusbar.h"
#include "base-gtk-utils.h"
-#include "nact-iactions-list.h"
#include "nact-main-tab.h"
#include "nact-icommand-tab.h"
#include "nact-ischemes-tab.h"
@@ -71,7 +70,7 @@ static GType register_type( void );
static void interface_base_init( NactICommandTabInterface *klass );
static void interface_base_finalize( NactICommandTabInterface *klass );
-static void on_iactions_list_column_edited( NactICommandTab *instance, NAObject *object, gchar *text, gint column );
+static void on_tree_view_content_changed( NactICommandTab *instance, NactTreeView *view, NAObject *object, gpointer user_data );
static void on_tab_updatable_selection_changed( NactICommandTab *instance, gint count_selected );
static GtkWidget *get_label_entry( NactICommandTab *instance );
@@ -268,11 +267,8 @@ nact_icommand_tab_runtime_init_toplevel( NactICommandTab *instance )
MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
G_CALLBACK( on_tab_updatable_selection_changed ));
- base_window_signal_connect(
- BASE_WINDOW( instance ),
- G_OBJECT( instance ),
- IACTIONS_LIST_SIGNAL_COLUMN_EDITED,
- G_CALLBACK( on_iactions_list_column_edited ));
+ base_window_signal_connect( BASE_WINDOW( instance ),
+ G_OBJECT( instance ), TREE_SIGNAL_CONTENT_CHANGED, G_CALLBACK( on_tree_view_content_changed ));
/* allocate a static fake NATokens object which will be user to build
* the example label - this object will be unreffed on dispose
@@ -322,9 +318,10 @@ nact_icommand_tab_dispose( NactICommandTab *instance )
}
static void
-on_iactions_list_column_edited( NactICommandTab *instance, NAObject *object, gchar *text, gint column )
+on_tree_view_content_changed( NactICommandTab *instance, NactTreeView *view, NAObject *object, gpointer user_data )
{
GtkWidget *label_widget;
+ gchar *label;
g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
@@ -332,7 +329,9 @@ on_iactions_list_column_edited( NactICommandTab *instance, NAObject *object, gch
if( NA_IS_OBJECT_PROFILE( object )){
label_widget = get_label_entry( instance );
- gtk_entry_set_text( GTK_ENTRY( label_widget ), text );
+ label = na_object_get_label( object );
+ gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
+ g_free( label );
}
}
}
diff --git a/src/nact/nact-main-toolbar.c b/src/nact/nact-main-toolbar.c
index 4e344bd..1f280cf 100644
--- a/src/nact/nact-main-toolbar.c
+++ b/src/nact/nact-main-toolbar.c
@@ -63,7 +63,7 @@ static int toolbar_pos[] = {
MAIN_TOOLBAR_HELP_ID
};
-static void init_toolbar( NactMainWindow *window, GtkActionGroup *group, int toolbar_id );
+static void init_toolbar( BaseWindow *window, GtkActionGroup *group, int toolbar_id );
static void reorder_toolbars( GtkHBox *hbox, int toolbar_id, GtkWidget *handle );
static void on_handle_finalize( gpointer data, GObject *handle );
static void on_attach_toolbar( GtkHandleBox *handle, GtkToolbar *toolbar, NactMainWindow *window );
@@ -82,7 +82,7 @@ static ToolbarProps *get_toolbar_properties( int toolbar_id );
* toolbar.
*/
void
-nact_main_toolbar_init( NactMainWindow *window, GtkActionGroup *group )
+nact_main_toolbar_init( BaseWindow *window, GtkActionGroup *group )
{
static const gchar *thisfn = "nact_main_toolbar_init";
int i;
@@ -95,7 +95,7 @@ nact_main_toolbar_init( NactMainWindow *window, GtkActionGroup *group )
}
static void
-init_toolbar( NactMainWindow *window, GtkActionGroup *group, int toolbar_id )
+init_toolbar( BaseWindow *window, GtkActionGroup *group, int toolbar_id )
{
NactApplication *application;
NAUpdater *updater;
@@ -103,7 +103,7 @@ init_toolbar( NactMainWindow *window, GtkActionGroup *group, int toolbar_id )
gboolean is_active;
GtkToggleAction *action;
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+ application = NACT_APPLICATION( base_window_get_application( window ));
updater = nact_application_get_updater( application );
props = get_toolbar_properties( toolbar_id );
if( props ){
diff --git a/src/nact/nact-main-toolbar.h b/src/nact/nact-main-toolbar.h
index ebafaf9..b389040 100644
--- a/src/nact/nact-main-toolbar.h
+++ b/src/nact/nact-main-toolbar.h
@@ -48,7 +48,7 @@ enum {
MAIN_TOOLBAR_HELP_ID,
};
-void nact_main_toolbar_init( NactMainWindow *window, GtkActionGroup *group );
+void nact_main_toolbar_init( BaseWindow *window, GtkActionGroup *group );
void nact_main_toolbar_activate( NactMainWindow *window, int toolbar_id, GtkUIManager *manager, gboolean active );
G_END_DECLS
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 479ff93..e6d1fb6 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -41,7 +41,6 @@
#include <core/na-iprefs.h>
#include <core/na-pivot.h>
-#include "nact-iactions-list.h"
#include "nact-iaction-tab.h"
#include "nact-icommand-tab.h"
#include "nact-ibasenames-tab.h"
@@ -57,6 +56,7 @@
#include "nact-marshal.h"
#include "nact-main-window.h"
#include "nact-menubar.h"
+#include "nact-tree-view.h"
#include "nact-confirm-logout.h"
#include "nact-sort-buttons.h"
@@ -110,9 +110,11 @@ struct _NactMainWindowPrivate {
NAObjectProfile *selected_profile;
/**
- * The convenience clipboard object.
+ * Some convenience objects.
*/
+ NactTreeView *items_view;
NactClipboard *clipboard;
+ guint count_modified;
};
/* action properties
@@ -129,7 +131,6 @@ enum {
*/
enum {
PROVIDER_CHANGED,
- SELECTION_CHANGED,
ITEM_UPDATED,
ORDER_CHANGED,
LAST_SIGNAL
@@ -144,7 +145,6 @@ static gint st_signals[ LAST_SIGNAL ] = { 0 };
static GType register_type( void );
static void class_init( NactMainWindowClass *klass );
-static void iactions_list_iface_init( NactIActionsListInterface *iface );
static void iaction_tab_iface_init( NactIActionTabInterface *iface );
static void icommand_tab_iface_init( NactICommandTabInterface *iface );
static void ibasenames_tab_iface_init( NactIBasenamesTabInterface *iface );
@@ -167,6 +167,12 @@ static void on_base_initialize_gtk_toplevel( NactMainWindow *window, GtkWind
static void on_base_initialize_base_window( NactMainWindow *window, gpointer user_data );
static void on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data );
+static void on_tree_view_modified_count_changed( NactMainWindow *window, NactTreeView *view, guint count, gpointer user_data );
+static void on_tree_view_selection_changed( NactMainWindow *window, NactTreeView *view, GList *selected_items, gpointer user_data );
+static void raz_selection_properties( NactMainWindow *window );
+static void setup_current_selection( NactMainWindow *window, NAObjectId *selected_row );
+static void setup_dialog_title( NactMainWindow *window );
+static void setup_writability_status( NactMainWindow *window );
static void on_pivot_items_changed( NAUpdater *updater, NactMainWindow *window );
static gboolean confirm_for_giveup_from_pivot( const NactMainWindow *window );
static gboolean confirm_for_giveup_from_menu( const NactMainWindow *window );
@@ -174,22 +180,15 @@ static void reload_items( NactMainWindow *window );
static gboolean base_is_willing_to_quit( const BaseWindow *window );
static gboolean on_delete_event( GtkWidget *toplevel, GdkEvent *event, NactMainWindow *window );
+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 void on_main_window_level_zero_order_changed( NactMainWindow *window, gpointer user_data );
-static void on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected_items );
-static void on_iactions_list_status_changed( NactMainWindow *window, gpointer user_data );
-static void raz_main_properties( NactMainWindow *window );
-static void setup_current_selection( NactMainWindow *window, NAObjectId *selected_row );
-static void setup_dialog_title( NactMainWindow *window );
-static void setup_writability_status( NactMainWindow *window );
-static gchar *iactions_list_get_treeview_name( NactIActionsList *instance );
-
+#endif
static void on_tab_updatable_item_updated( NactMainWindow *window, gpointer user_data, gboolean force_display );
-
static void on_settings_order_mode_changed( const gchar *group, const gchar *key, gconstpointer new_value, gboolean mandatory, NactMainWindow *window );
-
static gchar *iabout_get_application_name( NAIAbout *instance );
static GtkWindow *iabout_get_toplevel( NAIAbout *instance );
@@ -224,12 +223,6 @@ register_type( void )
( GInstanceInitFunc ) instance_init
};
- static const GInterfaceInfo iactions_list_iface_info = {
- ( GInterfaceInitFunc ) iactions_list_iface_init,
- NULL,
- NULL
- };
-
static const GInterfaceInfo iaction_tab_iface_info = {
( GInterfaceInitFunc ) iaction_tab_iface_init,
NULL,
@@ -300,8 +293,6 @@ register_type( void )
type = g_type_register_static( NACT_WINDOW_TYPE, "NactMainWindow", &info, 0 );
- g_type_add_interface_static( type, NACT_IACTIONS_LIST_TYPE, &iactions_list_iface_info );
-
g_type_add_interface_static( type, NACT_IACTION_TAB_TYPE, &iaction_tab_iface_info );
g_type_add_interface_static( type, NACT_ICOMMAND_TAB_TYPE, &icommand_tab_iface_info );
@@ -400,33 +391,6 @@ class_init( NactMainWindowClass *klass )
G_TYPE_POINTER );
/**
- * main-window-selection-changed:
- *
- * This signal is emitted by this main window, in response of a
- * change of the selection in IActionsList, after having updated
- * its properties.
- * Notebook tabs should connect to this signal and update their
- * display to reflect the content of the new selection (if applyable).
- *
- * Note also that, where this main window will receive from
- * IActionsList the full list of currently selected items, this
- * signal only carries to the tabs the count of selected items.
- *
- * See #iactions_list_selection_changed().
- */
- st_signals[ SELECTION_CHANGED ] = g_signal_new(
- MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
- G_TYPE_OBJECT,
- G_SIGNAL_RUN_LAST,
- 0, /* no default handler */
- NULL,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1,
- G_TYPE_POINTER );
-
- /**
* nact-tab-updatable-item-updated:
*
* This signal is emitted by the notebook tabs, when any property
@@ -469,16 +433,6 @@ class_init( NactMainWindowClass *klass )
}
static void
-iactions_list_iface_init( NactIActionsListInterface *iface )
-{
- static const gchar *thisfn = "nact_main_window_iactions_list_iface_init";
-
- g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
-
- iface->get_treeview_name = iactions_list_get_treeview_name;
-}
-
-static void
iaction_tab_iface_init( NactIActionTabInterface *iface )
{
static const gchar *thisfn = "nact_main_window_iaction_tab_iface_init";
@@ -687,8 +641,20 @@ instance_constructed( GObject *window )
base_window_signal_connect( BASE_WINDOW( window ),
G_OBJECT( window ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, G_CALLBACK( on_tab_updatable_item_updated ));
+ /* create the tree view which will create itself its own tree model
+ */
+ self->private->items_view = nact_tree_view_new( BASE_WINDOW( window ), "ActionsList", TREE_MODE_EDITION );
+
+ base_window_signal_connect( BASE_WINDOW( window ),
+ G_OBJECT( window ), TREE_SIGNAL_MODIFIED_COUNT_CHANGED, G_CALLBACK( on_tree_view_modified_count_changed ));
+
+ /* create the menubar
+ * it will create itself toolbar and statusbar
+ */
nact_menubar_new( BASE_WINDOW( window ));
+ self->private->clipboard = nact_clipboard_new( BASE_WINDOW( window ));
+
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->constructed ){
G_OBJECT_CLASS( st_parent_class )->constructed( window );
@@ -728,8 +694,8 @@ instance_dispose( GObject *window )
}
na_object_free_items( self->private->deleted );
- nact_iactions_list_dispose( NACT_IACTIONS_LIST( window ));
- nact_sort_buttons_dispose( self );
+ nact_sort_buttons_dispose( BASE_WINDOW( self ));
+
nact_iaction_tab_dispose( NACT_IACTION_TAB( window ));
nact_icommand_tab_dispose( NACT_ICOMMAND_TAB( window ));
nact_ibasenames_tab_dispose( NACT_IBASENAMES_TAB( window ));
@@ -805,9 +771,6 @@ on_base_initialize_gtk_toplevel( NactMainWindow *window, GtkWindow *toplevel, gp
g_debug( "%s: window=%p, toplevel=%p, user_data=%p",
thisfn, ( void * ) window, ( void * ) toplevel, ( void * ) user_data );
- nact_iactions_list_set_management_mode( NACT_IACTIONS_LIST( window ), IACTIONS_LIST_MANAGEMENT_MODE_EDITION );
- nact_iactions_list_initial_load_toplevel( NACT_IACTIONS_LIST( window ));
-
nact_iaction_tab_initial_load_toplevel( NACT_IACTION_TAB( window ));
nact_icommand_tab_initial_load_toplevel( NACT_ICOMMAND_TAB( window ));
nact_ibasenames_tab_initial_load_toplevel( NACT_IBASENAMES_TAB( window ));
@@ -830,7 +793,6 @@ on_base_initialize_base_window( NactMainWindow *window, gpointer user_data )
NASettings *settings;
guint pos;
GtkWidget *pane;
- GList *tree;
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
@@ -845,10 +807,8 @@ on_base_initialize_base_window( NactMainWindow *window, gpointer user_data )
gtk_paned_set_position( GTK_PANED( pane ), pos );
}
- window->private->clipboard = nact_clipboard_new( BASE_WINDOW( window ));
-
base_window_signal_connect( BASE_WINDOW( window ),
- G_OBJECT( window ), IACTIONS_LIST_SIGNAL_SELECTION_CHANGED, G_CALLBACK( on_iactions_list_selection_changed ));
+ G_OBJECT( window ), TREE_SIGNAL_SELECTION_CHANGED, G_CALLBACK( on_tree_view_selection_changed ));
nact_iaction_tab_runtime_init_toplevel( NACT_IACTION_TAB( window ));
nact_icommand_tab_runtime_init_toplevel( NACT_ICOMMAND_TAB( window ));
@@ -863,25 +823,13 @@ on_base_initialize_base_window( NactMainWindow *window, gpointer user_data )
na_settings_register_key_callback( settings, NA_IPREFS_ITEMS_LIST_ORDER_MODE, G_CALLBACK( on_settings_order_mode_changed ), window );
- /* fill the IActionsList at last so that all signals are connected
- */
- tree = na_updater_load_items( window->private->updater );
- g_debug( "%s: pivot_tree=%p", thisfn, ( void * ) tree );
- nact_iactions_list_runtime_init_toplevel( NACT_IACTIONS_LIST( window ), tree );
-
/* other initializations
*/
- nact_sort_buttons_runtime_init( window );
+ nact_sort_buttons_runtime_init( BASE_WINDOW( window ));
- /* this to update the title when an item is modified
+ /* terminate the application by clicking the top right [X] button
*/
base_window_signal_connect( BASE_WINDOW( window ),
- G_OBJECT( window ), IACTIONS_LIST_SIGNAL_STATUS_CHANGED, G_CALLBACK( on_iactions_list_status_changed ));
-
- base_window_signal_connect( BASE_WINDOW( window ),
- G_OBJECT( window ), MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED, G_CALLBACK( on_main_window_level_zero_order_changed ));
-
- base_window_signal_connect( BASE_WINDOW( window ),
G_OBJECT( base_window_get_gtk_toplevel( BASE_WINDOW( window ))),
"delete-event", G_CALLBACK( on_delete_event ));
}
@@ -891,9 +839,9 @@ static void
on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data )
{
static const gchar *thisfn = "nact_main_window_on_base_all_widgets_showed";
+ GList *tree;
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
- g_return_if_fail( NACT_IS_IACTIONS_LIST( window ));
g_return_if_fail( NACT_IS_IACTION_TAB( window ));
g_return_if_fail( NACT_IS_ICOMMAND_TAB( window ));
g_return_if_fail( NACT_IS_IBASENAMES_TAB( window ));
@@ -907,7 +855,12 @@ on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data )
if( !window->private->dispose_has_run ){
g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
- raz_main_properties( window );
+ raz_selection_properties( window );
+
+ /* fill the items tree view at last so that all signals are connected
+ */
+ tree = na_updater_load_items( window->private->updater );
+ nact_tree_view_fill( window->private->items_view, tree );
nact_iaction_tab_all_widgets_showed( NACT_IACTION_TAB( window ));
nact_icommand_tab_all_widgets_showed( NACT_ICOMMAND_TAB( window ));
@@ -920,8 +873,7 @@ on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data )
nact_iexecution_tab_all_widgets_showed( NACT_IEXECUTION_TAB( window ));
nact_iproperties_tab_all_widgets_showed( NACT_IPROPERTIES_TAB( window ));
- nact_iactions_list_all_widgets_showed( NACT_IACTIONS_LIST( window ));
- nact_sort_buttons_all_widgets_showed( window );
+ nact_sort_buttons_all_widgets_showed( BASE_WINDOW( window ));
}
}
@@ -929,7 +881,7 @@ on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data )
* nact_main_window_get_clipboard:
* @window: this #NactMainWindow instance.
*
- * Returns: the #nactClipboard convenience object.
+ * Returns: the #NactClipboard convenience object.
*/
NactClipboard *
nact_main_window_get_clipboard( const NactMainWindow *window )
@@ -949,40 +901,26 @@ nact_main_window_get_clipboard( const NactMainWindow *window )
}
/**
- * nact_main_window_get_item:
+ * nact_main_window_get_items_view:
* @window: this #NactMainWindow instance.
- * @id: the identifier to check for existancy.
- *
- * Returns: a pointer to the #NAObjectItem if it exists in the current
- * tree, or %NULL else.
*
- * Do not check in NAPivot: actions which are not displayed in the user
- * interface are not considered as existing.
- *
- * Also note that the returned object may be an action, but also a menu.
+ * Returns: The #NactTreeView convenience object.
*/
-NAObjectItem *
-nact_main_window_get_item( const NactMainWindow *window, const gchar *id )
+NactTreeView *
+nact_main_window_get_items_view( const NactMainWindow *window )
{
- NAObjectItem *exists;
+ NactTreeView *view;
- g_return_val_if_fail( NACT_IS_MAIN_WINDOW( window ), FALSE );
+ g_return_val_if_fail( NACT_IS_MAIN_WINDOW( window ), NULL );
- exists = NULL;
+ view = NULL;
if( !window->private->dispose_has_run ){
- /* leave here this dead code, in case I change of opinion later */
- if( 0 ){
- exists = na_pivot_get_item( NA_PIVOT( window->private->updater ), id );
- }
-
- if( !exists ){
- exists = NA_OBJECT_ITEM( nact_iactions_list_bis_get_item( NACT_IACTIONS_LIST( window ), id ));
- }
+ view = window->private->items_view;
}
- return( exists );
+ return( view );
}
/**
@@ -1011,6 +949,141 @@ nact_main_window_reload( NactMainWindow *window )
}
/*
+ * the count of modified NAObjectItem has changed
+ */
+static void
+on_tree_view_modified_count_changed( NactMainWindow *window, NactTreeView *view, guint count, gpointer user_data )
+{
+ static const gchar *thisfn = "nact_main_window_on_tree_view_modified_count_changed";
+
+ g_debug( "%s: window=%p, view=%p, count=%d, user_data=%p",
+ thisfn, ( void * ) window, ( void * ) view, count, ( void * ) user_data );
+
+ if( !window->private->dispose_has_run ){
+
+ window->private->count_modified = count;
+ }
+}
+
+/*
+ * tree view selection has changed
+ */
+static void
+on_tree_view_selection_changed( NactMainWindow *window, NactTreeView *view, GList *selected_items, gpointer user_data )
+{
+ static const gchar *thisfn = "nact_main_window_on_tree_view_selection_changed";
+ guint count;
+
+ count = g_list_length( selected_items );
+
+ g_debug( "%s: window=%p, view=%p, selected_items=%p (count=%d), user_data=%p",
+ thisfn, ( void * ) window, ( void * ) view,
+ ( void * ) selected_items, count, ( void * ) user_data );
+
+ if( !window->private->dispose_has_run ){
+
+ raz_selection_properties( window );
+
+ if( count == 1 ){
+ g_return_if_fail( NA_IS_OBJECT_ID( selected_items->data ));
+ setup_current_selection( window, NA_OBJECT_ID( selected_items->data ));
+ setup_writability_status( window );
+ }
+
+ setup_dialog_title( window );
+ }
+}
+
+static void
+raz_selection_properties( NactMainWindow *window )
+{
+ window->private->selected_item = NULL;
+ window->private->selected_profile = NULL;
+ window->private->editable = FALSE;
+ window->private->reason = 0;
+
+ nact_main_statusbar_set_locked( window, FALSE, 0 );
+}
+
+/*
+ * enter after raz_properties
+ * only called when only one selected row
+ */
+static void
+setup_current_selection( NactMainWindow *window, NAObjectId *selected_row )
+{
+ guint nb_profiles;
+ 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 ));
+
+ } else {
+ g_return_if_fail( NA_IS_OBJECT_ITEM( selected_row ));
+ window->private->selected_item = NA_OBJECT_ITEM( 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 );
+ }
+ }
+ }
+}
+
+/*
+ * the title bar of the main window brings up three informations:
+ * - the name of the application
+ * - the name of the currently selected item if there is only one
+ * - an asterisk if anything has been modified
+ */
+static void
+setup_dialog_title( NactMainWindow *window )
+{
+ static const gchar *thisfn = "nact_main_window_setup_dialog_title";
+ GtkWindow *toplevel;
+ NactApplication *application;
+ gchar *title;
+ gchar *label;
+ gchar *tmp;
+
+ g_debug( "%s: window=%p", thisfn, ( void * ) 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 );
+ tmp = g_strdup_printf( "%s - %s", label, title );
+ g_free( label );
+ g_free( title );
+ title = tmp;
+ }
+
+ if( window->private->count_modified > 0 ){
+ tmp = g_strdup_printf( "*%s", title );
+ g_free( title );
+ title = tmp;
+ }
+
+ toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( window ));
+ gtk_window_set_title( toplevel, title );
+ g_free( title );
+}
+
+static void
+setup_writability_status( NactMainWindow *window )
+{
+ g_return_if_fail( NA_IS_OBJECT_ITEM( window->private->selected_item ));
+
+ window->private->editable = na_updater_is_item_writable( window->private->updater, window->private->selected_item, &window->private->reason );
+ nact_main_statusbar_set_locked( window, !window->private->editable, window->private->reason );
+}
+
+/*
* The handler of the signal sent by NAPivot when items have been modified
* in the underlying storage subsystems
*/
@@ -1051,7 +1124,7 @@ confirm_for_giveup_from_pivot( const NactMainWindow *window )
"You could keep to work with your current list of actions, "
"or you may want to reload a fresh one." ));
- if( nact_main_window_has_modified_items( window )){
+ if( window->private->count_modified > 0 ){
gchar *tmp = g_strdup_printf( "%s\n\n%s", first,
_( "Note that reloading a fresh list of actions requires "
@@ -1080,7 +1153,7 @@ confirm_for_giveup_from_menu( const NactMainWindow *window )
gboolean reload_ok = TRUE;
gchar *first, *second;
- if( nact_main_window_has_modified_items( window )){
+ if( window->private->count_modified > 0 ){
first = g_strdup(
_( "Reloading a fresh list of actions requires "
@@ -1105,14 +1178,12 @@ reload_items( NactMainWindow *window )
g_debug( "%s: window=%p", thisfn, ( void * ) window );
- window->private->selected_item = NULL;
- window->private->selected_profile = NULL;
+ raz_selection_properties( window );
window->private->deleted = na_object_free_items( window->private->deleted );
tree = na_updater_load_items( window->private->updater );
- nact_iactions_list_fill( NACT_IACTIONS_LIST( window ), tree );
- nact_iactions_list_bis_select_first_row( NACT_IACTIONS_LIST( window ));
+ nact_tree_view_fill( window->private->items_view, tree );
}
/**
@@ -1128,7 +1199,6 @@ gboolean
nact_main_window_quit( NactMainWindow *window )
{
static const gchar *thisfn = "nact_main_window_quit";
- gboolean has_modified;
gboolean terminated;
g_return_val_if_fail( NACT_IS_MAIN_WINDOW( window ), FALSE );
@@ -1138,9 +1208,7 @@ nact_main_window_quit( NactMainWindow *window )
if( !window->private->dispose_has_run ){
g_debug( "%s: window=%p (%s)", thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ));
- has_modified = nact_main_window_has_modified_items( window );
-
- if( !has_modified || nact_window_warn_modified( NACT_WINDOW( window ))){
+ if( window->private->count_modified == 0 || warn_modified( window )){
g_object_unref( window );
terminated = TRUE;
}
@@ -1158,7 +1226,7 @@ base_is_willing_to_quit( const BaseWindow *window )
g_debug( "%s: window=%p", thisfn, ( void * ) window );
willing_to = TRUE;
- if( nact_main_window_has_modified_items( NACT_MAIN_WINDOW( window ))){
+ if( NACT_MAIN_WINDOW( window )->private->count_modified > 0 ){
willing_to = nact_confirm_logout_run( NACT_MAIN_WINDOW( window ));
}
@@ -1190,68 +1258,30 @@ on_delete_event( GtkWidget *toplevel, GdkEvent *event, NactMainWindow *window )
return( TRUE );
}
-/**
- * nact_main_window_get_current_items:
- * @window: this #NactMainWindow instance.
- *
- * Returns: The current content of the items tree view.
- */
-GList *
-nact_main_window_get_current_items( const NactMainWindow *window )
-{
- GList *items;
-
- g_return_val_if_fail( NACT_IS_MAIN_WINDOW( window ), NULL );
-
- items = NULL;
-
- if( !window->private->dispose_has_run ){
-
- items = nact_iactions_list_bis_get_items( NACT_IACTIONS_LIST( window ));
- }
-
- return( items );
-}
-
-/**
- * nact_main_window_has_modified_items:
- * @window: this #NactMainWindow instance.
+/*
+ * warn_modified:
+ * @window: this #NactWindow instance.
*
- * Returns: %TRUE if there is at least one modified item in IActionsList.
+ * Emits a warning if at least one item has been modified.
*
- * Note that exact count of modified actions is subject to some
- * approximation:
- * 1. counting the modified actions currently in the list is ok
- * 2. but what about deleted actions ?
- * we can create any new actions, deleting them, and so on
- * if we have eventually deleted all newly created actions, then the
- * final count of modified actions should be zero... don't it ?
+ * Returns: %TRUE if the user confirms he wants to quit.
*/
-gboolean
-nact_main_window_has_modified_items( const NactMainWindow *window )
+static gboolean
+warn_modified( NactMainWindow *window )
{
- static const gchar *thisfn = "nact_main_window_has_modified_items";
- GList *ia;
- gint count_deleted = 0;
- gboolean has_modified = FALSE;
-
- g_return_val_if_fail( NACT_IS_MAIN_WINDOW( window ), FALSE );
- g_return_val_if_fail( NACT_IS_IACTIONS_LIST( window ), FALSE );
+ gboolean confirm = FALSE;
+ gchar *first;
+ gchar *second;
- if( !window->private->dispose_has_run ){
+ first = g_strdup_printf( _( "Some items have been modified." ));
+ second = g_strdup( _( "Are you sure you want to quit without saving them ?" ));
- for( ia = window->private->deleted ; ia ; ia = ia->next ){
- if( na_object_get_origin( NA_OBJECT( ia->data )) != NULL ){
- count_deleted += 1;
- }
- }
- g_debug( "%s: count_deleted=%d", thisfn, count_deleted );
+ confirm = base_window_display_yesno_dlg( BASE_WINDOW( window ), first, second );
- has_modified = nact_iactions_list_has_modified_items( NACT_IACTIONS_LIST( window ));
- g_debug( "%s: has_modified=%s", thisfn, has_modified ? "True":"False" );
- }
+ g_free( second );
+ g_free( first );
- return( count_deleted > 0 || has_modified || nact_menubar_is_level_zero_order_changed( window ));
+ return( confirm );
}
/**
@@ -1329,10 +1359,12 @@ nact_main_window_remove_deleted( NactMainWindow *window, GSList **messages )
setup_dialog_title( window );
+#if 0
if( g_list_length( not_deleted )){
nact_iactions_list_bis_insert_items( NACT_IACTIONS_LIST( window ), not_deleted, NULL );
na_object_free_items( not_deleted );
}
+#endif
}
return( delete_ok );
@@ -1382,6 +1414,7 @@ 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 )
{
@@ -1390,41 +1423,6 @@ on_main_window_level_zero_order_changed( NactMainWindow *window, gpointer user_d
setup_dialog_title( window );
}
-/*
- * iactions_list_selection_changed:
- * @window: this #NactMainWindow instance.
- * @selected_items: the currently selected items in ActionsList
- */
-static void
-on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected_items )
-{
- static const gchar *thisfn = "nact_main_window_on_iactions_list_selection_changed";
- NactMainWindow *window;
- gint count;
-
- count = g_slist_length( selected_items );
-
- g_debug( "%s: instance=%p, selected_items=%p, count=%d",
- thisfn, ( void * ) instance, ( void * ) selected_items, count );
-
- window = NACT_MAIN_WINDOW( instance );
-
- if( window->private->dispose_has_run ){
- return;
- }
-
- raz_main_properties( window );
-
- if( count == 1 ){
- g_return_if_fail( NA_IS_OBJECT_ID( selected_items->data ));
- setup_current_selection( window, NA_OBJECT_ID( selected_items->data ));
- setup_writability_status( window );
- }
-
- setup_dialog_title( window );
- g_signal_emit_by_name( window, MAIN_WINDOW_SIGNAL_SELECTION_CHANGED, GINT_TO_POINTER( count ));
-}
-
static void
on_iactions_list_status_changed( NactMainWindow *window, gpointer user_data )
{
@@ -1432,107 +1430,7 @@ on_iactions_list_status_changed( NactMainWindow *window, gpointer user_data )
setup_dialog_title( window );
}
-
-static void
-raz_main_properties( NactMainWindow *window )
-{
- window->private->selected_item = NULL;
- window->private->selected_profile = NULL;
- window->private->editable = FALSE;
- window->private->reason = 0;
-
- nact_main_statusbar_set_locked( window, FALSE, 0 );
-}
-
-/*
- * enter after raz_properties
- * only called when only one selected row
- */
-static void
-setup_current_selection( NactMainWindow *window, NAObjectId *selected_row )
-{
- guint nb_profiles;
- 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 ));
-
- } else {
- g_return_if_fail( NA_IS_OBJECT_ITEM( selected_row ));
- window->private->selected_item = NA_OBJECT_ITEM( 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 );
- }
- }
- }
-}
-
-/*
- * the title bar of the main window brings up three informations:
- * - the name of the application
- * - the name of the currently selected item if there is only one
- * - an asterisk if anything has been modified
- */
-static void
-setup_dialog_title( NactMainWindow *window )
-{
- static const gchar *thisfn = "nact_main_window_setup_dialog_title";
- GtkWindow *toplevel;
- NactApplication *application;
- gchar *title;
- gchar *label;
- gchar *tmp;
-
- g_debug( "%s: window=%p", thisfn, ( void * ) 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 );
- tmp = g_strdup_printf( "%s - %s", label, title );
- g_free( label );
- g_free( title );
- title = tmp;
- }
-
- if( nact_main_window_has_modified_items( window )){
- tmp = g_strdup_printf( "*%s", title );
- g_free( title );
- title = tmp;
- }
-
- toplevel = base_window_get_gtk_toplevel( BASE_WINDOW( window ));
- gtk_window_set_title( toplevel, title );
- g_free( title );
-}
-
-static void
-setup_writability_status( NactMainWindow *window )
-{
- g_return_if_fail( NA_IS_OBJECT_ITEM( window->private->selected_item ));
-
- window->private->editable = na_updater_is_item_writable( window->private->updater, window->private->selected_item, &window->private->reason );
- nact_main_statusbar_set_locked( window, !window->private->editable, window->private->reason );
-}
-
-static gchar *
-iactions_list_get_treeview_name( NactIActionsList *instance )
-{
- gchar *name = NULL;
-
- g_return_val_if_fail( NACT_IS_MAIN_WINDOW( instance ), NULL );
-
- name = g_strdup( "ActionsList" );
-
- return( name );
-}
+#endif
static void
on_tab_updatable_item_updated( NactMainWindow *window, gpointer user_data, gboolean force_display )
@@ -1568,8 +1466,10 @@ on_settings_order_mode_changed( const gchar *group, const gchar *key, gconstpoin
thisfn, group, key, order_mode, order_mode_str,
mandatory ? "True":"False", ( void * ) window, G_OBJECT_TYPE_NAME( window ));
+#if 0
nact_iactions_list_display_order_change( NACT_IACTIONS_LIST( window ), order_mode );
- nact_sort_buttons_display_order_change( window, order_mode );
+#endif
+ nact_sort_buttons_display_order_change( BASE_WINDOW( window ), order_mode );
tree = na_pivot_get_items( NA_PIVOT( window->private->updater ));
diff --git a/src/nact/nact-main-window.h b/src/nact/nact-main-window.h
index e40c3f0..96d5beb 100644
--- a/src/nact/nact-main-window.h
+++ b/src/nact/nact-main-window.h
@@ -48,11 +48,10 @@
* - a status bar.
*/
-#include <api/na-object-item.h>
-
#include "nact-application.h"
#include "nact-clipboard.h"
#include "nact-window.h"
+#include "nact-tree-view.h"
G_BEGIN_DECLS
@@ -86,12 +85,11 @@ typedef struct {
GType nact_main_window_get_type( void );
-NactMainWindow *nact_main_window_new( const NactApplication *application );
+NactMainWindow *nact_main_window_new ( const NactApplication *application );
+
+NactClipboard *nact_main_window_get_clipboard ( const NactMainWindow *window );
+NactTreeView *nact_main_window_get_items_view( const NactMainWindow *window );
-NactClipboard *nact_main_window_get_clipboard ( const NactMainWindow *window );
-NAObjectItem *nact_main_window_get_item ( const NactMainWindow *window, const gchar *id );
-GList *nact_main_window_get_current_items ( const NactMainWindow *window );
-gboolean nact_main_window_has_modified_items( 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 );
diff --git a/src/nact/nact-marshal.def b/src/nact/nact-marshal.def
index ed28f49..3fa1ae5 100644
--- a/src/nact/nact-marshal.def
+++ b/src/nact/nact-marshal.def
@@ -1,6 +1,14 @@
-# NactTreeView:: signals
+# NactTreeView:: TREE_SIGNAL_CONTENT_CHANGED
+# NactTreeView:: TREE_SIGNAL_CONTEXT_MENU
+# NactTreeView:: TREE_SIGNAL_SELECTION_CHANGED
VOID:POINTER,POINTER
#
+# NactTreeView:: TREE_SIGNAL_MODIFIED_COUNT_CHANGED
+VOID:POINTER,INT
+#
+# NactTreeView:: TREE_SIGNAL_COUNT_CHANGED
+VOID:POINTER,BOOLEAN,INT,INT,INT
+#
# NactIActionsList::nact-iactions-list-count-updated
VOID:INT,INT,INT
#
diff --git a/src/nact/nact-menubar-edit.c b/src/nact/nact-menubar-edit.c
index 5729782..44741c8 100644
--- a/src/nact/nact-menubar-edit.c
+++ b/src/nact/nact-menubar-edit.c
@@ -40,20 +40,19 @@
#include <core/na-iprefs.h>
#include "nact-application.h"
-#include "nact-iactions-list.h"
#include "nact-main-tab.h"
#include "nact-menubar-priv.h"
#include "nact-preferences-editor.h"
-static GList *prepare_for_paste( NactMainWindow *window );
+static GList *prepare_for_paste( BaseWindow *window );
static GList *get_deletables( NAUpdater *updater, GList *tree, GSList **not_deletable );
static GSList *get_deletables_rec( NAUpdater *updater, GList *tree );
static gchar *add_non_deletable_msg( const NAObjectItem *item, gint reason );
-static void update_clipboard_counters( NactMainWindow *window );
+static void update_clipboard_counters( BaseWindow *window );
/**
* nact_menubar_edit_on_update_sensitivities:
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
* user_data: the data passed to the function via the signal.
* @mis: the #MenubarIndicatorsStruct struct.
*
@@ -175,7 +174,7 @@ nact_menubar_edit_on_update_sensitivities( const NactMenubar *bar )
/**
* nact_menubar_edit_on_cut:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* cuts the visible selection
* - (tree) get new refs on selected items
@@ -185,11 +184,9 @@ nact_menubar_edit_on_update_sensitivities( const NactMenubar *bar )
* - (tree) remove selected items, unreffing objects
*/
void
-nact_menubar_edit_on_cut( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_edit_on_cut( GtkAction *gtk_action, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_edit_on_cut";
- NactApplication *application;
- NAUpdater *updater;
GList *items;
NactClipboard *clipboard;
GList *to_delete;
@@ -197,14 +194,12 @@ nact_menubar_edit_on_cut( GtkAction *gtk_action, NactMainWindow *window )
g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
g_return_if_fail( GTK_IS_ACTION( gtk_action ));
- g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
- updater = nact_application_get_updater( application );
- items = nact_iactions_list_bis_get_selected_items( NACT_IACTIONS_LIST( window ));
+ BAR_WINDOW_VOID( window );
+ items = na_object_copyref_items( bar->private->selected_items );
non_deletables = NULL;
- to_delete = get_deletables( updater, items, &non_deletables );
+ to_delete = get_deletables( bar->private->updater, items, &non_deletables );
if( non_deletables ){
gchar *second = na_core_utils_slist_join_at_end( non_deletables, "\n" );
@@ -217,11 +212,13 @@ nact_menubar_edit_on_cut( GtkAction *gtk_action, NactMainWindow *window )
}
if( to_delete ){
- nact_main_window_move_to_deleted( window, to_delete );
- clipboard = nact_main_window_get_clipboard( window );
+ 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 );
+#if 0
nact_iactions_list_bis_delete( NACT_IACTIONS_LIST( window ), to_delete, TRUE );
+#endif
}
na_object_free_items( items );
@@ -230,7 +227,7 @@ nact_menubar_edit_on_cut( GtkAction *gtk_action, NactMainWindow *window )
/**
* nact_menubar_edit_on_copy:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* copies the visible selection
* - (tree) get new refs on selected items
@@ -240,7 +237,7 @@ nact_menubar_edit_on_cut( GtkAction *gtk_action, NactMainWindow *window )
* - (menu) refresh actions sensitivy (as selection doesn't change)
*/
void
-nact_menubar_edit_on_copy( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_edit_on_copy( GtkAction *gtk_action, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_edit_on_copy";
GList *items;
@@ -252,8 +249,8 @@ nact_menubar_edit_on_copy( GtkAction *gtk_action, NactMainWindow *window )
g_return_if_fail( GTK_IS_ACTION( gtk_action ));
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
- items = nact_iactions_list_bis_get_selected_items( NACT_IACTIONS_LIST( window ));
- clipboard = nact_main_window_get_clipboard( window );
+ items = na_object_copyref_items( bar->private->selected_items );
+ clipboard = nact_main_window_get_clipboard( NACT_MAIN_WINDOW( window ));
nact_clipboard_primary_set( clipboard, items, CLIPBOARD_MODE_COPY );
update_clipboard_counters( window );
na_object_free_items( items );
@@ -264,7 +261,7 @@ nact_menubar_edit_on_copy( GtkAction *gtk_action, NactMainWindow *window )
/**
* nact_menubar_edit_on_paste:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* pastes the current content of the clipboard at the current position
* (same path, same level)
@@ -278,7 +275,7 @@ nact_menubar_edit_on_copy( GtkAction *gtk_action, NactMainWindow *window )
* - (menu) unreffing the copy got from clipboard
*/
void
-nact_menubar_edit_on_paste( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_edit_on_paste( GtkAction *gtk_action, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_edit_on_paste";
GList *items;
@@ -287,7 +284,9 @@ nact_menubar_edit_on_paste( GtkAction *gtk_action, NactMainWindow *window )
items = prepare_for_paste( window );
if( items ){
+#if 0
nact_iactions_list_bis_insert_items( NACT_IACTIONS_LIST( window ), items, NULL );
+#endif
na_object_free_items( items );
}
}
@@ -295,7 +294,7 @@ nact_menubar_edit_on_paste( GtkAction *gtk_action, NactMainWindow *window )
/**
* nact_menubar_edit_on_paste_into:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* pastes the current content of the clipboard as the first child of
* currently selected item
@@ -309,7 +308,7 @@ nact_menubar_edit_on_paste( GtkAction *gtk_action, NactMainWindow *window )
* - (menu) unreffing the copy got from clipboard
*/
void
-nact_menubar_edit_on_paste_into( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_edit_on_paste_into( GtkAction *gtk_action, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_edit_on_paste_into";
GList *items;
@@ -318,13 +317,15 @@ nact_menubar_edit_on_paste_into( GtkAction *gtk_action, NactMainWindow *window )
items = prepare_for_paste( window );
if( items ){
+#if 0
nact_iactions_list_bis_insert_into( NACT_IACTIONS_LIST( window ), items );
+#endif
na_object_free_items( items );
}
}
static GList *
-prepare_for_paste( NactMainWindow *window )
+prepare_for_paste( BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_edit_prepare_for_paste";
GList *items, *it;
@@ -332,13 +333,10 @@ prepare_for_paste( NactMainWindow *window )
NAObjectAction *action;
gboolean relabel;
gboolean renumber;
- NactApplication *application;
- NAUpdater *updater;
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
- updater = nact_application_get_updater( application );
+ BAR_WINDOW_VALUE( window, NULL );
- clipboard = nact_main_window_get_clipboard( window );
+ clipboard = nact_main_window_get_clipboard( NACT_MAIN_WINDOW( window ));
items = nact_clipboard_primary_get( clipboard, &renumber );
action = NULL;
@@ -353,7 +351,7 @@ prepare_for_paste( NactMainWindow *window )
}
}
- relabel = na_updater_should_pasted_be_relabeled( updater, NA_OBJECT( it->data ));
+ relabel = na_updater_should_pasted_be_relabeled( bar->private->updater, NA_OBJECT( it->data ));
na_object_prepare_for_paste( it->data, relabel, renumber, action );
na_object_check_status( it->data );
}
@@ -367,7 +365,7 @@ prepare_for_paste( NactMainWindow *window )
/**
* nact_menubar_edit_on_duplicate:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* duplicate is just as paste, with the difference that content comes
* from the current selection, instead of coming from the clipboard
@@ -377,25 +375,23 @@ prepare_for_paste( NactMainWindow *window )
* items just besides the original ones...
*/
void
-nact_menubar_edit_on_duplicate( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_edit_on_duplicate( GtkAction *gtk_action, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_edit_on_duplicate";
- NactApplication *application;
- NAUpdater *updater;
NAObjectAction *action;
GList *items, *it;
GList *dup;
NAObject *obj;
gboolean relabel;
+ BAR_WINDOW_VOID( window );
+
g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
g_return_if_fail( GTK_IS_ACTION( gtk_action ));
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
- updater = nact_application_get_updater( application );
+ items = na_object_copyref_items( bar->private->selected_items );
- items = nact_iactions_list_bis_get_selected_items( NACT_IACTIONS_LIST( window ));
for( it = items ; it ; it = it->next ){
obj = NA_OBJECT( na_object_duplicate( it->data ));
action = NULL;
@@ -407,12 +403,14 @@ nact_menubar_edit_on_duplicate( GtkAction *gtk_action, NactMainWindow *window )
action = NA_OBJECT_ACTION( na_object_get_parent( it->data ));
}
- relabel = na_updater_should_pasted_be_relabeled( updater, obj );
+ relabel = na_updater_should_pasted_be_relabeled( bar->private->updater, obj );
na_object_prepare_for_paste( obj, relabel, TRUE, action );
na_object_set_origin( obj, NULL );
na_object_check_status( obj );
dup = g_list_prepend( NULL, obj );
+#if 0
nact_iactions_list_bis_insert_items( NACT_IACTIONS_LIST( window ), dup, it->data );
+#endif
na_object_free_items( dup );
}
@@ -422,7 +420,7 @@ nact_menubar_edit_on_duplicate( GtkAction *gtk_action, NactMainWindow *window )
/**
* nact_menubar_edit_on_delete:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* deletes the visible selection
* - (tree) get new refs on selected items
@@ -437,25 +435,22 @@ nact_menubar_edit_on_duplicate( GtkAction *gtk_action, NactMainWindow *window )
* this branch itself be deleted
*/
void
-nact_menubar_edit_on_delete( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_edit_on_delete( GtkAction *gtk_action, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_edit_on_delete";
- NactApplication *application;
- NAUpdater *updater;
GList *items;
GList *to_delete;
GSList *non_deletables;
+ BAR_WINDOW_VOID( window );
+
g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
g_return_if_fail( GTK_IS_ACTION( gtk_action ));
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
- updater = nact_application_get_updater( application );
- items = nact_iactions_list_bis_get_selected_items( NACT_IACTIONS_LIST( window ));
-
+ items = na_object_copyref_items( bar->private->selected_items );
non_deletables = NULL;
- to_delete = get_deletables( updater, items, &non_deletables );
+ to_delete = get_deletables( bar->private->updater, items, &non_deletables );
if( non_deletables ){
gchar *second = na_core_utils_slist_join_at_end( non_deletables, "\n" );
@@ -468,8 +463,10 @@ nact_menubar_edit_on_delete( GtkAction *gtk_action, NactMainWindow *window )
}
if( to_delete ){
- nact_main_window_move_to_deleted( window, to_delete );
+ nact_main_window_move_to_deleted( NACT_MAIN_WINDOW( window ), to_delete );
+#if 0
nact_iactions_list_bis_delete( NACT_IACTIONS_LIST( window ), to_delete, TRUE );
+#endif
}
na_object_free_items( items );
@@ -558,7 +555,7 @@ add_non_deletable_msg( const NAObjectItem *item, gint reason )
* counters to clipboard ones
*/
static void
-update_clipboard_counters( NactMainWindow *window )
+update_clipboard_counters( BaseWindow *window )
{
BAR_WINDOW_VOID( window );
@@ -575,25 +572,25 @@ update_clipboard_counters( NactMainWindow *window )
/**
* nact_menubar_edit_on_reload:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Reload items from I/O storage subsystems.
*/
void
-nact_menubar_edit_on_reload( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_edit_on_reload( GtkAction *gtk_action, BaseWindow *window )
{
- nact_main_window_reload( window );
+ nact_main_window_reload( NACT_MAIN_WINDOW( window ));
}
/**
* nact_menubar_edit_on_preferences:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Edit preferences.
*/
void
-nact_menubar_edit_on_prefererences( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_edit_on_prefererences( GtkAction *gtk_action, BaseWindow *window )
{
- nact_preferences_editor_run( BASE_WINDOW( window ));
+ nact_preferences_editor_run( window );
}
diff --git a/src/nact/nact-menubar-file.c b/src/nact/nact-menubar-file.c
index 695b434..491d235 100644
--- a/src/nact/nact-menubar-file.c
+++ b/src/nact/nact-menubar-file.c
@@ -42,7 +42,6 @@
#include <core/na-iprefs.h>
#include "nact-application.h"
-#include "nact-iactions-list.h"
#include "nact-main-statusbar.h"
#include "nact-main-tab.h"
#include "nact-menubar-priv.h"
@@ -55,15 +54,15 @@ 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" );
static gchar *st_delete_error = N_( "Some items cannot have been deleted" );
-static gboolean save_item( NactMainWindow *window, NAUpdater *updater, NAObjectItem *item, GSList **messages );
+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 );
-static void on_autosave_prefs_timeout( NactMainWindow *window );
-static gboolean autosave_callback( NactMainWindow *window );
-static void autosave_destroyed( NactMainWindow *window );
+static void on_autosave_prefs_timeout( BaseWindow *window );
+static gboolean autosave_callback( BaseWindow *window );
+static void autosave_destroyed( BaseWindow *window );
/**
* nact_menubar_file_on_update_sensitivities:
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
* user_data: the data passed to the function via the signal.
* @mis: the #MenubarIndicatorsStruct struct.
*
@@ -72,12 +71,7 @@ static void autosave_destroyed( NactMainWindow *window );
void
nact_menubar_file_on_update_sensitivities( const NactMenubar *bar )
{
- static const gchar *thisfn = "nact_menubar_file_on_update_sensitivities";
gboolean new_item_enabled;
- gboolean has_modified_items;
-
- has_modified_items = nact_main_window_has_modified_items( NACT_MAIN_WINDOW( bar->private->window ));
- g_debug( "%s: has_modified_items=%s", thisfn, has_modified_items ? "True":"False" );
/* new menu / new action
* new item will be inserted just before the beginning of selection
@@ -98,8 +92,7 @@ nact_menubar_file_on_update_sensitivities( const NactMenubar *bar )
/* save enabled if at least one item has been modified
* or level-zero has been resorted and is writable
*/
- nact_menubar_enable_item( bar, "SaveItem",
- has_modified_items || ( bar->private->level_zero_order_changed && bar->private->is_level_zero_writable ));
+ nact_menubar_enable_item( bar, "SaveItem", ( bar->private->count_modified > 0 ));
/* quit always enabled */
}
@@ -107,12 +100,12 @@ nact_menubar_file_on_update_sensitivities( const NactMenubar *bar )
/**
* nact_menubar_file_on_new_menu:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Triggers File / New menu item.
*/
void
-nact_menubar_file_on_new_menu( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_file_on_new_menu( GtkAction *gtk_action, BaseWindow *window )
{
NAObjectMenu *menu;
GList *items;
@@ -123,19 +116,21 @@ nact_menubar_file_on_new_menu( GtkAction *gtk_action, NactMainWindow *window )
menu = na_object_menu_new_with_defaults();
na_object_check_status( menu );
items = g_list_prepend( NULL, menu );
+#if 0
nact_iactions_list_bis_insert_items( NACT_IACTIONS_LIST( window ), items, NULL );
+#endif
na_object_free_items( items );
}
/**
* nact_menubar_file_on_new_action:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Triggers File / New action item.
*/
void
-nact_menubar_file_on_new_action( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_file_on_new_action( GtkAction *gtk_action, BaseWindow *window )
{
NAObjectAction *action;
GList *items;
@@ -146,19 +141,21 @@ nact_menubar_file_on_new_action( GtkAction *gtk_action, NactMainWindow *window )
action = na_object_action_new_with_defaults();
na_object_check_status( action );
items = g_list_prepend( NULL, action );
+#if 0
nact_iactions_list_bis_insert_items( NACT_IACTIONS_LIST( window ), items, NULL );
+#endif
na_object_free_items( items );
}
/**
* nact_menubar_file_on_new_profile:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Triggers File / New profile item.
*/
void
-nact_menubar_file_on_new_profile( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_file_on_new_profile( GtkAction *gtk_action, BaseWindow *window )
{
NAObjectAction *action;
NAObjectProfile *profile;
@@ -185,14 +182,16 @@ nact_menubar_file_on_new_profile( GtkAction *gtk_action, NactMainWindow *window
na_object_check_status( profile );
items = g_list_prepend( NULL, profile );
+#if 0
nact_iactions_list_bis_insert_items( NACT_IACTIONS_LIST( window ), items, NULL );
+#endif
na_object_free_items( items );
}
/**
* nact_menubar_file_on_save:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Triggers File /Save item.
*
@@ -203,7 +202,7 @@ nact_menubar_file_on_new_profile( GtkAction *gtk_action, NactMainWindow *window
* different arguments.
*/
void
-nact_menubar_file_on_save( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_file_on_save( GtkAction *gtk_action, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_file_on_save";
@@ -217,7 +216,7 @@ nact_menubar_file_on_save( GtkAction *gtk_action, NactMainWindow *window )
/**
* nact_menubar_file_save_items:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Save items.
* This is the same function that nact_menubar_file_on_save(), just
@@ -245,12 +244,11 @@ nact_menubar_file_on_save( GtkAction *gtk_action, NactMainWindow *window )
* - idem if some items cannot be actually rewritten...
*/
void
-nact_menubar_file_save_items( NactMainWindow *window )
+nact_menubar_file_save_items( BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_file_save_items";
+ NactTreeView *items_view;
GList *items, *it;
- NactApplication *application;
- NAUpdater *updater;
gchar *label;
GList *new_pivot;
NAObjectItem *duplicate;
@@ -264,18 +262,17 @@ nact_menubar_file_save_items( NactMainWindow *window )
/* always write the level zero list of items as the first save phase
* and reset the corresponding modification flag
*/
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
- updater = nact_application_get_updater( application );
- items = nact_iactions_list_bis_get_items( NACT_IACTIONS_LIST( window ));
+ items_view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
+ items = nact_tree_view_get_items( items_view );
messages = NULL;
- if( !na_iprefs_write_level_zero( NA_PIVOT( updater ), items, &messages )){
+ if( !na_iprefs_write_level_zero( NA_PIVOT( bar->private->updater ), items, &messages )){
if( g_slist_length( messages )){
msg = na_core_utils_slist_join_at_end( messages, "\n" );
} else {
msg = g_strdup( gettext( st_level_zero_write ));
}
- base_window_display_error_dlg( BASE_WINDOW( window ), gettext( st_save_error ), msg );
+ base_window_display_error_dlg( window, gettext( st_save_error ), msg );
g_free( msg );
na_core_utils_slist_free( messages );
return;
@@ -286,13 +283,13 @@ nact_menubar_file_save_items( NactMainWindow *window )
/* remove deleted items
* so that new actions with same id do not risk to be deleted later
*/
- if( !nact_main_window_remove_deleted( window, &messages )){
+ 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" );
} else {
msg = g_strdup( gettext( st_delete_error ));
}
- base_window_display_error_dlg( BASE_WINDOW( window ), gettext( st_save_error ), msg );
+ base_window_display_error_dlg( window, gettext( st_save_error ), msg );
g_free( msg );
na_core_utils_slist_free( messages );
return;
@@ -315,7 +312,7 @@ nact_menubar_file_save_items( NactMainWindow *window )
na_object_is_modified( it->data ) ? "True":"False" );
g_free( label );
- save_item( window, updater, NA_OBJECT_ITEM( it->data ), &messages );
+ save_item( window, bar->private->updater, NA_OBJECT_ITEM( it->data ), &messages );
duplicate = NA_OBJECT_ITEM( na_object_duplicate( it->data ));
na_object_reset_origin( it->data, duplicate );
@@ -325,12 +322,12 @@ nact_menubar_file_save_items( NactMainWindow *window )
if( g_slist_length( messages )){
msg = na_core_utils_slist_join_at_end( messages, "\n" );
- base_window_display_error_dlg( BASE_WINDOW( window ), gettext( st_save_warning ), msg );
+ base_window_display_error_dlg( window, gettext( st_save_warning ), msg );
g_free( msg );
na_core_utils_slist_free( messages );
}
- na_pivot_set_new_items( NA_PIVOT( updater ), g_list_reverse( new_pivot ));
+ na_pivot_set_new_items( NA_PIVOT( bar->private->updater ), g_list_reverse( new_pivot ));
g_list_free( items );
/* when new_pivot is empty, then there has been no chance of updating
@@ -364,7 +361,7 @@ nact_menubar_file_save_items( NactMainWindow *window )
* save order: A-B-C-D-E-F-G-H (first parent, then children)
*/
static gboolean
-save_item( NactMainWindow *window, NAUpdater *updater, NAObjectItem *item, GSList **messages )
+save_item( BaseWindow *window, NAUpdater *updater, NAObjectItem *item, GSList **messages )
{
gboolean ret;
NAIOProvider *provider_before;
@@ -389,7 +386,9 @@ save_item( NactMainWindow *window, NAUpdater *updater, NAObjectItem *item, GSLis
na_object_reset_last_allocated( item );
}
+#if 0
nact_iactions_list_bis_remove_modified( NACT_IACTIONS_LIST( window ), item );
+#endif
provider_after = na_object_get_provider( item );
if( provider_after != provider_before ){
@@ -416,29 +415,29 @@ save_item( NactMainWindow *window, NAUpdater *updater, NAObjectItem *item, GSLis
/**
* nact_menubar_file_on_quit:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Triggers the File / Quit item.
*/
void
-nact_menubar_file_on_quit( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_file_on_quit( GtkAction *gtk_action, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_file_on_quit";
g_debug( "%s: item=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
g_return_if_fail( GTK_IS_ACTION( gtk_action ) || gtk_action == NULL );
- nact_main_window_quit( window );
+ nact_main_window_quit( NACT_MAIN_WINDOW( window ));
}
/**
* nact_menubar_file_install_autosave:
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Setup the autosave feature and initialize its monitoring.
*/
void
-nact_menubar_file_install_autosave( NactMainWindow *window )
+nact_menubar_file_install_autosave( BaseWindow *window )
{
NactApplication *application;
NAUpdater *updater;
@@ -467,7 +466,7 @@ on_autosave_prefs_changed( const gchar *group, const gchar *key, gconstpointer n
}
static void
-on_autosave_prefs_timeout( NactMainWindow *window )
+on_autosave_prefs_timeout( BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_file_on_autosave_prefs_timeout";
NactApplication *application;
@@ -503,20 +502,20 @@ on_autosave_prefs_timeout( NactMainWindow *window )
}
static gboolean
-autosave_callback( NactMainWindow *window )
+autosave_callback( BaseWindow *window )
{
const gchar *context = "autosave-context";
g_debug( "nact_menubar_file_autosave_callback" );
- nact_main_statusbar_display_status( window, context, _( "Automatically saving pending modifications..." ));
+ nact_main_statusbar_display_status( NACT_MAIN_WINDOW( window ), context, _( "Automatically saving pending modifications..." ));
nact_menubar_file_save_items( window );
- nact_main_statusbar_hide_status( window, context );
+ nact_main_statusbar_hide_status( NACT_MAIN_WINDOW( window ), context );
return( TRUE );
}
static void
-autosave_destroyed( NactMainWindow *window )
+autosave_destroyed( BaseWindow *window )
{
g_debug( "nact_menubar_file_autosave_destroyed" );
}
diff --git a/src/nact/nact-menubar-help.c b/src/nact/nact-menubar-help.c
index 074e97d..0bca89e 100644
--- a/src/nact/nact-menubar-help.c
+++ b/src/nact/nact-menubar-help.c
@@ -38,7 +38,7 @@
/**
* nact_menubar_help_on_update_sensitivities:
- * @window: the #NactMainWindow main application window.
+ * @window: the #BaseWindow main application window.
* @user_data: user data ?
* @mis: the #MenubarIndicatorsStruct structure.
*
@@ -54,12 +54,12 @@ nact_menubar_help_on_update_sensitivities( const NactMenubar *bar )
/**
* nact_menubar_help_on_help:
* @action: the #GtkAction of the item.
- * @window: the #NactMainWindow main application window.
+ * @window: the #BaseWindow main application window.
*
* Triggers the "Help/Help" item.
*/
void
-nact_menubar_help_on_help( GtkAction *action, NactMainWindow *window )
+nact_menubar_help_on_help( GtkAction *action, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_help_on_help";
GError *error;
@@ -75,12 +75,12 @@ nact_menubar_help_on_help( GtkAction *action, NactMainWindow *window )
/**
* nact_menubar_help_on_about:
* @action: the #GtkAction of the item.
- * @window: the #NactMainWindow main application window.
+ * @window: the #BaseWindow main application window.
*
* Triggers the "Help/About" item.
*/
void
-nact_menubar_help_on_about( GtkAction *action, NactMainWindow *window )
+nact_menubar_help_on_about( GtkAction *action, BaseWindow *window )
{
na_iabout_display( NA_IABOUT( window ));
}
diff --git a/src/nact/nact-menubar-maintainer.c b/src/nact/nact-menubar-maintainer.c
index 75d13e8..514c83b 100644
--- a/src/nact/nact-menubar-maintainer.c
+++ b/src/nact/nact-menubar-maintainer.c
@@ -34,13 +34,13 @@
#include <api/na-object-api.h>
-#include "nact-iactions-list.h"
#include "nact-clipboard.h"
#include "nact-menubar-priv.h"
+#include "nact-main-window.h"
/**
* nact_menubar_maintainer_on_update_sensitivities:
- * @window: the #NactMainWindow main application window.
+ * @window: the #BaseWindow main application window.
* @user_data: user data ?
* @mis: the #MenubarIndicatorsStruct structure.
*
@@ -54,58 +54,65 @@ nact_menubar_maintainer_on_update_sensitivities( const NactMenubar *bar )
/**
* nact_menubar_maintainer_on_dump_selection:
* @action: the #GtkAction of the item.
- * @window: the #NactMainWindow main application window.
+ * @window: the #BaseWindow main application window.
*
* Triggers the "Maintainer/Dump selection" item.
*/
void
-nact_menubar_maintainer_on_dump_selection( GtkAction *action, NactMainWindow *window )
+nact_menubar_maintainer_on_dump_selection( GtkAction *action, BaseWindow *window )
{
- GList *items, *it;
+ GList *items;
- items = nact_iactions_list_bis_get_selected_items( NACT_IACTIONS_LIST( window ));
- for( it = items ; it ; it = it->next ){
- na_object_dump( it->data );
- }
+ BAR_WINDOW_VOID( window );
+ items = na_object_copyref_items( bar->private->selected_items );
+ na_object_dump_tree( items );
na_object_free_items( items );
}
/**
* nact_menubar_maintainer_on_brief_tree_store_dump:
* @action: the #GtkAction of the item.
- * @window: the #NactMainWindow main application window.
+ * @window: the #BaseWindow main application window.
*
* Triggers the "Maintainer/Brief treestore dump" item.
*/
void
-nact_menubar_maintainer_on_brief_tree_store_dump( GtkAction *action, NactMainWindow *window )
+nact_menubar_maintainer_on_brief_tree_store_dump( GtkAction *action, BaseWindow *window )
{
- nact_iactions_list_brief_tree_dump( NACT_IACTIONS_LIST( window ));
+ NactTreeView *items_view;
+ GList *items;
+
+ items_view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
+ items = nact_tree_view_get_items( items_view );
+ na_object_dump_tree( items );
+ na_object_free_items( items );
}
/**
* nact_menubar_maintainer_on_list_modified_items:
* @action: the #GtkAction of the item.
- * @window: the #NactMainWindow main application window.
+ * @window: the #BaseWindow main application window.
*
* Triggers the "Maintainer/List modified items" item.
*/
void
-nact_menubar_maintainer_on_list_modified_items( GtkAction *action, NactMainWindow *window )
+nact_menubar_maintainer_on_list_modified_items( GtkAction *action, BaseWindow *window )
{
+#if 0
nact_iactions_list_bis_list_modified_items( NACT_IACTIONS_LIST( window ));
+#endif
}
/**
* nact_menubar_maintainer_on_dump_clipboard:
* @action: the #GtkAction of the item.
- * @window: the #NactMainWindow main application window.
+ * @window: the #BaseWindow main application window.
*
* Triggers the "Maintainer/Dump clipboard" item.
*/
void
-nact_menubar_maintainer_on_dump_clipboard( GtkAction *action, NactMainWindow *window )
+nact_menubar_maintainer_on_dump_clipboard( GtkAction *action, BaseWindow *window )
{
- nact_clipboard_dump( nact_main_window_get_clipboard( window ));
+ nact_clipboard_dump( nact_main_window_get_clipboard( NACT_MAIN_WINDOW( window )));
}
diff --git a/src/nact/nact-menubar-priv.h b/src/nact/nact-menubar-priv.h
index 54f8ec8..64f0602 100644
--- a/src/nact/nact-menubar-priv.h
+++ b/src/nact/nact-menubar-priv.h
@@ -71,6 +71,26 @@ struct _NactMenubarPrivate {
gboolean is_action_writable;
gboolean are_parents_writable; /* cut/delete */
+ /* set when the count of modified NAObjectItem changes
+ * this is a NactTreeIEditable-driven count
+ */
+ guint count_modified;
+
+ /* set on focus in/out
+ */
+ gboolean treeview_has_focus;
+
+ /* opening a contextual popup menu
+ */
+ gulong popup_handler;
+
+ /* set when total count of items changes
+ */
+ gint count_menus;
+ gint count_actions;
+ gint count_profiles;
+ gboolean have_exportables;
+
/* *** */
gint selected_menus;
gint selected_actions;
@@ -78,14 +98,7 @@ struct _NactMenubarPrivate {
gint clipboard_menus;
gint clipboard_actions;
gint clipboard_profiles;
- gint list_menus;
- gint list_actions;
- gint list_profiles;
- gboolean is_modified;
- gboolean have_exportables;
- gboolean treeview_has_focus;
gboolean level_zero_order_changed;
- gulong popup_handler;
/* *** */
};
@@ -113,51 +126,51 @@ void nact_menubar_enable_item( const NactMenubar *bar, const gchar *name, gboole
void nact_menubar_edit_on_update_sensitivities( const NactMenubar *bar );
-void nact_menubar_edit_on_cut ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_edit_on_copy ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_edit_on_paste ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_edit_on_paste_into ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_edit_on_duplicate ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_edit_on_delete ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_edit_on_reload ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_edit_on_prefererences( GtkAction *action, NactMainWindow *window );
+void nact_menubar_edit_on_cut ( GtkAction *action, BaseWindow *window );
+void nact_menubar_edit_on_copy ( GtkAction *action, BaseWindow *window );
+void nact_menubar_edit_on_paste ( GtkAction *action, BaseWindow *window );
+void nact_menubar_edit_on_paste_into ( GtkAction *action, BaseWindow *window );
+void nact_menubar_edit_on_duplicate ( GtkAction *action, BaseWindow *window );
+void nact_menubar_edit_on_delete ( GtkAction *action, BaseWindow *window );
+void nact_menubar_edit_on_reload ( GtkAction *action, BaseWindow *window );
+void nact_menubar_edit_on_prefererences( GtkAction *action, BaseWindow *window );
void nact_menubar_file_on_update_sensitivities( const NactMenubar *bar );
-void nact_menubar_file_on_new_menu ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_file_on_new_action ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_file_on_new_profile( GtkAction *action, NactMainWindow *window );
-void nact_menubar_file_on_save ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_file_on_quit ( GtkAction *action, NactMainWindow *window );
+void nact_menubar_file_on_new_menu ( GtkAction *action, BaseWindow *window );
+void nact_menubar_file_on_new_action ( GtkAction *action, BaseWindow *window );
+void nact_menubar_file_on_new_profile( GtkAction *action, BaseWindow *window );
+void nact_menubar_file_on_save ( GtkAction *action, BaseWindow *window );
+void nact_menubar_file_on_quit ( GtkAction *action, BaseWindow *window );
-void nact_menubar_file_save_items ( NactMainWindow *window );
-void nact_menubar_file_install_autosave( NactMainWindow *window );
+void nact_menubar_file_save_items ( BaseWindow *window );
+void nact_menubar_file_install_autosave( BaseWindow *window );
void nact_menubar_help_on_update_sensitivities( const NactMenubar *bar );
-void nact_menubar_help_on_help ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_help_on_about( GtkAction *action, NactMainWindow *window );
+void nact_menubar_help_on_help ( GtkAction *action, BaseWindow *window );
+void nact_menubar_help_on_about( GtkAction *action, BaseWindow *window );
void nact_menubar_maintainer_on_update_sensitivities( const NactMenubar *bar );
-void nact_menubar_maintainer_on_dump_selection ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_maintainer_on_brief_tree_store_dump( GtkAction *action, NactMainWindow *window );
-void nact_menubar_maintainer_on_list_modified_items ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_maintainer_on_dump_clipboard ( GtkAction *action, NactMainWindow *window );
+void nact_menubar_maintainer_on_dump_selection ( GtkAction *action, BaseWindow *window );
+void nact_menubar_maintainer_on_brief_tree_store_dump( GtkAction *action, BaseWindow *window );
+void nact_menubar_maintainer_on_list_modified_items ( GtkAction *action, BaseWindow *window );
+void nact_menubar_maintainer_on_dump_clipboard ( GtkAction *action, BaseWindow *window );
void nact_menubar_tools_on_update_sensitivities( const NactMenubar *bar );
-void nact_menubar_tools_on_import( GtkAction *action, NactMainWindow *window );
-void nact_menubar_tools_on_export( GtkAction *action, NactMainWindow *window );
+void nact_menubar_tools_on_import( GtkAction *action, BaseWindow *window );
+void nact_menubar_tools_on_export( GtkAction *action, BaseWindow *window );
void nact_menubar_view_on_update_sensitivities( const NactMenubar *bar );
-void nact_menubar_view_on_expand_all ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_view_on_collapse_all ( GtkAction *action, NactMainWindow *window );
-void nact_menubar_view_on_toolbar_file ( GtkToggleAction *action, NactMainWindow *window );
-void nact_menubar_view_on_toolbar_edit ( GtkToggleAction *action, NactMainWindow *window );
-void nact_menubar_view_on_toolbar_tools( GtkToggleAction *action, NactMainWindow *window );
-void nact_menubar_view_on_toolbar_help ( GtkToggleAction *action, NactMainWindow *window );
+void nact_menubar_view_on_expand_all ( GtkAction *action, BaseWindow *window );
+void nact_menubar_view_on_collapse_all ( GtkAction *action, BaseWindow *window );
+void nact_menubar_view_on_toolbar_file ( GtkToggleAction *action, BaseWindow *window );
+void nact_menubar_view_on_toolbar_edit ( GtkToggleAction *action, BaseWindow *window );
+void nact_menubar_view_on_toolbar_tools( GtkToggleAction *action, BaseWindow *window );
+void nact_menubar_view_on_toolbar_help ( GtkToggleAction *action, BaseWindow *window );
G_END_DECLS
diff --git a/src/nact/nact-menubar-tools.c b/src/nact/nact-menubar-tools.c
index 90e5123..1d3a70f 100644
--- a/src/nact/nact-menubar-tools.c
+++ b/src/nact/nact-menubar-tools.c
@@ -38,7 +38,7 @@
/**
* nact_menubar_tools_on_update_sensitivities:
- * @window: the #NactMainWindow main application window.
+ * @window: the #BaseWindow main application window.
* @user_data: user data ?
* @mis: the #MenubarIndicatorsStruct structure.
*
@@ -57,12 +57,12 @@ nact_menubar_tools_on_update_sensitivities( const NactMenubar *bar )
/**
* nact_menubar_tools_on_import:
* @action: the #GtkAction of the item.
- * @window: the #NactMainWindow main application window.
+ * @window: the #BaseWindow main application window.
*
* Triggers the "Tools/Import assitant" item.
*/
void
-nact_menubar_tools_on_import( GtkAction *action, NactMainWindow *window )
+nact_menubar_tools_on_import( GtkAction *action, BaseWindow *window )
{
nact_assistant_import_run( BASE_WINDOW( window ));
}
@@ -70,12 +70,12 @@ nact_menubar_tools_on_import( GtkAction *action, NactMainWindow *window )
/**
* nact_menubar_tools_on_export:
* @action: the #GtkAction of the item.
- * @window: the #NactMainWindow main application window.
+ * @window: the #BaseWindow main application window.
*
* Triggers the "Tools/Export assistant" item.
*/
void
-nact_menubar_tools_on_export( GtkAction *action, NactMainWindow *window )
+nact_menubar_tools_on_export( GtkAction *action, BaseWindow *window )
{
nact_assistant_export_run( BASE_WINDOW( window ));
}
diff --git a/src/nact/nact-menubar-view.c b/src/nact/nact-menubar-view.c
index b8f63f1..090485b 100644
--- a/src/nact/nact-menubar-view.c
+++ b/src/nact/nact-menubar-view.c
@@ -32,15 +32,14 @@
#include <config.h>
#endif
-#include "nact-iactions-list.h"
#include "nact-main-toolbar.h"
#include "nact-menubar-priv.h"
-static void on_view_toolbar_activated( GtkToggleAction *action, NactMainWindow *window, int toolbar_id );
+static void on_view_toolbar_activated( GtkToggleAction *action, BaseWindow *window, int toolbar_id );
/**
* nact_menubar_view_on_update_sensitivities:
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
* user_data: the data passed to the function via the signal.
* @mis: the #MenubarIndicatorsStruct struct.
*
@@ -52,7 +51,7 @@ nact_menubar_view_on_update_sensitivities( const NactMenubar *bar )
guint count_list;
/* expand all/collapse all requires at least one item in the list */
- count_list = bar->private->list_menus + bar->private->list_actions + bar->private->list_profiles;
+ count_list = bar->private->count_menus + bar->private->count_actions + bar->private->count_profiles;
nact_menubar_enable_item( bar, "ExpandAllItem", count_list > 0 );
nact_menubar_enable_item( bar, "CollapseAllItem", count_list > 0 );
}
@@ -60,38 +59,44 @@ nact_menubar_view_on_update_sensitivities( const NactMenubar *bar )
/**
* nact_menubar_view_on_expand_all:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Triggers View / Expand all item.
*/
void
-nact_menubar_view_on_expand_all( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_view_on_expand_all( GtkAction *gtk_action, BaseWindow *window )
{
- nact_iactions_list_expand_all( NACT_IACTIONS_LIST( window ));
+ NactTreeView *items_view;
+
+ items_view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
+ nact_tree_view_expand_all( items_view );
}
/**
* nact_menubar_view_on_collapse_all:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Triggers View / Collapse all item.
*/
void
-nact_menubar_view_on_collapse_all( GtkAction *gtk_action, NactMainWindow *window )
+nact_menubar_view_on_collapse_all( GtkAction *gtk_action, BaseWindow *window )
{
- nact_iactions_list_collapse_all( NACT_IACTIONS_LIST( window ));
+ NactTreeView *items_view;
+
+ items_view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
+ nact_tree_view_collapse_all( items_view );
}
/**
* nact_menubar_view_on_toolbar_file:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Triggers View / Toolbar / File item.
*/
void
-nact_menubar_view_on_toolbar_file( GtkToggleAction *action, NactMainWindow *window )
+nact_menubar_view_on_toolbar_file( GtkToggleAction *action, BaseWindow *window )
{
/*on_view_toolbar_activated( action, window, MENUBAR_IPREFS_FILE_TOOLBAR, "/ui/FileToolbar", MENUBAR_FILE_TOOLBAR_POS );*/
on_view_toolbar_activated( action, window, MAIN_TOOLBAR_FILE_ID );
@@ -100,12 +105,12 @@ nact_menubar_view_on_toolbar_file( GtkToggleAction *action, NactMainWindow *wind
/**
* nact_menubar_view_on_toolbar_edit:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Triggers View / Toolbar / Edit item.
*/
void
-nact_menubar_view_on_toolbar_edit( GtkToggleAction *action, NactMainWindow *window )
+nact_menubar_view_on_toolbar_edit( GtkToggleAction *action, BaseWindow *window )
{
/*on_view_toolbar_activated( action, window, MENUBAR_IPREFS_EDIT_TOOLBAR, "/ui/EditToolbar", MENUBAR_EDIT_TOOLBAR_POS );*/
on_view_toolbar_activated( action, window, MAIN_TOOLBAR_EDIT_ID );
@@ -114,12 +119,12 @@ nact_menubar_view_on_toolbar_edit( GtkToggleAction *action, NactMainWindow *wind
/**
* nact_menubar_view_on_toolbar_tools:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Triggers View / Toolbar / Tools item.
*/
void
-nact_menubar_view_on_toolbar_tools( GtkToggleAction *action, NactMainWindow *window )
+nact_menubar_view_on_toolbar_tools( GtkToggleAction *action, BaseWindow *window )
{
/*on_view_toolbar_activated( action, window, MENUBAR_IPREFS_TOOLS_TOOLBAR, "/ui/ToolsToolbar", MENUBAR_TOOLS_TOOLBAR_POS );*/
on_view_toolbar_activated( action, window, MAIN_TOOLBAR_TOOLS_ID );
@@ -128,19 +133,19 @@ nact_menubar_view_on_toolbar_tools( GtkToggleAction *action, NactMainWindow *win
/**
* nact_menubar_view_on_toolbar_help:
* @gtk_action: the #GtkAction action.
- * @window: the #NactMainWindow main window.
+ * @window: the #BaseWindow main window.
*
* Triggers View / Toolbar / Help item.
*/
void
-nact_menubar_view_on_toolbar_help( GtkToggleAction *action, NactMainWindow *window )
+nact_menubar_view_on_toolbar_help( GtkToggleAction *action, BaseWindow *window )
{
/*on_view_toolbar_activated( action, window, MENUBAR_IPREFS_HELP_TOOLBAR, "/ui/HelpToolbar", MENUBAR_HELP_TOOLBAR_POS );*/
on_view_toolbar_activated( action, window, MAIN_TOOLBAR_HELP_ID );
}
static void
-on_view_toolbar_activated( GtkToggleAction *action, NactMainWindow *window, int toolbar_id )
+on_view_toolbar_activated( GtkToggleAction *action, BaseWindow *window, int toolbar_id )
{
gboolean is_active;
@@ -148,5 +153,5 @@ on_view_toolbar_activated( GtkToggleAction *action, NactMainWindow *window, int
is_active = gtk_toggle_action_get_active( action );
- nact_main_toolbar_activate( window, toolbar_id, bar->private->ui_manager, is_active );
+ nact_main_toolbar_activate( NACT_MAIN_WINDOW( window ), toolbar_id, bar->private->ui_manager, is_active );
}
diff --git a/src/nact/nact-menubar.c b/src/nact/nact-menubar.c
index 865c5a4..6ab8070 100644
--- a/src/nact/nact-menubar.c
+++ b/src/nact/nact-menubar.c
@@ -42,7 +42,7 @@
#include "nact-main-tab.h"
#include "nact-menubar-priv.h"
#include "nact-sort-buttons.h"
-#include "nact-iactions-list.h"
+#include "nact-tree-view.h"
/* private class data
*/
@@ -219,19 +219,25 @@ static void instance_finalize( GObject *application );
static void on_base_initialize_window( BaseWindow *window, gpointer user_data );
static void on_ui_manager_proxy_connect( GtkUIManager *ui_manager, GtkAction *action, GtkWidget *proxy, BaseWindow *window );
-static void on_menu_item_selected( GtkMenuItem *proxy, NactMainWindow *window );
-static void on_menu_item_deselected( GtkMenuItem *proxy, NactMainWindow *window );
-static void on_finalizing_window( NactMenubar *bar, GObject *window );
+static void on_menu_item_selected( GtkMenuItem *proxy, BaseWindow *window );
+static void on_menu_item_deselected( GtkMenuItem *proxy, BaseWindow *window );
+
+static void on_tree_view_open_context_menu( BaseWindow *window, NactTreeView *view, GdkEventButton *event, gpointer user_data );
+static void on_popup_selection_done( GtkMenuShell *menushell, BaseWindow *window );
+static void on_tree_view_count_changed( BaseWindow *window, NactTreeView *view, gboolean reset, guint menus, guint actions, guint profiles );
+static void on_tree_view_focus_in( BaseWindow *window, NactTreeView *view, gpointer user_data );
+static void on_tree_view_focus_out( BaseWindow *window, NactTreeView *view, gpointer user_data );
+static void on_tree_view_modified_count_changed( BaseWindow *window, NactTreeView *view, guint count, gpointer user_data );
+static void on_tree_view_selection_changed( BaseWindow *window, NactTreeView *view, GList *selected, gpointer user_data );
+
+static void on_update_sensitivities( NactMenubar *bar, BaseWindow *window );
-static void on_iactions_list_count_updated( NactMainWindow *window, gint menus, gint actions, gint profiles );
-static void on_iactions_list_selection_changed( NactMainWindow *window, GList *selected );
-static void on_iactions_list_focus_in( NactMainWindow *window, gpointer user_data );
-static void on_iactions_list_focus_out( NactMainWindow *window, gpointer user_data );
-static void on_iactions_list_status_changed( NactMainWindow *window, gpointer user_data );
-static void on_level_zero_order_changed( NactMainWindow *window, gpointer user_data );
-static void on_update_sensitivities( NactMenubar *bar, NactMainWindow *window );
+static void on_finalizing_window( NactMenubar *bar, GObject *window );
-static void on_popup_selection_done(GtkMenuShell *menushell, NactMainWindow *window );
+#if 0
+static void on_iactions_list_status_changed( BaseWindow *window, gpointer user_data );
+static void on_level_zero_order_changed( BaseWindow *window, gpointer user_data );
+#endif
GType
nact_menubar_get_type( void )
@@ -374,7 +380,7 @@ instance_finalize( GObject *instance )
/**
* nact_menubar_new:
- * @window: the main window which embeds the menubar, usually the #NactMainWindow.
+ * @window: the main window which embeds the menubar, usually the #BaseWindow.
*
* The created menubar attachs itself to the @window; it also connect a weak
* reference to this same @window, thus automatically g_object_unref() -ing
@@ -491,27 +497,35 @@ on_base_initialize_window( BaseWindow *window, gpointer user_data )
* items sensitivity
*/
base_window_signal_connect( window,
- G_OBJECT( window ), IACTIONS_LIST_SIGNAL_LIST_COUNT_UPDATED, G_CALLBACK( on_iactions_list_count_updated ));
+ G_OBJECT( window ), TREE_SIGNAL_CONTEXT_MENU, G_CALLBACK( on_tree_view_open_context_menu ));
base_window_signal_connect( window,
- G_OBJECT( window ), IACTIONS_LIST_SIGNAL_SELECTION_CHANGED, G_CALLBACK( on_iactions_list_selection_changed ));
+ G_OBJECT( window ), TREE_SIGNAL_COUNT_CHANGED, G_CALLBACK( on_tree_view_count_changed ));
base_window_signal_connect( window,
- G_OBJECT( window ), IACTIONS_LIST_SIGNAL_FOCUS_IN, G_CALLBACK( on_iactions_list_focus_in ));
+ G_OBJECT( window ), TREE_SIGNAL_FOCUS_IN, G_CALLBACK( on_tree_view_focus_in ));
base_window_signal_connect( window,
- G_OBJECT( window ), IACTIONS_LIST_SIGNAL_FOCUS_OUT, G_CALLBACK( on_iactions_list_focus_out ));
+ G_OBJECT( window ), TREE_SIGNAL_FOCUS_OUT, G_CALLBACK( on_tree_view_focus_out ));
base_window_signal_connect( window,
+ G_OBJECT( window ), TREE_SIGNAL_MODIFIED_COUNT_CHANGED, G_CALLBACK( on_tree_view_modified_count_changed ));
+
+ base_window_signal_connect( window,
+ G_OBJECT( window ), TREE_SIGNAL_SELECTION_CHANGED, G_CALLBACK( on_tree_view_selection_changed ));
+
+#if 0
+ base_window_signal_connect( window,
G_OBJECT( window ), IACTIONS_LIST_SIGNAL_STATUS_CHANGED, G_CALLBACK( on_iactions_list_status_changed ));
base_window_signal_connect( window,
G_OBJECT( window ), MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED, G_CALLBACK( on_level_zero_order_changed ));
+#endif
base_window_signal_connect( window,
G_OBJECT( bar ), MENUBAR_SIGNAL_UPDATE_SENSITIVITIES, G_CALLBACK( on_update_sensitivities ));
- nact_main_toolbar_init(( NactMainWindow * ) window, bar->private->action_group );
+ nact_main_toolbar_init( window, bar->private->action_group );
}
}
@@ -550,7 +564,7 @@ on_ui_manager_proxy_connect( GtkUIManager *ui_manager, GtkAction *action, GtkWid
* are only available starting with Gtk 2.16
*/
static void
-on_menu_item_selected( GtkMenuItem *proxy, NactMainWindow *window )
+on_menu_item_selected( GtkMenuItem *proxy, BaseWindow *window )
{
GtkAction *action;
gchar *tooltip;
@@ -574,7 +588,7 @@ on_menu_item_selected( GtkMenuItem *proxy, NactMainWindow *window )
#endif
if( tooltip ){
- nact_main_statusbar_display_status( window, MENUBAR_PROP_STATUS_CONTEXT, tooltip );
+ nact_main_statusbar_display_status( NACT_MAIN_WINDOW( window ), MENUBAR_PROP_STATUS_CONTEXT, tooltip );
}
#ifndef NA_HAS_GTK_ACTIVATABLE
@@ -583,20 +597,16 @@ on_menu_item_selected( GtkMenuItem *proxy, NactMainWindow *window )
}
static void
-on_menu_item_deselected( GtkMenuItem *proxy, NactMainWindow *window )
+on_menu_item_deselected( GtkMenuItem *proxy, BaseWindow *window )
{
- nact_main_statusbar_hide_status( window, MENUBAR_PROP_STATUS_CONTEXT );
+ nact_main_statusbar_hide_status( NACT_MAIN_WINDOW( window ), MENUBAR_PROP_STATUS_CONTEXT );
}
-/**
- * nact_menubar_open_popup:
- * @window: this #NactMainWindow window.
- * @event: the mouse event.
- *
+/*
* Opens a popup menu.
*/
-void
-nact_menubar_open_popup( BaseWindow *window, GdkEventButton *event )
+static void
+on_tree_view_open_context_menu( BaseWindow *window, NactTreeView *view, GdkEventButton *event, gpointer user_data )
{
GtkWidget *menu;
@@ -605,76 +615,102 @@ nact_menubar_open_popup( BaseWindow *window, GdkEventButton *event )
menu = gtk_ui_manager_get_widget( bar->private->ui_manager, "/ui/Popup" );
bar->private->popup_handler =
g_signal_connect( menu, "selection-done", G_CALLBACK( on_popup_selection_done ), window );
- g_signal_emit_by_name( bar, MENUBAR_SIGNAL_UPDATE_SENSITIVITIES );
+
gtk_menu_popup( GTK_MENU( menu ), NULL, NULL, NULL, NULL, event->button, event->time );
}
-/**
- * nact_menubar_save_items:
- * @window: the #NactMainWindow
- */
-void
-nact_menubar_save_items( BaseWindow *window )
+static void
+on_popup_selection_done(GtkMenuShell *menushell, BaseWindow *window )
{
- g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
+ static const gchar *thisfn = "nact_menubar_on_popup_selection_done";
- nact_menubar_file_save_items( NACT_MAIN_WINDOW( window ));
+ BAR_WINDOW_VOID( window );
+
+ g_debug( "%s", thisfn );
+
+ g_signal_handler_disconnect( menushell, bar->private->popup_handler );
+ bar->private->popup_handler = ( gulong ) 0;
}
/*
- * triggered just before the NactMainWindow is finalized
+ * when the tree view is refilled, update our internal counters so
+ * that we are knowing if we have some exportables
*/
static void
-on_finalizing_window( NactMenubar *bar, GObject *window )
+on_tree_view_count_changed( BaseWindow *window,
+ NactTreeView *view, gboolean reset, guint menus, guint actions, guint profiles )
{
- static const gchar *thisfn = "nact_menubar_on_finalizing_window";
+ static const gchar *thisfn = "nact_menubar_on_tree_view_count_changed";
+ gchar *status;
- g_return_if_fail( NACT_IS_MENUBAR( bar ));
+ BAR_WINDOW_VOID( window );
- g_debug( "%s: bar=%p (%s), window=%p", thisfn,
- ( void * ) bar, G_OBJECT_TYPE_NAME( bar ), ( void * ) window );
+ g_debug( "%s: window=%p, view=%p, reset=%s, menus=%u, actions=%u, profiles=%u",
+ thisfn, ( void * ) window, ( void * ) view, reset ? "True":"False", menus, actions, profiles );
- g_object_unref( bar );
-}
+ if( reset ){
+ bar->private->count_menus = menus;
+ bar->private->count_actions = actions;
+ bar->private->count_profiles = profiles;
-/**
- * nact_menubar_is_level_zero_order_changed:
- * @window: the #NactMainWindow main window.
- *
- * Returns: %TRUE if the level zero has changed, %FALSE else.
- */
-gboolean
-nact_menubar_is_level_zero_order_changed( const NactMainWindow *window )
-{
- BAR_WINDOW_VALUE( window, FALSE );
- return( bar->private->level_zero_order_changed );
+ } else {
+ bar->private->count_menus += menus;
+ bar->private->count_actions += actions;
+ bar->private->count_profiles += profiles;
+ }
+
+ bar->private->have_exportables = ( bar->private->count_menus + bar->private->count_actions > 0 );
+
+ nact_sort_buttons_enable_buttons( window, bar->private->count_menus + bar->private->count_actions > 0 );
+
+ /* i18n: note the space at the beginning of the sentence */
+ status = g_strdup_printf(
+ _( " %d menu(s), %d action(s), %d profile(s) are currently loaded" ),
+ bar->private->count_menus, bar->private->count_actions, bar->private->count_profiles );
+ nact_main_statusbar_display_status( NACT_MAIN_WINDOW( window ), MENUBAR_PROP_MAIN_STATUS_CONTEXT, status );
+ g_free( status );
+
+ g_signal_emit_by_name( bar, MENUBAR_SIGNAL_UPDATE_SENSITIVITIES );
}
/*
- * when the IActionsList is refilled, update our internal counters so
- * that we are knowing if we have some exportables
+ * the count of modified NAObjectItem has changed
*/
static void
-on_iactions_list_count_updated( NactMainWindow *window, gint menus, gint actions, gint profiles )
+on_tree_view_modified_count_changed( BaseWindow *window, NactTreeView *view, guint count, gpointer user_data )
{
- gchar *status;
+ static const gchar *thisfn = "nact_menubar_on_tree_view_modified_count_changed";
+
+ g_debug( "%s: window=%p, view=%p, count=%d, user_data=%p",
+ thisfn, ( void * ) window, ( void * ) view, count, ( void * ) user_data );
BAR_WINDOW_VOID( window );
- g_debug( "nact_menubar_on_iactions_list_count_updated: menus=%u, actions=%u, profiles=%u", menus, actions, profiles );
+ if( !bar->private->dispose_has_run ){
- bar->private->list_menus = menus;
- bar->private->list_actions = actions;
- bar->private->list_profiles = profiles;
- bar->private->have_exportables = ( bar->private->list_menus + bar->private->list_actions > 0 );
+ bar->private->count_modified = count;
+ }
+}
- nact_sort_buttons_enable_buttons( window, bar->private->list_menus + bar->private->list_actions > 0 );
+static void
+on_tree_view_focus_in( BaseWindow *window, NactTreeView *view, gpointer user_data )
+{
+ BAR_WINDOW_VOID( window );
- /* i18n: note the space at the beginning of the sentence */
- status = g_strdup_printf( _( " %d menu(s), %d action(s), %d profile(s) are currently loaded" ), menus, actions, profiles );
- nact_main_statusbar_display_status( window, MENUBAR_PROP_MAIN_STATUS_CONTEXT, status );
- g_free( status );
+ g_debug( "nact_menubar_on_tree_view_focus_in" );
+
+ bar->private->treeview_has_focus = TRUE;
+ g_signal_emit_by_name( bar, MENUBAR_SIGNAL_UPDATE_SENSITIVITIES );
+}
+
+static void
+on_tree_view_focus_out( BaseWindow *window, NactTreeView *view, gpointer user_data )
+{
+ BAR_WINDOW_VOID( window );
+ g_debug( "nact_menubar_on_tree_view_focus_out" );
+
+ bar->private->treeview_has_focus = FALSE;
g_signal_emit_by_name( bar, MENUBAR_SIGNAL_UPDATE_SENSITIVITIES );
}
@@ -682,9 +718,9 @@ on_iactions_list_count_updated( NactMainWindow *window, gint menus, gint actions
* when the selection changes in the tree view, see what is selected
*/
static void
-on_iactions_list_selection_changed( NactMainWindow *window, GList *selected )
+on_tree_view_selection_changed( BaseWindow *window, NactTreeView *view, GList *selected, gpointer user_data )
{
- static const gchar *thisfn = "nact_menubar_on_iactions_list_selection_changed";
+ static const gchar *thisfn = "nact_menubar_on_tree_view_selection_changed";
NAObject *first;
NAObject *selected_action;
GList *is;
@@ -785,50 +821,7 @@ on_iactions_list_selection_changed( NactMainWindow *window, GList *selected )
}
static void
-on_iactions_list_focus_in( NactMainWindow *window, gpointer user_data )
-{
- BAR_WINDOW_VOID( window );
-
- g_debug( "nact_menubar_on_iactions_list_focus_in" );
-
- bar->private->treeview_has_focus = TRUE;
- g_signal_emit_by_name( bar, MENUBAR_SIGNAL_UPDATE_SENSITIVITIES );
-}
-
-static void
-on_iactions_list_focus_out( NactMainWindow *window, gpointer user_data )
-{
- BAR_WINDOW_VOID( window );
-
- g_debug( "nact_menubar_on_iactions_list_focus_out" );
-
- bar->private->treeview_has_focus = FALSE;
- g_signal_emit_by_name( bar, MENUBAR_SIGNAL_UPDATE_SENSITIVITIES );
-}
-
-static void
-on_iactions_list_status_changed( NactMainWindow *window, gpointer user_data )
-{
- g_debug( "nact_menubar_on_iactions_list_status_changed" );
-
- BAR_WINDOW_VOID( window );
-
- g_signal_emit_by_name( bar, MENUBAR_SIGNAL_UPDATE_SENSITIVITIES );
-}
-
-static void
-on_level_zero_order_changed( NactMainWindow *window, gpointer user_data )
-{
- BAR_WINDOW_VOID( window );
-
- g_debug( "nact_menubar_on_level_zero_order_changed: change=%s", user_data ? "True":"False" );
-
- bar->private->level_zero_order_changed = GPOINTER_TO_INT( user_data );
- g_signal_emit_by_name( bar, MENUBAR_SIGNAL_UPDATE_SENSITIVITIES );
-}
-
-static void
-on_update_sensitivities( NactMenubar *bar, NactMainWindow *window )
+on_update_sensitivities( NactMenubar *bar, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_on_update_sensitivities";
@@ -862,15 +855,64 @@ nact_menubar_enable_item( const NactMenubar *bar, const gchar *name, gboolean en
}
}
+/**
+ * nact_menubar_save_items:
+ * @window: the #BaseWindow
+ */
+void
+nact_menubar_save_items( BaseWindow *window )
+{
+ nact_menubar_file_save_items( window );
+}
+
+/*
+ * triggered just before the BaseWindow is finalized
+ */
+static void
+on_finalizing_window( NactMenubar *bar, GObject *window )
+{
+ static const gchar *thisfn = "nact_menubar_on_finalizing_window";
+
+ g_return_if_fail( NACT_IS_MENUBAR( bar ));
+
+ g_debug( "%s: bar=%p (%s), window=%p", thisfn,
+ ( void * ) bar, G_OBJECT_TYPE_NAME( bar ), ( void * ) window );
+
+ g_object_unref( bar );
+}
+
+#if 0
+/**
+ * nact_menubar_is_level_zero_order_changed:
+ * @window: the #BaseWindow main window.
+ *
+ * Returns: %TRUE if the level zero has changed, %FALSE else.
+ */
+gboolean
+nact_menubar_is_level_zero_order_changed( const BaseWindow *window )
+{
+ BAR_WINDOW_VALUE( window, FALSE );
+ return( bar->private->level_zero_order_changed );
+}
+
static void
-on_popup_selection_done(GtkMenuShell *menushell, NactMainWindow *window )
+on_iactions_list_status_changed( BaseWindow *window, gpointer user_data )
{
- static const gchar *thisfn = "nact_menubar_on_popup_selection_done";
+ g_debug( "nact_menubar_on_iactions_list_status_changed" );
BAR_WINDOW_VOID( window );
- g_debug( "%s", thisfn );
+ g_signal_emit_by_name( bar, MENUBAR_SIGNAL_UPDATE_SENSITIVITIES );
+}
- g_signal_handler_disconnect( menushell, bar->private->popup_handler );
- bar->private->popup_handler = ( gulong ) 0;
+static void
+on_level_zero_order_changed( BaseWindow *window, gpointer user_data )
+{
+ BAR_WINDOW_VOID( window );
+
+ g_debug( "nact_menubar_on_level_zero_order_changed: change=%s", user_data ? "True":"False" );
+
+ bar->private->level_zero_order_changed = GPOINTER_TO_INT( user_data );
+ g_signal_emit_by_name( bar, MENUBAR_SIGNAL_UPDATE_SENSITIVITIES );
}
+#endif
diff --git a/src/nact/nact-menubar.h b/src/nact/nact-menubar.h
index b26f8dc..cceefec 100644
--- a/src/nact/nact-menubar.h
+++ b/src/nact/nact-menubar.h
@@ -60,10 +60,6 @@
#include "base-window.h"
-/* *** */
-#include "nact-main-window.h"
-/* *** */
-
G_BEGIN_DECLS
#define NACT_MENUBAR_TYPE ( nact_menubar_get_type())
@@ -95,11 +91,10 @@ GType nact_menubar_get_type( void );
NactMenubar *nact_menubar_new ( BaseWindow *window );
-void nact_menubar_open_popup( BaseWindow *window, GdkEventButton *event );
void nact_menubar_save_items( BaseWindow *window );
/* *** */
-gboolean nact_menubar_is_level_zero_order_changed( const NactMainWindow *window );
+gboolean nact_menubar_is_level_zero_order_changed( const BaseWindow *window );
/* *** */
G_END_DECLS
diff --git a/src/nact/nact-sort-buttons.c b/src/nact/nact-sort-buttons.c
index 730a7f7..34c6fe4 100644
--- a/src/nact/nact-sort-buttons.c
+++ b/src/nact/nact-sort-buttons.c
@@ -50,10 +50,10 @@ static gboolean st_in_toggle = FALSE;
static gboolean st_enable_buttons = FALSE;
static gint st_last_active = -1;
-static void enable_buttons( NactMainWindow *window );
-static void on_toggle_button_toggled( GtkToggleButton *button, NactMainWindow *window );
-static void set_new_sort_order( NactMainWindow *window, guint order_mode );
-static void display_sort_order( NactMainWindow *window, guint order_mode );
+static void enable_buttons( BaseWindow *window );
+static void on_toggle_button_toggled( GtkToggleButton *button, BaseWindow *window );
+static void set_new_sort_order( BaseWindow *window, guint order_mode );
+static void display_sort_order( BaseWindow *window, guint order_mode );
static gint toggle_group_get_active( ToggleGroup *group, BaseWindow *window );
static gint toggle_group_get_for_mode( ToggleGroup *group, guint mode );
static void toggle_group_set_active( ToggleGroup *group, BaseWindow *window, gint idx );
@@ -68,7 +68,7 @@ static ToggleGroup st_toggle_group [] = {
/**
* nact_sort_buttons_runtime_init:
- * @window: the #NactMainWindow.
+ * @window: the #BaseWindow.
*
* Initialization of the UI each time it is displayed.
*
@@ -78,7 +78,7 @@ static ToggleGroup st_toggle_group [] = {
* - enabled (sensitive) if level zero is writable
*/
void
-nact_sort_buttons_runtime_init( NactMainWindow *window )
+nact_sort_buttons_runtime_init( BaseWindow *window )
{
static const gchar *thisfn = "nact_sort_buttons_runtime_init";
GtkToggleButton *button;
@@ -104,13 +104,13 @@ nact_sort_buttons_runtime_init( NactMainWindow *window )
/**
* nact_sort_buttons_all_widgets_showed:
- * @window: the #NactMainWindow.
+ * @window: the #BaseWindow.
*
* Called when all the widgets are showed after end of all runtime
* initializations.
*/
void
-nact_sort_buttons_all_widgets_showed( NactMainWindow *window )
+nact_sort_buttons_all_widgets_showed( BaseWindow *window )
{
static const gchar *thisfn = "nact_sort_buttons_all_widgets_showed";
@@ -121,7 +121,7 @@ nact_sort_buttons_all_widgets_showed( NactMainWindow *window )
/**
* nact_sort_buttons_enable_buttons:
- * @window: the #NactMainWindow.
+ * @window: the #BaseWindow.
* @enable: whether we wish enable or disable these sort buttons.
*
* Enable or disable the sort buttons, while keeping relevant with
@@ -131,7 +131,7 @@ nact_sort_buttons_all_widgets_showed( NactMainWindow *window )
* the sort buttons, typically when there is no record to sort.
*/
void
-nact_sort_buttons_enable_buttons( NactMainWindow *window, gboolean enable )
+nact_sort_buttons_enable_buttons( BaseWindow *window, gboolean enable )
{
static const gchar *thisfn = "nact_sort_buttons_enable_buttons";
@@ -143,12 +143,12 @@ nact_sort_buttons_enable_buttons( NactMainWindow *window, gboolean enable )
/**
* nact_sort_buttons_dispose:
- * @window: the #NactMainWindow.
+ * @window: the #BaseWindow.
*
* The main window is disposed.
*/
void
-nact_sort_buttons_dispose( NactMainWindow *window )
+nact_sort_buttons_dispose( BaseWindow *window )
{
static const gchar *thisfn = "nact_sort_buttons_dispose";
@@ -157,13 +157,13 @@ nact_sort_buttons_dispose( NactMainWindow *window )
/**
* nact_sort_buttons_display_order_change:
- * @window: the #NactMainWindow.
+ * @window: the #BaseWindow.
* @order_mode: the new order mode.
*
- * Relayed via NactMainWindow, this is a NAIPivotConsumer notification.
+ * Relayed via BaseWindow, this is a NAIPivotConsumer notification.
*/
void
-nact_sort_buttons_display_order_change( NactMainWindow *window, guint order_mode )
+nact_sort_buttons_display_order_change( BaseWindow *window, guint order_mode )
{
static const gchar *thisfn = "nact_sort_buttons_display_order_change";
@@ -174,12 +174,12 @@ nact_sort_buttons_display_order_change( NactMainWindow *window, guint order_mode
/**
* nact_sort_buttons_level_zero_writability_change:
- * @window: the #NactMainWindow.
+ * @window: the #BaseWindow.
*
- * Relayed via NactMainWindow, this is a NAIPivotConsumer notification.
+ * Relayed via BaseWindow, this is a NAIPivotConsumer notification.
*/
void
-nact_sort_buttons_level_zero_writability_change( NactMainWindow *window )
+nact_sort_buttons_level_zero_writability_change( BaseWindow *window )
{
static const gchar *thisfn = "nact_sort_buttons_level_zero_writability_change";
@@ -189,7 +189,7 @@ nact_sort_buttons_level_zero_writability_change( NactMainWindow *window )
}
static void
-enable_buttons( NactMainWindow *window )
+enable_buttons( BaseWindow *window )
{
NactApplication *application;
NAUpdater *updater;
@@ -210,7 +210,7 @@ enable_buttons( NactMainWindow *window )
}
static void
-on_toggle_button_toggled( GtkToggleButton *toggled_button, NactMainWindow *window )
+on_toggle_button_toggled( GtkToggleButton *toggled_button, BaseWindow *window )
{
static const gchar *thisfn = "nact_sort_buttons_on_toggle_button_toggled";
gint ibtn, iprev;
@@ -235,7 +235,7 @@ on_toggle_button_toggled( GtkToggleButton *toggled_button, NactMainWindow *windo
}
static void
-set_new_sort_order( NactMainWindow *window, guint order_mode )
+set_new_sort_order( BaseWindow *window, guint order_mode )
{
static const gchar *thisfn = "nact_sort_buttons_set_new_sort_order";
NactApplication *application;
@@ -257,7 +257,7 @@ set_new_sort_order( NactMainWindow *window, guint order_mode )
* do nothing if new button and previous button are the sames
*/
static void
-display_sort_order( NactMainWindow *window, guint order_mode )
+display_sort_order( BaseWindow *window, guint order_mode )
{
static const gchar *thisfn = "nact_sort_buttons_display_sort_order";
gint iprev, inew;
diff --git a/src/nact/nact-sort-buttons.h b/src/nact/nact-sort-buttons.h
index 73d0426..221c844 100644
--- a/src/nact/nact-sort-buttons.h
+++ b/src/nact/nact-sort-buttons.h
@@ -37,16 +37,16 @@
* @include: nact/nact-sort-buttons.h
*/
-#include "nact-main-window.h"
+#include "base-window.h"
G_BEGIN_DECLS
-void nact_sort_buttons_runtime_init ( NactMainWindow *window );
-void nact_sort_buttons_all_widgets_showed ( NactMainWindow *window );
-void nact_sort_buttons_enable_buttons ( NactMainWindow *window, gboolean enable );
-void nact_sort_buttons_dispose ( NactMainWindow *window );
-void nact_sort_buttons_display_order_change ( NactMainWindow *window, guint order_mode );
-void nact_sort_buttons_level_zero_writability_change( NactMainWindow *window );
+void nact_sort_buttons_runtime_init ( BaseWindow *window );
+void nact_sort_buttons_all_widgets_showed ( BaseWindow *window );
+void nact_sort_buttons_enable_buttons ( BaseWindow *window, gboolean enable );
+void nact_sort_buttons_dispose ( BaseWindow *window );
+void nact_sort_buttons_display_order_change ( BaseWindow *window, guint order_mode );
+void nact_sort_buttons_level_zero_writability_change( BaseWindow *window );
G_END_DECLS
diff --git a/src/nact/nact-tree-ieditable.c b/src/nact/nact-tree-ieditable.c
new file mode 100644
index 0000000..e7a1a3c
--- /dev/null
+++ b/src/nact/nact-tree-ieditable.c
@@ -0,0 +1,1211 @@
+/*
+ * Nautilus-Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "nact-tree-ieditable.h"
+
+/* private interface data
+ */
+struct _NactTreeIEditableInterfacePrivate {
+ void *empty; /* so that gcc -pedantic is happy */
+};
+
+/* data attached to the NactTreeView
+ */
+typedef struct {
+ guint nb_modified;
+}
+ IEditableData;
+
+#define VIEW_DATA_IEDITABLE "view-data-ieditable"
+
+static gboolean st_tree_ieditable_initialized = FALSE;
+static gboolean st_tree_ieditable_finalized = FALSE;
+
+static GType register_type( void );
+static void interface_base_init( NactTreeIEditableInterface *klass );
+static void interface_base_finalize( NactTreeIEditableInterface *klass );
+
+static IEditableData *get_instance_data( NactTreeIEditable *view );
+
+GType
+nact_tree_ieditable_get_type( void )
+{
+ static GType iface_type = 0;
+
+ if( !iface_type ){
+ iface_type = register_type();
+ }
+
+ return( iface_type );
+}
+
+static GType
+register_type( void )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_register_type";
+ GType type;
+
+ static const GTypeInfo info = {
+ sizeof( NactTreeIEditableInterface ),
+ ( GBaseInitFunc ) interface_base_init,
+ ( GBaseFinalizeFunc ) interface_base_finalize,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ NULL
+ };
+
+ g_debug( "%s", thisfn );
+
+ type = g_type_register_static( G_TYPE_INTERFACE, "NactTreeIEditable", &info, 0 );
+
+ return( type );
+}
+
+static void
+interface_base_init( NactTreeIEditableInterface *klass )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_interface_base_init";
+
+ if( !st_tree_ieditable_initialized ){
+ g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+
+ klass->private = g_new0( NactTreeIEditableInterfacePrivate, 1 );
+
+ st_tree_ieditable_initialized = TRUE;
+ }
+}
+
+static void
+interface_base_finalize( NactTreeIEditableInterface *klass )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_interface_base_finalize";
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+ g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+
+ st_tree_ieditable_finalized = TRUE;
+
+ g_free( klass->private );
+ }
+}
+
+/**
+ * nact_tree_ieditable_view_constructed:
+ * @view: the #NactTreeView which implements this interface.
+ * @window: the #BaseWindow which embeds the @view.
+ *
+ * Initialize the interface, mainly connecting to signals of interest.
+ */
+void
+nact_tree_ieditable_on_view_constructed( NactTreeView *view, BaseWindow *window )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_on_view_constructed";
+ IEditableData *ied;
+
+ g_debug( "%s: view=%p, window=%p", thisfn, ( void * ) view, ( void * ) window );
+
+ ied = get_instance_data( NACT_TREE_IEDITABLE( view ));
+}
+
+static IEditableData *
+get_instance_data( NactTreeIEditable *view )
+{
+ IEditableData *ied;
+
+ ied = ( IEditableData * ) g_object_get_data( G_OBJECT( view ), VIEW_DATA_IEDITABLE );
+
+ if( !ied ){
+ ied = g_new0( IEditableData, 1 );
+ g_object_set_data( G_OBJECT( view ), VIEW_DATA_IEDITABLE, ied );
+ }
+
+ return( ied );
+}
+
+#if 0
+/* when iterating through a selection
+ */
+typedef struct {
+ gboolean has_menu_or_action;
+}
+ SelectionIter;
+
+/* signals
+ */
+enum {
+ LIST_COUNT_UPDATED,
+ SELECTION_CHANGED,
+ FOCUS_IN,
+ FOCUS_OUT,
+ COLUMN_EDITED,
+ STATUS_CHANGED,
+ LAST_SIGNAL
+};
+
+static gint st_signals[ LAST_SIGNAL ] = { 0 };
+
+static void free_items_callback( NactTreeIEditable *instance, GList *items );
+static void free_column_edited_callback( NactTreeIEditable *instance, NAObject *object, gchar *text, gint column );
+
+static gboolean are_profiles_displayed( NactTreeIEditable *instance, TreeIEditableInstanceData *ialid );
+static void display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, NactTreeIEditable *instance );
+static gboolean filter_selection( GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, NactTreeIEditable *instance );
+static gboolean filter_selection_is_homogeneous( GtkTreeSelection *selection, NAObject *object );
+static void filter_selection_iter( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, SelectionIter *str );
+static gboolean filter_selection_has_menu_or_action( GtkTreeSelection *selection );
+static gboolean filter_selection_is_implicitely_selected( NAObject *object );
+static void filter_selection_set_implicitely_selected_childs( NAObject *object, gboolean select );
+static gboolean have_dnd_mode( NactTreeIEditable *instance, TreeIEditableInstanceData *ialid );
+static gboolean have_filter_selection_mode( NactTreeIEditable *instance, TreeIEditableInstanceData *ialid );
+static void inline_edition( NactTreeIEditable *instance );
+static gboolean is_iduplicable_proxy( NactTreeIEditable *instance, TreeIEditableInstanceData *ialid );
+static gboolean on_button_press_event( GtkWidget *widget, GdkEventButton *event, NactTreeIEditable *instance );
+static void on_edition_status_changed( NactTreeIEditable *instance, NAIDuplicable *object );
+static gboolean on_focus_in( GtkWidget *widget, GdkEventFocus *event, NactTreeIEditable *instance );
+static gboolean on_focus_out( GtkWidget *widget, GdkEventFocus *event, NactTreeIEditable *instance );
+static gboolean on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, NactTreeIEditable *instance );
+static void on_label_edited( GtkCellRendererText *renderer, const gchar *path, const gchar *text, NactTreeIEditable *instance );
+static void on_tab_updatable_item_updated( NactTreeIEditable *instance, NAObject *object, gboolean force_display );
+static void open_popup( NactTreeIEditable *instance, GdkEventButton *event );
+
+static void
+free_items_callback( NactTreeIEditable *instance, GList *items )
+{
+ g_debug( "nact_tree_ieditable_free_items_callback: selection=%p (%d items)",
+ ( void * ) items, g_list_length( items ));
+
+ na_object_free_items( items );
+}
+
+static void
+free_column_edited_callback( NactTreeIEditable *instance, NAObject *object, gchar *text, gint column )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_free_column_edited_callback";
+
+ g_debug( "%s: instance=%p, object=%p (%s), text=%s, column=%d",
+ thisfn, ( void * ) instance, ( void * ) object, G_OBJECT_TYPE_NAME( object ), text, column );
+
+ g_free( text );
+}
+
+/**
+ * nact_tree_ieditable_initial_load_toplevel:
+ * @instance: this #NactTreeIEditable *instance.
+ *
+ * Allocates and initializes the ActionsList widget.
+ *
+ * GtkTreeView is created with NactTreeModel model
+ * NactTreeModel
+ * implements EggTreeMultiDragSourceIface
+ * is derived from GtkTreeModelFilter
+ * GtkTreeModelFilter is built on top of GtkTreeStore
+ *
+ * Please note that management mode for the list should have been set
+ * before calling this function.
+ */
+void
+nact_tree_ieditable_initial_load_toplevel( NactTreeIEditable *instance )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_initial_load_toplevel";
+ GtkWidget *label;
+ GtkTreeView *treeview;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ TreeIEditableInstanceData *ialid;
+
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+ ialid->selection_changed_allowed = FALSE;
+
+ /* associates the ActionsList to the label */
+ label = base_window_get_widget( BASE_WINDOW( instance ), "ActionsListLabel" );
+ gtk_label_set_mnemonic_widget( GTK_LABEL( label ), GTK_WIDGET( treeview ));
+
+ nact_tree_model_initial_load( BASE_WINDOW( instance ), treeview );
+ gtk_tree_view_set_enable_tree_lines( treeview, TRUE );
+
+ /* create visible columns on the tree view
+ */
+ /* icon: no header */
+ column = gtk_tree_view_column_new_with_attributes(
+ "icon",
+ gtk_cell_renderer_pixbuf_new(),
+ "pixbuf", TREE_IEDITABLE_ICON_COLUMN,
+ NULL );
+ gtk_tree_view_append_column( treeview, column );
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(
+ "label",
+ renderer,
+ "text", TREE_IEDITABLE_LABEL_COLUMN,
+ NULL );
+ gtk_tree_view_column_set_sort_column_id( column, TREE_IEDITABLE_LABEL_COLUMN );
+ gtk_tree_view_column_set_cell_data_func(
+ column, renderer, ( GtkTreeCellDataFunc ) display_label, instance, NULL );
+ gtk_tree_view_append_column( treeview, column );
+ }
+}
+
+/**
+ * nact_tree_ieditable_runtime_init_toplevel:
+ * @window: this #NactTreeIEditable *instance.
+ * @items: list of #NAObject actions and menus as provided by #NAPivot.
+ *
+ * Allocates and initializes the ActionsList widget.
+ */
+void
+nact_tree_ieditable_runtime_init_toplevel( NactTreeIEditable *instance, GList *items )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_runtime_init_toplevel";
+ GtkTreeView *treeview;
+ NactTreeModel *model;
+ gboolean have_dnd;
+ gboolean have_filter_selection;
+ gboolean is_proxy;
+ GtkTreeSelection *selection;
+ TreeIEditableInstanceData *ialid;
+ GtkTreeViewColumn *column;
+ GList *renderers;
+
+ g_debug( "%s: instance=%p, items=%p (%d items)",
+ thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ));
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+ ialid->selection_changed_allowed = FALSE;
+ have_dnd = have_dnd_mode( instance, ialid );
+ have_filter_selection = have_filter_selection_mode( instance, ialid );
+
+ if( have_filter_selection ){
+ selection = gtk_tree_view_get_selection( treeview );
+ gtk_tree_selection_set_select_function( selection, ( GtkTreeSelectionFunc ) filter_selection, instance, NULL );
+ }
+
+ nact_tree_model_runtime_init( model, have_dnd );
+
+ /* set up selection control */
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( gtk_tree_view_get_selection( treeview )),
+ "changed",
+ G_CALLBACK( nact_tree_ieditable_on_treeview_selection_changed ));
+
+ /* catch press 'Enter' */
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( treeview ),
+ "key-press-event",
+ G_CALLBACK( on_key_pressed_event ));
+
+ /* catch double-click */
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( treeview ),
+ "button-press-event",
+ G_CALLBACK( on_button_press_event ));
+
+ /* updates the treeview display when an item is modified */
+ ialid->tab_updated_handler = base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( instance ),
+ TAB_UPDATABLE_SIGNAL_ITEM_UPDATED,
+ G_CALLBACK( on_tab_updatable_item_updated ));
+
+ /* enable/disable edit menu item accelerators depending of
+ * which widget has the focus */
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( treeview ),
+ "focus-in-event",
+ G_CALLBACK( on_focus_in ));
+
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( treeview ),
+ "focus-out-event",
+ G_CALLBACK( on_focus_out ));
+
+ /* label edition: inform the corresponding tab */
+ column = gtk_tree_view_get_column( treeview, TREE_IEDITABLE_LABEL_COLUMN );
+ renderers = gtk_cell_layout_get_cells( GTK_CELL_LAYOUT( column ));
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( renderers->data ),
+ "edited",
+ G_CALLBACK( on_label_edited ));
+
+ /* records NactTreeIEditable as a proxy for edition status
+ * modification */
+ is_proxy = is_iduplicable_proxy( instance, ialid );
+ if( is_proxy ){
+ na_iduplicable_register_consumer( G_OBJECT( instance ));
+
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( instance ),
+ NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED,
+ G_CALLBACK( on_edition_status_changed ));
+ }
+
+ /* fill the model after having connected the signals
+ * so that callbacks are triggered at last
+ */
+ nact_tree_ieditable_fill( instance, items );
+
+ /* force the treeview to have the focus at start
+ */
+ gtk_widget_grab_focus( GTK_WIDGET( treeview ));
+ }
+}
+
+/**
+ * nact_tree_ieditable_all_widgets_showed:
+ * @window: this #NactTreeIEditable *instance.
+ */
+void
+nact_tree_ieditable_all_widgets_showed( NactTreeIEditable *instance )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_all_widgets_showed";
+ gboolean profiles_are_displayed;
+ TreeIEditableInstanceData *ialid;
+
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+ profiles_are_displayed = are_profiles_displayed( instance, ialid );
+
+ if( profiles_are_displayed ){
+ nact_tree_ieditable_priv_send_list_count_updated_signal( instance, ialid );
+ }
+
+ nact_tree_ieditable_bis_select_first_row( instance );
+ }
+}
+
+/**
+ * nact_tree_ieditable_dispose:
+ * @window: this #NactTreeIEditable *instance.
+ */
+void
+nact_tree_ieditable_dispose( NactTreeIEditable *instance )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_dispose";
+ GtkTreeView *treeview;
+ NactTreeModel *model;
+ TreeIEditableInstanceData *ialid;
+
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+ g_list_free( ialid->modified_items );
+ ialid->modified_items = NULL;
+
+ ialid->selection_changed_allowed = FALSE;
+ nact_tree_model_dispose( model );
+
+ g_free( ialid );
+ }
+}
+
+/**
+ * nact_tree_ieditable_brief_tree_dump:
+ * @instance: this #NactTreeIEditable implementation.
+ *
+ * Brief dump of the tree store content.
+ */
+void
+nact_tree_ieditable_brief_tree_dump( NactTreeIEditable *instance )
+{
+ GtkTreeView *treeview;
+ NactTreeModel *model;
+
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ nact_tree_model_dump( model );
+ }
+}
+
+/**
+ * nact_tree_ieditable_collapse_all:
+ * @instance: this #NactTreeIEditable implementation.
+ *
+ * Collapse all the tree hierarchy.
+ */
+void
+nact_tree_ieditable_collapse_all( NactTreeIEditable *instance )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_collapse_all";
+ GtkTreeView *treeview;
+
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ gtk_tree_view_collapse_all( treeview );
+ }
+}
+
+/**
+ * nact_tree_ieditable_display_order_change:
+ * @instance: this #NactTreeIEditable implementation.
+ * @order_mode: the new order mode.
+ *
+ * Setup the new order mode.
+ */
+void
+nact_tree_ieditable_display_order_change( NactTreeIEditable *instance, gint order_mode )
+{
+ GtkTreeView *treeview;
+ NactTreeModel *model;
+
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ nact_tree_model_display_order_change( model, order_mode );
+ }
+}
+
+/**
+ * nact_tree_ieditable_expand_all:
+ * @instance: this #NactTreeIEditable implementation.
+ *
+ * Expand all the tree hierarchy.
+ */
+void
+nact_tree_ieditable_expand_all( NactTreeIEditable *instance )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_expand_all";
+ GtkTreeView *treeview;
+
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ gtk_tree_view_expand_all( treeview );
+ }
+}
+
+/**
+ * nact_tree_ieditable_fill:
+ * @instance: this #NactTreeIEditable instance.
+ *
+ * Fill the listbox with the provided list of items.
+ *
+ * Menus are expanded, profiles are not.
+ * The selection is reset to the first line of the tree, if there is one.
+ */
+void
+nact_tree_ieditable_fill( NactTreeIEditable *instance, GList *items )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_fill";
+ GtkTreeView *treeview;
+ NactTreeModel *model;
+ gboolean profiles_are_displayed;
+ TreeIEditableInstanceData *ialid;
+
+ g_debug( "%s: instance=%p, items=%p", thisfn, ( void * ) instance, ( void * ) items );
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+
+ nact_tree_ieditable_bis_clear_selection( instance, treeview );
+
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+ profiles_are_displayed = are_profiles_displayed( instance, ialid );
+ g_debug( "%s: profiles_are_displayed:%s", thisfn, profiles_are_displayed ? "True":"False" );
+
+ ialid->selection_changed_allowed = FALSE;
+ nact_tree_model_fill( model, items, profiles_are_displayed );
+ ialid->selection_changed_allowed = TRUE;
+
+ g_list_free( ialid->modified_items );
+ ialid->modified_items = NULL;
+
+ g_signal_emit_by_name(
+ instance,
+ MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED,
+ GINT_TO_POINTER( FALSE ));
+
+ ialid->menus = 0;
+ ialid->actions = 0;
+ ialid->profiles = 0;
+
+ if( profiles_are_displayed ){
+ na_object_item_count_items( items, &ialid->menus, &ialid->actions, &ialid->profiles, TRUE );
+ nact_tree_ieditable_priv_send_list_count_updated_signal( instance, ialid );
+ }
+ }
+}
+
+/**
+ * nact_tree_ieditable_get_management_mode:
+ * @instance: this #NactTreeIEditable instance.
+ *
+ * Returns: the current management mode of the list.
+ */
+gint
+nact_tree_ieditable_get_management_mode( NactTreeIEditable *instance )
+{
+ gint mode = 0;
+ TreeIEditableInstanceData *ialid;
+
+ g_return_val_if_fail( NACT_IS_TREE_IEDITABLE( instance ), 0 );
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+ mode = ialid->management_mode;
+ }
+
+ return( mode );
+}
+
+/**
+ * nact_tree_ieditable_has_modified_items:
+ * @window: this #NactTreeIEditable instance.
+ *
+ * Returns: %TRUE if at least there is one modified item in the list.
+ */
+gboolean
+nact_tree_ieditable_has_modified_items( NactTreeIEditable *instance )
+{
+ gboolean has_modified = FALSE;
+ /*GtkTreeView *treeview;
+ NactTreeModel *model;*/
+ TreeIEditableInstanceData *ialid;
+
+ g_return_val_if_fail( NACT_IS_TREE_IEDITABLE( instance ), FALSE );
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+ has_modified = ( g_list_length( ialid->modified_items ) > 0 );
+
+ /*treeview = get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ nact_tree_model_iter( model, ( FnIterOnStore ) has_modified_iter, &has_modified );*/
+ }
+
+ return( has_modified );
+}
+
+/**
+ * nact_tree_ieditable_on_treeview_selection_changed:
+ * @selection: current selection.
+ * @instance: this instance of the #NactTreeIEditable interface.
+ *
+ * This is our handler for "changed" signal emitted by the treeview.
+ * The handler is inhibited while filling the list (usually only at
+ * runtime init), and while deleting a selection.
+ */
+void
+nact_tree_ieditable_on_treeview_selection_changed( GtkTreeSelection *selection, NactTreeIEditable *instance )
+{
+ GList *selected_items;
+ TreeIEditableInstanceData *ialid;
+
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+ if( ialid->selection_changed_allowed ){
+
+ g_debug( "nact_tree_ieditable_on_treeview_selection_changed" );
+ g_signal_handler_block( instance, ialid->tab_updated_handler );
+
+ selected_items = nact_tree_ieditable_bis_get_selected_items( instance );
+ g_debug( "nact_tree_ieditable_on_treeview_selection_changed: selection=%p (%d items)", ( void * ) selected_items, g_list_length( selected_items ));
+ g_signal_emit_by_name( instance, TREE_IEDITABLE_SIGNAL_SELECTION_CHANGED, selected_items );
+
+ g_signal_handler_unblock( instance, ialid->tab_updated_handler );
+
+ /* selection list is freed in cleanup handler for the signal */
+ }
+}
+
+/**
+ * nact_tree_ieditable_remove_rec:
+ * @list: list of modified objects.
+ * @object: the object to be removed from the list.
+ *
+ * When removing from modified list an object which is no more modified,
+ * then all subitems of the object have also to be removed
+ *
+ * Returns: the updated list.
+ */
+GList *
+nact_tree_ieditable_remove_rec( GList *list, NAObject *object )
+{
+ GList *subitems, *it;
+
+ if( NA_IS_OBJECT_ITEM( object )){
+ subitems = na_object_get_items( object );
+ for( it = subitems ; it ; it = it->next ){
+ list = nact_tree_ieditable_remove_rec( list, it->data );
+ }
+ }
+
+ list = g_list_remove( list, object );
+
+ return( list );
+}
+
+/**
+ * nact_tree_ieditable_set_management_mode:
+ * @instance: this #NactTreeIEditable instance.
+ * @mode: management mode.
+ *
+ * Set the management mode for this @instance.
+ *
+ * For the two known modes (edition mode, export mode), we also allow
+ * multiple selection in the list.
+ */
+void
+nact_tree_ieditable_set_management_mode( NactTreeIEditable *instance, gint mode )
+{
+ GtkTreeView *treeview;
+ GtkTreeSelection *selection;
+ gboolean multiple;
+ TreeIEditableInstanceData *ialid;
+
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+ ialid->management_mode = mode;
+
+ multiple = ( mode == TREE_IEDITABLE_MANAGEMENT_MODE_EDITION ||
+ mode == TREE_IEDITABLE_MANAGEMENT_MODE_EXPORT );
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ selection = gtk_tree_view_get_selection( treeview );
+ gtk_tree_selection_set_mode( selection, multiple ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE );
+ }
+}
+
+static gboolean
+are_profiles_displayed( NactTreeIEditable *instance, TreeIEditableInstanceData *ialid )
+{
+ gboolean display;
+
+ display = ( ialid->management_mode == TREE_IEDITABLE_MANAGEMENT_MODE_EDITION );
+
+ return( display );
+}
+
+/*
+ * item modified: italic
+ * item not saveable (invalid): red
+ */
+static void
+display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, NactTreeIEditable *instance )
+{
+ NAObject *object;
+ gchar *label;
+ gboolean modified = FALSE;
+ gboolean valid = TRUE;
+ TreeIEditableInstanceData *ialid;
+ NAObjectItem *item;
+#if 0
+ gboolean writable_item;
+ NactApplication *application;
+ NAUpdater *updater;
+#endif
+
+ gtk_tree_model_get( model, iter, TREE_IEDITABLE_NAOBJECT_COLUMN, &object, -1 );
+ g_object_unref( object );
+ g_return_if_fail( NA_IS_OBJECT( object ));
+
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+ label = na_object_get_label( object );
+ g_object_set( cell, "style-set", FALSE, NULL );
+ g_object_set( cell, "foreground-set", FALSE, NULL );
+ /*g_debug( "nact_tree_ieditable_display_label: %s %s", G_OBJECT_TYPE_NAME( object ), label );*/
+
+ if( ialid->management_mode == TREE_IEDITABLE_MANAGEMENT_MODE_EDITION ){
+
+ modified = na_object_is_modified( object );
+ valid = na_object_is_valid( object );
+ item = NA_IS_OBJECT_PROFILE( object ) ? na_object_get_parent( object ) : NA_OBJECT_ITEM( object );
+
+ if( modified ){
+ g_object_set( cell, "style", PANGO_STYLE_ITALIC, "style-set", TRUE, NULL );
+ }
+
+ if( !valid ){
+ g_object_set( cell, "foreground", "Red", "foreground-set", TRUE, NULL );
+ }
+
+#if 0
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( instance )));
+ updater = nact_application_get_updater( application );
+ writable_item = na_updater_is_item_writable( updater, item, NULL );
+ g_object_set( cell, "editable", writable_item, NULL );
+#endif
+ }
+
+ g_object_set( cell, "text", label, NULL );
+ g_free( label );
+}
+
+/*
+ * rationale: it is very difficult to copy anything in the clipboard,
+ * and to hope that this will be easily copyable anywhere after.
+ * We know how to insert profiles, or how to insert actions or menus,
+ * but not how nor where to insert e.g. a mix selection.
+ *
+ * So a selection must first be homogeneous, i.e. it only contains
+ * explicitely selected profiles _or_ menus or actions (and their childs).
+ *
+ * To simplify the selection management while letting the user actually
+ * select almost anything, we are doing following assumptions:
+ * - when the user selects one row, all childs are also automatically
+ * selected ; visible childs are setup so that they are known as
+ * 'indirectly' selected
+ * - when a row is set as 'indirectly' selected, user cannot select
+ * nor unselect it (sort of readonly or mandatory implied selection)
+ * while the parent stays itself selected
+ */
+static gboolean
+filter_selection( GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, NactTreeIEditable *instance )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_filter_selection";
+ GList *selected_paths;
+ GtkTreeIter iter;
+ NAObject *object;
+
+ gtk_tree_model_get_iter( model, &iter, path );
+ gtk_tree_model_get( model, &iter, TREE_IEDITABLE_NAOBJECT_COLUMN, &object, -1 );
+ g_return_val_if_fail( object, FALSE );
+ g_return_val_if_fail( NA_IS_OBJECT_ID( object ), FALSE );
+ g_object_unref( object );
+
+ /* if there is not yet any selection, then anything is allowed
+ */
+ selected_paths = gtk_tree_selection_get_selected_rows( selection, NULL );
+ if( !selected_paths || !g_list_length( selected_paths )){
+ /*g_debug( "%s: current selection is empty: allowing this one", thisfn );*/
+ filter_selection_set_implicitely_selected_childs( object, !path_currently_selected );
+ return( TRUE );
+ }
+
+ /* if the object at the row is already 'implicitely' selected, i.e.
+ * selected because of the selection of one of its parents, then
+ * nothing is allowed
+ */
+ if( filter_selection_is_implicitely_selected( object )){
+ g_debug( "%s: implicitely selected item: selection not allowed", thisfn );
+ return( FALSE );
+ }
+
+ /* object at the row is not 'implicitely' selected: we may so select
+ * or unselect it while the selection stays homogeneous
+ * (rather we set its childs to the corresponding implied status)
+ */
+ if( path_currently_selected ||
+ filter_selection_is_homogeneous( selection, object )){
+
+ filter_selection_set_implicitely_selected_childs( object, !path_currently_selected );
+ }
+ return( TRUE );
+}
+
+/*
+ * does the selection stay homogeneous when adding this object ?
+ */
+static gboolean
+filter_selection_is_homogeneous( GtkTreeSelection *selection, NAObject *object )
+{
+ gboolean homogeneous;
+
+ if( filter_selection_has_menu_or_action( selection )){
+ homogeneous = !NA_IS_OBJECT_PROFILE( object );
+ } else {
+ homogeneous = NA_IS_OBJECT_PROFILE( object );
+ }
+
+ return( homogeneous );
+}
+
+static gboolean
+filter_selection_has_menu_or_action( GtkTreeSelection *selection )
+{
+ gboolean has_menu_or_action;
+ SelectionIter *str;
+
+ has_menu_or_action = FALSE;
+ str = g_new0( SelectionIter, 1 );
+ str->has_menu_or_action = has_menu_or_action;
+ gtk_tree_selection_selected_foreach( selection, ( GtkTreeSelectionForeachFunc ) filter_selection_iter, str );
+ has_menu_or_action = str->has_menu_or_action;
+ g_free( str );
+
+ return( has_menu_or_action );
+}
+
+static void
+filter_selection_iter( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, SelectionIter *str )
+{
+ NAObject *object;
+
+ gtk_tree_model_get( model, iter, TREE_IEDITABLE_NAOBJECT_COLUMN, &object, -1 );
+
+ if( NA_IS_OBJECT_ITEM( object )){
+ str->has_menu_or_action = TRUE;
+ }
+
+ g_object_unref( object );
+}
+
+static gboolean
+filter_selection_is_implicitely_selected( NAObject *object )
+{
+ gboolean selected;
+
+ selected = ( gboolean ) GPOINTER_TO_UINT( g_object_get_data( G_OBJECT( object), "nact-implicit-selection" ));
+
+ return( selected );
+}
+
+/*
+ * the object is being selected (resp. unselected)
+ * recursively set the 'implicit selection' flag for all its childs
+ */
+static void
+filter_selection_set_implicitely_selected_childs( NAObject *object, gboolean select )
+{
+ GList *childs, *ic;
+
+ if( NA_IS_OBJECT_ITEM( object )){
+ childs = na_object_get_items( object );
+ for( ic = childs ; ic ; ic = ic->next ){
+ g_object_set_data( G_OBJECT( ic->data ), "nact-implicit-selection", GUINT_TO_POINTER(( guint ) select ));
+ filter_selection_set_implicitely_selected_childs( NA_OBJECT( ic->data ), select );
+ }
+ }
+}
+
+static gboolean
+have_dnd_mode( NactTreeIEditable *instance, TreeIEditableInstanceData *ialid )
+{
+ gboolean have_dnd;
+
+ have_dnd = ( ialid->management_mode == TREE_IEDITABLE_MANAGEMENT_MODE_EDITION );
+
+ return( have_dnd );
+}
+
+static gboolean
+have_filter_selection_mode( NactTreeIEditable *instance, TreeIEditableInstanceData *ialid )
+{
+ gboolean have_filter;
+
+ have_filter = ( ialid->management_mode == TREE_IEDITABLE_MANAGEMENT_MODE_EDITION );
+
+ return( have_filter );
+}
+
+/*
+ * triggered by 'F2' key
+ * only in edition mode
+ */
+static void
+inline_edition( NactTreeIEditable *instance )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_inline_edition";
+ TreeIEditableInstanceData *ialid;
+ GtkTreeView *treeview;
+ GtkTreeSelection *selection;
+ GList *listrows;
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
+
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+ if( ialid->management_mode == TREE_IEDITABLE_MANAGEMENT_MODE_EDITION ){
+
+ ialid->selection_changed_allowed = FALSE;
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ selection = gtk_tree_view_get_selection( treeview );
+ listrows = gtk_tree_selection_get_selected_rows( selection, NULL );
+
+ if( g_list_length( listrows ) == 1 ){
+ path = ( GtkTreePath * ) listrows->data;
+ column = gtk_tree_view_get_column( treeview, TREE_IEDITABLE_LABEL_COLUMN );
+ gtk_tree_view_set_cursor( treeview, path, column, TRUE );
+ }
+
+ g_list_foreach( listrows, ( GFunc ) gtk_tree_path_free, NULL );
+ g_list_free( listrows );
+
+ ialid->selection_changed_allowed = TRUE;
+ }
+}
+
+static gboolean
+is_iduplicable_proxy( NactTreeIEditable *instance, TreeIEditableInstanceData *ialid )
+{
+ gboolean is_proxy;
+
+ is_proxy = ( ialid->management_mode == TREE_IEDITABLE_MANAGEMENT_MODE_EDITION );
+ g_debug( "nact_tree_ieditable_is_iduplicable_proxy: is_proxy=%s", is_proxy ? "True":"False" );
+
+ return( is_proxy );
+}
+
+static gboolean
+on_button_press_event( GtkWidget *widget, GdkEventButton *event, NactTreeIEditable *instance )
+{
+ /*static const gchar *thisfn = "nact_tree_ieditable_v_on_button_pres_event";
+ g_debug( "%s: widget=%p, event=%p, user_data=%p", thisfn, widget, event, user_data );*/
+
+ gboolean stop = FALSE;
+
+ /* double-click of left button */
+ if( event->type == GDK_2BUTTON_PRESS && event->button == 1 ){
+ nact_tree_ieditable_bis_toggle_collapse( instance );
+ stop = TRUE;
+ }
+
+ /* single click on right button */
+ if( event->type == GDK_BUTTON_PRESS && event->button == 3 ){
+ open_popup( instance, event );
+ stop = TRUE;
+ }
+
+ return( stop );
+}
+
+static void
+on_edition_status_changed( NactTreeIEditable *instance, NAIDuplicable *object )
+{
+ GtkTreeView *treeview;
+ NactTreeModel *model;
+ TreeIEditableInstanceData *ialid;
+
+ ialid = nact_tree_ieditable_priv_get_instance_data( instance );
+
+ g_debug( "nact_tree_ieditable_on_edition_status_changed: instance=%p, object=%p (%s)",
+ ( void * ) instance,
+ ( void * ) object, G_OBJECT_TYPE_NAME( object ));
+
+ g_return_if_fail( NA_IS_OBJECT( object ));
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ nact_tree_model_display( model, NA_OBJECT( object ));
+
+ if( na_object_is_modified( object )){
+ if( !g_list_find( ialid->modified_items, object )){
+ ialid->modified_items = g_list_prepend( ialid->modified_items, object );
+ }
+ } else {
+ ialid->modified_items = nact_tree_ieditable_remove_rec( ialid->modified_items, NA_OBJECT( object ));
+ }
+
+ /* do not send status-changed signal while filling the tree
+ */
+ if( ialid->selection_changed_allowed ){
+ g_signal_emit_by_name( instance, TREE_IEDITABLE_SIGNAL_STATUS_CHANGED, NULL );
+ }
+}
+
+/*
+ * focus is monitored to avoid an accelerator being pressed while on a tab
+ * triggers an unwaited operation on the list
+ * e.g. when editing an entry field on the tab, pressing Del should _not_
+ * delete current row in the list !
+ */
+static gboolean
+on_focus_in( GtkWidget *widget, GdkEventFocus *event, NactTreeIEditable *instance )
+{
+ /*static const gchar *thisfn = "nact_tree_ieditable_on_focus_in";*/
+ gboolean stop = FALSE;
+
+ /*g_debug( "%s: widget=%p, event=%p, instance=%p", thisfn, ( void * ) widget, ( void * ) event, ( void * ) instance );*/
+ g_signal_emit_by_name( instance, TREE_IEDITABLE_SIGNAL_FOCUS_IN, instance );
+
+ return( stop );
+}
+
+static gboolean
+on_focus_out( GtkWidget *widget, GdkEventFocus *event, NactTreeIEditable *instance )
+{
+ /*static const gchar *thisfn = "nact_tree_ieditable_on_focus_out";*/
+ gboolean stop = FALSE;
+
+ /*g_debug( "%s: widget=%p, event=%p, instance=%p", thisfn, ( void * ) widget, ( void * ) event, ( void * ) instance );*/
+ g_signal_emit_by_name( instance, TREE_IEDITABLE_SIGNAL_FOCUS_OUT, instance );
+
+ return( stop );
+}
+
+static gboolean
+on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, NactTreeIEditable *instance )
+{
+ /*static const gchar *thisfn = "nact_tree_ieditable_v_on_key_pressed_event";
+ g_debug( "%s: widget=%p, event=%p, user_data=%p", thisfn, widget, event, user_data );*/
+ gboolean stop = FALSE;
+
+ if( event->keyval == NACT_KEY_Return || event->keyval == NACT_KEY_KP_Enter ){
+ nact_tree_ieditable_bis_toggle_collapse( instance );
+ stop = TRUE;
+ }
+
+ if( event->keyval == NACT_KEY_F2 ){
+ inline_edition( instance );
+ stop = TRUE;
+ }
+
+ if( event->keyval == NACT_KEY_Right ){
+ nact_tree_ieditable_bis_expand_to_first_child( instance );
+ stop = TRUE;
+ }
+
+ if( event->keyval == NACT_KEY_Left ){
+ nact_tree_ieditable_bis_collapse_to_parent( instance );
+ 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
+ * this will trigger set the object content, and other updates
+ */
+static void
+on_label_edited( GtkCellRendererText *renderer, const gchar *path_str, const gchar *text, NactTreeIEditable *instance )
+{
+ GtkTreeView *treeview;
+ NactTreeModel *model;
+ NAObject *object;
+ GtkTreePath *path;
+ gchar *new_text;
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+ path = gtk_tree_path_new_from_string( path_str );
+ object = nact_tree_model_object_at_path( model, path );
+ new_text = g_strdup( text );
+
+ g_signal_emit_by_name( instance, TREE_IEDITABLE_SIGNAL_COLUMN_EDITED, object, new_text, TREE_IEDITABLE_LABEL_COLUMN );
+}
+
+/*
+ * an item has been updated in one of the tabs
+ * update the treeview to reflects its new edition status
+ */
+static void
+on_tab_updatable_item_updated( NactTreeIEditable *instance, NAObject *object, gboolean force_display )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_on_tab_updatable_item_updated";
+ GtkTreeView *treeview;
+ GtkTreeModel *model;
+
+ g_debug( "%s: instance=%p, object=%p (%s), force_display=%s", thisfn,
+ ( void * ) instance, ( void * ) object, G_OBJECT_TYPE_NAME( object ),
+ force_display ? "True":"False" );
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+ g_return_if_fail( NA_IS_OBJECT( object ));
+ g_return_if_fail( NA_IS_IDUPLICABLE( object ));
+
+ if( object ){
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+ model = gtk_tree_view_get_model( treeview );
+ if( !na_object_check_status_up( object ) && force_display ){
+ on_edition_status_changed( instance, NA_IDUPLICABLE( object ));
+ }
+ }
+}
+
+static void
+open_popup( NactTreeIEditable *instance, GdkEventButton *event )
+{
+ GtkTreeView *treeview;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+
+ treeview = nact_tree_ieditable_priv_get_actions_list_treeview( instance );
+
+ if( gtk_tree_view_get_path_at_pos( treeview, event->x, event->y, &path, NULL, NULL, NULL )){
+ model = gtk_tree_view_get_model( treeview );
+ nact_tree_ieditable_bis_select_row_at_path( instance, treeview, model, path );
+ gtk_tree_path_free( path );
+ nact_menubar_open_popup( BASE_WINDOW( instance ), event );
+ }
+}
+#endif
diff --git a/src/nact/nact-tree-ieditable.h b/src/nact/nact-tree-ieditable.h
new file mode 100644
index 0000000..066f61e
--- /dev/null
+++ b/src/nact/nact-tree-ieditable.h
@@ -0,0 +1,118 @@
+/*
+ * Nautilus-Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
+ *
+ * This Program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifndef __NACT_TREE_TREE_IEDITABLE_H__
+#define __NACT_TREE_TREE_IEDITABLE_H__
+
+/**
+ * SECTION: nact-tree_ieditable
+ * @title: NactTreeIEditable
+ * @short_description: The NactTreeIEditable interface definition
+ * @include: nact-tree_ieditable.h
+ *
+ * This interface is to be implemented by a NactTreeView which would
+ * want get edition features, such as inline edition, insert, delete,
+ * and so on.
+ *
+ * NactTreeIEditable maintains the count of modified items.
+ * Starting with zero when the tree view is filled up, it is incremented
+ * each time an item is modified, inserted or deleted.
+ * The modified count is fully recomputed after a save.
+ */
+
+#include "nact-tree-view.h"
+
+G_BEGIN_DECLS
+
+#define NACT_TREE_IEDITABLE_TYPE ( nact_tree_ieditable_get_type())
+#define NACT_TREE_IEDITABLE( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NACT_TREE_IEDITABLE_TYPE, NactTreeIEditable ))
+#define NACT_IS_TREE_IEDITABLE( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NACT_TREE_IEDITABLE_TYPE ))
+#define NACT_TREE_IEDITABLE_GET_INTERFACE( instance ) ( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NACT_TREE_IEDITABLE_TYPE, NactTreeIEditableInterface ))
+
+typedef struct _NactTreeIEditable NactTreeIEditable;
+typedef struct _NactTreeIEditableInterfacePrivate NactTreeIEditableInterfacePrivate;
+
+typedef struct {
+ /*< private >*/
+ GTypeInterface parent;
+ NactTreeIEditableInterfacePrivate *private;
+}
+ NactTreeIEditableInterface;
+
+GType nact_tree_ieditable_get_type( void );
+
+void nact_tree_ieditable_on_view_constructed( NactTreeView *view, BaseWindow *window );
+
+#if 0
+/* signals
+ */
+#define TREE_IEDITABLE_SIGNAL_LIST_COUNT_UPDATED "nact-iactions-list-count-updated"
+#define TREE_IEDITABLE_SIGNAL_FOCUS_IN "nact-iactions-list-focus-in"
+#define TREE_IEDITABLE_SIGNAL_FOCUS_OUT "nact-iactions-list-focus-out"
+#define TREE_IEDITABLE_SIGNAL_COLUMN_EDITED "nact-iactions-list-column-edited"
+#define TREE_IEDITABLE_SIGNAL_STATUS_CHANGED "nact-iactions-list-status-changed"
+
+void nact_tree_ieditable_initial_load_toplevel( NactTreeIEditable *instance );
+void nact_tree_ieditable_runtime_init_toplevel( NactTreeIEditable *instance, GList *actions );
+void nact_tree_ieditable_all_widgets_showed( NactTreeIEditable *instance );
+void nact_tree_ieditable_dispose( NactTreeIEditable *instance );
+
+void nact_tree_ieditable_brief_tree_dump( NactTreeIEditable *instance );
+void nact_tree_ieditable_collapse_all( NactTreeIEditable *instance );
+void nact_tree_ieditable_display_order_change( NactTreeIEditable *instance, gint order_mode );
+void nact_tree_ieditable_expand_all( NactTreeIEditable *instance );
+void nact_tree_ieditable_fill( NactTreeIEditable *instance, GList *items );
+gint nact_tree_ieditable_get_management_mode( NactTreeIEditable *instance );
+gboolean nact_tree_ieditable_has_modified_items( NactTreeIEditable *instance );
+void nact_tree_ieditable_on_treeview_selection_changed( GtkTreeSelection *selection, NactTreeIEditable *instance );
+GList *nact_tree_ieditable_remove_rec( GList *list, NAObject *object );
+void nact_tree_ieditable_set_management_mode( NactTreeIEditable *instance, gint mode );
+
+void nact_tree_ieditable_bis_clear_selection( NactTreeIEditable *instance, GtkTreeView *treeview );
+void nact_tree_ieditable_bis_collapse_to_parent( NactTreeIEditable *instance );
+void nact_tree_ieditable_bis_delete( NactTreeIEditable *instance, GList *items, gboolean select_at_end );
+void nact_tree_ieditable_bis_expand_to_first_child( NactTreeIEditable *instance );
+NAObject *nact_tree_ieditable_bis_get_item( NactTreeIEditable *instance, const gchar *id );
+GList *nact_tree_ieditable_bis_get_items( NactTreeIEditable *instance );
+GList *nact_tree_ieditable_bis_get_selected_items( NactTreeIEditable *instance );
+void nact_tree_ieditable_bis_insert_at_path( NactTreeIEditable *instance, GList *items, GtkTreePath *path );
+void nact_tree_ieditable_bis_insert_items( NactTreeIEditable *instance, GList *items, NAObject *sibling );
+void nact_tree_ieditable_bis_insert_into( NactTreeIEditable *instance, GList *items );
+void nact_tree_ieditable_bis_list_modified_items( NactTreeIEditable *instance );
+void nact_tree_ieditable_bis_remove_modified( NactTreeIEditable *instance, const NAObjectItem *item );
+void nact_tree_ieditable_bis_select_first_row( NactTreeIEditable *instance );
+void nact_tree_ieditable_bis_select_row_at_path( NactTreeIEditable *instance, GtkTreeView *treeview, GtkTreeModel *model, GtkTreePath *path );
+void nact_tree_ieditable_bis_toggle_collapse( NactTreeIEditable *instance );
+void nact_tree_ieditable_bis_toggle_collapse_object( NactTreeIEditable *instance, const NAObject *item );
+#endif
+
+G_END_DECLS
+
+#endif /* __NACT_TREE_TREE_IEDITABLE_H__ */
diff --git a/src/nact/nact-tree-model-dnd.c b/src/nact/nact-tree-model-dnd.c
index 1857cf6..95e80d7 100644
--- a/src/nact/nact-tree-model-dnd.c
+++ b/src/nact/nact-tree-model-dnd.c
@@ -45,11 +45,9 @@
#include "nact-application.h"
#include "nact-clipboard.h"
-#include "nact-iactions-list.h"
#include "nact-main-statusbar.h"
#include "nact-main-window.h"
#include "nact-tree-model.h"
-#include "nact-tree-model-dnd.h"
#include "nact-tree-model-priv.h"
/*
@@ -623,7 +621,9 @@ drop_inside( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData *selecti
} else {
inserted = na_object_ref( current );
deletable = g_list_prepend( NULL, inserted );
+#if 0
nact_iactions_list_bis_delete( NACT_IACTIONS_LIST( main_window ), deletable, FALSE );
+#endif
g_list_free( deletable );
}
@@ -637,7 +637,9 @@ drop_inside( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData *selecti
}
object_list = g_list_reverse( object_list );
+#if 0
nact_iactions_list_bis_insert_at_path( NACT_IACTIONS_LIST( main_window ), object_list, new_dest );
+#endif
if( gtk_tree_path_get_depth( new_dest ) == 1 ){
g_signal_emit_by_name( main_window, MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED, GINT_TO_POINTER( TRUE ));
@@ -957,8 +959,10 @@ drop_uri_list( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData *selec
drop_done = TRUE;
}
+#if 0
nact_iactions_list_bis_insert_at_path( NACT_IACTIONS_LIST( main_window ), imported, dest );
nact_tree_model_dump( model );
+#endif
na_object_free_items( imported );
na_core_utils_slist_free( parms.uris );
@@ -974,8 +978,11 @@ drop_uri_list( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData *selec
static NAObjectItem *
is_dropped_already_exists( const NAObjectItem *importing, const NactMainWindow *window )
{
+ NactTreeView *items_view;
+
gchar *id = na_object_get_id( importing );
- NAObjectItem *exists = nact_main_window_get_item( window, id );
+ items_view = nact_main_window_get_items_view( window );
+ NAObjectItem *exists = nact_tree_view_get_item_by_id( items_view, id );
g_free( id );
return( exists );
diff --git a/src/nact/nact-tree-model-priv.h b/src/nact/nact-tree-model-priv.h
index a66223d..e5eac59 100644
--- a/src/nact/nact-tree-model-priv.h
+++ b/src/nact/nact-tree-model-priv.h
@@ -38,6 +38,7 @@
#define __NACT_TREE_MODEL_PRIV_H__
#include "base-window.h"
+#include "egg-tree-multi-dnd.h"
#include "nact-clipboard.h"
G_BEGIN_DECLS
@@ -46,18 +47,46 @@ G_BEGIN_DECLS
*/
struct _NactTreeModelPrivate {
gboolean dispose_has_run;
+
+ /* data set at instanciation time
+ */
BaseWindow *window;
GtkTreeView *treeview;
- gboolean have_dnd;
- gboolean are_profiles_displayed;
+ guint mode;
NactClipboard *clipboard;
+
+ /* runtime data
+ */
gboolean drag_has_profiles;
gboolean drag_highlight; /* defined for on_drag_motion handler */
gboolean drag_drop; /* defined for on_drag_motion handler */
};
+/* the NactTreeModel is attached to the BaseWindow which embeds the NactTreeView
+ */
+#define WINDOW_DATA_TREE_MODEL "window-data-tree-model"
+
+#define WINDOW_MODEL_VOID( window ) \
+ g_return_if_fail( BASE_IS_WINDOW( window )); \
+ NactTreeModel *model = ( NactTreeModel * ) g_object_get_data( G_OBJECT( window ), WINDOW_DATA_TREE_MODEL ); \
+ g_return_if_fail( NACT_IS_TREE_MODEL( model ));
+
#define TREE_MODEL_STATUSBAR_CONTEXT "nact-tree-model-statusbar-context"
+gboolean nact_tree_model_dnd_idrag_dest_drag_data_received( GtkTreeDragDest *drag_dest, GtkTreePath *dest, GtkSelectionData *selection_data );
+gboolean nact_tree_model_dnd_idrag_dest_row_drop_possible( GtkTreeDragDest *drag_dest, GtkTreePath *dest_path, GtkSelectionData *selection_data );
+
+gboolean nact_tree_model_dnd_imulti_drag_source_drag_data_get( EggTreeMultiDragSource *drag_source, GdkDragContext *context, GtkSelectionData *selection_data, GList *path_list, guint info );
+gboolean nact_tree_model_dnd_imulti_drag_source_drag_data_delete( EggTreeMultiDragSource *drag_source, GList *path_list );
+GdkDragAction nact_tree_model_dnd_imulti_drag_source_get_drag_actions( EggTreeMultiDragSource *drag_source );
+GtkTargetList *nact_tree_model_dnd_imulti_drag_source_get_format_list( EggTreeMultiDragSource *drag_source );
+gboolean nact_tree_model_dnd_imulti_drag_source_row_draggable( EggTreeMultiDragSource *drag_source, GList *path_list );
+
+void nact_tree_model_dnd_on_drag_begin( GtkWidget *widget, GdkDragContext *context, BaseWindow *window );
+/*gboolean on_drag_motion( GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, BaseWindow *window );*/
+/*gboolean on_drag_drop( GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, BaseWindow *window );*/
+void nact_tree_model_dnd_on_drag_end( GtkWidget *widget, GdkDragContext *context, BaseWindow *window );
+
G_END_DECLS
#endif /* __NACT_TREE_MODEL_PRIV_H__ */
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index b389773..57b69a2 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -41,9 +41,7 @@
#include "nact-application.h"
#include "nact-clipboard.h"
#include "base-gtk-utils.h"
-#include "nact-iactions-list.h"
#include "nact-tree-model.h"
-#include "nact-tree-model-dnd.h"
#include "nact-tree-model-priv.h"
/* private class data
@@ -62,15 +60,25 @@ typedef struct {
}
ntmSearchStruct;
-/* search for an object identified by its id, setting the iter if found
+/* getting the list of items
+ * - mode is the indicator of the wished content
+ * - list is the returned list
*/
typedef struct {
- GtkTreeModel *store;
- gchar *id;
- gboolean found;
- GtkTreeIter *iter;
+ guint mode;
+ GList *items;
+}
+ ntmGetItems;
+
+/* when iterating while searching for an object
+ * setting the iter if found
+ */
+typedef struct {
+ gchar *id;
+ NAObject *object;
+ GtkTreeIter *iter;
}
- ntmSearchIdStruct;
+ ntmFindObject;
/* dump the content of the tree
*/
@@ -94,27 +102,31 @@ static void class_init( NactTreeModelClass *klass );
static void imulti_drag_source_init( EggTreeMultiDragSourceIface *iface );
static void idrag_dest_init( GtkTreeDragDestIface *iface );
static void instance_init( GTypeInstance *instance, gpointer klass );
-static void instance_dispose( GObject *application );
-static void instance_finalize( GObject *application );
+static void instance_dispose( GObject *model );
+static void instance_finalize( GObject *model );
-static NactTreeModel *tree_model_new( BaseWindow *window, GtkTreeView *treeview );
+static void on_initialize_model( BaseWindow *window, gpointer user_data );
+static void dump( NactTreeModel *model );
static void append_item( GtkTreeStore *model, GtkTreeView *treeview, GtkTreeIter *parent, GtkTreeIter *iter, const NAObject *object );
static void display_item( GtkTreeStore *model, GtkTreeView *treeview, GtkTreeIter *iter, const NAObject *object );
+#if 0
static gboolean dump_store( NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmDumpStruct *ntm );
+#endif
static void fill_tree_store( GtkTreeStore *model, GtkTreeView *treeview, NAObject *object, GtkTreeIter *parent );
static gboolean filter_visible( GtkTreeModel *store, GtkTreeIter *iter, NactTreeModel *model );
-static gboolean get_items_iter( NactTreeModel *model, GtkTreePath *path, NAObject *object, GList **items );
-static void iter_on_store( NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *parent, FnIterOnStore fn, gpointer user_data );
-static gboolean iter_on_store_item( NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *iter, FnIterOnStore fn, gpointer user_data );
+static gboolean find_item_iter( NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmFindObject *nfo );
+static gboolean get_items_iter( const NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmGetItems *ngi );
+static void iter_on_store( const NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *parent, FnIterOnStore fn, gpointer user_data );
+static gboolean iter_on_store_item( const NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *iter, FnIterOnStore fn, gpointer user_data );
static void remove_if_exists( NactTreeModel *model, GtkTreeModel *store, const NAObject *object );
static gboolean remove_items( GtkTreeStore *store, GtkTreeIter *iter );
static gboolean search_for_object( NactTreeModel *model, GtkTreeModel *store, const NAObject *object, GtkTreeIter *iter );
static gboolean search_for_object_iter( NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmSearchStruct *ntm );
-static gboolean search_for_object_id( NactTreeModel *model, GtkTreeModel *store, const NAObject *object, GtkTreeIter *iter );
-static gboolean search_for_object_id_iter( NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmSearchIdStruct *ntm );
static gint sort_actions_list( GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data );
+static void on_finalizing_window( NactTreeModel *model, GObject *window );
+
GType
nact_tree_model_get_type( void )
{
@@ -234,19 +246,23 @@ instance_dispose( GObject *object )
{
static const gchar *thisfn = "nact_tree_model_instance_dispose";
NactTreeModel *self;
+ GtkTreeStore *ts_model;
g_return_if_fail( NACT_IS_TREE_MODEL( object ));
- g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
-
self = NACT_TREE_MODEL( object );
if( !self->private->dispose_has_run ){
+ g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
self->private->dispose_has_run = TRUE;
g_object_unref( self->private->clipboard );
+ ts_model = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( self )));
+ gtk_tree_store_clear( ts_model );
+ g_debug( "%s: tree store cleared", thisfn );
+
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
G_OBJECT_CLASS( st_parent_class )->dispose( object );
@@ -274,19 +290,20 @@ instance_finalize( GObject *object )
}
}
-/*
- * tree_model_new:
- * @window: a #BaseWindow window which must implement #NactIActionsList
- * interface.
+/**
+ * nact_tree_model_new:
+ * @window: a #BaseWindow window which embeds our NactTreeView
* @treeview: the #GtkTreeView widget.
+ * @mode: management mode.
*
- * Creates a new #NactTreeModel model.
+ * Returns: a newly created NactTreeModel object, which will take
+ * care itself of its destroy by attaching a weak reference to the
+ * @window.
*
- * This function should be called at widget initial load time. Is is so
- * too soon to make any assumption about sorting in the tree view.
+ * The returned reference is owned by the #GtkTreeView.
*/
-static NactTreeModel *
-tree_model_new( BaseWindow *window, GtkTreeView *treeview )
+NactTreeModel *
+nact_tree_model_new( BaseWindow *window, GtkTreeView *treeview, NactTreeMode mode )
{
static const gchar *thisfn = "nact_tree_model_new";
GtkTreeStore *ts_model;
@@ -295,12 +312,13 @@ tree_model_new( BaseWindow *window, GtkTreeView *treeview )
NAUpdater *updater;
gint order_mode;
- g_debug( "%s: window=%p, treeview=%p", thisfn, ( void * ) window, ( void * ) treeview );
g_return_val_if_fail( BASE_IS_WINDOW( window ), NULL );
g_return_val_if_fail( GTK_IS_TREE_VIEW( treeview ), NULL );
+ g_debug( "%s: window=%p, treeview=%p, mode=%u", thisfn, ( void * ) window, ( void * ) treeview, mode );
+
ts_model = gtk_tree_store_new(
- IACTIONS_LIST_N_COLUMN, GDK_TYPE_PIXBUF, G_TYPE_STRING, NA_OBJECT_TYPE );
+ TREE_N_COLUMN, GDK_TYPE_PIXBUF, G_TYPE_STRING, NA_OBJECT_TYPE );
/* create the filter model
*/
@@ -316,47 +334,32 @@ tree_model_new( BaseWindow *window, GtkTreeView *treeview )
order_mode = na_iprefs_get_order_mode( NA_PIVOT( updater ), NULL );
nact_tree_model_display_order_change( model, order_mode );
+ /* setup instanciation time data
+ */
model->private->window = window;
model->private->treeview = treeview;
+ model->private->mode = mode;
model->private->clipboard = nact_clipboard_new( window );
- return( model );
-}
-
-/**
- * nact_tree_model_initial_load:
- * @window: the #BaseWindow window.
- * @widget: the #GtkTreeView which will implement the #NactTreeModel.
- *
- * Creates a #NactTreeModel, and attaches it to the treeview.
- *
- * Please note that we cannot make any assumption here whether the
- * treeview, and so the tree model, must or not implement the drag and
- * drop interfaces.
- * This is because #NactIActionsList::on_initial_load() initializes these
- * properties to %FALSE. The actual values will be set by the main
- * program between #NactIActionsList::on_initial_load() returns and call
- * to #NactIActionsList::on_runtime_init().
- */
-void
-nact_tree_model_initial_load( BaseWindow *window, GtkTreeView *treeview )
-{
- static const gchar *thisfn = "nact_tree_model_initial_load";
- NactTreeModel *model;
+ /* connect to some signal of interest
+ */
+ base_window_signal_connect( window,
+ G_OBJECT( window ), BASE_SIGNAL_INITIALIZE_WINDOW, G_CALLBACK( on_initialize_model ));
- g_debug( "%s: window=%p, treeview=%p", thisfn, ( void * ) window, ( void * ) treeview );
- g_return_if_fail( BASE_IS_WINDOW( window ));
- g_return_if_fail( GTK_IS_TREE_VIEW( treeview ));
+ g_object_set_data( G_OBJECT( window ), WINDOW_DATA_TREE_MODEL, model );
- model = tree_model_new( window, treeview );
+ g_object_weak_ref( G_OBJECT( window ), ( GWeakNotify ) on_finalizing_window, model );
+ /* attach the model to the tree view
+ */
gtk_tree_view_set_model( treeview, GTK_TREE_MODEL( model ));
-
g_object_unref( model );
+
+ return( model );
}
-/**
- * nact_tree_model_runtime_init:
+/*
+ * on_initialize_model:
* @model: this #NactTreeModel instance.
* @have_dnd: whether the tree model must implement drag and drop
* interfaces.
@@ -369,75 +372,60 @@ nact_tree_model_initial_load( BaseWindow *window, GtkTreeView *treeview )
* - from treeview to the outside world (e.g. Nautilus) to export actions
* - from outside world (e.g. Nautilus) to import actions
*/
-void
-nact_tree_model_runtime_init( NactTreeModel *model, gboolean have_dnd )
+static void
+on_initialize_model( BaseWindow *window, gpointer user_data )
{
- static const gchar *thisfn = "nact_tree_model_runtime_init";
+ static const gchar *thisfn = "nact_tree_model_on_initialize_model";
- g_debug( "%s: model=%p, have_dnd=%s", thisfn, ( void * ) model, have_dnd ? "True":"False" );
- g_return_if_fail( NACT_IS_TREE_MODEL( model ));
+ WINDOW_MODEL_VOID( window );
+
+ g_debug( "%s: window=%p (%s), user_data=%p, model=%p (%s)",
+ thisfn, ( void * ) window, G_OBJECT_TYPE_NAME( window ),
+ ( void * ) user_data, ( void * ) model, G_OBJECT_TYPE_NAME( model ));
if( !model->private->dispose_has_run ){
- if( have_dnd ){
+ if( model->private->mode == TREE_MODE_EDITION ){
- egg_tree_multi_drag_add_drag_support( EGG_TREE_MULTI_DRAG_SOURCE( model ), model->private->treeview );
+ egg_tree_multi_drag_add_drag_support(
+ EGG_TREE_MULTI_DRAG_SOURCE( model ), model->private->treeview );
- gtk_tree_view_enable_model_drag_dest(
- model->private->treeview,
- tree_model_dnd_dest_formats,
- tree_model_dnd_dest_formats_count,
+ gtk_tree_view_enable_model_drag_dest( model->private->treeview,
+ tree_model_dnd_dest_formats, tree_model_dnd_dest_formats_count,
nact_tree_model_dnd_imulti_drag_source_get_drag_actions( EGG_TREE_MULTI_DRAG_SOURCE( model )));
- base_window_signal_connect(
- BASE_WINDOW( model->private->window ),
- G_OBJECT( model->private->treeview ),
- "drag-begin",
- G_CALLBACK( nact_tree_model_dnd_on_drag_begin ));
+ base_window_signal_connect( window,
+ G_OBJECT( model->private->treeview ), "drag-begin", G_CALLBACK( nact_tree_model_dnd_on_drag_begin ));
/* connect: implies that we have to do all hard stuff
* connect_after: no more triggers drag-drop signal
*/
- /*base_window_signal_connect_after(
- BASE_WINDOW( model->private->window ),
- G_OBJECT( model->private->treeview ),
- "drag-motion",
- G_CALLBACK( on_drag_motion ));*/
-
- /*base_window_signal_connect(
- BASE_WINDOW( model->private->window ),
- G_OBJECT( model->private->treeview ),
- "drag-drop",
- G_CALLBACK( on_drag_drop ));*/
-
- base_window_signal_connect(
- BASE_WINDOW( model->private->window ),
- G_OBJECT( model->private->treeview ),
- "drag-end",
- G_CALLBACK( nact_tree_model_dnd_on_drag_end ));
+ /*base_window_signal_connect_after( window,
+ G_OBJECT( model->private->treeview ), "drag-motion", G_CALLBACK( on_drag_motion ));*/
+
+ /*base_window_signal_connect( window,
+ G_OBJECT( model->private->treeview ), "drag-drop", G_CALLBACK( on_drag_drop ));*/
+
+ base_window_signal_connect( window,
+ G_OBJECT( model->private->treeview ), "drag-end", G_CALLBACK( nact_tree_model_dnd_on_drag_end ));
}
}
}
-void
-nact_tree_model_dispose( NactTreeModel *model )
+/*
+ * dump:
+ * @model: this #NactTreeModel instance.
+ *
+ * Briefly dumps the content of the tree.
+ */
+static void
+dump( NactTreeModel *model )
{
- static const gchar *thisfn = "nact_tree_model_dispose";
- GtkTreeStore *ts_model;
-
- g_debug( "%s: model=%p", thisfn, ( void * ) model );
- g_return_if_fail( NACT_IS_TREE_MODEL( model ));
-
- if( !model->private->dispose_has_run ){
-
- nact_tree_model_dump( model );
-
- ts_model = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
-
- gtk_tree_store_clear( ts_model );
+ GList *items;
- g_debug( "%s: end of tree store clear", thisfn );
- }
+ items = nact_tree_model_get_items( model, TREE_LIST_ALL );
+ na_object_dump_tree( items );
+ na_object_free_items( items );
}
/**
@@ -541,47 +529,11 @@ nact_tree_model_display_order_change( NactTreeModel *model, gint order_mode )
}
/**
- * nact_tree_model_dump:
- * @model: this #NactTreeModel instance.
- *
- * Briefly dumps the content of the tree.
- */
-void
-nact_tree_model_dump( NactTreeModel *model )
-{
- static const gchar *thisfn = "nact_tree_model_dump";
- GtkTreeStore *store;
- ntmDumpStruct *ntm;
-
- g_return_if_fail( NACT_IS_TREE_MODEL( model ));
-
- if( !model->private->dispose_has_run ){
-
- store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
-
- g_debug( "%s: %s at %p, %s at %p", thisfn,
- G_OBJECT_TYPE_NAME( model ), ( void * ) model, G_OBJECT_TYPE_NAME( store ), ( void * ) store );
-
- ntm = g_new0( ntmDumpStruct, 1 );
- ntm->fname = g_strdup( thisfn );
- ntm->prefix = g_strdup( "" );
-
- nact_tree_model_iter( model, ( FnIterOnStore ) dump_store, ntm );
-
- g_free( ntm->prefix );
- g_free( ntm->fname );
- g_free( ntm );
- }
-}
-
-/**
* nact_tree_model_fill:
* @model: this #NactTreeModel instance.
* @ŧreeview: the #GtkTreeView widget.
* @items: this list of items, usually from #NAPivot, which will be used
* to fill up the tree store.
- * @are_profiles_displayed: whether to show profiles (in edition mode),
- * or not (in export mode).
*
* Fill up the tree store with specified items.
*
@@ -590,7 +542,7 @@ nact_tree_model_dump( NactTreeModel *model )
* tree store, so that we are able to freely edit it.
*/
void
-nact_tree_model_fill( NactTreeModel *model, GList *items, gboolean are_profiles_displayed )
+nact_tree_model_fill( NactTreeModel *model, GList *items )
{
static const gchar *thisfn = "nact_tree_model_fill";
GtkTreeStore *ts_model;
@@ -599,15 +551,11 @@ nact_tree_model_fill( NactTreeModel *model, GList *items, gboolean are_profiles_
g_return_if_fail( NACT_IS_TREE_MODEL( model ));
- g_debug( "%s: model=%p, items=%p (%d items), are_profiles_displayed=%s",
- thisfn,
- ( void * ) model,
- ( void * ) items, g_list_length( items ),
- are_profiles_displayed ? "True":"False" );
+ g_debug( "%s: model=%p, items=%p (%d items)",
+ thisfn, ( void * ) model, ( void * ) items, g_list_length( items ));
if( !model->private->dispose_has_run ){
- model->private->are_profiles_displayed = are_profiles_displayed;
ts_model = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
gtk_tree_store_clear( ts_model );
@@ -621,26 +569,64 @@ nact_tree_model_fill( NactTreeModel *model, GList *items, gboolean are_profiles_
}
/**
+ * nact_tree_model_get_item_by_id:
+ * @model: this #NactTreeModel object.
+ * @id: the searched #NAObjectItem.
+ *
+ * Returns: a pointer on the searched #NAObjectItem if it exists, or %NULL.
+ *
+ * The returned pointer is owned by the underlying tree store, and should
+ * not be released by the caller.
+ */
+NAObjectItem *
+nact_tree_model_get_item_by_id( const NactTreeModel *model, const gchar *id )
+{
+ static const gchar *thisfn = "nact_tree_model_get_item_by_id";
+ GtkTreeStore *store;
+ ntmFindObject nfo;
+
+ g_return_val_if_fail( NACT_IS_TREE_MODEL( model ), NULL );
+
+ nfo.object = NULL;
+
+ if( !model->private->dispose_has_run ){
+ g_debug( "%s: model=%p, id=%s", thisfn, ( void * ) model, id );
+
+ nfo.id = ( gchar * ) id;
+ 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 ) find_item_iter, &nfo );
+ }
+
+ return(( NAObjectItem * ) nfo.object );
+}
+
+/**
* nact_tree_model_get_items:
* @model: this #NactTreeModel object.
+ * @mode: the content indicator for the returned list
*
* Returns: the content of the current store as a newly allocated list
* which should be na_object_free_items() by the caller.
*/
GList *
-nact_tree_model_get_items( NactTreeModel *model )
+nact_tree_model_get_items( const NactTreeModel *model, guint mode )
{
+ static const gchar *thisfn = "nact_tree_model_get_items";
GList *items;
GtkTreeStore *store;
+ ntmGetItems ngi;
g_return_val_if_fail( NACT_IS_TREE_MODEL( model ), NULL );
items = NULL;
if( !model->private->dispose_has_run ){
+ g_debug( "%s: model=%p, mode=%x", thisfn, ( void * ) model, mode );
+ ngi.mode = 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, &items );
+ iter_on_store( model, GTK_TREE_MODEL( store ), NULL, ( FnIterOnStore ) get_items_iter, &ngi );
}
return( items );
@@ -918,6 +904,7 @@ display_item( GtkTreeStore *model, GtkTreeView *treeview, GtkTreeIter *iter, con
}
}
+#if 0
static gboolean
dump_store( NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmDumpStruct *ntm )
{
@@ -948,6 +935,7 @@ dump_store( NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmDumpSt
/* don't stop iteration */
return( FALSE );
}
+#endif
static void
fill_tree_store( GtkTreeStore *model, GtkTreeView *treeview, NAObject *object, GtkTreeIter *parent )
@@ -986,7 +974,6 @@ filter_visible( GtkTreeModel *store, GtkTreeIter *iter, NactTreeModel *model )
/*static const gchar *thisfn = "nact_tree_model_filter_visible";*/
NAObject *object;
NAObjectAction *action;
- gboolean are_profiles_displayed;
gint count;
/*g_debug( "%s: model=%p, iter=%p, window=%p", thisfn, ( void * ) model, ( void * ) iter, ( void * ) window );*/
@@ -994,42 +981,65 @@ filter_visible( GtkTreeModel *store, GtkTreeIter *iter, NactTreeModel *model )
/* is a GtkTreeStore */
gtk_tree_model_get( store, iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
+ g_object_unref( object );
+ /*na_object_dump( object );*/
- if( object ){
- g_object_unref( object );
- /*na_object_dump( object );*/
+ /* an action or a menu
+ */
+ if( NA_IS_OBJECT_ITEM( object )){
+ return( TRUE );
+ }
- /* an action or a menu
- */
- if( NA_IS_OBJECT_ITEM( object )){
- return( TRUE );
- }
+ g_return_val_if_fail( NA_IS_OBJECT_PROFILE( object ), FALSE );
- g_return_val_if_fail( NA_IS_OBJECT_PROFILE( object ), FALSE );
- are_profiles_displayed = NACT_TREE_MODEL( model )->private->are_profiles_displayed;
+ if( NACT_TREE_MODEL( model )->private->mode != TREE_MODE_EDITION ){
+ return( FALSE );
+ }
- if( !are_profiles_displayed ){
- return( FALSE );
- }
+ action = NA_OBJECT_ACTION( na_object_get_parent( object ));
+ count = na_object_get_items_count( action );
+ /*g_debug( "action=%p: count=%d", ( void * ) action, count );*/
+ /*return( TRUE );*/
+ return( count > 1 );
+
+}
- action = NA_OBJECT_ACTION( na_object_get_parent( object ));
- count = na_object_get_items_count( action );
- /*g_debug( "action=%p: count=%d", ( void * ) action, count );*/
- /*return( TRUE );*/
- return( count > 1 );
+/*
+ * search for an object, given its id
+ */
+static gboolean
+find_item_iter( NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmFindObject *nfo )
+{
+ gchar *id;
+ gboolean found = FALSE;
+
+ if( NA_IS_OBJECT_ITEM( object )){
+ id = na_object_get_id( object );
+ found = ( g_ascii_strcasecmp( id, nfo->id ) == 0 );
+ g_free( id );
+
+ if( found ){
+ nfo->object = object;
+ }
}
- return( FALSE );
+ /* stop iteration if found */
+ return( found );
}
/*
- * builds the tree by iterating on the store
+ * Builds the tree by iterating on the store
+ * we may want selected, modified or both, or a combination of these modes
+ *
+ * This function is called from iter_on_store_item();
*/
static gboolean
-get_items_iter( NactTreeModel *model, GtkTreePath *path, NAObject *object, GList **items )
+get_items_iter( const NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmGetItems *ngi )
{
- if( gtk_tree_path_get_depth( path ) == 1 ){
- *items = g_list_prepend( *items, na_object_ref( object ));
+ if( ngi->mode == TREE_LIST_ALL ){
+ if( gtk_tree_path_get_depth( path ) == 1 ){
+ ngi->items = g_list_prepend( ngi->items, na_object_ref( object ));
+ }
}
/* don't stop iteration */
@@ -1037,13 +1047,14 @@ get_items_iter( NactTreeModel *model, GtkTreePath *path, NAObject *object, GList
}
static void
-iter_on_store( NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *parent, FnIterOnStore fn, gpointer user_data )
+iter_on_store( const NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *parent, FnIterOnStore fn, gpointer user_data )
{
GtkTreeIter iter;
gboolean stop;
if( gtk_tree_model_iter_children( store, &iter, parent )){
stop = iter_on_store_item( model, store, &iter, fn, user_data );
+
while( !stop && gtk_tree_model_iter_next( store, &iter )){
stop = iter_on_store_item( model, store, &iter, fn, user_data );
}
@@ -1051,7 +1062,7 @@ iter_on_store( NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *parent, F
}
static gboolean
-iter_on_store_item( NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *iter, FnIterOnStore fn, gpointer user_data )
+iter_on_store_item( const NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *iter, FnIterOnStore fn, gpointer user_data )
{
NAObject *object;
GtkTreePath *path;
@@ -1060,11 +1071,13 @@ iter_on_store_item( NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *iter
/* unreffing as soon as we got the pointer so that the ref count is
* unchanged in dump_store
*/
- gtk_tree_model_get( store, iter, IACTIONS_LIST_NAOBJECT_COLUMN, &object, -1 );
+ gtk_tree_model_get( store, iter, TREE_COLUMN_NAOBJECT, &object, -1 );
g_object_unref( object );
+ /*
g_debug( "nact_tree_model_iter_on_store_item: object=%p (%s, ref_count=%d)",
( void * ) object, G_OBJECT_TYPE_NAME( object ), G_OBJECT( object )->ref_count );
+ */
path = gtk_tree_model_get_path( store, iter );
stop = ( *fn )( model, path, object, user_data );
@@ -1084,14 +1097,24 @@ iter_on_store_item( NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *iter
static void
remove_if_exists( NactTreeModel *model, GtkTreeModel *store, const NAObject *object )
{
+ ntmFindObject nfo;
GtkTreeIter iter;
if( NA_IS_OBJECT_ITEM( object )){
- if( search_for_object_id( model, store, object, &iter )){
+
+ nfo.id = na_object_get_id( object );
+ nfo.object = NULL;
+ nfo.iter = &iter;
+
+ iter_on_store( model, store, NULL, ( FnIterOnStore ) find_item_iter, &nfo );
+
+ if( nfo.object ){
g_debug( "nact_tree_model_remove_if_exists: removing %s %p",
G_OBJECT_TYPE_NAME( object ), ( void * ) object );
- gtk_tree_store_remove( GTK_TREE_STORE( store ), &iter );
+ gtk_tree_store_remove( GTK_TREE_STORE( store ), nfo.iter );
}
+
+ g_free( nfo.id );
}
}
@@ -1150,50 +1173,6 @@ search_for_object_iter( NactTreeModel *model, GtkTreePath *path, NAObject *objec
return( ntm->found );
}
-static gboolean
-search_for_object_id( NactTreeModel *model, GtkTreeModel *store, const NAObject *object, GtkTreeIter *result_iter )
-{
- gboolean found = FALSE;
- ntmSearchIdStruct *ntm;
- GtkTreeIter iter;
-
- ntm = g_new0( ntmSearchIdStruct, 1 );
- ntm->store = store;
- ntm->id = na_object_get_id( object );
- ntm->found = FALSE;
- ntm->iter = &iter;
-
- iter_on_store( model, store, NULL, ( FnIterOnStore ) search_for_object_id_iter, ntm );
-
- if( ntm->found ){
- found = TRUE;
- memcpy( result_iter, ntm->iter, sizeof( GtkTreeIter ));
- }
-
- g_free( ntm->id );
- g_free( ntm );
- return( found );
-}
-
-static gboolean
-search_for_object_id_iter( NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmSearchIdStruct *ntm )
-{
- gchar *id;
-
- id = na_object_get_id( object );
-
- if( !g_ascii_strcasecmp( id, ntm->id )){
- if( gtk_tree_model_get_iter( ntm->store, ntm->iter, path )){
- ntm->found = TRUE;
- }
- }
-
- g_free( id );
-
- /* stop iteration when found */
- return( ntm->found );
-}
-
static gint
sort_actions_list( GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data )
{
@@ -1218,3 +1197,18 @@ sort_actions_list( GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer
/*g_debug( "%s: ret=%d", thisfn, ret );*/
return( ret );
}
+
+static void
+on_finalizing_window( NactTreeModel *model, GObject *window )
+{
+ static const gchar *thisfn = "nact_tree_model_on_finalizing_window";
+
+ g_return_if_fail( NACT_IS_TREE_MODEL( model ));
+
+ g_debug( "%s: model=%p (%s), window=%p",
+ thisfn, ( void * ) model, G_OBJECT_TYPE_NAME( model ), ( void * ) window );
+
+ dump( model );
+
+ g_object_unref( model );
+}
diff --git a/src/nact/nact-tree-model.h b/src/nact/nact-tree-model.h
index 68f4564..2089209 100644
--- a/src/nact/nact-tree-model.h
+++ b/src/nact/nact-tree-model.h
@@ -45,11 +45,9 @@
#ifndef __NACT_TREE_MODEL_H__
#define __NACT_TREE_MODEL_H__
-#include <gtk/gtk.h>
-
#include <api/na-object.h>
-#include "base-window.h"
+#include "nact-tree-view.h"
G_BEGIN_DECLS
@@ -87,26 +85,53 @@ enum {
IACTIONS_LIST_N_COLUMN
};
+/**
+ * Column ordering in the tree view
+ */
+enum {
+ TREE_COLUMN_ICON = 0,
+ TREE_COLUMN_LABEL,
+ TREE_COLUMN_NAOBJECT,
+ TREE_N_COLUMN
+};
+
+/**
+ * When getting a list of items; these indcators may be OR-ed.
+ */
+enum {
+ TREE_LIST_SELECTED = 1<<0,
+ TREE_LIST_MODIFIED = 1<<1,
+ TREE_LIST_ALL = 0xff,
+};
+
/* iter on tree store
*/
-typedef gboolean ( *FnIterOnStore )( NactTreeModel *, GtkTreePath *, NAObject *, gpointer );
+typedef gboolean ( *FnIterOnStore )( const NactTreeModel *, GtkTreePath *, NAObject *, gpointer );
+
+GType nact_tree_model_get_type( void );
-GType nact_tree_model_get_type( void );
+NactTreeModel *nact_tree_model_new( BaseWindow *window, GtkTreeView *view, NactTreeMode mode );
-void nact_tree_model_initial_load( BaseWindow *window, GtkTreeView *treeview );
-void nact_tree_model_runtime_init( NactTreeModel *model, gboolean have_dnd );
-void nact_tree_model_dispose( NactTreeModel *model );
+void nact_tree_model_fill( NactTreeModel *model, GList *items );
+
+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 );
+
+/* find an item
+ * get items (all, selected, modified)
+ * remove a list of items
+ * insert a list of items (here, inside)
+ */
+/* *** */
void nact_tree_model_display( NactTreeModel *model, NAObject *object );
void nact_tree_model_display_order_change( NactTreeModel *model, gint order_mode );
-void nact_tree_model_dump( NactTreeModel *model );
-void nact_tree_model_fill( NactTreeModel *model, GList *items, gboolean are_profiles_displayed );
-GList *nact_tree_model_get_items( NactTreeModel *model );
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 );
void nact_tree_model_iter( NactTreeModel *model, FnIterOnStore fn, gpointer user_data );
NAObject *nact_tree_model_object_at_path( NactTreeModel *model, GtkTreePath *path );
GtkTreePath *nact_tree_model_remove( NactTreeModel *model, NAObject *object );
+/* *** */
G_END_DECLS
diff --git a/src/nact/nact-tree-view.c b/src/nact/nact-tree-view.c
index 54f5539..d98b8a5 100644
--- a/src/nact/nact-tree-view.c
+++ b/src/nact/nact-tree-view.c
@@ -40,8 +40,6 @@
#include "nact-tree-view.h"
#include "nact-tree-model.h"
-#include "nact-iactions-list.h"
-
/* private class data
*/
struct _NactTreeViewClassPrivate {
@@ -51,19 +49,18 @@ struct _NactTreeViewClassPrivate {
/* private instance data
*/
struct _NactTreeViewPrivate {
- gboolean dispose_has_run;
+ gboolean dispose_has_run;
/* properties set at instanciation time
*/
- BaseWindow *window;
- gchar *widget_name;
- gboolean have_dnd;
- gboolean display_profiles;
+ BaseWindow *window;
+ gchar *widget_name;
+ guint mode;
/* runtime data
*/
- GtkTreeView *tree_view;
- gboolean notify_allowed;
+ GtkTreeView *tree_view;
+ gboolean notify_allowed;
};
/* instance properties
@@ -73,8 +70,7 @@ enum {
TREE_PROP_WINDOW_ID,
TREE_PROP_WIDGET_NAME_ID,
- TREE_PROP_HAVE_DND_ID,
- TREE_PROP_DISPLAY_PROFILES_ID,
+ TREE_PROP_MODE_ID,
TREE_PROP_N_PROPERTIES
};
@@ -83,6 +79,11 @@ enum {
*/
enum {
CONTENT_CHANGED,
+ CONTEXT_MENU,
+ COUNT_CHANGED,
+ FOCUS_IN,
+ FOCUS_OUT,
+ MODIFIED_COUNT,
SELECTION_CHANGED,
LAST_SIGNAL
};
@@ -129,6 +130,9 @@ static void instance_finalize( GObject *application );
static void on_base_initialize_gtk( BaseWindow *window, GtkWindow *toplevel, gpointer user_data );
static void on_base_initialize_view( BaseWindow *window, gpointer user_data );
static void on_base_all_widgets_showed( BaseWindow *window, gpointer user_data );
+static gboolean on_button_press_event( GtkWidget *widget, GdkEventButton *event, BaseWindow *window );
+static gboolean on_focus_in( GtkWidget *widget, GdkEventFocus *event, BaseWindow *window );
+static gboolean on_focus_out( GtkWidget *widget, GdkEventFocus *event, BaseWindow *window );
static gboolean on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseWindow *window );
static void on_treeview_selection_changed( GtkTreeSelection *selection, BaseWindow *window );
static void on_content_changed_cleanup_handler( BaseWindow *window, NactTreeView *view, NAObject *edited );
@@ -139,6 +143,7 @@ static GList *get_selected_items( NactTreeView *view );
static void iter_on_selection( NactTreeView *view, FnIterOnSelection fn_iter, gpointer user_data );
static void navigate_to_child( NactTreeView *view );
static void navigate_to_parent( NactTreeView *view );
+static void open_popup( BaseWindow *window, NactTreeView *view, GdkEventButton *event );
static void select_row_at_path( NactTreeView *view, GtkTreePath *path );
static void select_row_at_path_by_string( NactTreeView *view, const gchar *path );
static void toggle_collapse( NactTreeView *view );
@@ -215,21 +220,15 @@ class_init( NactTreeViewClass *klass )
"",
G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
- g_object_class_install_property( object_class, TREE_PROP_HAVE_DND_ID,
- g_param_spec_boolean(
- TREE_PROP_HAVE_DND,
- "Have DnD",
- "Whether Drag and Drop operations are implemented",
- FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
-
- g_object_class_install_property( object_class, TREE_PROP_DISPLAY_PROFILES_ID,
- g_param_spec_boolean(
- TREE_PROP_DISPLAY_PROFILES,
- "Display profiles",
- "Whether actions profiles are displayed",
- FALSE,
- G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
+ g_object_class_install_property( object_class, TREE_PROP_MODE_ID,
+ g_param_spec_uint(
+ TREE_PROP_MODE,
+ "Management mode",
+ "Management mode of the tree view, selection or edition",
+ 0,
+ TREE_MODE_N_MODES,
+ TREE_MODE_SELECTION,
+ G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE ));
/**
* NactTreeView::tree-signal-content-changed:
@@ -260,6 +259,147 @@ class_init( NactTreeViewClass *klass )
G_TYPE_POINTER, G_TYPE_POINTER );
/**
+ * NactTreeView::tree-signal-open-popup
+ *
+ * This signal is emitted on the BaseWindow parent when the user right
+ * clicks on the tree view.
+ *
+ * Signal args:
+ * - a pointer on the view
+ * - the GdkEvent.
+ *
+ * Handler prototype:
+ * void ( *handler )( BaseWindow *window, NactTreeView *view, GdkEvent *event, gpointer user_data );
+ */
+ st_signals[ CONTEXT_MENU ] = g_signal_new(
+ TREE_SIGNAL_CONTEXT_MENU,
+ G_TYPE_OBJECT,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ nact_cclosure_marshal_VOID__POINTER_POINTER,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER, G_TYPE_POINTER );
+
+ /**
+ * NactTreeView::tree-signal-count-changed:
+ *
+ * This signal is emitted on BaseWindow parent when the count of items
+ * has changed in the underlying tree store.
+ *
+ * Counting rows is needed to maintain action sensitivities in the
+ * menubar : at least 'Tools\Export' menu item depends if we have
+ * exportables, i.e. at least one menu or action.
+ * Also, the total count of menu/actions/profiles is displayed in the
+ * statusbar.
+ *
+ * Rows are first counted when the treeview is primarily filled, or
+ * refilled on demand. Counters are then incremented (resp. decremented)
+ * when inserting or pasting (resp. deleting) rows in the list.
+ *
+ * Signal args:
+ * - a pointer on the view
+ * - reset if %TRUE, add if %FALSE
+ * - menus count/increment (may be negative)
+ * - actions count/increment (may be negative)
+ * - profiles count/increment (may be negative)
+ *
+ * Handler prototype:
+ * void ( *handler )( BaseWindow *window, NactTreeView *view, gboolean reset,
+ * guint menus_count, guint actions_count, guint profiles_count, gpointer user_data );
+ */
+ st_signals[ COUNT_CHANGED ] = g_signal_new(
+ TREE_SIGNAL_COUNT_CHANGED,
+ G_TYPE_OBJECT,
+ G_SIGNAL_RUN_LAST,
+ 0, /* no default handler */
+ NULL,
+ NULL,
+ nact_cclosure_marshal_VOID__POINTER_BOOLEAN_INT_INT_INT,
+ G_TYPE_NONE,
+ 5,
+ G_TYPE_POINTER, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT );
+
+ /**
+ * NactTreeView::tree-signal-focus-in:
+ *
+ * This signal is emitted on the BaseWindow when the view gains the
+ * focus. In particular, edition menu is disabled outside of the treeview.
+ *
+ * Signal args:
+ * - a pointer on the view
+ *
+ * Handler prototype:
+ * void ( *handler )( BaseWindow *window, NactTreeView *view, gpointer user_data )
+ */
+ st_signals[ FOCUS_IN ] = g_signal_new(
+ TREE_SIGNAL_FOCUS_IN,
+ G_TYPE_OBJECT,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER );
+
+ /**
+ * NactTreeView::tree-signal-focus-out:
+ *
+ * This signal is emitted on the BaseWindow when the view loses the
+ * focus. In particular, edition menu is disabled outside of the treeview.
+ *
+ * Signal args:
+ * - a pointer on the view
+ *
+ * Handler prototype:
+ * void ( *handler )( BaseWindow *window, NactTreeView *view, gpointer user_data )
+ */
+ st_signals[ FOCUS_OUT ] = g_signal_new(
+ TREE_SIGNAL_FOCUS_OUT,
+ G_TYPE_OBJECT,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER );
+
+ /**
+ * NactTreeView::tree-signal-modified-count-changed:
+ *
+ * This signal is emitted on the BaseWindow when the view detects that
+ * the count of modified NAObjectItems has changed.
+ * The signal is actually emitted by the NactTreeIEditable interface
+ * which takes care of all edition features.
+ *
+ * Having the order of items at level zero changed counts for one.
+ *
+ * Signal args:
+ * - a pointer on the view
+ * - the new count of modified items
+ *
+ * Handler prototype:
+ * void ( *handler )( BaseWindow *window, NactTreeView *view, guint count, gpointer user_data )
+ */
+ st_signals[ MODIFIED_COUNT ] = g_signal_new(
+ TREE_SIGNAL_MODIFIED_COUNT_CHANGED,
+ G_TYPE_OBJECT,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ nact_cclosure_marshal_VOID__POINTER_INT,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_POINTER, G_TYPE_INT );
+
+ /**
* NactTreeView::tree-signal-selection-changed:
*
* This signal is emitted on the BaseWindow parent each time the selection
@@ -324,12 +464,8 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
g_value_set_string( value, self->private->widget_name );
break;
- case TREE_PROP_HAVE_DND_ID:
- g_value_set_boolean( value, self->private->have_dnd );
- break;
-
- case TREE_PROP_DISPLAY_PROFILES_ID:
- g_value_set_boolean( value, self->private->display_profiles );
+ case TREE_PROP_MODE_ID:
+ g_value_set_uint( value, self->private->mode );
break;
default:
@@ -359,12 +495,8 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
self->private->widget_name = g_value_dup_string( value );
break;
- case TREE_PROP_HAVE_DND_ID:
- self->private->have_dnd = g_value_get_boolean( value );
- break;
-
- case TREE_PROP_DISPLAY_PROFILES_ID:
- self->private->display_profiles = g_value_get_boolean( value );
+ case TREE_PROP_MODE_ID:
+ self->private->mode = g_value_get_uint( value );
break;
default:
@@ -411,7 +543,6 @@ instance_dispose( GObject *object )
{
static const gchar *thisfn = "nact_tree_view_instance_dispose";
NactTreeView *self;
- NactTreeModel *model;
g_return_if_fail( NACT_IS_TREE_VIEW( object ));
@@ -422,9 +553,6 @@ instance_dispose( GObject *object )
self->private->dispose_has_run = TRUE;
- model = NACT_TREE_MODEL( gtk_tree_view_get_model( self->private->tree_view ));
- nact_tree_model_dispose( model );
-
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->dispose ){
G_OBJECT_CLASS( st_parent_class )->dispose( object );
@@ -458,19 +586,21 @@ instance_finalize( GObject *instance )
* nact_tree_view_new:
* @window: the BaseWindow which embeds the tree view.
* @treeview_name: the GtkTreeView widget name.
+ * @mode: management mode.
*
* Returns: a newly allocated NactTreeView object, which will be owned
* by the caller. It is useless to unref it as it will automatically
* auto-destroys itself at @window finalization.
*/
NactTreeView *
-nact_tree_view_new( BaseWindow *window, const gchar *treeview_name )
+nact_tree_view_new( BaseWindow *window, const gchar *treeview_name, NactTreeMode mode )
{
NactTreeView *view;
view = g_object_new( NACT_TREE_VIEW_TYPE,
TREE_PROP_WINDOW, window,
TREE_PROP_WIDGET_NAME, treeview_name,
+ TREE_PROP_MODE, mode,
NULL );
return( view );
@@ -495,14 +625,12 @@ on_base_initialize_gtk( BaseWindow *window, GtkWindow *toplevel, gpointer user_d
if( !view->private->dispose_has_run ){
treeview = GTK_TREE_VIEW( base_window_get_widget( window, view->private->widget_name ));
+ nact_tree_model_new( window, treeview, view->private->mode );
/* associates the ItemsView to the label */
label = base_window_get_widget( window, "ActionsListLabel" );
gtk_label_set_mnemonic_widget( GTK_LABEL( label ), GTK_WIDGET( treeview ));
- nact_tree_model_initial_load( window, treeview );
- gtk_tree_view_set_enable_tree_lines( treeview, TRUE );
-
/* create visible columns on the tree view
*/
column = gtk_tree_view_column_new_with_attributes(
@@ -525,6 +653,10 @@ on_base_initialize_gtk( BaseWindow *window, GtkWindow *toplevel, gpointer user_d
*/
selection = gtk_tree_view_get_selection( treeview );
gtk_tree_selection_set_mode( selection, GTK_SELECTION_MULTIPLE );
+
+ /* misc properties
+ */
+ gtk_tree_view_set_enable_tree_lines( treeview, TRUE );
}
}
@@ -533,7 +665,6 @@ on_base_initialize_view( BaseWindow *window, gpointer user_data )
{
static const gchar *thisfn = "nact_tree_view_on_base_initialize_view";
GtkTreeView *treeview;
- NactTreeModel *model;
GtkTreeSelection *selection;
VIEW_WINDOW_VOID( window );
@@ -546,10 +677,7 @@ on_base_initialize_view( BaseWindow *window, gpointer user_data )
treeview = GTK_TREE_VIEW( base_window_get_widget( window, view->private->widget_name ));
view->private->tree_view = treeview;
- model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
- nact_tree_model_runtime_init( model, view->private->have_dnd );
-
- /* set up selection control */
+ /* monitors the selection */
selection = gtk_tree_view_get_selection( treeview );
base_window_signal_connect( window,
G_OBJECT( selection ), "changed", G_CALLBACK( on_treeview_selection_changed ));
@@ -557,6 +685,17 @@ on_base_initialize_view( BaseWindow *window, gpointer user_data )
/* expand/collapse with the keyboard */
base_window_signal_connect( window,
G_OBJECT( treeview ), "key-press-event", G_CALLBACK( on_key_pressed_event ));
+
+ /* monitors whether the focus is on the view */
+ base_window_signal_connect( window,
+ G_OBJECT( treeview ), "focus-in-event", G_CALLBACK( on_focus_in ));
+
+ base_window_signal_connect( window,
+ G_OBJECT( treeview ), "focus-out-event", G_CALLBACK( on_focus_out ));
+
+ /* monitors mouse events */
+ base_window_signal_connect( window,
+ G_OBJECT( treeview ), "button-press-event", G_CALLBACK( on_button_press_event ));
}
}
@@ -582,6 +721,52 @@ on_base_all_widgets_showed( BaseWindow *window, gpointer user_data )
}
static gboolean
+on_button_press_event( GtkWidget *widget, GdkEventButton *event, BaseWindow *window )
+{
+ gboolean stop = FALSE;
+
+ VIEW_WINDOW_VALUE( window, FALSE );
+
+ /* single click on right button */
+ if( event->type == GDK_BUTTON_PRESS && event->button == 3 ){
+ open_popup( window, view, event );
+ stop = TRUE;
+ }
+
+ return( stop );
+}
+
+/*
+ * focus is monitored to avoid an accelerator being pressed while on a tab
+ * triggers an unwaited operation on the list
+ * e.g. when editing an entry field on the tab, pressing Del should _not_
+ * delete current row in the list!
+ */
+static gboolean
+on_focus_in( GtkWidget *widget, GdkEventFocus *event, BaseWindow *window )
+{
+ gboolean stop = FALSE;
+
+ VIEW_WINDOW_VALUE( window, FALSE );
+
+ g_signal_emit_by_name( window, TREE_SIGNAL_FOCUS_IN, view );
+
+ return( stop );
+}
+
+static gboolean
+on_focus_out( GtkWidget *widget, GdkEventFocus *event, BaseWindow *window )
+{
+ gboolean stop = FALSE;
+
+ VIEW_WINDOW_VALUE( window, FALSE );
+
+ g_signal_emit_by_name( window, TREE_SIGNAL_FOCUS_OUT, view );
+
+ return( stop );
+}
+
+static gboolean
on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, BaseWindow *window )
{
gboolean stop = FALSE;
@@ -676,6 +861,7 @@ nact_tree_view_fill( NactTreeView *view, GList *items )
static const gchar *thisfn = "nact_tree_view_fill";
NactTreeModel *model;
gboolean prev;
+ gint nb_menus, nb_actions, nb_profiles;
g_return_if_fail( NACT_IS_TREE_VIEW( view ));
@@ -687,16 +873,86 @@ nact_tree_view_fill( NactTreeView *view, GList *items )
prev = view->private->notify_allowed;
view->private->notify_allowed = FALSE;
model = NACT_TREE_MODEL( gtk_tree_view_get_model( view->private->tree_view ));
- nact_tree_model_fill( model, items, view->private->display_profiles );
+ nact_tree_model_fill( model, items );
view->private->notify_allowed = prev;
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 );
}
+
+ select_row_at_path_by_string( view, "0" );
+ }
+}
+
+/**
+ * nact_tree_view_collapse_all:
+ * @view: this #NactTreeView instance.
+ *
+ * Collapse all the tree hierarchy.
+ */
+void
+nact_tree_view_collapse_all( const NactTreeView *view )
+{
+ g_return_if_fail( NACT_IS_TREE_VIEW( view ));
+
+ if( !view->private->dispose_has_run ){
+
+ gtk_tree_view_collapse_all( view->private->tree_view );
}
}
/**
+ * nact_tree_view_expand_all:
+ * @view: this #NactTreeView instance.
+ *
+ * Collapse all the tree hierarchy.
+ */
+void
+nact_tree_view_expand_all( const NactTreeView *view )
+{
+ g_return_if_fail( NACT_IS_TREE_VIEW( view ));
+
+ if( !view->private->dispose_has_run ){
+
+ gtk_tree_view_expand_all( view->private->tree_view );
+ }
+}
+
+/**
+ * nact_tree_view_get_item_by_id:
+ * @view: this #NactTreeView instance.
+ * @id: the searched #NAObjectItem.
+ *
+ * Returns: a pointer on the searched #NAObjectItem if it exists, or %NULL.
+ *
+ * The returned pointer is owned by the underlying tree store, and should
+ * not be released by the caller.
+ */
+NAObjectItem *
+nact_tree_view_get_item_by_id( const NactTreeView *view, const gchar *id )
+{
+ NAObjectItem *item;
+ NactTreeModel *model;
+
+ g_return_val_if_fail( NACT_IS_TREE_VIEW( view ), NULL );
+
+ item = NULL;
+
+ if( !view->private->dispose_has_run ){
+
+ model = NACT_TREE_MODEL( gtk_tree_view_get_model( view->private->tree_view ));
+ item = nact_tree_model_get_item_by_id( model, id );
+ }
+
+ return( item );
+}
+
+/**
* nact_tree_view_get_items:
* @view: this #NactTreeView instance.
*
@@ -704,7 +960,7 @@ nact_tree_view_fill( NactTreeView *view, GList *items )
* which should be na_object_free_items() by the caller.
*/
GList *
-nact_tree_view_get_items( NactTreeView *view )
+nact_tree_view_get_items( const NactTreeView *view )
{
GList *items;
NactTreeModel *model;
@@ -716,7 +972,7 @@ nact_tree_view_get_items( NactTreeView *view )
if( !view->private->dispose_has_run ){
model = NACT_TREE_MODEL( gtk_tree_view_get_model( view->private->tree_view ));
- items = nact_tree_model_get_items( model );
+ items = nact_tree_model_get_items( model, TREE_LIST_ALL );
}
return( items );
@@ -910,6 +1166,19 @@ navigate_to_parent( NactTreeView *view )
g_list_free( listrows );
}
+static void
+open_popup( BaseWindow *window, NactTreeView *view, GdkEventButton *event )
+{
+ GtkTreePath *path;
+
+ if( gtk_tree_view_get_path_at_pos( view->private->tree_view, event->x, event->y, &path, NULL, NULL, NULL )){
+ select_row_at_path( view, path );
+ gtk_tree_path_free( path );
+ }
+
+ g_signal_emit_by_name( window, TREE_SIGNAL_CONTEXT_MENU, view, event );
+}
+
/*
* Select the row at the required path, or the immediate previous, or
* the next following, or eventually the immediate parent.
@@ -1053,20 +1322,3 @@ on_finalizing_window( NactTreeView *view, GObject *window )
g_object_unref( view );
}
-
-void
-nact_tree_view_setup_ialid( const NactTreeView *view, IActionsListInstanceData *ialid )
-{
- g_return_if_fail( NACT_IS_TREE_VIEW( view ));
-
- if( !view->private->dispose_has_run ){
-
- ialid->management_mode = IACTIONS_LIST_MANAGEMENT_MODE_EXPORT;
- /*ialid->menus;*/
- /*ialid->actions;*/
- /*ialid->profiles;*/
- ialid->selection_changed_allowed = view->private->notify_allowed;
- /*ialid->tab_updated_handler;*/
- /*ialid->modified_items;*/
- }
-}
diff --git a/src/nact/nact-tree-view.h b/src/nact/nact-tree-view.h
index 8390dea..856e4ee 100644
--- a/src/nact/nact-tree-view.h
+++ b/src/nact/nact-tree-view.h
@@ -40,6 +40,8 @@
* This is a convenience class to manage a read-only items tree view.
*/
+#include <api/na-object-item.h>
+
#include "base-window.h"
G_BEGIN_DECLS
@@ -73,44 +75,43 @@ typedef struct {
* Properties defined by the NactTreeView class.
* They should be provided at object instantiation time.
*
- * @TREE_PROP_WINDOW: the BaseWindow parent.
- * @TREE_PROP_WIDGET_NAME: the widget name.
- * @TREE_PROP_HAVE_DND: whether drag and drop is implemented.
- * @TREE_PROP_DISPLAY_PROFILES: whether profiles are displayed.
+ * @TREE_PROP_WINDOW: the BaseWindow parent.
+ * @TREE_PROP_WIDGET_NAME: the widget name.
+ * @TREE_PROP_MODE: management mode.
*/
#define TREE_PROP_WINDOW "tree-prop-window"
#define TREE_PROP_WIDGET_NAME "tree-prop-widget-name"
-#define TREE_PROP_HAVE_DND "tree-prop-have-dnd"
-#define TREE_PROP_DISPLAY_PROFILES "tree-prop-display-profiles"
-
-/**
- * Column ordering in the tree view
- */
-enum {
- TREE_COLUMN_ICON = 0,
- TREE_COLUMN_LABEL,
- TREE_COLUMN_NAOBJECT,
- TREE_N_COLUMN
-};
+#define TREE_PROP_MODE "tree-prop-mode"
/**
* Signals emitted by the NactTreeView instance.
*/
#define TREE_SIGNAL_CONTENT_CHANGED "tree-signal-content-changed"
+#define TREE_SIGNAL_CONTEXT_MENU "tree-signal-open-popup"
+#define TREE_SIGNAL_COUNT_CHANGED "tree-signal-count-changed"
+#define TREE_SIGNAL_FOCUS_IN "tree-signal-focus-in"
+#define TREE_SIGNAL_FOCUS_OUT "tree-signal-focus-out"
+#define TREE_SIGNAL_MODIFIED_COUNT_CHANGED "tree-signal-modified-count-changed"
#define TREE_SIGNAL_SELECTION_CHANGED "tree-signal-selection-changed"
+typedef enum {
+ TREE_MODE_EDITION = 0,
+ TREE_MODE_SELECTION,
+ /*< private >*/
+ TREE_MODE_N_MODES
+}
+ NactTreeMode;
+
GType nact_tree_view_get_type( void );
-NactTreeView *nact_tree_view_new( BaseWindow *window, const gchar *treeview_name );
+NactTreeView *nact_tree_view_new( BaseWindow *window, const gchar *treeview_name, NactTreeMode mode );
void nact_tree_view_fill ( NactTreeView *view, GList *items );
-GList *nact_tree_view_get_items( NactTreeView *view );
-
-/* special transition phase
- */
-#include "nact-iactions-list-priv.h"
-void nact_tree_view_setup_ialid( const NactTreeView *view, IActionsListInstanceData *ialid );
+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 );
G_END_DECLS
diff --git a/src/nact/nact-window.c b/src/nact/nact-window.c
index c8d1557..943acbc 100644
--- a/src/nact/nact-window.c
+++ b/src/nact/nact-window.c
@@ -310,34 +310,3 @@ nact_window_count_level_zero_items( GList *items, guint *actions, guint *profile
}
}
}
-
-/**
- * nact_window_warn_modified:
- * @window: this #NactWindow instance.
- *
- * Emits a warning if the action has been modified.
- *
- * Returns: %TRUE if the user confirms he wants to quit.
- */
-gboolean
-nact_window_warn_modified( NactWindow *window )
-{
- gboolean confirm = FALSE;
- gchar *first;
- gchar *second;
-
- g_return_val_if_fail( NACT_IS_WINDOW( window ), FALSE );
-
- if( !window->private->dispose_has_run ){
-
- first = g_strdup_printf( _( "Some items have been modified." ));
- second = g_strdup( _( "Are you sure you want to quit without saving them ?" ));
-
- confirm = base_window_display_yesno_dlg( BASE_WINDOW( window ), first, second );
-
- g_free( second );
- g_free( first );
- }
-
- return( confirm );
-}
diff --git a/src/nact/nact-window.h b/src/nact/nact-window.h
index 0fd26b4..c3ef49e 100644
--- a/src/nact/nact-window.h
+++ b/src/nact/nact-window.h
@@ -80,8 +80,6 @@ gboolean nact_window_delete_item( NactWindow *window, const NAObjectItem *item
void nact_window_count_level_zero_items( GList *items, guint *actions, guint *profiles, guint *menus );
-gboolean nact_window_warn_modified( NactWindow *window );
-
G_END_DECLS
#endif /* __NACT_WINDOW_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]