This is the answer to my question, which was out of the mailing list. I wanted to share it with everybody.
-------- Forwarded Message -------- From: Arvind Kumar <arvind.ku...@gmail.com> To: Göktuğ Kayaalp <goktug.kaya...@gmail.com> Subject: Re: Gtk key events Date: Tue, 22 Jan 2013 08:15:34 -0600 No problem in you sharing it. The reason it worked is this: if you return TRUE, it means you completely handled the signal and it will not be propagated further. If you return FALSE, it means that you have handled it but not completely and it will be propagated further. -a On Tue, Jan 22, 2013 at 7:50 AM, Göktuğ Kayaalp <goktug.kaya...@gmail.com>wrote: > Hi Arvind, > > And thanks a lot! Sorry for late reply, I wasn't home. But in the first > reply > of yours to me, you've told me to return True from the handler funtion. > Today > I tried it again, and it worked magically! (or I accidentally fixed some > error :). I now can block all of the Gtk's shortcuts. > > I wonder if you'd let me post this converstaion to the mailing list, so > other > guys there can benefit? > > Thanks a lot, > Göktuğ. > > On Tue, 2013-01-22 at 07:13 -0600, Arvind Kumar wrote: > > To achieve what you want, you can have flags that you set in the > keypressed > > handler when the ctrl key is pressed (or any other key of your choice is > > pressed) and unset the flag in the keyreleased handler. So when the next > > keystroke comes in, if you want to create your own combination, you can > > simply check the value of the flag and act accordingly. > > > > -a > > > > On Tue, Jan 22, 2013 at 6:42 AM, Arvind Kumar <arvind.ku...@gmail.com > >wrote: > > > > > I wrote similar functions for a text editor and this works. What you > need > > > to do is to have if conditions that catch the keystrokes by hardware > > > keycode. And make you have both keypress and keyrelease handlers. > > > > > > I don't use python but write in C, and my handlers check the > > > event->hardware_keycode which is just a short int. > > > > > > If you compare strings, you won't catch the special characters. > > > > > > -a > > > > > > > > > On Mon, Jan 21, 2013 at 11:01 PM, Göktuğ Kayaalp < > goktug.kaya...@gmail.com > > > > wrote: > > > > > >> Hi Arvind, > > >> > > >> Thanks for help, but it did not solve my problem. I actually want to > > >> disable > > >> any keyboard shortcuts that Gtk provides me by default. The reason for > > >> that > > >> is, I'm implementing an Emacs-like editor in Python 3 and GTK and I > want > > >> all > > >> the key combinations to be configurable by user. > > >> > > >> But Gtk provides some default combinations, i.e. Ctrl-a for select all > > >> text, > > >> Ctrl-x for cut. When I map e.g. Ctrl-a to function x, this keystroke > > >> triggers > > >> both the Gtk's defined event (select all in this case) and my > callback. > > >> > > >> In my implementation, "key-press-event" is handled by a > > >> __key_event_handler() > > >> function, which constructs a string and looks it up in a hash if it > is a > > >> modified key, or otherwise, just lets it go. > > >> > > >> I would be grateful if you can point me to some documentation, as I > can > > >> only > > >> get function signatures from pydoc (which doesn't really tell > anything in > > >> Python) and can't find python-gobject related comprehensive > documentation > > >> anywhere. > > >> > > >> Have a nice day, > > >> Göktuğ. > > >> > > >> On Mon, 2013-01-21 at 22:28 -0600, Arvind Kumar wrote: > > >> > I am not on the gtk list but saw your question while browsing the > web. > > >> > So if you respond, please respond directly to me and not to the > > >> > mailing list. > > >> > > > >> > You can have your own custom callbacks for key_press_event and > > >> > key_release_event of the GtkTextView object and return TRUE for the > > >> > callbacks. (return TRUE means you have completely handled it.) > > >> > Whatever handling you want to perform should go in the callback > > >> > methods. > > >> > > > >> > If you want the system to takeover control after your callback > > >> > executes, you just have to return FALSE. The callbacks for these two > > >> > events will have GdkEventKey* as the second parameter and you can > > >> > identify the key. > > >> > > > >> > I hope this helps. > > >> > > > >> > -a _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list