]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkdnd.c
filechooserbutton: Update the button/combo whenever the selection is changed programm...
[~andy/gtk] / gtk / gtkdnd.c
index 38911799357de2f56ea5b4237a152c81ce29143c..4b974a5ee95c60a1939a5880ec649f5388aabf50 100644 (file)
@@ -12,9 +12,7 @@
  * Lesser General Public License for more details.
  *
  * 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.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
@@ -52,7 +50,6 @@
 #include "gtktooltip.h"
 #include "gtkwindow.h"
 #include "gtkintl.h"
-#include "gtkdndcursors.h"
 #include "gtkselectionprivate.h"
 
 
@@ -309,16 +306,15 @@ static void     set_icon_helper (GdkDragContext    *context,
 static struct {
   GdkDragAction action;
   const gchar  *name;
-  const guint8 *data;
   GdkPixbuf    *pixbuf;
   GdkCursor    *cursor;
 } drag_cursors[] = {
   { GDK_ACTION_DEFAULT, NULL },
-  { GDK_ACTION_ASK,   "dnd-ask",  dnd_cursor_ask,  NULL, NULL },
-  { GDK_ACTION_COPY,  "dnd-copy", dnd_cursor_copy, NULL, NULL },
-  { GDK_ACTION_MOVE,  "dnd-move", dnd_cursor_move, NULL, NULL },
-  { GDK_ACTION_LINK,  "dnd-link", dnd_cursor_link, NULL, NULL },
-  { 0              ,  "dnd-none", dnd_cursor_none, NULL, NULL },
+  { GDK_ACTION_ASK,   "dnd-ask",  NULL, NULL },
+  { GDK_ACTION_COPY,  "dnd-copy", NULL, NULL },
+  { GDK_ACTION_MOVE,  "dnd-move", NULL, NULL },
+  { GDK_ACTION_LINK,  "dnd-link", NULL, NULL },
+  { 0              ,  "dnd-none", NULL, NULL },
 };
 
 /*********************
@@ -364,7 +360,7 @@ gtk_drag_get_ipc_widget_for_screen (GdkScreen *screen)
       result = gtk_window_new (GTK_WINDOW_POPUP);
       gtk_window_set_screen (GTK_WINDOW (result), screen);
       gtk_window_resize (GTK_WINDOW (result), 1, 1);
-      gtk_window_move (GTK_WINDOW (result), -100, -100);
+      gtk_window_move (GTK_WINDOW (result), -99, -99);
       gtk_widget_show (result);
     }  
 
@@ -415,6 +411,18 @@ root_key_filter (GdkXEvent *xevent,
   if ((ev->type == KeyPress || ev->type == KeyRelease) &&
       ev->xkey.root == ev->xkey.window)
     ev->xkey.window = (Window)data;
+  else if (ev->type == GenericEvent)
+    {
+      XGenericEventCookie *cookie;
+      XIDeviceEvent *dev;
+
+      cookie = &ev->xcookie;
+      dev = (XIDeviceEvent *) cookie->data;
+
+      if (dev->evtype == XI_KeyPress ||
+          dev->evtype == XI_KeyRelease)
+        dev->event = (Window)data;
+    }
 
   return GDK_FILTER_CONTINUE;
 }
@@ -734,7 +742,7 @@ gtk_drag_get_event_actions (GdkEvent *event,
          break;
        }
 
-      if ((button == 2 || button == 3) && (actions & GDK_ACTION_ASK))
+      if ((button == GDK_BUTTON_MIDDLE || button == GDK_BUTTON_SECONDARY) && (actions & GDK_ACTION_ASK))
        {
          *suggested_action = GDK_ACTION_ASK;
          *possible_actions = actions;
@@ -820,6 +828,22 @@ gtk_drag_can_use_rgba_cursor (GdkDisplay *display,
   return TRUE;
 }
 
+static void
+ensure_drag_cursor_pixbuf (int i)
+{
+  if (drag_cursors[i].pixbuf == NULL)
+    {
+      char *path = g_strconcat ("/org/gtk/libgtk/cursor/",  drag_cursors[i].name, ".png", NULL);
+      GInputStream *stream = g_resources_open_stream (path, 0, NULL);
+      if (stream != NULL)
+       {
+         drag_cursors[i].pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
+         g_object_unref (stream);
+       }
+      g_free (path);
+    }
+}
+
 static GdkCursor *
 gtk_drag_get_cursor (GtkWidget         *widget,
                      GdkDisplay        *display,
@@ -845,10 +869,6 @@ gtk_drag_get_cursor (GtkWidget         *widget,
     if (drag_cursors[i].action == action)
       break;
 
-  if (drag_cursors[i].pixbuf == NULL)
-    drag_cursors[i].pixbuf = 
-      gdk_pixbuf_new_from_inline (-1, drag_cursors[i].data, FALSE, NULL);
-
   if (drag_cursors[i].cursor != NULL)
     {
       if (display != gdk_cursor_get_display (drag_cursors[i].cursor))
@@ -862,7 +882,10 @@ gtk_drag_get_cursor (GtkWidget         *widget,
     drag_cursors[i].cursor = gdk_cursor_new_from_name (display, drag_cursors[i].name);
   
   if (drag_cursors[i].cursor == NULL)
-    drag_cursors[i].cursor = gdk_cursor_new_from_pixbuf (display, drag_cursors[i].pixbuf, 0, 0);
+    {
+      ensure_drag_cursor_pixbuf (i);
+      drag_cursors[i].cursor = gdk_cursor_new_from_pixbuf (display, drag_cursors[i].pixbuf, 0, 0);
+    }
 
   if (info && info->icon_helper) 
     {
@@ -893,7 +916,10 @@ gtk_drag_get_cursor (GtkWidget         *widget,
       hot_x = hot_y = 0;
       cursor_pixbuf = gdk_cursor_get_image (drag_cursors[i].cursor);
       if (!cursor_pixbuf)
-       cursor_pixbuf = g_object_ref (drag_cursors[i].pixbuf);
+       {
+         ensure_drag_cursor_pixbuf (i);
+         cursor_pixbuf = g_object_ref (drag_cursors[i].pixbuf);
+       }
       else
        {
          if (gdk_pixbuf_get_option (cursor_pixbuf, "x_hot"))