int main (int argc, char **argv) { GtkWidget *window; GtkWidget *sw; GtkWidget *tv; GtkWidget *box; GtkWidget *combo_box; GtkTreeModel *model; gint i; gtk_init (&argc, &argv); if (g_getenv ("RTL")) gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL); our_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) book_closed_xpm); #if 0 models[MODEL_TYPES] = GTK_TREE_MODEL (gtk_tree_model_types_new ()); #endif models[MODEL_LIST] = create_list_model (); models[MODEL_TREE] = create_tree_model (); model = create_list_model (); models[MODEL_SORTED_LIST] = gtk_tree_model_sort_new_with_model (model); g_object_unref (model); model = create_tree_model (); models[MODEL_SORTED_TREE] = gtk_tree_model_sort_new_with_model (model); g_object_unref (model); models[MODEL_EMPTY_LIST] = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_INT)); models[MODEL_EMPTY_TREE] = GTK_TREE_MODEL (gtk_tree_store_new (1, G_TYPE_INT)); models[MODEL_NULL] = NULL; run_automated_tests (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_window_set_default_size (GTK_WINDOW (window), 430, 400); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), box); tv = gtk_tree_view_new_with_model (models[0]); gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv), GDK_BUTTON1_MASK, row_targets, G_N_ELEMENTS (row_targets), GDK_ACTION_MOVE | GDK_ACTION_COPY); gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (tv), row_targets, G_N_ELEMENTS (row_targets), GDK_ACTION_MOVE | GDK_ACTION_COPY); /* Model menu */ combo_box = gtk_combo_box_text_new (); gtk_widget_set_halign (combo_box, GTK_ALIGN_CENTER); for (i = 0; i < MODEL_LAST; i++) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), model_names[i]); gtk_container_add (GTK_CONTAINER (box), combo_box); g_signal_connect (combo_box, "changed", G_CALLBACK (model_selected), tv); /* Columns menu */ combo_box = gtk_combo_box_text_new (); gtk_widget_set_halign (combo_box, GTK_ALIGN_CENTER); for (i = 0; i < COLUMNS_LAST; i++) gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), column_type_names[i]); gtk_container_add (GTK_CONTAINER (box), combo_box); set_columns_type (GTK_TREE_VIEW (tv), COLUMNS_LOTS); gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), COLUMNS_LOTS); g_signal_connect (combo_box, "changed", G_CALLBACK (columns_selected), tv); sw = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_hexpand (sw, TRUE); gtk_widget_set_vexpand (sw, TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (box), sw); gtk_container_add (GTK_CONTAINER (sw), tv); create_prop_editor (G_OBJECT (tv), GTK_TYPE_TREE_VIEW); create_prop_editor (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (tv))), GTK_TYPE_TREE_SELECTION); gtk_widget_show_all (window); gtk_main (); return 0; }
int main (int argc, char **argv) { GtkWidget *window; GtkWidget *sw; GtkWidget *tv; GtkWidget *table; GtkWidget *om; GtkWidget *menu; GtkTreeModel *model; gint i; gtk_init (&argc, &argv); our_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) book_closed_xpm); #if 0 models[MODEL_TYPES] = GTK_TREE_MODEL (gtk_tree_model_types_new ()); #endif models[MODEL_LIST] = create_list_model (); models[MODEL_TREE] = create_tree_model (); model = create_list_model (); models[MODEL_SORTED_LIST] = gtk_tree_model_sort_new_with_model (model); g_object_unref (model); model = create_tree_model (); models[MODEL_SORTED_TREE] = gtk_tree_model_sort_new_with_model (model); g_object_unref (model); models[MODEL_EMPTY_LIST] = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_INT)); models[MODEL_EMPTY_TREE] = GTK_TREE_MODEL (gtk_tree_store_new (1, G_TYPE_INT)); models[MODEL_NULL] = NULL; run_automated_tests (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_window_set_default_size (GTK_WINDOW (window), 430, 400); table = gtk_table_new (3, 1, FALSE); gtk_container_add (GTK_CONTAINER (window), table); tv = gtk_tree_view_new_with_model (models[0]); gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv), GDK_BUTTON1_MASK, row_targets, G_N_ELEMENTS (row_targets), GDK_ACTION_MOVE | GDK_ACTION_COPY); gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (tv), row_targets, G_N_ELEMENTS (row_targets), GDK_ACTION_MOVE | GDK_ACTION_COPY); /* Model menu */ menu = gtk_menu_new (); i = 0; while (i < MODEL_LAST) { GtkWidget *mi; const char *name; name = model_names[i]; mi = gtk_menu_item_new_with_label (name); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); #if 0 window = create_prop_editor (G_OBJECT (models[i])); gtk_window_set_title (GTK_WINDOW (window), name); #endif ++i; } gtk_widget_show_all (menu); om = gtk_option_menu_new (); gtk_option_menu_set_menu (GTK_OPTION_MENU (om), menu); gtk_table_attach (GTK_TABLE (table), om, 0, 1, 0, 1, 0, 0, 0, 0); g_signal_connect (om, "changed", G_CALLBACK (model_selected), tv); /* Columns menu */ menu = gtk_menu_new (); i = 0; while (i < COLUMNS_LAST) { GtkWidget *mi; const char *name; name = column_type_names[i]; mi = gtk_menu_item_new_with_label (name); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); ++i; } gtk_widget_show_all (menu); om = gtk_option_menu_new (); gtk_option_menu_set_menu (GTK_OPTION_MENU (om), menu); gtk_table_attach (GTK_TABLE (table), om, 0, 1, 1, 2, 0, 0, 0, 0); set_columns_type (GTK_TREE_VIEW (tv), COLUMNS_LOTS); gtk_option_menu_set_history (GTK_OPTION_MENU (om), COLUMNS_LOTS); g_signal_connect (om, "changed", G_CALLBACK (columns_selected), tv); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_table_attach (GTK_TABLE (table), sw, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_container_add (GTK_CONTAINER (sw), tv); gtk_widget_show_all (window); gtk_main (); return 0; }