[Commits] [SCM] claws branch, master, updated. 3.18.0-141-g953d86931

wwp at claws-mail.org wwp at claws-mail.org
Thu Sep 16 18:42:01 CEST 2021


The branch, master has been updated
       via  953d86931c9de2c278e1c58207bec2b8bd56887c (commit)
      from  e56e77d20e2cb9117f161ff5fe039f36d14c1940 (commit)

Summary of changes:
 src/edittags.c    | 343 ++++++++++++++++++++++++++++--------------------------
 src/edittags.h    |   4 +-
 src/mainwindow.c  |  12 +-
 src/summaryview.c |   6 +-
 4 files changed, 191 insertions(+), 174 deletions(-)


- Log -----------------------------------------------------------------
commit 953d86931c9de2c278e1c58207bec2b8bd56887c
Author: paul <paul at claws-mail.org>
Date:   Thu Sep 16 16:45:27 2021 +0100

    rework tags
    
    set correct window title, depending on whether we are configuring the tags, or modifying the tags of the selected message(s); display or don't display the label in the window, depending on the same; improve the English usage; make the 'add' button sensitive, so we don't need the 'tag not set' warning if someone presses Add without setting the tag name; only show the vertidal scrollbar when needed; lots of renaming, e.g. not 'apply_window' but 'tags_window'

diff --git a/src/edittags.c b/src/edittags.c
index 8cfb61c24..38aab7d32 100644
--- a/src/edittags.c
+++ b/src/edittags.c
@@ -76,9 +76,9 @@ static gint tag_cmp_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, g
 	return res;
 }
 
-static void apply_window_create(void);
+static void tags_window_create(void);
 
-static struct TagApplyWindow
+static struct TagsWindow
 {
 	GtkWidget *window;
 	GtkWidget *hbox1;
@@ -92,48 +92,58 @@ static struct TagApplyWindow
 	gboolean has_tag_col;
 	GdkCursor *watch_cursor;
 	gboolean busy;
-} applywindow;
+} tagswindow;
 
-#define APPLYWINDOW_LOCK() {								\
-	gdk_window_set_cursor(gtk_widget_get_window(applywindow.window), applywindow.watch_cursor);	\
-	applywindow.busy = TRUE;							\
+#define TAGS_WINDOW_LOCK() {								\
+	gdk_window_set_cursor(gtk_widget_get_window(tagswindow.window), tagswindow.watch_cursor);	\
+	tagswindow.busy = TRUE;							\
 }
 
-#define APPLYWINDOW_UNLOCK() {								\
-	gdk_window_set_cursor(gtk_widget_get_window(applywindow.window), NULL);			\
-	applywindow.busy = FALSE;							\
+#define TAGS_WINDOW_UNLOCK() {								\
+	gdk_window_set_cursor(gtk_widget_get_window(tagswindow.window), NULL);			\
+	tagswindow.busy = FALSE;							\
 }
 
-static void apply_window_load_tags (void);
-static void apply_window_insert_check_column(GtkWidget *list_view);
+static void tags_window_load_tags (void);
+static void tags_window_insert_check_column(GtkWidget *list_view);
+static void new_tag_set_add_sensitivity(void);
 
