Re: gtk_combo behavior



    Hi GTKers.

    Tony, it seems that the tutorial section 9.11 is broken (or, at 
    least, lacks an important information : the "activate" signal
    on the combo->entry is already connected to a handler in order
    to display the list popup window. This is why you may want
    to use gtk_combo_disable_activate()). But more important,
    connecting a handler to the "activate" signal does only a small
    part of the job.

Hi all,

I have a gtk_combo that I am using basically exactly as described in the
tutorial.  It semi-works, or rather works as far as is specified, but is
annoying to use.  Let me describe it:

If the operator types in a value and hits enter, my callback gets the
"activate" signal and responds accordingly, reading the text from the
entry associated with the combo.  Annoyingly, the list of choices pops
up in the window, as if the little triangle was clicked.  The operator
has to hit ESC, or click elsewhere, to make this go away.  How can I
prevent this?

    Do not connect to ::activate (see below) or use the 
    gtk_combo_disable_activate() function.

Worse, when an operator clicks the little triangle, and then selects one
of the choices, the entry text changes (which would make the operator
suspect that the action had occurred), but my "activate" signal handler
is not called.  If the operator then hits enter, it gets called, but
then the list pops up again.  I suspect that I need to attach a
"select_child" signal handler, which will act as if an "activate" for
the entry was done, but the order in which things need to happen is not
clear to me.  E.g., when the "select_child" signal handler is called,
will the widget's own behavior of putting the text into the combo->entry
widget already have occurred?

    You should better use the combo->entry::changed signal. You'll get
    it in both cases:
      a) when the usert enters text in the entry
      b) when the user selects a new child
    Moreover, you don't rely on a particular user action (ie the user
    do not have to press ENTER to validate the text - just remember
    that a lot of GUI user do not use ENTER when typing text in a 
    single line edit box)

I looked into testgtk and (one combo inside of) glade, and they have the
same annoying behavior for gtk_combo's.  Neither of my Gtk/Gnome books,
nor GGAD, seem to have any advice on this.

Can anyone suggest how to get the nice behavior operators will expect? 
Or point me toward some example code that does so?  That typing into the
entry gets behavior like an entry, but that selecting a choice is
identical to having types that choice and hit enter?

    Connecting to the combo->entry::activate signal is not the
    way it should work, since the GtkComboBox widget allready has
    this signal handler:

/* in gtkcombo.c */

static void        
gtk_combo_activate (GtkWidget        *widget,
      GtkCombo         *combo)
{
  gtk_combo_popup_list (combo);

  if (!GTK_WIDGET_HAS_FOCUS (combo->entry))
    gtk_widget_grab_focus (combo->entry);

  gtk_grab_add (combo->popwin);
  gdk_pointer_grab (combo->popwin->window, TRUE,
      GDK_BUTTON_PRESS_MASK | 
      GDK_BUTTON_RELEASE_MASK |
      GDK_POINTER_MOTION_MASK, 
      NULL, NULL, GDK_CURRENT_TIME);
} 

    Hope it helps,

    Emmanuel


Thanks in advance,

Eric M. Monsler

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







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