[latexila] LaTeX commands: port Math Environments submenu to GAction
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] LaTeX commands: port Math Environments submenu to GAction
- Date: Fri, 24 Nov 2017 19:16:07 +0000 (UTC)
commit 1b2bd0a493494bc926d5b22c3569d8eebd265a89
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Nov 24 19:59:28 2017 +0100
LaTeX commands: port Math Environments submenu to GAction
src/latex_menu.vala | 48 ++++++++++------------------
src/liblatexila/latexila-latex-commands.c | 36 +++++++++++++++++++++
2 files changed, 53 insertions(+), 31 deletions(-)
---
diff --git a/src/latex_menu.vala b/src/latex_menu.vala
index 6e6e04e..8923308 100644
--- a/src/latex_menu.vala
+++ b/src/latex_menu.vala
@@ -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 ("^{", "}");
diff --git a/src/liblatexila/latexila-latex-commands.c b/src/liblatexila/latexila-latex-commands.c
index 53e8523..0e14f7a 100644
--- a/src/liblatexila/latexila-latex-commands.c
+++ b/src/liblatexila/latexila-latex-commands.c
@@ -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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]