示例#1
0
static gboolean
trash_applet_drag_motion (GtkWidget      *widget,
                          GdkDragContext *context,
                          gint            x,
                          gint            y,
                          guint           time)
{
  GList *target;

  /* refuse drops of panel applets */
  for (target = gdk_drag_context_list_targets (context); target; target = target->next)
    {
      const char *name = gdk_atom_name (target->data);

      if (!strcmp (name, "application/x-panel-icon-internal"))
        break;
    }

  if (target)
    gdk_drag_status (context, 0, time);
  else
    gdk_drag_status (context, GDK_ACTION_MOVE, time);

  return TRUE;
}
示例#2
0
static gint bar_pane_keywords_dnd_motion(GtkWidget *tree_view, GdkDragContext *context,
					gint x, gint y, guint time, gpointer data)
{
	GtkTreePath *tpath = NULL;
        GtkTreeViewDropPosition pos;
	gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(tree_view), x, y, &tpath, &pos);
	if (tpath)
		{
		GtkTreeModel *model;
		GtkTreeIter dest_iter;
		model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view));
                gtk_tree_model_get_iter(model, &dest_iter, tpath);
		if (pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE && gtk_tree_model_iter_has_child(model, &dest_iter))
			pos = GTK_TREE_VIEW_DROP_BEFORE;

		if (pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER && gtk_tree_model_iter_has_child(model, &dest_iter))
			pos = GTK_TREE_VIEW_DROP_AFTER;
		}

	gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW(tree_view), tpath, pos);
	gtk_tree_path_free(tpath);

	if (tree_view == gtk_drag_get_source_widget(context))
		gdk_drag_status(context, GDK_ACTION_MOVE, time);
	else
		gdk_drag_status(context, GDK_ACTION_COPY, time);

	return TRUE;
}
示例#3
0
static gboolean
gpview_document_view_drag_motion_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, GPViewSymbolView *view)
{
    GPViewDocumentViewPrivate *privat = GPVIEW_DOCUMENT_VIEW_GET_PRIVATE(view);

    if (privat != NULL)
    {
        GdkAtom target;

        gtk_drag_highlight(widget);

        target = gtk_drag_dest_find_target(widget, context, NULL);

        if (target == GDK_NONE)
        {
            gdk_drag_status(context, 0, time);
        }
        else
        {
            gdk_drag_status(context, gdk_drag_context_get_suggested_action(context), time);
        }
    }

    return TRUE;
}
示例#4
0
static gboolean
panel_check_drop_forbidden (PanelWidget    *panel,
			    GdkDragContext *context,
			    guint           info,
			    guint           time_)
{
	if (!panel)
		return FALSE;

	if (panel_lockdown_get_panels_locked_down_s ())
		return FALSE;

	if (info == TARGET_ICON_INTERNAL ||
	    info == TARGET_APPLET_INTERNAL) {
		if (gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE)
			gdk_drag_status (context, GDK_ACTION_MOVE, time_);
		else
			gdk_drag_status (context,
					 gdk_drag_context_get_suggested_action (context),
					 time_);

	} else if (gdk_drag_context_get_actions (context) & GDK_ACTION_COPY)
		gdk_drag_status (context, GDK_ACTION_COPY, time_);
	else
		gdk_drag_status (context,
				 gdk_drag_context_get_suggested_action (context),
				 time_);

	return TRUE;

}
示例#5
0
/**
 * dnd_clarity_drag_motion:
 *
 * Used by the drag and drop of a jpg. While the jpg is being
 * dragged, this reports to the source widget whether it is an
 * acceptable location to allow a drop.
 *
 */
