[nautilus-actions: 14/45] Collapse/expand on double-click or Enter



commit c010ba249bff1c0ba11ccc5a298d7bb9cc08e509
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Jul 19 16:26:39 2009 +0200

    Collapse/expand on double-click or Enter

 ChangeLog                     |    1 +
 src/nact/nact-iactions-list.c |   32 ++++++++++++++++++++++++++++----
 src/nact/nact-iactions-list.h |    1 +
 src/nact/nact-main-window.c   |    4 ++--
 4 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a3b46b4..f34e741 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,7 @@
 	* src/nact/nact-iactions-list.h:
 	Uses GtkSortable interface.
 	Remove set_sorted_actions API.
+	nact_iactions_list_toggle_collapse: new function.
 
 	* src/nact/nact-icommand-tab.c:
 	Disable the example label when there is no current profile.
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index be5ce4f..133464a 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -176,7 +176,7 @@ nact_iactions_list_initial_load( NactWindow *window )
 	gtk_tree_view_set_model( GTK_TREE_VIEW( widget ), tmf_model );
 	gtk_tree_view_set_enable_tree_lines( GTK_TREE_VIEW( widget ), TRUE );
 
-	/*g_object_unref( tmf_model );*/
+	g_object_unref( tmf_model );
 	g_object_unref( ts_model );
 
 	/* create visible columns on the tree view */
@@ -251,9 +251,6 @@ nact_iactions_list_fill( NactWindow *window )
 	gtk_tree_store_clear( ts_model );
 
 	GSList *actions = v_get_actions( window );
-	/*actions = g_slist_sort( actions, ( GCompareFunc ) sort_actions_by_label );
-	v_set_sorted_actions( window, actions );*/
-
 	GSList *ia;
 	/*g_debug( "%s: actions has %d elements", thisfn, g_slist_length( actions ));*/
 
@@ -440,6 +437,33 @@ nact_iactions_list_set_modified( NactWindow *window, gboolean is_modified, gbool
 {
 }
 
+/*
+ * Collapse / expand if actions has more than one profile
+ */
+void
+nact_iactions_list_toggle_collapse( NactWindow *window )
+{
+	NAObject *object = nact_iactions_list_get_selected_action( window );
+	if( NA_IS_ACTION( object )){
+		NAAction *action = NA_ACTION( object );
+		if( na_action_get_profiles_count( action ) > 1 ){
+			GtkWidget *treeview = get_actions_list_widget( window );
+			GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( treeview ));
+			GtkTreeModel *model;
+			GtkTreeIter iter;
+			if( gtk_tree_selection_get_selected( selection, &model, &iter )){
+				GtkTreePath *path = gtk_tree_model_get_path( model, &iter );
+				if( gtk_tree_view_row_expanded( GTK_TREE_VIEW( treeview ), path )){
+					gtk_tree_view_collapse_row( GTK_TREE_VIEW( treeview ), path );
+				} else {
+					gtk_tree_view_expand_row( GTK_TREE_VIEW( treeview ), path, TRUE );
+				}
+				gtk_tree_path_free( path );
+			}
+		}
+	}
+}
+
 /**
  * Does the IActionsList box support multiple selection ?
  */
diff --git a/src/nact/nact-iactions-list.h b/src/nact/nact-iactions-list.h
index 0481f8c..94cd3f8 100644
--- a/src/nact/nact-iactions-list.h
+++ b/src/nact/nact-iactions-list.h
@@ -78,6 +78,7 @@ GSList  * nact_iactions_list_get_selected_actions( NactWindow *window );
 void      nact_iactions_list_set_selection( NactWindow *window, const gchar *uuid, const gchar *label );
 void      nact_iactions_list_set_focus( NactWindow *window );
 void      nact_iactions_list_set_modified( NactWindow *window, gboolean is_modified, gboolean can_save );
+void      nact_iactions_list_toggle_collapse( NactWindow *window );
 
 void      nact_iactions_list_set_multiple_selection( NactWindow *window, gboolean multiple );
 void      nact_iactions_list_set_send_selection_changed_on_fill_list( NactWindow *window, gboolean send_message );
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 6896caf..ee9d2e7 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -656,7 +656,7 @@ on_actions_list_double_click( GtkWidget *widget, GdkEventButton *event, gpointer
 {
 	g_assert( event->type == GDK_2BUTTON_PRESS );
 
-	/*on_edit_button_clicked( NULL, user_data );*/
+	nact_iactions_list_toggle_collapse( NACT_WINDOW( user_data ));
 
 	return( TRUE );
 }
@@ -664,7 +664,7 @@ on_actions_list_double_click( GtkWidget *widget, GdkEventButton *event, gpointer
 static gboolean
 on_actions_list_enter_key_pressed( GtkWidget *widget, GdkEventKey *event, gpointer user_data )
 {
-	/*on_edit_button_clicked( NULL, user_data );*/
+	nact_iactions_list_toggle_collapse( NACT_WINDOW( user_data ));
 
 	return( TRUE );
 }



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