Applying system scale on GTK 2

2018-03-02 Thread Andreas Falkenhahn
I have tried to run my GTK 2 application on a high DPI monitor and this leads 
to some layout issues because values that are passed to 
gtk_widget_set_size_request() are in pixels. 

I can solve these problems by reading the "Xft.dpi" Xresource and multiplying 
all my pixel values by it. Still, I'm wondering whether GTK 2 has an inhouse 
solution for this particular problem because my solution seems rather hackish. 
Any ideas?

-- 
Best regards,
 Andreas Falkenhahn  mailto:andr...@falkenhahn.com

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


Re: Using g_utf8_collate() with gtk_disable_setlocale()

2017-03-26 Thread Andreas Falkenhahn
On 09.03.2017 at 19:20 Emmanuele Bassi wrote:

> You should be using `g_ascii_strtod()` if you need a
> locale-independent version of `strtod()`, instead of disabling the
> locale.

> In general, disabling the locale is only meant for specific, limited
> cases, like platforms with broken locales, or debugging, not as a "get
> out of jail for free" card.

Easier said than done. The application in question is a rather large
one which can also be extended via plugins. Plugins expect the locale
to be "C". I don't see how to workaround that without breaking plugins.

Also, what about functions like sscanf()? I don't see any g_ascii_sscanf()
replacement. On a German locale sscanf() will expect a comma instead of a
point as a decimal separator. 

IMHO it would have been a much cleaner solution if glib locales were
completely separated from C's standard locales which many people consider
seriously broken.

Heck, even Wikipedia says "Most large-scale software forces the locale to "C"
(or another fixed value) to work around these problems."

;-)

-- 
Best regards,
 Andreas Falkenhahnmailto:andr...@falkenhahn.com

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


Using g_utf8_collate() with gtk_disable_setlocale()

2017-03-09 Thread Andreas Falkenhahn
Is there any way to make g_utf8_collate() use the system's locale
when using gtk_disable_setlocale()? In my application I need to use
gtk_disable_setlocale() because having GTK call setlocale() has
several implications which I'd like to avoid (e.g. strtod() suddenly
expecting a comma instead of a point as a decimal separator).

So I'd like to ask if there is any other way to tell glib to use
the system's locale when sorting using g_utf8_collate() so that I
can keep my call to gtk_disable_setlocale() and still use g_utf8_collate
to sort using the system's locale?

Thanks!

-- 
Best regards,
 Andreas Falkenhahn  mailto:andr...@falkenhahn.com

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


GtkFrame looks different each time the program is started

2016-03-27 Thread Andreas Falkenhahn
This is really confusing the heck out of me. Please take a look at the
attached screenshot.

Sometimes, the GtkFrames in my program look like on the left side, and
sometimes they look like on the right side - or even a mix of the two!
The program is exactly the same. Just running the same program multiple
times yields very different looks of the GtkFrames in the program! How
can that be?

It seems that there are two different designs of GtkFrame:

1) The first one has its label centered at the top of the frame and smoothly
dissolves towards the bottom so that the frame doesn't completely enclose
the GtkFrame's contents.

2) The second design has its label left-aligned at the top of the frame and
draws a border around the complete GtkFrame.

The problem is now that GTK+ seems to choose one of the two designs entirely
at random. I don't see any pattern in which design I'm going to get. It appears
to happen completely at random which is really confusing me.

Can somebody shed a light onto this mystery? What is going on here? Is there
a way to force GTK+ to use a certain design?

I'm using GTK+ 2.24.10 with the Adwaita theme on Linux Mint. On Ubuntu I
don't see this behaviour. On Ubuntu all GtkFrames look exactly the same
and they never change. But on Linux Mint with Adwaita the apparently random
change of GtkFrame designs is confusing the heck out of me...

Somebody please shed some light onto this! Thanks a lot!

-- 
Best regards,
 Andreas Falkenhahn  mailto:andr...@falkenhahn.com___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Computing border size of GtkFrame

2016-03-23 Thread Andreas Falkenhahn
On 23.03.2016 at 16:52 Igor Korot wrote:

> Hi, Andreas,

