Re: [gtk-list] Clists (Feature request)



I couldn't find the program on your page... Could you send me the program
(would be usefull, as I said, I have no gtk experience), or could somebody
tell me how to make the on_person_selector_list_key_press_event function
the handler for keypresses? Thanks


On Sun, Feb 06, 2000 at 12:57:15AM +0100, Rene' Seindal wrote:
> This is an utility function to set the current focus row.
> 
> void
> gtk_clist_set_focus_row(GtkCList *list, guint row)
> {
>     g_return_if_fail(list != NULL);
>     g_return_if_fail(row >= 0);
>     g_return_if_fail(row < list->rows);
> 
>     list->focus_row = row;
> }
> 
> This is the key_press event handler for the clist.  Ignore the
> PersonSelector stuff, it is structure that contains the clist, among
> other things.
> 
> gboolean
> on_person_selector_list_key_press_event (GtkWidget       *widget,
>                                         GdkEventKey     *event,
>                                         gpointer         user_data)
> {
>     PersonSelector *sel;
> 
> #ifdef DEBUG
>     g_print("on_person_selector_list_key_press_event\n");
> #endif
> 
>     if (event->state != 0)
> 	return FALSE;
> 
>     sel = widget_get_person_selector(GTK_WIDGET(user_data));
>     return person_selector_search(sel,
> gdk_keyval_to_lower(event->keyval));
> }
> 
> 
> gboolean
> person_selector_search(PersonSelector *sel, guint keyval)
> {
>     GtkCList *list = sel->list;
>     guint row;
>     gchar *name;
> 
>     keyval = (guchar)keyval;
>     if (! isprint(keyval))
> 	return FALSE;
> 
> #ifdef DEBUG
>     g_print("person_selector_search: key %c\n", keyval);
> #endif /* DEBUG */
> 
>     row = (list->focus_row + 1) % list->rows;
>     while (row != list->focus_row) {
> 	gtk_clist_get_text(list, row, 0, &name);
> 
> #ifdef DEBUG
> 	g_print("person_selector_search: row %d match %.20s\n", row, name);
> #endif /* DEBUG */
> 
> 	if (tolower(*name) == keyval) {
> 	    gtk_clist_set_focus_row(list, row);
> 
> 	    if (gtk_clist_row_is_visible(list, row) != GTK_VISIBILITY_FULL)
> 		gtk_clist_moveto(list, row, 0, 0.5, 0.0);
> 	    gtk_widget_queue_draw(GTK_WIDGET(list));
> 
> #ifdef DEBUG
> 	    g_print("person_selector_search: got row %d\n", row);
> #endif /* DEBUG */
> 	    return TRUE;
> 	}
> 	row = (row + 1) % list->rows;
>     }
> 
> #ifdef DEBUG
>     g_print("person_selector_search: not found\n");
> #endif /* DEBUG */
> 
>     return FALSE;
> }

-- 

			Frank v Waveren
			fvw@var.cx
			ICQ# 10074100



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