Re: [gtk-list] Re: Blocking Dialog and Button listening to right,left mouse



Some Guy wrote:
> I think he means 'blocking' as in a blocking read() or function of that
> sort. ex:
>     result = make_dialog();
>     switch (result) {
>     case 1: /* handle first button... */
>     ....
> So the dialog will return the button pressed from the function without
> having to establish signal handlers.  I'm pretty sure this is not possible
> in gtk.  But that doesn't matter much since you can accomplish the same
> thing by just connecting all the buttons to a single handler (but passing
> different values depending on which button it is), and using
> gtk_grab_add/remove.
> 
It is possible. I've done something like this, though I've understand
that it is also in GNOME. I've once try to compile GNOME and failed and
lately my internet connection from office is down for 2 weekes and it'll
continue to be down for more than a week from now on. 

My solution is not too elegant, but it works. 8-) I'm a big fan of C++,
but because of the so poor documentation of gtk-- and the lack of the
sources of gtk+ and gtk-- (I've made the mistake to download only the
compiled version: deb files for my debian system), the code is a big
mixture of gtk+ and C++ code. 

Basicly, I access my function like this:

gint						// the number returned is the index of 
						// the pressed buton
show_message_box (gchar *title,			// mesage box title
                  gchar *message,		// message text
                  gchar *xpm_filename,		// a filename for the pixmap to 
						// be displayed beside the text
                  gint nbutton,			// the number of buttons to be shown
                  gchar **button_names,		// the text of buttons
                  gint default_button);		// the default button

gint
show_message_box (gchar *title,
                  gchar *message,
                  gchar **xpm_data,
                  gint nbutton,
                  gchar **button_names,
                  gint default_button);


(Here you have some function overloading, but, if you whant to stay just
with C, you can rename one of the function).

When the function is displayed it does something like this:

  // now show the dialog
  gtk_widget_show (dialog);

  // Poll the events queue
  while ( !message_box_destroyed )
    while ( gtk_events_pending() )
      gtk_main_iteration();

  return message_box_ret;

If anyone needs this, tell me. 

Ionutz



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]