> On Wed, Mar 23, 2016 at 11:34 AM, Andreas Falkenhahn
> <andr...@falkenhahn.com> wrote:
>> I need to compute the border sizes of a GtkFrame before the window containing
>> that GtkFrame has been realized. Precisely, I need the distances between the
>> GtkFrame container widget and its child. AFAICS, this isn't possible to get
>> before the GtkFrame has been realized. So I thought that I could use a 
>> workaround
>> that creates a top-level window, adds a GtkFrame with a GtkButton and 
>> computes
>> the size and destroys everything again. Here is the code:

> What is it that you are trying to accomplish/achieve?

Fixing wxWidgets. src/common/sizer.cpp calls wxStaticBox::GetBordersForSizer()
at a time when the window hasn't been realized yet. Hence, the values returned
are spurious.

> Maybe this is possible in some other way?

Sure there is. But then you'd probably have to rewrite major parts of the 
wxSizer
logic. So I prefer keeping the logic that we have and force the GTK+ backend to
make it do what we need, even if it's a hackish solution. But maybe there's a 
nicer
and cleaner that's why I was asking here, so please don't hijack this 
thread,
Igor :)

-- 
Best regards,
 Andreas Falkenhahnmailto:andr...@falkenhahn.com

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


Computing border size of GtkFrame

2016-03-23 Thread Andreas Falkenhahn
I need to compute the border sizes of a GtkFrame before the window containing
that GtkFrame has been realized. Precisely, I need the distances between the
GtkFrame container widget and its child. AFAICS, this isn't possible to get
before the GtkFrame has been realized. So I thought that I could use a 
workaround
that creates a top-level window, adds a GtkFrame with a GtkButton and computes
the size and destroys everything again. Here is the code:

void GTKFrameGetBorders(int *borderTop, int *borderOther)
{
GtkWidget *wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget* labelwidget = gtk_label_new_with_mnemonic("Foo");
gtk_widget_show(labelwidget); 

GtkWidget* framewidget = gtk_frame_new(NULL);
gtk_frame_set_label_widget(GTK_FRAME(framewidget), labelwidget);

GtkWidget *btn = gtk_button_new();
gtk_widget_show(btn);

gtk_container_add(GTK_CONTAINER(framewidget), btn);
gtk_container_add(GTK_CONTAINER(wnd), framewidget);

gtk_widget_show(framewidget);

// !!! THIS CALL IS NECESSARY TO GET CORRECT VALUES !!!
gtk_widget_realize(labelwidget);

GtkAllocation alloc, child_alloc;
gtk_widget_get_allocation(framewidget, );


GTK_FRAME_GET_CLASS(framewidget)->compute_child_allocation(GTK_FRAME(framewidget),
 _alloc);

*borderTop = child_alloc.y - alloc.y;
*borderOther = child_alloc.x - alloc.x;

gtk_widget_destroy(wnd);
}

This seems to do the job and returns the correct values but of course it's a
really hackish solution. So I've got two questions:

1) Is there a better/cleaner solution? :)

2) Is it allowed to call gtk_widget_realize() on the "labelwidget" as done 
above? The
docs say that gtk_widget_realize() is propagated upwards so does this mean that
gtk_widget_realize() will end up being called on the top-level window which 
means
that the top-level window will be shown very briefly? That's of course something
I'd like to avoid...

I'm targetting GTK+ 2.

Thanks for any suggestions!

-- 
Best regards,
 Andreas Falkenhahn  mailto:andr...@falkenhahn.com

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


Re: GtkFrame looks different each time the program is started

2016-03-23 Thread Andreas Falkenhahn
On 23.03.2016 at 01:30 Allin Cottrell wrote:

> On Tue, 22 Mar 2016, Andreas Falkenhahn wrote:

>> On 22.03.2016 at 20:17 Göran Hasse wrote:

>>> Hello,

>>> Strange... You can test the behavior by changing the order
>>> the widget get realized.

>>> Instead of gtk_widget_show_all(window); at the end try to do 
>>> gtk_widget_show(widget1);
>>> one at a time and in different order. This could give a clue... but maybe 
>>> not...

>> Unfortunately, this isn't easily possible because the GUI is programmed
>> using wxWidgets...

> Well then, it's all over, isn't it? 

Well, actually I was trying to fix it in wxWidgets but the problem is probably
not in wxWidgets but in the theme/engine. First, Emmanuele Bassi was right. This
isn't the "Adwaita" theme although that's what gsettings returned but the 
information
from gsettings is probably not reliable since I'm on KDE.

So I opened the KDE prefs for app appearance instead and saw that the GTK+
theme is actually set to oxygen-gtk which seems to be a theme/engine imitating 
the
Qt look.

