]> Pileus Git - ~andy/gtk/blobdiff - tests/testdnd.c
Some cleanups after the module cache file change
[~andy/gtk] / tests / testdnd.c
index 9ac1baec07ffb3231456a7a754f2e4730e5a10b9..24d642f6adb9a83d43b9a5a0618f5612e8be2457 100644 (file)
@@ -1,4 +1,24 @@
-#include <stdlib.h> /* putenv */
+/* testdnd.c
+ * Copyright (C) 1998  Red Hat, Inc.
+ * Author: Owen Taylor
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
 #include "gtk/gtk.h"
 
 /* Target side drag signals */
@@ -281,7 +301,7 @@ enum {
 static GtkTargetEntry target_table[] = {
   { "STRING",     0, TARGET_STRING },
   { "text/plain", 0, TARGET_STRING },
-  { "application/x-rootwin-drop", 0, TARGET_ROOTWIN }
+  { "application/x-rootwindow-drop", 0, TARGET_ROOTWIN }
 };
 
 static guint n_targets = sizeof(target_table) / sizeof(target_table[0]);
@@ -293,7 +313,8 @@ target_drag_leave      (GtkWidget          *widget,
 {
   g_print("leave\n");
   have_drag = FALSE;
-  gtk_pixmap_set (GTK_PIXMAP (widget), trashcan_closed, trashcan_closed_mask);
+  gtk_image_set_from_pixmap (GTK_IMAGE (widget),
+                            trashcan_closed, trashcan_closed_mask);
 }
 
 gboolean
@@ -309,12 +330,13 @@ target_drag_motion           (GtkWidget          *widget,
   if (!have_drag)
     {
       have_drag = TRUE;
-      gtk_pixmap_set (GTK_PIXMAP (widget), trashcan_open, trashcan_open_mask);
+      gtk_image_set_from_pixmap (GTK_IMAGE (widget),
+                                trashcan_open, trashcan_open_mask);
     }
 
   source_widget = gtk_drag_get_source_widget (context);
   g_print ("motion, source %s\n", source_widget ?
-          GTK_OBJECT_TYPE_NAME (source_widget) :
+          G_OBJECT_TYPE_NAME (source_widget) :
           "NULL");
 
   tmp_list = context->targets;
@@ -341,7 +363,8 @@ target_drag_drop       (GtkWidget          *widget,
   g_print("drop\n");
   have_drag = FALSE;
 
-  gtk_pixmap_set (GTK_PIXMAP (widget), trashcan_closed, trashcan_closed_mask);
+  gtk_image_set_from_pixmap (GTK_IMAGE (widget),
+                            trashcan_closed, trashcan_closed_mask);
 
   if (context->targets)
     {
@@ -405,11 +428,11 @@ source_drag_data_get  (GtkWidget          *widget,
   else
     gtk_selection_data_set (selection_data,
                            selection_data->target,
-                           8, "I'm Data!", 9);
+                           8, (guchar *) "I'm Data!", 9);
 }
   
 /* The following is a rather elaborate example demonstrating/testing
- * changing of the window heirarchy during a drag - in this case,
+ * changing of the window hierarchy during a drag - in this case,
  * via a "spring-loaded" popup window.
  */
 static GtkWidget *popup_window = NULL;
@@ -443,7 +466,7 @@ popup_motion           (GtkWidget          *widget,
       if (popdown_timer)
        {
          g_print ("removed popdown\n");
-         gtk_timeout_remove (popdown_timer);
+         g_source_remove (popdown_timer);
          popdown_timer = 0;
        }
     }
@@ -462,12 +485,12 @@ popup_leave          (GtkWidget          *widget,
       if (!popdown_timer)
        {
          g_print ("added popdown\n");
-         popdown_timer = gtk_timeout_add (500, popdown_cb, NULL);
+         popdown_timer = gdk_threads_add_timeout (500, popdown_cb, NULL);
        }
     }
 }
 
-gint
+gboolean
 popup_cb (gpointer data)
 {
   if (!popped_up)
@@ -497,10 +520,10 @@ popup_cb (gpointer data)
                                   GTK_DEST_DEFAULT_ALL,
                                   target_table, n_targets - 1, /* no rootwin */
                                   GDK_ACTION_COPY | GDK_ACTION_MOVE);
-               gtk_signal_connect (GTK_OBJECT (button), "drag_motion",
-                                   GTK_SIGNAL_FUNC (popup_motion), NULL);
-               gtk_signal_connect (GTK_OBJECT (button), "drag_leave",
-                                   GTK_SIGNAL_FUNC (popup_leave), NULL);
+               g_signal_connect (button, "drag_motion",
+                                 G_CALLBACK (popup_motion), NULL);
+               g_signal_connect (button, "drag_leave",
+                                 G_CALLBACK (popup_leave), NULL);
              }
 
          gtk_widget_show_all (table);
@@ -511,7 +534,7 @@ popup_cb (gpointer data)
       popped_up = TRUE;
     }
 
-  popdown_timer = gtk_timeout_add (500, popdown_cb, NULL);
+  popdown_timer = gdk_threads_add_timeout (500, popdown_cb, NULL);
   g_print ("added popdown\n");
 
   popup_timer = FALSE;
@@ -527,7 +550,7 @@ popsite_motion         (GtkWidget          *widget,
                    guint               time)
 {
   if (!popup_timer)
-    popup_timer = gtk_timeout_add (500, popup_cb, NULL);
+    popup_timer = gdk_threads_add_timeout (500, popup_cb, NULL);
 
   return TRUE;
 }
@@ -539,7 +562,7 @@ popsite_leave          (GtkWidget          *widget,
 {
   if (popup_timer)
     {
-      gtk_timeout_remove (popup_timer);
+      g_source_remove (popup_timer);
       popup_timer = 0;
     }
 }
@@ -553,13 +576,13 @@ source_drag_data_delete  (GtkWidget          *widget,
 }
   
 void
-test_init ()
+test_init (void)
 {
   if (g_file_test ("../gdk-pixbuf/libpixbufloader-pnm.la",
                   G_FILE_TEST_EXISTS))
     {
-      putenv ("GDK_PIXBUF_MODULEDIR=../gdk-pixbuf/");
-      putenv ("GTK_IM_MODULE_FILE=./gtk.immodules");
+      g_setenv ("GDK_PIXBUF_MODULE_FILE", "../gdk-pixbuf/loaders.cache", TRUE);
+      g_setenv ("GTK_IM_MODULE_FILE", "../modules/input/immodules.cache", TRUE);
     }
 }
 
@@ -579,8 +602,8 @@ main (int argc, char **argv)
   gtk_init (&argc, &argv); 
 
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_signal_connect (GTK_OBJECT(window), "destroy",
-                     GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
+  g_signal_connect (window, "destroy",
+                   G_CALLBACK (gtk_main_quit), NULL);
 
   
   table = gtk_table_new (2, 2, FALSE);
@@ -607,8 +630,8 @@ main (int argc, char **argv)
                     target_table, n_targets - 1, /* no rootwin */
                     GDK_ACTION_COPY | GDK_ACTION_MOVE);
 
-  gtk_signal_connect( GTK_OBJECT(label), "drag_data_received",
-                     GTK_SIGNAL_FUNC( label_drag_data_received), NULL);
+  g_signal_connect (label, "drag_data_received",
+                   G_CALLBACK( label_drag_data_received), NULL);
 
   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
                    GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
@@ -625,28 +648,28 @@ main (int argc, char **argv)
                    GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
                    0, 0);
 
-  gtk_signal_connect (GTK_OBJECT (label), "drag_motion",
-                     GTK_SIGNAL_FUNC (popsite_motion), NULL);
-  gtk_signal_connect (GTK_OBJECT (label), "drag_leave",
-                     GTK_SIGNAL_FUNC (popsite_leave), NULL);
+  g_signal_connect (label, "drag_motion",
+                   G_CALLBACK (popsite_motion), NULL);
+  g_signal_connect (label, "drag_leave",
+                   G_CALLBACK (popsite_leave), NULL);
   
-  pixmap = gtk_pixmap_new (trashcan_closed, trashcan_closed_mask);
+  pixmap = gtk_image_new_from_pixmap (trashcan_closed, trashcan_closed_mask);
   gtk_drag_dest_set (pixmap, 0, NULL, 0, 0);
   gtk_table_attach (GTK_TABLE (table), pixmap, 1, 2, 0, 1,
                    GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
                    0, 0);
 
-  gtk_signal_connect (GTK_OBJECT (pixmap), "drag_leave",
-                     GTK_SIGNAL_FUNC (target_drag_leave), NULL);
+  g_signal_connect (pixmap, "drag_leave",
+                   G_CALLBACK (target_drag_leave), NULL);
 
-  gtk_signal_connect (GTK_OBJECT (pixmap), "drag_motion",
-                     GTK_SIGNAL_FUNC (target_drag_motion), NULL);
+  g_signal_connect (pixmap, "drag_motion",
+                   G_CALLBACK (target_drag_motion), NULL);
 
-  gtk_signal_connect (GTK_OBJECT (pixmap), "drag_drop",
-                     GTK_SIGNAL_FUNC (target_drag_drop), NULL);
+  g_signal_connect (pixmap, "drag_drop",
+                   G_CALLBACK (target_drag_drop), NULL);
 
-  gtk_signal_connect (GTK_OBJECT (pixmap), "drag_data_received",
-                     GTK_SIGNAL_FUNC (target_drag_data_received), NULL);
+  g_signal_connect (pixmap, "drag_data_received",
+                   G_CALLBACK (target_drag_data_received), NULL);
 
   /* Drag site */
 
@@ -659,17 +682,17 @@ main (int argc, char **argv)
                            gtk_widget_get_colormap (window),
                            drag_icon, drag_mask);
 
-  gdk_pixmap_unref (drag_icon);
-  gdk_pixmap_unref (drag_mask);
+  g_object_unref (drag_icon);
+  g_object_unref (drag_mask);
 
   gtk_table_attach (GTK_TABLE (table), button, 0, 1, 1, 2,
                    GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
                    0, 0);
 
-  gtk_signal_connect (GTK_OBJECT (button), "drag_data_get",
-                     GTK_SIGNAL_FUNC (source_drag_data_get), NULL);
-  gtk_signal_connect (GTK_OBJECT (button), "drag_data_delete",
-                     GTK_SIGNAL_FUNC (source_drag_data_delete), NULL);
+  g_signal_connect (button, "drag_data_get",
+                   G_CALLBACK (source_drag_data_get), NULL);
+  g_signal_connect (button, "drag_data_delete",
+                   G_CALLBACK (source_drag_data_delete), NULL);
 
   gtk_widget_show_all (window);