Add toggle actions to the View menu.

So far these settings are not saved anywhere.
This commit is contained in:
Přemysl Eric Janouch 2011-03-06 15:57:58 +01:00
parent c8caca073f
commit 94cb6ee53a
2 changed files with 50 additions and 1 deletions

View File

@ -26,6 +26,11 @@
<menuitem action="SelectAll" />
</menu>
<menu name="ViewMenu" action="ViewMenu">
<menuitem action="MainToolbar" />
<menuitem action="LibraryToolbar" />
<separator />
<menuitem action="ShowGrid" />
<separator />
<menuitem action="ZoomIn" />
<menuitem action="ZoomOut" />
<menuitem action="NormalSize" />

View File

@ -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)
{