Gtk+ Modality Problem

2006-06-21 Thread Atanas Atanasov
Excuse me for the beginner question, but I am truly stuck on this
issue and do not know how to resolve it. My version of gtk is 2.8.18
under Linux 2.6.15-25-686. I have a simple function that behaves like
MessageBox under Windows and I am trying to make the messagebox to
behave truly modal. To test it I created this other window and I call
the messagebox in the delete event to ask if the user would like to
exit. I tried:

gtk_window_set_modal (GTK_WINDOW(window), TRUE);
gtk_grab_add (window);
gtk_widget_grab_focus (window);

And still I can bring the focus back to my main window. When I
generate an event (say click on the close button once more) it is not
processed immediately but exactly after the messagebox exits. This
approaches my aim, however I would like to force my messagebox into
receiving all events (or at least keyboard&mouse) so that nothing goes
to the main window.

Thanks in advance.

Regards,
Atanas Atanasov
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Gtk+ Modality Problem

2006-06-21 Thread Atanas Atanasov
> Don't forget to set the transient window:
>
> gtk_window_set_transient_for(GTK_WINDOW(window),GTK_WINDOW(parent_window));

I saw this option, but I would like to make the messagebox work
independently of the window from which it is called. Is this possible?
What I need is exatcly the behaviour of a modal MessageBox under
Windows.

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


Re: Gtk+ Modality Problem

2006-06-22 Thread Atanas Atanasov
I managed to make it partially modal using a combination of functions:
set_modal, grab_add and set_transient_for. However I can still say
resize the window behind. It seems as you said that this i supposed to
be the behaviour since gtk_message_dialow_new creates a dialog with
identical functionality.

A Windows API person told me that when a window is modal all events
except a small set are filtered out for the back window. This small
set should definitely include paint and clicks and keyboard should be
out of it. Right now since I can resize the window with the mouse,
clearly the clicks are not filtered. Is there a way to set such a
filter so as to force modality further?

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


Re: Gtk+ Modality Problem

2006-06-22 Thread Atanas Atanasov
The way ti works under windows: The window manager can distinguish
between what is called the client (the inside) and non-client
(titlebar & borders) areas a window. Subsequently all mouse events are
separated in two classes - normal and NC (non-client). Then the
default handlers (through DefWindowProc) for NC events will perform
the resizing and these tasks posting specific events that can be
handled by the application e.g. WM_SIZE, WM_MOVE. Of course one can
add a custom handler for any NC message thus overshadowing the default
behaviour. The is also a mechanism that can perform message filtering.
Does there exist such a mechanism in Gtk and how can I set it to
filter all mouse/keyboard events so that no subsequent resizes etc
will propagate?

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


Re: In gtk+ application,how to parse xml file

