Skip to contentSkip to conversation

ui/gtk: Set QEMU window icon

PATCH Applied Stefan Weil 4 participants 5 messages Mar 30, 2013 – Apr 12, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/gtk: Set QEMU window icon

The QEMU icon which is already used for SDL
is now also loaded by GTK.

---
 ui/gtk.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)
ui/gtk.c +13 -0
index a5a8156..c15023b 100644
@@ -1363,6 +1363,7 @@ static const DisplayChangeListenerOps dcl_ops = {
 void gtk_display_init(DisplayState *ds)
 {
     GtkDisplayState *s = g_malloc0(sizeof(*s));
+    char *filename;
 
     gtk_init(NULL, NULL);
 
@@ -1394,6 +1395,18 @@ void gtk_display_init(DisplayState *ds)
 
     gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), s->drawing_area, gtk_label_new("VGA"));
 
+    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
+    if (filename) {
+        GError *error = NULL;
+        GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, &error);
+        if (pixbuf) {
+            gtk_window_set_icon(GTK_WINDOW(s->window), pixbuf);
+        } else {
+            g_error_free(error);
+        }
+        g_free(filename);
+    }
+
     gd_create_menus(s);
 
     gd_connect_signals(s);
Signature · 1 line
1.7.10.4
#2 lore raw
In reply to Stefan Weil
Quoted 30 lines · Stefan Weil

The QEMU icon which is already used for SDL
is now also loaded by GTK.

---
 ui/gtk.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)
ui/gtk.c +6 -0
index a5a8156..c15023b 100644
@@ -1363,6 +1363,7 @@ static const DisplayChangeListenerOps dcl_ops = {
 void gtk_display_init(DisplayState *ds)
 {
     GtkDisplayState *s = g_malloc0(sizeof(*s));
+    char *filename;
 
     gtk_init(NULL, NULL);
 
@@ -1394,6 +1395,18 @@ void gtk_display_init(DisplayState *ds)
 
     gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), s->drawing_area, gtk_label_new("VGA"));
 
+    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
+    if (filename) {
+        GError *error = NULL;
+        GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, &error);
+        if (pixbuf) {

ui/gtk.c void gtk_display_init(DisplayState *ds) · line 1412

Quoted 10 lines
ui/gtk.c +7 -0
+            gtk_window_set_icon(GTK_WINDOW(s->window), pixbuf);
+        } else {
+            g_error_free(error);
+        }
+        g_free(filename);
+    }
+
     gd_create_menus(s);
 
     gd_connect_signals(s);

With gtk 2.22 I'm lacking transparency of that icon (it has a white background). The icon is fine with SDL. Is that an issue of this particular gtk version or actually a general problem with gdk_pixbuf_new_from_file?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
#3 lore raw

Am 10.04.2013 13:48, schrieb Jan Kiszka:

Quoted 47 lines · Stefan Weil
Quoted 30 lines

The QEMU icon which is already used for SDL
is now also loaded by GTK.

---
  ui/gtk.c |   13 +++++++++++++
  1 file changed, 13 insertions(+)
ui/gtk.c +6 -0
index a5a8156..c15023b 100644
@@ -1363,6 +1363,7 @@ static const DisplayChangeListenerOps dcl_ops = {
  void gtk_display_init(DisplayState *ds)
  {
      GtkDisplayState *s = g_malloc0(sizeof(*s));
+    char *filename;
 
      gtk_init(NULL, NULL);
 
@@ -1394,6 +1395,18 @@ void gtk_display_init(DisplayState *ds)
 
      gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), s->drawing_area, gtk_label_new("VGA"));
 
+    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
+    if (filename) {
+        GError *error = NULL;
+        GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename,&error);
+        if (pixbuf) {

ui/gtk.c void gtk_display_init(DisplayState *ds) · line 1412

Quoted 10 lines
ui/gtk.c +7 -0
+            gtk_window_set_icon(GTK_WINDOW(s->window), pixbuf);
+        } else {
+            g_error_free(error);
+        }
+        g_free(filename);
+    }
+
      gd_create_menus(s);
 
      gd_connect_signals(s);

With gtk 2.22 I'm lacking transparency of that icon (it has a white background). The icon is fine with SDL. Is that an issue of this particular gtk version or actually a general problem with gdk_pixbuf_new_from_file?

Quoted 1 line

Jan

I'm afraid that you won't get a transparent background as long as the image format does not support transparency.

SDL only accepts BMP files and obviously translates the white background to a transparent one.

I could have added a PNG icon for gtk, but did not do so because I thought that the BMP file looked sufficiently good (better than the default icon on my Debian hosts). There could be a GUI option which allows setting an arbitrary icon file. It would allow users to choose icons with transparency for gtk and also different icons for multiple QEMU instances.

Stefan

PS. Try the appended qemu-icon.bmp. It won't work with SDL, but show the desired result with gtk because it is not a BMP file, but a PNG file with transparent background.

#4 lore raw
Quoted 64 lines · Stefan Weil

Am 10.04.2013 13:48, schrieb Jan Kiszka:

Quoted 48 lines · Stefan Weil
Quoted 39 lines

The QEMU icon which is already used for SDL
is now also loaded by GTK.

---
  ui/gtk.c |   13 +++++++++++++
  1 file changed, 13 insertions(+)
ui/gtk.c +13 -0
index a5a8156..c15023b 100644
@@ -1363,6 +1363,7 @@ static const DisplayChangeListenerOps dcl_ops = {
  void gtk_display_init(DisplayState *ds)
  {
      GtkDisplayState *s = g_malloc0(sizeof(*s));
+    char *filename;
 
      gtk_init(NULL, NULL);
 
@@ -1394,6 +1395,18 @@ void gtk_display_init(DisplayState *ds)
 
      gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),
 s->drawing_area, gtk_label_new("VGA"));
 
+    filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
+    if (filename) {
+        GError *error = NULL;
+        GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename,&error);
+        if (pixbuf) {
+            gtk_window_set_icon(GTK_WINDOW(s->window), pixbuf);
+        } else {
+            g_error_free(error);
+        }
+        g_free(filename);
+    }
+
      gd_create_menus(s);
 
Quoted 2 lines
      gd_connect_signals(s);

With gtk 2.22 I'm lacking transparency of that icon (it has a white background). The icon is fine with SDL. Is that an issue of this particular gtk version or actually a general problem with gdk_pixbuf_new_from_file?

Quoted 1 line

Jan

I'm afraid that you won't get a transparent background as long as the image format does not support transparency.

SDL only accepts BMP files and obviously translates the white background to a transparent one.

I could have added a PNG icon for gtk, but did not do so because I thought that the BMP file looked sufficiently good (better than the default icon on my Debian hosts). There could be a GUI option which allows setting an arbitrary icon file. It would allow users to choose icons with transparency for gtk and also different icons for multiple QEMU instances.

Quoted 5 lines

Stefan

PS. Try the appended qemu-icon.bmp. It won't work with SDL, but show the desired result with gtk because it is not a BMP file, but a PNG file with transparent background.

Then why not use separate icons for both UIs (until SDL is removed)?

Jan