Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

add basic GtkClipboard support #176

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jonathanBieler
Copy link
Collaborator

It's the first time I do this, I hope I didn't messed up somewhere. I didn't added short names because there's already some clipboard methods in Base, but maybe it's not a problem.

clipboard_wait_for_text crashes when it's called from the terminal because Gtk checks for a main_loops that's not defined in that context, is there a way to check that from Julia to make it safer?

I tested it only on windows 7.

(UInt16,), selection))
GtkClipboardLeaf() = GtkClipboardLeaf(Gtk.GdkAtoms.CLIPBOARD)
clipboard_set_text(clip::GtkClipboard,text::String) = ccall((:gtk_clipboard_set_text,libgtk), Void,
(Ptr{GObject}, Ptr{Uint8},Cint), clip, text, length(text))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sizeof(text), not length

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will be exposed automatically as G_.text(clipboard, text) once the autogen script is rerun.

@jonathanBieler
Copy link
Collaborator Author

I couldn't find the value of the CLIPBOARD one anywhere so I generated the list by calling gdk_atom_name. Thinking about it it's probably not the best idea, these are maybe not constant.

Some are defined here though:

https://developer.gnome.org/gdk3/stable/gdk3-Selections.html#GDK-SELECTION-PRIMARY:CAPS

I can restrict them to this list. Otherwise I just saw there's gdk_atom_intern that allows to get the value at runtime, it's maybe safer.

fixed Uint16
@@ -134,6 +135,7 @@ export
GtkTextMarkLeaf,
GtkTextTagLeaf,
GtkTextViewLeaf,
GtkClipboardLeaf,
GtkToolButtonLeaf,
GtkToolItemLeaf,
GtkToolbarLeaf,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make the corresponding updates to short_leaf_exports.jl and short_exports.jl

@LilithHafner
Copy link
Contributor

Does this have any advantages over InteractiveUtils.clipboard?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants