From 94cb6ee53af6b17e45106765c6aeb99f64ed1be5 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Sun, 6 Mar 2011 15:57:58 +0100 Subject: Add toggle actions to the View menu. So far these settings are not saved anywhere. --- share/gui/window-main.ui | 5 +++++ src/ld-window-main.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/share/gui/window-main.ui b/share/gui/window-main.ui index 5ab82e9..62c8436 100644 --- a/share/gui/window-main.ui +++ b/share/gui/window-main.ui @@ -26,6 +26,11 @@ + + + + + diff --git a/src/ld-window-main.c b/src/ld-window-main.c index 7a94152..3602edb 100644 --- a/src/ld-window-main.c +++ b/src/ld-window-main.c @@ -101,6 +101,12 @@ static void on_action_redo (GtkAction *action, LdWindowMain *self); static void on_action_delete (GtkAction *action, LdWindowMain *self); static void on_action_select_all (GtkAction *action, LdWindowMain *self); +static void on_action_main_toolbar (GtkToggleAction *action, + LdWindowMain *self); +static void on_action_library_toolbar (GtkToggleAction *action, + LdWindowMain *self); +static void on_action_grid (GtkToggleAction *action, LdWindowMain *self); + static void on_action_zoom_in (GtkAction *action, LdWindowMain *self); static void on_action_zoom_out (GtkAction *action, LdWindowMain *self); static void on_action_normal_size (GtkAction *action, LdWindowMain *self); @@ -169,6 +175,19 @@ static GtkActionEntry wm_action_entries[] = G_CALLBACK (on_action_about)} }; +static GtkToggleActionEntry wm_toggle_action_entries[] = +{ + {"MainToolbar", NULL, N_("_Main Toolbar"), NULL, + N_("Toggle displaying of the main toolbar"), + G_CALLBACK (on_action_main_toolbar), TRUE}, + {"LibraryToolbar", NULL, N_("_Library Toolbar"), NULL, + N_("Toggle displaying of the library toolbar"), + G_CALLBACK (on_action_library_toolbar), TRUE}, + {"ShowGrid", NULL, N_("Show _Grid"), NULL, + N_("Toggle displaying of the grid"), + G_CALLBACK (on_action_grid), TRUE} +}; + /* ===== Generic widget methods ============================================ */ @@ -226,8 +245,12 @@ ld_window_main_init (LdWindowMain *self) priv->action_group = gtk_action_group_new ("MainActions"); gtk_action_group_set_translation_domain (priv->action_group, GETTEXT_DOMAIN); - gtk_action_group_add_actions (priv->action_group, wm_action_entries, + gtk_action_group_add_actions + (priv->action_group, wm_action_entries, G_N_ELEMENTS (wm_action_entries), self); + gtk_action_group_add_toggle_actions + (priv->action_group, wm_toggle_action_entries, + G_N_ELEMENTS (wm_toggle_action_entries), self); gtk_ui_manager_insert_action_group (priv->ui_manager, priv->action_group, 0); @@ -898,6 +921,27 @@ on_action_select_all (GtkAction *action, LdWindowMain *self) ld_diagram_select_all (self->priv->diagram); } +static void +on_action_main_toolbar (GtkToggleAction *action, LdWindowMain *self) +{ + gtk_widget_set_visible (self->priv->toolbar, + gtk_toggle_action_get_active (action)); +} + +static void +on_action_library_toolbar (GtkToggleAction *action, LdWindowMain *self) +{ + gtk_widget_set_visible (self->priv->library_toolbar, + gtk_toggle_action_get_active (action)); +} + +static void +on_action_grid (GtkToggleAction *action, LdWindowMain *self) +{ + ld_diagram_view_set_show_grid (self->priv->view, + gtk_toggle_action_get_active (action)); +} + static void on_action_zoom_in (GtkAction *action, LdWindowMain *self) { -- cgit v1.2.3-70-g09d2