From 3ee1ba1e9a8019e98012bc77ff3953363b2fa17a Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 12 Apr 2016 12:28:18 +0200 Subject: Add option for larger icons (useful for 4K display). (bzr r14789) --- src/widgets/icon.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/widgets/icon.cpp') diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 542d16797..f998cd66d 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -257,6 +257,14 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) 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); #else image = gtk_style_render_icon(gtk_widget_get_style(widget), source, gtk_widget_get_direction(widget), -- cgit v1.2.3 From 24397ca99c5807898ee423669bb2a089f51bc787 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 13 Apr 2016 16:59:14 +0100 Subject: icon: Fix deprecated gtk_widget_get_requisition() #Hackfest2016 (bzr r14839) --- src/widgets/icon.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/widgets/icon.cpp') diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index f998cd66d..010b3a6fb 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -280,7 +280,13 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) GtkAllocation allocation; GtkRequisition requisition; gtk_widget_get_allocation(widget, &allocation); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_get_preferred_size(widget, &requisition, NULL); +#else gtk_widget_get_requisition(widget, &requisition); +#endif + int x = floor(allocation.x + ((allocation.width - requisition.width) * 0.5)); int y = floor(allocation.y + ((allocation.height - requisition.height) * 0.5)); int width = gdk_pixbuf_get_width(image); -- cgit v1.2.3 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 From 41f30faca1b202da59a233f0556fc9580586f893 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 4 May 2016 10:10:42 +0200 Subject: Fix rendering of tool bar icons. (bzr r14869.1.2) --- src/widgets/icon.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/widgets/icon.cpp') diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 5acdc613c..f2031fe51 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -235,7 +235,6 @@ 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 ); @@ -249,7 +248,7 @@ 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; + std::cerr << "IconImpl::draw: Ooops! It is called in GTK2" << std::endl; #endif std::cerr << "IconImpl::draw: No image, creating fallback" << std::endl; @@ -805,6 +804,10 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name ) GtkWidget *widget = NULL; gint trySize = CLAMP( static_cast(lsize), 0, static_cast(G_N_ELEMENTS(iconSizeLookup) - 1) ); + if (trySize != lsize ) { + std::cerr << "GtkWidget *IconImple::newFull(): lsize != trySize: lsize: " << lsize + << " try Size: " << trySize << " " << (name?name:"NULL") << std::endl; + } if ( !sizeMapDone ) { injectCustomSize(); } @@ -832,6 +835,7 @@ GtkWidget *IconImpl::newFull( Inkscape::IconSize lsize, gchar const *name ) if ( Inkscape::Preferences::get()->getBool("/options/iconrender/named_nodelay") ) { int psize = getPhysSize(lsize); + // std::cout << " name: " << name << " size: " << psize << std::endl; prerenderIcon(name, mappedSize, psize); } else { addPreRender( mappedSize, name ); -- cgit v1.2.3