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

LaTeX commands: port Math misc commands to GAction

parent 1b2bd0a4
......@@ -272,16 +272,18 @@ public class LatexMenu : Gtk.ActionGroup
N_("Numbered Array of _Equations - \\begin{align}"), null,
N_("Numbered Array of Equations - \\begin{align}") },
// Math misc
{ "MathSuperscript", "math-superscript", N_("_Superscript - ^{}"), null,
N_("Superscript - ^{}"), on_math_superscript },
N_("Superscript - ^{}") },
{ "MathSubscript", "math-subscript", N_("Su_bscript - __{}"), null,
N_("Subscript - _{}"), on_math_subscript },
N_("Subscript - _{}") },
{ "MathFrac", "math-frac", N_("_Fraction - \\frac{}{}"), "<Alt><Shift>F",
N_("Fraction - \\frac{}{}"), on_math_frac },
N_("Fraction - \\frac{}{}") },
{ "MathSquareRoot", "math-square-root", N_("Square _Root - \\sqrt{}"), null,
N_("Square Root - \\sqrt{}"), on_math_square_root },
N_("Square Root - \\sqrt{}") },
{ "MathNthRoot", "math-nth-root", N_("_N-th Root - \\sqrt[]{}"), null,
N_("N-th Root - \\sqrt[]{}"), on_math_nth_root },
N_("N-th Root - \\sqrt[]{}") },
// Math functions
......@@ -691,6 +693,18 @@ public class LatexMenu : Gtk.ActionGroup
this, "MathEnvArray");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-env-simple::align",
this, "MathEnvNumberedArray");
// Math misc
Amtk.utils_bind_g_action_to_gtk_action (main_window, "math-command-misc-superscript",
this, "MathSuperscript");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "math-command-misc-subscript",
this, "MathSubscript");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "math-command-misc-frac",
this, "MathFrac");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::sqrt",
this, "MathSquareRoot");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "math-command-misc-nth-root",
this, "MathNthRoot");
}
private Gtk.Action get_menu_tool_action (string name, string? label, string? icon_name)
......@@ -711,33 +725,6 @@ public class LatexMenu : Gtk.ActionGroup
text_if_no_selection);
}
/* Math environments */
public void on_math_superscript ()
{
text_buffer_insert ("^{", "}");
}
public void on_math_subscript ()
{
text_buffer_insert ("_{", "}");
}
public void on_math_frac ()
{
text_buffer_insert ("\\frac{", "}{}");
}
public void on_math_square_root ()
{
text_buffer_insert ("\\sqrt{", "}");
}
public void on_math_nth_root ()
{
text_buffer_insert ("\\sqrt[]{", "}");
}
/* Math Functions */
public void on_math_func_arccos ()
......
......@@ -625,6 +625,46 @@ math_command_env_array_cb (GSimpleAction *action,
NULL);
}
static void
math_command_misc_superscript_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_misc_subscript_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_misc_frac_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
latexila_latex_commands_insert_text (tepl_window, "\\frac{", "}{}", NULL);
}
static void
math_command_misc_nth_root_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
latexila_latex_commands_insert_text (tepl_window, "\\sqrt[]{", "}", NULL);
}
/**
* latexila_latex_commands_add_actions:
* @gtk_window: a #GtkApplicationWindow.
......@@ -659,6 +699,10 @@ latexila_latex_commands_add_actions (GtkApplicationWindow *gtk_window)
{ "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 },
{ "math-command-misc-superscript", math_command_misc_superscript_cb },
{ "math-command-misc-subscript", math_command_misc_subscript_cb },
{ "math-command-misc-frac", math_command_misc_frac_cb },
{ "math-command-misc-nth-root", math_command_misc_nth_root_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