Example #1
0
gboolean Ctrl::GtkDragDrop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
                           guint time, gpointer user_data)
{
    LLOG("GtkDragDrop");

    PasteClip clip = GtkDnd(widget, context, x, y, time, user_data, true);
    gtk_drag_finish(context, clip.IsAccepted(), clip.IsAccepted() && clip.GetAction() == DND_MOVE, time);
    g_object_unref(widget);
    g_object_unref(context);
    DnDLeave();
    return TRUE;
}
Example #2
0
static gboolean
display_drop_callback(GtkWidget *widget, GdkDragContext *context,
		      gint x, gint y, guint time)
{
  if (gtk_drag_get_source_widget(context) != NULL) {
    /* we only accept drops from the same instance of the application,
     * as the drag data is a pointer in our address space */
    return TRUE;
  }
  gtk_drag_finish (context, FALSE, FALSE, time);
  return FALSE;
}
Example #3
0
File: gui.c Project: lukspdev/lppb
static void  
drag_data_received_handl(GtkWidget          *widget,
					     GdkDragContext     *context,
					     gint                x,
					     gint                y,
					     GtkSelectionData   *sel_data,
					     guint               info,
					     guint               time,
                         gpointer            data)
{
    gint i;
    guint candid = GPOINTER_TO_UINT(data);

    g_print("%s to dest %d\n",
            (gchar *)gtk_selection_data_get_data(sel_data), candid);
    i=g_strcmp0((gchar *)gtk_selection_data_get_data(sel_data), "Candidate 1");
    switch(i){
        case -1:
            merged[candid] = 0;
            break;
        case 0:
            merged[candid] = 1;
            break;
        case 1:
            merged[candid] = 2;
            break;
        default:
            break;
    }

    GtkWidget *source_widget;
    GdkPixbuf *source_buf;
    GtkWidget *parent;
    GdkPixbuf *buf;
    GtkWidget *new_widget;

    parent = gtk_widget_get_parent(GTK_WIDGET(widget));
    source_widget = gtk_drag_get_source_widget(context);
    source_widget = gtk_button_get_image(GTK_BUTTON(source_widget));
    source_buf = gtk_image_get_pixbuf(GTK_IMAGE(source_widget));
    buf = gdk_pixbuf_scale_simple(source_buf, hole_sizes_w[candid],
                                  hole_sizes_h[candid], GDK_INTERP_BILINEAR);
    new_widget = gtk_image_new_from_pixbuf(buf);
    g_object_unref(buf);

    gtk_fixed_put(GTK_FIXED(parent), new_widget, hole_x[candid],
                                                 hole_y[candid]);

    gtk_widget_show_all(new_widget);

    gtk_drag_finish (context, TRUE, FALSE, time);
}
gboolean
gimp_container_tree_view_drag_drop (GtkWidget             *widget,
                                    GdkDragContext        *context,
                                    gint                   x,
                                    gint                   y,
                                    guint                  time,
                                    GimpContainerTreeView *tree_view)
{
  GimpDndType              src_type;
  GimpViewable            *src_viewable;
  GimpViewable            *dest_viewable;
  GdkAtom                  target;
  GtkTreeViewDropPosition  drop_pos;

  if (tree_view->priv->scroll_timeout_id)
    {
      g_source_remove (tree_view->priv->scroll_timeout_id);
      tree_view->priv->scroll_timeout_id = 0;
    }

  if (gimp_container_tree_view_drop_status (tree_view,
                                            context, x, y, time,
                                            NULL, &target, &src_type,
                                            &src_viewable,
                                            &dest_viewable, &drop_pos))
    {
      GimpContainerTreeViewClass *tree_view_class;

      tree_view_class = GIMP_CONTAINER_TREE_VIEW_GET_CLASS (tree_view);

      if (src_viewable)
        {
          gboolean success = TRUE;

          /* XXX: Make GimpContainerTreeViewClass::drop_viewable()
           * return success?
           */
          tree_view_class->drop_viewable (tree_view, src_viewable,
                                          dest_viewable, drop_pos);

          gtk_drag_finish (context, success, FALSE, time);
        }
      else
        {
          gtk_drag_get_data (widget, context, target, time);
        }

      return TRUE;
    }

  return FALSE;
}
Example #5
0
static void drop_box_drag_data_received(GtkWidget *drop_box,
			      GdkDragContext    *context,
			      gint              x,
			      gint              y,
			      GtkSelectionData  *selection_data,
			      guint             drag_info,
			      guint32           time)
{
	GList *uris = NULL;
	guchar *path = NULL;
	gboolean success = FALSE;

	if (!selection_data->data)
		goto err; 		/* Timeout? */

	uris = uri_list_to_glist(selection_data->data);

	if (g_list_length(uris) != 1)
	{
		delayed_error(_("Sorry, you need to drop exactly one file "
				"onto the drop area."));
		goto err;
	}
		
	path = get_local_path((EscapedPath *) uris->data);

	if (!path)
	{
		delayed_error(
			_("Sorry, I can't use '%s' because it's not a local "
			  "file."), (guchar *) uris->data);
		goto err;
	}

	if (!file_exists(path))
	{
		delayed_error(_("Can't access '%s':\n%s"), path,
				g_strerror(errno));
		goto err;
	}

	g_signal_emit_by_name(drop_box, "path_dropped", path);

	success = TRUE;
err:
	if (path)
		g_free(path);
	
	if (uris)
		g_list_free(uris);
	gtk_drag_finish(context, success, FALSE, time);	/* Failure */
}
Example #6
0
void
gnac_profiles_mgr_on_drag_data_received(GtkWidget        *widget,
                                        GdkDragContext   *context,
                                        gint              x,
                                        gint              y,
                                        GtkSelectionData *selection_data,
                                        guint             info,
                                        guint             time,
                                        gpointer          data)
{
  gchar **uris = g_uri_list_extract_uris((const gchar *)
      gtk_selection_data_get_data(selection_data));
  if (!uris) {
    gtk_drag_finish(context, FALSE, FALSE, time);
    return;
  }

  ThreadCopyData  *tcopy_data = g_malloc(sizeof(ThreadCopyData));
  tcopy_data->uris = uris;
  tcopy_data->info = info;

  GError *error = NULL;

#if GLIB_CHECK_VERSION(2, 31, 0)
  g_thread_try_new("drag-data-thread",
      (GThreadFunc) gnac_profiles_mgr_copy_and_load_files, tcopy_data, &error);
#else
  g_thread_create((GThreadFunc) gnac_profiles_mgr_copy_and_load_files,
      tcopy_data, TRUE, &error);
#endif
  if (error) {
    libgnac_debug("Failed to create thread: %s", error->message);
    gnac_profiles_mgr_display_status_message(NULL,
        _("Impossible to import file(s)"));
    g_clear_error(&error);
  }

  gtk_drag_finish(context, TRUE, FALSE, time);
}
// DND CYB
void DNDDataReceived( GtkWidget *widget, GdkDragContext *dc,
                                  gint x, gint y, GtkSelectionData *selection_data, guint info, guint t)
{
   void *filename;
   char *start,*end;
   int cont;

    if (info == TARGET_URI_LIST)
    {
     start = strstr((char*)selection_data->data,"file://");
     cont = 0;
     do
     {
       if (start)
       {
        end = strstr((char*)start+1,"file://");
        if (!end)
        {
                      end = start + strlen(start);
                      cont = 1;
                      continue;
        }
        filename = ADM_alloc(end-start); 
        if (filename)
        {
              memset(filename,0,end-start);
              memcpy(filename,start+7,end-start-7-2);
              if (avifileinfo) 
              {
                    // Append video when there's already something
                    fileReadWrite(A_appendAvi, 0, (char*)filename);
               }
               else
               {
                    fileReadWrite(A_openAvi, 0, (char*)filename);
               }
         } 
         ADM_dealloc(filename);
         start = end;
       }
       else
       {
           cont=1;
       } 
     } //do
     while (!cont);  
    }
    gtk_drag_finish(dc,TRUE,FALSE,t);
}
Example #8
0
File: gnac-ui.c Project: GNOME/gnac
void
gnac_ui_on_drag_data_received_cb(GtkWidget        *widget,
                                 GdkDragContext   *context,
                                 gint              x,
                                 gint              y,
                                 GtkSelectionData *selection_data,
                                 guint             info,
                                 guint             time,
                                 gpointer          data)
{
  /* Disable any filtering for DnD. */
  gnac_ui_reset_file_filter();

  gchar **uris = gtk_selection_data_get_uris(selection_data);

  if (!uris) {
    gtk_drag_finish(context, FALSE, FALSE, time);
    return;
  }

  guint index = 0;
  GSList *list_uris = NULL;

  gchar *uri = uris[index];
  while (uri) {
    GFile *file = g_file_new_for_uri(uri);
    list_uris = g_slist_prepend(list_uris, file);
    index++;
    uri = uris[index];
  }

  gnac_add_files(list_uris);

  gtk_drag_finish(context, TRUE, FALSE, time);
  g_strfreev(uris);
}
Example #9
0
bool DragAndDropHandler::drop(GdkDragContext* context, const IntPoint& position, unsigned time)
{
    DroppingContext* droppingContext = m_droppingContexts.get(context);
    if (!droppingContext)
        return false;

    droppingContext->dropHappened = true;

    DragData dragData(droppingContext->selectionData.ptr(), position, convertWidgetPointToScreenPoint(m_page.viewWidget(), position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
    SandboxExtension::Handle handle;
    SandboxExtension::HandleArray sandboxExtensionForUpload;
    m_page.performDragOperation(dragData, String(), handle, sandboxExtensionForUpload);
    gtk_drag_finish(context, TRUE, FALSE, time);
    return true;
}
Example #10
0
static void
ide_editor_frame__drag_data_received (IdeEditorFrame    *self,
                                      GdkDragContext    *context,
                                      gint               x,
                                      gint               y,
                                      GtkSelectionData  *selection_data,
                                      guint              info,
                                      guint              timestamp,
                                      GtkWidget         *widget)
{
  gchar **uri_list;

  g_return_if_fail (IDE_IS_SOURCE_VIEW (widget));

  switch (info)
    {
    case TARGET_URI_LIST:
      uri_list = ide_dnd_get_uri_list (selection_data);

      if (uri_list)
        {
          GVariantBuilder *builder;
          GVariant *variant;
          guint i;

          builder = g_variant_builder_new (G_VARIANT_TYPE_STRING_ARRAY);
          for (i = 0; uri_list [i]; i++)
            g_variant_builder_add (builder, "s", uri_list [i]);
          variant = g_variant_builder_end (builder);
          g_variant_builder_unref (builder);
          g_strfreev (uri_list);

          /*
           * request that we get focus first so the workbench will deliver the
           * document to us in the case it is not already open
           */
          gtk_widget_grab_focus (GTK_WIDGET (self));

          ide_widget_action (GTK_WIDGET (self), "workbench", "open-uri-list", variant);
        }

      gtk_drag_finish (context, TRUE, FALSE, timestamp);
      break;

    default:
      break;
    }
}
Example #11
0
static void
cairo_main_icon_drag_data_received (GtkWidget        *widget,
                                    GdkDragContext   *context,
                                    gint              x,
                                    gint              y,
                                    GtkSelectionData *sdata,
                                    guint             info,
                                    guint             evt_time)
{
  CairoMainIconPrivate * priv = GET_PRIVATE (widget);
  gchar           *sdata_data;
  GStrv           i;
  GStrv           tokens = NULL;
  sdata_data = (gchar*)gtk_selection_data_get_data (sdata);


  if (strstr (sdata_data, "cairo_menu_item_dir:///"))
  {
    /*TODO move into a separate function */
    tokens = g_strsplit  (sdata_data, "\n",-1);
    for (i=tokens; *i;i++)
    {
      GStrv           sub_tokens = NULL;
      gchar * filename = g_filename_from_uri ((gchar*) *i,NULL,NULL);
      if (!filename && ((gchar *)*i))
      {
        filename = g_strdup ((gchar*)*i);
      }
      if (filename)
      {
        g_strstrip(filename);
        sub_tokens = g_strsplit (filename,"@@@",-1);
        if (sub_tokens && g_strv_length (sub_tokens)==4)
        {
          cairo_menu_applet_add_icon (AWN_CAIRO_MENU_APPLET(priv->applet),sub_tokens[1],sub_tokens[2],sub_tokens[3]);
          gtk_drag_finish (context, TRUE, FALSE, evt_time);
          g_strfreev (sub_tokens);
          g_strfreev (tokens);
          return;
        }
        g_strfreev (sub_tokens);
      }
    }
    g_strfreev (tokens);
  }
  awn_themed_icon_drag_data_received (widget,context,x,y,sdata,info,evt_time);
  //gtk_drag_finish (context,TRUE,FALSE,evt_time);
}
Example #12
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;
}
Example #13
0
static void
drag_drop_cb(GtkWidget *w, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer user_data)
{
  gchar **filenames;
  int num;

  switch (info) {
  case DROP_TYPE_FILE:
    filenames = gtk_selection_data_get_uris(data);
    num = g_strv_length(filenames);
    data_dropped(filenames, num, FILE_TYPE_MERGE);
    g_strfreev(filenames);
    gtk_drag_finish(context, TRUE, FALSE, time);
    break;
  }
}
Example #14
0
static void
on_drag_data_received (GtkWidget *widget,
					   GdkDragContext *context,
					   gint x, gint y,
					   GtkSelectionData *selection_data,
					   guint target_type, guint time,
					   gpointer data)
{
	gchar *text = (gchar*) gtk_selection_data_get_text (selection_data);

	if (rookie_misc_is_valid_url (text))
		rookie_misc_add_download (text);

	gtk_drag_finish (context, TRUE, FALSE, time);
	g_free (text);
}
Example #15
0
static void
hand_display_drag_data_received (GtkWidget *hand, GdkDragContext *dc,
        gint x, gint y, GtkSelectionData *selection_data,
        guint targettype, guint t, gpointer data)
{
	HandDisplay *handdisp = HAND_DISPLAY (hand);
	int *card = (int *) gtk_selection_data_get_data (selection_data);
	int on_card = which_card(handdisp, x, y);
	/*
	if (*card == on_card) {
		gtk_drag_finish (dc, FALSE, FALSE, t);
		return;
	}
	*/
	g_signal_emit_by_name (handdisp, "card-drag-drop", *card, on_card);
	gtk_drag_finish (dc, TRUE, FALSE, t);
}
static void
drag_data_received (GtkWidget *widget,
    GdkDragContext *context,
    gint x,
    gint y,
    GtkSelectionData *selection,
    guint info,
    guint time_)
{
  EmpathyPersonaView *self = EMPATHY_PERSONA_VIEW (widget);
  gboolean success = TRUE;

  if (info == DND_DRAG_TYPE_INDIVIDUAL_ID || info == DND_DRAG_TYPE_STRING)
    success = individual_drag_received (self, context, selection);

  gtk_drag_finish (context, success, FALSE, GDK_CURRENT_TIME);
}
Example #17
0
void on_drag_data_received(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer user_data)
{
	FskGtkWindow gtkWin = user_data;
	gboolean dnd_success = FALSE;
	FskDragDropFile dropFileList = NULL;
	FskDragDropFile droppedFile = NULL;
	char* path = NULL;
	if (gdk_drag_context_get_suggested_action(context) == GDK_ACTION_COPY) {
		char* string = (char*)gtk_selection_data_get_data(data);
		char* end;
		FskFileInfo itemInfo;
		for (end = FskStrStr(string, "\r\n"); end; end = FskStrStr(string, "\r\n")) {
			BAIL_IF_ERR(FskMemPtrNewClear(sizeof(FskDragDropFileRecord), (FskMemPtr*)&droppedFile));
			FskListAppend((FskList *)&dropFileList, droppedFile);
			*end = 0;
			BAIL_IF_ERR(KprURLToPath(string, &path));
			BAIL_IF_ERR(FskFileGetFileInfo(path, &itemInfo));
			if (itemInfo.filetype == kFskDirectoryItemIsDirectory) {
				int length = FskStrLen(path);
				BAIL_IF_ERR(FskMemPtrNew(length + 2, &droppedFile->fullPathName));
				FskMemCopy(droppedFile->fullPathName, path, length);
				droppedFile->fullPathName[length] = '/';
				droppedFile->fullPathName[length + 1] = 0;
				FskMemPtrDispose(path);
			}
			else {
				droppedFile->fullPathName = path;
			}
			path = NULL;
			string = end + 2;
			*end = '\r';
		}
		(*gDropTargetProc)(kFskDragDropTargetEnterWindow, x, y, dropFileList, gtkWin->owner);
		(*gDropTargetProc)(kFskDragDropTargetDropInWindow, x, y, dropFileList, gtkWin->owner);
		dnd_success = TRUE;
	}
bail:
	gtk_drag_finish(context, dnd_success, TRUE, time);
	FskMemPtrDispose(path);
	while (NULL != dropFileList) {
		droppedFile = dropFileList;
		FskListRemove((FskList *)&dropFileList, droppedFile);
		FskMemPtrDispose(droppedFile->fullPathName);
		FskMemPtrDispose(droppedFile);
	}
}
static void
rb_tree_dnd_drag_data_received_cb (GtkWidget        *widget,
                                  GdkDragContext   *context,
                                  gint              x,
                                  gint              y,
                                  GtkSelectionData *selection_data,
                                  guint             info,
                                  guint             time)
{
	GtkTreeView *tree_view;
	GtkTreeModel *model;
	GtkTreePath *dest_row;
	GtkTreeViewDropPosition pos;
	gboolean filtered = TRUE;
	gboolean accepted = FALSE;

	tree_view = GTK_TREE_VIEW (widget);
	model = gtk_tree_view_get_model (tree_view);

	gtk_tree_view_get_dest_row_at_pos (tree_view, x, y, &dest_row, &pos);

	if (dest_row)
		if (!filter_drop_position (widget, context, dest_row, &pos))
			filtered = FALSE;

	if (filtered && selection_data->length >= 0)
	{
		if (rb_tree_drag_dest_drag_data_received (RB_TREE_DRAG_DEST (model),
                					  dest_row,
							  pos,
                					  selection_data))
        		accepted = TRUE;
	}

	gtk_drag_finish (context,
        		 accepted,
			 (context->action == GDK_ACTION_MOVE),
			 time);

	if (dest_row)
  		gtk_tree_path_free (dest_row);

	g_signal_stop_emission_by_name (widget, "drag_data_received");

}
Example #19
0
File: vte.c Project: phaero/svi
static void vte_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context,
								   gint UP(x), gint UP(y), GtkSelectionData *data, guint info, guint ltime)
{
	if (info == TARGET_TEXT_PLAIN)
	{
		if (data->format == 8 && data->length > 0)
			vf->vte_terminal_feed_child(VTE_TERMINAL(widget),
				(const gchar*) data->data, data->length);
	}
	else
	{
		gchar *text = (gchar*) gtk_selection_data_get_text(data);
		if (NZV(text))
			vf->vte_terminal_feed_child(VTE_TERMINAL(widget), text, strlen(text));
		g_free(text);
	}
	gtk_drag_finish(drag_context, TRUE, FALSE, ltime);
}
static gboolean
carrick_list_drag_drop (GtkWidget      *widget,
                        GdkDragContext *context,
                        gint            x,
                        gint            y,
                        guint           time,
                        CarrickList    *list)
{
  CarrickListPrivate *priv = list->priv;

  gtk_container_child_get (GTK_CONTAINER (priv->box),
                           widget,
                           "position", &priv->drop_position,
                           NULL);

  gtk_drag_finish (context, TRUE, TRUE, time);
  return TRUE;
}
Example #21
0
static void drag_data_received(GtkWidget *widget, GdkDragContext *context,
				gint x, gint y, GtkSelectionData *data,
				guint info, guint time, gpointer user_data)
{
	GtkTreeModel *model = user_data;
	GtkTreePath *path;
	GtkTreeIter iter;
	DBusGProxy *source, *proxy = NULL;
	gboolean success = FALSE;

	if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
				x, y, &path, NULL, NULL, NULL) == FALSE)
		return;

	if (gtk_tree_model_get_iter(model, &iter, path) == FALSE)
		goto done;

	gtk_tree_model_get(model, &iter, CONNMAN_COLUMN_PROXY, &proxy, -1);

	if (data == NULL || data->length == 0)
		goto done;

	if (info != CONNMAN_SERVICE_MOVE)
		goto done;

	if (gtk_tree_model_get_iter_from_string(model, &iter,
						(gchar *) data->data) == FALSE)
		goto done;

	g_print("%s -> %s\n", (gchar *) data->data, gtk_tree_path_to_string(path));

	gtk_tree_model_get(model, &iter, CONNMAN_COLUMN_PROXY, &source, -1);

	method_call(source, "MoveBefore", dbus_g_proxy_get_path(proxy));

	g_object_unref(proxy);

	success = TRUE;

