2007-10-25 [colin] 3.0.2cvs103
authorColin Leroy <colin@colino.net>
Thu, 25 Oct 2007 16:56:50 +0000 (16:56 +0000)
committerColin Leroy <colin@colino.net>
Thu, 25 Oct 2007 16:56:50 +0000 (16:56 +0000)
* src/editaddress.c
Add tap-and-hold on the picture, for Maemo
* src/edittags.c
* src/edittags.h
* src/mainwindow.c
* src/procmsg.c
* src/summaryview.c
* src/textview.c
Unify tag interfaces.

ChangeLog
PATCHSETS
configure.ac
src/editaddress.c
src/edittags.c
src/edittags.h
src/mainwindow.c
src/procmsg.c
src/summaryview.c
src/textview.c

index aca52f8..5fa4cae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-10-25 [colin]     3.0.2cvs103
+
+       * src/editaddress.c
+               Add tap-and-hold on the picture, for Maemo
+       * src/edittags.c
+       * src/edittags.h
+       * src/mainwindow.c
+       * src/procmsg.c
+       * src/summaryview.c
+       * src/textview.c
+               Unify tag interfaces.
+
 2007-10-25 [colin]     3.0.2cvs102
 
        * src/imap.c
index 4a78b51..4907a01 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.14.2.41 -r 1.14.2.42 src/editaddress.c;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/editaddress_other_attributes_ldap.c;  cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/editaddress_other_attributes_ldap.h;  cvs diff -u -r 1.2.2.15 -r 1.2.2.16 src/ldapctrl.c;  cvs diff -u -r 1.3.2.27 -r 1.3.2.28 src/ldapquery.c;  cvs diff -u -r 1.1.2.15 -r 1.1.2.16 src/ldapupdate.c;  ) > 3.0.2cvs100.patchset
 ( cvs diff -u -r 1.1.2.7 -r 1.1.2.8 src/edittags.c;  cvs diff -u -r 1.274.2.218 -r 1.274.2.219 src/mainwindow.c;  cvs diff -u -r 1.395.2.332 -r 1.395.2.333 src/summaryview.c;  cvs diff -u -r 1.96.2.189 -r 1.96.2.190 src/textview.c;  ) > 3.0.2cvs101.patchset
 ( cvs diff -u -r 1.179.2.195 -r 1.179.2.196 src/imap.c;  cvs diff -u -r 1.1.4.19 -r 1.1.4.20 src/etpan/imap-thread.h;  ) > 3.0.2cvs102.patchset
+( cvs diff -u -r 1.14.2.42 -r 1.14.2.43 src/editaddress.c;  cvs diff -u -r 1.1.2.8 -r 1.1.2.9 src/edittags.c;  cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/edittags.h;  cvs diff -u -r 1.274.2.219 -r 1.274.2.220 src/mainwindow.c;  cvs diff -u -r 1.150.2.104 -r 1.150.2.105 src/procmsg.c;  cvs diff -u -r 1.395.2.333 -r 1.395.2.334 src/summaryview.c;  cvs diff -u -r 1.96.2.190 -r 1.96.2.191 src/textview.c;  ) > 3.0.2cvs103.patchset
index 58e4eab..a554568 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=102
+EXTRA_VERSION=103
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 344048f..112a99e 100644 (file)
@@ -784,6 +784,18 @@ static void addressbook_edit_person_set_picture_cb(GtkWidget *widget,
        }
 }
 
