]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkdnd.c
Set this to `$(libexecdir)/pkgconfig'; this is the directory where
[~andy/gtk] / gtk / gtkdnd.c
index 635834e222fbaad32f541bc96fc1c8f1e11d4b2d..0abbdda674573610126381bb8e2e9386073eed32 100644 (file)
@@ -2,23 +2,23 @@
  * Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
  *
  * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser 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.
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser 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.
  */
 
 /*
- * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
+ * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
  * file for a list of people on the GTK+ Team.  See the ChangeLog
  * files for a list of changes.  These files are distributed with
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
 #include "x11/gdkx.h"
 #elif defined (GDK_WINDOWING_WIN32)
 #include "win32/gdkwin32.h"
+#elif defined(GDK_WINDOWING_FB)
+#include "linux-fb/gdkfb.h"
+#elif defined (GDK_WINDOWING_NANOX)
+#include "nanox/gdkprivate-nanox.h"
 #endif
 
 #include "gdk/gdkkeysyms.h"
@@ -553,6 +557,17 @@ gtk_drag_get_event_actions (GdkEvent *event,
            *suggested_action = GDK_ACTION_LINK;
        }
     }
+  else
+    {
+      *possible_actions = actions;
+      
+      if (actions & GDK_ACTION_COPY)
+       *suggested_action =  GDK_ACTION_COPY;
+      else if (actions & GDK_ACTION_MOVE)
+       *suggested_action = GDK_ACTION_MOVE;
+      else if (actions & GDK_ACTION_LINK)
+       *suggested_action = GDK_ACTION_LINK;
+    }
   
   return;
 }
@@ -828,6 +843,30 @@ gtk_drag_unhighlight (GtkWidget *widget)
   gtk_widget_queue_clear (widget);
 }
 
+static void
+gtk_drag_dest_set_internal (GtkWidget       *widget,
+                           GtkDragDestSite *site)
+{
+  GtkDragDestSite *old_site;
+  
+  g_return_if_fail (widget != NULL);
+
+  /* HACK, do this in the destroy */
+  old_site = gtk_object_get_data (GTK_OBJECT (widget), "gtk-drag-dest");
+  if (old_site)
+    gtk_signal_disconnect_by_data (GTK_OBJECT (widget), old_site);
+
+  if (GTK_WIDGET_REALIZED (widget))
+    gtk_drag_dest_realized (widget);
+
+  gtk_signal_connect (GTK_OBJECT (widget), "realize",
+                     GTK_SIGNAL_FUNC (gtk_drag_dest_realized), site);
+
+  gtk_object_set_data_full (GTK_OBJECT (widget), "gtk-drag-dest",
+                           site, gtk_drag_dest_site_destroy);
+}
+                           
+
 /*************************************************************
  * gtk_drag_dest_set:
  *     Register a drop site, and possibly add default behaviors.
@@ -851,17 +890,6 @@ gtk_drag_dest_set   (GtkWidget            *widget,
   
   g_return_if_fail (widget != NULL);
 
-  /* HACK, do this in the destroy */
-  site = gtk_object_get_data (GTK_OBJECT (widget), "gtk-drag-dest");
-  if (site)
-    gtk_signal_disconnect_by_data (GTK_OBJECT (widget), site);
-
-  if (GTK_WIDGET_REALIZED (widget))
-    gtk_drag_dest_realized (widget);
-
-  gtk_signal_connect (GTK_OBJECT (widget), "realize",
-                     GTK_SIGNAL_FUNC (gtk_drag_dest_realized), NULL);
-
   site = g_new (GtkDragDestSite, 1);
 
   site->flags = flags;
@@ -874,8 +902,7 @@ gtk_drag_dest_set   (GtkWidget            *widget,
   site->actions = actions;
   site->do_proxy = FALSE;
 
-  gtk_object_set_data_full (GTK_OBJECT (widget), "gtk-drag-dest",
-                           site, gtk_drag_dest_site_destroy);
+  gtk_drag_dest_set_internal (widget, site);
 }
 
 /*************************************************************
@@ -901,17 +928,6 @@ gtk_drag_dest_set_proxy (GtkWidget      *widget,
   
   g_return_if_fail (widget != NULL);
 
-  /* HACK, do this in the destroy */
-  site = gtk_object_get_data (GTK_OBJECT (widget), "gtk-drag-dest");
-  if (site)
-    gtk_signal_disconnect_by_data (GTK_OBJECT (widget), site);
-
-  if (GTK_WIDGET_REALIZED (widget))
-    gtk_drag_dest_realized (widget);
-
-  gtk_signal_connect (GTK_OBJECT (widget), "realize",
-                     GTK_SIGNAL_FUNC (gtk_drag_dest_realized), NULL);
-
   site = g_new (GtkDragDestSite, 1);
 
   site->flags = 0;
@@ -925,8 +941,7 @@ gtk_drag_dest_set_proxy (GtkWidget      *widget,
   site->proxy_protocol = protocol;
   site->proxy_coords = use_coordinates;
 
-  gtk_object_set_data_full (GTK_OBJECT (widget), "gtk-drag-dest",
-                           site, gtk_drag_dest_site_destroy);
+  gtk_drag_dest_set_internal (widget, site);
 }
 
 /*************************************************************
@@ -978,8 +993,8 @@ gtk_drag_dest_handle_event (GtkWidget *toplevel,
       info->proxy_data = NULL;
       info->dropped = FALSE;
       info->proxy_drop_wait = FALSE;
-      g_dataset_set_data_full (context,
-                              "gtk-info",
+      g_object_set_qdata_full (G_OBJECT (context),
+                              g_quark_from_static_string ("gtk-info"),
                               info,
                               gtk_drag_dest_info_destroy);
     }
@@ -1112,7 +1127,7 @@ gtk_drag_selection_received (GtkWidget        *widget,
   drop_widget = data;
 
   context = gtk_object_get_data (GTK_OBJECT (widget), "drag-context");
-  info = g_dataset_get_data (context, "gtk-info");
+  info = g_object_get_qdata (G_OBJECT (context), g_quark_from_static_string ("gtk-info"));
 
   if (info->proxy_data && 
       info->proxy_data->target == selection_data->target)
@@ -1141,7 +1156,7 @@ gtk_drag_selection_received (GtkWidget        *widget,
 
       site = gtk_object_get_data (GTK_OBJECT (drop_widget), "gtk-drag-dest");
 
-      if (site->target_list)
+      if (site && site->target_list)
        {
          guint target_info;
 
@@ -1166,7 +1181,7 @@ gtk_drag_selection_received (GtkWidget        *widget,
                                   selection_data, 0, time);
        }
       
-      if (site->flags & GTK_DEST_DEFAULT_DROP)
+      if (site && site->flags & GTK_DEST_DEFAULT_DROP)
        {
 
          gtk_drag_finish (context, 
@@ -1330,7 +1345,9 @@ gtk_drag_proxy_begin (GtkWidget       *widget,
 
   source_info->proxy_dest = dest_info;
   
-  g_dataset_set_data (source_info->context, "gtk-info", source_info);
+  g_object_set_qdata (G_OBJECT (source_info->context),
+                      g_quark_from_static_string ("gtk-info"),
+                      source_info);
   
   gtk_signal_connect (GTK_OBJECT (source_info->ipc_widget), 
                      "selection_get",
@@ -1381,7 +1398,8 @@ gtk_drag_dest_leave (GtkWidget      *widget,
 
   if (site->do_proxy)
     {
-      GtkDragDestInfo *info = g_dataset_get_data (context, "gtk-info");
+      GtkDragDestInfo *info = g_object_get_qdata (G_OBJECT (context),
+                                                  g_quark_from_static_string ("gtk-info"));
 
       if (info->proxy_source && !info->dropped)
        gdk_drag_abort (info->proxy_source->context, time);
@@ -1422,7 +1440,8 @@ gtk_drag_dest_motion (GtkWidget        *widget,
       GdkWindow *dest_window;
       GdkDragProtocol proto;
        
-      GtkDragDestInfo *info = g_dataset_get_data (context, "gtk-info");
+      GtkDragDestInfo *info = g_object_get_qdata (G_OBJECT (context),
+                                                 g_quark_from_static_string ("gtk-info"));
 
       if (!info->proxy_source)
        gtk_drag_proxy_begin (widget, info);
@@ -1519,7 +1538,8 @@ gtk_drag_dest_drop (GtkWidget          *widget,
   site = gtk_object_get_data (GTK_OBJECT (widget), "gtk-drag-dest");
   g_return_val_if_fail (site != NULL, FALSE);
 
-  info = g_dataset_get_data (context, "gtk-info");
+  info = g_object_get_qdata (G_OBJECT (context),
+                             g_quark_from_static_string ("gtk-info"));
   g_return_val_if_fail (info != NULL, FALSE);
 
   info->drop_x = x;
@@ -1662,7 +1682,8 @@ gtk_drag_begin (GtkWidget         *widget,
   info->context = gdk_drag_begin (info->ipc_widget->window, targets);
   g_list_free (targets);
   
-  g_dataset_set_data (info->context, "gtk-info", info);
+  g_object_set_qdata (G_OBJECT (info->context),
+                     g_quark_from_static_string ("gtk-info"), info);
 
   info->button = button;
   info->target_list = target_list;
@@ -1680,13 +1701,12 @@ gtk_drag_begin (GtkWidget         *widget,
   gtk_drag_get_event_actions (event, info->button, actions,
                              &suggested_action, &possible_actions);
   
-  if (event)
-    info->cursor = gtk_drag_get_cursor (suggested_action);
+  info->cursor = gtk_drag_get_cursor (suggested_action);
 
   /* Set cur_x, cur_y here so if the "drag_begin" signal shows
    * the drag icon, it will be in the right place
    */
-  if (event->type == GDK_MOTION_NOTIFY)
+  if (event && event->type == GDK_MOTION_NOTIFY)
     {
       info->cur_x = event->motion.x_root;
       info->cur_y = event->motion.y_root;
@@ -1703,7 +1723,7 @@ gtk_drag_begin (GtkWidget         *widget,
   gtk_signal_emit_by_name (GTK_OBJECT (widget), "drag_begin",
                           info->context);
   
-  if (event->type == GDK_MOTION_NOTIFY)
+  if (event && event->type == GDK_MOTION_NOTIFY)
     gtk_drag_motion_cb (info->ipc_widget, (GdkEventMotion *)event, info);
 
   info->start_x = info->cur_x;
@@ -1899,7 +1919,8 @@ gtk_drag_set_icon_window (GdkDragContext *context,
   g_return_if_fail (context != NULL);
   g_return_if_fail (widget != NULL);
 
-  info = g_dataset_get_data (context, "gtk-info");
+  info = g_object_get_qdata (G_OBJECT (context),
+                            g_quark_from_static_string ("gtk-info"));
   gtk_drag_remove_icon (info);
 
   info->icon_window = widget;
@@ -1972,14 +1993,12 @@ gtk_drag_set_icon_pixmap (GdkDragContext    *context,
 
   gdk_window_get_size (pixmap, &width, &height);
 
-  gtk_widget_push_visual (gdk_colormap_get_visual (colormap));
   gtk_widget_push_colormap (colormap);
 
   window = gtk_window_new (GTK_WINDOW_POPUP);
   gtk_widget_set_events (window, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
   gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
 
-  gtk_widget_pop_visual ();
   gtk_widget_pop_colormap ();
 
   gtk_widget_set_usize (window, width, height);
@@ -2053,7 +2072,7 @@ gtk_drag_set_default_icon (GdkColormap   *colormap,
   if (default_icon_pixmap)
     gdk_pixmap_unref (default_icon_pixmap);
   if (default_icon_mask)
-    gdk_pixmap_unref (default_icon_pixmap);
+    gdk_pixmap_unref (default_icon_mask);
 
   default_icon_colormap = colormap;
   gdk_colormap_ref (colormap);
@@ -2092,7 +2111,8 @@ gtk_drag_source_handle_event (GtkWidget *widget,
   g_return_if_fail (event != NULL);
 
   context = event->dnd.context;
-  info = g_dataset_get_data (context, "gtk-info");
+  info = g_object_get_qdata (G_OBJECT (context),
+                            g_quark_from_static_string ("gtk-info"));
   if (!info)
     return;
 
@@ -2271,7 +2291,8 @@ gtk_drag_drop_finished (GtkDragSourceInfo *info,
          /* Mark the context as dead, so if the destination decides
           * to respond really late, we still are OK.
           */
-         g_dataset_set_data (info->context, "gtk-info", NULL);
+         g_object_set_qdata (G_OBJECT (info->context),
+                             g_quark_from_static_string ("gtk-info"), NULL);
          gtk_timeout_add (ANIM_STEP_TIME, gtk_drag_anim_timeout, anim);
        }
     }
@@ -2405,7 +2426,8 @@ gtk_drag_source_event_cb (GtkWidget      *widget,
                                        i, event);
 
              
-             info = g_dataset_get_data (context, "gtk-info");
+             info = g_object_get_qdata (G_OBJECT (context),
+                                         g_quark_from_static_string ("gtk-info"));
 
              if (!info->icon_window)
                {
@@ -2580,7 +2602,7 @@ gtk_drag_source_info_destroy (gpointer data)
 
   gtk_target_list_unref (info->target_list);
 
-  g_dataset_set_data (info->context, "gtk-info", NULL);
+  g_object_set_qdata (G_OBJECT (info->context), g_quark_from_static_string ("gtk-info"), NULL);
   gdk_drag_context_unref (info->context);
 
   if (info->drop_timeout)
@@ -2694,13 +2716,10 @@ gtk_drag_end (GtkDragSourceInfo *info, guint32 time)
   send_event.button.time = time;
   send_event.button.x = 0;
   send_event.button.y = 0;
-  send_event.button.pressure = 0.;
-  send_event.button.xtilt = 0.;
-  send_event.button.ytilt = 0.;
+  send_event.button.axes = NULL;
   send_event.button.state = 0;
   send_event.button.button = info->button;
-  send_event.button.source = GDK_SOURCE_PEN;
-  send_event.button.deviceid = GDK_CORE_POINTER;
+  send_event.button.device = gdk_core_pointer;
   send_event.button.x_root = 0;
   send_event.button.y_root = 0;