-void tag_apply_open(GSList *msglist)
+void tags_window_open(GSList *msglist)
 {
-	if (!applywindow.window)
-		apply_window_create();
+	if (!tagswindow.window)
+		tags_window_create();
 
-	manage_window_set_transient(GTK_WINDOW(applywindow.window));
-	gtk_widget_grab_focus(applywindow.close_btn);
+	manage_window_set_transient(GTK_WINDOW(tagswindow.window));
+	gtk_widget_grab_focus(tagswindow.close_btn);
 	
-	applywindow.msglist = msglist;
-	apply_window_load_tags();
+	tagswindow.msglist = msglist;
+	tags_window_load_tags();
 
-	if (msglist && !applywindow.has_tag_col) {
-		apply_window_insert_check_column(applywindow.taglist);
-		applywindow.has_tag_col = TRUE;
+	if (msglist != NULL && !tagswindow.has_tag_col) {
+		tags_window_insert_check_column(tagswindow.taglist);
+		tagswindow.has_tag_col = TRUE;
 	}
-	if (!msglist && applywindow.has_tag_col) {
-		gtk_tree_view_remove_column(GTK_TREE_VIEW(applywindow.taglist),
-			gtk_tree_view_get_column(GTK_TREE_VIEW(applywindow.taglist), 0));
-		applywindow.has_tag_col = FALSE;
+	if (msglist == NULL && tagswindow.has_tag_col) {
+		gtk_tree_view_remove_column(GTK_TREE_VIEW(tagswindow.taglist),
+			gtk_tree_view_get_column(GTK_TREE_VIEW(tagswindow.taglist), 0));
+		tagswindow.has_tag_col = FALSE;
 	} 
+	if (msglist == NULL) {
+		gtk_widget_hide(tagswindow.label);
+		gtk_window_set_title(GTK_WINDOW(tagswindow.window),
+				     C_("Window title", "Tags configuration"));
+	} else {
+		gtk_widget_show(tagswindow.label);
+		gtk_window_set_title(GTK_WINDOW(tagswindow.window),
+				     C_("Window title", "Modify tags"));
+	}
 
-	gtk_widget_show(applywindow.window);
-	gtk_widget_grab_focus(applywindow.taglist);
-	gtk_window_set_modal(GTK_WINDOW(applywindow.window), TRUE);
+	gtk_widget_show(tagswindow.window);
+	gtk_widget_grab_focus(tagswindow.taglist);
+	gtk_window_set_modal(GTK_WINDOW(tagswindow.window), TRUE);
 }
 
-static GtkListStore* apply_window_create_data_store(void)
+static GtkListStore* tags_window_create_data_store(void)
 {
 	GtkListStore *store = gtk_list_store_new(N_TAG_EDIT_COLUMNS,
 				  G_TYPE_BOOLEAN,
@@ -149,14 +159,14 @@ static GtkListStore* apply_window_create_data_store(void)
 	return store;
 }
 
-static void tag_apply_selected_toggled(GtkCellRendererToggle *widget,
+static void tags_selected_toggled(GtkCellRendererToggle *widget,
 		gchar *path,
 		GtkWidget *list_view);
-static void tag_apply_selected_edited(GtkCellRendererText *widget,
+static void tags_selected_edited(GtkCellRendererText *widget,
 		gchar *arg1, gchar *arg2,
 		GtkWidget *list_view);
 
-static void apply_window_insert_check_column(GtkWidget *list_view)
+static void tags_window_insert_check_column(GtkWidget *list_view)
 {
 	GtkTreeViewColumn *column;
 	GtkCellRenderer *renderer;
@@ -175,11 +185,11 @@ static void apply_window_insert_check_column(GtkWidget *list_view)
 	gtk_tree_view_column_set_alignment (column, 0.5);
 	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),
+			 G_CALLBACK(tags_selected_toggled),
 			 list_view);
 }
 
-static void apply_window_create_list_view_columns(GtkWidget *list_view)
+static void tags_window_create_list_view_columns(GtkWidget *list_view)
 {
 	GtkTreeViewColumn *column;
 	GtkCellRenderer *renderer;
@@ -197,22 +207,22 @@ static void apply_window_create_list_view_columns(GtkWidget *list_view)
 	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),
+			 G_CALLBACK(tags_selected_edited),
 			 list_view);
 
 }
 
-static GtkWidget *apply_popup_menu = NULL;
+static GtkWidget *tags_popup_menu = NULL;
 
-static void apply_popup_delete (GtkAction *action, gpointer data)
+static void tags_popup_delete (GtkAction *action, gpointer data)
 {
 	GtkTreeIter sel;
 	GtkTreeModel *model;
 	gint id;
 	SummaryView *summaryview = NULL;
 	GtkTreeSelection *selection = gtk_tree_view_get_selection
-				(GTK_TREE_VIEW(applywindow.taglist));
-	model = gtk_tree_view_get_model(GTK_TREE_VIEW(applywindow.taglist));
+				(GTK_TREE_VIEW(tagswindow.taglist));
+	model = gtk_tree_view_get_model(GTK_TREE_VIEW(tagswindow.taglist));
 
 	if (!gtk_tree_selection_get_selected(selection, NULL, &sel))
 		return;
@@ -223,7 +233,7 @@ static void apply_popup_delete (GtkAction *action, gpointer data)
 					 ALERTFOCUS_FIRST) != G_ALERTALTERNATE)
 		return;
 
-	APPLYWINDOW_LOCK();
+	TAGS_WINDOW_LOCK();
 
 	/* XXX: Here's the reason why we need to store the original 
 	 * pointer: we search the slist for it. */
@@ -244,10 +254,10 @@ static void apply_popup_delete (GtkAction *action, gpointer data)
 		summary_set_tag(summaryview, -id, NULL);
 	tags_remove_tag(id);
 	tags_write_tags();
-	APPLYWINDOW_UNLOCK();
+	TAGS_WINDOW_UNLOCK();
 }
 
-static void apply_popup_delete_all (GtkAction *action, gpointer data)
+static void tags_popup_delete_all (GtkAction *action, gpointer data)
 {
 	GSList *cur, *tags;
 	GtkTreeModel *model;
@@ -259,9 +269,9 @@ static void apply_popup_delete_all (GtkAction *action, gpointer data)
 					 ALERTFOCUS_FIRST) != G_ALERTALTERNATE)
 		return;
 
-	APPLYWINDOW_LOCK();
+	TAGS_WINDOW_LOCK();
 
