#include <gtk/gtk.h>
#include <stdio.h>

const GtkTargetEntry drag_targets[] = {{ (gchar*)"SAME_PROC", GTK_TARGET_SAME_APP, 0}};

int main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkTreeView         *tree_view;
    GtkTreeStore        *tree_store;
    GtkCellRenderer     *pCellRenderer;
    GtkTreeViewColumn   *pColumn;
    GtkWidget           *pTable;
    GtkWidget           *pButton;
    GtkTreeIter         Iter;
 
    gtk_init(&argc, &argv);
 
    /* Create the main, top level window */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_resize (GTK_WINDOW (window), 600, 400);
 
    /* Give it the title */
    gtk_window_set_title(GTK_WINDOW(window), "Hello, world!");
 
    /*
    ** Map the destroy signal of the window to gtk_main_quit;
    ** When the window is about to be destroyed, we get a notification and
    ** stop the main GTK+ loop by returning 0
    */
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
    
    pTable = gtk_table_new (1, 2, FALSE);
    pButton = gtk_button_new_with_label("foobar");
    
    tree_store = gtk_tree_store_new(1, G_TYPE_INT);
    tree_view = (GtkTreeView*)gtk_tree_view_new_with_model(GTK_TREE_MODEL(tree_store));
    
    pCellRenderer = gtk_cell_renderer_text_new();
    pColumn = gtk_tree_view_column_new_with_attributes("barfoo", pCellRenderer, "text", 0, NULL);
    gtk_tree_view_append_column(tree_view, pColumn);
    
    gtk_tree_view_set_reorderable(GTK_TREE_VIEW(tree_view), TRUE);
    gtk_drag_dest_set(GTK_WIDGET(tree_view), GTK_DEST_DEFAULT_ALL, drag_targets, 1, GDK_ACTION_MOVE);
    gtk_drag_source_set(GTK_WIDGET(tree_view), GDK_BUTTON1_MASK, drag_targets, 1, GDK_ACTION_MOVE);
     
    gtk_tree_store_append(tree_store, &Iter, NULL);
    gtk_tree_store_set(tree_store, &Iter, 0, "Test 1", -1);
    
    
    
    gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(pTable));
    gtk_table_attach (GTK_TABLE(pTable), pButton, 0, 1, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
    gtk_table_attach (GTK_TABLE(pTable), GTK_WIDGET(tree_view), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
    
    gtk_widget_show_all(window);
 
    gtk_main();
 
    return 0;
}
