[nautilus-actions] Optimize Folders tab insert_new_row() func
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Optimize Folders tab insert_new_row() func
- Date: Tue, 27 Oct 2009 23:11:19 +0000 (UTC)
commit a2cf0425dadb8fc20fa70d02df9c46b5c8a74364
Author: Pierre Wieser <pwieser trychlos org>
Date: Tue Oct 27 20:36:16 2009 +0100
Optimize Folders tab insert_new_row() func
ChangeLog | 3 ++
src/nact/nact-ibackground-tab.c | 43 ++++++++++----------------------------
2 files changed, 15 insertions(+), 31 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 01a7018..64eca38 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2009-10-27 Pierre Wieser <pwieser trychlos org>
+ * src/nact/nact-ibackground-tab.c (insert_new_row):
+ Optimizes because the list is sorted on uris.
+
* src/nact/nact-iadvanced-tab.c:
Implements F2, Insert and Del keyboard accelerators.
diff --git a/src/nact/nact-ibackground-tab.c b/src/nact/nact-ibackground-tab.c
index 8b61f3a..8e260f6 100644
--- a/src/nact/nact-ibackground-tab.c
+++ b/src/nact/nact-ibackground-tab.c
@@ -395,50 +395,31 @@ inline_edition( NactIBackgroundTab *instance )
g_list_free( listrows );
}
+/*
+ * the list is sorted on uri : it is no worth to try to insert a row
+ * before currently selected item...
+ */
static void
insert_new_row( NactIBackgroundTab *instance )
{
GtkTreeView *listview;
GtkTreeModel *model;
- GtkTreeSelection *selection;
- GList *listrows;
- GtkTreePath *path;
- GtkTreeIter iter, sibling;
- gboolean inserted;
+ GtkTreeIter iter;
const gchar *uri = "file:///";
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
listview = get_folders_treeview( instance );
model = gtk_tree_view_get_model( listview );
- selection = gtk_tree_view_get_selection( listview );
- listrows = gtk_tree_selection_get_selected_rows( selection, NULL );
- inserted = FALSE;
-
- if( g_list_length( listrows ) == 1 ){
- path = ( GtkTreePath * ) listrows->data;
- if( gtk_tree_model_get_iter( model, &sibling, path )){
- /* though the path of sibling is correct, the new row is always
- * inserted at path=0 !
- */
- /*g_debug( "insert_new_row: sibling=%s", gtk_tree_model_get_string_from_iter( &sibling ));*/
- gtk_list_store_insert_before( GTK_LIST_STORE( model ), &iter, &sibling );
- inserted = TRUE;
- }
- }
- if( !inserted ){
- gtk_list_store_append( GTK_LIST_STORE( model ), &iter );
- }
-
- path = gtk_tree_model_get_path( model, &iter );
- gtk_tree_view_set_cursor( listview, path, NULL, FALSE );
+ gtk_list_store_append( GTK_LIST_STORE( model ), &iter );
gtk_list_store_set( GTK_LIST_STORE( model ), &iter, BACKGROUND_URI_COLUMN, uri, -1 );
add_uri_to_folders( instance, uri );
- gtk_tree_path_free( path );
-
- g_list_foreach( listrows, ( GFunc ) gtk_tree_path_free, NULL );
- g_list_free( listrows );
- inline_edition( instance );
+ path = gtk_tree_model_get_path( model, &iter );
+ column = gtk_tree_view_get_column( listview, BACKGROUND_URI_COLUMN );
+ gtk_tree_view_set_cursor( listview, path, column, TRUE );
+ gtk_tree_path_free( path );
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]