Since I only ever get two different looks for GtkFrame with that oxygen-gtk
theme I suppose that the bug is in oxygen-gtk, not in gtk or wxWidgets. With
all other themes I tried I always get a consistent look of GtkFrame so I
suppose it's a bug in oxygen-gtk. Does this sound plausible to you GTK+ wizards?

I don't know very much about GTK+ but that's the only plausible explanation
I can come up with: oxygen-gtk probably tries to be very clever and comes
up with different looks for GtkFrame depending on the context but then somehow
gets things messed up so that apps always look different. From my observations,
the problem is especially related to tabbed pages. When the GtkFrames are on
a tab that is visible on program start, I usually get the first look whereas
GtkFrames on tab pages that are invisible on program start I usually get the
second look.... it really looks like an issue with oxygen-gtk to me. Do you
agree?

-- 
Best regards,
 Andreas Falkenhahnmailto:andr...@falkenhahn.com

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


Re: GtkFrame looks different each time the program is started

2016-03-22 Thread Andreas Falkenhahn
On 22.03.2016 at 20:17 Göran Hasse wrote:

> Hello,

> Strange... You can test the behavior by changing the order
> the widget get realized.

> Instead of gtk_widget_show_all(window); at the end try to do 
> gtk_widget_show(widget1);
> one at a time and in different order. This could give a clue... but maybe 
> not...

Unfortunately, this isn't easily possible because the GUI is programmed
using wxWidgets...

-- 
Best regards,
 Andreas Falkenhahnmailto:andr...@falkenhahn.com

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


Re: GtkFrame looks different each time the program is started

2016-03-22 Thread Andreas Falkenhahn
On 22.03.2016 at 19:17 Emmanuele Bassi wrote:

> Hi;

> On 22 March 2016 at 18:09, Andreas Falkenhahn <andr...@falkenhahn.com> wrote:
>> This is really confusing the heck out of me. Please take a look at this
>> screenshot:

>> http://www.falkenhahn.com/tmp/shot.png

> Are you sure you linked the right screenshot? That looks like a Qt UI, to me.

No, it's definitely GTK+. 

> I have no idea what kind of theme you're using, by that's most
> definitely *not* Adwaita.

But this is what gsettings returns. Entering

$ gsettings get org.gnome.desktop.interface gtk-theme

returns 'Adwaita'.

I can also rule out that my installation is messed up or anything. I've
tried the latest Mint Live DVD and the problem is there as well. I really
don't know where or what to look for because the GtkFrames randomly
change their look.

-- 
Best regards,
 Andreas Falkenhahnmailto:andr...@falkenhahn.com

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


GtkFrame looks different each time the program is started

2016-03-22 Thread Andreas Falkenhahn
This is really confusing the heck out of me. Please take a look at this
screenshot:

http://www.falkenhahn.com/tmp/shot.png

Sometimes, the GtkFrames in my program look like on the left side, and
sometimes they look like on the right side - or even a mix of the two!
The program is exactly the same. Just running the same program multiple
times yields very different looks of the GtkFrames in the program! How
can that be?

It seems that there are two different designs of GtkFrame:

1) The first one has its label centered at the top of the frame and smoothly
dissolves towards the bottom so that the frame doesn't completely enclose
the GtkFrame's contents.

2) The second design has its label left-aligned at the top of the frame and
draws a border around the complete GtkFrame.

The problem is now that GTK+ seems to choose one of the two designs entirely
at random. I don't see any pattern in which design I'm going to get. It appears
to happen completely at random which is really confusing me.

Can somebody shed a light onto this mystery? What is going on here? Is there
a way to force GTK+ to use a certain design?

I'm using GTK+ 2.24.10 with the Adwaita theme on Linux Mint. On Ubuntu I
don't see this behaviour. On Ubuntu all GtkFrames look exactly the same
and they never change. But on Linux Mint with Adwaita the apparently random
change of GtkFrame designs is confusing the heck out of me...

Somebody please shed some light onto this! Thanks a lot!

-- 
Best regards,
 Andreas Falkenhahn  mailto:andr...@falkenhahn.com

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


Re: Creating an app with optional GTK support

2010-05-16 Thread Andreas Falkenhahn
On 15.05.2010 at 21:14 Stanislav Maslovski wrote:

