[balsa/gtk4: 50/311] Various: Actually launch the default app
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk4: 50/311] Various: Actually launch the default app
- Date: Fri, 17 Dec 2021 19:53:14 +0000 (UTC)
commit 2befe31c2dc984ad999569fc0e6027d20c089d26
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Tue Jun 16 12:19:29 2020 -0400
Various: Actually launch the default app
Actually launch the default app on clicking the "Open with…" button.
* libbalsa/libbalsa-vfs.c (libbalsa_vfs_mime_button):
* libbalsa/libbalsa-vfs.h:
* src/balsa-message.c (open_with_change_state):
* src/balsa-mime-widget-callbacks.c (balsa_mime_widget_ctx_menu_launch_app),
(balsa_mime_widget_ctx_menu_cb):
* src/balsa-mime-widget-callbacks.h:
* src/balsa-mime-widget-text.c (open_with_change_state):
ChangeLog | 13 +++++++++++++
libbalsa/libbalsa-vfs.c | 15 ++++++++-------
libbalsa/libbalsa-vfs.h | 1 +
src/balsa-message.c | 2 +-
src/balsa-mime-widget-callbacks.c | 14 ++++++++++++--
src/balsa-mime-widget-callbacks.h | 5 ++++-
src/balsa-mime-widget-text.c | 2 +-
7 files changed, 40 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 044bb750c..fbcc75afa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -337,6 +337,19 @@
* src/main.c (balsa_startup_cb):
+ Various: Actually launch the default app
+
+ * libbalsa/libbalsa-vfs.c (libbalsa_vfs_mime_button):
+ * libbalsa/libbalsa-vfs.h:
+ * src/balsa-message.c (open_with_change_state):
+ * src/balsa-mime-widget-callbacks.c
+ (balsa_mime_widget_ctx_menu_launch_app),
+ (balsa_mime_widget_ctx_menu_cb):
+ * src/balsa-mime-widget-callbacks.h:
+ * src/balsa-mime-widget-text.c (open_with_change_state):
+
+2020-06-16 Peter Bloomfield <pbloomfield bellsouth net>
+
Various: Check GTK_IS_POPOVER() instead of
libbalsa_use_popover() when popping down a popover.
diff --git a/libbalsa/libbalsa-vfs.c b/libbalsa/libbalsa-vfs.c
index 06dd87e58..8cd5b1904 100644
--- a/libbalsa/libbalsa-vfs.c
+++ b/libbalsa/libbalsa-vfs.c
@@ -40,8 +40,6 @@
#define LIBBALSA_VFS_ERROR_QUARK (g_quark_from_static_string("libbalsa-vfs"))
-#define LIBBALSA_VFS_MIME_ACTION "mime_action"
-
#define GIO_INFO_ATTS \
G_FILE_ATTRIBUTE_STANDARD_TYPE "," \
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," \
@@ -678,14 +676,17 @@ libbalsa_vfs_mime_button(LibBalsaMessageBody * mime_body,
GAppInfo *app = g_app_info_get_default_for_type(content_type, FALSE);
if (app != NULL) {
- msg = g_strdup_printf(_("Open _part with %s"), g_app_info_get_name(app));
+ const gchar *app_name;
+
+ app_name = g_app_info_get_name(app);
+ msg = g_strdup_printf(_("Open _part with %s"), app_name);
button = gtk_button_new_with_mnemonic(msg);
- g_object_set_data_full(G_OBJECT(button), LIBBALSA_VFS_MIME_ACTION,
- app, g_object_unref);
g_free(msg);
- g_signal_connect(button, "clicked",
- callback, data);
+ g_object_set_data_full(G_OBJECT(button), LIBBALSA_VFS_MIME_ACTION,
+ g_strdup(app_name), g_free);
+
+ g_signal_connect(button, "clicked", callback, data);
}
return button;
diff --git a/libbalsa/libbalsa-vfs.h b/libbalsa/libbalsa-vfs.h
index c6fb560ff..0f95cb1e6 100644
--- a/libbalsa/libbalsa-vfs.h
+++ b/libbalsa/libbalsa-vfs.h
@@ -31,6 +31,7 @@
G_BEGIN_DECLS
+#define LIBBALSA_VFS_MIME_ACTION "mime-action"
/* a vfs file description as GObject */
#define LIBBALSA_TYPE_VFS (libbalsa_vfs_get_type())
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 8aa8c4587..9c76c3405 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -1846,7 +1846,7 @@ open_with_change_state(GSimpleAction *action,
const gchar *app = g_variant_get_string(parameter, NULL);
BalsaPartInfo *info = user_data;
- balsa_mime_widget_ctx_menu_cb(app, info->body);
+ balsa_mime_widget_ctx_menu_launch_app(app, info->body);
g_simple_action_set_state(action, parameter);
if (GTK_IS_POPOVER(info->popup_widget))
diff --git a/src/balsa-mime-widget-callbacks.c b/src/balsa-mime-widget-callbacks.c
index d97482dc6..cab4e9e52 100644
--- a/src/balsa-mime-widget-callbacks.c
+++ b/src/balsa-mime-widget-callbacks.c
@@ -37,8 +37,8 @@
void
-balsa_mime_widget_ctx_menu_cb(const gchar *app,
- LibBalsaMessageBody *mime_body)
+balsa_mime_widget_ctx_menu_launch_app(const gchar *app,
+ LibBalsaMessageBody *mime_body)
{
GError *err = NULL;
gboolean result;
@@ -53,6 +53,16 @@ balsa_mime_widget_ctx_menu_cb(const gchar *app,
g_clear_error(&err);
}
+void
+balsa_mime_widget_ctx_menu_cb(GtkWidget *button,
+ gpointer user_data)
+{
+ LibBalsaMessageBody *mime_body = user_data;
+ const gchar *app;
+
+ app = g_object_get_data(G_OBJECT(button), LIBBALSA_VFS_MIME_ACTION);
+ balsa_mime_widget_ctx_menu_launch_app(app, mime_body);
+}
/** Pops up a "save part" dialog for a message part.
diff --git a/src/balsa-mime-widget-callbacks.h b/src/balsa-mime-widget-callbacks.h
index 868fbf4a1..670bb78f7 100644
--- a/src/balsa-mime-widget-callbacks.h
+++ b/src/balsa-mime-widget-callbacks.h
@@ -27,7 +27,10 @@
G_BEGIN_DECLS
-void balsa_mime_widget_ctx_menu_cb(const gchar * app, LibBalsaMessageBody * mime_body);
+void balsa_mime_widget_ctx_menu_launch_app(const gchar * app,
+ LibBalsaMessageBody * mime_body);
+void balsa_mime_widget_ctx_menu_cb(GtkWidget * button,
+ gpointer user_data);
void balsa_mime_widget_ctx_menu_save(GtkWidget * parent_widget,
LibBalsaMessageBody * mime_body);
gboolean balsa_mime_widget_key_pressed(GtkEventControllerKey *controller,
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 404f01aef..0222a2f15 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -610,7 +610,7 @@ open_with_change_state(GSimpleAction *action,
const gchar *app = g_variant_get_string(parameter, NULL);
LibBalsaMessageBody *part = user_data;
- balsa_mime_widget_ctx_menu_cb(app, part);
+ balsa_mime_widget_ctx_menu_launch_app(app, part);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]