static gboolean
get_drag_data (NautilusTreeViewDragDest *dest,
               GdkDragContext *context,
               guint32 time)
{
    GdkAtom target;

    target = gtk_drag_dest_find_target (GTK_WIDGET (dest->details->tree_view),
                                        context,
                                        NULL);

    if (target == GDK_NONE) {
        return FALSE;
    }

    if (target == gdk_atom_intern (NAUTILUS_ICON_DND_XDNDDIRECTSAVE_TYPE, FALSE) &&
            !dest->details->drop_occurred) {
        dest->details->drag_type = NAUTILUS_ICON_DND_XDNDDIRECTSAVE;
        dest->details->have_drag_data = TRUE;
        return TRUE;
    }

    gtk_drag_get_data (GTK_WIDGET (dest->details->tree_view),
                       context, target, time);

    return TRUE;
}
Esempio n. 2
0
static void
rb_playlist_source_drop_cb (GtkWidget *widget,
			    GdkDragContext *context,
			    gint x,
			    gint y,
			    GtkSelectionData *data,
			    guint info,
			    guint time,
			    gpointer user_data)
{
	RBPlaylistSource *source = RB_PLAYLIST_SOURCE (user_data);
	GtkTargetList *tlist;
	GdkAtom target;

	tlist = gtk_target_list_new (target_uri, G_N_ELEMENTS (target_uri));
	target = gtk_drag_dest_find_target (widget, context, tlist);
	gtk_target_list_unref (tlist);

	if (target == GDK_NONE)
		return;

	rb_display_page_receive_drag (RB_DISPLAY_PAGE (source), data);

	gtk_drag_finish (context, TRUE, FALSE, time);
}
Esempio n. 3
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;
}
static gboolean
gstyle_color_widget_on_drag_drop (GtkWidget        *widget,
                                  GdkDragContext   *context,
                                  gint              x,
                                  gint              y,
                                  guint             time)
{
  GstyleColorWidget *self = (GstyleColorWidget *)widget;
  GdkAtom target;

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

  target = gtk_drag_dest_find_target (widget, context, NULL);
  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)) &&
      is_in_drop_zone (self, x, y))
    {
      gtk_drag_get_data (widget, context, target, time);
      return TRUE;
    }

  return FALSE;
}
Esempio n. 5
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;
}
Esempio n. 6
0
int
clip_GTK_DRAGDESTFINDTARGET(ClipMachine * cm)
{
	C_widget     *cwid = _fetch_cw_arg(cm);
        C_object *ccontext = _fetch_cobject(cm, _clip_spar(cm, 2));
        C_object   *ctlist = _fetch_cobject(cm, _clip_spar(cm, 3));
        GdkAtom       atom ;
        C_object    *catom ;

	CHECKCWID(cwid, GTK_IS_WIDGET);
	if (!ccontext || ccontext->type != GDK_TYPE_DRAG_CONTEXT)
        	goto err;
	if (!ctlist || ctlist->type != GTK_TYPE_TARGET_LIST)
        		goto err;

        atom = gtk_drag_dest_find_target(GTK_WIDGET(cwid->widget),
        	(GdkDragContext*)ccontext->object,
        	(GtkTargetList*)ctlist->object);
	if (atom)
        {
        	catom = _list_get_cobject(cm, &atom);
        	if (!catom) catom = _register_object(cm, &atom, GDK_TYPE_ATOM, NULL, NULL);
                if (catom) _clip_mclone(cm, RETPTR(cm), &catom->obj);
        }

	return 0;
err:
	return 1;
}
Esempio n. 7
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;
}
Esempio n. 8
0
/**
 * dnd_clarity_drag_drop:
 *
 * Used by the drag and drop of a jpg. When a drop is
 * made, this determines whether the drop is valid
 * then requests the data from the source widget.
 *
 */