On Fri, May 14, 2010 at 12:26:00PM +0200, Andreas Falkenhahn wrote:
 Hi,
 
 I'm currently developing an X11 app and would like to use GTK only for
the
 file chooser dialog.

Are you sure you want to use it? It is broken beyond repair in all
possible ways.

Huh, what, GTK broken? GTK always worked fine for me... except the Windows
port could use some polishing ;)

Greets,

Andreas
--
Remember: It's nice to be important but it's more important to be nice!


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


Re: Creating an app with optional GTK support

2010-05-16 Thread Andreas Falkenhahn
On 14.05.2010 at 18:34 Lothar Scholz wrote:

Hello Andreas,

Friday, May 14, 2010, 12:26:00 PM, you wrote:

AF I'm currently developing an X11 app and would like to use GTK only for
the
AF file chooser dialog. The rest is done entirely in X11. However, the GTK
AF support shall be optional. If GTK is there, then my app will use the
GTK
AF file chooser. If GTK is not there, I'll simply ask for a file name
using a
AF fgets() on stdin :-)

After reading all the other answers and your addtional comments.
I would really question your decision to only rely on
libX11. What value does this add these days for your customers.

It's not an ideological decision or something. It's just that in this very
app I really don't need GTK because the app doesn't have a GUI in
the traditional sense. It's drawing everything on its own and X11 is
just fine for that. 

Greets,

Andreas
--
Remember: It's nice to be important but it's more important to be nice!


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


Creating an app with optional GTK support

2010-05-14 Thread Andreas Falkenhahn
Hi,

I'm currently developing an X11 app and would like to use GTK only for the
file chooser dialog. The rest is done entirely in X11. However, the GTK
support shall be optional. If GTK is there, then my app will use the GTK
file chooser. If GTK is not there, I'll simply ask for a file name using a
fgets() on stdin :-)

Now to my question: Because I want my app to run even if GTK is not
present, I can't link against the GTK libs. Instead, I have to use
dlopen() and manually read the function pointers of the functions I need
using dlsym(). This all works fine so far, except one thing: There are
name discrepancies across the different distros. For example, comparing
openSUSE and Ubuntu:

openSUSE .so names:
1) libgtk-x11-2.0.so
2) libglib-2.0.so
3) libgobject-2.0.so

Ubuntu .so names:
1) libgtk-x11-2.0.so.0
2) libglibmm-2.4.so.1 !!!
3) libgobject-2.0.so.0

Especially striking is that Ubuntu doesn't have a libglib-XXX.so at all,
but only a libglibmm-XXX.so! So what would be the best strategy to make my
app work even with those diverging *.so names? I guess the only way would
be to manually scan the libs in /usr/lib/ and compare against the
patterns:

libgtk-x11-*.so.*
libglib-*.so.*
libglibmm-*.so.*
libgobject-*.so.*

And then choose an appropriate .so for dlopen(). Or does anybody have a
better solution?

Thanks,

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


Re: Creating an app with optional GTK support

2010-05-14 Thread Andreas Falkenhahn
 Hello.

 Especially striking is that Ubuntu doesn't have a libglib-XXX.so at all,
 but only a libglibmm-XXX.so!

 I'm not sure why you cannot find it, by all my machines have at least
 libglib-2.0.so, libgtk-x11-2.0.so, libgobject-2.0.so ... Are you sure
 glib shared object is not present?

Yes, it's not there. Maybe it's because I've not installed Ubuntu. I'm just
using the latest live CD (10.04). This CD only has the said
libglibmm-2.4.so.1,
not a libglib-2.0.so.


 As for optional GTK+ support, wouldn't be better to check for GTK+ at
 configure phase and compile/link your application accordingly?

Not possible because my app is currently not open source.

Greets,

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


Re: Creating an app with optional GTK support

2010-05-14 Thread Andreas Falkenhahn
 On Fri, 2010-05-14 at 12:46 +0200, Andreas Falkenhahn wrote:
  I'm not sure why you cannot find it, by all my machines have at least
  libglib-2.0.so, libgtk-x11-2.0.so, libgobject-2.0.so ... Are you sure
  glib shared object is not present?

 Yes, it's not there. Maybe it's because I've not installed Ubuntu. I'm
 just
 using the latest live CD (10.04). This CD only has the said
 libglibmm-2.4.so.1,
 not a libglib-2.0.so.

 Ubuntu places glib and gtk+ under /lib so make sure to look there.

