]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Toolbox: fix black icon from Linux guests in Unity mode
authorVMware, Inc <>
Wed, 24 Feb 2010 21:55:47 +0000 (13:55 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Wed, 24 Feb 2010 21:55:47 +0000 (13:55 -0800)
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 <mvanzin@vmware.com>
open-vm-tools/toolbox/toolbox-gtk.c
open-vm-tools/toolbox/toolboxGtkInt.h
open-vm-tools/toolbox/toolboxShrink.c

index cc31dba169a5891cce5f06729a206b77f72c4b32..3c4345bdbce084da34f23669abe65b39eb73900c 100644 (file)
@@ -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;
index 9b15d6620e6bc964780c2685892d679565b9ca17..0d66e6c1235f688ddf4202bec81980148d4c8a5c 100644 (file)
@@ -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;
index 46afeea39ceebf3bcff09ad9596ab2dae8b64811..1d5dedef9e423a6a79a0fd10f01ce9db225fada1 100644 (file)
@@ -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);