-	model = gtk_tree_view_get_model(GTK_TREE_VIEW(applywindow.taglist));
+	model = gtk_tree_view_get_model(GTK_TREE_VIEW(tagswindow.taglist));
 	gtk_list_store_clear(GTK_LIST_STORE(model));
 
 	if (mainwindow_get_mainwindow() != NULL)
@@ -276,22 +286,22 @@ static void apply_popup_delete_all (GtkAction *action, gpointer data)
 	g_slist_free(tags);
 	tags_write_tags();
 
-	APPLYWINDOW_UNLOCK();
+	TAGS_WINDOW_UNLOCK();
 }
 
-static GtkActionEntry apply_popup_actions[] =
+static GtkActionEntry tags_popup_actions[] =
 {
 	{ "EditTags", NULL, "EditTags", NULL, NULL, NULL },
-	{ "EditTags/Delete", NULL, N_("_Delete"), NULL, "Delete tag", G_CALLBACK(apply_popup_delete) },
-	{ "EditTags/DeleteAll", NULL, N_("Delete _all"), NULL, "Delete all tags", G_CALLBACK(apply_popup_delete_all) }
+	{ "EditTags/Delete", NULL, N_("_Delete"), NULL, "Delete tag", G_CALLBACK(tags_popup_delete) },
+	{ "EditTags/DeleteAll", NULL, N_("Delete _all"), NULL, "Delete all tags", G_CALLBACK(tags_popup_delete_all) }
 };
 
