[nautilus-actions] Review NactIPropertiesTab page



commit 63b66e1c8fd59adbb327cfc994ca26e79ee7a61d
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Jun 17 19:45:28 2010 +0200

    Review NactIPropertiesTab page

 ChangeLog                       |    5 ++
 src/api/na-object-api.h         |    2 +
 src/nact/nact-iproperties-tab.c |  128 +++++++++++++++++++++++---------------
 3 files changed, 84 insertions(+), 51 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d4c366e..bd13a08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 2010-06-17 Pierre Wieser <pwieser trychlos org>
 
 	* src/api/na-object-api.h
+	(na_object_get_shortcut, na_object_set_shortcut): New macros.
+
+	* src/nact/nact-iproperties-tab.c: Review NactIPropertiesTab page.
+
+	* src/api/na-object-api.h
 	(na_object_get_execution_mode,
 	na_object_get_startup_notify, na_object_get_startup_class,
 	na_object_get_execute_as, na_object_set_execution_mode,
diff --git a/src/api/na-object-api.h b/src/api/na-object-api.h
index 8acb72d..a763202 100644
--- a/src/api/na-object-api.h
+++ b/src/api/na-object-api.h
@@ -106,6 +106,7 @@ G_BEGIN_DECLS
 #define na_object_get_provider( obj )					na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PROVIDER )
 #define na_object_get_provider_data( obj )				na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PROVIDER_DATA )
 #define na_object_get_iversion( obj )					GPOINTER_TO_UINT( na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_IVERSION ))
+#define na_object_get_shortcut( obj )					(( gchar * ) na_ifactory_object_get_as_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_SHORTCUT ))
 
 #define na_object_set_tooltip( obj, tooltip )			na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_TOOLTIP, ( const void * )( tooltip ))
 #define na_object_set_icon( obj, icon )					na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_ICON, ( const void * )( icon ))
@@ -117,6 +118,7 @@ G_BEGIN_DECLS
 #define na_object_set_provider( obj, provider )			na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PROVIDER, ( const void * )( provider ))
 #define na_object_set_provider_data( obj, data )		na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_PROVIDER_DATA, ( const void * )( data ))
 #define na_object_set_iversion( obj, version )			na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_IVERSION, ( const void * ) GUINT_TO_POINTER( version ))
+#define na_object_set_shortcut( obj, shortcut )			na_ifactory_object_set_from_void( NA_IFACTORY_OBJECT( obj ), NAFO_DATA_SHORTCUT, ( const void * )( shortcut ))
 
 #define na_object_get_item( obj, id )					na_object_item_get_item( NA_OBJECT_ITEM( obj ),( const gchar * )( id ))
 #define na_object_get_position( obj, child )			na_object_item_get_position( NA_OBJECT_ITEM( obj ), NA_OBJECT_ID( child ))
diff --git a/src/nact/nact-iproperties-tab.c b/src/nact/nact-iproperties-tab.c
index 20db304..8fbd874 100644
--- a/src/nact/nact-iproperties-tab.c
+++ b/src/nact/nact-iproperties-tab.c
@@ -63,6 +63,7 @@ static GtkButton *get_enabled_button( NactIPropertiesTab *instance );
 static void       on_enabled_toggled( GtkToggleButton *button, NactIPropertiesTab *instance );
 static void       on_readonly_toggled( GtkToggleButton *button, NactIPropertiesTab *instance );
 static void       on_description_changed( GtkTextBuffer *buffer, NactIPropertiesTab *instance );
+static void       on_shortcut_clicked( GtkButton *button, NactIPropertiesTab *instance );
 
 static void       display_provider_name( NactIPropertiesTab *instance, NAObjectItem *item );
 
@@ -140,10 +141,11 @@ nact_iproperties_tab_initial_load_toplevel( NactIPropertiesTab *instance )
 {
 	static const gchar *thisfn = "nact_iproperties_tab_initial_load_toplevel";
 
-	g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
 	g_return_if_fail( NACT_IS_IPROPERTIES_TAB( instance ));
 
 	if( st_initialized && !st_finalized ){
+
+		g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
 	}
 }
 
@@ -156,11 +158,12 @@ nact_iproperties_tab_runtime_init_toplevel( NactIPropertiesTab *instance )
 	GtkWidget *label_widget;
 	GtkTextBuffer *buffer;
 
-	g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
 	g_return_if_fail( NACT_IS_IPROPERTIES_TAB( instance ));
 
 	if( st_initialized && !st_finalized ){
 
+		g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+
 		base_window_signal_connect(
 				BASE_WINDOW( instance ),
 				G_OBJECT( instance ),
@@ -180,13 +183,6 @@ nact_iproperties_tab_runtime_init_toplevel( NactIPropertiesTab *instance )
 				"toggled",
 				G_CALLBACK( on_enabled_toggled ));
 
-		button = base_window_get_widget( BASE_WINDOW( instance ), "ActionReadonlyButton" );
-		base_window_signal_connect(
-				BASE_WINDOW( instance ),
-				G_OBJECT( button ),
-				"toggled",
-				G_CALLBACK( on_readonly_toggled ));
-
 		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionDescriptionText" );
 		buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( label_widget ));
 		base_window_signal_connect(
@@ -194,6 +190,20 @@ nact_iproperties_tab_runtime_init_toplevel( NactIPropertiesTab *instance )
 				G_OBJECT( buffer ),
 				"changed",
 				G_CALLBACK( on_description_changed ));
+
+		button = base_window_get_widget( BASE_WINDOW( instance ), "SuggestedShortcutButton" );
+		base_window_signal_connect(
+				BASE_WINDOW( instance ),
+				G_OBJECT( buffer ),
+				"clicked",
+				G_CALLBACK( on_shortcut_clicked ));
+
+		button = base_window_get_widget( BASE_WINDOW( instance ), "ActionReadonlyButton" );
+		base_window_signal_connect(
+				BASE_WINDOW( instance ),
+				G_OBJECT( button ),
+				"toggled",
+				G_CALLBACK( on_readonly_toggled ));
 	}
 }
 
