Mercurial > pidgin
comparison src/gtkrequest.c @ 7903:d91806e4ea64
[gaim-migrate @ 8563]
This *should* be a working list field UI implementation. Untested for now.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Sun, 21 Dec 2003 08:52:38 +0000 |
| parents | 365d8a67972d |
| children | 9b478c6e0bfa |
comparison
equal
deleted
inserted
replaced
| 7902:3ca501305ac5 | 7903:d91806e4ea64 |
|---|---|
| 576 | 576 |
| 577 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | 577 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
| 578 } | 578 } |
| 579 | 579 |
| 580 g_signal_connect(G_OBJECT(widget), "changed", | 580 g_signal_connect(G_OBJECT(widget), "changed", |
| 581 G_CALLBACK(field_choice_menu_cb), | 581 G_CALLBACK(field_choice_menu_cb), field); |
| 582 field); | |
| 583 } | 582 } |
| 584 else | 583 else |
| 585 { | 584 { |
| 586 GtkWidget *box; | 585 GtkWidget *box; |
| 587 GtkWidget *first_radio = NULL; | 586 GtkWidget *first_radio = NULL; |
| 611 G_CALLBACK(field_choice_option_cb), field); | 610 G_CALLBACK(field_choice_option_cb), field); |
| 612 } | 611 } |
| 613 } | 612 } |
| 614 | 613 |
| 615 return widget; | 614 return widget; |
| 615 } | |
| 616 | |
| 617 static void | |
| 618 select_field_list_item(GtkTreeModel *model, GtkTreePath *path, | |
| 619 GtkTreeIter *iter, gpointer data) | |
| 620 { | |
| 621 GaimRequestField *field = (GaimRequestField *)data; | |
| 622 const char *text; | |
| 623 | |
| 624 gtk_tree_model_get(model, iter, 0, &text, -1); | |
| 625 | |
| 626 gaim_request_field_list_add_selected(field, text); | |
| 627 } | |
| 628 | |
| 629 static void | |
| 630 list_field_select_changed_cb(GtkTreeSelection *sel, GaimRequestField *field) | |
| 631 { | |
| 632 gaim_request_field_list_clear_selected(field); | |
| 633 | |
| 634 gtk_tree_selection_selected_foreach(sel, select_field_list_item, field); | |
| 635 } | |
| 636 | |
| 637 static GtkWidget * | |
| 638 create_list_field(GaimRequestField *field) | |
| 639 { | |
| 640 GtkWidget *sw; | |
| 641 GtkWidget *treeview; | |
| 642 GtkListStore *store; | |
| 643 GtkCellRenderer *renderer; | |
| 644 GtkTreeSelection *sel; | |
| 645 GtkTreeViewColumn *column; | |
| 646 | |
| 647 /* Create the scrolled window */ | |
| 648 sw = gtk_scrolled_window_new(NULL, NULL); | |
| 649 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
| 650 GTK_POLICY_AUTOMATIC, | |
| 651 GTK_POLICY_ALWAYS); | |
| 652 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | |
| 653 GTK_SHADOW_IN); | |
| 654 gtk_widget_show(sw); | |
| 655 | |
| 656 /* Create the list store */ | |
| 657 store = gtk_list_store_new(1, G_TYPE_STRING); | |
| 658 | |
| 659 /* Create the tree view */ | |
| 660 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
| 661 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
| 662 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
| 663 | |
| 664 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); | |
| 665 | |
| 666 if (gaim_request_field_list_get_multi_select(field)) | |
| 667 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE); | |
| 668 | |
| 669 g_signal_connect(G_OBJECT(sel), "changed", | |
| 670 G_CALLBACK(list_field_select_changed_cb), field); | |
| 671 | |
| 672 column = gtk_tree_view_column_new(); | |
| 673 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); | |
| 674 | |
| 675 renderer = gtk_cell_renderer_text_new(); | |
| 676 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
| 677 gtk_tree_view_column_add_attribute(column, renderer, "text", 0); | |
| 678 | |
| 679 gtk_container_add(GTK_CONTAINER(sw), treeview); | |
| 680 gtk_widget_show(treeview); | |
| 681 | |
| 682 return sw; | |
| 616 } | 683 } |
| 617 | 684 |
| 618 static void * | 685 static void * |
| 619 gaim_gtk_request_fields(const char *title, const char *primary, | 686 gaim_gtk_request_fields(const char *title, const char *primary, |
| 620 const char *secondary, GaimRequestFields *fields, | 687 const char *secondary, GaimRequestFields *fields, |
| 809 widget = create_int_field(field); | 876 widget = create_int_field(field); |
| 810 else if (type == GAIM_REQUEST_FIELD_BOOLEAN) | 877 else if (type == GAIM_REQUEST_FIELD_BOOLEAN) |
| 811 widget = create_bool_field(field); | 878 widget = create_bool_field(field); |
| 812 else if (type == GAIM_REQUEST_FIELD_CHOICE) | 879 else if (type == GAIM_REQUEST_FIELD_CHOICE) |
| 813 widget = create_choice_field(field); | 880 widget = create_choice_field(field); |
| 881 else if (type == GAIM_REQUEST_FIELD_LIST) | |
| 882 widget = create_list_field(field); | |
| 814 | 883 |
| 815 if (type == GAIM_REQUEST_FIELD_STRING && | 884 if (type == GAIM_REQUEST_FIELD_STRING && |
| 816 gaim_request_field_string_is_multiline(field)) | 885 gaim_request_field_string_is_multiline(field)) |
| 817 { | 886 { |
| 818 gtk_table_attach(GTK_TABLE(table), widget, | 887 gtk_table_attach(GTK_TABLE(table), widget, |