-static gint apply_list_btn_pressed(GtkWidget *widget, GdkEventButton *event,
-				    GtkTreeView *list_view)
+static gint tags_list_btn_pressed(GtkWidget *widget, GdkEventButton *event,
+				  GtkTreeView *list_view)
 {
 	GtkUIManager *gui_manager = gtkut_ui_manager();
 
-	if (applywindow.busy)
+	if (tagswindow.busy)
 		return FALSE;
 
 	if (event && event->button == 3) {
@@ -299,9 +309,9 @@ static gint apply_list_btn_pressed(GtkWidget *widget, GdkEventButton *event,
 		GtkTreeIter iter;
 		gboolean non_empty;
 
-		if (!apply_popup_menu) {
-			(void) cm_menu_create_action_group("EditTags", apply_popup_actions,
-					G_N_ELEMENTS(apply_popup_actions), (gpointer)list_view);
+		if (!tags_popup_menu) {
+			(void) cm_menu_create_action_group("EditTags", tags_popup_actions,
+					G_N_ELEMENTS(tags_popup_actions), (gpointer)list_view);
 
 			MENUITEM_ADDUI("/Menus", "EditTags", "EditTags", GTK_UI_MANAGER_MENU)
 			MENUITEM_ADDUI("/Menus/EditTags", "Delete", "EditTags/Delete",
@@ -309,7 +319,7 @@ static gint apply_list_btn_pressed(GtkWidget *widget, GdkEventButton *event,
 			MENUITEM_ADDUI("/Menus/EditTags", "DeleteAll", "EditTags/DeleteAll",
 					GTK_UI_MANAGER_MENUITEM)
 
-			apply_popup_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
+			tags_popup_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
 						gtk_ui_manager_get_widget(gui_manager, "/Menus/EditTags")) );
 		}
 
@@ -318,7 +328,7 @@ static gint apply_list_btn_pressed(GtkWidget *widget, GdkEventButton *event,
 		cm_menu_set_sensitive("EditTags/Delete", non_empty);
 		cm_menu_set_sensitive("EditTags/DeleteAll", non_empty);
 
-		gtk_menu_popup(GTK_MENU(apply_popup_menu), 
+		gtk_menu_popup(GTK_MENU(tags_popup_menu), 
 			       NULL, NULL, NULL, NULL, 
 			       event->button, event->time);
 
@@ -327,7 +337,7 @@ static gint apply_list_btn_pressed(GtkWidget *widget, GdkEventButton *event,
 	return FALSE;
 }
 
-static gboolean apply_list_popup_menu(GtkWidget *widget, gpointer data)
+static gboolean tags_list_popup_menu(GtkWidget *widget, gpointer data)
 {
 	GtkTreeView *list_view = (GtkTreeView *)data;
 	GdkEventButton event;
@@ -335,18 +345,18 @@ static gboolean apply_list_popup_menu(GtkWidget *widget, gpointer data)
 	event.button = 3;
 	event.time = gtk_get_current_event_time();
 	
-	apply_list_btn_pressed(NULL, &event, list_view);
+	tags_list_btn_pressed(NULL, &event, list_view);
 
 	return TRUE;
 }
 
-static GtkWidget *apply_window_list_view_create	(void)
+static GtkWidget *tags_window_list_view_create	(void)
 {
 	GtkTreeView *list_view;
 	GtkTreeSelection *selector;
 	GtkTreeModel *model;
 
-	model = GTK_TREE_MODEL(apply_window_create_data_store());
+	model = GTK_TREE_MODEL(tags_window_create_data_store());
 	list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
 	g_object_unref(model);	
 	gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), TAG_NAME, GTK_SORT_ASCENDING);
@@ -357,43 +367,43 @@ static GtkWidget *apply_window_list_view_create	(void)
 	gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
 
 	/* create the columns */
-	apply_window_create_list_view_columns(GTK_WIDGET(list_view));
+	tags_window_create_list_view_columns(GTK_WIDGET(list_view));
 
 	g_signal_connect(G_OBJECT(list_view), "popup-menu",
-			 G_CALLBACK(apply_list_popup_menu), list_view);
+			 G_CALLBACK(tags_list_popup_menu), list_view);
 	g_signal_connect(G_OBJECT(list_view), "button-press-event",
-			G_CALLBACK(apply_list_btn_pressed), list_view);
+			G_CALLBACK(tags_list_btn_pressed), list_view);
 	return GTK_WIDGET(list_view);
 
 }
 
-static void apply_window_list_view_clear_tags(GtkWidget *list_view);
+static void tags_window_list_view_clear_tags(GtkWidget *list_view);
 
-static void apply_window_close(void) 
+static void tags_window_close(void) 
 {
-	if (applywindow.busy)
+	if (tagswindow.busy)
 		return;
 
-	if (applywindow.msglist)
-		g_slist_free(applywindow.msglist);
-	applywindow.msglist = NULL;
-	APPLYWINDOW_LOCK();
+	if (tagswindow.msglist)
+		g_slist_free(tagswindow.msglist);
+	tagswindow.msglist = NULL;
+	TAGS_WINDOW_LOCK();
 	main_window_reflect_tags_changes(mainwindow_get_mainwindow());
-	APPLYWINDOW_UNLOCK();
-	apply_window_list_view_clear_tags(applywindow.taglist);
-	gtk_widget_hide(applywindow.window);
-	gtk_window_set_modal(GTK_WINDOW(applywindow.window), FALSE);
+	TAGS_WINDOW_UNLOCK();
+	tags_window_list_view_clear_tags(tagswindow.taglist);
+	gtk_widget_hide(tagswindow.window);
+	gtk_window_set_modal(GTK_WINDOW(tagswindow.window), FALSE);
 }
 
-static void apply_window_close_cb(GtkWidget *widget,
+static void tags_window_close_cb(GtkWidget *widget,
 			         gpointer data) 
 {
-	apply_window_close();
+	tags_window_close();
 }
 
-static void apply_window_list_view_insert_tag(GtkWidget *list_view,
-						  GtkTreeIter *row_iter,
-						  gint tag);
+static void tags_window_list_view_insert_tag(GtkWidget *list_view,
+					     GtkTreeIter *row_iter,
+					     gint tag);
 
 typedef struct FindTagInStore {
 	gint		 tag_id;
@@ -418,9 +428,9 @@ static gboolean find_tag_in_store(GtkTreeModel *model,
 	return FALSE; 
 }
 
-static void apply_window_add_tag(void)
+static void tags_window_add_tag(void)
 {
-	gchar *new_tag = gtk_editable_get_chars(GTK_EDITABLE(applywindow.add_entry), 0, -1);
+	gchar *new_tag = gtk_editable_get_chars(GTK_EDITABLE(tagswindow.add_entry), 0, -1);
 	g_strstrip(new_tag);
 	if (new_tag && *new_tag) {
 		gint id;
@@ -431,7 +441,7 @@ static void apply_window_add_tag(void)
 			return;
 		}
 		id = tags_get_id_for_str(new_tag);
-		APPLYWINDOW_LOCK();
+		TAGS_WINDOW_LOCK();
 		if (id == -1) {
 			id = tags_add_tag(new_tag);
 			tags_write_tags();
@@ -440,78 +450,74 @@ static void apply_window_add_tag(void)
 					mainwindow_get_mainwindow()->summaryview, 
 					id, NULL);
 			main_window_reflect_tags_changes(mainwindow_get_mainwindow());
-			apply_window_list_view_insert_tag(applywindow.taglist, NULL, id);
+			tags_window_list_view_insert_tag(tagswindow.taglist, NULL, id);
 		} 
 		fis.tag_id = id;
 		fis.path = NULL;
 		gtk_tree_model_foreach(gtk_tree_view_get_model
-				(GTK_TREE_VIEW(applywindow.taglist)), 
+				(GTK_TREE_VIEW(tagswindow.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));
+				GTK_TREE_VIEW(tagswindow.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));
+			selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tagswindow.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_view_set_cursor(GTK_TREE_VIEW(tagswindow.taglist), path, NULL, FALSE);
+			tags_window_list_view_insert_tag(tagswindow.taglist, &fis.iter, id);
 			gtk_tree_path_free(path);
 		}
-		APPLYWINDOW_UNLOCK();
-	} else {
-		alertpanel_error(_("Tag is not set."));
+		TAGS_WINDOW_UNLOCK();
 	}
 	g_free(new_tag);
 }
 
-static void apply_window_add_tag_cb(GtkWidget *widget,
-			         gpointer data) 
+static void tags_window_add_tag_cb(GtkWidget *widget, gpointer data) 
 {
-	if (applywindow.busy)
+	if (tagswindow.busy)
 		return;
-	apply_window_add_tag();
-	gtk_entry_set_text(GTK_ENTRY(applywindow.add_entry), "");
-	gtk_widget_grab_focus(applywindow.taglist);
+	tags_window_add_tag();
+	gtk_entry_set_text(GTK_ENTRY(tagswindow.add_entry), "");
+	gtk_widget_grab_focus(tagswindow.taglist);
 }
 
-static void apply_window_del_tag_cb(GtkWidget *widget,
-			         gpointer data) 
+static void tags_window_del_tag_cb(GtkWidget *widget, gpointer data) 
 {
-	if (applywindow.busy)
+	if (tagswindow.busy)
 		return;
-	apply_popup_delete(NULL, NULL);
-	gtk_widget_grab_focus(applywindow.taglist);
+	tags_popup_delete(NULL, NULL);
+	gtk_widget_grab_focus(tagswindow.taglist);
 }
 
-static gboolean apply_window_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
+static gboolean tags_window_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-	if (applywindow.busy)
+	if (tagswindow.busy)
 		return FALSE;
 	if (event && event->keyval == GDK_KEY_Escape)
-		apply_window_close();
+		tags_window_close();
 	else if (event && event->keyval == GDK_KEY_Delete)
-		apply_popup_delete(NULL, NULL);
+		tags_popup_delete(NULL, NULL);
 	return FALSE;
 }
 