@@ -230,12 +240,12 @@ on_tab_updatable_selection_changed( NactIPropertiesTab *instance, gint count_sel
 	gboolean enable_tab;
 	GtkNotebook *notebook;
 	GtkWidget *page;
-	GtkWidget *title_widget, *label_widget;
+	GtkWidget *title_widget, *label_widget, *shortcut_button;
 	GtkButton *enabled_button;
 	gboolean enabled_item;
 	GtkToggleButton *readonly_button;
 	GtkTextBuffer *buffer;
-	gchar *label;
+	gchar *label, *shortcut;
 
 	g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
 	g_return_if_fail( BASE_IS_WINDOW( instance ));
@@ -243,8 +253,6 @@ on_tab_updatable_selection_changed( NactIPropertiesTab *instance, gint count_sel
 
 	if( st_initialized && !st_finalized ){
 
-		st_on_selection_change = TRUE;
-
 		g_object_get(
 				G_OBJECT( instance ),
 				TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
@@ -257,6 +265,8 @@ on_tab_updatable_selection_changed( NactIPropertiesTab *instance, gint count_sel
 		nact_main_tab_enable_page( NACT_MAIN_WINDOW( instance ), TAB_PROPERTIES, enable_tab );
 
 		if( enable_tab ){
+			st_on_selection_change = TRUE;
+
 			notebook = GTK_NOTEBOOK( base_window_get_widget( BASE_WINDOW( instance ), "MainNotebook" ));
 			page = gtk_notebook_get_nth_page( notebook, TAB_ACTION );
 			title_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionPropertiesTitle" );
@@ -268,38 +278,43 @@ on_tab_updatable_selection_changed( NactIPropertiesTab *instance, gint count_sel
 				gtk_label_set_label( GTK_LABEL( label_widget ), _( "_Action" ));
 				gtk_label_set_markup( GTK_LABEL( title_widget ), _( "<b>Action editable properties</b>" ));
 			}
-		}
-
-		enabled_button = get_enabled_button( instance );
-		enabled_item = item ? na_object_is_enabled( NA_OBJECT_ITEM( item )) : FALSE;
-		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( enabled_button ), enabled_item );
-		gtk_widget_set_sensitive( GTK_WIDGET( enabled_button ), item != NULL );
-		nact_gtk_utils_set_editable( GTK_OBJECT( enabled_button ), editable );
-
-		/* read-only toggle only indicates the intrinsic writability status of this item
-		 * _not_ the writability status of the provider
-		 */
-		readonly_button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ActionReadonlyButton" ));
-		gtk_toggle_button_set_active( readonly_button, item ? na_object_is_readonly( item ) : FALSE );
-		gtk_widget_set_sensitive( GTK_WIDGET( readonly_button ), item != NULL );
-		nact_gtk_utils_set_editable( GTK_OBJECT( readonly_button ), FALSE );
-
-		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionDescriptionText" );
-		buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( label_widget ));
-		label = item ? na_object_get_description( item ) : g_strdup( "" );
-		gtk_text_buffer_set_text( buffer, label, -1 );
-		g_free( label );
-		gtk_widget_set_sensitive( label_widget, item != NULL );
-
-		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionItemID" );
-		label = item ? na_object_get_id( item ) : g_strdup( "" );
-		gtk_label_set_text( GTK_LABEL( label_widget ), label );
-		g_free( label );
-		gtk_widget_set_sensitive( label_widget, item != NULL );
 
-		display_provider_name( instance, item );
-
-		st_on_selection_change = FALSE;
+			enabled_button = get_enabled_button( instance );
+			enabled_item = item ? na_object_is_enabled( NA_OBJECT_ITEM( item )) : FALSE;
+			gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( enabled_button ), enabled_item );
+			nact_gtk_utils_set_editable( GTK_OBJECT( enabled_button ), editable );
+
+			label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionDescriptionText" );
+			buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( label_widget ));
+			label = item ? na_object_get_description( item ) : g_strdup( "" );
+			gtk_text_buffer_set_text( buffer, label, -1 );
+			g_free( label );
+
+			shortcut_button = base_window_get_widget( BASE_WINDOW( instance ), "SuggestedShortcutButton" );
+			shortcut = na_object_get_shortcut( item );
+			gtk_button_set_label( GTK_BUTTON( shortcut_button ), shortcut );
+			g_free( shortcut );
+			nact_gtk_utils_set_editable( GTK_OBJECT( shortcut_button ), editable );
+
+			/* TODO: don't know how to edit a shortcut for now */
+			gtk_widget_set_sensitive( shortcut_button, FALSE );
+
+			/* read-only toggle only indicates the intrinsic writability status of this item
+			 * _not_ the writability status of the provider
+			 */
+			readonly_button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ActionReadonlyButton" ));
+			gtk_toggle_button_set_active( readonly_button, item ? na_object_is_readonly( item ) : FALSE );
+			nact_gtk_utils_set_editable( GTK_OBJECT( readonly_button ), FALSE );
+
+			label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionItemID" );
+			label = item ? na_object_get_id( item ) : g_strdup( "" );
+			gtk_label_set_text( GTK_LABEL( label_widget ), label );
+			g_free( label );
+
+			display_provider_name( instance, item );
+
+			st_on_selection_change = FALSE;
+		}
 	}
 }
 
@@ -385,13 +400,24 @@ on_description_changed( GtkTextBuffer *buffer, NactIPropertiesTab *instance )
 			TAB_UPDATABLE_PROP_SELECTED_ITEM, &edited,
 			NULL );
 
-	if( edited ){
-		gtk_text_buffer_get_start_iter( buffer, &start );
-		gtk_text_buffer_get_end_iter( buffer, &end );
-		text = gtk_text_buffer_get_text( buffer, &start, &end, TRUE );
-		na_object_set_description( edited, text );
-		g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, edited, FALSE );
-	}
+	gtk_text_buffer_get_start_iter( buffer, &start );
+	gtk_text_buffer_get_end_iter( buffer, &end );
+	text = gtk_text_buffer_get_text( buffer, &start, &end, TRUE );
+	na_object_set_description( edited, text );
+	g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, edited, FALSE );
+}
+
+static void
+on_shortcut_clicked( GtkButton *button, NactIPropertiesTab *instance )
+{
+	NAObjectItem *item;
+
+	g_object_get(
+			G_OBJECT( instance ),
+			TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
+			NULL );
+
+	/*g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, edited, FALSE );*/
 }
 
 static void



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