[balsa/popover: 10/67] Various: Adapt to MRU menu changes
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/popover: 10/67] Various: Adapt to MRU menu changes
- Date: Sun, 13 Sep 2020 16:40:32 +0000 (UTC)
commit d365cee8944654075ab790bcf40ba2e13a09a613
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Tue May 5 10:54:43 2020 -0400
Various: Adapt to MRU menu changes
src/balsa-index.c | 25 ++++++++++++++-----------
src/balsa-message.c | 12 ++++++++----
src/balsa-mime-widget-message.c | 18 ++++++++++++------
src/message-window.c | 13 ++++++++-----
4 files changed, 42 insertions(+), 26 deletions(-)
---
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 85a438310..07752951c 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -2037,14 +2037,19 @@ move_to_change_state(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- BalsaIndex *index = user_data;
- const gchar *url = g_variant_get_string(parameter, NULL);
- LibBalsaMailbox *mailbox = balsa_find_mailbox_by_url(url);
-
- if (balsa_mailbox_node_get_mailbox(index->mailbox_node) != mailbox) {
- GArray *selected = balsa_index_selected_msgnos_new(index);
- balsa_index_transfer(index, selected, mailbox, FALSE);
- balsa_index_selected_msgnos_free(index, selected);
+ BalsaIndex *bindex = user_data;
+ LibBalsaMailbox *mailbox;
+
+ mailbox =
+ balsa_mblist_mru_get_mailbox_from_variant(parameter, GTK_WIDGET(bindex));
+
+ if (mailbox != NULL) {
+ balsa_mblist_mru_add(&balsa_app.folder_mru, libbalsa_mailbox_get_url(mailbox));
+ if (mailbox != balsa_mailbox_node_get_mailbox(bindex->mailbox_node)) {
+ GArray *selected = balsa_index_selected_msgnos_new(bindex);
+ balsa_index_transfer(bindex, selected, mailbox, FALSE);
+ balsa_index_selected_msgnos_free(bindex, selected);
+ }
}
}
@@ -2109,9 +2114,7 @@ bndx_do_popup(BalsaIndex * index, const GdkEvent *event)
g_object_unref(simple);
mru_menu =
- balsa_mblist_mru_menu(GTK_WINDOW
- (gtk_widget_get_toplevel(GTK_WIDGET(index))),
- &balsa_app.folder_mru, "bndx-popup.move-to");
+ balsa_mblist_mru_menu(&balsa_app.folder_mru, "bndx-popup.move-to");
submenu = gtk_menu_new_from_model(G_MENU_MODEL(mru_menu));
g_object_unref(mru_menu);
diff --git a/src/balsa-message.c b/src/balsa-message.c
index e5625e729..85dc6fa5f 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1640,10 +1640,15 @@ copy_part_change_state(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- const gchar *url = g_variant_get_string(parameter, NULL);
BalsaPartInfo *info = user_data;
+ const gchar *url;
- balsa_message_copy_part(url, info->body);
+ url = balsa_mblist_mru_get_url_from_variant(parameter, info->popup_menu);
+
+ if (url[0] != '\0') {
+ balsa_mblist_mru_add(&balsa_app.folder_mru, url);
+ balsa_message_copy_part(url, info->body);
+ }
g_simple_action_set_state(action, parameter);
}
@@ -1689,8 +1694,7 @@ part_create_menu(BalsaMessage *balsa_message, BalsaPartInfo *info)
GMenu *submenu;
submenu =
- balsa_mblist_mru_menu(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(balsa_message))),
- &balsa_app.folder_mru, "part-menu.copy-part");
+ balsa_mblist_mru_menu(&balsa_app.folder_mru, "part-menu.copy-part");
g_menu_append_submenu(menu, _("_Copy to folder…"), G_MENU_MODEL(submenu));
}
diff --git a/src/balsa-mime-widget-message.c b/src/balsa-mime-widget-message.c
index 6189116e6..0b33c24d4 100644
--- a/src/balsa-mime-widget-message.c
+++ b/src/balsa-mime-widget-message.c
@@ -442,15 +442,20 @@ copy_change_state(GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- const gchar *url = g_variant_get_string(parameter, NULL);
LibBalsaMessageBody *part = user_data;
+ const gchar *url =
+ balsa_mblist_mru_get_url_from_variant(parameter, part->user_data);
- balsa_message_copy_part(url, part);
+ if (url[0] != '\0') {
+ balsa_mblist_mru_add(&balsa_app.folder_mru, url);
+ balsa_message_copy_part(url, part);
+ }
}
static void
bm_header_extend_popup(GtkWidget * widget, GtkMenu * menu, gpointer arg)
{
+ LibBalsaMessageBody *part = arg;
GSimpleActionGroup *simple;
static const GActionEntry header_popup_entries[] = {
{"copy", libbalsa_radio_activated, "s", "''", copy_change_state},
@@ -459,12 +464,14 @@ bm_header_extend_popup(GtkWidget * widget, GtkMenu * menu, gpointer arg)
GtkWidget *menu_item, *submenu;
GtkWidget *separator = gtk_separator_menu_item_new();
+ part->user_data = widget;
+
gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator);
gtk_widget_show(separator);
menu_item = gtk_menu_item_new_with_label(_("Reply…"));
g_signal_connect(menu_item, "activate",
G_CALLBACK(bm_header_ctx_menu_reply),
- arg);
+ part);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
gtk_widget_show(menu_item);
@@ -472,15 +479,14 @@ bm_header_extend_popup(GtkWidget * widget, GtkMenu * menu, gpointer arg)
g_action_map_add_action_entries(G_ACTION_MAP(simple),
header_popup_entries,
G_N_ELEMENTS(header_popup_entries),
- arg);
+ part);
gtk_widget_insert_action_group(widget,
"header-popup",
G_ACTION_GROUP(simple));
g_object_unref(simple);
mru_menu =
- balsa_mblist_mru_menu(GTK_WINDOW(gtk_widget_get_toplevel(widget)),
- &balsa_app.folder_mru, "header-popup.copy");
+ balsa_mblist_mru_menu(&balsa_app.folder_mru, "header-popup.copy");
submenu = gtk_menu_new_from_model(G_MENU_MODEL(mru_menu));
g_object_unref(mru_menu);
diff --git a/src/message-window.c b/src/message-window.c
index 303bcfa17..39f9ca13b 100644
--- a/src/message-window.c
+++ b/src/message-window.c
@@ -800,10 +800,14 @@ move_to_change_state(GSimpleAction *action,
gpointer user_data)
{
MessageWindow *mw = user_data;
- const gchar *url = g_variant_get_string(parameter, NULL);
- LibBalsaMailbox *mailbox = balsa_find_mailbox_by_url(url);
+ LibBalsaMailbox *mailbox;
+
+ mailbox = balsa_mblist_mru_get_mailbox_from_variant(parameter, mw->window);
- message_window_move_message(mw, mailbox);
+ if (mailbox != NULL) {
+ balsa_mblist_mru_add(&balsa_app.folder_mru, libbalsa_mailbox_get_url(mailbox));
+ message_window_move_message(mw, mailbox);
+ }
}
void
@@ -902,8 +906,7 @@ message_window_new(LibBalsaMailbox * mailbox, guint msgno)
g_object_unref(simple);
mru_menu =
- balsa_mblist_mru_menu(GTK_WINDOW(window),
- &balsa_app.folder_mru, "message-window.move-to");
+ balsa_mblist_mru_menu(&balsa_app.folder_mru, "message-window.move-to");
submenu = gtk_menu_new_from_model(G_MENU_MODEL(mru_menu));
g_object_unref(mru_menu);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]