Skip to content

Commit 9d5bb58

Browse files
Rhialtochrisbra
authored andcommitted
patch 9.1.1583: gvim window lost its icons
Problem: Since patch 9.1.1199 the gvim window no longer had _NET_WM_ICON nor WM_HINTS icon information, for example when not using a Gnome or KDE desktop (after v9.1.1199) Solution: Check if the icon theme as used in patch 1199 contains a gvim icon. If so, set the window's icon from that. Otherwise use the previous method (Olaf Seibert) fixes: #17703 closes: #17814 Signed-off-by: Olaf Seibert <rhialto@falu.nl> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent d680d40 commit 9d5bb58

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

src/gui_gtk_x11.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,6 +2704,10 @@ global_event_filter(GdkXEvent *xev,
27042704
static void
27052705
mainwin_realize(GtkWidget *widget UNUSED, gpointer data UNUSED)
27062706
{
2707+
#include "../runtime/vim16x16.xpm"
2708+
#include "../runtime/vim32x32.xpm"
2709+
#include "../runtime/vim48x48.xpm"
2710+
27072711
GdkWindow * const mainwin_win = gtk_widget_get_window(gui.mainwin);
27082712

27092713
// When started with "--echo-wid" argument, write window ID on stdout.
@@ -2718,10 +2722,32 @@ mainwin_realize(GtkWidget *widget UNUSED, gpointer data UNUSED)
27182722

27192723
if (vim_strchr(p_go, GO_ICON) != NULL)
27202724
{
2721-
/*
2722-
* Add an icon to the main window. For fun and convenience of the user.
2723-
*/
2724-
gtk_window_set_icon_name(GTK_WINDOW(gui.mainwin), "gvim");
2725+
GtkIconTheme *icon_theme;
2726+
2727+
icon_theme = gtk_icon_theme_get_default();
2728+
2729+
if (icon_theme && gtk_icon_theme_has_icon(icon_theme, "gvim"))
2730+
{
2731+
gtk_window_set_icon_name(GTK_WINDOW(gui.mainwin), "gvim");
2732+
}
2733+
else
2734+
{
2735+
/*
2736+
* Add an icon to the main window. For fun and convenience of the user.
2737+
*/
2738+
GList *icons = NULL;
2739+
2740+
icons = g_list_prepend(icons, gdk_pixbuf_new_from_xpm_data((const char **)vim16x16));
2741+
icons = g_list_prepend(icons, gdk_pixbuf_new_from_xpm_data((const char **)vim32x32));
2742+
icons = g_list_prepend(icons, gdk_pixbuf_new_from_xpm_data((const char **)vim48x48));
2743+
2744+
gtk_window_set_icon_list(GTK_WINDOW(gui.mainwin), icons);
2745+
2746+
// TODO: is this type cast OK?
2747+
g_list_foreach(icons, (GFunc)(void *)&g_object_unref, NULL);
2748+
g_list_free(icons);
2749+
}
2750+
g_object_unref(icon_theme);
27252751
}
27262752

27272753
#if !defined(USE_GNOME_SESSION)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ static char *(features[]) =
719719

720720
static int included_patches[] =
721721
{ /* Add new patch number below this line */
722+
/**/
723+
1583,
722724
/**/
723725
1582,
724726
/**/

0 commit comments

Comments
 (0)