Re: gtk_icon_theme_load_icon and GDK_SCALE=2 results in blurry icon

2017-10-04 Thread Alexander Shaduri
Hi,

On Tue, 2017-10-03 at 20:13 +0200, infirit wrote:

> See bug 765167 [1] it has an example in python how you can still use a
> surface in the GtkIconView.  You should be able to translate this pretty
> easily to C/C++.
> 
> ~infirit
> 
> [1] https://bugzilla.gnome.org/show_bug.cgi?id=765167#c5.

Thanks a lot for the pointer. I was able to translate this into Gtkmm.
This fixes my issue, although I wish GTK would implement a proper
method for doing this.

This is the code, if anyone is interested:

class MainWindowIconView : public Gtk::IconView {
public:

Gtk::CellRendererPixbuf cell_renderer_pixbuf;  ///< Cell renderer for 
icons.
Gtk::TreeModelColumn col_pixbuf;  ///< 
Model column
// ...

MainWindowIconView()
{
// ...
columns.add(col_pixbuf);

// For high quality rendering with GDK_SCALE=2
this->pack_start(cell_renderer_pixbuf, false);
this->set_cell_data_func(cell_renderer_pixbuf,
sigc::mem_fun(this, 
::on_cell_data_render));
// ...
}

/// Cell data renderer (needed for high quality icons in GDK_SCALE=2).
/// We have to use Cairo surfaces, because pixbufs are scaled by 
GtkIconView.
void on_cell_data_render(const Gtk::TreeModel::const_iterator& iter)
{
Gtk::TreeRow row = *iter;
Glib::RefPtr pixbuf = row[col_pixbuf];

// Gtkmm property_surface() doesn't work, so use plain C.
cairo_surface_t* surface = gdk_cairo_surface_create_from_pixbuf(
pixbuf->gobj(), get_scale_factor(), 
get_window()->gobj());
g_object_set(G_OBJECT(cell_renderer_pixbuf.gobj()), "surface", 
surface, NULL);
cairo_surface_destroy(surface);
}

// ...
};



Thanks,
Alexander

___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: gtk_icon_theme_load_icon and GDK_SCALE=2 results in blurry icon

2017-10-03 Thread Alexander Shaduri

Hi,

On Tue, 2017-10-03 at 19:32 +0200, infirit wrote:
> Op 10/03/2017 om 03:28 PM schreef Alexander Shaduri:
> > 
> > I have a HiDPI Screen with DPI set to 192, GDK_SCALE=2 and GDK_DPI_SCALE=-1.
> > 
> > I need to get an icon as a pixbuf for GtkIconView.
> 
> Short answer, there is no way to do scaling properly with pixbufs. The
> only way I found to do this was setting icon names and using cairo surfaces.

Unfortunately, GtkIconView expects pixbufs in the model.
I don't see a way to pass cairo surfaces to it.

> > This is the code in gtkmm:
> > Glib::RefPtr default_icon_theme = 
> > Gtk::IconTheme::get_default();
> > Glib::RefPtr icon = 
> > default_icon_theme->load_icon("drive-harddisk", 64, 
> > Gtk::IconLookupFlags(0));
> 
> As others have mentioned use the _at_scale() version of the icon theme
> functions, it handles all the necessary scaling for you. To get the
> scale factor use gtk_widget_get_scale_factor on the window/widget.

Yes, tried that, GtkIconView scales the resulting pixbuf.

> Another thing to think about is the quality of the icons. I added proper
> scaling for a project and found that the a couple of png icons it used
> where in only a single size and of low quality. No matter what you do in
> this case there is no way to prevent blurry icons.

The quality is not an issue here. I can get a sharp 128-size icon when not
using GDK_SCALE=2.

> Internally Gtk handles this transparently as long as use icon-names
> instead of pixbufs. I highly recommend you use icon-names whenever
> possible and use cairo surfaces if you need to draw over or transform
> the icon.
> 
> I ended up using gtk_icon_theme_lookup_icon_for_scale and then retrieve
> the surface at the very last moment with gtk_icon_info_load_surface.
> gtk_icon_info_load_surface also sets the correct scaling factor on the
> surface so there is no need to change it with
> cairo_surface_set_device_scale. Most widgets will accept the surface
> these days and you should start using them.

Not GtkIconView, it seems.


> > Is there a way to get a sharp icon with gtk_icon_theme_load_icon?
> 
> Yes I managed it as described above. I have a silly experiment in python
> that uses cairo surfaces at [1], maybe this helps. The moment you write
> to png and use it as source on a widget things go blurry.
> 
> ~infirit
> 
> [1] https://gist.github.com/infirit/7434371b93cf727f7517c4601df602b9