-static gboolean apply_window_add_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
+static gboolean tags_window_add_key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-	if (applywindow.busy)
+	if (tagswindow.busy)
 		return FALSE;
 
 	if (event && (event->keyval == GDK_KEY_KP_Enter || event->keyval == GDK_KEY_Return)) {
-		apply_window_add_tag();
-		gtk_entry_set_text(GTK_ENTRY(applywindow.add_entry), "");
-		gtk_widget_grab_focus(applywindow.taglist);
+		tags_window_add_tag();
+		gtk_entry_set_text(GTK_ENTRY(tagswindow.add_entry), "");
+		gtk_widget_grab_focus(tagswindow.taglist);
 	}
 		
 	return FALSE;
@@ -520,7 +526,7 @@ static gboolean apply_window_add_key_pressed(GtkWidget *widget, GdkEventKey *eve
 /*!
  *\brief	Save Gtk object size to prefs dataset
  */
-static void apply_window_size_allocate_cb(GtkWidget *widget,
+static void tags_window_size_allocate_cb(GtkWidget *widget,
 					 GtkAllocation *allocation)
 {
 	cm_return_if_fail(allocation != NULL);
@@ -529,7 +535,7 @@ static void apply_window_size_allocate_cb(GtkWidget *widget,
 	prefs_common.tagswin_height = allocation->height;
 }
 
-static void apply_window_create(void) 
+static void tags_window_create(void) 
 {
 	GtkWidget *window;
 	GtkWidget *hbox1;
@@ -544,21 +550,19 @@ static void apply_window_create(void)
 	GtkWidget *del_btn;
 	static GdkGeometry geometry;
 
-	window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "tag_apply_window");
-	gtk_window_set_title (GTK_WINDOW(window),
-			      C_("Dialog title", "Apply tags"));
+	window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "tags_window");
 
-	gtk_container_set_border_width (GTK_CONTAINER (window), 8);
-	gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
-	gtk_window_set_resizable(GTK_WINDOW (window), TRUE);
+	gtk_container_set_border_width(GTK_CONTAINER(window), 8);
+	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
+	gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
 	gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
 	g_signal_connect(G_OBJECT(window), "delete_event",
-			 G_CALLBACK(apply_window_close_cb), NULL);
+			 G_CALLBACK(tags_window_close_cb), NULL);
 	g_signal_connect(G_OBJECT(window), "size_allocate",
-			 G_CALLBACK(apply_window_size_allocate_cb), NULL);
+			 G_CALLBACK(tags_window_size_allocate_cb), NULL);
 	g_signal_connect(G_OBJECT(window), "key_press_event",
-			 G_CALLBACK(apply_window_key_pressed), NULL);
-	MANAGE_WINDOW_SIGNALS_CONNECT (window);
+			 G_CALLBACK(tags_window_key_pressed), NULL);
+	MANAGE_WINDOW_SIGNALS_CONNECT(window);
 
 	vbox1 = gtk_vbox_new(FALSE, 6);
 	hbox1 = gtk_hbox_new(FALSE, 6);
