コード例 #1
0
static gboolean
image_drag_drop_cb (GtkWidget *widget,
		    GdkDragContext *context,
		    gint x, gint y, guint time, EImageChooser *chooser)
{
	GList *p;

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

	if (gdk_drag_context_list_targets (context) == NULL) {
		return FALSE;
	}

	for (p = gdk_drag_context_list_targets (context); p; 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);
			gtk_drag_get_data (widget, context,
					   GDK_POINTER_TO_ATOM (p->data),
					   time);
			return TRUE;
		}

		g_free (possible_type);
	}

	return FALSE;
}
コード例 #2
0
ファイル: main.c プロジェクト: Vild/ImageToMap-X
gboolean drag_drop(GtkWidget * widget, GdkDragContext * context, gint x, gint y, guint time, gpointer user_data)
{
  if (gdk_drag_context_list_targets(context))
    return TRUE;
  else
    return FALSE;
}
コード例 #3
0
ファイル: prefs.c プロジェクト: ptomato/gnome-inform7
gboolean
on_extensions_view_drag_drop(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, guint time)
{
	/* Iterate through the list of target types provided by the source */
	GdkAtom target_type = NULL;
	GList *iter;
	for(iter = gdk_drag_context_list_targets(drag_context); iter != NULL; iter = g_list_next(iter)) {
		gchar *type_name = gdk_atom_name(GDK_POINTER_TO_ATOM(iter->data));
		/* Select 'text/uri-list' from the list of available targets */
		if(!strcmp(type_name, "text/uri-list")) {
			g_free(type_name);
			target_type = GDK_POINTER_TO_ATOM(iter->data);
			break;
		}
		g_free(type_name);
	}
	/* If URI list not supported, then cancel */
	if(!target_type)
		return FALSE;

	/* Request the data from the source. */
	gtk_drag_get_data(
	  widget,         /* this widget, which will get 'drag-data-received' */
	  drag_context,   /* represents the current state of the DnD */
	  target_type,    /* the target type we want */
	  time);            /* time stamp */
	return TRUE;
}
コード例 #4
0
ファイル: panel.c プロジェクト: fanpenggogo/mate-panel-new
gboolean
panel_check_dnd_target_data (GtkWidget      *widget,
			     GdkDragContext *context,
			     guint          *ret_info,
			     GdkAtom        *ret_atom)
{
	GList *l;

	g_return_val_if_fail (widget, FALSE);

	if (!PANEL_IS_TOPLEVEL  (widget) &&
	    !BUTTON_IS_WIDGET (widget))
		return FALSE;

	if (!(gdk_drag_context_get_actions (context) & (GDK_ACTION_COPY|GDK_ACTION_MOVE)))
		return FALSE;

	for (l = gdk_drag_context_list_targets (context); l; l = l->next) {
		GdkAtom atom;
		guint   info;

		atom = GDK_POINTER_TO_ATOM (l->data);

		if (gtk_target_list_find (get_target_list (), atom, &info)) {
			if (ret_info)
				*ret_info = info;

			if (ret_atom)
				*ret_atom = atom;
			break;
		}
	}

	return l ? TRUE : FALSE;
}
コード例 #5
0
ファイル: dragdrop.c プロジェクト: AreaScout/vice
/* Emitted when the user releases (drops) the selection. It should check that
 * the drop is over a valid part of the widget (if its a complex widget), and
 * itself to return true if the operation should continue. Next choose the
 * target type it wishes to ask the source for. Finally call gtk_drag_get_data
 * which will emit "drag-data-get" on the source. */
