Commit cafd0894 authored by Sébastien Wilmet's avatar Sébastien Wilmet
Browse files

LaTeX commands: don't add AmtkActionInfo's for each window

The GAction's are created for each main window, but the AmtkActionInfo's
are for the whole application.
parent a14aed95
......@@ -132,7 +132,8 @@ latexila_build_view_get_type
<SECTION>
<FILE>latex-commands</FILE>
latexila_latex_commands_init
latexila_latex_commands_add_action_infos
latexila_latex_commands_add_actions
latexila_latex_commands_insert_text
</SECTION>
......
......@@ -443,7 +443,7 @@ public class LatexMenu : Gtk.ActionGroup
/* GActions */
Latexila.latex_commands_init (main_window);
Latexila.latex_commands_add_actions (main_window);
// LaTeX: Sectioning
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::part",
......
......@@ -119,6 +119,7 @@ public class LatexilaApp : Gtk.Application
hold ();
add_action_entries (_app_actions, this);
Latexila.latex_commands_add_action_infos (this);
GLib.MenuModel manual_app_menu = get_menu_by_id ("manual-app-menu");
if (manual_app_menu == null)
......
......@@ -29,6 +29,39 @@
#include "latexila-utils.h"
#include "latexila-view.h"
/**
* latexila_latex_commands_add_action_infos:
* @gtk_app: the #GtkApplication instance.
*
* Creates the #AmtkActionInfo's related to the LaTeX and Math menus, and add
* them to the #AmtkActionInfoStore as returned by
* tepl_application_get_app_action_info_store().
*/
void
latexila_latex_commands_add_action_infos (GtkApplication *gtk_app)
{
TeplApplication *tepl_app;
AmtkActionInfoStore *store;
const AmtkActionInfoEntry entries[] =
{
/* action, icon, label, accel, tooltip */
{ "win.latex-command-env-figure", "image-x-generic", "\\begin{_figure}", NULL,
N_("Figure - \\begin{figure}") },
};
g_return_if_fail (GTK_IS_APPLICATION (gtk_app));
tepl_app = tepl_application_get_from_gtk_application (gtk_app);
store = tepl_application_get_app_action_info_store (tepl_app);
amtk_action_info_store_add_entries (store,
entries,
G_N_ELEMENTS (entries),
GETTEXT_PACKAGE);
}
/* Util functions */
/* Temporarily public, will be made private when all GActions for the LaTeX and
......@@ -667,8 +700,15 @@ math_command_misc_nth_root_cb (GSimpleAction *action,
latexila_latex_commands_insert_text (tepl_window, "\\sqrt[]{", "}", NULL);
}
static void
add_actions (GtkApplicationWindow *gtk_window)
/**
* latexila_latex_commands_add_actions:
* @gtk_window: a #GtkApplicationWindow.
*
* Creates the #GAction's related to the LaTeX and Math menus, and add them to
* @gtk_window.
*/
void
latexila_latex_commands_add_actions (GtkApplicationWindow *gtk_window)
{
TeplApplicationWindow *tepl_window;
......@@ -701,6 +741,8 @@ add_actions (GtkApplicationWindow *gtk_window)
{ "math-command-misc-nth-root", math_command_misc_nth_root_cb },
};
g_return_if_fail (GTK_IS_APPLICATION_WINDOW (gtk_window));
tepl_window = tepl_application_window_get_from_gtk_application_window (gtk_window);
amtk_action_map_add_action_entries_check_dups (G_ACTION_MAP (gtk_window),
......@@ -708,42 +750,3 @@ add_actions (GtkApplicationWindow *gtk_window)
G_N_ELEMENTS (entries),
tepl_window);
}
static void
add_action_info_entries (void)
{
TeplApplication *tepl_app;
AmtkActionInfoStore *store;
const AmtkActionInfoEntry entries[] =
{
/* action, icon, label, accel, tooltip */
{ "win.latex-command-env-figure", "image-x-generic", "\\begin{_figure}", NULL,
N_("Figure - \\begin{figure}") },
};
tepl_app = tepl_application_get_default ();
store = tepl_application_get_app_action_info_store (tepl_app);
amtk_action_info_store_add_entries (store,
entries,
G_N_ELEMENTS (entries),
GETTEXT_PACKAGE);
}
/**
* latexila_latex_commands_init:
* @gtk_window: a #GtkApplicationWindow.
*
* Creates the #GAction's and #AmtkActionInfo's related to the LaTeX and Math
* menus.
*/
void
latexila_latex_commands_init (GtkApplicationWindow *gtk_window)
{
g_return_if_fail (GTK_IS_APPLICATION_WINDOW (gtk_window));
add_actions (gtk_window);
add_action_info_entries ();
}
......@@ -24,7 +24,9 @@
G_BEGIN_DECLS
void latexila_latex_commands_init (GtkApplicationWindow *gtk_window);
void latexila_latex_commands_add_action_infos (GtkApplication *gtk_app);
void latexila_latex_commands_add_actions (GtkApplicationWindow *gtk_window);
void latexila_latex_commands_insert_text (TeplApplicationWindow *tepl_window,
const gchar *text_before,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment