0

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;
}

1 Answers1

1

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.

Bob Murphy
  • 5,814
  • 2
  • 32
  • 35
  • It seems like it's really an unresolved bug in GTK+ for Windows since version 2.20, it didn't showed up from just a Google search, and I thought it's not a bug since many website shows pictures using Windows and this particular functionality: https://bugzilla.gnome.org/show_bug.cgi?id=616544 I'm currently trying to resolve the bug. – Arnel A. Borja Aug 01 '11 at 01:59
  • If you can, you might want to switch to GTK+ 3. Most of the development focus is there right now, and that bug may have been resolved in that code tree. – Bob Murphy Aug 01 '11 at 04:12