コード例 #1
0
static guint
get_drop_action (NautilusTreeViewDragDest *dest,
                 GdkDragContext *context,
                 GtkTreePath *path)
{
    char *drop_target;
    int action;

    if (!dest->details->have_drag_data ||
            (dest->details->drag_type == NAUTILUS_ICON_DND_GNOME_ICON_LIST &&
             dest->details->drag_list == NULL)) {
        return 0;
    }

    drop_target = get_drop_target_uri_for_path (dest, path);
    if (drop_target == NULL) {
        return 0;
    }

    action = 0;
    switch (dest->details->drag_type) {
    case NAUTILUS_ICON_DND_GNOME_ICON_LIST :
        nautilus_drag_default_drop_action_for_icons
        (context,
         drop_target,
         dest->details->drag_list,
         &action);
        break;
    case NAUTILUS_ICON_DND_NETSCAPE_URL:
        action = nautilus_drag_default_drop_action_for_netscape_url (context);
        break;
    case NAUTILUS_ICON_DND_URI_LIST :
        action = gdk_drag_context_get_suggested_action (context);
        break;
    case NAUTILUS_ICON_DND_TEXT:
    case NAUTILUS_ICON_DND_RAW:
    case NAUTILUS_ICON_DND_XDNDDIRECTSAVE:
        action = GDK_ACTION_COPY;
        break;
    }

    g_free (drop_target);

    return action;
}
コード例 #2
0
static gboolean
slot_proxy_drag_motion (GtkWidget          *widget,
                        GdkDragContext     *context,
                        int                 x,
                        int                 y,
                        unsigned int        time,
                        gpointer            user_data)
{
    NautilusDragSlotProxyInfo *drag_info;
    NautilusWindowSlot *target_slot;
    GtkWidget *window;
    GdkAtom target;
    int action;
    char *target_uri;
    GFile *location;
    gboolean valid_text_drag;
    gboolean valid_xds_drag;

    drag_info = user_data;

    action = 0;
    valid_text_drag = FALSE;
    valid_xds_drag = FALSE;

    if (gtk_drag_get_source_widget (context) == widget) {
        goto out;
    }

    window = gtk_widget_get_toplevel (widget);
    g_assert (NAUTILUS_IS_WINDOW (window));

    if (!drag_info->have_data) {
        target = gtk_drag_dest_find_target (widget, context, NULL);

        if (target == GDK_NONE) {
            goto out;
        }

        gtk_drag_get_data (widget, context, target, time);
    }

    target_uri = NULL;
    if (drag_info->target_file != NULL) {
        target_uri = nautilus_file_get_uri (drag_info->target_file);
    } else {
        if (drag_info->target_slot != NULL) {
            target_slot = drag_info->target_slot;
        } else {
            target_slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window));
        }

        if (target_slot != NULL) {
            location = nautilus_window_slot_get_location (target_slot);
            target_uri = g_file_get_uri (location);
        }
    }

    if (target_uri != NULL) {
        NautilusFile *file;
        gboolean can;
        file = nautilus_file_get_existing_by_uri (target_uri);
        can = nautilus_file_can_write (file);
        g_object_unref (file);
        if (!can) {
            action = 0;
            goto out;
        }
    }

    if (drag_info->have_data &&
            drag_info->have_valid_data) {
        if (drag_info->info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
            nautilus_drag_default_drop_action_for_icons (context, target_uri,
                    drag_info->data.selection_list,
                    0,
                    &action);
        } else if (drag_info->info == NAUTILUS_ICON_DND_URI_LIST) {
            action = nautilus_drag_default_drop_action_for_uri_list (context, target_uri);
        } else if (drag_info->info == NAUTILUS_ICON_DND_NETSCAPE_URL) {
            action = nautilus_drag_default_drop_action_for_netscape_url (context);
        } else if (drag_info->info == NAUTILUS_ICON_DND_TEXT) {
            valid_text_drag = TRUE;
        } else if (drag_info->info == NAUTILUS_ICON_DND_XDNDDIRECTSAVE ||
                   drag_info->info == NAUTILUS_ICON_DND_RAW) {
            valid_xds_drag = TRUE;
        }
    }

    g_free (target_uri);

out:
    if (action != 0 || valid_text_drag || valid_xds_drag) {
        gtk_drag_highlight (widget);
        slot_proxy_check_switch_location_timer (drag_info, widget);
    } else {
        gtk_drag_unhighlight (widget);
        slot_proxy_remove_switch_location_timer (drag_info);
    }

    gdk_drag_status (context, action, time);

    return TRUE;
}
コード例 #3
0
static gboolean
slot_proxy_drag_motion (GtkWidget          *widget,
			GdkDragContext     *context,
			int                 x,
			int                 y,
			unsigned int        time,
			gpointer            user_data)
{
  NautilusDragSlotProxyInfo *drag_info;
  NautilusWindowSlot *target_slot;
  GtkWidget *window;
  GdkAtom target;
  int action;
  char *target_uri;

  drag_info = user_data;

  action = 0;

  if (gtk_drag_get_source_widget (context) == widget) {
    goto out;
  }

  window = gtk_widget_get_toplevel (widget);
  g_assert (NAUTILUS_IS_WINDOW (window));

  if (!drag_info->have_data) {
    target = gtk_drag_dest_find_target (widget, context, NULL);

    if (target == GDK_NONE) {
      goto out;
    }

    gtk_drag_get_data (widget, context, target, time);
  }

  target_uri = NULL;
  if (drag_info->target_location != NULL) {
    target_uri = g_file_get_uri (drag_info->target_location);
  } else {
    if (drag_info->target_slot != NULL) {
      target_slot = drag_info->target_slot;
    } else {
      target_slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window));
    }

    if (target_slot != NULL) {
      target_uri = nautilus_window_slot_get_current_uri (target_slot);
    }
  }

  if (drag_info->have_data &&
      drag_info->have_valid_data) {
    if (drag_info->info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
      nautilus_drag_default_drop_action_for_icons (context, target_uri,
                                                   drag_info->data.selection_list,
                                                   &action);
    } else if (drag_info->info == NAUTILUS_ICON_DND_URI_LIST) {
      action = nautilus_drag_default_drop_action_for_uri_list (context, target_uri);
    } else if (drag_info->info == NAUTILUS_ICON_DND_NETSCAPE_URL) {
      action = nautilus_drag_default_drop_action_for_netscape_url (context);
    }
  }

  g_free (target_uri);

 out:
  if (action != 0) {
    gtk_drag_highlight (widget);
  } else {
    gtk_drag_unhighlight (widget);
  }

  gdk_drag_status (context, action, time);

  return TRUE;
}