[gtk-osx-users] modifyng Gtk-2 keybinding



Going back to my question, I have found a solution for my problem.
My goal was simply being able to use <COMMAND><C> instead of <CONTROL><C> and < COMMAND><V>instead of 
<CONTROL><V> but I had introduced spurious elements when I was formulating my question.
Reading the 'Menu accelerators's part in https://wiki.gnome.org/Projects/GTK%2B/OSX/Integration I was 
confused, I did not know how to search things properly (IMO there should be more emphasis about keybindings). 
I am still not sure what exactly 'automatic conversion' and 'new facility' refer to; shouldn't be explained 
more clearly, maybe?
This is what I have done; I have edited the gtkr file inside my bundle 
(My.app/Contents/Resources/etc/gtk-2.0) to include these lines and now everything works like it should.
Really useful and simple once you know how to do it.

# Mac-like text editing keybindings
binding "gtk-mac-text-entry"
{
   unbind "<ctrl>c"
   unbind "<ctrl>v"
   bind "<meta>c" { "copy-clipboard" () }
   bind "<meta>v" { "paste-clipboard" () }
  #   ...
}
class "GtkEntry" binding "gtk-mac-text-entry"

Regards
Bermarte

----------------------------------------
From: gtk-osx-users-list-request gnome org
Subject: Gtk-osx-users-list Digest, Vol 31, Issue 1
To: gtk-osx-users-list gnome org
Date: Tue, 1 Apr 2014 12:00:03 +0000

Send Gtk-osx-users-list mailing list submissions to
gtk-osx-users-list gnome org

To subscribe or unsubscribe via the World Wide Web, visit
https://mail.gnome.org/mailman/listinfo/gtk-osx-users-list
or, via email, send a message with subject or body 'help' to
gtk-osx-users-list-request gnome org

You can reach the person managing the list at
gtk-osx-users-list-owner gnome org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Gtk-osx-users-list digest..."


Today's Topics:

1. Re: gtk-osx question (Richard Procter)
2. Re: gtk-osx question (Chris Angelico)


----------------------------------------------------------------------

Message: 1
Date: Tue, 1 Apr 2014 06:57:18 +1300
From: Richard Procter <richard n procter gmail com>
To: b m <bermarte hotmail com>
Cc: gtk-osx-users-list gnome org
Subject: Re: [gtk-osx-users] gtk-osx question
Message-ID: <952BB5EB-BA72-4873-BEB2-361AD2E59627 gmail com>
Content-Type: text/plain; charset=windows-1252

Hi Bermarte,

You're best off sending questions like this to the gtk-osx group as more people will see it who may be able 
to help.

The code you reference was my refactoring of Olivier Sessink's code[0] for style, and I didn't compile it.

My wild guess is that the error is due to C and C++ handling enums differently. If I remember right C enum
values are little more than #defines and don't belong to a specific type (I seem to
remember they're all ints), whereas C++ puts stronger type constraints on enum values.

I suspect that for the |=, C++, but not C, implicitly converts the GdkModifierType operands to int but
then refuses to implicitly convert back to GdkModifier type when it comes to the assignment (as blindly 
converting
an invalid value would break the type).

You might try compiling the code as C first and check the error remains. If it doesn't, I'm on the right 
track.
You might also see if the error occurs in C++ for 'accel_mods = GDK_META_MASK' (this should work), and
for 'accel_mods = 5' (this will in C but, if I'm on the right track, not in C++).

best,
Richard.

[0] https://mail.gnome.org/archives/gtk-osx-users-list/2011-February/msg00004.html

On 31/03/2014, at 11:32 PM, b m wrote:

Good morning,

I saw a post about GTK http://sourceforge.net/p/gtk-osx/mailman/gtk-osx-users/?viewmonth=201102 and I am 
trying to use this part of code but g++ or clang++ gives me
two errors

error: invalid conversion from ?int? to ?GdkModifierType?
static void osx_accel_map_foreach_lcb(gpointer data,const gchar
*accel_path,guint accel_key, GdkModifierType accel_mods, gboolean
changed) {
if (accel_mods & GDK_CONTROL_MASK) {
accel_mods |= GDK_META_MASK;//error
accel_mods &= (accel_mods & GDK_MOD1_MASK) ? ~GDK_MOD1_MASK : ~GDK_CONTROL_MASK; //error

if (!gtk_accel_map_change_entry(accel_path,accel_key,accel_mods,FALSE)) {
g_print("could not change accelerator %s\n",accel_path);
}
}
}
I am new to programming with GTK for mac and C++ and I don't understand what would be the problem and how 
to use this code.
My problem is that
I would need to use <command>+paste and <command>+copy instead of <control>+paste<control>+copy in the 
program I am working on (it is ported from linux).
The first step for me was to use the definition of
void osx_accel_map_foreach_lcb

as I found in your post
I am using OS 10.8 64 bit and latest gtkmacintegration library.

On top of the file there is this part:

#include <gtk/gtk.h>
#include <gtkmacintegration/gtkosxapplication.h>
#include <gdk/gdkkeysyms.h>

I am not familiar with accel_mods neither.
It would be really useful for me to use this code correctly, any help would be greatly apprecieted.

Thank you.richard
Bermarte



------------------------------

Message: 2
Date: Tue, 1 Apr 2014 10:07:19 +1100
From: Chris Angelico <rosuav gmail com>
Cc: gtk-osx-users-list gnome org
Subject: Re: [gtk-osx-users] gtk-osx question
Message-ID:
<CAPTjJmokVkuLih490pGOGtNq3FRFV0bb=J=ZPUQkNVC_Ncqb-Q mail gmail com>
Content-Type: text/plain; charset=UTF-8

On Tue, Apr 1, 2014 at 4:57 AM, Richard Procter
<richard n procter gmail com> wrote:
I suspect that for the |=, C++, but not C, implicitly converts the GdkModifierType operands to int but
then refuses to implicitly convert back to GdkModifier type when it comes to the assignment (as blindly 
converting
an invalid value would break the type).

That sounds like flawed design. The GdkModifier enumerated values are
documented as bit flags [1], so the type for a collection of them
should surely be a straight integer (probably 'int' or 'unsigned').
But most likely an explicit cast will fix the problem.

ChrisA

[1] https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#GdkModifierType


------------------------------

Subject: Digest Footer

_______________________________________________
Gtk-osx-users-list mailing list
Gtk-osx-users-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-osx-users-list


------------------------------

End of Gtk-osx-users-list Digest, Vol 31, Issue 1
*************************************************
                                          


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