gboolean dnd_clarity_drag_motion(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, guint time, gpointer user_data) {
    GdkAtom target;
    iTunesDB *itdb;
    ExtraiTunesDBData *eitdb;

    itdb = gp_get_selected_itdb();
    /* no drop is possible if no playlist/repository is selected */
    if (itdb == NULL) {
        gdk_drag_status(dc, 0, time);
        return FALSE;
    }

    eitdb = itdb->userdata;
    g_return_val_if_fail (eitdb, FALSE);
    /* no drop is possible if no repository is loaded */
    if (!eitdb->itdb_imported) {
        gdk_drag_status(dc, 0, time);
        return FALSE;
    }

    target = gtk_drag_dest_find_target(widget, dc, NULL);
    /* no drop possible if no valid target can be found */
    if (target == GDK_NONE) {
        gdk_drag_status(dc, 0, time);
        return FALSE;
    }

    gdk_drag_status(dc, gdk_drag_context_get_suggested_action(dc), time);

    return TRUE;
}
static gboolean
drag_motion (GtkWidget *widget,
    GdkDragContext *context,
    gint x,
    gint y,
    guint time_)
{
  EmpathyPersonaView *self = EMPATHY_PERSONA_VIEW (widget);
  GdkAtom target;
  guint i;
  DndDragType drag_type = DND_DRAG_TYPE_UNKNOWN;

  target = gtk_drag_dest_find_target (GTK_WIDGET (self), context, NULL);

  /* Determine the DndDragType of the data */
  for (i = 0; i < G_N_ELEMENTS (drag_atoms_dest); i++)
    {
      if (target == drag_atoms_dest[i])
        {
          drag_type = drag_types_dest[i].info;
          break;
        }
    }

  if (drag_type == DND_DRAG_TYPE_INDIVIDUAL_ID)
    {
      GtkTreePath *path;

      /* FIXME: It doesn't make sense for us to highlight a specific row or
       * position to drop an Individual in, so just highlight the entire
       * widget.
       * Since I can't find a way to do this, just highlight the first possible
       * position in the tree. */
      gdk_drag_status (context, gdk_drag_context_get_suggested_action (context),
          time_);

      path = gtk_tree_path_new_first ();
      gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (self), path,
          GTK_TREE_VIEW_DROP_BEFORE);
      gtk_tree_path_free (path);

      return TRUE;
    }

  /* Unknown or unhandled drag target */
  gdk_drag_status (context, GDK_ACTION_DEFAULT, time_);
  gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (self), NULL, 0);

  return FALSE;
}
static gboolean
avatar_chooser_drag_motion_cb (GtkWidget          *widget,
			      GdkDragContext     *context,
			      gint                x,
			      gint                y,
			      guint               time,
			      EmpathyAvatarChooser *chooser)
{
	EmpathyAvatarChooserPriv *priv;
	GList                  *p;

	priv = GET_PRIV (chooser);

	for (p = context->targets; p != NULL; p = p->next) {
		gchar *possible_type;

		possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data));

		if (!strcmp (possible_type, URI_LIST_TYPE)) {
			g_free (possible_type);
			gdk_drag_status (context, GDK_ACTION_COPY, time);

			return TRUE;
		}

		g_free (possible_type);
	}

	return FALSE;
}
示例#8
0
文件: testdnd.c 项目: BYC/gtk
gboolean
target_drag_motion	   (GtkWidget	       *widget,
			    GdkDragContext     *context,
			    gint                x,
			    gint                y,
			    guint               time)
{
  GtkWidget *source_widget;
  GList *tmp_list;

  if (!have_drag)
    {
      have_drag = TRUE;
      gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_open);
    }

  source_widget = gtk_drag_get_source_widget (context);
  g_print ("motion, source %s\n", source_widget ?
	   G_OBJECT_TYPE_NAME (source_widget) :
	   "NULL");

  tmp_list = gdk_drag_context_list_targets (context);
  while (tmp_list)
    {
      char *name = gdk_atom_name (GDK_POINTER_TO_ATOM (tmp_list->data));
      g_print ("%s\n", name);
      g_free (name);
      
      tmp_list = tmp_list->next;
    }

  gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time);

  return TRUE;
}
static gboolean
image_drag_motion_cb (GtkWidget *widget,
		      GdkDragContext *context,
		      gint x, gint y, guint time, EImageChooser *chooser)
{
	GList *p;

	if (!chooser->priv->editable)
		return FALSE;

	for (p = context->targets; p != NULL; p = p->next) {
		char *possible_type;

		possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data));
		if (!strcmp (possible_type, URI_LIST_TYPE)) {
			g_free (possible_type);
			gdk_drag_status (context, GDK_ACTION_COPY, time);
			return TRUE;
		}

		g_free (possible_type);
	}

	return FALSE;
}
示例#10
0
static gboolean
interactive_canvas_drag_motion (GtkWidget      *widget,
                                GdkDragContext *context,
                                gint            x,
                                gint            y,
                                guint           time,
                                gpointer        data)
{
  if (drop_item)
    {
      /* already have a drop indicator - just update position */

      drop_item->x = x;
      drop_item->y = y;

      gtk_widget_queue_draw (widget);
      gdk_drag_status (context, GDK_ACTION_COPY, time);
    }
  else
    {
      /* request DnD data for creating a drop indicator */

      GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL);

      if (!target)
        return FALSE;

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

  return TRUE;
}
示例#11
0
PasteClip Ctrl::GtkDnd(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
                       guint time, gpointer user_data, bool paste)
{
	DndTargets(context);
	g_object_ref(context); // make sure these always survive the action...
	g_object_ref(widget);
	dnd_context = context;
	dnd_widget = widget;
	dnd_time = time;
	PasteClip clip;
	clip.type = 1;
	clip.paste = paste;
	clip.accepted = false;
	clip.allowed = DND_MOVE|DND_COPY;
	gint dummy;
	GdkModifierType mod;
	gdk_window_get_pointer(gdk_get_default_root_window(), &dummy, &dummy, &mod);
	clip.action = mod & GDK_CONTROL_MASK ? DND_COPY : DND_MOVE;
	Ctrl *w = DragWnd(user_data);
	if(w) {
		gint mx, my;
		GdkModifierType mod;
		gdk_window_get_pointer(gdk_get_default_root_window(), &mx, &my, &mod);
		CurrentState = mod;
		CurrentMousePos = Point(x, y) + w->GetScreenRect().TopLeft();	
		w->DnD(CurrentMousePos, clip);
	}
	gdk_drag_status(context, clip.IsAccepted() ? clip.GetAction() == DND_MOVE ? GDK_ACTION_MOVE
	                                                                          : GDK_ACTION_COPY
	                                           : GdkDragAction(0), time);
	return clip;
}
示例#12
0
static gboolean
drag_motion_callback (GtkWidget *widget,
		      GdkDragContext *context,
		      int x, int y,
		      guint32 time)
{
	int action;

	nemo_icon_container_ensure_drag_data (NEMO_ICON_CONTAINER (widget), context, time);
	nemo_icon_container_position_shadow (NEMO_ICON_CONTAINER (widget), x, y);
	nemo_icon_dnd_update_drop_target (NEMO_ICON_CONTAINER (widget), context, x, y);
	set_up_auto_scroll_if_needed (NEMO_ICON_CONTAINER (widget));
	/* Find out what the drop actions are based on our drag selection and
	 * the drop target.
	 */
	action = 0;
	nemo_icon_container_get_drop_action (NEMO_ICON_CONTAINER (widget), context, x, y,
						 &action);
	if (action != 0) {
		start_dnd_highlight (widget);
	}
	  
	gdk_drag_status (context, action, time);

	return TRUE;
}
gboolean
contact_list_editor_drag_motion_cb (GtkWidget *widget,
                                    GdkDragContext *context,
                                    gint x, gint y,
                                    guint time)
{
	EContactListEditor *editor;
	GList *iter;

	editor = contact_list_editor_extract (widget);

	for (iter = context->targets; iter != NULL; iter = iter->next) {
		GdkAtom target = GDK_POINTER_TO_ATOM (iter->data);
		gchar *possible_type;
		gboolean match;

		possible_type = gdk_atom_name (target);
		match = (strcmp (possible_type, VCARD_TYPE) == 0);
		g_free (possible_type);

		if (match) {
			gdk_drag_status (context, GDK_ACTION_LINK, time);
			return TRUE;
		}
	}

	return FALSE;
}
示例#14
0
static void
interactive_canvas_drag_data_received (GtkWidget        *widget,
                                       GdkDragContext   *context,
                                       gint              x,
                                       gint              y,
                                       GtkSelectionData *selection,
                                       guint             info,
                                       guint             time,
                                       gpointer          data)