2006-06-22 Thread Atanas Atanasov
In such cases always check GLib. This is most probably the most useful
library ever written. If you check the GLib Utilities section of
http://developer.gnome.org/doc/API/2.0/glib/index.html you will find
there is a simple XML (a subset actually) parser (see
http://developer.gnome.org/doc/API/2.0/glib/glib-Simple-XML-Subset-Parser.html).
You can also use an INI (key-value) file parser (see
http://developer.gnome.org/doc/API/2.0/glib/glib-Key-value-file-parser.html).

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


Re: Gtk+ Modality Problem

2006-06-23 Thread Atanas Atanasov
I did some experiments with gdk_window_add_filter. First of all there
is a GdkWindow associated with every GtkWidget. It can be acquired
either by ->window or using gtk_widget_get_parent_window. Then is it
not so hard to add an event filter to any particular widget - in my
case to the parent window. The filter is, in reality, a function which
takes a GdkXEvent and should either translate the message manually to
a GdkEvent, or leave the system continue (default translation), or
drop it on the floor. First thing I tried is to drop everything on the
floor and this made my application "not responding a couple of times".
Then I got a printout of the events and after some trying I realised
that if I filter event of type 33 (not sure what this means in X
style) the WM considers the application "not responding". Even when I
filtered everything except type 33, no further modality was achieved.
The only explanation I have is that the respective resize, move, etc
events are handled on a lower level than Gtk i.e. WM or even X11.
Therefore no matter what I do with the events from Gtk, I cannot
modify this default behaviour. Even further, this kind of work starts
going to specific with respect to platform, display server and window
manager - and I would definitely like to avoid that. I guess I will
have to leave the issue as it is and go on with my work.

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


GtkFixed child control resizing

2006-07-05 Thread Atanas Atanasov
I have a GtkWindow with a single GtkFixedChild. Then all the rest of
the interface goes into the GtkFixed with exact positions which I can
set through gtk_fixed_put or gtk_fixed_move. Suppose I have a GtkLabel
child. I would like to be able to set its size and apply a text
alignment through gtk_label_set_justify - for example centered.
However I do not see how this can be done since GTK is a layout widget
toolkit and one rarely works with specific coordinates in this case.
Also I would like to set the vertical alignment of the text.

Thanks in advance,
Atanas
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkFixed child control resizing

2006-07-05 Thread Atanas Atanasov
Thanks. The size request worked. However there is an issue. Say I
create my label to cover all the GtkFixed and set its text
justification to left. What I expect to see is something like:

/--\
|  |
|line 1 is longer  |
|line2 |
|  |
\--/

but what I see is

/--\
 |  |
 | line 1 is longer |
 | line2|
 |  |
 \--/

It seems that first Gtk computes the required minimum size of the
label. Centers a rectangle in the "outer label" and draws my contents
be it left justified inside the small minimal size rectangle. Is there
a way to change this behaviour? Furthermore how can I achieve vertical
alignment?

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


Re: Re: GtkFixed child control resizing

2006-07-05 Thread Atanas Atanasov
Thanks. It worked perfectly.

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


Three state check button

2006-07-06 Thread Atanas Atanasov
Is there an option that would make a check button have a third state.
What I am after is similar to BS_3STATE and BS_AUTO3STATE styles of
the BUTTON class in Windows.

Any suggestions are welcome.

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


Re: Three state check button

2006-07-06 Thread Atanas Atanasov
It worked but I would say partially. I tested with a GtkCheckButton
and its appearance is a shaded tick. However I cannot see how I can
get and set the "third" state.  Is the button supposed to change its
state automatically as it does with not-inconsistent buttons or I have
to receive the pressed and released and change the state accordingly
up to my preference.

I also have another problem. I would like to know whether the button
is pressed at some moment or not. I could not find a function which
returns this aspect of the button state. Is there any other solution
apart from trapping pressed and released and keeping a flag of the
state.

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


Re: Why ? When segmentation fault,there has no "core" file

2006-07-09 Thread Atanas Atanasov
My best advice is to read the GDB Manual -
http://www.gnu.org/software/gdb/documentation/. Chapters 4 and 5
should give you a fairly good idea how to perform simple debugging on
your program. If you don't feel like get some GUI debugger like
Insight (http://sources.redhat.com/insight/).

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


Re: How to keep the check button' checked state

2006-07-09 Thread Atanas Atanasov
You can use the button-press-event and button-release-event signals of
GtkWidget 
(http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#GtkWidget-button-press-event
and 
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#GtkWidget-button-release-event).
By returning TRUE you will bypass the default behaviour and do
whatever you like with the button. Eventually you have to use
gtk_toggle_button_set_active and gtk_toggle_button_set_inconsistent to
set the state of the check button from your code.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: About gtk_object_set_data()

2006-07-09 Thread Atanas Atanasov
There are two approaches. The data you set with gtk_object_set_data is
simply a gpointer and  when the object is destroyed or the data is
removed it manages the pointer but not the data (location) it points
to. If you eventually would like to perform some freeing when the data
is removed use g_object_set_data_full and specify a destroy callback.

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


Re: I did not know this leak memory or not (gtk_object_set_data)

2006-07-09 Thread Atanas Atanasov
>
> /***/
> guint *p = NULL;
> p = g_malloc0(sizeof(guint)):
>
> gtk_object_set_data(GTK_OBJECT(button),"key",p);
> /*/

Why would you allocate the size of a single guint??? If all you want
to store is an (unsigned) integer value simply convert it to gpointer
and store it straight away. If you need to store a pointer to an array
then allocate and specify a destroy callback using
g_object_set_data_full and in the function use g_free.

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


Re: why button is hidden behind drawing area(win32)

2006-07-10 Thread Atanas Atanasov
As a more general question: How is the drawing order in a GtkFixed
determined? Can I control this since I might need it at a later stage
of my project.

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


Re: RADiola, a GTK RAD tool

2006-07-10 Thread Atanas Atanasov
Hi,

I really like the idea. Looks great! The logical editor is a nice idea
and it definitely outlines the ease with which the tool can be used.
Can I get a sample version to try it?

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


Parent window for other GtkWindow-s

2006-07-12 Thread Atanas Atanasov
I have a set of GtkWindow-s and I would like to enclose them in a
single frame - something very similar to the MDI interface. What
widget can I use for the parent frame / window? It is important that
the child windows will appear inside the parent window and one will
not see them outside its border.

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


Re: why button is hidden behind drawing area(win32)

2006-07-12 Thread Atanas Atanasov
I am trying to avoid libgnome and to stick to the pure gtk. Therefore
GnomeCanvas is not really a solution. In reality my project is not yet
in the stage where I require specific z-order and the problem is not
so apparent yet. However I will have to face it one day, sooner or
later. I guess the worst case solution in this case would be a custom
widget derived from a convinient class. I will let you know what I get
to that because right now there are other issues on my mind. I asked
since the topic was related to my future work.

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


GtkWindow show and move

2006-07-12 Thread Atanas Atanasov
I have a fragment of code similar to this:

gtk_widget_show_all (window);
gtk_window_resize (window, ...);

The problem is that sometimes the specified window starts with the
size I set and sometimes it doesn't. This problem occurs in both debug
& release versions, and it seems to be completely random. What I know
is that before a window is shown the resize function acts differently.
It seems that it works well after the window is shown so as such it is
a timing issue. If for example I delay for a second between these two
lines with g_usleep(100); everything would be fine. How can I
solve the problem without introducing any artificial solutions such as
delays and the similar? Should I try to purge the message queue
running gtk_main_iteration while gtk_main_events_pending? Would it
make a difference if I use functions like gtk_widget_request_size and
the alike requests?

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


Re: why button is hidden behind drawing area(win32)

2006-07-12 Thread Atanas Atanasov
In this case what solution can be used to force the display order?
Should one check the code of the respective functions and make a local
copy of the code, modifying it as appropriate? I am afraid this will
change too quickly and my code might not be compatible with future
versions of gtk.

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


Re: why button is hidden behind drawing area(win32)

2006-07-12 Thread Atanas Atanasov
> I cant count how many time's I've said this: "widgets do not overlap in gtk+".
>
> I'm sure that whatever design you want to achieve can be done by
> packing widgets into containers normally.
>

My project is still in an early stage and I have other things to worry
about. However I do need overlapping widgets for the simple reason
that I am trying to mimic Windows and that's how it works. I
understand that from a design point of view this contradicts gtk+ but
I will have to figure out some way to make this work. Right now in
order to position widgets freely in a window i place a GtkFixed child
and make it contain everything. Eventually one solution may be using a
different bin widget but I still haven't come across something
suitable.

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


Re: g_queue_find problems

2006-07-12 Thread Atanas Atanasov
Are you sure that your search key is part of the queue? The issue
might be that the your search key is a copy of the string stored in
the queue and the pointers won't match. If this is the case try using
g_queue_find_custom and wrap strcmp in a simple function. Otherwise
you will have to make sure the pointers match.

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


Re: Parent window for other GtkWindow-s

2006-07-12 Thread Atanas Atanasov
Thanks for the information - it was very useful. If I have any
problems I will write back.

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


Re: GtkWindow show and move

2006-07-13 Thread Atanas Atanasov
I did the queue purging at a different point - after all widgets are
created. This works fine so far.

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


Re: RADiola, a GTK RAD tool

2006-07-16 Thread Atanas Atanasov
Maybe I can give some help on RADiola. My suggestion would be to get
the bare GUI you have done, compile and release it so that there will
be a skeleton. There also is another issue I thought about which is
the language support. Excuse me if you wrote something about this
already in the documentation released but I did not have time to go
through it in detail. My idea was as follows: Since you are aiming at
a tool which makes application development easy, I would suggest
picking a suitable language (or even a set). Something like python
might be quite easy to handle. However the language binding can be
done as some sort of plugin which is dynamically loaded. What were the
intentions in this direction?

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


Re: More about RADiola

2006-07-18 Thread Atanas Atanasov
Why don't you try to set a mailing list at sourceforge - it should be
possible. This way we will keep RADiola specific talk there.

I like the idea of XML "code" template. It can be a good option to
make the code browser fairly portable languagewise. Though we have to
discuss this. I have a couple of ideas but it would be better not to
flood the gtk mailing list anymore. See what you can do and post us a
link here please.

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


Label problem under Win32

2006-07-19 Thread Atanas Atanasov
I have a small GTK+ application for Linux and recently ported it for
Windows (2000). However I am experiencing one problem - the text in
all label is white instead of black. I do not have any fancy themes or
appearance tweaks. More interestingly the mnemonics show in black i.e.
if I have a button with text "_Cancel" the underline would be black
but none of the text. Is there some setting which affects this because
I do not want to force the color?

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


Re: Allow a GtkWindow to prevent losing focus

2006-07-26 Thread Atanas Atanasov
I have been trying to do something similar - the behaviour of modal
windows under Windows. However this solution seemed too fragile
because you never know what window manager will be running beneath.
After all most of these functions just pass on hints to the window
manager, and the behaviour depends on it completely. Therefore if you
REALLY need this sort of thing you may need to fix your project on a
specific WM and start doing some not so nice things as trapping
XEvents globally and the alike. Mind you that I did not go into detail
because it was not so crucial and I did not want to make the interface
dull.

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