[nautilus-actions] Define IActionsList:get_treeview_name pure virtual function



commit 978c9a63d570a7eaef0e1caa9f0a7eee14e23f45
Author: pierre <pierre vfedora10 virtuals pwi>
Date:   Mon Sep 28 13:03:33 2009 +0200

    Define IActionsList:get_treeview_name pure virtual function
    
    Implements this in NactMainWindow and NactAssistantExport.
    This will let us merge the two UI XML definition files, while always
    having a common interface to IActionsList.

 ChangeLog                        |    5 +++++
 src/nact/nact-assistant-export.c |   16 ++++++++++++++++
 src/nact/nact-iactions-list.c    |   29 +++++++++++++++++++++++++----
 src/nact/nact-iactions-list.h    |   17 +++++++++++++++--
 src/nact/nact-main-window.c      |   16 ++++++++++++++++
 5 files changed, 77 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cd2476d..b8140b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,9 @@
 	Replace the BaseWindow argument by a BaseIPrefs	one.
 	Define three new UI preferences.
 
+	* src/nact/nact-assistant-export.c:
+	Implements IActionsList::get_treeview_name virtual function.
+
 	* src/nact/nact-clipboard.c:
 	* src/nact/nact-main-window.c:
 	Now implements the BaseIPrefs interface.
@@ -21,6 +24,7 @@
 	* src/nact/nact-main-window.c (nact_main_window_action_exists):
 	No more check for action existancy in NAPivot.
 	No more forward nact-tab-updatable-item-updated signal.
+	Implements IActionsList::get_treeview_name virtual function.
 
 	* src/nact/nact-iactions-list.c:
 	* src/nact/nact-iactions-list.h
@@ -28,6 +32,7 @@
 	New functions.
 	Remove useless nact-iactions-list-item-updated signal.
 	Connect instead to nact-tab-updatable-item-updated signal.
+	(get_treeview_name): New pure virtual function.
 
 	* src/nact/nact-main-menubar.c (on_duplicate_activated):
 	Takes advantage of new UI preferences.
diff --git a/src/nact/nact-assistant-export.c b/src/nact/nact-assistant-export.c
index 06d17d4..b44336e 100644
--- a/src/nact/nact-assistant-export.c
+++ b/src/nact/nact-assistant-export.c
@@ -117,6 +117,7 @@ static void            assist_runtime_init_intro( NactAssistantExport *window, G
 static void            assist_initial_load_actions_list( NactAssistantExport *window, GtkAssistant *assistant );
 static void            assist_runtime_init_actions_list( NactAssistantExport *window, GtkAssistant *assistant );
 static void            on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected_items );
+static gchar          *on_iactions_list_get_treeview_name( NactIActionsList *instance );
 
 static void            assist_initial_load_target_folder( NactAssistantExport *window, GtkAssistant *assistant );
 static void            assist_runtime_init_target_folder( NactAssistantExport *window, GtkAssistant *assistant );
@@ -231,6 +232,7 @@ iactions_list_iface_init( NactIActionsListInterface *iface )
 	g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
 
 	iface->selection_changed = on_iactions_list_selection_changed;
+	iface->get_treeview_name = on_iactions_list_get_treeview_name;
 }
 
 static void
@@ -549,6 +551,20 @@ on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected
 	}
 }
 
+static gchar *
+on_iactions_list_get_treeview_name( NactIActionsList *instance )
+{
+	gchar *name = NULL;
+
+	g_return_val_if_fail( NACT_IS_ASSISTANT_EXPORT( instance ), NULL );
+
+	if( !NACT_ASSISTANT_EXPORT( instance )->private->dispose_has_run ){
+		name = g_strdup( "ActionsList" );
+	}
+
+	return( name );
+}
+
 static void
 assist_initial_load_target_folder( NactAssistantExport *window, GtkAssistant *assistant )
 {
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 8e4d376..167559c 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -119,6 +119,8 @@ static void         free_items_callback( NactIActionsList *instance, GList *item
 static GtkTreePath *do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTreePath *path, gint level, GList **parents );
 static GList       *do_insert_items_add_parent( GList *parents, GtkTreeView *treeview, GtkTreeModel *model, NAObject *parent );
 
+static gchar       *v_get_treeview_name( NactIActionsList *instance );
+
 static void         display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, NactIActionsList *instance );
 static void         extend_selection_to_childs( NactIActionsList *instance, GtkTreeView *treeview, GtkTreeModel *model, GtkTreeIter *parent );
 static gboolean     filter_selection( GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, NactIActionsList *instance );
