On Donnerstag, 8. Februar 2018 12:17:06 CET Daniel Boles wrote: > > are correctly updated with the expected textual representation of the > > keyboard > > accelerator key(s) (i.e. "Ctrl c", "F1", etc.), however the menu item's > > GtkAccelLabel would never be displayed on screen. > > I think we'd need to see precisely how you're setting up this MenuItem to > do anything other than speculate wildly.
Hi Daniel, first of all, the application code to reproduce this issue is actually gtkmm code and it is perfectly working with gtkmm2 & Gtk2. After investigating this a bit further, it seems to be a bug on gtkmm(3) level rather than on gtk(3) level, but I am not absolutely sure yet. Here is the setup, first as gtkmm C++ code (followed by unwrapped gtk C code): // MainWindow being subclass of Gtk::Window MainWindow::MainWindow() { ... // create a global keyboard acceleration entry for Shif+F1 and acceleration // path to be named "<Foo>/bla" Gtk::AccelMap::add_entry("<Foo>/bla", GDK_KEY_F1, Gdk::SHIFT_MASK); // actually creates (implied) a new acceleration group and assigns it to // window Glib::RefPtr<Gtk::AccelGroup> accelGroup = this->get_accel_group(); // assign newly created acceleration group to menu menu->set_accel_group(accelGroup); // add menu item to menu Gtk::MenuItem* menuItem = new Gtk::MenuItem("Some text"); menu->append(menuItem); // assign keyboard acceleration path to menu item menuItem->set_accel_path("<Foo>/bla"); // assign a callback as action when either menu item is clicked or // triggered by keyboard accelerator menuItem->signal_activate().connect( sigc::men_fun(*this, &MainWindow::doSomething) ); } That gtkmm code still provides its expected base functionality with gtkmm3, that is the menu item's action is triggered correctly when the keyboard accelerator is used, but unlike with gtkmm2 the accelerator keys are no longer displayed in the menu with gtkmm3. Now unwrapped as gtk C code it would look like this: // create a global keyboard acceleration entry for Shif+F1 and acceleration // path to be named "<Foo>/bla" gtk_accel_map_add_entry("<Foo>/bla", GDK_KEY_F1, GDK_SHIFT_MASK); // create an acceleration group and assign it to main window and menu GtkAccelGroup* accelGroup = gtk_accel_group_new(); gtk_window_add_accel_group(mainWindow, accelGroup); gtk_menu_set_accel_group(menu, accelGroup); // add menu item to menu GtkWidget* menuItem = gtk_menu_item_new_with_label("Some text"); gtk_menu_shell_append(menu, menuItem); // assign keyboard acceleration path to menu item gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuItem), "<Foo>/bla"); gtk_widget_show(menuItem); // assign a callback as action when either menu item is clicked or // triggered by keyboard accelerator g_signal_connect( G_OBJECT(menuItem), "activate", G_CALLBACK(doSomething), NULL ); And in fact that C code works perfectly even with Gtk 3, but gtkmm3 is doing something differently than in above's C code: in the Gtk::MenuItem constructor they explicitly create an acceleration label for the menu item and I am not sure whether they should not do that, or whether gtk should rather be able to handle that: https://github.com/GNOME/gtkmm/blob/gtkmm-3-22/gtk/src/menuitem.ccg (line 46 and line 51-61 being the relevant ones) As far as I can read from the gtk sources, gtk automatically creates the menu item's acceleration label (even if no accelerators are used at all). But right now I cannot judge which side is wrong here (gtkmm3 or gtk3). > Isn't this a tautology? Why would the size be updated for an accelerator > that is not being shown...? Well, if I force a greater allocation size for the menu item, the accelerator is in fact displayed (even with gtkmm3 that is). CU Christian _______________________________________________ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list