[latexila] LaTeX commands: port Spacing submenu to GAction
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] LaTeX commands: port Spacing submenu to GAction
- Date: Wed, 1 Nov 2017 16:07:55 +0000 (UTC)
commit 9a9d939f8f596f9fde7eefa9ba0fe461df03a3f8
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Nov 1 16:58:09 2017 +0100
LaTeX commands: port Spacing submenu to GAction
src/latex_menu.vala | 65 +++++++++-------------------
src/liblatexila/latexila-latex-commands.c | 29 +++++++++++++
2 files changed, 50 insertions(+), 44 deletions(-)
---
diff --git a/src/latex_menu.vala b/src/latex_menu.vala
index e632710..d95bff9 100644
--- a/src/latex_menu.vala
+++ b/src/latex_menu.vala
@@ -189,23 +189,23 @@ public class LatexMenu : Gtk.ActionGroup
{ "Spacing", null, N_("_Spacing") },
{ "SpacingNewLine", null, N_("New _Line"), null,
- N_("New Line - \\\\"), on_spacing_new_line },
+ N_("New Line - \\\\") },
{ "SpacingNewPage", null, "\\new_page", null,
- N_("New page - \\newpage"), on_spacing_new_page },
+ N_("New page - \\newpage") },
{ "SpacingLineBreak", null, "\\l_inebreak", null,
- N_("Line break - \\linebreak"), on_spacing_line_break },
+ N_("Line break - \\linebreak") },
{ "SpacingPageBreak", null, "\\p_agebreak", null,
- N_("Page break - \\pagebreak"), on_spacing_page_break },
+ N_("Page break - \\pagebreak") },
{ "SpacingBigSkip", null, "\\_bigskip", null,
- N_("Big skip - \\bigskip"), on_spacing_bigskip },
+ N_("Big skip - \\bigskip") },
{ "SpacingMedSkip", null, "\\_medskip", null,
- N_("Medium skip - \\medskip"), on_spacing_medskip },
+ N_("Medium skip - \\medskip") },
{ "SpacingHSpace", null, "\\_hspace", null,
N_("Horizontal space - \\hspace") },
{ "SpacingVSpace", null, "\\_vspace", null,
N_("Vertical space - \\vspace") },
{ "SpacingNoIndent", null, "\\_noindent", null,
- N_("No paragraph indentation - \\noindent"), on_spacing_noindent },
+ N_("No paragraph indentation - \\noindent") },
// LaTeX: International accents
@@ -597,10 +597,24 @@ public class LatexMenu : Gtk.ActionGroup
this, "TabularCline");
// LaTeX: Spacing
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-spacing-new-line",
+ this, "SpacingNewLine");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-newline::newpage",
+ this, "SpacingNewPage");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-newline::linebreak",
+ this, "SpacingLineBreak");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-newline::pagebreak",
+ this, "SpacingPageBreak");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-without-braces::bigskip",
+ this, "SpacingBigSkip");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-without-braces::medskip",
+ this, "SpacingMedSkip");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::hspace",
this, "SpacingHSpace");
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::vspace",
this, "SpacingVSpace");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-without-braces::noindent",
+ this, "SpacingNoIndent");
// LaTeX: International accents
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces('\\'')",
@@ -660,43 +674,6 @@ public class LatexMenu : Gtk.ActionGroup
return Latexila.view_get_indentation_style (main_window.active_view);
}
- /* Spacing */
-
- public void on_spacing_new_line ()
- {
- text_buffer_insert ("\\\\\n", "");
- }
-
- public void on_spacing_new_page ()
- {
- text_buffer_insert ("\\newpage\n", "");
- }
-
- public void on_spacing_line_break ()
- {
- text_buffer_insert ("\\linebreak\n", "");
- }
-
- public void on_spacing_page_break ()
- {
- text_buffer_insert ("\\pagebreak\n", "");
- }
-
- public void on_spacing_bigskip ()
- {
- text_buffer_insert ("\\bigskip ", "");
- }
-
- public void on_spacing_medskip ()
- {
- text_buffer_insert ("\\medskip ", "");
- }
-
- public void on_spacing_noindent ()
- {
- text_buffer_insert ("\\noindent ", "");
- }
-
/* Presentation */
public void on_present_frame ()
diff --git a/src/liblatexila/latexila-latex-commands.c b/src/liblatexila/latexila-latex-commands.c
index 15503fa..c769a35 100644
--- a/src/liblatexila/latexila-latex-commands.c
+++ b/src/liblatexila/latexila-latex-commands.c
@@ -202,6 +202,23 @@ latex_command_without_braces_cb (GSimpleAction *action,
}
static void
+latex_command_with_newline_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\n", command);
+
+ latexila_latex_commands_insert_text (tepl_window, text_before, "", NULL);
+
+ g_free (text_before);
+}
+
+static void
latex_command_env_simple_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -463,6 +480,16 @@ latex_command_tabular_cline_cb (GSimpleAction *action,
latexila_latex_commands_insert_text (tepl_window, "\\cline{", "-}", NULL);
}
+static void
+latex_command_spacing_new_line_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+
+ latexila_latex_commands_insert_text (tepl_window, "\\\\\n", "", NULL);
+}
+
/**
* latexila_latex_commands_add_actions:
* @gtk_window: a #GtkApplicationWindow.
@@ -477,6 +504,7 @@ latexila_latex_commands_add_actions (GtkApplicationWindow *gtk_window)
const GActionEntry entries[] = {
{ "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" },
{ "latex-command-env-simple", latex_command_env_simple_cb, "s" },
{ "latex-command-env-figure", latex_command_env_figure_cb },
{ "latex-command-env-table", latex_command_env_table_cb },
@@ -487,6 +515,7 @@ latexila_latex_commands_add_actions (GtkApplicationWindow *gtk_window)
{ "latex-command-tabular-tabular", latex_command_tabular_tabular_cb },
{ "latex-command-tabular-multicolumn", latex_command_tabular_multicolumn_cb },
{ "latex-command-tabular-cline", latex_command_tabular_cline_cb },
+ { "latex-command-spacing-new-line", latex_command_spacing_new_line_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]