GtkComboBox focus issue
- From: Pramod Patangay <pramod patangay gmail com>
- To: gtk-list gnome org
- Subject: GtkComboBox focus issue
- Date: Thu, 7 Jul 2005 19:37:24 +0530
Hi,
I am trying to grab focus to GtkComboBox but focus is not set to it.
Here's a sample program. What's wrong with the code?
gboolean kp(GtkWidget *w, GdkEvent* e, gpointer d)
{
printf("Key Pressed\n");
gtk_widget_grab_focus(GTK_WIDGET(d));
return TRUE;
}
int main( int argc, char *argv[] )
{
gtk_init (&argc, &argv);
GtkWidget *dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget* l = gtk_layout_new(NULL,NULL);
gtk_widget_show(l);
GtkWidget* b = gtk_button_new_from_stock(GTK_STOCK_FLOPPY);
gtk_layout_put(GTK_LAYOUT(l),b,40,70);
ts = gtk_tree_store_new(1, G_TYPE_STRING);
GtkCellRenderer* cr = gtk_cell_renderer_text_new();
GtkTreeIter iter;
gtk_tree_store_insert(ts, &iter, NULL, 0);
gtk_tree_store_set(ts, &iter, 0, "FIRST", -1);
combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ts));
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo),cr,FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo),cr,"text",0,NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(combo),0);
gtk_widget_show(combo);
gtk_layout_put(GTK_LAYOUT(l),combo,20,20);
gtk_widget_grab_focus(b);
gtk_widget_show(b);
g_signal_connect(b,"key-press-event",G_CALLBACK(kp),combo);
gtk_container_add(GTK_CONTAINER(dialog),l);
gtk_widget_show(dialog);
gtk_main();
return 0;
}
Thanks
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]