@@ -570,17 +574,17 @@ static void apply_window_create(void)
 	new_tag_entry = gtk_entry_new();
 	gtk_box_pack_start(GTK_BOX(hbox1), new_tag_entry, FALSE, FALSE, 0);
 	g_signal_connect(G_OBJECT(new_tag_entry), "key_press_event",
-			 G_CALLBACK(apply_window_add_key_pressed), NULL);
+			 G_CALLBACK(tags_window_add_key_pressed), NULL);
 
 	add_btn = gtk_button_new_from_stock(GTK_STOCK_ADD);
 	gtk_box_pack_start(GTK_BOX(hbox1), add_btn, FALSE, FALSE, 0);
 	CLAWS_SET_TIP(add_btn,
-			_("Create a new tag with name defined beside"));
+			_("Add the new tag"));
 
 	del_btn = gtk_button_new_from_stock(GTK_STOCK_DELETE);
 	gtk_box_pack_start(GTK_BOX(hbox1), del_btn, FALSE, FALSE, 0);
 	CLAWS_SET_TIP(del_btn,
-			_("Delete the selected tag from the list"));
+			_("Delete the selected tag"));
 
 	close_btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
 	gtk_box_pack_end(GTK_BOX(hbox1), close_btn, FALSE, FALSE, 0);
@@ -592,27 +596,28 @@ static void apply_window_create(void)
 	gtk_widget_show(del_btn);
 
 	g_signal_connect(G_OBJECT(close_btn), "clicked",
-			 G_CALLBACK(apply_window_close_cb), NULL);
+			 G_CALLBACK(tags_window_close_cb), NULL);
 	g_signal_connect(G_OBJECT(add_btn), "clicked",
-			 G_CALLBACK(apply_window_add_tag_cb), NULL);
+			 G_CALLBACK(tags_window_add_tag_cb), NULL);
 	g_signal_connect(G_OBJECT(del_btn), "clicked",
-			 G_CALLBACK(apply_window_del_tag_cb), NULL);
+			 G_CALLBACK(tags_window_del_tag_cb), NULL);
 
-	taglist = apply_window_list_view_create();
+	taglist = tags_window_list_view_create();
 	
-	label = gtk_label_new(_("Please select tags to apply/remove. Changes are immediate."));
+	label = gtk_label_new(_("Choose the tag(s) for the message(s).\n"
+				"Changes are immediately applied."));
 	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+
 	gtk_box_pack_start(GTK_BOX(vbox1), label, FALSE, TRUE, 0);
 	
 	scrolledwin = gtk_scrolled_window_new(NULL, NULL);
 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
-				       GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+				       GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 				       
 	gtk_container_add(GTK_CONTAINER(scrolledwin), taglist);
 	gtk_box_pack_start(GTK_BOX(vbox1), scrolledwin, TRUE, TRUE, 0);
 	gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, FALSE, 0);
-	
-	gtk_widget_show(label);
+
 	gtk_widget_show(scrolledwin);
 	gtk_widget_show(taglist);
 	gtk_widget_show(hbox1);
@@ -630,19 +635,23 @@ static void apply_window_create(void)
 	gtk_widget_set_size_request(window, prefs_common.tagswin_width,
 				    prefs_common.tagswin_height);
 
-	applywindow.window = window;
-	applywindow.hbox1 = hbox1;
-	applywindow.vbox1 = vbox1;
-	applywindow.label = label;
-	applywindow.taglist = taglist;
-	applywindow.close_btn = close_btn;
-	applywindow.add_btn = add_btn;
-	applywindow.add_entry = new_tag_entry;
-	applywindow.has_tag_col = FALSE;
-	applywindow.watch_cursor = gdk_cursor_new(GDK_WATCH);
+	tagswindow.window = window;
+	tagswindow.hbox1 = hbox1;
+	tagswindow.vbox1 = vbox1;
+	tagswindow.label = label;
+	tagswindow.taglist = taglist;
+	tagswindow.close_btn = close_btn;
+	tagswindow.add_btn = add_btn;
+	tagswindow.add_entry = new_tag_entry;
+	tagswindow.has_tag_col = FALSE;
+	tagswindow.watch_cursor = gdk_cursor_new(GDK_WATCH);
+
+	g_signal_connect(G_OBJECT(new_tag_entry), "changed", 
+			 G_CALLBACK(new_tag_set_add_sensitivity), NULL);
+	new_tag_set_add_sensitivity();
 }
 