{
  /* find the tool button which is the source of this DnD operation */

  GtkWidget *palette = gtk_drag_get_source_widget (context);
  GtkWidget *tool_item = NULL;

  while (palette && !GTK_IS_TOOL_PALETTE (palette))
    palette = gtk_widget_get_parent (palette);

  if (palette)
    tool_item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette),
                                                selection);

  /* create a drop indicator when a tool button was found */

  g_assert (NULL == drop_item);

  if (GTK_IS_TOOL_ITEM (tool_item))
    {
      drop_item = canvas_item_new (widget, GTK_TOOL_BUTTON (tool_item), x, y);
      gdk_drag_status (context, GDK_ACTION_COPY, time);
      gtk_widget_queue_draw (widget);
    }
}
示例#15
0
static VALUE
rg_drag_status(VALUE self, VALUE action, VALUE time)
{
    gdk_drag_status(_SELF(self), 
                    RVAL2GFLAGS(action, GDK_TYPE_DRAG_ACTION), NUM2UINT(time));
    return self;
}
示例#16
0
gboolean
panel_check_drop_forbidden (PanelWidget    *panel,
			    GdkDragContext *context,
			    guint           info,
			    guint           time_)
{
	if (!panel)
		return FALSE;

	if (panel_lockdown_get_locked_down ())
		return FALSE;

	if (info == TARGET_APPLET_INTERNAL) {
		GtkWidget *source_widget;

		source_widget = gtk_drag_get_source_widget (context);

		if (BUTTON_IS_WIDGET (source_widget)) {
			GSList *forb;

			forb = g_object_get_data (G_OBJECT (source_widget),
						  MATE_PANEL_APPLET_FORBIDDEN_PANELS);

			if (g_slist_find (forb, panel))
				return FALSE;
		}
	}

	if (info == TARGET_ICON_INTERNAL ||
	    info == TARGET_APPLET_INTERNAL) {
		if (gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE)
			gdk_drag_status (context, GDK_ACTION_MOVE, time_);
		else
			gdk_drag_status (context,
					 gdk_drag_context_get_suggested_action (context),
					 time_);

	} else if (gdk_drag_context_get_actions (context) & GDK_ACTION_COPY)
		gdk_drag_status (context, GDK_ACTION_COPY, time_);
	else
		gdk_drag_status (context,
				 gdk_drag_context_get_suggested_action (context),
				 time_);

	return TRUE;

}
示例#17
0
static gboolean button_drag_motion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time, ShowDesktopData* sdd)
{
	if (sdd->button_activate == 0)
		sdd->button_activate = g_timeout_add_seconds (TIMEOUT_ACTIVATE_SECONDS, button_motion_timeout, sdd);

	gdk_drag_status(context, 0, time);

	return TRUE;
}
static void process_dnd_target_drag_motion(WindowContext *ctx, GdkEventDND *event)
{
    if (!enter_ctx.ctx) {
        gdk_drag_status(event->context, static_cast<GdkDragAction>(0), GDK_CURRENT_TIME);
        return; // Do not process motion events if no enter event was received
    }
    jmethodID method = enter_ctx.just_entered ? jViewNotifyDragEnter : jViewNotifyDragOver;
    GdkDragAction suggested = GLASS_GDK_DRAG_CONTEXT_GET_SUGGESTED_ACTION(event->context);
    GdkDragAction result = translate_glass_action_to_gdk(mainEnv->CallIntMethod(ctx->get_jview(), method,
            (jint)event->x_root - enter_ctx.dx, (jint)event->y_root - enter_ctx.dy,
            (jint)event->x_root, (jint)event->y_root,
            translate_gdk_action_to_glass(suggested)));
    CHECK_JNI_EXCEPTION(mainEnv)

    if (enter_ctx.just_entered) {
        enter_ctx.just_entered = FALSE;
    }
    gdk_drag_status(event->context, result, GDK_CURRENT_TIME);
}
示例#19
0
文件: toolpalette.c 项目: 3v1n0/gtk
static void
interactive_canvas_drag_data_received (GtkWidget        *widget,
                                       GdkDragContext   *context,
                                       gint              x,
                                       gint              y,
                                       GtkSelectionData *selection,
                                       guint             info,
                                       guint             time,
                                       gpointer          data)

