combo completion from db



I need to fill the list_store of a combo box entry from a database based on the contents of the entry widget.  It needs to work just like the gtk completion except it gets its values by continually querying a database whenever the contents of the entry change.  

I connected the key-release-event signal for the entry to a function which performs the query and sets the correct values in the list_store.  This works fine, but it also needs to pull down the drop down list so I can see the query results.  

I use gtk_combo_box_popup() to pull down the list.  The problem is that when the drop down list is pulled down focus is switched to it and I can't continue typing the search parameter in the entry widget.  I also can't use gtk_widget_grab_focus() to reset focus on the entry--it just doesn't work.

Here's the function I connected to the key-release-event signal on the combo 
box's entry:

static gboolean
sigRequeryCombo(GtkWidget *entry, GdkEventKey *event, gpointer combo)
{
  const gchar *text;
  gint num_rows;

  text = gtk_entry_get_text (GTK_ENTRY(entry));

  /* execute query and fill list */
  num_rows = requeryCombo(conn, text, GTK_COMBO_BOX(combo));

  if (num_rows > 0)
  {
    gtk_combo_box_popup (GTK_COMBO_BOX(combo));
  }
  return FALSE;
}

Does gtk_combo_box_set_focus_on_click() do what I want? It isn't implemented 
until 2.6 so I haven't been able to try it yet.  Any other ideas on this?  Maybe I'm going about the completely wrong?

Thanks,
Jeremy



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