-static void apply_window_list_view_clear_tags(GtkWidget *list_view)
+static void tags_window_list_view_clear_tags(GtkWidget *list_view)
 {
 	GtkListStore *list_store = GTK_LIST_STORE(gtk_tree_view_get_model
 					(GTK_TREE_VIEW(list_view)));
@@ -650,7 +659,7 @@ static void apply_window_list_view_clear_tags(GtkWidget *list_view)
 }
 
 
-static void tag_apply_selected_toggled(GtkCellRendererToggle *widget,
+static void tags_selected_toggled(GtkCellRendererToggle *widget,
 		gchar *path,
 		GtkWidget *list_view)
 {
@@ -661,7 +670,7 @@ static void tag_apply_selected_toggled(GtkCellRendererToggle *widget,
 	gint tag_id;
 	SummaryView *summaryview = NULL;
 
-	if (applywindow.busy)
+	if (tagswindow.busy)
 		return;
 
 	if (mainwindow_get_mainwindow() != NULL)
@@ -683,13 +692,13 @@ static void tag_apply_selected_toggled(GtkCellRendererToggle *widget,
 			   TAG_SELECTED_INCONSISTENT, FALSE,
 			   -1);
 	
-	APPLYWINDOW_LOCK();
+	TAGS_WINDOW_LOCK();
 	if (summaryview)
 		summary_set_tag(summaryview, set ? tag_id : -tag_id, NULL);
-	APPLYWINDOW_UNLOCK();
+	TAGS_WINDOW_UNLOCK();
 }
 
-static void tag_apply_selected_edited(GtkCellRendererText *widget,
+static void tags_selected_edited(GtkCellRendererText *widget,
 		gchar *path, gchar *new_text,
 		GtkWidget *list_view)
 {
@@ -700,7 +709,7 @@ static void tag_apply_selected_edited(GtkCellRendererText *widget,
 	SummaryView *summaryview = NULL;
 	gboolean selected;
 
-	if (applywindow.busy)
+	if (tagswindow.busy)
 		return;
 
 	if (mainwindow_get_mainwindow() != NULL)
@@ -719,7 +728,7 @@ static void tag_apply_selected_edited(GtkCellRendererText *widget,
 
 	tag_id = GPOINTER_TO_INT(tmp);
 	
-	APPLYWINDOW_LOCK();
+	TAGS_WINDOW_LOCK();
 	if (selected) {
 		if (summaryview)
 			summary_set_tag(summaryview, -tag_id, NULL);
@@ -737,12 +746,12 @@ static void tag_apply_selected_edited(GtkCellRendererText *widget,
 		if (summaryview)
 			summary_set_tag(summaryview, 0, NULL);
 	}	
-	APPLYWINDOW_UNLOCK();
+	TAGS_WINDOW_UNLOCK();
 }
 
-static void apply_window_get_selected_state(gint tag, gboolean *selected, gboolean *selected_inconsistent)
+static void tags_window_get_selected_state(gint tag, gboolean *selected, gboolean *selected_inconsistent)
 {
-	GSList *cur = applywindow.msglist;
+	GSList *cur = tagswindow.msglist;
 	gint num_mails = 0;
 	gint num_selected = 0;
 	for (; cur; cur = cur->next) {
@@ -759,9 +768,9 @@ static void apply_window_get_selected_state(gint tag, gboolean *selected, gboole
 		*selected_inconsistent = FALSE;
 }
 
-static void apply_window_list_view_insert_tag(GtkWidget *list_view,
-						  GtkTreeIter *row_iter,
-						  gint tag) 
+static void tags_window_list_view_insert_tag(GtkWidget *list_view,
+					     GtkTreeIter *row_iter,
+					     gint tag) 
 {
 	GtkTreeIter iter;
 	GtkListStore *list_store = GTK_LIST_STORE(gtk_tree_view_get_model
@@ -769,7 +778,7 @@ static void apply_window_list_view_insert_tag(GtkWidget *list_view,
 	const gchar *name = tags_get_tag(tag);
 	gboolean selected = FALSE, selected_inconsistent = FALSE;
 
-	apply_window_get_selected_state(tag, &selected, &selected_inconsistent);
+	tags_window_get_selected_state(tag, &selected, &selected_inconsistent);
 	if (row_iter == NULL) {
 		/* append new */
 		gtk_list_store_append(list_store, &iter);
@@ -789,16 +798,26 @@ static void apply_window_list_view_insert_tag(GtkWidget *list_view,
 	}
 }
 
-static void apply_window_load_tags (void) 
+static void new_tag_set_add_sensitivity()
+{
+	const gchar *newtag = gtk_entry_get_text((GtkEntry *)tagswindow.add_entry);
+	gchar *trim_text = g_strdup(newtag);
+	g_strstrip(trim_text);
+	gtk_widget_set_sensitive(tagswindow.add_btn, (*trim_text != 0));
+	g_free(trim_text);
+
+}
+
+static void tags_window_load_tags (void) 
 {
 	GSList *cur, *tags;
 	gint id;
-	apply_window_list_view_clear_tags(applywindow.taglist);
+	tags_window_list_view_clear_tags(tagswindow.taglist);
 	
 	cur = tags = tags_get_list();
 	for (; cur; cur = cur->next) {
 		id = GPOINTER_TO_INT(cur->data);
-		apply_window_list_view_insert_tag(applywindow.taglist, NULL, id);
+		tags_window_list_view_insert_tag(tagswindow.taglist, NULL, id);
 	}
 	g_slist_free(tags);
 }
diff --git a/src/edittags.h b/src/edittags.h
index dbf0354f9..e1e2e67a6 100644
--- a/src/edittags.h
+++ b/src/edittags.h
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2007-2012 the Claws Mail team
+ * Copyright (C) 2007-2021 the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,5 +22,5 @@
 
 #include <glib.h>
 
-void tag_apply_open(GSList *msglist);
+void tags_window_open(GSList *msglist);
 #endif
diff --git a/src/mainwindow.c b/src/mainwindow.c
index ef2257989..7de1f27d2 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -1235,7 +1235,7 @@ static void mainwindow_tags_menu_item_apply_tags_activate_cb(GtkWidget *widget,
 				"dont_toggle"))
 		return;
 	
-	tag_apply_open(summary_get_selection(mainwin->summaryview));	
+	tags_window_open(summary_get_selection(mainwin->summaryview));
 }
 
 static gint mainwin_tag_cmp_list(gconstpointer a, gconstpointer b)
@@ -1304,7 +1304,7 @@ static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
 		gtk_widget_show(item);
 	}
 
-	item = gtk_menu_item_new_with_label(_("Apply tags..."));
+	item = gtk_menu_item_new_with_label(_("Modify tags..."));
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 	g_signal_connect(G_OBJECT(item), "activate",
 			 G_CALLBACK(mainwindow_tags_menu_item_apply_tags_activate_cb),
@@ -1312,10 +1312,10 @@ static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
 	g_object_set_data(G_OBJECT(item), "mainwin",
 			  mainwin);
 	gtk_widget_show(item);
-	accel_path = g_strdup_printf("<ClawsTags>/ApplyTags");
+	accel_path = g_strdup_printf("<ClawsTags>/ModifyTags");
 	gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item), accel_path);
 	g_free(accel_path);
-	gtk_accel_map_add_entry("<ClawsTags>/ApplyTags", GDK_KEY_T, GDK_CONTROL_MASK|GDK_SHIFT_MASK);
+	gtk_accel_map_add_entry("<ClawsTags>/ModifyTags", GDK_KEY_T, GDK_CONTROL_MASK|GDK_SHIFT_MASK);
 	g_slist_free(orig);
 	gtk_widget_show(menu);
 	gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
@@ -5110,9 +5110,7 @@ static void prefs_actions_open_cb(GtkAction *action, gpointer data)
 
 static void prefs_tags_open_cb(GtkAction *action, gpointer data)
 {
-	MainWindow *mainwin = (MainWindow *)data;
-	GSList * list = summary_get_selected_msg_list(mainwin->summaryview);
-	tag_apply_open(list);
+	tags_window_open(NULL);
 }
 #ifdef USE_GNUTLS
 static void ssl_manager_open_cb(GtkAction *action, gpointer data)
diff --git a/src/summaryview.c b/src/summaryview.c
index d7314f941..ed999963b 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -6427,7 +6427,7 @@ static void summary_tags_menu_item_apply_tags_activate_cb(GtkWidget *widget,
 				"dont_toggle"))
 		return;
 	
-	tag_apply_open(summary_get_selection(summaryview));	
+	tags_window_open(summary_get_selection(summaryview));
 }
 
 static gint summary_tag_cmp_list(gconstpointer a, gconstpointer b)
@@ -6496,7 +6496,7 @@ static void summary_tags_menu_create(SummaryView *summaryview, gboolean refresh)
 		gtk_widget_show(item);
 	}
 
-	item = gtk_menu_item_new_with_label(_("Apply tags..."));
+	item = gtk_menu_item_new_with_label(_("Modify tags..."));
 	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 	g_signal_connect(G_OBJECT(item), "activate",
 			 G_CALLBACK(summary_tags_menu_item_apply_tags_activate_cb),
@@ -6504,7 +6504,7 @@ static void summary_tags_menu_create(SummaryView *summaryview, gboolean refresh)
 	g_object_set_data(G_OBJECT(item), "summaryview",
 			  summaryview);
 	gtk_widget_show(item);
-	accel_path = g_strdup_printf("<ClawsTags>/ApplyTags");
+	accel_path = g_strdup_printf("<ClawsTags>/ModifyTags");
 	gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item), accel_path);
 	g_free(accel_path);
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list