[balsa/66-save-and-open-folder] add ability to open download location after download
- From: Albrecht Dreß <albrecht src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/66-save-and-open-folder] add ability to open download location after download
- Date: Fri, 21 Jan 2022 20:18:39 +0000 (UTC)
commit 63f626bdb14314f2112a53aa2fbe041e279b3510
Author: Albrecht Dreß <albrecht dress netcologne de>
Date: Fri Jan 21 21:18:17 2022 +0100
add ability to open download location after download
See issue #66.
Add an additional context menu option for opening the file manager with
the enclosing folder after saving an attachment.
Details:
- src/balsa-message: iff a default app info for 'inode/directory' is
available, add a 'Save and view' context menu item with the app info
- src/balsa-mime-widget-callbacks.[ch]: iff saving the file was
successful and an app info has been passed, launch it with the folder
Signed-off-by: Albrecht Dreß <albrecht dress netcologne de>
src/balsa-message.c | 11 +++++++++++
src/balsa-mime-widget-callbacks.c | 15 +++++++++++++++
src/balsa-mime-widget-callbacks.h | 3 +++
3 files changed, 29 insertions(+)
---
diff --git a/src/balsa-message.c b/src/balsa-message.c
index ea8d26d28..e6b23b07d 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1664,6 +1664,17 @@ part_create_menu (BalsaPartInfo* info)
G_CALLBACK(balsa_message_copy_part),
info->body);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu);
+ } else {
+ GAppInfo *app_info;
+
+ app_info = g_app_info_get_default_for_type("inode/directory", FALSE);
+ if (app_info != NULL) {
+ menu_item = gtk_menu_item_new_with_mnemonic (_("Save and _view…"));
+ g_object_set_data(G_OBJECT(menu_item), BALSA_MIME_WIDGET_CB_APPINFO, app_info);
+ g_signal_connect(menu_item, "activate",
+ G_CALLBACK (balsa_mime_widget_ctx_menu_save), info->body);
+ gtk_menu_shell_append (GTK_MENU_SHELL (info->popup_menu), menu_item);
+ }
}
gtk_widget_show_all (info->popup_menu);
diff --git a/src/balsa-mime-widget-callbacks.c b/src/balsa-mime-widget-callbacks.c
index 1ec29fc86..aebd4b1a1 100644
--- a/src/balsa-mime-widget-callbacks.c
+++ b/src/balsa-mime-widget-callbacks.c
@@ -167,6 +167,21 @@ balsa_mime_widget_ctx_menu_save(GtkWidget * parent_widget,
_("Could not save %s: %s"),
file_uri, err ? err->message : _("Unknown error"));
g_clear_error(&err);
+ } else {
+ GAppInfo *app_info;
+
+ app_info = (GAppInfo *) g_object_get_data(G_OBJECT(parent_widget),
BALSA_MIME_WIDGET_CB_APPINFO);
+ if (app_info != NULL) {
+ GList *list;
+
+ list = g_list_prepend(NULL, balsa_app.save_dir);
+ if (!g_app_info_launch_uris(app_info, list, NULL, &err)) {
+ balsa_information(LIBBALSA_INFORMATION_ERROR, _("Could not view %s: %s"),
+ file_uri, err ? err->message : _("Unknown error"));
+ g_clear_error(&err);
+ }
+ g_list_free(list);
+ }
}
}
diff --git a/src/balsa-mime-widget-callbacks.h b/src/balsa-mime-widget-callbacks.h
index c819aa4e4..c8c061c8d 100644
--- a/src/balsa-mime-widget-callbacks.h
+++ b/src/balsa-mime-widget-callbacks.h
@@ -27,6 +27,9 @@
G_BEGIN_DECLS
+#define BALSA_MIME_WIDGET_CB_APPINFO "balsa-mime-widget-appinfo"
+
+
void balsa_mime_widget_ctx_menu_cb(GtkWidget * menu_item, LibBalsaMessageBody * mime_body);
void balsa_mime_widget_ctx_menu_save(GtkWidget * parent_widget,
LibBalsaMessageBody * mime_body);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]