+static gboolean addressbook_edit_person_picture_popup_menu(GtkWidget *widget, gpointer data)
+{
+       GdkEventButton event;
+       
+       event.button = 3;
+       event.time = gtk_get_current_event_time();
+       
+       addressbook_edit_person_set_picture_cb(NULL, &event, data);
+
+       return TRUE;
+}
+
 static void addressbook_edit_person_page_basic( gint pageNum, gchar *pageLbl ) {
        GtkWidget *vbox;
        GtkWidget *hbox;
@@ -833,6 +845,15 @@ static void addressbook_edit_person_page_basic( gint pageNum, gchar *pageLbl ) {
                GTK_NOTEBOOK( personeditdlg.notebook ),
                gtk_notebook_get_nth_page( GTK_NOTEBOOK( personeditdlg.notebook ), pageNum ), label );
        
+#ifndef MAEMO
+       g_signal_connect(G_OBJECT(ebox_picture), "popup-menu",
+                        G_CALLBACK(addressbook_edit_person_picture_popup_menu), NULL);
+#else
+       gtk_widget_tap_and_hold_setup(GTK_WIDGET(ebox_picture), NULL, NULL,
+                       GTK_TAP_AND_HOLD_NONE | GTK_TAP_AND_HOLD_NO_INTERNALS);
+       g_signal_connect(G_OBJECT(ebox_picture), "tap-and-hold",
+                        G_CALLBACK(addressbook_edit_person_picture_popup_menu), NULL);
+#endif
        g_signal_connect(G_OBJECT(ebox_picture), "button_press_event", 
                        G_CALLBACK(addressbook_edit_person_set_picture_cb), NULL);
 
index a3d0bdc..f399521 100644 (file)
 #include "gtkutils.h"
 #include "manual.h"
 
-enum {
-       PREFS_TAGS_STRING,      /*!< string pointer managed by list store, 
-                                *   and never touched or retrieved by 
-                                *   us */ 
-       PREFS_TAGS_ID,          /*!< pointer to string that is not managed by 
-                                *   the list store, and which is retrieved
-                                *   and touched by us */
-       N_PREFS_TAGS_COLUMNS
-};
-
-       
 enum {
        TAG_SELECTED,
        TAG_SELECTED_INCONSISTENT,
@@ -66,407 +55,13 @@ enum {
        N_TAG_EDIT_COLUMNS
 };
 
-static struct Tags
-{
-       GtkWidget *window;
-
-       GtkWidget *ok_btn;
-
-       GtkWidget *name_entry;
-       GtkWidget *tags_list_view;
-} tags;
-
-static int modified = FALSE;
-
-/* widget creating functions */
-static void prefs_tags_create  (MainWindow *mainwin);
-static void prefs_tags_set_dialog      (void);
-static gint prefs_tags_clist_set_row   (GtkTreeIter *row);
-
-/* callback functions */
-static void prefs_tags_register_cb     (GtkWidget      *w,
-                                        gpointer        data);
-static void prefs_tags_substitute_cb   (GtkWidget      *w,
-                                        gpointer        data);
-static void prefs_tags_delete_cb       (GtkWidget      *w,
-                                        gpointer        data);
-static gint prefs_tags_deleted         (GtkWidget      *widget,
-                                        GdkEventAny    *event,
-                                        gpointer       *data);
-static gboolean prefs_tags_key_pressed(GtkWidget       *widget,
-                                         GdkEventKey   *event,
-                                         gpointer       data);
-static void prefs_tags_ok              (GtkWidget      *w,
-                                        gpointer        data);
-
-
-static GtkListStore* prefs_tags_create_data_store      (void);
-
-static void prefs_tags_list_view_insert_tag    (GtkWidget *list_view,
-                                                        GtkTreeIter *row_iter,
-                                                        gchar *tag,
-                                                        gint id);
-static GtkWidget *prefs_tags_list_view_create  (void);
-static void prefs_tags_create_list_view_columns        (GtkWidget *list_view);
-static gboolean prefs_tags_selected                    (GtkTreeSelection *selector,
-                                                        GtkTreeModel *model, 
-                                                        GtkTreePath *path,
-                                                        gboolean currently_selected,
-                                                        gpointer data);
-
-void prefs_tags_open(MainWindow *mainwin)
-{
-       if (!tags.window)
-               prefs_tags_create(mainwin);
-
-       manage_window_set_transient(GTK_WINDOW(tags.window));
-       gtk_widget_grab_focus(tags.ok_btn);
-
-       prefs_tags_set_dialog();
-
-       gtk_widget_show(tags.window);
-}
-
-/*!
- *\brief       Save Gtk object size to prefs dataset
- */
-static void prefs_tags_size_allocate_cb(GtkWidget *widget,
-                                        GtkAllocation *allocation)
-{
-       g_return_if_fail(allocation != NULL);
-
-       prefs_common.tagswin_width = allocation->width;
-       prefs_common.tagswin_height = allocation->height;
-}
-
-static void prefs_tags_create(MainWindow *mainwin)
-{
-       GtkWidget *window;
-       GtkWidget *vbox;
-       GtkWidget *help_btn;
-       GtkWidget *ok_btn;
-       GtkWidget *confirm_area;
-
-       GtkWidget *vbox1;
-       GtkWidget *table;
-
-       GtkWidget *name_label;
-       GtkWidget *name_entry;
-
-       GtkWidget *reg_hbox;
-       GtkWidget *btn_hbox;
-       GtkWidget *arrow;
-       GtkWidget *reg_btn;
-       GtkWidget *subst_btn;
-       GtkWidget *del_btn;
-
-       GtkWidget *cond_hbox;
-       GtkWidget *cond_scrolledwin;
-       GtkWidget *cond_list_view;
-
-
-       GtkWidget *btn_vbox;
-       static GdkGeometry geometry;
-
-       debug_print("Creating tags configuration window...\n");
-
-       window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_tags");
-
-       gtk_container_set_border_width(GTK_CONTAINER (window), 8);
-       gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
-       gtk_window_set_modal(GTK_WINDOW(window), TRUE);
-       gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
-
-       vbox = gtk_vbox_new(FALSE, 6);
-       gtk_widget_show(vbox);
-       gtk_container_add(GTK_CONTAINER(window), vbox);
-
-       gtkut_stock_button_set_create_with_help(&confirm_area, &help_btn,
-                       &ok_btn, GTK_STOCK_OK,
-                       NULL, NULL,
-                       NULL, NULL);
-       gtk_widget_show(confirm_area);
-       gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
-       gtk_widget_grab_default(ok_btn);
-
-       gtk_window_set_title(GTK_WINDOW(window), _("Tags configuration"));
-       g_signal_connect(G_OBJECT(window), "delete_event",
-                        G_CALLBACK(prefs_tags_deleted), NULL);
-       g_signal_connect(G_OBJECT(window), "size_allocate",
-                        G_CALLBACK(prefs_tags_size_allocate_cb), NULL);
-       g_signal_connect(G_OBJECT(window), "key_press_event",
-                        G_CALLBACK(prefs_tags_key_pressed), NULL);
-       MANAGE_WINDOW_SIGNALS_CONNECT(window);
-       g_signal_connect(G_OBJECT(ok_btn), "clicked",
-                        G_CALLBACK(prefs_tags_ok), mainwin);
-       g_signal_connect(G_OBJECT(help_btn), "clicked",
-                        G_CALLBACK(manual_open_with_anchor_cb),
-                        MANUAL_ANCHOR_TAGS);
-
-       vbox1 = gtk_vbox_new(FALSE, VSPACING);
-       gtk_widget_show(vbox1);
-       gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0);
-       gtk_container_set_border_width(GTK_CONTAINER(vbox1), 2);
-
-       table = gtk_table_new(2, 2, FALSE);
-       gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
-       gtk_table_set_col_spacings (GTK_TABLE (table), 4);
-       gtk_widget_show(table);
-       gtk_box_pack_start (GTK_BOX (vbox1), table, FALSE, FALSE, 0);
-
-       name_label = gtk_label_new (_("Tag name"));
-       gtk_widget_show (name_label);
-       gtk_misc_set_alignment (GTK_MISC (name_label), 1, 0.5);
-       gtk_table_attach (GTK_TABLE (table), name_label, 0, 1, 0, 1,
-                         (GtkAttachOptions) (GTK_FILL),
-                         (GtkAttachOptions) (0), 0, 0);
-
-       name_entry = gtk_entry_new ();
-       gtk_widget_show (name_entry);
-       gtk_table_attach (GTK_TABLE (table), name_entry, 1, 2, 0, 1,
-                         (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
-                         (GtkAttachOptions) (0), 0, 0);
-
-       /* register / delete */
-
-       reg_hbox = gtk_hbox_new(FALSE, 4);
-       gtk_widget_show(reg_hbox);
-       gtk_box_pack_start(GTK_BOX(vbox1), reg_hbox, FALSE, FALSE, 0);
-
-       arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
-       gtk_widget_show(arrow);
-       gtk_box_pack_start(GTK_BOX(reg_hbox), arrow, FALSE, FALSE, 0);
-       gtk_widget_set_size_request(arrow, -1, 16);
-
-       btn_hbox = gtk_hbox_new(TRUE, 4);
-       gtk_widget_show(btn_hbox);
-       gtk_box_pack_start(GTK_BOX(reg_hbox), btn_hbox, FALSE, FALSE, 0);
-
-       reg_btn = gtk_button_new_from_stock(GTK_STOCK_ADD);
-       gtk_widget_show(reg_btn);
-       gtk_box_pack_start(GTK_BOX(btn_hbox), reg_btn, FALSE, TRUE, 0);
-       g_signal_connect(G_OBJECT(reg_btn), "clicked",
-                        G_CALLBACK(prefs_tags_register_cb), NULL);
-
-       subst_btn = gtkut_get_replace_btn(_("Replace"));
-       gtk_widget_show(subst_btn);
-       gtk_box_pack_start(GTK_BOX(btn_hbox), subst_btn, FALSE, TRUE, 0);
-       g_signal_connect(G_OBJECT(subst_btn), "clicked",
-                        G_CALLBACK(prefs_tags_substitute_cb),
-                        NULL);
-
-       del_btn = gtk_button_new_from_stock(GTK_STOCK_DELETE);
-       gtk_widget_show(del_btn);
-       gtk_box_pack_start(GTK_BOX(btn_hbox), del_btn, FALSE, TRUE, 0);
-       g_signal_connect(G_OBJECT(del_btn), "clicked",
-                        G_CALLBACK(prefs_tags_delete_cb), NULL);
-
-       cond_hbox = gtk_hbox_new(FALSE, 8);
-       gtk_widget_show(cond_hbox);
-       gtk_box_pack_start(GTK_BOX(vbox1), cond_hbox, TRUE, TRUE, 0);
-
-       cond_scrolledwin = gtk_scrolled_window_new(NULL, NULL);
-       gtk_widget_show(cond_scrolledwin);
-       gtk_widget_set_size_request(cond_scrolledwin, -1, 150);
-       gtk_box_pack_start(GTK_BOX(cond_hbox), cond_scrolledwin,
-                          TRUE, TRUE, 0);
-       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (cond_scrolledwin),
-                                      GTK_POLICY_AUTOMATIC,
-                                      GTK_POLICY_AUTOMATIC);
-
-       cond_list_view = prefs_tags_list_view_create();                                
-       gtk_widget_show(cond_list_view);
-       gtk_container_add(GTK_CONTAINER (cond_scrolledwin), cond_list_view);
-
-       btn_vbox = gtk_vbox_new(FALSE, 8);
-       gtk_widget_show(btn_vbox);
-       gtk_box_pack_start(GTK_BOX(cond_hbox), btn_vbox, FALSE, FALSE, 0);
-
-       if (!geometry.min_height) {
-               geometry.min_width = 486;
-               geometry.min_height = 322;
-       }
-
-       gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
-                                     GDK_HINT_MIN_SIZE);
-       gtk_widget_set_size_request(window, prefs_common.tagswin_width,
-                                   prefs_common.tagswin_height);
-
-       gtk_widget_show(window);
-
-       tags.window = window;
-       tags.ok_btn = ok_btn;
-
-       tags.name_entry = name_entry;
-
-       tags.tags_list_view = cond_list_view;
-}
-
-static void prefs_tags_set_dialog(void)
-{
-       GtkListStore *store;
-       GSList *cur, *orig;
-       GtkTreeSelection *selection;
-       GtkTreeIter iter;
-
-       store = GTK_LIST_STORE(gtk_tree_view_get_model
-                               (GTK_TREE_VIEW(tags.tags_list_view)));
-       gtk_list_store_clear(store);
-
-       for (orig = cur = tags_get_list(); cur != NULL; cur = cur->next) {
-               gint id = GPOINTER_TO_INT(cur->data);
-               gchar *tag = (gchar *) tags_get_tag(id);
-               
-               prefs_tags_list_view_insert_tag(tags.tags_list_view,
-                                                     NULL, tag, id);
-       }
-
-       g_slist_free(orig);
-       /* select first entry */
-       selection = gtk_tree_view_get_selection
-               (GTK_TREE_VIEW(tags.tags_list_view));
-       if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store),
-                                         &iter))
-               gtk_tree_selection_select_iter(selection, &iter);
-}
-
-static gint prefs_tags_clist_set_row(GtkTreeIter *row)
-{
-       gchar *tag;
-       GtkListStore *store;
-       gint id = -1;
-
-       store = GTK_LIST_STORE(gtk_tree_view_get_model
-                               (GTK_TREE_VIEW(tags.tags_list_view)));
-       
-
-       tag = gtk_editable_get_chars(GTK_EDITABLE(tags.name_entry), 0, -1);
-       g_strstrip(tag);
-       if (tag[0] == '\0') {
-               alertpanel_error(_("Tag is not set."));
-               return -1;
-       }
-
-       if (row == NULL) {
-               if ((id = tags_add_tag(tag)) != -1) {
-                       prefs_tags_list_view_insert_tag(tags.tags_list_view,
-                                             row, tag, id);
-                       tags_write_tags();
-               }
-       } else {
-               prefs_tags_list_view_insert_tag(tags.tags_list_view,
-                                     row, tag, -1);
-               tags_write_tags();
-       }
-       return 0;
-}
-
-/* callback functions */
-
-static void prefs_tags_register_cb(GtkWidget *w, gpointer data)
-{
-       prefs_tags_clist_set_row(NULL);
-       modified = FALSE;
-}
-
-static void prefs_tags_substitute_cb(GtkWidget *w, gpointer data)
-{
-       GtkTreeIter isel, inew;
-       GtkTreePath *path_sel, *path_new;
-       GtkTreeSelection *selection = gtk_tree_view_get_selection
-                                       (GTK_TREE_VIEW(tags.tags_list_view));
-       GtkTreeModel *model;                                    
-
-       if (!gtk_tree_selection_get_selected(selection, &model, &isel))
-               return;
-       if (!gtk_tree_model_get_iter_first(model, &inew))
-               return;
-
-       path_sel = gtk_tree_model_get_path(model, &isel);
-       path_new = gtk_tree_model_get_path(model, &inew);
-
-       if (path_sel && path_new 
-       &&  gtk_tree_path_compare(path_sel, path_new) != 0)
-               prefs_tags_clist_set_row(&isel);
-
-       gtk_tree_path_free(path_sel);
-       gtk_tree_path_free(path_new);
-       modified = FALSE;
-}
-
-static void prefs_tags_delete_cb(GtkWidget *w, gpointer data)
-{
-       GtkTreeIter sel;
-       GtkTreeModel *model;
-       gint id;
-
-       if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection
-                               (GTK_TREE_VIEW(tags.tags_list_view)),
-                               &model, &sel))
-               return;                         
-
-       if (alertpanel(_("Delete tag"),
-                      _("Do you really want to delete this tag?"),
-                      GTK_STOCK_CANCEL, GTK_STOCK_DELETE, NULL) != G_ALERTALTERNATE)
-               return;
-
-       /* XXX: Here's the reason why we need to store the original 
-        * pointer: we search the slist for it. */
-       gtk_tree_model_get(model, &sel,
-                          PREFS_TAGS_ID, &id,
-                          -1);
-       gtk_list_store_remove(GTK_LIST_STORE(model), &sel);
-       tags_remove_tag(id);
-       tags_write_tags();
-}
-
-static gint prefs_tags_deleted(GtkWidget *widget, GdkEventAny *event,
-                                 gpointer *data)
-{
-       prefs_tags_ok(widget, data);
-       return TRUE;
-}
-
-static gboolean prefs_tags_key_pressed(GtkWidget *widget, GdkEventKey *event,
-                                         gpointer data)
-{
-       if (event && event->keyval == GDK_Escape)
-               prefs_tags_ok(widget, data);
-       else {
-               GtkWidget *focused = gtkut_get_focused_child(
-                                       GTK_CONTAINER(widget));
-               if (focused && GTK_IS_EDITABLE(focused)) {
-                       modified = TRUE;
-               }
-       }
-       return FALSE;
-}
-
-static void prefs_tags_ok(GtkWidget *widget, gpointer data)
-{
-       if (modified && alertpanel(_("Entry not saved"),
-                                _("The entry was not saved. Close anyway?"),
-                                GTK_STOCK_CLOSE, _("+_Continue editing"),
-                                NULL) != G_ALERTDEFAULT) {
-               return;
-       }
-       modified = FALSE;
-
-       main_window_reflect_tags_changes(mainwindow_get_mainwindow());
-       gtk_widget_hide(tags.window);
-}
-
 gint tag_cmp_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata)
  {
        gchar *name1, *name2;
 
-       if (GPOINTER_TO_INT(userdata) == 0) {
-               gtk_tree_model_get(model, a, PREFS_TAGS_STRING, &name1, -1);
-               gtk_tree_model_get(model, b, PREFS_TAGS_STRING, &name2, -1);
-       } else {
-               gtk_tree_model_get(model, a, TAG_NAME, &name1, -1);
-               gtk_tree_model_get(model, b, TAG_NAME, &name2, -1);
-       }
+       gtk_tree_model_get(model, a, TAG_NAME, &name1, -1);
+       gtk_tree_model_get(model, b, TAG_NAME, &name2, -1);
+       
        if (name1 == NULL)
                return name2 == NULL ? 0:1;
        
@@ -476,125 +71,12 @@ gint tag_cmp_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer
        return g_utf8_collate(name1,name2);
 }
 
