Loading

GTK #1840 steps to reprod

  1. #include <glib.h>
  2. #include <gtk/gtk.h>
  3.  
  4. int main(int argc, char **argv) {
  5.   gtk_init (&argc, &argv);
  6.  
  7.  
  8.   GtkWidget *win2 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  9.   GtkWidget *hello = gtk_label_new ("This window goes behind");
  10.   gtk_container_add (GTK_CONTAINER (win2), GTK_WIDGET (hello));
  11.   gtk_window_set_default_size (GTK_WINDOW (win2), 400, 400);
  12.   gtk_widget_show_all (GTK_WIDGET (win2));
  13.  
  14.  
  15.   GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  16.   GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 18);
  17.  
  18.   GtkListStore *liststore = gtk_list_store_new (1, G_TYPE_STRING);
  19.   gtk_list_store_insert_with_values (liststore, NULL, -1, 0, "foo", -1);
  20.   gtk_list_store_insert_with_values (liststore, NULL, -1, 0, "bar", -1);
  21.  
  22.   GtkWidget *treeview = gtk_tree_view_new ();
  23.   gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (liststore));
  24.   GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes (
  25.     "word", gtk_cell_renderer_text_new(), "text", 0, NULL
  26.   );
  27.   gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
  28.  
  29.   GtkTargetEntry entries[] = {
  30.     (GtkTargetEntry) { .target="resource", .flags=GTK_TARGET_SAME_APP, .info=1}
  31.   };
  32.   gtk_tree_view_enable_model_drag_source (
  33.     GTK_TREE_VIEW (treeview),
  34.     GDK_BUTTON1_MASK,
  35.     entries, 1,
  36.     GDK_ACTION_COPY
  37.   );
  38.  
  39.  
  40.   GtkWidget *listbox = gtk_list_box_new ();
  41.   gtk_drag_dest_set (listbox, GTK_DEST_DEFAULT_ALL, entries, 1, GDK_ACTION_COPY);
  42.   gtk_container_add (GTK_CONTAINER (listbox), gtk_label_new ("Drop here"));
  43.  
  44.   gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (treeview), TRUE, TRUE, 0);
  45.   gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (listbox), TRUE, TRUE, 0);
  46.   gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (box));
  47.  
  48.   gtk_widget_show_all (window);
  49.   g_signal_connect (window, "destroy", gtk_main_quit, NULL);
  50.  
  51.  
  52.   gtk_main ();
  53.  
  54.   return 0;
  55. }