@@ -1026,6 +1028,20 @@ nact_iactions_list_toggle_collapse( NactIActionsList *instance, const NAObject *
 	}
 }
 
+static gchar *
+v_get_treeview_name( NactIActionsList *instance )
+{
+	gchar *name = NULL;
+
+	if( st_initialized && !st_finalized ){
+		if( NACT_IACTIONS_LIST_GET_INTERFACE( instance )->get_treeview_name ){
+			name = NACT_IACTIONS_LIST_GET_INTERFACE( instance )->get_treeview_name( instance );
+		}
+	}
+
+	return( name );
+}
+
 /*
  * item modified: italic
  * item not saveable (invalid): red
@@ -1179,10 +1195,15 @@ filter_selection_iter( GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter
 static GtkTreeView *
 get_actions_list_treeview( NactIActionsList *instance )
 {
-	GtkTreeView *treeview;
-
-	treeview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( instance ), "ActionsList" ));
-	g_assert( GTK_IS_TREE_VIEW( treeview ));
+	gchar *widget_name;
+	GtkTreeView *treeview = NULL;
+
+	widget_name = v_get_treeview_name( instance );
+	if( widget_name ){
+		treeview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( instance ), widget_name ));
+		g_return_val_if_fail( GTK_IS_TREE_VIEW( treeview ), NULL );
+		g_free( widget_name );
+	}
 
 	return( treeview );
 }
diff --git a/src/nact/nact-iactions-list.h b/src/nact/nact-iactions-list.h
index c90c420..274fd88 100644
--- a/src/nact/nact-iactions-list.h
+++ b/src/nact/nact-iactions-list.h
@@ -59,7 +59,7 @@ typedef struct {
 
 	/**
 	 * selection_changed:
-	 * @instance: this #NactIActionsList instance.
+	 * @instance: this #NactIActionsList implementor.
 	 * @selected_items: currently selected items.
 	 *
 	 * This function is an exact duplicate of the
@@ -72,7 +72,20 @@ typedef struct {
 	 * signal must be considered at least as useless, and just a way to
 	 * be triggered twice for the same event.
 	 */
-	void ( *selection_changed )( NactIActionsList *instance, GSList *selected_items );
+	void    ( *selection_changed )( NactIActionsList *instance, GSList *selected_items );
+
+	/**
+	 * get_treeview_name:
+	 * @instance: this #NactIActionsList implementor.
+	 *
+	 * Returns: a newly allocated string, which contains the treeview
+	 * widget name in its XML UI definition.
+	 *
+	 * The returned string will be g_free() by IActionsList interface.
+	 *
+	 * This is a pure virtual function which must be implemented.
+	 */
+	gchar * ( *get_treeview_name )( NactIActionsList *instance );
 }
 	NactIActionsListInterface;
 
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 399d0ca..4b6bb67 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -142,6 +142,7 @@ static void     on_base_all_widgets_showed( NactMainWindow *window, gpointer use
 static void     iactions_list_selection_changed( NactIActionsList *instance, GSList *selected_items );
 static void     set_current_object_item( NactMainWindow *window, GSList *selected_items );
 static void     set_current_profile( NactMainWindow *window, gboolean set_action, GSList *selected_items );
+static gchar   *iactions_list_get_treeview_name( NactIActionsList *instance );
 
 static void     on_tab_updatable_item_updated( NactMainWindow *window, gpointer user_data );
 
@@ -348,6 +349,7 @@ iactions_list_iface_init( NactIActionsListInterface *iface )
 	g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
 
 	iface->selection_changed = iactions_list_selection_changed;
+	iface->get_treeview_name = iactions_list_get_treeview_name;
 }
 
 static void
@@ -1026,6 +1028,20 @@ set_current_profile( NactMainWindow *window, gboolean set_action, GSList *select
 	}
 }
 
+static gchar *
+iactions_list_get_treeview_name( NactIActionsList *instance )
+{
+	gchar *name = NULL;
+
+	g_return_val_if_fail( NACT_IS_MAIN_WINDOW( instance ), NULL );
+
+	if( !NACT_MAIN_WINDOW( instance )->private->dispose_has_run ){
+		name = g_strdup( "ActionsList" );
+	}
+
+	return( name );
+}
+
 static void
 on_tab_updatable_item_updated( NactMainWindow *window, gpointer user_data )
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]