-static GtkListStore* prefs_tags_create_data_store(void)
-{
-       GtkListStore *store = gtk_list_store_new(N_PREFS_TAGS_COLUMNS,
-                                 G_TYPE_STRING,        
-                                 G_TYPE_INT,
-                                 -1);
-       GtkTreeSortable *sortable = GTK_TREE_SORTABLE(store);
-
-       gtk_tree_sortable_set_sort_func(sortable, 0, tag_cmp_func,
-                                    GINT_TO_POINTER(0), NULL);
-       return store;
-}
-
-static void prefs_tags_list_view_insert_tag(GtkWidget *list_view,
-                                                 GtkTreeIter *row_iter,
-                                                 gchar *tag,
-                                                 gint id) 
-{
-       GtkTreeIter iter;
-       GtkListStore *list_store = GTK_LIST_STORE(gtk_tree_view_get_model
-                                       (GTK_TREE_VIEW(list_view)));
-
-       if (row_iter == NULL) {
-               /* append new */
-               gtk_list_store_append(list_store, &iter);
-               gtk_list_store_set(list_store, &iter,
-                                  PREFS_TAGS_STRING, tag,
-                                  PREFS_TAGS_ID, id,
-                                  -1);
-       } else if (id == -1) {
-               /* change existing */
-               gtk_tree_model_get(GTK_TREE_MODEL(list_store), row_iter,
-                                  PREFS_TAGS_ID, &id,
-                                  -1);
-               gtk_list_store_set(list_store, row_iter,
-                                  PREFS_TAGS_STRING, tag,
-                                  PREFS_TAGS_ID, id,
-                                  -1);
-               tags_update_tag(id, tag);
-       }
-}
-
-static GtkWidget *prefs_tags_list_view_create(void)
-{
-       GtkTreeView *list_view;
-       GtkTreeSelection *selector;
-       GtkTreeModel *model;
-
-       model = GTK_TREE_MODEL(prefs_tags_create_data_store());
-       gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), PREFS_TAGS_STRING, GTK_SORT_ASCENDING);
-
-       list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
-       g_object_unref(model);  
-       
-       gtk_tree_view_set_rules_hint(list_view, prefs_common.use_stripes_everywhere);
-
-       selector = gtk_tree_view_get_selection(list_view);
-       gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
-       gtk_tree_selection_set_select_function(selector, prefs_tags_selected,
-                                              NULL, NULL);
-
-       /* create the columns */
-       prefs_tags_create_list_view_columns(GTK_WIDGET(list_view));
-
-       return GTK_WIDGET(list_view);
-}
-
-static void prefs_tags_create_list_view_columns(GtkWidget *list_view)
-{
-       GtkTreeViewColumn *column;
-       GtkCellRenderer *renderer;
-
-       renderer = gtk_cell_renderer_text_new();
-       column = gtk_tree_view_column_new_with_attributes
-               (_("Current tags"),
-                renderer,
-                "text", PREFS_TAGS_STRING,
-                NULL);
-       gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);          
-}
-
-#define ENTRY_SET_TEXT(entry, str) \
-       gtk_entry_set_text(GTK_ENTRY(entry), str ? str : "")
-
-static gboolean prefs_tags_selected(GtkTreeSelection *selector,
-                                      GtkTreeModel *model, 
-                                      GtkTreePath *path,
-                                      gboolean currently_selected,
-                                      gpointer data)
-{
-       gchar *tag;
-       GtkTreeIter iter;
-       gint id;
-
-       if (currently_selected)
-               return TRUE;
-
-       if (!gtk_tree_model_get_iter(model, &iter, path))
-               return TRUE;
-
-       gtk_tree_model_get(model, &iter, 
-                          PREFS_TAGS_ID,  &id,
-                          PREFS_TAGS_STRING, &tag,
-                          -1);
-       if (id == -1) {
-               ENTRY_SET_TEXT(tags.name_entry, "");
-               return TRUE;
-       }
-       
-       ENTRY_SET_TEXT(tags.name_entry, tag);
-
-       return TRUE;
-}
-
 static void apply_window_create(void);
 
 static struct TagApplyWindow
 {
        GtkWidget *window;
+       GtkWidget *list_view;
        GtkWidget *hbox1;
        GtkWidget *vbox1;
        GtkWidget *label;
@@ -603,14 +85,14 @@ static struct TagApplyWindow
        GtkWidget *add_entry;
        GtkWidget *add_btn;
        GSList *msglist;
+       gboolean has_tag_col;
 } applywindow;
 
 static void apply_window_load_tags (void);
