title: Is there a good way to copy a Gtk widget?
body: <p>Is there a way, using the Gtk library in C, to clone a Gtk button (for instance), and pack it somewhere else in the app. I know you can't pack the same widget twice. And that this code obviously wouldn't work, but shows what happens when I attempt a shallow copy of the button:</p>
  
  <pre><code>GtkButton *a = g_object_new(GTK_TYPE_BUTTON, "label", "o_0", NULL);
  GtkButton *b = g_memdup(a, sizeof *a);
  gtk_box_pack_start_defaults(GTK_BOX(vbox), GTK_WIDGET(b));
  </code></pre>
  
  <p>There is surrounding code which creates a vbox and packs it in a window and runs gtk_main(). This will result in these hard to understand error messages:</p>
  
  <pre><code>(main:6044): Gtk-CRITICAL **: gtk_widget_hide: assertion `GTK_IS_WIDGET (widget)' failed
  
  (main:6044): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
  **
  Gtk:ERROR:/build/buildd/gtk+2.0-2.18.3/gtk/gtkwidget.c:8431:gtk_widget_real_map: assertion failed: (GTK_WIDGET_REALIZED (widget))
  </code></pre>
  
  <p>Along the same lines, if I were to write my own GObject (not necessarily a Gtk widget), is there a good way to write a copy constructor. Im thinking it should be an interface with optional hooks and based mostly on the properties, handling the class's hierarchy in some way.</p>
  
  <p>I'd want to do this:</p>
  
  <pre><code>GtkButton *b = copyable_copy(COPYABLE(a));
  </code></pre>
  
  <p>If GtkButton could use a theoretical copyable interface.</p>