Hi, Thank you for your reply. I am not sure what you mean by "GtkToolbar doesn't implement the GAction interface". In Glade, I can define the specify the "Action Name" for each individual widget in the Toolbar. Those action names get automatically linked to the actions that I've defined in the my GActionEntry array. The only thing that does not work are the Radio button actions.
Thank you, Mitko On Tue, Oct 2, 2018 at 4:19 PM <cecas...@aol.com> wrote: > > Hi Mitko, > > The GtkToolbar doesn't implement the GAction interface so you are out of > luck there. > > You can use gtk_toggle_tool_button_get_active() to get the state of one of > the GtkRadioToolButton's in the toolbar. > > Eric > > > //gcc -Wall toolbar1.c -o toolbar1 `pkg-config --cflags --libs gtk+-3.0` > > #include<gtk/gtk.h> > > static void get_active_radio(GtkWidget *button, GtkToolItem **radios) > { > gint i=0; > > for(i=0;i<3;i++) > { > > if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(radios[i]))) > { > g_print("radio%i\n", i+1); > } > } > } > int main(int argc, char **argv) > { > gtk_init(&argc, &argv); > > GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL); > gtk_window_set_title(GTK_WINDOW(window), "Toolbar"); > gtk_window_set_default_size(GTK_WINDOW(window), 300, 100); > gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); > g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); > > GtkToolItem *radio1=gtk_radio_tool_button_new(NULL); > gtk_tool_item_set_expand(radio1, TRUE); > gtk_tool_button_set_label(GTK_TOOL_BUTTON(radio1), "radio1"); > GtkToolItem > *radio2=gtk_radio_tool_button_new_from_widget(GTK_RADIO_TOOL_BUTTON(radio1)); > gtk_tool_item_set_expand(radio2, TRUE); > gtk_tool_button_set_label(GTK_TOOL_BUTTON(radio2), "radio2"); > GtkToolItem > *radio3=gtk_radio_tool_button_new_from_widget(GTK_RADIO_TOOL_BUTTON(radio1)); > gtk_tool_item_set_expand(radio3, TRUE); > gtk_tool_button_set_label(GTK_TOOL_BUTTON(radio3), "radio3"); > > GtkWidget *toolbar=gtk_toolbar_new(); > gtk_widget_set_hexpand(toolbar, TRUE); > gtk_toolbar_insert(GTK_TOOLBAR(toolbar), radio1, 0); > gtk_toolbar_insert(GTK_TOOLBAR(toolbar), radio2, 1); > gtk_toolbar_insert(GTK_TOOLBAR(toolbar), radio3, 2); > > GtkWidget *button=gtk_button_new_with_label("Get Active Radio"); > gtk_widget_set_hexpand(button, TRUE); > gtk_widget_set_vexpand(button, TRUE); > GtkToolItem *radios[]={radio1, radio2, radio3}; > g_signal_connect(button, "clicked", G_CALLBACK(get_active_radio), > radios); > > GtkWidget *grid1=gtk_grid_new(); > gtk_container_set_border_width(GTK_CONTAINER(grid1), 15); > gtk_grid_set_row_spacing(GTK_GRID(grid1), 8); > gtk_grid_attach(GTK_GRID(grid1), toolbar, 0, 0, 1, 1); > gtk_grid_attach(GTK_GRID(grid1), button, 0, 1, 1, 1); > > gtk_container_add(GTK_CONTAINER(window), grid1); > > gtk_widget_show_all(window); > > gtk_widget_grab_focus(button); > > gtk_main(); > > return 0; > } > > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list