From: VMware, Inc <> Date: Wed, 24 Feb 2010 21:55:47 +0000 (-0800) Subject: Toolbox: fix black icon from Linux guests in Unity mode X-Git-Tag: 2010.02.23-236320~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71cba2f53ce3e9e2d3d36609d5813c6f549d7798;p=thirdparty%2Fopen-vm-tools.git Toolbox: fix black icon from Linux guests in Unity mode When switching to Unity mode icon for toolbox in Linux guests is mangled thusly: transparent pixels left as transparent and filled pixels are turned into black ones. With old logo it was not noticeable since boxes were done with transparent pixels so that logo outline was preserved. With the new logo consisting only of colored pixels (with the exception of couple transparent ones in the corners) the result is solid black square in place of the icon, which is not acceptable. The logo is currently attached to the window with gdk_window_set_icon. GDK documentation does not recommend using this function, suggesting gdk_window_set_icon_list() instead, which, coincidentally, fixes the color mangling issue. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/toolbox/toolbox-gtk.c b/open-vm-tools/toolbox/toolbox-gtk.c index cc31dba16..3c4345bdb 100644 --- a/open-vm-tools/toolbox/toolbox-gtk.c +++ b/open-vm-tools/toolbox/toolbox-gtk.c @@ -108,9 +108,7 @@ static int const gSignals[] = { /* * From toolboxInt.h */ -GdkPixmap* pixmap; -GdkBitmap* bitmask; -GdkColormap* colormap; +GList *gIconList; GtkWidget *optionsTimeSync; GtkWidget *scriptsApply; DblLnkLst_Links *gEventQueue; @@ -356,7 +354,7 @@ ToolsMain_MsgBox(gchar *title, // IN: dialog's title gtk_widget_show(dialog); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 10); - gdk_window_set_icon(dialog->window, NULL, pixmap, bitmask); + gdk_window_set_icon_list(dialog->window, gIconList); label = gtk_label_new (msg); gtk_widget_show(label); @@ -413,7 +411,7 @@ ToolsMain_YesNoBox(gchar *title, gchar *msg) gtk_widget_show(dialog); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 10); - gdk_window_set_icon(dialog->window, NULL, pixmap, bitmask); + gdk_window_set_icon_list(dialog->window, gIconList); gtk_signal_connect(GTK_OBJECT(dialog), "destroy", GTK_SIGNAL_FUNC(ToolsMain_YesNoBoxOnDestroy), &ret); @@ -1075,6 +1073,7 @@ main(int argc, // IN: ARRAY_SIZEOF(argv) Bool optIconify, optHelp, optVersion; struct sigaction olds[ARRAYSIZE(gSignals)]; GKeyFile *pConfDict; + GdkPixbuf *iconPixbuf; if (!VmCheck_IsVirtualWorld()) { Warning("The VMware Toolbox must be run inside a virtual machine.\n"); @@ -1190,11 +1189,14 @@ main(int argc, // IN: ARRAY_SIZEOF(argv) DefaultScreen (GDK_DISPLAY ())); } - /* Create the icon from a pixmap */ - colormap = gtk_widget_get_colormap(toolsMain); - pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL,colormap,&bitmask,NULL, - smallIcon_xpm); - gdk_window_set_icon(toolsMain->window, NULL, pixmap, bitmask); + /* + * Cast below is needed, in perfect world gdk_pixbuf_new_from_xpm_data + * should be taking 'const char * const * data', not 'const char **data'. + */ + iconPixbuf = gdk_pixbuf_new_from_xpm_data((const char**)smallIcon_xpm); + gIconList = g_list_append(gIconList, iconPixbuf); + + gdk_window_set_icon_list(toolsMain->window, gIconList); gXDisplay = GDK_WINDOW_XDISPLAY(toolsMain->window); gXRoot = RootWindow(gXDisplay, DefaultScreen(gXDisplay)); @@ -1214,8 +1216,9 @@ main(int argc, // IN: ARRAY_SIZEOF(argv) Signal_ResetGroupHandler(gSignals, olds, ARRAYSIZE(gSignals)); System_FreeNativeEnviron(gNativeEnviron); - gdk_pixmap_unref(pixmap); - gdk_bitmap_unref(bitmask); + g_list_foreach(gIconList, (GFunc)gdk_pixbuf_unref, NULL); + g_list_free(gIconList); + g_free(hlpDir); return 0; diff --git a/open-vm-tools/toolbox/toolboxGtkInt.h b/open-vm-tools/toolbox/toolboxGtkInt.h index 9b15d6620..0d66e6c12 100644 --- a/open-vm-tools/toolbox/toolboxGtkInt.h +++ b/open-vm-tools/toolbox/toolboxGtkInt.h @@ -74,9 +74,7 @@ void Devices_OnDeviceToggled(gpointer btn, gpointer data); void Pointer_SetXCursorPos(int x, int y); void Scripts_OnApply(gpointer btn, gpointer data); -extern GdkPixmap* pixmap; -extern GdkBitmap* bitmask; -extern GdkColormap* colormap; +extern GList *gIconList; extern GtkWidget *optionsTimeSync; extern DblLnkLst_Links *gEventQueue; extern GtkWidget *scriptsApply; diff --git a/open-vm-tools/toolbox/toolboxShrink.c b/open-vm-tools/toolbox/toolboxShrink.c index 46afeea39..1d5dedef9 100644 --- a/open-vm-tools/toolbox/toolboxShrink.c +++ b/open-vm-tools/toolbox/toolboxShrink.c @@ -307,7 +307,7 @@ Shrink_DoWipe(WiperPartition *part, GtkWidget* mainWnd) // IN: partition to be w gtk_window_set_modal(GTK_WINDOW(shrinkWipeDlg), TRUE); gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(shrinkWipeDlg)->vbox), 10); - gdk_window_set_icon(shrinkWipeDlg->window, NULL, pixmap, bitmask); + gdk_window_set_icon_list(shrinkWipeDlg->window, gIconList); gtk_signal_connect(GTK_OBJECT(shrinkWipeDlg), "destroy", GTK_SIGNAL_FUNC(Shrink_OnWipeDestroy), shrinkWipeDlg);