Re: Understanding accelerators.
On 09/10/2014 20:53, Lucas Levrel wrote: Le 7 octobre 2014, Oscar Lazzarino a écrit : Let's say I have a window with just one button quit. I'd like to handle the controloq key event to quit the application. Here's how I set Return as accel in my GTK 2 app: gtkwin=gtk_window_new(GTK_WINDOW_TOPLEVEL); accels=gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(gtkwin),accels); ... button=gtk_button_new(); gtk_box_pack_end( GTK_BOX(...), button, FALSE, FALSE, 0); button_img=gtk_image_new_from_stock(GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(button), button_img); g_signal_connect(button, clicked, G_CALLBACK(...), ...); gtk_widget_add_accelerator(button, clicked, accels, gdk_keyval_from_name(Return), (GdkModifierType)0, GTK_ACCEL_LOCKED); HTH. That helped. Thanks O. -- Oscar Lazzarino (Software Architect and Senior Developer) oscar.lazzar...@i-m3d.com im3D SpA - Medical Imaging Lab http://www.i-m3d.com/ via Lessolo, 3 10153 Torino (TO) - Italy tel:+39 011 19508773 fax:+39 011 19508968 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Understanding accelerators.
Le 7 octobre 2014, Oscar Lazzarino a écrit : Let's say I have a window with just one button quit. I'd like to handle the controloq key event to quit the application. Here's how I set Return as accel in my GTK 2 app: gtkwin=gtk_window_new(GTK_WINDOW_TOPLEVEL); accels=gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(gtkwin),accels); ... button=gtk_button_new(); gtk_box_pack_end( GTK_BOX(...), button, FALSE, FALSE, 0); button_img=gtk_image_new_from_stock(GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(button), button_img); g_signal_connect(button, clicked, G_CALLBACK(...), ...); gtk_widget_add_accelerator(button, clicked, accels, gdk_keyval_from_name(Return), (GdkModifierType)0, GTK_ACCEL_LOCKED); HTH. -- Lucas Levrel ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Understanding accelerators.
Hi, I'm trying to understand the difference between accelerators and the “key-press-event” signal. Let's say I have a window with just one button quit. I'd like to handle the controloq key event to quit the application. I now I can connect to the top window key-press-event, but - just to understand how things work - is there any way to do the same with accelerators? Or are accelerators exclusively intended to be used with menus? I'm totally lost in the documentation bouncing between actions, accelerators, accerator groups, action groups, ui managers, etc, and I can't find a SIMPLE example. Any help would be greatly appreciated. Thanks -- Oscar Lazzarino (Software Architect and Senior Developer) oscar.lazzar...@i-m3d.com im3D SpA - Medical Imaging Lab http://www.i-m3d.com/ via Lessolo, 3 10153 Torino (TO) - Italy tel:+39 011 19508773 fax:+39 011 19508968 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Understanding accelerators.
On 10/07/2014 04:45 AM, Oscar Lazzarino wrote: I'm trying to understand the difference between accelerators and the “key-press-event” signal. Let's say I have a window with just one button quit. I'd like to handle the controloq key event to quit the application. I now I can connect to the top window key-press-event, but - just to understand how things work - is there any way to do the same with accelerators? Or are accelerators exclusively intended to be used with menus? I'm totally lost in the documentation bouncing between actions, accelerators, accerator groups, action groups, ui managers, etc, and I can't find a SIMPLE example. Any help would be greatly appreciated. There are menu accelerators and there are mnemonic accelerators. What you need to use for a quit button is a mnemonic accelerator. You do not attach to any key-press signal. Attach to the button clicked signal. GTK provides the functionality to capture the keyboard press and route it to the button click. You're complicating this a little. It's not that complicated. :) ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Understanding accelerators.
Mnemonics are discouraged by the HIG, and AFAIK they are not displayed by recent GTK versions. From the user's perspective, I think there is no difference. However, if you are using GApplication/GtkApplication, it is easier to register accels, and you can even make them easily customizable for the users. I'm yet to find a good example on the Interwebs, but if you take a look at GNOME 3.14 apps, you will find some for sure. Best, Gergely On 7 Oct 2014 16:12, Michael Cronenworth m...@cchtml.com wrote: On 10/07/2014 04:45 AM, Oscar Lazzarino wrote: I'm trying to understand the difference between accelerators and the “key-press-event” signal. Let's say I have a window with just one button quit. I'd like to handle the controloq key event to quit the application. I now I can connect to the top window key-press-event, but - just to understand how things work - is there any way to do the same with accelerators? Or are accelerators exclusively intended to be used with menus? I'm totally lost in the documentation bouncing between actions, accelerators, accerator groups, action groups, ui managers, etc, and I can't find a SIMPLE example. Any help would be greatly appreciated. There are menu accelerators and there are mnemonic accelerators. What you need to use for a quit button is a mnemonic accelerator. You do not attach to any key-press signal. Attach to the button clicked signal. GTK provides the functionality to capture the keyboard press and route it to the button click. You're complicating this a little. It's not that complicated. :) ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Understanding accelerators.
On 10/07/2014 09:18 AM, Gergely Polonkai wrote: Mnemonics are discouraged by the HIG, and AFAIK they are not displayed by recent GTK versions. From the user's perspective, I think there is no difference. However, if you are using GApplication/GtkApplication, it is easier to register accels, and you can even make them easily customizable for the users. I'm yet to find a good example on the Interwebs, but if you take a look at GNOME 3.14 apps, you will find some for sure. It's quite humorous that no one responds to most queries on this list, but as soon as I do there are a handful of replies to point out how I'm wrong. Mnemonics are not displayed by default, yes, as that's a stylistic preference of the theme you use and not a GTK default. Discouraged? This is news to me. I just ran through a handful of GNOME apps and they all use mnemonics. In fact... the GNOME HIG page *encourages* to make shortcut keys as mnemonic as possible[1]. Menu and mnemonic accelerators do have differences. The former can be assigned to any key combination. The later only apply to the ALT key. [1] https://developer.gnome.org/hig/stable/keyboard-input.html.en ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Understanding accelerators.
This is becoming offtopic, but… this is strange, last time I saw a discussion about them, they were considered out of date or something and many was upset that they are gone (even if only at theme level). Sorry then, it's my mistake. On 7 Oct 2014 16:31, Michael Cronenworth m...@cchtml.com wrote: On 10/07/2014 09:18 AM, Gergely Polonkai wrote: Mnemonics are discouraged by the HIG, and AFAIK they are not displayed by recent GTK versions. From the user's perspective, I think there is no difference. However, if you are using GApplication/GtkApplication, it is easier to register accels, and you can even make them easily customizable for the users. I'm yet to find a good example on the Interwebs, but if you take a look at GNOME 3.14 apps, you will find some for sure. It's quite humorous that no one responds to most queries on this list, but as soon as I do there are a handful of replies to point out how I'm wrong. Mnemonics are not displayed by default, yes, as that's a stylistic preference of the theme you use and not a GTK default. Discouraged? This is news to me. I just ran through a handful of GNOME apps and they all use mnemonics. In fact... the GNOME HIG page *encourages* to make shortcut keys as mnemonic as possible[1]. Menu and mnemonic accelerators do have differences. The former can be assigned to any key combination. The later only apply to the ALT key. [1] https://developer.gnome.org/hig/stable/keyboard-input.html.en ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list