+static void apply_window_insert_check_column(GtkWidget *list_view);
 
 void tag_apply_open(GSList *msglist)
 {
-       g_return_if_fail(msglist);
-
        if (!applywindow.window)
                apply_window_create();
 
@@ -620,6 +102,16 @@ void tag_apply_open(GSList *msglist)
        applywindow.msglist = msglist;
        apply_window_load_tags();
 
+       if (msglist && !applywindow.has_tag_col) {
+               apply_window_insert_check_column(applywindow.list_view);
+               applywindow.has_tag_col = TRUE;
+       }
+       if (!msglist && applywindow.has_tag_col) {
+               gtk_tree_view_remove_column(GTK_TREE_VIEW(applywindow.list_view),
+                       gtk_tree_view_get_column(GTK_TREE_VIEW(applywindow.list_view), 0));
+               applywindow.has_tag_col = FALSE;
+       } 
+
        gtk_widget_show(applywindow.window);
        gtk_widget_grab_focus(applywindow.taglist);
        gtk_window_set_modal(GTK_WINDOW(applywindow.window), TRUE);
@@ -636,7 +128,7 @@ static GtkListStore* apply_window_create_data_store(void)
        GtkTreeSortable *sortable = GTK_TREE_SORTABLE(store);
 
        gtk_tree_sortable_set_sort_func(sortable, 0, tag_cmp_func,
-                                    GINT_TO_POINTER(1), NULL);
+                                    NULL, NULL);
 
        return store;
 }
