Re: [gtk-osx-users] About copy & paste



Thanks a lot, 

I was struggling with GtkBindingSet stuff (rather poorly documented and without usage examples) when I found that GTK+2 has an easier way to do that through .gtkrc-2.0:

binding "custom-text-entry"
{
    bind "<meta>v" { "paste-clipboard" () }
    bind "<meta>c" { "copy-clipboard" () }
    bind "<meta>x" { "cut-clipboard" () }
}

class "GtkEntry" binding "custom-text-entry"


On Thu, Jun 7, 2018 at 5:54 AM, John Ralls <jralls ceridwen us> wrote:


On Jun 6, 2018, at 2:13 AM, Gabriele Greco <gabrielegreco gmail com> wrote:


> There is a "clean" way to allow copy & paste on GtkEntry/GtkTextView on the OSX GTK version at least ALSO with CMD-C & CMD-V ?
Unless you’re using a very old version of Gtk--more than 5 or 6 years--for some strange reason
it should Just Work *with out-of-the-box GtkEntry/TextView*. If the code using the widgets has overridden the bindings to <control>C and <control>V then you’ll have to patch it. 
In C you can use GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR instead of GDK_CONTROL_MASK. GtkBuilder got a <primary> modifier in 3.20 that does the same thing, but Glade neither understands it nor uses it. Worse, Glade gets it completely wrong by having a radio choice for “primary” modifier but inserting <control> in response.

Sorry I forgot to mention that my apps are all based on GTK 2.24.x (with X the latest patch). Mostly because I found in the past (last time I checked was about two years ago) that Win32 and OSX versions of GTK 3 where a bit buggy and not suited for production environment. 

I also have a tiny C++ wrapper on GTK that will need a lot of work to be ported to GTK 3 ( https://oogtk.sourceforge.net ), but that's a secondary issue :)

My GUI use GtkBuilder, but, as you said, GtkBuilder supports GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR  since 3.20.

Of course grepping that macro in my GTK 2 sources do not give any result...

For Gtk+-2 you’ll need to patch the code with #ifdef __APPLE__ or some such. If you’re using gtk_mac_integration you can use whatever preprocessor macro you use to control that. The functions you need are https://developer.gnome.org/gtk2/stable/gtk2-Bindings.html and the signals are cut-clipboard, copy-clipboard, and paste-clipboard. The command keys are bound to GDK_META_MASK. If the entry is created with GtkBuilder then load the builder file first, then override the signal’s keybinding.

Regards,
John Ralls





--
Bye,
 Gabry



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]