[maemo-developers] GtkAction vs. AppMenu
From: Cornelius Hald hald at icandy.deDate: Fri May 22 16:24:01 EEST 2009
- Previous message: GtkAction vs. AppMenu
- Next message: GtkAction vs. AppMenu
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 2009-05-21 at 17:28 +0200, Alberto Garcia wrote: > On Tue, May 19, 2009 at 05:24:47PM +0200, Cornelius Hald wrote: > > First of all, sorry for the delay :) No problem at all. I really appreciate your help :) > They are not supposed to show up, but they should work. I've just > tested it here and it works fine. If you can send your test case I can > take a look at it. Well, I don't really have a test case, but rather a complete application ;) The complete source can be found here: https://garage.maemo.org/viewvc/trunk/conboy/src/interface.c?view=markup&root=conboy&pathrev=134 The menu starts around line 280. Note that Fremantle specific code is marked with #ifdef HILDON_HAS_APP_MENU. But so that you don't have to read through this big and ugly file, I'll try to outline what I do with one of the actions. Casts etc. are removed to make it less cluttered: action = gtk_toggle_action_new("bold", "Bold", NULL, GTK_STOCK_BOLD)); gtk_action_set_accel_group(action, accel_group); gtk_action_set_accel_path(action, ACCEL_PATH_STYLE_BOLD); gtk_accel_map_add_entry(ACCEL_PATH_STYLE_BOLD, GDK_b, GDK_CONTROL_MASK); text_style_menu = hildon_app_menu_new(); menu_bold = gtk_button_new(); gtk_action_connect_proxy(action_bold, menu_bold); hildon_app_menu_append(text_style_menu, menu_bold); The result is a menu with the correct labels on the buttons and the correct behavior - only the accelerators (here Ctrl+b) do not work. > > 2) How do I get my GtkRadioActions to work with the HildonAppMenu? I > > created the the buttons with gtk_radio_button_new() and then used > > gtk_action_connect_proxy() like with the normal GtkActions above. > > The problem is that now all of the radio buttons are selected active > > at the same time. > > Try using gtk_radio_button_new_from_widget () to create all buttons > after the first one. I'll tried in three different ways with different outcomes. Unfortunately non of them was good :( First, my GtkRadioActions are set up like this: a1 = gtk_radio_action_new("size:small", "Small"), NULL, NULL, 0); a2 = gtk_radio_action_new("size:normal", "Normal"), NULL, NULL, 1); a3 = gtk_radio_action_new("size:large", "Large"), NULL, NULL, 2); gtk_radio_action_set_group(a1, action_group); action_group = gtk_radio_action_get_group(a1); gtk_radio_action_set_group(a2, action_group); action_group = gtk_radio_action_get_group(a2); gtk_radio_action_set_group(a3, action_group); action_group = gtk_radio_action_get_group(a3); gtk_radio_action_set_current_value(a2, 1); Now we come to the part, where I create the buttons. I tried these three different ways: /* Correctly shown, but not reacting on gtk_radio_action_set_current_value() */ but1 = gtk_radio_button_new(NULL); but2 = gtk_radio_button_new_from_widget(but1); but3 = gtk_radio_button_new_from_widget(but1); /* All shown as active */ but1 = gtk_radio_button_new(NULL); but2 = gtk_radio_button_new(NULL); but3 = gtk_radio_button_new(NULL); /* Same effect as with NULL /* but1 = gtk_radio_button_new(action_group); but2 = gtk_radio_button_new(action_group); but3 = gtk_radio_button_new(action_group); Then I simply connect the buttons with the actions gtk_action_connect_proxy(a1, but1); gtk_action_connect_proxy(a2, but2); gtk_action_connect_proxy(a3, but3); In all cases the label text is correctly taken from the actions, so I would say there is a connection somehow. I couldn't find examples for using GtkRadioAction with GtkRadioButton and gtk_action_connect_proxy() on the net, so it would really help me if you would take the time to look into it again :) Thanks! Conny
- Previous message: GtkAction vs. AppMenu
- Next message: GtkAction vs. AppMenu
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]