[latexila] LaTeX commands: port LaTeX Misc submenu to GAction
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] LaTeX commands: port LaTeX Misc submenu to GAction
- Date: Tue, 7 Nov 2017 20:22:32 +0000 (UTC)
commit 671414d6e1d1e95385a00deb000b1877ff42b765
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Nov 3 12:46:20 2017 +0100
LaTeX commands: port LaTeX Misc submenu to GAction
src/latex_menu.vala | 109 ++++++++++-------------------
src/liblatexila/latexila-latex-commands.c | 34 +++++++++
2 files changed, 70 insertions(+), 73 deletions(-)
---
diff --git a/src/latex_menu.vala b/src/latex_menu.vala
index 3cc513a..32cbcbb 100644
--- a/src/latex_menu.vala
+++ b/src/latex_menu.vala
@@ -228,30 +228,29 @@ public class LatexMenu : Gtk.ActionGroup
{ "Accent14", "accent14", "\\r", null, N_("Ring - \\r") },
{ "Accent15", "accent15", "\\t", null, N_("Tie - \\t") },
- // LaTeX: Others
+ // LaTeX: Misc
{ "LatexMisc", null, N_("_Misc") },
{ "LatexDocumentClass", null, "\\_documentclass", null,
- N_("Document class - \\documentclass"), on_documentclass },
+ N_("Document class - \\documentclass") },
{ "LatexUsepackage", null, "\\_usepackage", null,
- N_("Use package - \\usepackage"), on_usepackage },
+ N_("Use package - \\usepackage") },
{ "LatexAMS", null, N_("_AMS packages"), null,
- N_("AMS packages"), on_ams_packages },
- { "LatexAuthor", null, "\\au_thor", null, N_("Author - \\author"), on_author },
- { "LatexTitle", null, "\\t_itle", null, N_("Title - \\title"), on_title },
+ N_("AMS packages") },
+ { "LatexAuthor", null, "\\au_thor", null, N_("Author - \\author") },
+ { "LatexTitle", null, "\\t_itle", null, N_("Title - \\title") },
{ "LatexBeginDocument", null, "\\begin{d_ocument}", null,
- N_("Content of the document - \\begin{document}"), on_begin_document },
+ N_("Content of the document - \\begin{document}") },
{ "LatexMakeTitle", null, "\\_maketitle", null,
- N_("Make title - \\maketitle"), on_maketitle },
+ N_("Make title - \\maketitle") },
{ "LatexTableOfContents", null, "\\tableof_contents", null,
- N_("Table of contents - \\tableofcontents"), on_tableofcontents },
+ N_("Table of contents - \\tableofcontents") },
{ "LatexAbstract", null, "\\begin{abst_ract}", null,
- N_("Abstract - \\begin{abstract}"), on_abstract },
+ N_("Abstract - \\begin{abstract}") },
{ "LatexIncludeGraphics", null, "\\include_graphics", null,
- N_("Include an image (graphicx package) - \\includegraphics"),
- on_include_graphics },
+ N_("Include an image (graphicx package) - \\includegraphics") },
{ "LatexInput", null, "\\_input", null,
- N_("Include a file - \\input"), on_input },
+ N_("Include a file - \\input") },
// Math
@@ -657,6 +656,30 @@ public class LatexMenu : Gtk.ActionGroup
this, "Accent14");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces('t')",
this, "Accent15");
+
+ // LaTeX: Misc
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::documentclass",
+ this, "LatexDocumentClass");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::usepackage",
+ this, "LatexUsepackage");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-ams-packages",
+ this, "LatexAMS");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::author",
+ this, "LatexAuthor");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::title",
+ this, "LatexTitle");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-env-simple::document",
+ this, "LatexBeginDocument");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-simple::maketitle",
+ this, "LatexMakeTitle");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-simple::tableofcontents",
+ this, "LatexTableOfContents");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-env-simple::abstract",
+ this, "LatexAbstract");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::includegraphics",
+ this, "LatexIncludeGraphics");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::input",
+ this, "LatexInput");
}
private Gtk.Action get_menu_tool_action (string name, string? label, string? icon_name)
@@ -677,66 +700,6 @@ public class LatexMenu : Gtk.ActionGroup
text_if_no_selection);
}
- /* Others */
-
- public void on_documentclass ()
- {
- text_buffer_insert ("\\documentclass{", "}");
- }
-
- public void on_usepackage ()
- {
- text_buffer_insert ("\\usepackage{", "}");
- }
-
- public void on_ams_packages ()
- {
- string packages = "\\usepackage{amsmath}\n"
- + "\\usepackage{amsfonts}\n"
- + "\\usepackage{amssymb}";
- text_buffer_insert (packages, "");
- }
-
- public void on_author ()
- {
- text_buffer_insert ("\\author{", "}");
- }
-
- public void on_title ()
- {
- text_buffer_insert ("\\title{", "}");
- }
-
- public void on_begin_document ()
- {
- text_buffer_insert ("\\begin{document}\n", "\n\\end{document}");
- }
-
- public void on_maketitle ()
- {
- text_buffer_insert ("\\maketitle", "");
- }
-
- public void on_tableofcontents ()
- {
- text_buffer_insert ("\\tableofcontents", "");
- }
-
- public void on_abstract ()
- {
- text_buffer_insert ("\\begin{abstract}\n", "\n\\end{abstract}");
- }
-
- public void on_include_graphics ()
- {
- text_buffer_insert ("\\includegraphics{", "}");
- }
-
- public void on_input ()
- {
- text_buffer_insert ("\\input{", "}");
- }
-
/* Math environments */
public void on_math_env_normal ()
diff --git a/src/liblatexila/latexila-latex-commands.c b/src/liblatexila/latexila-latex-commands.c
index f9ea1de..3de88eb 100644
--- a/src/liblatexila/latexila-latex-commands.c
+++ b/src/liblatexila/latexila-latex-commands.c
@@ -168,6 +168,23 @@ deselect_text (TeplApplicationWindow *tepl_window)
/* GActions implementation */
static void
+latex_command_simple_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+ const gchar *command;
+ gchar *text_before;
+
+ command = g_variant_get_string (parameter, NULL);
+ text_before = g_strdup_printf ("\\%s", command);
+
+ latexila_latex_commands_insert_text (tepl_window, text_before, "", NULL);
+
+ g_free (text_before);
+}
+
+static void
latex_command_with_braces_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -560,6 +577,21 @@ latex_command_spacing_new_line_cb (GSimpleAction *action,
latexila_latex_commands_insert_text (tepl_window, "\\\\\n", "", NULL);
}
+static void
+latex_command_ams_packages_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+
+ latexila_latex_commands_insert_text (tepl_window,
+ "\\usepackage{amsmath}\n"
+ "\\usepackage{amsfonts}\n"
+ "\\usepackage{amssymb}",
+ "",
+ NULL);
+}
+
/**
* latexila_latex_commands_add_actions:
* @gtk_window: a #GtkApplicationWindow.
@@ -572,6 +604,7 @@ latexila_latex_commands_add_actions (GtkApplicationWindow *gtk_window)
TeplApplicationWindow *tepl_window;
const GActionEntry entries[] = {
+ { "latex-command-simple", latex_command_simple_cb, "s" },
{ "latex-command-with-braces", latex_command_with_braces_cb, "s" },
{ "latex-command-without-braces", latex_command_without_braces_cb, "s" },
{ "latex-command-with-newline", latex_command_with_newline_cb, "s" },
@@ -589,6 +622,7 @@ latexila_latex_commands_add_actions (GtkApplicationWindow *gtk_window)
{ "latex-command-presentation-block", latex_command_presentation_block_cb },
{ "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 },
};
g_return_if_fail (GTK_IS_APPLICATION_WINDOW (gtk_window));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]