done:
	gtk_tree_path_free(path);

	gtk_drag_finish(context, success, FALSE, time);
}
Example #22
0
static void vte_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context,
								   gint x, gint y, GtkSelectionData *data, guint info, guint ltime)
{
	if (info == TARGET_TEXT_PLAIN)
	{
		if (gtk_selection_data_get_format(data) == 8 && gtk_selection_data_get_length(data) > 0)
			vf->vte_terminal_feed_child(VTE_TERMINAL(widget),
				(const gchar*) gtk_selection_data_get_data(data),
				gtk_selection_data_get_length(data));
	}
	else
	{
		gchar *text = (gchar*) gtk_selection_data_get_text(data);
		if (!EMPTY(text))
			vf->vte_terminal_feed_child(VTE_TERMINAL(widget), text, strlen(text));
		g_free(text);
	}
	gtk_drag_finish(drag_context, TRUE, FALSE, ltime);
}
Example #23
0
static void
drag_data_received_cb (GtkWidget        *widget,
		       GdkDragContext   *context,
		       gint              x,
		       gint              y,
		       GtkSelectionData *selection_data,
		       guint             info,
		       guint             time,
		       Launcher         *launcher)
{
	GError  *error = NULL;
	char   **uris;
	int      i;
	GList   *file_list;

	launcher_do_zoom_animation (widget);
	
	file_list = NULL;
	uris = g_uri_list_extract_uris ((const char *) gtk_selection_data_get_data (selection_data));
	for (i = 0; uris[i]; i++)
		file_list = g_list_prepend (file_list, uris[i]);
	file_list = g_list_reverse (file_list);

	panel_launch_key_file (launcher->key_file, file_list,
			       launcher_get_screen (launcher), &error);

	g_list_free (file_list);
	g_strfreev (uris);

	if (error) {
		GtkWidget *error_dialog;
		error_dialog = panel_error_dialog (NULL,
						   launcher_get_screen (launcher),
						   "cannot_use_dropped_item",
						   TRUE,
						   _("Could not use dropped item"),
						   error->message);
		launcher_register_error_dialog (launcher, error_dialog);
		g_clear_error (&error);
	}

	gtk_drag_finish (context, TRUE, FALSE, time);
}
Example #24
0
static void
handle_drop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
            GtkSelectionData *data, guint info, guint time)
{
   gboolean success = FALSE;

   if (gtk_selection_data_get_length (data) >= 0 &&
       gtk_selection_data_get_format (data) == 8)
     {
       const gchar *text = (const gchar *) gtk_selection_data_get_data (data);

       if (g_utf8_validate (text, -1, NULL))
         {
           gtk_entry_set_text (GTK_ENTRY (widget), text);
           success = TRUE;
         }
     }

   gtk_drag_finish(context, success, FALSE, time);
}
static void _on_drag_data_received (G_GNUC_UNUSED GtkWidget *pWidget, G_GNUC_UNUSED GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, G_GNUC_UNUSED guint info, guint time, CairoDesklet *pDesklet)
{
	//\_________________ On recupere l'URI.
	gchar *cReceivedData = (gchar *) gtk_selection_data_get_data (selection_data);  // the data are actually 'const guchar*', but since we only allowed text and urls, it will be a string
	g_return_if_fail (cReceivedData != NULL);
	int length = strlen (cReceivedData);
	if (cReceivedData[length-1] == '\n')
		cReceivedData[--length] = '\0';  // on vire le retour chariot final.
	if (cReceivedData[length-1] == '\r')
		cReceivedData[--length] = '\0';
	
	// g_print ("%s (%dx%d, %s)\n", __func__, x, y, cReceivedData);
	
	pDesklet->container.iMouseX = x;
	pDesklet->container.iMouseY = y;
	Icon *pClickedIcon = gldi_desklet_find_clicked_icon (pDesklet);
	gldi_container_notify_drop_data (CAIRO_CONTAINER (pDesklet), cReceivedData, pClickedIcon, 0);
	
	gtk_drag_finish (dc, TRUE, FALSE, time);
}
Example #26
0
int
clip_GTK_DRAGFINISH(ClipMachine * cm)
{
        C_object *ccontext = _fetch_co_arg(cm);
	gboolean   success = _clip_parl(cm, 2);
        gboolean       del = _clip_parl(cm, 3);
        guint32       time = _clip_parni(cm, 4);

	if (!ccontext || ccontext->type != GDK_TYPE_DRAG_CONTEXT)
        	goto err;
	CHECKARG(2, LOGICAL_t);
	CHECKARG(3, LOGICAL_t);
	CHECKARG(4, NUMERIC_t);

        gtk_drag_finish((GdkDragContext*)ccontext->object, success, del, time);

	return 0;
err:
	return 1;
}
Example #27
0
static void
drag_data_received_cb (GtkWidget          *widget,
                       GdkDragContext     *context,
                       gint                x,
                       gint                y,
                       GtkSelectionData   *selection_data,
                       guint               info,
                       guint               time_,
                       Drawer             *drawer)
{
    PanelWidget *panel_widget;

    if (!panel_check_dnd_target_data (widget, context, &info, NULL)) {
        gtk_drag_finish (context, FALSE, FALSE, time_);
        return;
    }

    panel_widget = panel_toplevel_get_panel_widget (drawer->toplevel);

    panel_receive_dnd_data (panel_widget, info, -1, selection_data, context, time_);
}
Example #28
0
static void
gpview_document_view_drag_data_received_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time, GPViewSymbolView *view)
{
    gboolean success = FALSE;

    GPViewDocumentViewPrivate *privat = GPVIEW_DOCUMENT_VIEW_GET_PRIVATE(view);

    if (privat != NULL)
    {
        if (info != 1)
        {
            g_debug("gpview_document_view_drag_data_received_cb: Wrong format");
        }
        else if (data == NULL)
        {
            g_debug("gpview_document_view_drag_data_received_cb: NULL data pointer");
        }
        else if (gtk_selection_data_get_length(data) < 0)
        {
            g_debug("gpview_document_view_drag_data_received_cb: Invalid length");
        }
        else
        {
            GStrv uris = gtk_selection_data_get_uris(data);

            gpview_document_ctrl_add_uris(privat->controller, uris);
            g_strfreev(uris);

            success = TRUE;
        }

    }

    gtk_drag_finish(context, success, FALSE, time);

    g_signal_stop_emission_by_name(
        widget,
        "drag-data-received"
        );
}
Example #29
0
static void
drag_data_recieved_cb (GtkWidget	*widget,
		       GdkDragContext   *context,
		       gint              x,
		       gint              y,
		       GtkSelectionData *selection_data,
		       guint             info,
		       guint             time)
{
	PanelWidget *panel_widget;
	int          pos;

	g_return_if_fail (PANEL_IS_TOPLEVEL (widget));

	/* we use this only to really find out the info, we already
	   know this is an ok drop site and the info that got passed
	   to us is bogus (it's always 0 in fact) */
	if (!panel_check_dnd_target_data (widget, context, &info, NULL)) {
		gtk_drag_finish (context, FALSE, FALSE, time);
		return;
	}

	panel_widget = panel_toplevel_get_panel_widget (PANEL_TOPLEVEL (widget));

	pos = panel_widget_get_cursorloc (panel_widget);
	
	/* 
	 * -1 passed to mate_panel_applet_register will turn on 
	 * the insert_at_pos flag for panel_widget_add_full,
	 * which will not place it after the first applet.
	 */
	if(pos < 0)
		pos = -1;
	else if(pos > panel_widget->size)
		pos = panel_widget->size;

	panel_receive_dnd_data (
		panel_widget, info, pos, selection_data, context, time);
}
Example #30
0
static void
on_drag_data_received (GtkWidget        *widget,
                       GdkDragContext   *context,
                       gint              x,
                       gint              y,
                       GtkSelectionData *data,
                       guint             info,
                       guint             time,
                       gpointer          user_data)
{
  gint length = gtk_selection_data_get_length (data) ;

  if (length >= 0)
  {
    guchar *text = gtk_selection_data_get_text(data);

    if (text)
    {
      BijiManager *manager;
      BijiNoteObj *ret;
      BjbMainView *self = BJB_MAIN_VIEW (user_data);
      BjbSettings *settings;

      /* FIXME Text is guchar utf 8, conversion to perform */
      manager =  bjb_window_base_get_manager (self->priv->window);
      settings = bjb_app_get_settings (g_application_get_default ());
      ret = biji_manager_note_new (manager,
                                     (gchar*) text,
                                     bjb_settings_get_default_location (settings));
      switch_to_note_view (self, ret); // maybe AFTER drag finish?

      g_free (text);
    }
  }

  /* Return false to ensure text is not removed from source
   * We just want to create a note. */
  gtk_drag_finish (context, FALSE, FALSE, time);
}