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

LaTeX commands: port Math Environments submenu to GAction

parent 28065996
......@@ -260,18 +260,17 @@ public class LatexMenu : Gtk.ActionGroup
{ "MathEnvironments", null, N_("_Math Environments") },
{ "MathEnvNormal", null, N_("_Mathematical Environment - $...$"),
"<Alt><Shift>M", N_("Mathematical Environment - $...$"), on_math_env_normal },
"<Alt><Shift>M", N_("Mathematical Environment - $...$") },
{ "MathEnvCentered", null, N_("_Centered Formula - \\[...\\]"),
"<Alt><Shift>E", N_("Centered Formula - \\[...\\]"), on_math_env_centered },
"<Alt><Shift>E", N_("Centered Formula - \\[...\\]") },
{ "MathEnvNumbered", null,
N_("_Numbered Equation - \\begin{equation}"), null,
N_("Numbered Equation - \\begin{equation}"), on_math_env_numbered },
N_("Numbered Equation - \\begin{equation}") },
{ "MathEnvArray", null, N_("_Array of Equations - \\begin{align*}"), null,
N_("Array of Equations - \\begin{align*}"), on_math_env_array },
N_("Array of Equations - \\begin{align*}") },
{ "MathEnvNumberedArray", null,
N_("Numbered Array of _Equations - \\begin{align}"), null,
N_("Numbered Array of Equations - \\begin{align}"),
on_math_env_numbered_array },
N_("Numbered Array of Equations - \\begin{align}") },
{ "MathSuperscript", "math-superscript", N_("_Superscript - ^{}"), null,
N_("Superscript - ^{}"), on_math_superscript },
......@@ -680,6 +679,18 @@ public class LatexMenu : Gtk.ActionGroup
this, "LatexIncludeGraphics");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::input",
this, "LatexInput");
// Math Environments
Amtk.utils_bind_g_action_to_gtk_action (main_window, "math-command-env-normal",
this, "MathEnvNormal");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "math-command-env-centered",
this, "MathEnvCentered");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-env-simple::equation",
this, "MathEnvNumbered");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "math-command-env-array",
this, "MathEnvArray");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-env-simple::align",
this, "MathEnvNumberedArray");
}
private Gtk.Action get_menu_tool_action (string name, string? label, string? icon_name)
......@@ -702,31 +713,6 @@ public class LatexMenu : Gtk.ActionGroup
/* Math environments */
public void on_math_env_normal ()
{
text_buffer_insert ("$ ", " $");
}
public void on_math_env_centered ()
{
text_buffer_insert ("\\[ ", " \\]");
}
public void on_math_env_numbered ()
{
text_buffer_insert ("\\begin{equation}\n", "\n\\end{equation}");
}
public void on_math_env_array ()
{
text_buffer_insert ("\\begin{align*}\n", "\n\\end{align*}");
}
public void on_math_env_numbered_array ()
{
text_buffer_insert ("\\begin{align}\n", "\n\\end{align}");
}
public void on_math_superscript ()
{
text_buffer_insert ("^{", "}");
......
......@@ -592,6 +592,39 @@ latex_command_ams_packages_cb (GSimpleAction *action,
NULL);
}
static void
math_command_env_normal_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
latexila_latex_commands_insert_text (tepl_window, "$ ", " $", NULL);
}
static void
math_command_env_centered_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
latexila_latex_commands_insert_text (tepl_window, "\\[ ", " \\]", NULL);
}
static void
math_command_env_array_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
latexila_latex_commands_insert_text (tepl_window,
"\\begin{align*}\n",
"\n\\end{align*}",
NULL);
}
/**
* latexila_latex_commands_add_actions:
* @gtk_window: a #GtkApplicationWindow.
......@@ -623,6 +656,9 @@ latexila_latex_commands_add_actions (GtkApplicationWindow *gtk_window)
{ "latex-command-presentation-columns", latex_command_presentation_columns_cb },
{ "latex-command-spacing-new-line", latex_command_spacing_new_line_cb },
{ "latex-command-ams-packages", latex_command_ams_packages_cb },
{ "math-command-env-normal", math_command_env_normal_cb },
{ "math-command-env-centered", math_command_env_centered_cb },
{ "math-command-env-array", math_command_env_array_cb },
};
g_return_if_fail (GTK_IS_APPLICATION_WINDOW (gtk_window));
......
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