Oh, right, there it is. Sorry for that. I didn't look into /lib because
the gtk and gobject libs were all in /usr/lib.

Thanks,

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


Re: Creating an app with optional GTK support

2010-05-14 Thread Andreas Falkenhahn
 Hi.



 As for optional GTK+ support, wouldn't be better to check for GTK+ at
 configure phase and compile/link your application accordingly?

 Not possible because my app is currently not open source.

 Which probably means that you'll be distributing binaries. So you can
 compile two versions of your app: one that links against GTK+ and the
 one that doesn't. Your clients can then decide which one to use.

Not possible either because my app also has optional support Xrender,
Xfixes, Xcursor, and ALSA. The only lib I'm linking against is -lX11. The
rest is entirely optional. Now if I'd start building different binaries
for each config, there would be a lot of different combinations. It's
really easier to do this manually using a single binary and some calls to
dlopen().

However, I think I still need to scan /usr/lib and /lib and analyze what
we have because on this Ubuntu live CD here, there are no symlinks like
libglib-2.0.so and libgtk-x11-2.0.so. Instead, they all have a .0
version attached. So the following call will fail on my Ubuntu live CD:

dlopen(libglib-2.0.so)
dlopen(libgtk-x11-2.0.so)

This doesn't work. I need to append a .0 first. But of course I can't
hardcode the .0 either because of new versions that could appear. So I
still need to scan /usr/lib and /lib and do some pattern matching and then
make an educated guess what .so I should open :)

Greets,

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


GTK clipboard notification

2010-05-06 Thread Andreas Falkenhahn

Hi,

is there a way to get notified by GTK when the flavor type in the clipboard 
changes?
I have an image app here and I'd like to disable my toolbar's paste button 
whenever
there is something other than an image in the clipboard. So I'm wondering if 
there is
any way to get notified when the clipboard flavor changes?

Tks,

Andreas
--
Remember: It's nice to be important but it's more important to be nice!


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


GTK on Linux and UTF-8 text

2010-05-04 Thread Andreas Falkenhahn
Hi,

I previously worked with GTK only on Windows and the Windows builds of GTK
always used UTF-8 for everything. Now I played a bit with GTK on Linux and
noticed that it doesn't seem to handle UTF-8 correctly by default.
Instead, ISO 8859-1 is used (which should be my locale's default charset).
When I pass UTF-8 text to functions like gtk_dialog_add_button(), then the
specified strings seem to be treated as ISO-8859-1, i.e. non ASCII
characters appear as multiple characters instead of being resolved to the
single character they represent according to UTF-8 decoding tables.

Could someone tell me how I can convince GTK to use UTF-8 as the default
on Linux, too?

Thanks alot,

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


Re: GTK on Linux and UTF-8 text

2010-05-04 Thread Andreas Falkenhahn
 On Tue, May 04, 2010 at 02:01:45PM +0200, Andreas Falkenhahn wrote:
 I previously worked with GTK only on Windows and the Windows builds of
 GTK
 always used UTF-8 for everything. Now I played a bit with GTK on Linux
 and
 noticed that it doesn't seem to handle UTF-8 correctly by default.
 Instead, ISO 8859-1 is used (which should be my locale's default
 charset).
 When I pass UTF-8 text to functions like gtk_dialog_add_button(), then
 the
 specified strings seem to be treated as ISO-8859-1, i.e. non ASCII
 characters appear as multiple characters instead of being resolved to
 the
 single character they represent according to UTF-8 decoding tables.

 Could someone tell me how I can convince GTK to use UTF-8 as the default
 on Linux, too?

 Gtk+ uses UTF-8 everywhere for everything[*] so I am almost sure that
 you do not pass UTF-8 even if you think so.  Most likely your strings
 were double-encoded to UTF-8.

Oops, yes, it happened because my text editor seems to have changed the
encoding of sources from ISO 8859-1 to UTF-8. So it really was a double
encoding :)

Thanks,

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


Re: gtk on win32

2010-03-29 Thread Andreas Falkenhahn
Hi Jorge,

On 29.03.2010 at 14:57 Jorge Opaso Pazos wrote:

Hello everybody,

Can I use GTK and all its dependencies to develop Windows applications at
production level? That is a general question, no about a particular
versions.
I have to make a decision, because a new project I'm participating
(commercial application).