{
  /* find the tool button which is the source of this DnD operation */

  GtkWidget *palette = gtk_drag_get_source_widget (context);
  GtkWidget *tool_item = NULL;
  CanvasItem *item;

  while (palette && !GTK_IS_TOOL_PALETTE (palette))
    palette = gtk_widget_get_parent (palette);

  if (palette)
    tool_item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette),
                                                selection);

  /* create a canvas item when a tool button was found */

  g_assert (NULL == drop_item);

  if (!GTK_IS_TOOL_ITEM (tool_item))
    return;

  if (drop_item)
    {
      canvas_item_free (drop_item);
      drop_item = NULL;
    }

  item = canvas_item_new (widget, GTK_TOOL_BUTTON (tool_item), x, y);

  /* Either create a new item or just create a preview item, 
     depending on why the drag data was requested. */
  if(drag_data_requested_for_drop)
    {
      canvas_items = g_list_append (canvas_items, item);
      drop_item = NULL;

      gtk_drag_finish (context, TRUE, FALSE, time);
    } else
    {
      drop_item = item;
      gdk_drag_status (context, GDK_ACTION_COPY, time);
    }

  gtk_widget_queue_draw (widget);
}
static gboolean
gstyle_color_widget_on_drag_motion (GtkWidget      *widget,
                                    GdkDragContext *context,
                                    gint            x,
                                    gint            y,
                                    guint           time)
{
  GstyleColorWidget *self = (GstyleColorWidget *)widget;
  GstylePaletteWidgetDndLockFlags dnd_lock;
  GdkAtom target;
  GdkDragAction drag_action;

  g_assert (GSTYLE_IS_COLOR_WIDGET (self));
  g_assert (GDK_IS_DRAG_CONTEXT (context));

  target = gtk_drag_dest_find_target (widget, context, NULL);
  dnd_lock = get_palette_widget_dnd_lock (self);
  if ((dnd_lock & GSTYLE_PALETTE_WIDGET_DND_LOCK_FLAGS_DRAG) != 0)
    {
      gdk_drag_status (context, 0, time);
      return FALSE;
    }

  if ((target == gdk_atom_intern_static_string ("GSTYLE_COLOR_WIDGET") ||
       target == gdk_atom_intern_static_string ("application/x-color") ||
       gtk_targets_include_text (&target, 1)) &&
      (dnd_lock & GSTYLE_PALETTE_WIDGET_DND_LOCK_FLAGS_DROP) == 0 &&
      is_in_drop_zone (self, x, y))
    {
      gtk_drag_highlight (widget);

      drag_action = gdk_drag_context_get_actions (context);
      if ((drag_action | GDK_ACTION_COPY) != 0)
        {
          gdk_drag_status (context, GDK_ACTION_COPY, time);
          return TRUE;
        }
    }

  gdk_drag_status (context, 0, time);
  return FALSE;
}
示例#21
0
void DragAndDropHandler::dragMotion(GdkDragContext* context, const IntPoint& position, unsigned time)
{
    DataObjectGtk* dataObject = requestDragData(context, position, time);
    if (!dataObject)
        return;

    DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(m_page.viewWidget(), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
    m_page.dragUpdated(dragData);
    DragOperation operation = m_page.currentDragOperation();
    gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
}
示例#22
0
文件: callbacks.c 项目: linuxmint/pix
static gboolean
gth_file_list_drag_motion (GtkWidget      *file_view,
			   GdkDragContext *context,
			   gint            x,
			   gint            y,
			   guint           time,
			   gpointer        extra_data)
{
	GthBrowser  *browser = extra_data;
	BrowserData *data;
	GthFileData *location_data;

	data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
	data->drop_pos = -1;

	if ((gtk_drag_get_source_widget (context) == file_view) && ! gth_file_source_is_reorderable (gth_browser_get_location_source (browser))) {
		gdk_drag_status (context, 0, time);
		return FALSE;
	}

	location_data = gth_browser_get_location_data (browser);
	if (! g_file_info_get_attribute_boolean (location_data->info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) {
		gdk_drag_status (context, 0, time);
		return FALSE;
	}

	if (gth_file_source_is_reorderable (gth_browser_get_location_source (browser))) {
		GtkAllocation allocation;

		if (gtk_drag_get_source_widget (context) == file_view)
			gdk_drag_status (context, GDK_ACTION_MOVE, time);
		else
			gdk_drag_status (context, GDK_ACTION_COPY, time);
		gth_file_view_set_drag_dest_pos (GTH_FILE_VIEW (file_view), context, x, y, time, &data->drop_pos);

		gtk_widget_get_allocation (file_view, &allocation);

		if (y < 10)
			data->scroll_diff = - (10 - y);
		else if (y > allocation.height - 10)
			data->scroll_diff = (10 - (allocation.height - y));
		else
			data->scroll_diff = 0;

		if (data->scroll_diff != 0) {
			if (data->scroll_event == 0)
				data->scroll_event = gdk_threads_add_timeout (SCROLL_TIMEOUT, drag_motion_autoscroll_cb, browser);
		}
		else if (data->scroll_event != 0) {
			g_source_remove (data->scroll_event);
			data->scroll_event = 0;
		}
	}
	else if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_ASK)
		gdk_drag_status (context, GDK_ACTION_ASK, time);
	else
		gdk_drag_status (context, GDK_ACTION_COPY, time);

	return TRUE;
}
示例#23
0
void DragAndDropHandler::dragEntered(GdkDragContext* context, GtkSelectionData* selectionData, unsigned info, unsigned time)
{
    IntPoint position;
    DataObjectGtk* dataObject = dataObjectForDropData(context, selectionData, info, position);
    if (!dataObject)
        return;

    DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(m_page.viewWidget(), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
    m_page.resetCurrentDragInformation();
    m_page.dragEntered(dragData);
    DragOperation operation = m_page.currentDragOperation();
    gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
}
示例#24
0
static gboolean
individual_view_drag_motion_cb (GtkWidget *widget,
    GdkDragContext *context,
    gint x,
    gint y,
    guint time_)
{
  EmpathyIndividualView *view = EMPATHY_INDIVIDUAL_VIEW (widget);
  GdkAtom target;

  target = gtk_drag_dest_find_target (GTK_WIDGET (view), context, NULL);

  if (target == gdk_atom_intern_static_string ("text/x-persona-id"))
    {
      GtkTreePath *path;

      /* FIXME: It doesn't make sense for us to highlight a specific row or
       * position to drop a Persona in, so just highlight the entire widget.
       * Since I can't find a way to do this, just highlight the first possible
       * position in the tree. */
      gdk_drag_status (context, gdk_drag_context_get_suggested_action (context),
          time_);

      path = gtk_tree_path_new_first ();
      gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view), path,
          GTK_TREE_VIEW_DROP_BEFORE);
      gtk_tree_path_free (path);

      return TRUE;
    }

  /* Unknown or unhandled drag target */
  gdk_drag_status (context, GDK_ACTION_DEFAULT, time_);
  gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (view), NULL, 0);

  return FALSE;
}
示例#25
0
static gboolean gtkDragMotion(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, guint time, Ihandle* ih)
{
  GdkAtom targetAtom;

  /* The third argument must be NULL. Internally, GTK will use the list returned
     by the call gtk_drag_dest_get_target_list(widget), which is the list of targets
     that be destination widget can accept (defined in the gtkSetDropTargetAttrib IUP) */
  targetAtom = gtk_drag_dest_find_target(widget, drag_context, NULL);

  if(targetAtom != GDK_NONE)
  {
    IFniis cbDropMotion = (IFniis)IupGetCallback(ih, "DROPMOTION_CB");

    if(cbDropMotion)
    {
      char status[IUPKEY_STATUS_SIZE] = IUPKEY_STATUS_INIT;
      GdkModifierType mask;
      gdk_window_get_pointer(iupgtkGetWindow(widget), NULL, NULL, &mask);

      iupgtkButtonKeySetStatus(mask, 0, status, 0);
      cbDropMotion(ih, x, y, status);
    }

#if GTK_CHECK_VERSION(2, 22, 0)   
    gdk_drag_status(drag_context, gdk_drag_context_get_suggested_action(drag_context), time);
#else
    gdk_drag_status(drag_context, drag_context->suggested_action, time);
#endif
    return TRUE;
  }
  (void)ih;
  (void)x;
  (void)y;

  gdk_drag_status(drag_context, 0, time);
  return FALSE;
}
示例#26
0
文件: fm-dnd-dest.c 项目: engla/libfm
inline static
gboolean cache_src_file_infos(FmDndDest* dd, GtkWidget *dest_widget,
                        gint x, gint y, GdkDragContext *drag_context)
{
    GdkAtom target;
    target = gtk_drag_dest_find_target( dest_widget, drag_context, NULL );
    if( target != GDK_NONE )
    {
        GdkDragAction action;
        gboolean ret;
        /* treat X direct save as a special case. */
        if( target == gdk_atom_intern_static_string("XdndDirectSave0") )
        {
            /* FIXME: need a better way to handle this. */
            action = drag_context->suggested_action;
            g_signal_emit(dd, signals[QUERY_INFO], 0, x, y, &action, &ret);

            gdk_drag_status(drag_context, action, time);
            return TRUE;
        }

        /* g_debug("try to cache src_files"); */
        dd->mainloop = g_main_loop_new(NULL, TRUE);
        gtk_drag_get_data(dest_widget, drag_context, target, time);
        /* run the main loop to block here waiting for
         * 'drag-data-received' signal being handled first. */
        /* it's possible that g_main_loop_quit is called before we really run the loop. */
        if(g_main_loop_is_running(dd->mainloop))
            g_main_loop_run(dd->mainloop);
        g_main_loop_unref(dd->mainloop);
        dd->mainloop = NULL;
        /* g_debug("src_files cached: %p", dd->src_files); */

        /* dd->src_files should be set now */
        if( dd->src_files && fm_list_is_file_info_list(dd->src_files) )
        {
            /* cache file system id of source files */
            if( fm_file_info_list_is_same_fs(dd->src_files) )
            {
                FmFileInfo* fi = (FmFileInfo*)fm_list_peek_head(dd->src_files);
                if(fm_path_is_native(fi->path))
                    dd->src_dev = fi->dev;
                else
                    dd->src_fs_id = fi->fs_id;
            }
        }
    }
    return FALSE;
}
示例#27
0
static gboolean DNDDragMotionCB(
        GtkWidget *widget, GdkDragContext *dc,
        gint xx, gint yy, guint tt,
        gpointer data
)
{
#ifdef WAVE_USE_GTK2
	GdkDragAction suggested_action;

        /* Respond with default drag action (status). First we check
         * the dc's list of actions. If the list only contains
         * move, copy, or link then we select just that, otherwise we
         * return with our default suggested action.
         * If no valid actions are listed then we respond with 0.
         */
        suggested_action = GDK_ACTION_MOVE;
 
        /* Only move? */
        if(dc->actions == GDK_ACTION_MOVE)
            gdk_drag_status(dc, GDK_ACTION_MOVE, tt);
        /* Only copy? */
        else if(dc->actions == GDK_ACTION_COPY)
            gdk_drag_status(dc, GDK_ACTION_COPY, tt);  
        /* Only link? */
        else if(dc->actions == GDK_ACTION_LINK)
            gdk_drag_status(dc, GDK_ACTION_LINK, tt);
        /* Other action, check if listed in our actions list? */   
        else if(dc->actions & suggested_action)
            gdk_drag_status(dc, suggested_action, tt);
        /* All else respond with 0. */
        else
            gdk_drag_status(dc, 0, tt);
#endif

return(FALSE);
}
static gboolean
toolbar_drag_motion_cb (GtkToolbar         *toolbar,
		        GdkDragContext     *context,
		        gint                x,
		        gint                y,
		        guint               time,
		        EggEditableToolbar *etoolbar)
{
  GdkAtom target = gtk_drag_dest_find_target (GTK_WIDGET (toolbar), context, NULL);
  if (target == GDK_NONE)
    {
      gdk_drag_status (context, 0, time);
      return FALSE;
    }

  /* Make ourselves the current dnd toolbar, and request a highlight item. */
  if (etoolbar->priv->dnd_toolbar != toolbar)
    {
      etoolbar->priv->dnd_toolbar = toolbar;
      etoolbar->priv->dnd_toolitem = NULL;
      etoolbar->priv->dnd_pending++;
      gtk_drag_get_data (GTK_WIDGET (toolbar), context, target, time);
    }

  /* If a highlight item is available, use it. */
  else if (etoolbar->priv->dnd_toolitem)
    {
      gint ipos = gtk_toolbar_get_drop_index (etoolbar->priv->dnd_toolbar, x, y);
      gtk_toolbar_set_drop_highlight_item (etoolbar->priv->dnd_toolbar,
                                           etoolbar->priv->dnd_toolitem, ipos);
    }

  gdk_drag_status (context, context->suggested_action, time);

  return TRUE;
}
示例#29
0
static gboolean
drag_motion_cb(GtkWidget *widget,
	       GdkDragContext *context,
	       gint x,
	       gint y,
	       guint time,
	       Launcher *launcher)
{
	if ( ! is_this_drop_ok (widget, context))
		return FALSE;

	gdk_drag_status (context, GDK_ACTION_COPY, time);

	button_widget_set_dnd_highlight(BUTTON_WIDGET(widget), TRUE);

	return TRUE;
}
示例#30
0
static gboolean on_drag_motion(GtkWidget *dest_widget,
                                 GdkDragContext *drag_context,
                                 gint x,
                                 gint y,
                                 guint time,
                                 FmFolderView* fv)
{
    gboolean ret;
    GdkDragAction action = 0;
    GdkAtom target = gtk_drag_dest_find_target(dest_widget, drag_context, NULL);

    if(target == GDK_NONE)
        return FALSE;

    ret = FALSE;
    /* files are being dragged */
    if(fm_dnd_dest_is_target_supported(fv->dnd_dest, target))
    {
        GtkTreePath* tp = get_drop_path(fv, x, y);
        if(tp)
        {
            GtkTreeIter it;
            if(gtk_tree_model_get_iter(fv->model, &it, tp))
            {
                FmFileInfo* fi;
                gtk_tree_model_get(fv->model, &it, COL_FILE_INFO, &fi, -1);
                fm_dnd_dest_set_dest_file(fv->dnd_dest, fi);
            }
            gtk_tree_path_free(tp);
        }
        else
        {
            /* FIXME: prevent direct access to data members. */
            FmFolderModel* model = (FmFolderModel*)fv->model;
            FmPath* dir_path =  model->dir->dir_path;
            fm_dnd_dest_set_dest_file(fv->dnd_dest, model->dir->dir_fi);
        }
        action = fm_dnd_dest_get_default_action(fv->dnd_dest, drag_context, target);
        ret = action != 0;
    }

    if (action)
    gdk_drag_status(drag_context, action, time);

    return ret;
}