I'm at loss here, I guess this can be viewed as a bug in GtkIconView.


Thanks

___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: gtk_icon_theme_load_icon and GDK_SCALE=2 results in blurry icon

2017-10-03 Thread Alexander Shaduri

It looks like GDK_SCALE makes GtkIconView scale its icons (the pixbufs).

Glib::RefPtr hd_icon = 
default_icon_theme->load_icon("gtk-harddisk", 64, 2, Gtk::IconLookupFlags(0));
This makes a pixbuf of size 128 (the filename points to 128-size png).

However, when this pixbuf is set on a GtkIconView, it's scaled by it,
making the size 256.

Basically, I need a method of disabling GtkIconView's scaling of icons.

Thanks,
Alexander


On Tue, 2017-10-03 at 19:43 +0400, Alexander Shaduri wrote:
> Hi Stefan,
> 
> On Tue, 2017-10-03 at 16:59 +0200, Stefan Salewski wrote:
> > 
> > Have you tried
> > 
> > https://developer.gnome.org/gtk3/stable/GtkIconTheme.html#gtk-icon-theme-load-icon-for-scale
> 
> Yes I have tried gtk_icon_theme_lookup_icon_for_scale().
> Passing size=64 and scale=2 to this function results in a blurry icon
> of size 256. It seems the icon is scaled twice - once by "scale" and
> once
> more by GDK_SCALE=2.
> Passing scale=1 gets me a blurry 128-size icon.
> 
> > 
> > There you will find a reference to
> > 
> > https://developer.gnome.org/gtk3/stable/GtkIconTheme.html#gtk-icon-theme-load-icon-for-scale
> > 
> > where notes about displays with high pixel densities exists.
> 
> I guess you meant gtk_icon_theme_lookup_icon(). It just says to use
> gtk_icon_theme_lookup_icon_for_scale(), which gets me a blurry icon.
> 
> Thanks,
> Alexander
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: gtk_icon_theme_load_icon and GDK_SCALE=2 results in blurry icon

2017-10-03 Thread Alexander Shaduri

Hi Stefan,

On Tue, 2017-10-03 at 16:59 +0200, Stefan Salewski wrote:
> Have you tried
> 
> https://developer.gnome.org/gtk3/stable/GtkIconTheme.html#gtk-icon-theme-load-icon-for-scale

Yes I have tried gtk_icon_theme_lookup_icon_for_scale().
Passing size=64 and scale=2 to this function results in a blurry icon
of size 256. It seems the icon is scaled twice - once by "scale" and
once
more by GDK_SCALE=2.
Passing scale=1 gets me a blurry 128-size icon.

> There you will find a reference to
> 
> https://developer.gnome.org/gtk3/stable/GtkIconTheme.html#gtk-icon-theme-load-icon-for-scale
> 
> where notes about displays with high pixel densities exists.

I guess you meant gtk_icon_theme_lookup_icon(). It just says to use
gtk_icon_theme_lookup_icon_for_scale(), which gets me a blurry icon.

Thanks,
Alexander

___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


gtk_icon_theme_load_icon and GDK_SCALE=2 results in blurry icon

2017-10-03 Thread Alexander Shaduri

Hi,

I have a HiDPI Screen with DPI set to 192, GDK_SCALE=2 and GDK_DPI_SCALE=-1.

I need to get an icon as a pixbuf for GtkIconView.

This is the code in gtkmm:
Glib::RefPtr default_icon_theme = Gtk::IconTheme::get_default();
Glib::RefPtr icon = 
default_icon_theme->load_icon("drive-harddisk", 64, Gtk::IconLookupFlags(0));

Now matter how I try, I simply cannot get a non-blurry icon. It seems that
GTK+ looks up an icon of size 64, then scales it to 128. I'd like for it to
get a 128-size icon directly.

Specifying 128 as an argument results in a blurry icon of size 256.

Note that without GDK_SCALE=2 I can specify size 128 and get a sharp icon
(there are major artifacts in the GUI though).
I need to support GDK_SCALE=2.
I tried playing with "scale" argument, but that doesn't help.

Note that icons on buttons and in menu appear sharp.

Is there a way to get a sharp icon with gtk_icon_theme_load_icon?

Thanks,
Alexander

___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Stable cross-platform version?

2011-09-19 Thread Alexander Shaduri

Hello,

On Mon, 19 Sep 2011 10:05:56 +0200
dieterv wrote:

 If you're referring to the binaries on ftp.gnome.org/www.gtk.org, then 
 I'll
 update these to GTK+ 2.24.5 (hopefully) somewhere this week. If you 
 can't
 wait they are currently living here:
 https://github.com/dieterv/legacynativebuilds/downloads

