Re: Handling Unix signals in a GTK+ application

2006-03-20 Thread Freddie Unpenstein

  Add a unix signal number in the signal handler, and suck it out
  again in a custom event source's prepare method. The prepare
  method can return -1 for its timeout contribution, and true/false
  if there's something in the queue.
 So... poll *will* exit because of the signal... but will it check
 its event sources and everything... if no file descriptor is ready
 and timeout isnt reached ?  you'll have to test it out with an idle
 main loop... because for the same reasons... you cant call
 g_main_context_wakeup().

I'll have to check the Glib source when I get back in about three weeks time... 
 If I remember (the discussion will probably be well and truely over by then... 
 heh).

It SHOULD do the checks, as long as the main loop does a full cycle when it 
gets an EAGAIN from poll(), and doesn't just skip right back into the poll() 
call (which I personally think would be a very bad design idea).  Returning -1 
as the timeout basically tells the main loop to wait indefinately in the poll() 
call (unless a different event source, such as a timeout or idle, tells it to 
finish sooner).

The source prepare methods, as I understand from the documentation, are the 
part that really drives the whole thing.  They prepare the list of file 
descriptors that are passed to poll(), and it's the prepare methods that set up 
the timeout value that will be given to poll().

The event sources that indicated that there was an event waiting are then given 
a chance to dispatch those events after the poll() call.


So it's sort of like an idler in that it'll get called every time through the 
loop (in fact, it should get called EVERY time though the loop, unlike an 
idler), but it's different from an idler in that it won't cause the poll() call 
to exit prematurely, and hence you won't get a busy wait happening.


Fredderic

___
Join Excite! - http://www.excite.com
The most personalized portal on the Web!


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


subscribe

2006-03-20 Thread yueyu lin
--
--
Yueyu Lin
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Widgets inside a GtkDrawingArea

2006-03-20 Thread Olexiy Avramchenko

Sander Marechal wrote:

Hello,

I am writing a hearts game for GNOME using glade and the libglade XML 
loader. The main playing area is a big GtkDrawingArea. I need to add a 
button in the middle of the drawing area during the beginning of the 
game (when you are passing cards to another player). This button needs 
to disappear during the main play.


Is there a way to add a button inside (or on top) a GtkDrawingArea using 
glade? Or using Gtk directly in C? Glade wouldn't let me add one. If it 
isn't possible, is there an easy way I can fake the effect of a button 
sitting in the middle of the drawing area?


This is my first Gtk application (heck it's my first app since I moved 
away from the Win32 platform) so I'm not terribly experienced yet.

Hi,
You can't add a children widget to drawing area (it's not so easy, at 
least). Take a look at GtkLayout instead of GtkDrawingArea. This widget 
provides a window GtkLayout::bin_window that can be used for custom 
drawing like GtkDrawingArea and also it is a container like GtkFixed.


http://developer.gnome.org/doc/API/2.0/gtk/GtkLayout.html

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


Re: Find Signal Name, in callback handler.

2006-03-20 Thread Olexiy Avramchenko

Muthiah Annamalai wrote:

Dear friend,

I want to know if its possible to find Signal Name, in
callback handler.

Im writing language bindings and I need to evaluate
some designs on routing callbacks; with a fair
amount of searching on archives of this ML,
I dont find this question answered well, enough.

Q: void handler(GObject *obj,gpointer *ptr)
   {
  //how do I know which signal 
  // eg: changed, clicked, or whatever

  // triggered this handler?
   }

I can see some of the folks trying to show me the
thing called closures, but I dont want to tackle


1) Use g_signal_handler_find() to find the signal's id.
2) Use g_signal_name() to get the signal's name.

http://developer.gnome.org/doc/API/2.0/gobject/gobject-Signals.html#g-signal-handler-find
http://developer.gnome.org/doc/API/2.0/gobject/gobject-Signals.html#g-signal-name

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


Re: Widgets inside a GtkDrawingArea

2006-03-20 Thread Sander Marechal

Olexiy Avramchenko wrote:

Sander Marechal wrote:
Is there a way to add a button inside (or on top) a GtkDrawingArea 
using glade? Or using Gtk directly in C? Glade wouldn't let me add 
one. If it isn't possible, is there an easy way I can fake the 
effect of a button sitting in the middle of the drawing area?


Hi,
You can't add a children widget to drawing area (it's not so easy, at 
least). Take a look at GtkLayout instead of GtkDrawingArea. This widget 
provides a window GtkLayout::bin_window that can be used for custom 
drawing like GtkDrawingArea and also it is a container like GtkFixed.


http://developer.gnome.org/doc/API/2.0/gtk/GtkLayout.html


Thank you, I got it partially how I want it.

The button is sitting neatly on top of the playing area now, but it has 
a small grey box around it. See the screenshot at [1]. I think that the 
1 pixel grey border is added by an invisible container widget that holds 
the button in question somehow. I have set all the border values on the 
button to 0 already, so I think it's not the button itself.


Is it possible to remove that container, or set it's grey background to 
transparent so that the rounded button shape is drawn directly on the 
green canvas? A GIMPed mockup of the desired result is at [2].


It's no problem if it can't be done in Glade directly. I can simply load 
the glade XML file in C and execute a couple additional GTK commands on 
the button or it's container.


Thanks again!

[1] http://www.jejik.com/sander/hearts.png
[2] http://www.jejik.com/sander/hearts2.png

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


Re: Widgets inside a GtkDrawingArea

2006-03-20 Thread Sander Marechal

Olexiy Avramchenko wrote:
Take a look at GtkLayout instead of GtkDrawingArea. This widget 
provides a window GtkLayout::bin_window that can be used for custom 
drawing like GtkDrawingArea and also it is a container like GtkFixed.


I'm also having trouble getting the GtkLayout resized properly if the 
main window changes size. It looks like GtkLayout and it's container 
element GtkScrolledWindow do not send out configure_event's when the 
main GtkWindow is resized. Is this true?


I have tried attaching a configure_event to the window itself and 
calling getting the size of the GtkScrolledWindow in the code, but that 
doesn't work. The resizing of the GtkLayout starts to lag a couple of 
frames behind the actual resize so it ends up at an incorrect size. 
Setting the configure_event to shoot after the class function improved 
it a little, but it still lags.


Any solutions to this? Thanks!

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