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

LaTeX commands: add first AmtkActionInfo and create GtkAction from it

This is a proof of concept, all the other GtkActionEntry's will need to
be ported to AmtkActionInfoEntry's. This will permit to create the Edit
toolbar with Amtk, without duplicating the action infos, while still
using GtkUIManager to create the menu.
parent 72b9aa0f
......@@ -132,7 +132,7 @@ latexila_build_view_get_type
<SECTION>
<FILE>latex-commands</FILE>
latexila_latex_commands_add_actions
latexila_latex_commands_init
latexila_latex_commands_insert_text
</SECTION>
......
......@@ -70,8 +70,6 @@ public class LatexMenu : Gtk.ActionGroup
N_("Align Left - \\begin{flushleft}") },
{ "EnvRight", "format-justify-right", "\\begin{flush_right}", null,
N_("Align Right - \\begin{flushright}") },
{ "EnvFigure", "image-x-generic", "\\begin{_figure}", null,
N_("Figure - \\begin{figure}") },
{ "EnvTable", "table", "\\begin{_table}", null,
N_("Table - \\begin{table}") },
{ "EnvQuote", null, "\\begin{_quote}", null,
......@@ -453,7 +451,7 @@ public class LatexMenu : Gtk.ActionGroup
/* GActions */
Latexila.latex_commands_add_actions (main_window);
Latexila.latex_commands_init (main_window);
// LaTeX: Sectioning
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::part",
......@@ -492,7 +490,7 @@ public class LatexMenu : Gtk.ActionGroup
this, "EnvLeft");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-env-simple::flushright",
this, "EnvRight");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-env-figure",
Amtk.utils_create_gtk_action (main_window, "win.latex-command-env-figure",
this, "EnvFigure");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-env-table",
this, "EnvTable");
......
......@@ -23,7 +23,9 @@
* @short_description: LaTeX menu, Math menu and Edit toolbar
*/
#include "config.h"
#include "latexila-latex-commands.h"
#include <glib/gi18n.h>
#include "latexila-utils.h"
#include "latexila-view.h"
......@@ -665,14 +667,8 @@ math_command_misc_nth_root_cb (GSimpleAction *action,
latexila_latex_commands_insert_text (tepl_window, "\\sqrt[]{", "}", NULL);
}
/**
* latexila_latex_commands_add_actions:
* @gtk_window: a #GtkApplicationWindow.
*
* Adds the #GAction's related to the LaTeX and Math menus.
*/
void
latexila_latex_commands_add_actions (GtkApplicationWindow *gtk_window)
static void
add_actions (GtkApplicationWindow *gtk_window)
{
TeplApplicationWindow *tepl_window;
......@@ -705,8 +701,6 @@ latexila_latex_commands_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),
......@@ -714,3 +708,42 @@ latexila_latex_commands_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,7 @@
G_BEGIN_DECLS
void latexila_latex_commands_add_actions (GtkApplicationWindow *gtk_window);
void latexila_latex_commands_init (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