@@ -644,8 +136,11 @@ static GtkListStore* apply_window_create_data_store(void)
 static void tag_apply_selected_toggled(GtkCellRendererToggle *widget,
                gchar *path,
                GtkWidget *list_view);
+static void tag_apply_selected_edited(GtkCellRendererText *widget,
+               gchar *arg1, gchar *arg2,
+               GtkWidget *list_view);
 
-static void apply_window_create_list_view_columns(GtkWidget *list_view)
+static void apply_window_insert_check_column(GtkWidget *list_view)
 {
        GtkTreeViewColumn *column;
        GtkCellRenderer *renderer;
@@ -662,12 +157,20 @@ static void apply_window_create_list_view_columns(GtkWidget *list_view)
                 "inconsistent", TAG_SELECTED_INCONSISTENT,
                 NULL);
        gtk_tree_view_column_set_alignment (column, 0.5);
-       gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);          
+       gtk_tree_view_insert_column(GTK_TREE_VIEW(list_view), column, 0);               
        g_signal_connect(G_OBJECT(renderer), "toggled",
                         G_CALLBACK(tag_apply_selected_toggled),
                         list_view);
+}
+
+static void apply_window_create_list_view_columns(GtkWidget *list_view)
+{
+       GtkTreeViewColumn *column;
+       GtkCellRenderer *renderer;
 
        renderer = gtk_cell_renderer_text_new();
+       g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL);
+
        column = gtk_tree_view_column_new_with_attributes
                (_("Tag"),
                 renderer,
@@ -675,9 +178,12 @@ 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);
+       g_signal_connect(G_OBJECT(renderer), "edited",
+                        G_CALLBACK(tag_apply_selected_edited),
+                        list_view);
+
 }
 
 static GtkItemFactory *apply_popup_factory = NULL;
