summaryrefslogtreecommitdiff
path: root/packages/sylpheed/files/claws-plugin-mailmbox-fixup.patch
blob: f8cce25225f005af724c6f0aeb54c5e58d968492 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
Index: mailmbox-1.14/src/plugin_gtk.c
===================================================================
--- mailmbox-1.14.orig/src/plugin_gtk.c	2008-12-04 06:18:50.000000000 +0300
+++ mailmbox-1.14/src/plugin_gtk.c	2008-12-04 06:49:40.000000000 +0300
@@ -35,39 +35,41 @@

 #include "pluginconfig.h"

-static void new_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void delete_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void rename_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void update_tree_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void remove_mailbox_cb(FolderView *folderview, guint action, GtkWidget *widget);
-static void add_mailbox(gpointer callback_data, guint callback_action, GtkWidget *widget);
-
-static GtkItemFactoryEntry claws_mailmbox_popup_entries[] =
-{
-	{N_("/Create _new folder..."),	 NULL, new_folder_cb,     0, NULL},
-	{N_("/---"),			 NULL, NULL,              0, "<Separator>"},
-	{N_("/_Rename folder..."),	 NULL, rename_folder_cb,  0, NULL},
-	{N_("/M_ove folder..."), 	 NULL, move_folder_cb,    0, NULL},
-	{N_("/Cop_y folder..."),	 NULL, move_folder_cb,    1, NULL},
-	{N_("/---"),			 NULL, NULL,              0, "<Separator>"},
-	{N_("/_Delete folder"),		 NULL, delete_folder_cb,  0, NULL},
-	{N_("/---"),			 NULL, NULL,              0, "<Separator>"},
-	{N_("/_Check for new messages"), NULL, update_tree_cb,    0, NULL},
-	{N_("/C_heck for new folders"),  NULL, update_tree_cb,    1, NULL},
-	{N_("/R_ebuild folder tree"),	 NULL, update_tree_cb,    2, NULL},
-	{N_("/---"),			 NULL, NULL, 		  0, "<Separator>"},
-	{N_("/Remove _mailbox"),	 NULL, remove_mailbox_cb, 0, NULL},
-	{N_("/---"),			 NULL, NULL, 		  0, "<Separator>"},
+static void new_folder_cb(GtkAction *action, gpointer data);
+static void delete_folder_cb(GtkAction *action, gpointer data);
+static void rename_folder_cb(GtkAction *action, gpointer data);
+static void move_folder_cb(GtkAction *action, gpointer data);
+static void update_tree_cb(GtkAction *action, gpointer data);
+static void remove_mailbox_cb(GtkAction *action, gpointer data);
+static void add_mailbox(gpointer callback_data, guint callback_action, gpointer data);
+
+static GtkActionEntry claws_mailmbox_popup_entries[] =
+{
+	{"FolderViewPopup/CreateNewFolder",	NULL, N_("/Create _new folder..."), NULL, NULL, G_CALLBACK(new_folder_cb) },
+	{"FolderViewPopup/---",			NULL, N_("/---") },
+	{"FolderViewPopup/RenameFolder",	NULL, N_("/_Rename folder..."), NULL, NULL, G_CALLBACK(rename_folder_cb) },
+	{"FolderViewPopup/MoveFolder",		NULL, N_("/M_ove folder..."), NULL, NULL, G_CALLBACK(move_folder_cb) },
+	{"FolderViewPopup/CopyFolder",		NULL, N_("/Cop_y folder..."), NULL, NULL, G_CALLBACK(move_folder_cb) },
+	{"FolderViewPopup/---",			NULL, N_("/---") },
+	{"FolderViewPopup/DeleteFolder",	NULL, N_("/_Delete folder"), NULL, NULL, G_CALLBACK(delete_folder_cb) },
+	{"FolderViewPopup/---",			NULL, N_("/---") },
+	{"FolderViewPopup/CheckNewMessages",	NULL, N_("/_Check for new messages"), NULL, NULL, G_CALLBACK(update_tree_cb) },
+	{"FolderViewPopup/CheckNewFolders",	NULL, N_("/C_heck for new folders"), NULL, NULL, G_CALLBACK(update_tree_cb) },
+	{"FolderViewPopup/RebuildfTree",	NULL, N_("/R_ebuild folder tree"), NULL, NULL, G_CALLBACK(update_tree_cb) },
+	{"FolderViewPopup/---",			NULL, N_("/---") },
+	{"FolderViewPopup/RemoveMailbox",	NULL, N_("/Remove _mailbox"), NULL, NULL, G_CALLBACK(remove_mailbox_cb) },
 };

-static void set_sensitivity(GtkItemFactory *factory, FolderItem *item);
+static void set_sensitivity(GtkUIManager *factory, FolderItem *item);

 static FolderViewPopup claws_mailmbox_popup =
 {
	"mailmbox",
	"<MailmboxFolder>",
-	NULL,
+	claws_mailmbox_popup_entries,
+	G_N_ELEMENTS(claws_mailmbox_popup_entries),
+	NULL, 0,
+	NULL, 0, 0, NULL, NULL,
	set_sensitivity
 };

@@ -85,11 +87,6 @@
	GtkItemFactory *ifactory;
	MainWindow *mainwin = mainwindow_get_mainwindow();

-	n_entries = sizeof(claws_mailmbox_popup_entries) /
-		sizeof(claws_mailmbox_popup_entries[0]);
-	for (i = 0; i < n_entries; i++)
-		claws_mailmbox_popup.entries = g_slist_append(claws_mailmbox_popup.entries, &claws_mailmbox_popup_entries[i]);
-
	folderview_register_popup(&claws_mailmbox_popup);

	ifactory = gtk_item_factory_from_widget(mainwin->menubar);
@@ -115,7 +112,7 @@
	gtk_item_factory_delete_item(ifactory, mainwindow_add_mailbox.path);
 }