gboolean dnd_clarity_drag_drop(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, guint time, gpointer user_data) {
    GdkAtom target;
    target = gtk_drag_dest_find_target(widget, drag_context, NULL);

    if (target != GDK_NONE) {
        gtk_drag_get_data(widget, drag_context, target, time);
        return TRUE;
    }

    return FALSE;
}
gboolean receive_drag(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, guint time, gpointer user_data)
{
	GtkTargetList *TL = gtk_target_list_new(target_table,1);
	GdkAtom target = gtk_drag_dest_find_target(widget,drag_context,TL);
	GtkWidget *srcWidget = gtk_drag_get_source_widget(drag_context);
	if (target == GDK_NONE || srcWidget == NULL)
		return FALSE;
	gtk_drag_get_data(srcWidget,drag_context,target,time);
	gtk_widget_queue_draw(widget);
	return TRUE;
}
Esempio n. 10
0
static VALUE
rg_m_dest_find_target(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
{
    VALUE widget, context, target_list;
    GdkAtom ret;
    rb_scan_args(argc, argv, "21", &widget, &context, &target_list);

    ret = gtk_drag_dest_find_target(
        RVAL2WIDGET(widget), RVAL2DC(context),
        NIL_P(target_list) ? NULL : RVAL2BOXED(target_list, GTK_TYPE_TARGET_LIST));

    return BOXED2RVAL(ret, GDK_TYPE_ATOM);
}
Esempio n. 11
0
static gboolean on_drag_drop(GtkWidget *dest_widget,
                               GdkDragContext *drag_context,
                               gint x,
                               gint y,
                               guint time,
                               FmFolderView* fv)
{
    gboolean ret = FALSE;
    GdkAtom target = gtk_drag_dest_find_target(dest_widget, drag_context, NULL);
    if(target != GDK_NONE)
        ret = fm_dnd_dest_drag_drop(fv->dnd_dest, drag_context, target, x, y, time);
    return ret;
}
Esempio n. 12
0
/* FIXME bugzilla.gnome.org 47445: Needs to become a shared function */
static void
get_data_on_first_target_we_support (GtkWidget *widget, GdkDragContext *context, guint32 time, int x, int y)
{
	GtkTargetList *list;
	GdkAtom target;

	if (drop_types_list == NULL) {
		drop_types_list = gtk_target_list_new (drop_types,
						       G_N_ELEMENTS (drop_types) - 1);
		gtk_target_list_add_text_targets (drop_types_list, NEMO_ICON_DND_TEXT);
	}
	if (drop_types_list_root == NULL) {
		drop_types_list_root = gtk_target_list_new (drop_types,
							    G_N_ELEMENTS (drop_types));
		gtk_target_list_add_text_targets (drop_types_list_root, NEMO_ICON_DND_TEXT);
	}
	
	if (nemo_icon_container_get_is_desktop (NEMO_ICON_CONTAINER (widget))) {
		list = drop_types_list_root;
	} else {
		list = drop_types_list;
	}

	target = gtk_drag_dest_find_target (widget, context, list);
	if (target != GDK_NONE) {
		guint info;
		NemoDragInfo *drag_info;
		gboolean found;

		drag_info = &(NEMO_ICON_CONTAINER (widget)->details->dnd_info->drag_info);

		found = gtk_target_list_find (list, target, &info);
		g_assert (found);

		/* Don't get_data for destructive ops */
		if ((info == NEMO_ICON_DND_ROOTWINDOW_DROP ||
		     info == NEMO_ICON_DND_XDNDDIRECTSAVE) &&
		    !drag_info->drop_occured) {
			/* We can't call get_data here, because that would
			   make the source execute the rootwin action or the direct save */
			drag_info->got_drop_data_type = TRUE;
			drag_info->data_type = info;
		} else {
			if (info == NEMO_ICON_DND_XDNDDIRECTSAVE) {
				set_direct_save_uri (widget, context, drag_info, x, y);
			}
			gtk_drag_get_data (GTK_WIDGET (widget), context,
					   target, time);
		}
	}
}
static gboolean
rb_tree_dnd_drag_drop_cb (GtkWidget        *widget,
                         GdkDragContext   *context,
                         gint              x,
                         gint              y,
                         guint             time)
{
	GtkTreeView *tree_view;
	GtkTreePath *path;
	GtkTreeModel *model;
	GtkTreeViewDropPosition pos;
	RbTreeDndData *priv_data;

	tree_view = GTK_TREE_VIEW (widget);
	model = gtk_tree_view_get_model (tree_view);
	priv_data = g_object_get_data (G_OBJECT (widget), RB_TREE_DND_STRING);
	gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &path, &pos);

	remove_scroll_timeout (tree_view);

	/* Unset this thing */
	gtk_tree_view_set_drag_dest_row (tree_view,
               				 NULL,
					 GTK_TREE_VIEW_DROP_BEFORE);

	if (path || priv_data->dest_flags & RB_TREE_DEST_EMPTY_VIEW_DROP) {

		GdkAtom target;
		RbTreeDragDestIface *iface = RB_TREE_DRAG_DEST_GET_IFACE (model);
		if (iface->rb_get_drag_target) {
			RbTreeDragDest *dest = RB_TREE_DRAG_DEST (model);
			target = (* iface->rb_get_drag_target) (dest, widget, 
								context, path, 
								priv_data->dest_target_list);
		} else {
			target = gtk_drag_dest_find_target (widget, context, 
							    priv_data->dest_target_list);
		}

		if (path)
			gtk_tree_path_free (path);

		if (target != GDK_NONE) {
			gtk_drag_get_data (widget, context, target, time);
			return TRUE;
		}
	}

	return FALSE;
}
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;
}
Esempio n. 15
0
static void
get_drag_data (EphyNodeView *view,
	       GdkDragContext *context, 
	       guint32 time)
{
	GdkAtom target;
	
	target = gtk_drag_dest_find_target (GTK_WIDGET (view), 
					    context, 
					    NULL);

	gtk_drag_get_data (GTK_WIDGET (view),
			   context, target, time);
}
Esempio n. 16
0
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;
}
Esempio n. 17
0
static gboolean on_drag_motion(GtkWidget *widget, GdkDragContext *drag_context,
                               gint x, gint y, guint time, gpointer user_data)
{
    FmDndAutoScroll* as = (FmDndAutoScroll*)user_data;
    /* FIXME: this is a dirty hack for GTK_TREE_MODEL_ROW. When dragging GTK_TREE_MODEL_ROW
     * we cannot receive "drag-leave" message. So weied! Is it a gtk+ bug? */
    GdkAtom target = gtk_drag_dest_find_target(widget, drag_context, NULL);
    if(target == GDK_NONE)
        return FALSE;
    if(0 == as->timeout) /* install a scroll timeout if needed */
    {
        as->timeout = gdk_threads_add_timeout(150, on_auto_scroll, as);
    }
    return FALSE;
}
Esempio n. 18
0
static gboolean
on_drag_drop (GtkWidget *widget,
			  GdkDragContext *context,
			  gint x, gint y,
			  guint time, gpointer data)
{
	GtkTargetList *target_list = gtk_target_list_new (targets, n_targets);
	GdkAtom atom = gtk_drag_dest_find_target (widget, context, target_list);

	if (atom == GDK_NONE)
		return FALSE;

	gtk_drag_get_data (widget, context, atom, time);
	gtk_target_list_unref (target_list);
	return TRUE;
}
Esempio n. 19
0
static gboolean
on_log_pane_drag_drop (GtkWidget *widget, GdkDragContext *context, 
                       gint x, gint y, guint time,
                       GitLogPane *self)
{
	GdkAtom target_type;

	target_type = gtk_drag_dest_find_target (widget, context, NULL);

	if (target_type != GDK_NONE)
		gtk_drag_get_data (widget, context, target_type, time);
	else
		gtk_drag_finish (context, FALSE, FALSE, time);

	return TRUE;
}
Esempio n. 20
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;
}
Esempio n. 21
0
Vector<GdkAtom> PasteboardHelper::dropAtomsForContext(GtkWidget* widget, GdkDragContext* context)
{
    // Always search for these common atoms.
    Vector<GdkAtom> dropAtoms;
    dropAtoms.append(textPlainAtom);
    dropAtoms.append(markupAtom);
    dropAtoms.append(uriListAtom);
    dropAtoms.append(netscapeURLAtom);

    // For images, try to find the most applicable image type.
    PlatformRefPtr<GtkTargetList> list(gtk_target_list_new(0, 0));
    gtk_target_list_add_image_targets(list.get(), getIdForTargetType(TargetTypeImage), TRUE);
    GdkAtom atom = gtk_drag_dest_find_target(widget, context, list.get());
    if (atom != GDK_NONE)
        dropAtoms.append(atom);

    return dropAtoms;
}
Esempio n. 22
0
static gboolean
interactive_canvas_drag_drop (GtkWidget      *widget,
                              GdkDragContext *context,
                              gint            x,
                              gint            y,
                              guint           time,
                              gpointer        data)
{
  GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL);

  if (!target)
    return FALSE;

  drag_data_requested_for_drop = TRUE;
  gtk_drag_get_data (widget, context, target, time);

  return FALSE;
}
static gboolean
toolbar_drag_drop_cb (GtkToolbar         *toolbar,
		      GdkDragContext     *context,
		      gint                x,
		      gint                y,
		      guint               time,
		      EggEditableToolbar *etoolbar)
{
  GdkAtom target;

  target = gtk_drag_dest_find_target (GTK_WIDGET (toolbar), context, NULL);
  if (target != GDK_NONE)
    {
      gtk_drag_get_data (GTK_WIDGET (toolbar), context, target, time);
      return TRUE;
    }

  return FALSE;
}
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;
}
static gboolean
drag_drop_callback (GtkWidget *widget,
		    GdkDragContext *context,
		    int x, 
		    int y,
		    guint32 time,
		    gpointer data)
{
	NemoTreeViewDragDest *dest;
	guint info;
	GdkAtom target;

	dest = NEMO_TREE_VIEW_DRAG_DEST (data);
	
	target = gtk_drag_dest_find_target (GTK_WIDGET (dest->details->tree_view), 
					    context, 
					    NULL);
	if (target == GDK_NONE) {
		return FALSE;
	}

	info = dest->details->drag_type;

	if (info == NEMO_ICON_DND_XDNDDIRECTSAVE) {
		/* We need to set this or get_drop_path will fail, and it
		   was unset by drag_leave_callback */
		dest->details->have_drag_data = TRUE;
		if (!set_direct_save_uri (dest, context, x, y)) {
			return FALSE;
		}
		dest->details->have_drag_data = FALSE;
	}

	dest->details->drop_occurred = TRUE;

	get_drag_data (dest, context, time);
	remove_scroll_timeout (dest);
	remove_expand_timeout (dest);
	clear_drag_dest_row (dest);
	
	return TRUE;
}
Esempio n. 26
0
static gboolean
slot_proxy_drag_drop (GtkWidget          *widget,
                      GdkDragContext     *context,
                      int                 x,
                      int                 y,
                      unsigned int        time,
                      gpointer            user_data)
{
    GdkAtom target;
    NautilusDragSlotProxyInfo *drag_info;

    drag_info = user_data;
    g_assert (!drag_info->have_data);

    drag_info->drop_occured = TRUE;

    target = gtk_drag_dest_find_target (widget, context, NULL);
    gtk_drag_get_data (widget, context, target, time);

    return TRUE;
}
Esempio n. 27
0
static gboolean on_drag_drop ( GtkWidget *dest_widget,
                    GdkDragContext *drag_context, gint x, gint y, guint time)
{
    FmPlacesView* view = FM_PLACES_VIEW(dest_widget);
    GtkTreeViewDropPosition pos;
    gboolean ret = FALSE;

    GdkAtom target = gtk_drag_dest_find_target(dest_widget, drag_context, NULL);
    /* this is to reorder bookmark */
    if(target == gdk_atom_intern_static_string("GTK_TREE_MODEL_ROW"))
    {
        gtk_drag_get_data(dest_widget, drag_context, target, time);
        ret = TRUE;
    }
    else
    {
        /* try FmDndDest */
        ret = fm_dnd_dest_drag_drop(view->dnd_dest, drag_context, target, time);
        if(!ret)
            gtk_drag_finish(drag_context, FALSE, FALSE, time);
    }
    return ret;
}
Esempio n. 28
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;
}
Esempio n. 29
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;
}
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;
}