[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gnome
Subject:    RES: How to bind F1 key as custom shortcut?
From:       Ubirajara Marques da Cruz <biracruz () cemig ! com ! br>
Date:       2013-12-23 12:17:18
Message-ID: 92E9CC19835EFD4DA26E46033425458271DA01A9 () SA-CORP-EMCL5 ! cemig ! ad ! corp
[Download RAW message or body]

Sean,

If you have a resource file (.rc) into your program, you can try set highest priority \
to this key binding. Links below above explain better priority of key bindings.  
https://developer.gnome.org/gtk2/2.24/gtk2-Resource-Files.html 
or/and
https://developer.gnome.org/gtk2/2.24/gtk2-Bindings.html

Follow a little example that can help you to develop.

Into your main.c  file 

File main.c
	# Includes .....
	Void functions.....;
	.....
	Int exit(void)
		{gtk_main_quit()};
	.....
	Int main (){
	/* Key binding work fine when you define name to object. You must define name for \
                which widget
	* that you built in your interface with function \
                gtk_widget_set_name(widget,"widget_name") after
	* create them
	* After named all widget call resource file with key binding setting
	*/

	GtkWidget *window;
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_name(widget,"wdteste");  //You must name all widget to key binding \
work fine

	.......//Other widgets into object structure

	gtk_rc_parse("resource.rc");

	/* You must connect some signal that will activate function you wanna execute.
	* into this example F1 key will close this app.*/

	g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(exit),NULL);

	........ //other functions;
}
//end of file


Example of content resource.rc file

binding "test"
{
  	#bind "<ctrl>j" {    # caracter is comment into rc file
	#bind "<alt>q" {

  bind "F1" {
    "destroy" () 
  }
}
	# bindings are associate to object (named) and signal then you must choice an object \
into   # object structure. 

# widget "*.object named above" binding : priority "custom binding name"
widget "*.wdtest" binding : highest "test"
# end of file



Try this little program to test function. With me works fine.

Happy xmas.

Ubirajara.


-----Mensagem original-----
De: gnome-list [mailto:gnome-list-bounces@gnome.org] Em nome de Sean Hammond
Enviada em: segunda-feira, 23 de dezembro de 2013 09:22
Para: gnome-list@gnome.org
Assunto: Re: How to bind F1 key as custom shortcut?

> Hey, I'm trying to bind the F1 key to run a custom script. I'm able to 
> do this with all the other F keys, but in the Settings app F1 opens 
> Help, so I can't press F1 in the Settings app to bind it.

Someone answered this for me on IRC: open dconf Editor and go to \
/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/, there you can find \
and all your custom keybindings and edit them directly. \
_______________________________________________ gnome-list mailing list
gnome-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gnome-list

As informações contidas nesta mensagem e nos arquivos anexados sao para uso exclusivo \
do destinatario aqui indicado e podem conter assuntos comerciais, de propriedade \
intelectual ou outras informações confidenciais, protegidas pelas leis aplicaveis. \
Caso não seja o destinatario correto, por favor, notifique o remetente. \
_______________________________________________ gnome-list mailing list
gnome-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gnome-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic