[nautilus-actions] Review NactICommandTab interface



commit 2b6da1a24042a4689b4a20eacbb6306ccc25d77a
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Jan 4 21:20:05 2012 +0100

    Review NactICommandTab interface

 ChangeLog                    |    2 +
 src/nact/nact-icommand-tab.c |  314 ++++++++++++++++++++----------------------
 2 files changed, 151 insertions(+), 165 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d76bec0..985e485 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2012-01-04 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/nact-icommand-tab.c: Review NactICommandTab interface.
+
 	* src/nact/nact-icapabilities-tab.c: Review NactICapabilitiesTab interface.
 
 	* src/nact/nact-ibasenames-tab.c: Review NactIBasenamesTab interface.
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index ac1505f..bd0ee90 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -61,8 +61,7 @@ struct _NactICommandTabInterfacePrivate {
 #define ICOMMAND_TAB_LEGEND_VISIBLE			"nact-icommand-tab-legend-dialog-visible"
 #define ICOMMAND_TAB_STATUSBAR_CONTEXT		"nact-icommand-tab-statusbar-context"
 
-static gboolean  st_initialized = FALSE;
-static gboolean  st_finalized = FALSE;
+static guint     st_initializations = 0;	/* interface initialization count */
 static gboolean  st_on_selection_change = FALSE;
 static NATokens *st_tokens = NULL;
 
@@ -136,14 +135,14 @@ interface_base_init( NactICommandTabInterface *klass )
 {
 	static const gchar *thisfn = "nact_icommand_tab_interface_base_init";
 
-	if( !st_initialized ){
+	if( !st_initializations ){
 
 		g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
 
 		klass->private = g_new0( NactICommandTabInterfacePrivate, 1 );
-
-		st_initialized = TRUE;
 	}
+
+	st_initializations += 1;
 }
 
 static void
@@ -151,11 +150,11 @@ interface_base_finalize( NactICommandTabInterface *klass )
 {
 	static const gchar *thisfn = "nact_icommand_tab_interface_base_finalize";
 
-	if( st_initialized && !st_finalized ){
+	st_initializations -= 1;
 
-		g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
+	if( !st_initializations ){
 
-		st_finalized = TRUE;
+		g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
 
 		g_free( klass->private );
 	}
@@ -178,10 +177,7 @@ nact_icommand_tab_initial_load_toplevel( NactICommandTab *instance )
 
 	g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
 
-	if( st_initialized && !st_finalized ){
-
-		g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
-	}
+	g_debug( "%s: instance=%p (%s)", thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ));
 }
 
 /**
@@ -201,78 +197,75 @@ nact_icommand_tab_runtime_init_toplevel( NactICommandTab *instance )
 
 	g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
 
-	if( st_initialized && !st_finalized ){
-
-		g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
-
-		label_entry = get_label_entry( instance );
-		base_window_signal_connect(
-				BASE_WINDOW( instance ),
-				G_OBJECT( label_entry ),
-				"changed",
-				G_CALLBACK( on_label_changed ));
-
-		path_entry = get_path_entry( instance );
-		base_window_signal_connect(
-				BASE_WINDOW( instance ),
-				G_OBJECT( path_entry ),
-				"changed",
-				G_CALLBACK( on_path_changed ));
-
-		path_button = get_path_button( instance );
-		base_window_signal_connect(
-				BASE_WINDOW( instance ),
-				G_OBJECT( path_button ),
-				"clicked",
-				G_CALLBACK( on_path_browse ));
-
-		parameters_entry = get_parameters_entry( instance );
-		base_window_signal_connect(
-				BASE_WINDOW( instance ),
-				G_OBJECT( parameters_entry ),
-				"changed",
-				G_CALLBACK( on_parameters_changed ));
+	g_debug( "%s: instance=%p (%s)", thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ));
 
-		legend_button = get_legend_button( instance );
-		base_window_signal_connect(
-				BASE_WINDOW( instance ),
-				G_OBJECT( legend_button ),
-				"clicked",
-				G_CALLBACK( on_legend_clicked ));
-
-		legend_dialog = get_legend_dialog( instance );
-		base_window_signal_connect(
-				BASE_WINDOW( instance ),
-				G_OBJECT( legend_dialog ),
-				"delete-event",
-				G_CALLBACK( on_legend_dialog_deleted ));
+	label_entry = get_label_entry( instance );
+	base_window_signal_connect(
+			BASE_WINDOW( instance ),
+			G_OBJECT( label_entry ),
+			"changed",
+			G_CALLBACK( on_label_changed ));
 
-		wdir_entry = base_window_get_widget( BASE_WINDOW( instance ), "WorkingDirectoryEntry" );
-		base_window_signal_connect(
-				BASE_WINDOW( instance ),
-				G_OBJECT( wdir_entry ),
-				"changed",
-				G_CALLBACK( on_wdir_changed ));
-
-		wdir_button = GTK_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "CommandWorkingDirectoryButton" ));
-		base_window_signal_connect(
-				BASE_WINDOW( instance ),
-				G_OBJECT( wdir_button ),
-				"clicked",
-				G_CALLBACK( on_wdir_browse ));
-
-		base_window_signal_connect( BASE_WINDOW( instance ),
-				G_OBJECT( instance ), MAIN_SIGNAL_SELECTION_CHANGED, G_CALLBACK( on_main_selection_changed ));
-
-		base_window_signal_connect( BASE_WINDOW( instance ),
-				G_OBJECT( instance ), MAIN_SIGNAL_ITEM_UPDATED, 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
-		 */
-		if( !st_tokens ){
-			st_tokens = na_tokens_new_for_example();
-		}
+	path_entry = get_path_entry( instance );
+	base_window_signal_connect(
+			BASE_WINDOW( instance ),
+			G_OBJECT( path_entry ),
+			"changed",
+			G_CALLBACK( on_path_changed ));
+
+	path_button = get_path_button( instance );
+	base_window_signal_connect(
+			BASE_WINDOW( instance ),
+			G_OBJECT( path_button ),
+			"clicked",
+			G_CALLBACK( on_path_browse ));
+
+	parameters_entry = get_parameters_entry( instance );
+	base_window_signal_connect(
+			BASE_WINDOW( instance ),
+			G_OBJECT( parameters_entry ),
+			"changed",
+			G_CALLBACK( on_parameters_changed ));
+
+	legend_button = get_legend_button( instance );
+	base_window_signal_connect(
+			BASE_WINDOW( instance ),
+			G_OBJECT( legend_button ),
+			"clicked",
+			G_CALLBACK( on_legend_clicked ));
+
+	legend_dialog = get_legend_dialog( instance );
+	base_window_signal_connect(
+			BASE_WINDOW( instance ),
+			G_OBJECT( legend_dialog ),
+			"delete-event",
+			G_CALLBACK( on_legend_dialog_deleted ));
+
+	wdir_entry = base_window_get_widget( BASE_WINDOW( instance ), "WorkingDirectoryEntry" );
+	base_window_signal_connect(
+			BASE_WINDOW( instance ),
+			G_OBJECT( wdir_entry ),
+			"changed",
+			G_CALLBACK( on_wdir_changed ));
+
+	wdir_button = GTK_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "CommandWorkingDirectoryButton" ));
+	base_window_signal_connect(
+			BASE_WINDOW( instance ),
+			G_OBJECT( wdir_button ),
+			"clicked",
+			G_CALLBACK( on_wdir_browse ));
+
+	base_window_signal_connect( BASE_WINDOW( instance ),
+			G_OBJECT( instance ), MAIN_SIGNAL_SELECTION_CHANGED, G_CALLBACK( on_main_selection_changed ));
+
+	base_window_signal_connect( BASE_WINDOW( instance ),
+			G_OBJECT( instance ), MAIN_SIGNAL_ITEM_UPDATED, G_CALLBACK( on_tree_view_content_changed ));
+
+	/* allocate a static fake NATokens object which will be used to build
+	 * the example label - this object will be unreffed on dispose
+	 */
+	if( !st_tokens ){
+		st_tokens = na_tokens_new_for_example();
 	}
 }
 
@@ -283,10 +276,7 @@ nact_icommand_tab_all_widgets_showed( NactICommandTab *instance )
 
 	g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
 
-	if( st_initialized && !st_finalized ){
-
-		g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
-	}
+	g_debug( "%s: instance=%p (%s)", thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ));
 }
 
 /**
@@ -302,15 +292,12 @@ nact_icommand_tab_dispose( NactICommandTab *instance )
 
 	g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
 
-	if( st_initialized && !st_finalized ){
+	g_debug( "%s: instance=%p (%s)", thisfn, ( void * ) instance, G_OBJECT_TYPE_NAME( instance ));
 
-		g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
-
-		legend_dialog_hide( instance );
+	legend_dialog_hide( instance );
 
-		if( st_tokens ){
-			g_object_unref( st_tokens );
-		}
+	if( st_tokens ){
+		g_object_unref( st_tokens );
 	}
 }
 
@@ -322,14 +309,11 @@ on_tree_view_content_changed( NactICommandTab *instance, NAObject *object, gpoin
 
 	g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
 
-	if( st_initialized && !st_finalized ){
-
-		if( NA_IS_OBJECT_PROFILE( object )){
-			label_widget = get_label_entry( instance );
-			label = na_object_get_label( object );
-			gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
-			g_free( label );
-		}
+	if( NA_IS_OBJECT_PROFILE( object )){
+		label_widget = get_label_entry( instance );
+		label = na_object_get_label( object );
+		gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
+		g_free( label );
 	}
 }
 
@@ -347,68 +331,68 @@ on_main_selection_changed( NactICommandTab *instance, GList *selected_items, gpo
 
 	g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
 
-	if( st_initialized && !st_finalized ){
-		g_debug( "%s: instance=%p, selected_items=%p (count=%d)",
-				thisfn, ( void * ) instance, ( void * ) selected_items, g_list_length( selected_items ));
-
-		g_object_get(
-				G_OBJECT( instance ),
-				MAIN_PROP_PROFILE, &profile,
-				MAIN_PROP_EDITABLE, &editable,
-				NULL );
+	g_debug( "%s: instance=%p (%s), selected_items=%p (count=%d)",
+			thisfn,
+			( void * ) instance, G_OBJECT_TYPE_NAME( instance ),
+			( void * ) selected_items, g_list_length( selected_items ));
 
-		enable_tab = ( profile != NULL );
-		nact_main_tab_enable_page( NACT_MAIN_WINDOW( instance ), TAB_COMMAND, enable_tab );
-
-		st_on_selection_change = TRUE;
-
-		label_entry = get_label_entry( instance );
-		label = profile ? na_object_get_label( profile ) : g_strdup( "" );
-		label = label ? label : g_strdup( "" );
-		gtk_entry_set_text( GTK_ENTRY( label_entry ), label );
-		g_free( label );
-		gtk_widget_set_sensitive( label_entry, profile != NULL );
-		base_gtk_utils_set_editable( G_OBJECT( label_entry ), editable );
-
-		path_entry = get_path_entry( instance );
-		path = profile ? na_object_get_path( profile ) : g_strdup( "" );
-		path = path ? path : g_strdup( "" );
-		gtk_entry_set_text( GTK_ENTRY( path_entry ), path );
-		g_free( path );
-		gtk_widget_set_sensitive( path_entry, profile != NULL );
-		base_gtk_utils_set_editable( G_OBJECT( path_entry ), editable );
-
-		path_button = get_path_button( instance );
-		gtk_widget_set_sensitive( GTK_WIDGET( path_button ), profile != NULL );
-		base_gtk_utils_set_editable( G_OBJECT( path_button ), editable );
-
-		parameters_entry = get_parameters_entry( instance );
-		parameters = profile ? na_object_get_parameters( profile ) : g_strdup( "" );
-		parameters = parameters ? parameters : g_strdup( "" );
-		gtk_entry_set_text( GTK_ENTRY( parameters_entry ), parameters );
-		g_free( parameters );
-		gtk_widget_set_sensitive( parameters_entry, profile != NULL );
-		base_gtk_utils_set_editable( G_OBJECT( parameters_entry ), editable );
-
-		legend_button = get_legend_button( instance );
-		gtk_widget_set_sensitive( GTK_WIDGET( legend_button ), profile != NULL );
-
-		update_example_label( instance, profile );
+	g_object_get(
+			G_OBJECT( instance ),
+			MAIN_PROP_PROFILE, &profile,
+			MAIN_PROP_EDITABLE, &editable,
+			NULL );
 
-		wdir_entry = base_window_get_widget( BASE_WINDOW( instance ), "WorkingDirectoryEntry" );
-		wdir = profile ? na_object_get_working_dir( profile ) : g_strdup( "" );
-		wdir = wdir ? wdir : g_strdup( "" );
-		gtk_entry_set_text( GTK_ENTRY( wdir_entry ), wdir );
-		g_free( wdir );
-		gtk_widget_set_sensitive( wdir_entry, profile != NULL );
-		base_gtk_utils_set_editable( G_OBJECT( wdir_entry ), editable );
-
-		wdir_button = GTK_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "CommandWorkingDirectoryButton" ));
-		gtk_widget_set_sensitive( GTK_WIDGET( wdir_button ), profile != NULL );
-		base_gtk_utils_set_editable( G_OBJECT( wdir_button ), editable );
-
-		st_on_selection_change = FALSE;
-	}
+	enable_tab = ( profile != NULL );
+	nact_main_tab_enable_page( NACT_MAIN_WINDOW( instance ), TAB_COMMAND, enable_tab );
+
+	st_on_selection_change = TRUE;
+
+	label_entry = get_label_entry( instance );
+	label = profile ? na_object_get_label( profile ) : g_strdup( "" );
+	label = label ? label : g_strdup( "" );
+	gtk_entry_set_text( GTK_ENTRY( label_entry ), label );
+	g_free( label );
+	gtk_widget_set_sensitive( label_entry, profile != NULL );
+	base_gtk_utils_set_editable( G_OBJECT( label_entry ), editable );
+
+	path_entry = get_path_entry( instance );
+	path = profile ? na_object_get_path( profile ) : g_strdup( "" );
+	path = path ? path : g_strdup( "" );
+	gtk_entry_set_text( GTK_ENTRY( path_entry ), path );
+	g_free( path );
+	gtk_widget_set_sensitive( path_entry, profile != NULL );
+	base_gtk_utils_set_editable( G_OBJECT( path_entry ), editable );
+
+	path_button = get_path_button( instance );
+	gtk_widget_set_sensitive( GTK_WIDGET( path_button ), profile != NULL );
+	base_gtk_utils_set_editable( G_OBJECT( path_button ), editable );
+
+	parameters_entry = get_parameters_entry( instance );
+	parameters = profile ? na_object_get_parameters( profile ) : g_strdup( "" );
+	parameters = parameters ? parameters : g_strdup( "" );
+	gtk_entry_set_text( GTK_ENTRY( parameters_entry ), parameters );
+	g_free( parameters );
+	gtk_widget_set_sensitive( parameters_entry, profile != NULL );
+	base_gtk_utils_set_editable( G_OBJECT( parameters_entry ), editable );
+
+	legend_button = get_legend_button( instance );
+	gtk_widget_set_sensitive( GTK_WIDGET( legend_button ), profile != NULL );
+
+	update_example_label( instance, profile );
+
+	wdir_entry = base_window_get_widget( BASE_WINDOW( instance ), "WorkingDirectoryEntry" );
+	wdir = profile ? na_object_get_working_dir( profile ) : g_strdup( "" );
+	wdir = wdir ? wdir : g_strdup( "" );
+	gtk_entry_set_text( GTK_ENTRY( wdir_entry ), wdir );
+	g_free( wdir );
+	gtk_widget_set_sensitive( wdir_entry, profile != NULL );
+	base_gtk_utils_set_editable( G_OBJECT( wdir_entry ), editable );
+
+	wdir_button = GTK_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "CommandWorkingDirectoryButton" ));
+	gtk_widget_set_sensitive( GTK_WIDGET( wdir_button ), profile != NULL );
+	base_gtk_utils_set_editable( G_OBJECT( wdir_button ), editable );
+
+	st_on_selection_change = FALSE;
 }
 
 static GtkWidget *



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