[latexila] LaTeX commands: port Presentation submenu to GAction
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] LaTeX commands: port Presentation submenu to GAction
- Date: Wed, 1 Nov 2017 18:23:16 +0000 (UTC)
commit 54b8e0bc5979fcae87df86d6d3c8ebd38de10238
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Nov 1 18:58:35 2017 +0100
LaTeX commands: port Presentation submenu to GAction
src/latex_menu.vala | 48 ++++---------------
src/liblatexila/latexila-latex-commands.c | 73 +++++++++++++++++++++++++++++
2 files changed, 84 insertions(+), 37 deletions(-)
---
diff --git a/src/latex_menu.vala b/src/latex_menu.vala
index d95bff9..3cc513a 100644
--- a/src/latex_menu.vala
+++ b/src/latex_menu.vala
@@ -179,11 +179,11 @@ public class LatexMenu : Gtk.ActionGroup
{ "Presentation", "x-office-presentation", "_Presentation" },
{ "PresentationFrame", null, "\\begin{frame}", null,
- N_("Frame - \\begin{frame}"), on_present_frame },
+ N_("Frame - \\begin{frame}") },
{ "PresentationBlock", null, "\\begin{block}", null,
- N_("Block - \\begin{block}"), on_present_block },
+ N_("Block - \\begin{block}") },
{ "PresentationColumns", null, "\\begin{columns}", null,
- N_("Two columns - \\begin{columns}"), on_present_columns },
+ N_("Two columns - \\begin{columns}") },
// LaTeX: Spacing
@@ -596,6 +596,14 @@ public class LatexMenu : Gtk.ActionGroup
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-tabular-cline",
this, "TabularCline");
+ // LaTeX: Presentation
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-presentation-frame",
+ this, "PresentationFrame");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-presentation-block",
+ this, "PresentationBlock");
+ Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-presentation-columns",
+ this, "PresentationColumns");
+
// LaTeX: Spacing
Amtk.utils_bind_g_action_to_gtk_action (main_window, "latex-command-spacing-new-line",
this, "SpacingNewLine");
@@ -669,40 +677,6 @@ public class LatexMenu : Gtk.ActionGroup
text_if_no_selection);
}
- private string get_indentation ()
- {
- return Latexila.view_get_indentation_style (main_window.active_view);
- }
-
- /* Presentation */
-
- public void on_present_frame ()
- {
- string indent = get_indentation ();
- string begin_frame = "\\begin{frame}\n"
- + @"$indent\\frametitle{}\n"
- + @"$indent\\framesubtitle{}\n";
- string end_frame = "\n\\end{frame}";
- text_buffer_insert (begin_frame, end_frame);
- }
-
- public void on_present_columns ()
- {
- string indent = get_indentation ();
- string begin_columns = "\\begin{columns}\n"
- + @"$indent\\begin{column}{.5\\textwidth}\n";
- string end_columns = @"\n$indent\\end{column}\n"
- + @"$indent\\begin{column}{.5\\textwidth}\n\n"
- + @"$indent\\end{column}\n"
- + "\\end{columns}";
- text_buffer_insert (begin_columns, end_columns);
- }
-
- public void on_present_block ()
- {
- text_buffer_insert ("\\begin{block}{}\n","\n\\end{block}");
- }
-
/* Others */
public void on_documentclass ()
diff --git a/src/liblatexila/latexila-latex-commands.c b/src/liblatexila/latexila-latex-commands.c
index c769a35..f9ea1de 100644
--- a/src/liblatexila/latexila-latex-commands.c
+++ b/src/liblatexila/latexila-latex-commands.c
@@ -481,6 +481,76 @@ latex_command_tabular_cline_cb (GSimpleAction *action,
}
static void
+latex_command_presentation_frame_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+ gchar *indent;
+ gchar *text_before;
+
+ indent = get_indentation (tepl_window);
+ text_before = g_strdup_printf ("\\begin{frame}\n"
+ "%s\\frametitle{}\n"
+ "%s\\framesubtitle{}\n",
+ indent,
+ indent);
+
+ latexila_latex_commands_insert_text (tepl_window,
+ text_before,
+ "\n\\end{frame}",
+ NULL);
+
+ g_free (indent);
+ g_free (text_before);
+}
+
+static void
+latex_command_presentation_block_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+
+ latexila_latex_commands_insert_text (tepl_window,
+ "\\begin{block}{}\n",
+ "\n\\end{block}",
+ NULL);
+}
+
+static void
+latex_command_presentation_columns_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TeplApplicationWindow *tepl_window = TEPL_APPLICATION_WINDOW (user_data);
+ gchar *indent;
+ gchar *text_before;
+ gchar *text_after;
+
+ indent = get_indentation (tepl_window);
+
+ text_before = g_strdup_printf ("\\begin{columns}\n"
+ "%s\\begin{column}{.5\\textwidth}\n",
+ indent);
+
+ text_after = g_strdup_printf ("\n"
+ "%s\\end{column}\n"
+ "%s\\begin{column}{.5\\textwidth}\n\n"
+ "%s\\end{column}\n"
+ "\\end{columns}",
+ indent,
+ indent,
+ indent);
+
+ latexila_latex_commands_insert_text (tepl_window, text_before, text_after, NULL);
+
+ g_free (indent);
+ g_free (text_before);
+ g_free (text_after);
+}
+
+static void
latex_command_spacing_new_line_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -515,6 +585,9 @@ 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-presentation-frame", latex_command_presentation_frame_cb },
+ { "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 },
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]