开发者

Reorder GtkTreeView in Microsoft Windows using gtk_tree_view_set_reorderable

According to the GTK+ Reference Manual, using gtk_tree_view_set_reorderable will enable drag and drop for reordering rows.

I tried it in Linux using GTK+ 开发者_如何学运维3 and GTK+ 2, and it seems to work fine. But when I tried it in Microsoft Windows, using GTK+ 2.24.0, I can only drag rows but can't drop them.

I tested it using Ubuntu Linux 11.04 (with Gnome 3 Desktop) and Microsoft Windows XP Service Pack 3.

Do I need to do something else in Microsoft Windows, other than setting reorderable to TRUE?

Here is a simple program I used to test this:

#include <gtk/gtk.h>

enum
{
   TITLE_COLUMN,
   N_COLUMNS
};

int
main (int argc, char* argv[])
{
    gtk_init (&argc, &argv);

    GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
    g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

    GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING);
    gtk_list_store_insert_with_values (store, NULL, -1, TITLE_COLUMN, "Ubuntu", -1);
    gtk_list_store_insert_with_values (store, NULL, -1, TITLE_COLUMN, "Fedora", -1);
    gtk_list_store_insert_with_values (store, NULL, -1, TITLE_COLUMN, "Debian", -1);
    gtk_list_store_insert_with_values (store, NULL, -1, TITLE_COLUMN, "Arch Linux", -1);
    gtk_list_store_insert_with_values (store, NULL, -1, TITLE_COLUMN, "Mandriva", -1);
    gtk_list_store_insert_with_values (store, NULL, -1, TITLE_COLUMN, "Gentoo", -1);
    gtk_list_store_insert_with_values (store, NULL, -1, TITLE_COLUMN, "openSUSE", -1);
    gtk_list_store_insert_with_values (store, NULL, -1, TITLE_COLUMN, "Slackware", -1);

    GtkWidget* tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
    gtk_tree_view_set_reorderable (GTK_TREE_VIEW (tree), TRUE);
    gtk_container_add (GTK_CONTAINER (window), tree);

    g_object_unref (G_OBJECT (store));

    GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes ("Linux Distribution",
        gtk_cell_renderer_text_new (),
        "text", TITLE_COLUMN,
        NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);

    gtk_widget_show_all (window);

    gtk_main ();

    return 0;
}


This may be a bug in the Windows GTK+ port. The GTK+ main development is focused on Linux and other X11 platforms, and the ports to Windows and Mac OS definitely don't get as much attention.

You might want to post this question to the GTK+ mailing list. If you don't get a reasonable answer, you should file a bug report.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