static gboolean drag_drop_handler(GtkWidget *widget, GdkDragContext *context, 
    gint x, gint y, guint time, gpointer user_data)
{
    GdkAtom target_type;
    GList *targets = gdk_drag_context_list_targets(context);

    DBG(("drag_drop_handler"));

    /* If the source offers a target */
    if (targets) {
        /* Choose the best target type */
        target_type = GDK_POINTER_TO_ATOM(g_list_nth_data (targets, TARGET_STRING));

        dropdata = 1;
        /* Request the data from the source. */
        gtk_drag_get_data(
            widget,         /* will receive 'drag-data-received' signal */
            context,        /* represents the current state of the DnD */
            target_type,    /* the target type we want */
            time            /* time stamp */
        );
        return TRUE;
    }
    /* No target offered by source => error */
    return FALSE;
}
コード例 #6
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;
}
コード例 #7
0
ファイル: GtkDnD.cpp プロジェクト: kolyden/mirror
void Ctrl::DndTargets(GdkDragContext *context)
{
    static Index<String> text_targets;
    static Index<String> image_targets;
    ONCELOCK {
        GtkTargetList *target_list = gtk_target_list_new (NULL, 0);
        gtk_target_list_add_text_targets (target_list, 0);
        ToIndex(target_list, text_targets);
        GtkTargetList *target_list2 = gtk_target_list_new (NULL, 0);
        gtk_target_list_add_image_targets (target_list2, 0, TRUE);
        ToIndex(target_list2, image_targets);
    }
    dnd_targets.Clear();
    dnd_text_target.Clear();
    for(GList *list = gdk_drag_context_list_targets(context); list; list = g_list_next (list)) {
        String g = gdk_atom_name((GdkAtom)list->data);
        if(text_targets.Find(g) >= 0) {
            dnd_targets.Add("text");
            if(dnd_text_target.IsEmpty())
                dnd_text_target = g;
        }
        else if(image_targets.Find(g) >= 0) {
            dnd_targets.Add("image");
            if(dnd_image_target.IsEmpty())
                dnd_image_target = g;
        }
        else
            dnd_targets.Add(g);
    }
}
コード例 #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;
}
コード例 #9
0
static gboolean
is_this_drop_ok (GtkWidget      *widget,
		 GdkDragContext *context)
{
	static GdkAtom  text_uri_list = GDK_NONE;
	GList           *l;
	GtkWidget       *source;

	source = gtk_drag_get_source_widget (context);

	if (source == widget)
		return FALSE;

	if (!(gdk_drag_context_get_actions (context) & GDK_ACTION_COPY))
		return FALSE;

	if (!text_uri_list)
		text_uri_list = gdk_atom_intern_static_string ("text/uri-list");

	for (l = gdk_drag_context_list_targets (context); l; l = l->next) {
		if (GDK_POINTER_TO_ATOM (l->data) == text_uri_list)
			break;
	}

	return l ? TRUE : FALSE;
}
コード例 #10
0
ファイル: dnd.cpp プロジェクト: 0ryuO/dolphin-avsync
GdkAtom wxDropTarget::GTKGetMatchingPair(bool quiet)
{
    if (!m_dataObject)
        return (GdkAtom) 0;

    if (!m_dragContext)
        return (GdkAtom) 0;

    const GList* child = gdk_drag_context_list_targets(m_dragContext);
    while (child)
    {
        GdkAtom formatAtom = (GdkAtom)(child->data);
        wxDataFormat format( formatAtom );

        if ( !quiet )
        {
            wxLogTrace(TRACE_DND, wxT("Drop target: drag has format: %s"),
                       format.GetId().c_str());
        }

        if (m_dataObject->IsSupportedFormat( format ))
            return formatAtom;

        child = child->next;
    }

    return (GdkAtom) 0;
}
コード例 #11
0
ファイル: misc.c プロジェクト: svn2github/GtkAda
void ada_gtk_dnd_context_get_targets (GdkDragContext* context, GdkAtom* result)
{
  GList *glist = gdk_drag_context_list_targets (context);
  GdkAtom* tmp = result;
  while (glist != NULL)
    {
      *tmp++ = (GdkAtom)glist->data;
//      gchar *name = gdk_atom_name ((GdkAtom)glist->data);
//      *tmp++ = name;
      glist = glist->next;
    }
}
コード例 #12
0
ファイル: testdnd.c プロジェクト: BYC/gtk
gboolean
target_drag_drop	   (GtkWidget	       *widget,
			    GdkDragContext     *context,
			    gint                x,
			    gint                y,
			    guint               time)
{
  g_print("drop\n");
  have_drag = FALSE;

  gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_closed);

  if (gdk_drag_context_list_targets (context))
    {
      gtk_drag_get_data (widget, context,
			 GDK_POINTER_TO_ATOM (gdk_drag_context_list_targets (context)->data),
			 time);
      return TRUE;
    }
  
  return FALSE;
}
コード例 #13
0
ファイル: gtkdragdest.c プロジェクト: endlessm/gtk
/**
 * gtk_drag_dest_find_target: (method)
 * @widget: drag destination widget
 * @context: drag context
 * @target_list: (allow-none): list of droppable targets, or %NULL to use
 *    gtk_drag_dest_get_target_list (@widget).
 *
 * Looks for a match between the supported targets of @context and the
 * @dest_target_list, returning the first matching target, otherwise
 * returning %GDK_NONE. @dest_target_list should usually be the return
 * value from gtk_drag_dest_get_target_list(), but some widgets may
 * have different valid targets for different parts of the widget; in
 * that case, they will have to implement a drag_motion handler that
 * passes the correct target list to this function.
 *
 * Returns: (transfer none): first target that the source offers
 *     and the dest can accept, or %GDK_NONE
 */
