[latexila] LaTeX commands: port Tabular submenu to GAction
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] LaTeX commands: port Tabular submenu to GAction
- Date: Wed, 1 Nov 2017 08:40:45 +0000 (UTC)
commit 202deb81129d7bd7427e751b8102d23a1e5ab8fd
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Oct 29 14:33:18 2017 +0100
LaTeX commands: port Tabular submenu to GAction
For the latex-command-tabular-tabular GAction, add content to the
tabular (a, b, c, d), as was done for the table environment in a recent
previous commit.
src/latex_menu.vala | 69 ++++++++--------------------
src/liblatexila/latexila-latex-commands.c | 50 +++++++++++++++++++++
2 files changed, 70 insertions(+), 49 deletions(-)
---
diff --git a/src/latex_menu.vala b/src/latex_menu.vala
index 53d0061..e632710 100644
--- a/src/latex_menu.vala
+++ b/src/latex_menu.vala
@@ -163,17 +163,17 @@ public class LatexMenu : Gtk.ActionGroup
{ "Tabular", "table", N_("_Tabular") },
{ "TabularTabbing", null, "\\begin{ta_bbing}", null,
- N_("Tabbing - \\begin{tabbing}"), on_tabular_tabbing },
+ N_("Tabbing - \\begin{tabbing}") },
{ "TabularTabular", null, "\\begin{_tabular}", null,
- N_("Tabular - \\begin{tabular}"), on_tabular_tabular },
+ N_("Tabular - \\begin{tabular}") },
{ "TabularMulticolumn", null, "\\_multicolumn", null,
- N_("Multicolumn - \\multicolumn"), on_tabular_multicolumn },
+ N_("Multicolumn - \\multicolumn") },
{ "TabularHline", null, "\\_hline", null,
- N_("Horizontal line - \\hline"), on_tabular_hline },
+ N_("Horizontal line - \\hline") },
{ "TabularVline", null, "\\_vline", null,
- N_("Vertical line - \\vline"), on_tabular_vline },
+ N_("Vertical line - \\vline") },
{ "TabularCline", null, "\\_cline", null,
- N_("Horizontal line (columns specified) - \\cline"), on_tabular_cline },
+ N_("Horizontal line (columns specified) - \\cline") },
// LaTeX: Presentation
@@ -582,6 +582,20 @@ public class LatexMenu : Gtk.ActionGroup
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-char-style::scshape",
this, "FontShapeSmallCaps");
+ // LaTeX: Tabular
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-env-simple::tabbing",
+ this, "TabularTabbing");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-tabular-tabular",
+ this, "TabularTabular");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-tabular-multicolumn",
+ this, "TabularMulticolumn");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-without-braces::hline",
+ this, "TabularHline");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-without-braces::vline",
+ this, "TabularVline");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-tabular-cline",
+ this, "TabularCline");
+
// LaTeX: Spacing
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-with-braces::hspace",
this, "SpacingHSpace");
@@ -646,49 +660,6 @@ public class LatexMenu : Gtk.ActionGroup
return Latexila.view_get_indentation_style (main_window.active_view);
}
- /* Tabular */
-
- public void on_tabular_tabbing ()
- {
- text_buffer_insert ("\\begin{tabbing}\n", "\n\\end{tabbing}");
- }
-
- public void on_tabular_tabular ()
- {
- string indent = get_indentation ();
-
- string before_cursor =
- "\\begin{tabular}{cc";
-
- string after_cursor =
- "}\n" +
- @"$indent & \\\\\n" +
- @"$indent & \\\\\n" +
- "\\end{tabular}";
-
- text_buffer_insert (before_cursor, after_cursor);
- }
-
- public void on_tabular_multicolumn ()
- {
- text_buffer_insert ("\\multicolumn{}{}{", "}");
- }
-
- public void on_tabular_hline ()
- {
- text_buffer_insert ("\\hline ", "");
- }
-
- public void on_tabular_vline ()
- {
- text_buffer_insert ("\\vline ", "");
- }
-
- public void on_tabular_cline ()
- {
- text_buffer_insert ("\\cline{", "-}");
- }
-
/* Spacing */
public void on_spacing_new_line ()
diff --git a/src/liblatexila/latexila-latex-commands.c b/src/liblatexila/latexila-latex-commands.c
index d399ec3..15503fa 100644
--- a/src/liblatexila/latexila-latex-commands.c
+++ b/src/liblatexila/latexila-latex-commands.c
@@ -416,6 +416,53 @@ latex_command_char_style_cb (GSimpleAction *action,
g_free (text_if_no_selection);
}
+static void
+latex_command_tabular_tabular_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+ gchar *indent;
+ gchar *text_after;
+
+ indent = get_indentation (tepl_window);
+ text_after = g_strdup_printf ("}\n"
+ "%s a & b \\\\\n"
+ "%s c & d \\\\\n"
+ "\\end{tabular}",
+ indent,
+ indent);
+
+ deselect_text (tepl_window);
+ latexila_latex_commands_insert_text (tepl_window,
+ "\\begin{tabular}{cc",
+ text_after,
+ NULL);
+
+ g_free (indent);
+ g_free (text_after);
+}
+
+static void
+latex_command_tabular_multicolumn_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+
+ latexila_latex_commands_insert_text (tepl_window, "\\multicolumn{}{}{", "}", NULL);
+}
+
+static void
+latex_command_tabular_cline_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+
+ latexila_latex_commands_insert_text (tepl_window, "\\cline{", "-}", NULL);
+}
+
/**
* latexila_latex_commands_add_actions:
* @gtk_window: a #GtkApplicationWindow.
@@ -437,6 +484,9 @@ latexila_latex_commands_add_actions (GtkApplicationWindow *gtk_window)
{ "latex-command-list-env-description", latex_command_list_env_description_cb },
{ "latex-command-list-env-list", latex_command_list_env_list_cb },
{ "latex-command-char-style", latex_command_char_style_cb, "s" },
+ { "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 },
};
g_return_if_fail (GTK_IS_APPLICATION_WINDOW (gtk_window));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]