diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-02-20 10:32:11 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-02-20 12:07:40 +0100 |
commit | fbf26a7d66c5ca5c83fce0c4a03ce9a1dd9c9b17 (patch) | |
tree | 9ef440a19e1ba6bd72c19b5161958804ad70f0df | |
parent | 1a8c461af2a1c6447a96a9becffb224bb64bad99 (diff) | |
download | fiv-fbf26a7d66c5ca5c83fce0c4a03ce9a1dd9c9b17.tar.gz fiv-fbf26a7d66c5ca5c83fce0c4a03ce9a1dd9c9b17.tar.xz fiv-fbf26a7d66c5ca5c83fce0c4a03ce9a1dd9c9b17.zip |
Show application icons in context menu items
-rw-r--r-- | fiv-browser.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/fiv-browser.c b/fiv-browser.c index 563898f..8f176bc 100644 --- a/fiv-browser.c +++ b/fiv-browser.c @@ -683,11 +683,29 @@ append_opener(GtkWidget *menu, GAppInfo *opener, const OpenContext *template) ctx->content_type = g_strdup(template->content_type); ctx->app_info = opener; - // It's documented that we can touch the child, if we want formatting: - // https://docs.gtk.org/gtk3/class.MenuItem.html // XXX: Would g_app_info_get_display_name() be any better? gchar *name = g_strdup_printf("Open With %s", g_app_info_get_name(opener)); + + // It's documented that we can touch the child, if we want to use markup. +#if 0 GtkWidget *item = gtk_menu_item_new_with_label(name); +#else + // GtkImageMenuItem overrides the toggle_size_request class method + // to get the image shown in the "margin"--too much work to duplicate. + G_GNUC_BEGIN_IGNORE_DEPRECATIONS; + + GtkWidget *item = gtk_image_menu_item_new_with_label(name); + GIcon *icon = g_app_info_get_icon(opener); + if (icon) { + GtkWidget *image = gtk_image_new_from_gicon(icon, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); + gtk_image_menu_item_set_always_show_image( + GTK_IMAGE_MENU_ITEM(item), TRUE); + } + + G_GNUC_END_IGNORE_DEPRECATIONS; +#endif + g_free(name); g_signal_connect_data(item, "activate", G_CALLBACK(open_context_launch), ctx, open_context_notify, 0); |