@@ -719,7 +225,6 @@ static GtkItemFactoryEntry apply_popup_entries[] =
        {N_("/_Delete"),                NULL, apply_popup_delete, 0, NULL, NULL},
 };
 
-
 static gint apply_list_btn_pressed(GtkWidget *widget, GdkEventButton *event,
                                    GtkTreeView *list_view)
 {
@@ -740,6 +245,19 @@ static gint apply_list_btn_pressed(GtkWidget *widget, GdkEventButton *event,
        return FALSE;
 }
 
+static gboolean apply_list_popup_menu(GtkWidget *widget, gpointer data)
+{
+       GtkTreeView *list_view = (GtkTreeView *)data;
+       GdkEventButton event;
+       
+       event.button = 3;
+       event.time = gtk_get_current_event_time();
+       
+       apply_list_btn_pressed(NULL, &event, list_view);
+
+       return TRUE;
+}
+
 static GtkWidget *apply_window_list_view_create        (void)
 {
        GtkTreeView *list_view;
@@ -759,6 +277,15 @@ static GtkWidget *apply_window_list_view_create    (void)
        /* create the columns */
        apply_window_create_list_view_columns(GTK_WIDGET(list_view));
 
+#ifndef MAEMO
+       g_signal_connect(G_OBJECT(list_view), "popup-menu",
+                        G_CALLBACK(apply_list_popup_menu), list_view);
+#else
+       gtk_widget_tap_and_hold_setup(GTK_WIDGET(list_view), NULL, NULL,
+                       GTK_TAP_AND_HOLD_NONE | GTK_TAP_AND_HOLD_NO_INTERNALS);
+       g_signal_connect(G_OBJECT(list_view), "tap-and-hold",
+                        G_CALLBACK(apply_list_popup_menu), list_view);
+#endif
        g_signal_connect(G_OBJECT(list_view), "button-press-event",
                        G_CALLBACK(apply_list_btn_pressed), list_view);
        return GTK_WIDGET(list_view);
@@ -767,7 +294,8 @@ static GtkWidget *apply_window_list_view_create     (void)
 
 static void apply_window_close(void) 
 {
-       g_slist_free(applywindow.msglist);
+       if (applywindow.msglist)
+               g_slist_free(applywindow.msglist);
        applywindow.msglist = NULL;
        gtk_widget_hide(applywindow.window);
        main_window_reflect_tags_changes(mainwindow_get_mainwindow());
@@ -812,6 +340,7 @@ static void apply_window_add_tag(void)
        g_strstrip(new_tag);
        if (new_tag && *new_tag) {
                gint id = tags_get_id_for_str(new_tag);
+               FindTagInStore fis;
                if (id == -1) {
                        id = tags_add_tag(new_tag);
                        tags_write_tags();
@@ -821,32 +350,30 @@ 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);
-                       }
+               } 
+               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);
        } else {
@@ -862,10 +389,19 @@ static void apply_window_add_tag_cb(GtkWidget *widget,
        gtk_widget_grab_focus(applywindow.taglist);
 }
 
+static void apply_window_del_tag_cb(GtkWidget *widget,
+                                gpointer data) 
+{
+       apply_popup_delete(NULL, 0, NULL);
+       gtk_widget_grab_focus(applywindow.taglist);
+}
+
 static gboolean apply_window_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
        if (event && event->keyval == GDK_Escape)
                apply_window_close();
+       else if (event && event->keyval == GDK_Delete)
+               apply_popup_delete(NULL, 0, NULL);
        return FALSE;
 }
 
