Gtk2::Clipboard(3)

πŸ“¦
version 1.24993 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

okay so bestie, meet Gtk2::Clipboard β€” it's the wrapper for GtkClipboard. that's it, that's the whole vibe. it's how you talk to the clipboard. the cut-and-paste one. the one that holds your stuff. iconic behavior fr fr.

this page lives in the User Contributed Perl Documentation section of the manual, and yes the page itself is Gtk2::Clipboard(3), we're all very aware. 🫢


🌈 HIERARCHY 🌈

the family tree, and it's giving inheritance:

Glib::Object
+----Gtk2::Clipboard

so it's a Glib::Object at heart, and Gtk2::Clipboard is the glow-up. ✨


πŸŽ€ METHODS πŸŽ€

okay this is the main character section, buckle up. πŸ’…

πŸ“ $clipboard->set_can_store (...)

  • ... β€” a (list) of Gtk2::TargetEntry's. give it as many as your heart desires.
Since: gtk+ 2.6

πŸ“ $clipboard->clear

just. wipes it. clears the clipboard. no args, no drama, no notes. 🧹

πŸ“ display = $clipboard->get_display

hands you the display back. that's the whole thing.

Since: gtk+ 2.2

πŸ“ clipboard = Gtk2::Clipboard->get_for_display ($display, $selection)

the class-method girlies, we love to see it:

  • $display β€” a Gtk2::Gdk::Display
  • $selection β€” a Gtk2::Gdk::Atom
Since: gtk+ 2.2

πŸ“ clipboard = Gtk2::Clipboard->get ($selection)

  • $selection β€” a Gtk2::Gdk::Atom

another class method! grab the clipboard for that selection. slay.

πŸ“ $clipboard->set_image ($pixbuf)

  • $pixbuf β€” a Gtk2::Gdk::Pixbuf

drop an image on the clipboard. pictures?? on MY clipboard?? it's more likely than you think. πŸ“Έ

Since: gtk+ 2.6

πŸ“ object = $clipboard->get_owner

who owns this clipboard rn?? this tells you. mystery solved. πŸ”

πŸ“ $clipboard->request_contents ($target, $callback, $user_data=undef)

  • $target β€” a Gtk2::Gdk::Atom
  • $callback β€” (scalar)
  • $user_data β€” (scalar), defaults to undef

πŸ“ $clipboard->request_image ($callback, $user_data=undef)

  • $callback β€” (scalar)
  • $user_data β€” (scalar), defaults to undef
Since: gtk+ 2.6

πŸ“ $clipboard->request_rich_text ($buffer, $callback, $user_data=undef)

  • $buffer β€” a Gtk2::TextBuffer
  • $callback β€” (scalar)
  • $user_data β€” (scalar), defaults to undef

rich text bestie, we're fancy now. πŸ’œ

Since: gtk+ 2.10

πŸ“ $clipboard->request_targets ($callback, $user_data=undef)

  • $callback β€” (scalar)
  • $user_data β€” (scalar), defaults to undef
Since: gtk+ 2.4

πŸ“ $clipboard->request_text ($callback, $user_data=undef)

  • $callback β€” (scalar)
  • $user_data β€” (scalar), defaults to undef

πŸ“ $clipboard->request_uris ($func, $data=undef)

  • $func β€” (scalar)
  • $data β€” (scalar), defaults to undef

note the arg names on this one β€” $func and $data, not $callback and $user_data. she's different like that. πŸ™ˆ

Since: gtk+ 2.14

πŸ“ $clipboard->store

store it. that's the method. that's what it does.

Since: gtk+ 2.6

πŸ“ $clipboard->set_text ($text)

  • $text β€” (string)

plain old text onto the clipboard. the classic. the original recipe. πŸ“

πŸ“ selectiondata or undef = $clipboard->wait_for_contents ($target)

  • $target β€” a Gtk2::Gdk::Atom

returns selectiondata, or undef if there's nothing. so check before you use it, bestie!! 😭

πŸ“ pixbuf or undef = $clipboard->wait_for_image

pixbuf, or undef. again with the undef jumpscare.

Since: gtk+ 2.6

πŸ“ list = $clipboard->wait_for_rich_text ($buffer)

  • $buffer β€” a Gtk2::TextBuffer
Since: gtk+ 2.10

πŸ“ list = $clipboard->wait_for_targets

Returns a list of GdkAtom's. plural. multiple atoms. a whole group chat of atoms. πŸ‘‘

Since: gtk+ 2.4

πŸ“ string = $clipboard->wait_for_text

just gives you the string. no undef disclaimer here, so live your truth.

πŸ“ scalar = $clipboard->wait_for_uris

Since: gtk+ 2.14

πŸ“ boolean = $clipboard->wait_is_image_available

true or false, is there an image waiting for you. vibe check, but for images. πŸ–ΌοΈ

Since: gtk+ 2.6

πŸ“ boolean = $clipboard->wait_is_rich_text_available ($buffer)

  • $buffer β€” a Gtk2::TextBuffer
Since: gtk+ 2.10

πŸ“ boolean = $clipboard->wait_is_target_available ($target)

  • $target β€” a Gtk2::Gdk::Atom
Since: gtk+ 2.6

πŸ“ boolean = $clipboard->wait_is_text_available

is there text?? boolean says yes or no. the suspense, honestly.

πŸ“ boolean = $clipboard->wait_is_uris_available

Since: gtk+ 2.14

πŸ“ boolean = $clipboard->set_with_data ($get_func, $clear_func, $user_data, ...)

the full lineup, no skipping:

  • $get_func β€” (scalar)
  • $clear_func β€” (scalar)
  • $user_data β€” (scalar)
  • ... β€” a (list) of Gtk2::TargetEntry's

πŸ“ boolean = $clipboard->set_with_owner ($get_func, $clear_func, $owner, ...)

same energy, but with an owner this time:

  • $get_func β€” (scalar)
  • $clear_func β€” (scalar)
  • $owner β€” a Glib::Object
  • ... β€” a (list) of Gtk2::TargetEntry's

✨ SIGNALS ✨

  • owner-change β€” signature is (Gtk2::Clipboard, Gtk2::Gdk::Event)

so when the clipboard owner changes, you get a whole event about it. main character notification energy. πŸ””


πŸ‘€ SEE ALSO πŸ‘€

go read these too, they're part of the lore:

  • Gtk2
  • Glib::Object

Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL. See Gtk2 for a full notice.


and that's the whole page, bestie!! this was documented by the perl crew, perl v5.42.0, dated 2025-07-25 β€” go forth and paste responsibly πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from