aboutsummaryrefslogtreecommitdiff
path: root/fiv-context-menu.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2025-11-08 18:47:51 +0100
committerPřemysl Eric Janouch <p@janouch.name>2025-11-11 19:28:45 +0100
commit690e60cd74c44ed1e2d21b27e3152856845ead28 (patch)
tree4a11dff3cec93315170c0caf9a0540c80aef8b75 /fiv-context-menu.c
parenta7ff9f220db0785e88a6013d286b5f6b92f71693 (diff)
downloadfiv-690e60cd74c44ed1e2d21b27e3152856845ead28.tar.gz
fiv-690e60cd74c44ed1e2d21b27e3152856845ead28.tar.xz
fiv-690e60cd74c44ed1e2d21b27e3152856845ead28.zip
Build an application bundle on macOSorigin/masterorigin/HEAD
This is far from done, but nonetheless constitutes a big improvement. macOS application bundles are more or less necessary for: - showing a nice icon; - having spawned off instances actually be brought to the foreground; - file associations (yet files currently do not open properly); - having a reasonable method of distribution. Also resolving a bunch of minor issues: - The context menu had duplicate items, and might needlessly end up with (null) labels.
Diffstat (limited to 'fiv-context-menu.c')
-rw-r--r--fiv-context-menu.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/fiv-context-menu.c b/fiv-context-menu.c
index 678c616..3284a2e 100644
--- a/fiv-context-menu.c
+++ b/fiv-context-menu.c
@@ -380,8 +380,11 @@ append_opener(GtkWidget *menu, GAppInfo *opener, const OpenContext *template)
ctx->app_info = opener;
// On Linux, this prefers the obsoleted X-GNOME-FullName.
- gchar *name =
- g_strdup_printf("Open With %s", g_app_info_get_display_name(opener));
+ const char *display_name = g_app_info_get_display_name(opener);
+ // Ironically, GIO reads CFBundleName and can't read CFBundleDisplayName.
+ if (!display_name)
+ display_name = g_app_info_get_executable(opener);
+ gchar *name = g_strdup_printf("Open With %s", display_name);
// It's documented that we can touch the child, if we want to use markup.
#if 0
@@ -503,8 +506,6 @@ fiv_context_menu_new(GtkWidget *widget, GFile *file)
GAppInfo *default_ =
g_app_info_get_default_for_type(ctx->content_type, FALSE);
- GList *recommended = g_app_info_get_recommended_for_type(ctx->content_type);
- GList *fallback = g_app_info_get_fallback_for_type(ctx->content_type);
GtkWidget *menu = gtk_menu_new();
if (default_) {
@@ -513,6 +514,7 @@ fiv_context_menu_new(GtkWidget *widget, GFile *file)
GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
}
+ GList *recommended = g_app_info_get_recommended_for_type(ctx->content_type);
for (GList *iter = recommended; iter; iter = iter->next) {
if (!default_ || !g_app_info_equal(iter->data, default_))
append_opener(menu, iter->data, ctx);
@@ -525,6 +527,10 @@ fiv_context_menu_new(GtkWidget *widget, GFile *file)
GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
}
+ // The implementation returns the same data for both,
+ // we'd have to filter out the recommended ones from here.
+#ifndef __APPLE__
+ GList *fallback = g_app_info_get_fallback_for_type(ctx->content_type);
for (GList *iter = fallback; iter; iter = iter->next) {
if (!default_ || !g_app_info_equal(iter->data, default_))
append_opener(menu, iter->data, ctx);
@@ -536,6 +542,7 @@ fiv_context_menu_new(GtkWidget *widget, GFile *file)
gtk_menu_shell_append(
GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
}
+#endif
GtkWidget *item = gtk_menu_item_new_with_label("Open With...");
g_signal_connect_data(item, "activate", G_CALLBACK(on_chooser_activate),