Thanks a lot for these packages!
Could you please indicate somewhere which versions of gcc/binutils/
mingw-runtime/etc... you used to build those? The thing is that sometimes
there are minor compatibility problems between the versions, so it
would be great to know the exact versions to rule out the incompatibility
in case of problems. Are you using mingw or mingw-w64?
A file in gtk+-bundle describing the versions would be ideal. Thanks!

 There are also other options. For example there's a treasure trove of
 both 32 and 64 bit Windows binaries built by the Open Build Service 
 here:
 https://build.opensuse.org/project/show?project=windows%3Amingw%3Awin32
 https://build.opensuse.org/project/show?project=windows%3Amingw%3Awin64

I'm not exactly familiar with these, are they binary compatible with your
zip files?

Thanks,
Alexander
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: What compiler is used to build GTK+ Windows packages?

2010-12-11 Thread Alexander Shaduri

Hello, anyone?

On Sun, 5 Dec 2010 14:19:23 +0400
Alexander Shaduri wrote:

 I'd like to know which version of mingw (gcc), binutils, w32api and
 mingw-runtime were used when compiling the win32 packages of GTK+
 located here:
 http://www.gtk.org/download-windows.html
 
 Also, are there any plans to use the mingw64 toolchain (like at
 http://download.opensuse.org/repositories/windows:/mingw:/win32/ )?
 Maybe for GTK+ 3?
 
 Are there any plans to make the non-experimental (that is, backwards
 binary-compatible) releases of win64 packages?
 http://www.gtk.org/download-windows-64bit.html
 What toolchain is used to build that and which version?


Tor, you're compiling those win32 packages, correct?
If so, could you please add this info to the README file
of gtk-bundle?

Thanks,
Alexander
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


What compiler is used to build GTK+ Windows packages?

2010-12-05 Thread Alexander Shaduri

Hello,

I'd like to know which version of mingw (gcc), binutils, w32api and
mingw-runtime were used when compiling the win32 packages of GTK+
located here:
http://www.gtk.org/download-windows.html

Also, are there any plans to use the mingw64 toolchain (like at
http://download.opensuse.org/repositories/windows:/mingw:/win32/ )?
Maybe for GTK+ 3?

Are there any plans to make the non-experimental (that is, backwards
binary-compatible) releases of win64 packages?
http://www.gtk.org/download-windows-64bit.html
What toolchain is used to build that and which version?

Thanks a lot in advance,
Alexander
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: shrink GTK+ disk usage for Windows

2010-04-01 Thread Alexander Shaduri

Hello,

On Wed, 31 Mar 2010 10:59:23 -0600
Andrew Ziem ahz...@gmail.com wrote:

 Wow, using Linux 'strip -v bin/*' cuts the bin directory from 16M to
 9.3M!  After UPX, it's down to 3.9M (compare to 7.8MB below).

Keep in mind that I had some problems with Linux version of strip
when running it on windows dlls.
I think the mingw version (usually called i386-pc-mingw32-strip or similar)
is better in that regard.
Also, it's usually safe to use --strip-debug and --strip-unneeded
on libraries, but simply using strip without arguments will damage them.

Alexander
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: questions on gtk icon view

2009-02-13 Thread Alexander Shaduri
On Wed, 11 Feb 2009 11:24:47 +0800
lfeng lf...@neusoft.com wrote:

 I create a gtk icon view in scrolled window, using list store to saving the
 data. Sometimes, I use gtk_store_clear to clear the data, then I set new
 data to iconview. However, the text under the icon in iconview displays
 wrongly, as accessory. 

Hello,

Sounds like a bug I filed some time ago:
http://bugzilla.gnome.org/show_bug.cgi?id=563999

Maybe you could add some comments there.

Thanks,
Alexander
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: g_locale_from_utf8() errors on Windows 2000

2008-12-16 Thread Alexander Shaduri

OK, I did a new installation of windows 2000 in a virtual machine.
The disk I installed from is SP2, and my test failed again.
However, when I updated it to SP4, the test passed.

The old installation won't update to sp4 for some reason
(says it's already installed, even if it's not), go figure...

Anyway, I'm not sure what's your policy regarding support
of pre-sp4 windows 2000, but at least there is a solution.

Thanks,
Alexander


On Mon, 15 Dec 2008 00:29:57 +0400
Alexander Shaduri ashad...@gmail.com wrote:

  Sorry, your test program runs fine here in a Win2k virtual machine,
  against the latest GTK+ stack. What GLib version are you using?
 
 glib_2.18.3-1_win32.zip
 from
 http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.18/
 
  If you
  check Control Panel:Regional Options:General:Advanced, do you see an
  entry for code page 65001 (UTF-8)?
 
 Yes, it's there, with an enabled checkbox.
 
 About win2k - mine's in a virtual machine too (I use it for testing).
 A really old installation. I don't know, maybe if I do a clean install
 the problem might go away...
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


g_locale_from_utf8() errors on Windows 2000

2008-12-14 Thread Alexander Shaduri

Hi all,

I'm getting an error when using g_locale_from_utf8()
under win2000 (doesn't happen in XP or Vista).

With a locale of English_United States.1252, for:
-
GError* error = 0;
gsize written = 0;
g_locale_from_utf8(hello, 5, NULL, written, error);
-

I get:
-
Invalid byte sequence in conversion input
-
in error-message.

A simple test case is attached.

This gets especially annoying when using Glibmm,
where a simple
std::cout  Glib::ustring(abc);
triggers a conversion error exception (it calls the
g_locale_from_utf8() function), and the program dies
all over the place due to unhandled exceptions.

The gtk/glib/dependencies come from
http://ftp.gnome.org/pub/gnome/binaries/win32/


Thanks,
Alexander

#include gtk/gtk.h
#include stdio.h
#include locale.h

/*
Compile with:
gcc `pkg-config --cflags --libs gtk+-2.0` test_win2k_locale.c -o test_win2k_locale

The output of this program under win2k is:
--
Current locale: English_United States.1252
Invalid byte sequence in conversion input
--
*/

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

	fprintf(stderr, Current locale: %s\n, setlocale(LC_ALL, NULL));

	GError* error = 0;
	gsize written = 0;
	g_locale_from_utf8(hello, 5, NULL, written, error);

	if (error) {
		fprintf(stderr, %s\n, error-message);
	}

	return 0;
}


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Move to LGPL3

2008-03-18 Thread Alexander Shaduri

Hi all,

Having studied the FSF licenses and their restrictions, I think
it would be reasonable to re-license GTK+ under the LGPLv3
(or later) + GPLv2 linking exception (or, alternatively, simply
multi-license it under LGPLv3 / GPLv2).

This method allows people to link GTK+ with any of the following:
- LGPLv2.1-only (since it's compatible with GPLv2 or later);
- LGPLv3 or later;
- GPLv2 (because of the linking exception);
- GPLv3 (because LGPLv3 is explicitly compatible with GPLv3).

Notes:
Re-licensing GTK+ won't pose any problems - the current
license allows it to be redistributed as LGPLv3/GPLv2 as a whole,
so no problem there.

The main reason to move to LGPLv3 is usually the patent protection.
By using the GPLv2 (as opposed to LGPLv2.1) exception, GTK+
will limit the damage by forcing the proprietary folk to use LGPLv3
(since most of them can't use GPLv2), so the patent protection is
still in effect.

I always wonder how the programmer has to be a lawyer too these days. :)

Thanks,
Alexander

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: GTK+ 2.12.3 (win32) and locales - not working

2007-12-19 Thread Alexander Shaduri

Thanks for the reply. I think I got closer to solving the problem.

The thing is, the only things I upgraded when switching from
2.12.1 to 2.12.3 are gtk and glib dlls and gettext's intl.dll
(from http://www.gimp.org/~tml/gimp/win32/downloads.html,
gettext-runtime-0.17.zip).

Now I took a clean 2.12.1 with working translations and only
updated intl.dll (I was using gettext-0.14.5 previously).
The translations stopped working.

This was on a win2kpro (sp4 I think) machine.
Then I moved the whole thing to winxp, and everything started
working.

So, to summarize, it seems to be the intl.dll / win2k problem.

Tried running 2.12.3 with old intl.dll, but it complains about missing
symbol (no surprise here).

Thanks, Alexander
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


GTK+ 2.12.3 (win32) and locales - not working

2007-12-13 Thread Alexander Shaduri

I have a problem in windows with GTK+ 2.12.3 which didn't happen with 2.12.1.
If I have a non-english locale set in windows, programs using 2.12.3 don't
get translated, but if I change GTK to 2.12.1, they do. (I'm talking about
Open, Cancel, etc... that sort of strings).
Both versions come from
http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.12/

It seems that 2.12.3 has the locale directory in share, not in lib as previous
versions did. I tried copying it to both share and lib, but still nothing.

I ran
strings libgtk-win32-2.0-0.dll | grep locale
on both versions and got:

2.12.3:
...
c:/devel/target/5acf545be633e26dcf39ce42e159bafc/share/locale
c:/devel/target/5acf545be633e26dcf39ce42e159bafc/share/locale
...

and
2.12.1:
...
c:/devel/target/0d05e97fbafcc302580d49b7ff9973ad/lib/locale
lib\locale
...

Seems to me like there's some compile-time stuff compiling in
instead of being determined at runtime.

Of course, I may be off by a mile here. :)

Alexander
___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list