@@ -892,6 +428,7 @@ static void apply_window_create(void)
        GtkWidget *new_tag_label;
        GtkWidget *new_tag_entry;
        GtkWidget *add_btn;
+       GtkWidget *del_btn;
 
        window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "tag_apply_window");
        gtk_window_set_title (GTK_WINDOW(window),
@@ -921,6 +458,9 @@ static void apply_window_create(void)
        add_btn = gtk_button_new_from_stock(GTK_STOCK_ADD);
        gtk_box_pack_start(GTK_BOX(hbox1), add_btn, FALSE, FALSE, 0);
        
+       del_btn = gtk_button_new_from_stock(GTK_STOCK_DELETE);
+       gtk_box_pack_start(GTK_BOX(hbox1), del_btn, FALSE, FALSE, 0);
+       
        close_btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
        gtk_box_pack_end(GTK_BOX(hbox1), close_btn, FALSE, FALSE, 0);
 
@@ -928,10 +468,14 @@ static void apply_window_create(void)
        gtk_widget_show(new_tag_entry);
        gtk_widget_show(close_btn);
        gtk_widget_show(add_btn);
+       gtk_widget_show(del_btn);
+
        g_signal_connect(G_OBJECT(close_btn), "clicked",
                         G_CALLBACK(apply_window_close_cb), NULL);
        g_signal_connect(G_OBJECT(add_btn), "clicked",
                         G_CALLBACK(apply_window_add_tag_cb), NULL);
+       g_signal_connect(G_OBJECT(del_btn), "clicked",
+                        G_CALLBACK(apply_window_del_tag_cb), NULL);
 
        taglist = apply_window_list_view_create();
        
@@ -958,6 +502,7 @@ static void apply_window_create(void)
        gtk_container_add(GTK_CONTAINER (window), vbox1);
 
        applywindow.window = window;
+       applywindow.list_view = taglist;
        applywindow.hbox1 = hbox1;
        applywindow.vbox1 = vbox1;
        applywindow.label = label;
@@ -965,6 +510,7 @@ static void apply_window_create(void)
        applywindow.close_btn = close_btn;
        applywindow.add_btn = add_btn;
        applywindow.add_entry = new_tag_entry;
+       applywindow.has_tag_col = FALSE;
 }
 
 static void apply_window_list_view_clear_tags(GtkWidget *list_view)
@@ -1009,6 +555,36 @@ static void tag_apply_selected_toggled(GtkCellRendererToggle *widget,
                summary_set_tag(summaryview, set ? tag_id : -tag_id, NULL);
 }
 
