+static void toggle_side_panel ( VikWindow *vw )
+{
+ vw->show_side_panel = !vw->show_side_panel;
+ if ( vw->show_side_panel )
+ gtk_widget_show(GTK_WIDGET(vw->viking_vlp));
+ else
+ gtk_widget_hide(GTK_WIDGET(vw->viking_vlp));
+}
+
+static void toggle_full_screen ( VikWindow *vw )
+{
+ vw->show_full_screen = !vw->show_full_screen;
+ if ( vw->show_full_screen )
+ gtk_window_fullscreen ( GTK_WINDOW(vw) );
+ else
+ gtk_window_unfullscreen ( GTK_WINDOW(vw) );
+}
+
+static void toggle_statusbar ( VikWindow *vw )
+{
+ vw->show_statusbar = !vw->show_statusbar;
+ if ( vw->show_statusbar )
+ gtk_widget_show ( GTK_WIDGET(vw->viking_vs) );
+ else
+ gtk_widget_hide ( GTK_WIDGET(vw->viking_vs) );
+}
+
+static void toggle_toolbar ( VikWindow *vw )
+{
+ vw->show_toolbar = !vw->show_toolbar;
+ if ( vw->show_toolbar )
+ gtk_widget_show ( toolbar_get_widget (vw->viking_vtb) );
+ else
+ gtk_widget_hide ( toolbar_get_widget (vw->viking_vtb) );
+}
+
+static void toggle_main_menu ( VikWindow *vw )
+{
+ vw->show_main_menu = !vw->show_main_menu;
+ if ( vw->show_main_menu )
+ gtk_widget_show ( gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu" ) );
+ else
+ gtk_widget_hide ( gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu" ) );
+}
+
+// Only for 'view' toggle menu widgets ATM.
+GtkWidget *get_show_widget_by_name(VikWindow *vw, const gchar *name)
+{
+ g_return_val_if_fail(name != NULL, NULL);
+
+ // ATM only FullScreen is *not* in SetShow path
+ gchar *path;
+ if ( g_strcmp0 ("FullScreen", name ) )
+ path = g_strconcat("/ui/MainMenu/View/SetShow/", name, NULL);
+ else
+ path = g_strconcat("/ui/MainMenu/View/", name, NULL);
+
+ GtkWidget *widget = gtk_ui_manager_get_widget(vw->uim, path);
+ g_free(path);
+
+ return widget;
+}
+
+static void tb_view_side_panel_cb ( GtkAction *a, VikWindow *vw )
+{
+ gboolean next_state = !vw->show_side_panel;
+ GtkWidget *check_box = get_show_widget_by_name ( vw, gtk_action_get_name(a) );
+ gboolean menu_state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+ if ( next_state != menu_state )
+ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(check_box), next_state );
+ else
+ toggle_side_panel ( vw );
+}
+
+static void tb_full_screen_cb ( GtkAction *a, VikWindow *vw )
+{
+ gboolean next_state = !vw->show_full_screen;
+ GtkWidget *check_box = get_show_widget_by_name ( vw, gtk_action_get_name(a) );
+ gboolean menu_state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+ if ( next_state != menu_state )
+ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(check_box), next_state );
+ else
+ toggle_full_screen ( vw );
+}
+
+static void tb_view_statusbar_cb ( GtkAction *a, VikWindow *vw )
+{
+ gboolean next_state = !vw->show_statusbar;
+ GtkWidget *check_box = get_show_widget_by_name ( vw, gtk_action_get_name(a) );
+ gboolean menu_state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+ if ( next_state != menu_state )
+ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(check_box), next_state );
+ else
+ toggle_statusbar ( vw );
+}
+
+static void tb_view_toolbar_cb ( GtkAction *a, VikWindow *vw )
+{
+ gboolean next_state = !vw->show_toolbar;
+ GtkWidget *check_box = get_show_widget_by_name ( vw, gtk_action_get_name(a) );
+ gboolean menu_state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+ if ( next_state != menu_state )
+ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(check_box), next_state );
+ else
+ toggle_toolbar ( vw );
+}
+
+static void tb_view_main_menu_cb ( GtkAction *a, VikWindow *vw )
+{
+ gboolean next_state = !vw->show_main_menu;
+ GtkWidget *check_box = get_show_widget_by_name ( vw, gtk_action_get_name(a) );
+ gboolean menu_state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+ if ( next_state != menu_state )
+ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(check_box), next_state );
+ else
+ toggle_main_menu ( vw );
+}
+
+static void tb_set_draw_scale ( GtkAction *a, VikWindow *vw )
+{
+ gboolean next_state = !vik_viewport_get_draw_scale ( vw->viking_vvp );
+ GtkWidget *check_box = get_show_widget_by_name ( vw, gtk_action_get_name(a) );
+ gboolean menu_state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+ if ( next_state != menu_state )
+ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(check_box), next_state );
+ else {
+ vik_viewport_set_draw_scale ( vw->viking_vvp, next_state );
+ draw_update ( vw );
+ }
+}
+
+static void tb_set_draw_centermark ( GtkAction *a, VikWindow *vw )
+{
+ gboolean next_state = !vik_viewport_get_draw_centermark ( vw->viking_vvp );
+ GtkWidget *check_box = get_show_widget_by_name ( vw, gtk_action_get_name(a) );
+ gboolean menu_state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+ if ( next_state != menu_state )
+ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(check_box), next_state );
+ else {
+ vik_viewport_set_draw_centermark ( vw->viking_vvp, next_state );
+ draw_update ( vw );
+ }
+}
+
+static void tb_set_draw_highlight ( GtkAction *a, VikWindow *vw )
+{
+ gboolean next_state = !vik_viewport_get_draw_highlight ( vw->viking_vvp );
+ GtkWidget *check_box = get_show_widget_by_name ( vw, gtk_action_get_name(a) );
+ gboolean menu_state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box) );
+ if ( next_state != menu_state )
+ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM(check_box), next_state );
+ else {
+ vik_viewport_set_draw_highlight ( vw->viking_vvp, next_state );
+ draw_update ( vw );
+ }
+}
+