-static void set_sensitivity(GtkItemFactory *factory, FolderItem *item)
+static void set_sensitivity(GtkUIManager *factory, FolderItem *item)
 {
 #define SET_SENS(name, sens) \
	menu_set_sensitive(factory, name, sens)
@@ -132,10 +129,13 @@
 #undef SET_SENS
 }

-static void update_tree_cb(FolderView *folderview, guint action,
-			   GtkWidget *widget)
+#define DO_ACTION(name, act)	{ if (!strcmp(a_name, name)) act; }
+
+static void update_tree_cb(GtkAction *action, gpointer data)
 {
+	FolderView *folderview = (FolderView *)data;
	FolderItem *item;
+	const gchar *a_name = gtk_action_get_name(action);

	item = folderview_get_selected_item(folderview);
	g_return_if_fail(item != NULL);
@@ -144,16 +144,12 @@

	g_return_if_fail(item->folder != NULL);

-	if (action == 0)
-		folderview_check_new(item->folder);
-	else if (action == 1)
-		folderview_rescan_tree(item->folder, FALSE);
-	else if (action == 2)
-		folderview_rescan_tree(item->folder, TRUE);
+	DO_ACTION("FolderViewPopup/CheckNewMessages", folderview_check_new(item->folder));
+	DO_ACTION("FolderViewPopup/CheckNewFolders", folderview_rescan_tree(item->folder, FALSE));
+	DO_ACTION("FolderViewPopup/RebuildTree", folderview_rescan_tree(item->folder, FALSE));
 }

-static void add_mailbox(gpointer callback_data, guint callback_action,
-                        GtkWidget *widget)
+static void add_mailbox(gpointer callback_data, guint callback_action, gpointer data)
 {
	MainWindow *mainwin = (MainWindow *) callback_data;
	gchar *path, *basename;
@@ -193,10 +189,10 @@
	return;
 }

-static void new_folder_cb(FolderView *folderview, guint action,
-		          GtkWidget *widget)
+static void new_folder_cb(GtkAction *action, gpointer data)
 {
-	GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+	FolderView *folderview = (FolderView *)data;
+	GtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);
	FolderItem *item;
	FolderItem *new_item;
	gchar *new_folder;
@@ -245,9 +241,10 @@
	folder_write_list();
 }

-static void remove_mailbox_cb(FolderView *folderview, guint action, GtkWidget *widget)
+static void remove_mailbox_cb(GtkAction *action, gpointer data)
 {
-	GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+	FolderView *folderview = (FolderView *)data;
+	GtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);
	GtkCTreeNode *node;
	FolderItem *item;
	gchar *name;
@@ -276,10 +273,10 @@
	folder_destroy(item->folder);
 }

-static void delete_folder_cb(FolderView *folderview, guint action,
-			     GtkWidget *widget)
+static void delete_folder_cb(GtkAction *action, gpointer data)
 {
-	GtkCTree *ctree = GTK_CTREE(folderview->ctree);
+	FolderView *folderview = (FolderView *)data;
+	GtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);
	FolderItem *item;
	gchar *message, *name;
	AlertValue avalue;
@@ -329,24 +326,41 @@

 }

-static void move_folder_cb(FolderView *folderview, guint action, GtkWidget *widget)
+static void move_folder_cb(GtkAction *action, gpointer data)
+{
+	FolderView *folderview = (FolderView *)data;
+	FolderItem *from_folder = NULL, *to_folder = NULL;
+
+	from_folder = folderview_get_selected_item(folderview);
+	if (!from_folder || from_folder->folder->klass != claws_mailmbox_get_class())
+		return;
+
+	to_folder = foldersel_folder_sel(from_folder->folder, FOLDER_SEL_MOVE, NULL, TRUE);
+	if (!to_folder)
+		return;
+
+	folderview_move_folder(folderview, from_folder, to_folder, 0);
+}
+
+static void copy_folder_cb(GtkAction *action, gpointer data)
 {
+	FolderView *folderview = (FolderView *)data;
	FolderItem *from_folder = NULL, *to_folder = NULL;

	from_folder = folderview_get_selected_item(folderview);
	if (!from_folder || from_folder->folder->klass != claws_mailmbox_get_class())
		return;

-	to_folder = foldersel_folder_sel(from_folder->folder, FOLDER_SEL_MOVE, NULL);
+	to_folder = foldersel_folder_sel(from_folder->folder, FOLDER_SEL_MOVE, NULL, TRUE);
	if (!to_folder)
		return;

-	folderview_move_folder(folderview, from_folder, to_folder, action);
+	folderview_move_folder(folderview, from_folder, to_folder, 1);
 }

-static void rename_folder_cb(FolderView *folderview, guint action,
-			     GtkWidget *widget)
+static void rename_folder_cb(GtkAction *action, gpointer data)
 {
+	FolderView *folderview = (FolderView *)data;
	FolderItem *item, *parent;
	gchar *new_folder;
	gchar *name;