From 85576d1b96e6e0793efdcc04abc228930152c4f2 Mon Sep 17 00:00:00 2001 From: Paul Mangan Date: Tue, 17 Jul 2007 11:42:09 +0000 Subject: [PATCH] 2007-07-17 [paul] 2.10.0cvs34 * src/edittags.c fix some issues with the Apply tags window: - set search column (enables autocompl in the treeview) - apply tag from "New tag" if it existed - clears New tag entry when adding it with the button Thanks to Colin --- ChangeLog | 9 +++++++++ PATCHSETS | 1 + configure.ac | 2 +- src/edittags.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6820f3d03..e4bed13cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-07-17 [paul] 2.10.0cvs34 + + * src/edittags.c + fix some issues with the Apply tags window: + - set search column (enables autocompl in the treeview) + - apply tag from "New tag" if it existed + - clears New tag entry when adding it with the button + Thanks to Colin + 2007-07-17 [paul] 2.10.0cvs33 * src/edittags.c diff --git a/PATCHSETS b/PATCHSETS index 56b4454ef..e823c507a 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -2687,3 +2687,4 @@ ( cvs diff -u -r 1.94.2.138 -r 1.94.2.139 src/messageview.c; ) > 2.10.0cvs31.patchset ( cvs diff -u -r 1.43.2.75 -r 1.43.2.76 src/toolbar.c; ) > 2.10.0cvs32.patchset ( cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/edittags.c; ) > 2.10.0cvs33.patchset +( cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/edittags.c; ) > 2.10.0cvs34.patchset diff --git a/configure.ac b/configure.ac index 4417e2bb7..88d94a80b 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=10 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=33 +EXTRA_VERSION=34 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/edittags.c b/src/edittags.c index a356b489b..4395e5c0b 100644 --- a/src/edittags.c +++ b/src/edittags.c @@ -665,6 +665,9 @@ static void apply_window_create_list_view_columns(GtkWidget *list_view) NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column); gtk_tree_view_column_set_resizable(column, TRUE); + + gtk_tree_view_set_search_column(GTK_TREE_VIEW(list_view), + TAG_NAME); } static GtkWidget *apply_window_list_view_create (void) @@ -706,6 +709,29 @@ static void apply_window_list_view_insert_tag(GtkWidget *list_view, GtkTreeIter *row_iter, gint tag); +typedef struct FindTagInStore { + gint tag_id; + GtkTreePath *path; + GtkTreeIter iter; +} FindTagInStore; + +static gboolean find_tag_in_store(GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + FindTagInStore *data) +{ + gpointer tmp; + gtk_tree_model_get(model, iter, TAG_DATA, &tmp, -1); + + if (data->tag_id == GPOINTER_TO_INT(tmp)) { + data->path = path; /* signal we found it */ + data->iter = *iter; + return TRUE; + } + + return FALSE; +} + static void apply_window_add_tag(void) { gchar *new_tag = gtk_editable_get_chars(GTK_EDITABLE(applywindow.add_entry), 0, -1); @@ -720,6 +746,32 @@ static void apply_window_add_tag(void) id, NULL); main_window_reflect_tags_changes(mainwindow_get_mainwindow()); apply_window_list_view_insert_tag(applywindow.taglist, NULL, id); + } else { + FindTagInStore fis; + fis.tag_id = id; + fis.path = NULL; + gtk_tree_model_foreach(gtk_tree_view_get_model + (GTK_TREE_VIEW(applywindow.taglist)), + (GtkTreeModelForeachFunc) find_tag_in_store, + &fis); + if (fis.path) { + GtkTreeSelection *selection; + GtkTreePath* path; + GtkTreeModel *model = gtk_tree_view_get_model( + GTK_TREE_VIEW(applywindow.taglist)); + + if (mainwindow_get_mainwindow()) + summary_set_tag( + mainwindow_get_mainwindow()->summaryview, + id, NULL); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(applywindow.taglist)); + gtk_tree_selection_select_iter(selection, &fis.iter); + path = gtk_tree_model_get_path(model, &fis.iter); + /* XXX returned path may not be valid??? create new one to be sure */ + gtk_tree_view_set_cursor(GTK_TREE_VIEW(applywindow.taglist), path, NULL, FALSE); + apply_window_list_view_insert_tag(applywindow.taglist, &fis.iter, id); + gtk_tree_path_free(path); + } } g_free(new_tag); } @@ -729,6 +781,8 @@ static void apply_window_add_tag_cb(GtkWidget *widget, gpointer data) { apply_window_add_tag(); + gtk_entry_set_text(GTK_ENTRY(applywindow.add_entry), ""); + gtk_widget_grab_focus(applywindow.taglist); } static gboolean apply_window_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data) -- 2.25.1