Mercurial > pidgin
comparison src/gtkrequest.c @ 7909:5be22af4ebfc
[gaim-migrate @ 8569]
Reworked the list field API a bit. Items now have data associated with them
(which is not automatically freed by the API).
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 21 Dec 2003 20:51:05 +0000 |
parents | 1d0bc32f8038 |
children | c3dc33bb94dc |
comparison
equal
deleted
inserted
replaced
7908:ad4841411ada | 7909:5be22af4ebfc |
---|---|
619 GtkTreeIter *iter, gpointer data) | 619 GtkTreeIter *iter, gpointer data) |
620 { | 620 { |
621 GaimRequestField *field = (GaimRequestField *)data; | 621 GaimRequestField *field = (GaimRequestField *)data; |
622 const char *text; | 622 const char *text; |
623 | 623 |
624 gtk_tree_model_get(model, iter, 0, &text, -1); | 624 gtk_tree_model_get(model, iter, 1, &text, -1); |
625 | 625 |
626 gaim_request_field_list_add_selected(field, text); | 626 gaim_request_field_list_add_selected(field, text); |
627 } | 627 } |
628 | 628 |
629 static void | 629 static void |
641 GtkWidget *treeview; | 641 GtkWidget *treeview; |
642 GtkListStore *store; | 642 GtkListStore *store; |
643 GtkCellRenderer *renderer; | 643 GtkCellRenderer *renderer; |
644 GtkTreeSelection *sel; | 644 GtkTreeSelection *sel; |
645 GtkTreeViewColumn *column; | 645 GtkTreeViewColumn *column; |
646 GtkTreeIter iter; | |
647 const GList *l; | |
646 | 648 |
647 /* Create the scrolled window */ | 649 /* Create the scrolled window */ |
648 sw = gtk_scrolled_window_new(NULL, NULL); | 650 sw = gtk_scrolled_window_new(NULL, NULL); |
649 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | 651 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
650 GTK_POLICY_AUTOMATIC, | 652 GTK_POLICY_AUTOMATIC, |
652 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | 654 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), |
653 GTK_SHADOW_IN); | 655 GTK_SHADOW_IN); |
654 gtk_widget_show(sw); | 656 gtk_widget_show(sw); |
655 | 657 |
656 /* Create the list store */ | 658 /* Create the list store */ |
657 store = gtk_list_store_new(1, G_TYPE_STRING); | 659 store = gtk_list_store_new(2, G_TYPE_POINTER, G_TYPE_STRING); |
658 | 660 |
659 /* Create the tree view */ | 661 /* Create the tree view */ |
660 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | 662 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
661 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | 663 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); |
662 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | 664 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); |
672 column = gtk_tree_view_column_new(); | 674 column = gtk_tree_view_column_new(); |
673 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); | 675 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); |
674 | 676 |
675 renderer = gtk_cell_renderer_text_new(); | 677 renderer = gtk_cell_renderer_text_new(); |
676 gtk_tree_view_column_pack_start(column, renderer, TRUE); | 678 gtk_tree_view_column_pack_start(column, renderer, TRUE); |
677 gtk_tree_view_column_add_attribute(column, renderer, "text", 0); | 679 gtk_tree_view_column_add_attribute(column, renderer, "text", 1); |
680 | |
681 for (l = gaim_request_field_list_get_items(field); l != NULL; l = l->next) | |
682 { | |
683 const char *text = (const char *)l->data; | |
684 | |
685 gtk_list_store_append(store, &iter); | |
686 | |
687 gtk_list_store_set(store, &iter, | |
688 0, gaim_request_field_list_get_data(field, text), | |
689 1, text, | |
690 -1); | |
691 } | |
678 | 692 |
679 gtk_container_add(GTK_CONTAINER(sw), treeview); | 693 gtk_container_add(GTK_CONTAINER(sw), treeview); |
680 gtk_widget_show(treeview); | 694 gtk_widget_show(treeview); |
681 | 695 |
682 return sw; | 696 return sw; |