+static void tag_apply_selected_edited(GtkCellRendererText *widget,
+               gchar *path, gchar *new_text,
+               GtkWidget *list_view)
+{
+       GtkTreeIter iter;
+       GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list_view));
+       gpointer tmp;
+       gint tag_id;
+       SummaryView *summaryview = NULL;
+
+       if (mainwindow_get_mainwindow() != NULL)
+               summaryview = mainwindow_get_mainwindow()->summaryview;
+
+       if (!gtk_tree_model_get_iter_from_string(model, &iter, path))
+               return;
+
+       gtk_tree_model_get(model, &iter,
+                          TAG_DATA, &tmp,
+                          -1);
+
+       tag_id = GPOINTER_TO_INT(tmp);
+       tags_update_tag(tag_id, new_text);
+       
+       gtk_list_store_set(GTK_LIST_STORE(model), &iter,
+                          TAG_NAME, new_text,
+                          -1);
+       if (summaryview)
+               summary_set_tag(summaryview, 0, NULL);
+}
+
 static void apply_window_get_selected_state(gint tag, gboolean *selected, gboolean *selected_inconsistent)
 {
        GSList *cur = applywindow.msglist;
index f4388f6..6383972 100644 (file)
@@ -20,9 +20,7 @@
 #ifndef __EDITTAGS_H__
 #define __EDITTAGS_H__
 
-#include "mainwindow.h"
-
-void prefs_tags_open(MainWindow *mainwin);
+#include <glib.h>
 
 void tag_apply_open(GSList *msglist);
 #endif
index 50ec4c8..e992023 100644 (file)
@@ -1229,15 +1229,23 @@ static void mainwindow_tags_menu_item_apply_tags_activate_cb(GtkWidget *widget,
        tag_apply_open(summary_get_selection(mainwin->summaryview));    
 }
 
-static gint tag_cmp_list(gconstpointer a, gconstpointer b)
+static gint mainwin_tag_cmp_list(gconstpointer a, gconstpointer b)
 {
        gint id_a = GPOINTER_TO_INT(a);
        gint id_b = GPOINTER_TO_INT(b);
        const gchar *tag_a = tags_get_tag(id_a);
        const gchar *tag_b = tags_get_tag(id_b);
        
-       return strcmp2(tag_a, tag_b);
+               
+       if (tag_a == NULL)
+               return tag_b == NULL ? 0:1;
+       
+       if (tag_b == NULL)
+               return tag_a == NULL ? 0:1;
+       return g_utf8_collate(tag_a, tag_b);
 }
+
 static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
 {
        GtkWidget *label_menuitem;
@@ -1247,7 +1255,7 @@ static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
        GSList *orig = NULL;
        gboolean existing_tags = FALSE;
 
-       cur = orig = g_slist_sort(cur, tag_cmp_list);
+       cur = orig = g_slist_sort(cur, mainwin_tag_cmp_list);
 
        label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
                                                   "/Message/Tags");
@@ -4228,7 +4236,8 @@ static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
 static void prefs_tags_open_cb(MainWindow *mainwin, guint action,
                                  GtkWidget *widget)
 {
-       prefs_tags_open(mainwin);
+       GSList * list = summary_get_selected_msg_list(mainwin->summaryview);
+       tag_apply_open(list);
 }
 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
index 19336b2..0173070 100644 (file)
@@ -2416,6 +2416,9 @@ gchar *procmsg_msginfo_get_tags_str(MsgInfo *msginfo)
 
 void procmsg_msginfo_update_tags(MsgInfo *msginfo, gboolean set, gint id)
 {
+       if (id == 0)
+               return;
+
        if (!set) {
                msginfo->tags = g_slist_remove(
                                        msginfo->tags,
index fb0fedc..7744a62 100644 (file)
@@ -5589,7 +5589,13 @@ static gint summary_tag_cmp_list(gconstpointer a, gconstpointer b)
        const gchar *tag_a = tags_get_tag(id_a);
        const gchar *tag_b = tags_get_tag(id_b);
        
-       return strcmp2(tag_a, tag_b);
+       if (tag_a == NULL)
+               return tag_b == NULL ? 0:1;
+       
+       if (tag_b == NULL)
+               return tag_a == NULL ? 0:1;
+
+       return g_utf8_collate(tag_a, tag_b);
 }
 
 static void summary_tags_menu_create(SummaryView *summaryview, gboolean refresh)
index 96d8d18..5f3243e 100644 (file)
@@ -1984,6 +1984,23 @@ bail:
        
 }
 
+static gint textview_tag_cmp_list(gconstpointer a, gconstpointer b)
+{
+       gint id_a = GPOINTER_TO_INT(a);
+       gint id_b = GPOINTER_TO_INT(b);
+       const gchar *tag_a = tags_get_tag(id_a);
+       const gchar *tag_b = tags_get_tag(id_b);
+       
+       if (tag_a == NULL)
+               return tag_b == NULL ? 0:1;
+       
+       if (tag_b == NULL)
+               return tag_a == NULL ? 0:1;
+
+       return g_utf8_collate(tag_a, tag_b);
+}
+
+
 static void textview_show_tags(TextView *textview)
 {
        MsgInfo *msginfo = textview->messageview->msginfo;
@@ -1991,27 +2008,31 @@ static void textview_show_tags(TextView *textview)
        GtkTextBuffer *buffer = gtk_text_view_get_buffer(text);
        GtkTextIter iter;
        ClickableText *uri;
-       GSList *cur;
+       GSList *cur, *orig;
        gboolean found_tag = FALSE;
        
        if (!msginfo->tags)
                return;
        
-       for (cur = msginfo->tags; cur; cur = cur->next) {
+       cur = orig = g_slist_sort(g_slist_copy(msginfo->tags), textview_tag_cmp_list);
+
+       for (; cur; cur = cur->next) {
                if (tags_get_tag(GPOINTER_TO_INT(cur->data)) != NULL) {
                        found_tag = TRUE;
                        break;
                }
        }
-       if (!found_tag) 
+       if (!found_tag) {
+               g_slist_free(orig);
                return;
+       }
 
        gtk_text_buffer_get_end_iter (buffer, &iter);
        gtk_text_buffer_insert_with_tags_by_name(buffer,
                &iter, _("Tags: "), -1,
                "header_title", "header", "tags", NULL);
 
-       for (cur = msginfo->tags; cur; cur = cur->next) {
+       for (cur = orig; cur; cur = cur->next) {
                const gchar *cur_tag = tags_get_tag(GPOINTER_TO_INT(cur->data));
                if (!cur_tag)
                        continue;
@@ -2033,6 +2054,7 @@ static void textview_show_tags(TextView *textview)
                        gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, " ", 1,
                                "header", "tags", NULL);
        }
+       g_slist_free(orig);
 
        gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "\n", 1,
                "header", "tags", NULL);