It generally works quite good but be prepared to fix bugs that you might
discover in the gtk Windows backend on your own. I discovered quite some
critical bugs (total app freeze, cursor keys misbehaviour, mouse handler bugs)
but nobody seems to have any time to fix them although these are really
critical things that should have high-priority. 

But it would be unfair to complain about this because gtk is free software and
most people work on it in their spare time without getting a penny for their 
work.
And its primary target is Linux after all. Everybody has the sourcecode, so 
everybody
can fix things that don't work. Just be prepared that if you encounter bugs in 
the
Windows gtk, you might have to dive into the gtk sourcecode on your own and
fix things.

Also, gtk 2.16 has less issues on Windows than the 2.18 issues AFAICS.

Greets,

Andreas
--
Remember: It's nice to be important but it's more important to be nice!


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


Re: GTK+ for Mac is online

2009-12-26 Thread Andreas Falkenhahn
On 25.12.2009 at 14:23 Janek Buchholz wrote:

GTK+ for Mac is online 
http://ftp.imendio.com/pub/imendio/gtk-osx/Gtk-Framework-2.14-LATEST.dmg

Is there also a newer version for OS X available? 2.16 or 2.18 maybe?

Andreas
--
Remember: It's nice to be important but it's more important to be nice!


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


Re: GtkFileChooser filter problems

2009-11-21 Thread Andreas Falkenhahn

Hi Bert 

On 21.11.2009 at 11:25 Bert Timmerman wrote:

Hi Andreas,

Andreas Falkenhahn wrote:
 Hi,
 
 I'm having a hard time to get filters to work with the file chooser
dialog. It seems
 that whenever I'm calling gtk_file_chooser_set_filename() before opening
the dialog,
 the file filters are not installed at all. The weird thing is that the
filters work fine when
 I use gtk_file_chooser_set_current_folder() instead set_filename(). But
of course it
 doesn't allow me to set an initially selected file. So I tried to call
gtk_file_chooser_select_filename()
 after set_current_folder() but this doesn't work either.
 
 This is giving me a real headache now. Is this a known issue or am I
doing
 something terribly wrong here?
 
 Tks
 
 Andreas
 --
 Remember: It's nice to be important but it's more important to be nice!
 
 

I recently added filters in a gtk based app.

One thing I learned is:

   /* add a default filter for not filtering files */
   no_filter = gtk_file_filter_new ();
   gtk_file_filter_set_name (no_filter, all);
   gtk_file_filter_add_pattern (no_filter, *.*);
   gtk_file_filter_add_pattern (no_filter, *);
   gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), no_filter);

To allow for normal behaviour.

After that add as many filters as you like.

Regarding your thread:

Setting a filter and then setting a filename (making possible 
contradicting decisions beforehand) and then realizing the widget may 
indeed give the result you mentioned.

Say I have set a filter on *.doc and set a filename with a .txt 
extension is asking for trouble.

Yes, that behaviour would be ok of course but I'm not setting a contradicting 
filename
at all. The filename I'm setting matches the filter perfectly. Yet, whenever I 
call
gtk_file_chooser_set_filename() it seems that the filter combo box is reset. My 
filter
still appears in the combo box in the file chooser dialog but it's impossible 
to make it
the default by calling gtk_file_chooser_set_filter() prior to opening the 
dialog because
gtk_file_chooser_set_filename() always seems to reset the active filter.

From my point of view, the filter should only be reset when the specified file 
name doesn't
match the filter. But if it matches, it doesn't make sense to reset the filter 
because as
far as I can see, it's currently impossible to select an initial filter and an 
initial filename.
These two things seem to be somewhat mutually exclusive currently...

Greets,

Andreas
--
Remember: It's nice to be important but it's more important to be nice!


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


GtkFileChooser filter problems

2009-11-20 Thread Andreas Falkenhahn

Hi,

I'm having a hard time to get filters to work with the file chooser dialog. It 
seems
that whenever I'm calling gtk_file_chooser_set_filename() before opening the 
dialog,
the file filters are not installed at all. The weird thing is that the filters 
work fine when
I use gtk_file_chooser_set_current_folder() instead set_filename(). But of 
course it
doesn't allow me to set an initially selected file. So I tried to call 
gtk_file_chooser_select_filename()
after set_current_folder() but this doesn't work either.

This is giving me a real headache now. Is this a known issue or am I doing
something terribly wrong here?

Tks

Andreas
--
Remember: It's nice to be important but it's more important to be nice!


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