GdkAtom
gtk_drag_dest_find_target (GtkWidget      *widget,
                           GdkDragContext *context,
                           GtkTargetList  *target_list)
{
  GList *tmp_target;
  GList *tmp_source = NULL;
  GtkWidget *source_widget;

  g_return_val_if_fail (GTK_IS_WIDGET (widget), GDK_NONE);
  g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), GDK_NONE);

  source_widget = gtk_drag_get_source_widget (context);
  if (target_list == NULL)
    target_list = gtk_drag_dest_get_target_list (widget);

  if (target_list == NULL)
    return GDK_NONE;

  tmp_target = target_list->list;
  while (tmp_target)
    {
      GtkTargetPair *pair = tmp_target->data;
      tmp_source = gdk_drag_context_list_targets (context);
      while (tmp_source)
        {
          if (tmp_source->data == GUINT_TO_POINTER (pair->target))
            {
              if ((!(pair->flags & GTK_TARGET_SAME_APP) || source_widget) &&
                  (!(pair->flags & GTK_TARGET_SAME_WIDGET) || (source_widget == widget)) &&
                  (!(pair->flags & GTK_TARGET_OTHER_APP) || !source_widget) &&
                  (!(pair->flags & GTK_TARGET_OTHER_WIDGET) || (source_widget != widget)))
                return pair->target;
              else
                break;
            }
          tmp_source = tmp_source->next;
        }
      tmp_target = tmp_target->next;
    }

  return GDK_NONE;
}
コード例 #14
0
ファイル: GtkDnD.cpp プロジェクト: AbdelghaniDr/mirror
void Ctrl::DndTargets(GdkDragContext *context)
{
	static Index<String> text_targets;
	static Index<String> image_targets;
	static Index<String> files_targets;
	ONCELOCK {
		GtkTargetList *target_list = gtk_target_list_new (NULL, 0);
		gtk_target_list_add_text_targets(target_list, 0);
		ToIndex(target_list, text_targets);
		GtkTargetList *target_list2 = gtk_target_list_new (NULL, 0);
		gtk_target_list_add_image_targets(target_list2, 0, TRUE);
		ToIndex(target_list2, image_targets);
		GtkTargetList *target_list3 = gtk_target_list_new (NULL, 0);
		gtk_target_list_add_uri_targets(target_list3, 0);
		ToIndex(target_list3, files_targets);
	}
	dnd_targets.Clear();
	dnd_text_target.Clear();
#if GTK_CHECK_VERSION(2,22,0) // No drag&drop support before 2.22, sorry...
	for(GList *list = gdk_drag_context_list_targets(context); list; list = g_list_next (list)) {
		String g = gdk_atom_name((GdkAtom)list->data);
		if(text_targets.Find(g) >= 0) {
			dnd_targets.Add("text");
			if(dnd_text_target.IsEmpty())
				dnd_text_target = g;
		}
		else
		if(image_targets.Find(g) >= 0) {
			dnd_targets.Add("image");
			if(dnd_image_target.IsEmpty())
				dnd_image_target = g;
		}
		else
		if(files_targets.Find(g) >= 0) {
			dnd_targets.Add("files");
			if(dnd_files_target.IsEmpty())
				dnd_files_target = g;
		}
		else
			dnd_targets.Add(g);
	}
#endif
}
コード例 #15
0
ファイル: videowindow.c プロジェクト: 42p/linphone
static gboolean drag_drop(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, guint time, gpointer user_data){
#if GTK_CHECK_VERSION(2,21,0)
	GList *l=gdk_drag_context_list_targets(drag_context);
	GList *elem;

	if (l){
		ms_message("drag_drop");
		/* Choose the best target type */
		for(elem=l;elem!=NULL;elem=g_list_next(elem)){
			char *name=gdk_atom_name(GDK_POINTER_TO_ATOM(elem->data));
			ms_message("target: %s",name);
			g_free(name);
		}
	}else{
		ms_warning("drag_drop no targets");
		return FALSE;
	}
#endif
	return TRUE;
}
コード例 #16
0
ファイル: misc.c プロジェクト: svn2github/GtkAda
guint ada_gtk_dnd_context_targets_count (GdkDragContext* context)
{
  return g_list_length (gdk_drag_context_list_targets (context));
}
コード例 #17
0
static gboolean
xds_context_offers_target (GdkDragContext *context, GdkAtom target)
{
	GList *targets = gdk_drag_context_list_targets (context);
	return (g_list_find (targets, target) != NULL);
}