Why can't image from gtk_image_new_from_icon_name show in toolbar dropdown?



Hi,
When the window is too small, the toolbar will be show as a dropdown menu. when I create a image from gtk_image_new_from_icon_name, it cannot show the thumbnail when in dropdown mode. but the image create from gtk_image_new_from_pixbuf shows.

Gtk Version: 2.16.1
here is the test code for g++:

#define GTK_DISABLE_DEPRECATED
#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>

void window_destroy(GtkWidget *w, gpointer data) {
  gtk_main_quit();
}

int main(int argc, char **argv) {
  gtk_init(&argc, &argv);


  GtkWidget *w       = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  GtkWidget *vbox    = gtk_vbox_new(false, 0);
  GtkWidget *toolbar = gtk_toolbar_new(); {
    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);

    GtkIconSize size = gtk_toolbar_get_icon_size(GTK_TOOLBAR(toolbar));

    GtkToolItem *item;
    GtkWidget   *img;

    // create image from icon name
    img  = gtk_image_new_from_icon_name("tar", size);
    item = gtk_tool_button_new(img, _("A"));
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);

    int width, height; {
      gtk_icon_size_lookup(size, &width, &height);
    }

    // create image from pixbuf
    GError       *error  = NULL ;
    GtkIconTheme *icon   = gtk_icon_theme_get_default();
GdkPixbuf *pixbuf = gtk_icon_theme_load_icon(icon, "tar", width, (GtkIconLookupFlags)0, &error);
    if(!pixbuf) {
      g_message("%s", error->message);
      g_free(error);
    } else {
      img  = gtk_image_new_from_pixbuf(pixbuf);
      item = gtk_tool_button_new(img, _("B"));
      gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
      g_object_unref(pixbuf);
    }
  }

  g_signal_connect(w, "destroy", G_CALLBACK(window_destroy), NULL);

  gtk_container_add(GTK_CONTAINER(w), vbox); {
    gtk_box_pack_start(GTK_BOX(vbox), toolbar, false, true, 0);
  }
  gtk_widget_show_all(w);
  gtk_main();
  return 0;
}

Screenshots:
normal: http://www.jiangmiao.org/blog/wp-content/uploads/2010/09/1.png
dropdown: http://www.jiangmiao.org/blog/wp-content/uploads/2010/09/2.png

What's the difference between those two images?

Thanks
Miao



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]