Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Feb 9th, 2010 | Syntax: C | Size: 1.15 KB | Hits: 70 | Expires: Never
Copy text to clipboard
  1. #include <gtk/gtk.h>
  2.  
  3. /* Another callback */
  4. static void destroy( GtkWidget *widget,
  5.                      gpointer   data )
  6. {
  7.   gtk_main_quit ();
  8. }
  9.  
  10. int main( int   argc,
  11.           char *argv[] )
  12. {
  13.   /* GtkWidget is the storage type for widgets */
  14.   GtkWidget *window;
  15.  
  16.  
  17.   GtkTargetEntry target_list[] =
  18.   {
  19.     { "text/uri-list", 0, 0 }
  20.   };
  21.  
  22.   guint n_targets = G_N_ELEMENTS (target_list);
  23.  
  24.  
  25.   /* This is called in all GTK applications. Arguments are parsed
  26.    * from the command line and are returned to the application. */
  27.   gtk_init (&argc, &argv);
  28.  
  29.   /* create a new window */
  30.   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  31.  
  32.   gtk_drag_dest_set(GTK_WIDGET(window), GTK_DEST_DEFAULT_ALL, target_list, n_targets, GDK_ACTION_COPY);
  33.  
  34.     g_signal_connect (G_OBJECT (window), "destroy",
  35.                       G_CALLBACK (destroy), NULL);
  36.  
  37.   gtk_widget_set_size_request(GTK_WIDGET(window), 200, 200);
  38.  
  39.   /* and the window */
  40.   gtk_widget_show (window);
  41.  
  42.   /* All GTK applications must have a gtk_main(). Control ends here
  43.    * and waits for an event to occur (like a key press or
  44.    * mouse event). */
  45.   gtk_main ();
  46.  
  47.   return 0;
  48. }