From ff29a7752c94cf9fce8894719256647925ab5eeb Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 3 May 2016 15:11:49 +0200 Subject: Remove some GTK3 warnings. (bzr r14869.1.1) --- src/widgets/icon.cpp | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'src/widgets/icon.cpp') diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 010b3a6fb..5acdc613c 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -232,8 +232,10 @@ void IconImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation) } } +// GTK3 Only, Doesn't actually seem to be used. gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) { + std::cout << "IconImpl::draw: Entrance" << std::endl; SPIcon *icon = SP_ICON(widget); if ( !icon->pb ) { fetchPixbuf( icon ); @@ -247,32 +249,34 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) if (gtk_widget_get_state_flags (GTK_WIDGET(icon)) != GTK_STATE_FLAG_NORMAL && image) { #else if (gtk_widget_get_state (GTK_WIDGET(icon)) != GTK_STATE_NORMAL && image) { + std::cout << "IconImpl::draw: Ooops! It is called in GTK2" << std::endl; #endif - GtkIconSource *source = gtk_icon_source_new(); - gtk_icon_source_set_pixbuf(source, icon->pb); - gtk_icon_source_set_size(source, GTK_ICON_SIZE_SMALL_TOOLBAR); // note: this is boilerplate and not used - gtk_icon_source_set_size_wildcarded(source, FALSE); + std::cerr << "IconImpl::draw: No image, creating fallback" << std::endl; #if GTK_CHECK_VERSION(3,0,0) - image = gtk_render_icon_pixbuf(gtk_widget_get_style_context(widget), - source, - (GtkIconSize)-1); + // image = gtk_render_icon_pixbuf(gtk_widget_get_style_context(widget), + // source, + // (GtkIconSize)-1); // gtk_render_icon_pixbuf deprecated, replaced by: - // GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); - // image = gtk_icon_theme_load_icon (icon_theme, - // name, - // 32, - // 0, - // NULL); + GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); + image = gtk_icon_theme_load_icon (icon_theme, + "gtk-image", + 32, + (GtkIconLookupFlags)0, + NULL); #else + GtkIconSource *source = gtk_icon_source_new(); + gtk_icon_source_set_pixbuf(source, icon->pb); + gtk_icon_source_set_size(source, GTK_ICON_SIZE_SMALL_TOOLBAR); // note: this is boilerplate and not used + gtk_icon_source_set_size_wildcarded(source, FALSE); image = gtk_style_render_icon(gtk_widget_get_style(widget), source, gtk_widget_get_direction(widget), (GtkStateType) gtk_widget_get_state(widget), (GtkIconSize)-1, widget, "gtk-image"); + gtk_icon_source_free(source); #endif - gtk_icon_source_free(source); unref_image = true; } @@ -1000,8 +1004,6 @@ int IconImpl::getPhysSize(int size) "inkscape-decoration" }; - GtkWidget *icon = GTK_WIDGET(g_object_new(SP_TYPE_ICON, NULL)); - for (unsigned i = 0; i < G_N_ELEMENTS(gtkSizes); ++i) { guint const val_ix = (gtkSizes[i] <= GTK_ICON_SIZE_DIALOG) ? (guint)gtkSizes[i] : (guint)Inkscape::ICON_SIZE_DECORATION; @@ -1026,7 +1028,12 @@ int IconImpl::getPhysSize(int size) // gtk_icon_size_lookup(), because themes are free to render the pixbuf however // they like, including changing the usual size." gchar const *id = INKSCAPE_ICON("document-open"); - GdkPixbuf *pb = gtk_widget_render_icon( icon, id, gtkSizes[i], NULL); + GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); + GdkPixbuf *pb = gtk_icon_theme_load_icon (icon_theme, + id, + vals[val_ix], + (GtkIconLookupFlags)0, + NULL); if (pb) { width = gdk_pixbuf_get_width(pb); height = gdk_pixbuf_get_height(pb); @@ -1042,7 +1049,6 @@ int IconImpl::getPhysSize(int size) g_object_unref(G_OBJECT(pb)); } } - //g_object_unref(icon); init = true; } -- cgit v1.2.3