Results 1 to 2 of 2

Thread: Clipboard: detect cut or copy

  1. #1
    Join Date
    Aug 2012
    Beans
    185

    Clipboard: detect cut or copy

    Hi,
    I'm using Gtk's Clipboard class (Gtk::Clipboard::get()), I can get the list of URI's in the clipboard (clipboard->wait_for_uris()) but can't figure out how to detect if the file URIs have been "cut" or "copied" (in a foreign app e.g. nautilus) - to know how to treat the URIs on "Paste" in my GUI app: should I delete the original files (cut), or leave them (copy).
    Last edited by bird1500; April 16th, 2013 at 03:46 AM.

  2. #2
    Join Date
    Aug 2012
    Beans
    185

    Re: Clipboard: detect cut or copy

    Well it looks like it's a mess, the Thunar source code uses a "special gnome copied files" atom and a slew of hooks, gee, I hoped for an easy solution.

    thunar-clipboard-manager.c:
    Code:
    struct _ThunarClipboardManager
    {
      GObject __parent__;
    
      GtkClipboard *clipboard;
      gboolean      can_paste;
      GdkAtom       x_special_gnome_copied_files;
    
      gboolean      files_cutted;
      GList        *files;
    };
    
    typedef struct
    {
      ThunarClipboardManager *manager;
      GFile                  *target_file;
      GtkWidget              *widget;
      GClosure               *new_files_closure;
    } ThunarClipboardPasteRequest;
    
    
    
    static const GtkTargetEntry clipboard_targets[] =
    {
      { "text/uri-list", 0, TARGET_TEXT_URI_LIST },
      { "x-special/gnome-copied-files", 0, TARGET_GNOME_COPIED_FILES },
      { "UTF8_STRING", 0, TARGET_UTF8_STRING }
    };
    And more info found here:
    Since there is no standard way to copy and paste files between applications on X11, various MIME types and conventions are currently in use. For instance, Nautilus expects files to be supplied with a x-special/gnome-copied-files MIME type with data beginning with the cut/copy action, a newline character, and the URL of the file.
    I guess it's because they never dared fixing X11, only working around it, but that's another story.
    Last edited by bird1500; April 16th, 2013 at 03:46 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •