[gnome-latex: 150/205] Edit toolbar: math
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 150/205] Edit toolbar: math
- Date: Fri, 14 Dec 2018 10:59:29 +0000 (UTC)
commit 9f582c5cf18561915e5e5be2e9fabf2e6fe2a6e2
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Sun Dec 20 22:31:55 2009 +0100
Edit toolbar: math
Maybe in the future there will be a separate math toolbar... For the
moment the toolitem is included in the edit toolbar.
TODO | 2 +-
data/images/icons/math-array.png | Bin 0 -> 469 bytes
data/images/icons/math-centered.png | Bin 0 -> 413 bytes
data/images/icons/math-frac.png | Bin 0 -> 391 bytes
data/images/icons/math-nth-root.png | Bin 0 -> 527 bytes
data/images/icons/math-numbered-array.png | Bin 0 -> 514 bytes
data/images/icons/math-numbered.png | Bin 0 -> 423 bytes
data/images/icons/math-square-root.png | Bin 0 -> 477 bytes
data/images/icons/math-subscript.png | Bin 0 -> 443 bytes
data/images/icons/math-superscript.png | Bin 0 -> 463 bytes
data/images/icons/math.png | Bin 0 -> 973 bytes
src/cb_latex.c | 167 ++++++++++++++++++++++++++++++
src/cb_latex.h | 29 ++++++
src/ui.c | 98 +++++++++++++++++-
src/ui.xml | 85 +++++++++++++++
15 files changed, 376 insertions(+), 5 deletions(-)
---
diff --git a/TODO b/TODO
index 1318773..a519994 100644
--- a/TODO
+++ b/TODO
@@ -2,6 +2,6 @@ TODO LaTeXila
[-] BibTeX support
-[-] math toolbar
+[-] preferences: GtkTable for the commands
[-] update French translation
diff --git a/data/images/icons/math-array.png b/data/images/icons/math-array.png
new file mode 100644
index 0000000..cbea7d6
Binary files /dev/null and b/data/images/icons/math-array.png differ
diff --git a/data/images/icons/math-centered.png b/data/images/icons/math-centered.png
new file mode 100644
index 0000000..31c1504
Binary files /dev/null and b/data/images/icons/math-centered.png differ
diff --git a/data/images/icons/math-frac.png b/data/images/icons/math-frac.png
new file mode 100644
index 0000000..a9a08ac
Binary files /dev/null and b/data/images/icons/math-frac.png differ
diff --git a/data/images/icons/math-nth-root.png b/data/images/icons/math-nth-root.png
new file mode 100644
index 0000000..409dd8d
Binary files /dev/null and b/data/images/icons/math-nth-root.png differ
diff --git a/data/images/icons/math-numbered-array.png b/data/images/icons/math-numbered-array.png
new file mode 100644
index 0000000..68f48a1
Binary files /dev/null and b/data/images/icons/math-numbered-array.png differ
diff --git a/data/images/icons/math-numbered.png b/data/images/icons/math-numbered.png
new file mode 100644
index 0000000..f63c391
Binary files /dev/null and b/data/images/icons/math-numbered.png differ
diff --git a/data/images/icons/math-square-root.png b/data/images/icons/math-square-root.png
new file mode 100644
index 0000000..8b31c10
Binary files /dev/null and b/data/images/icons/math-square-root.png differ
diff --git a/data/images/icons/math-subscript.png b/data/images/icons/math-subscript.png
new file mode 100644
index 0000000..2381f35
Binary files /dev/null and b/data/images/icons/math-subscript.png differ
diff --git a/data/images/icons/math-superscript.png b/data/images/icons/math-superscript.png
new file mode 100644
index 0000000..cbda109
Binary files /dev/null and b/data/images/icons/math-superscript.png differ
diff --git a/data/images/icons/math.png b/data/images/icons/math.png
new file mode 100644
index 0000000..a785b6a
Binary files /dev/null and b/data/images/icons/math.png differ
diff --git a/src/cb_latex.c b/src/cb_latex.c
index 9537fa2..b0e3ee9 100644
--- a/src/cb_latex.c
+++ b/src/cb_latex.c
@@ -404,3 +404,170 @@ cb_text_font_shape_small_caps (void)
text_buffer_insert ("{\\scshape ", "}", "\\scshape ");
}
+void
+cb_math_env_normal (void)
+{
+ text_buffer_insert ("$ ", " $", NULL);
+}
+
+void
+cb_math_env_centered (void)
+{
+ text_buffer_insert ("$$ ", " $$", NULL);
+}
+
+void
+cb_math_env_numbered (void)
+{
+ text_buffer_insert ("\\begin{equation}\n", "\n\\end{equation}", NULL);
+}
+
+void
+cb_math_env_array (void)
+{
+ text_buffer_insert ("\\begin{align*}\n", "\n\\end{align*}", NULL);
+}
+
+void
+cb_math_env_numbered_array (void)
+{
+ text_buffer_insert ("\\begin{align}\n", "\n\\end{align}", NULL);
+}
+
+void
+cb_math_superscript (void)
+{
+ text_buffer_insert ("^{", "}", NULL);
+}
+
+void
+cb_math_subscript (void)
+{
+ text_buffer_insert ("_{", "}", NULL);
+}
+
+void
+cb_math_frac (void)
+{
+ text_buffer_insert ("\\frac{", "}{}", NULL);
+}
+
+void
+cb_math_square_root (void)
+{
+ text_buffer_insert ("\\sqrt{", "}", NULL);
+}
+
+void
+cb_math_nth_root (void)
+{
+ text_buffer_insert ("\\sqrt[]{", "}", NULL);
+}
+
+void
+cb_math_left_delimiter_1 (void)
+{
+ text_buffer_insert ("\\left( ", "", NULL);
+}
+
+void
+cb_math_left_delimiter_2 (void)
+{
+ text_buffer_insert ("\\left[ ", "", NULL);
+}
+
+void
+cb_math_left_delimiter_3 (void)
+{
+ text_buffer_insert ("\\left\\lbrace ", "", NULL);
+}
+
+void
+cb_math_left_delimiter_4 (void)
+{
+ text_buffer_insert ("\\left\\langle ", "", NULL);
+}
+
+void
+cb_math_left_delimiter_5 (void)
+{
+ text_buffer_insert ("\\left) ", "", NULL);
+}
+
+void
+cb_math_left_delimiter_6 (void)
+{
+ text_buffer_insert ("\\left] ", "", NULL);
+}
+
+void
+cb_math_left_delimiter_7 (void)
+{
+ text_buffer_insert ("\\left\\rbrace ", "", NULL);
+}
+
+void
+cb_math_left_delimiter_8 (void)
+{
+ text_buffer_insert ("\\left\\rangle ", "", NULL);
+}
+
+void
+cb_math_left_delimiter_9 (void)
+{
+ text_buffer_insert ("\\left. ", "", NULL);
+}
+
+void
+cb_math_right_delimiter_1 (void)
+{
+ text_buffer_insert ("\\right( ", "", NULL);
+}
+
+void
+cb_math_right_delimiter_2 (void)
+{
+ text_buffer_insert ("\\right[ ", "", NULL);
+}
+
+void
+cb_math_right_delimiter_3 (void)
+{
+ text_buffer_insert ("\\right\\rbrace ", "", NULL);
+}
+
+void
+cb_math_right_delimiter_4 (void)
+{
+ text_buffer_insert ("\\right\\rangle ", "", NULL);
+}
+
+void
+cb_math_right_delimiter_5 (void)
+{
+ text_buffer_insert ("\\right) ", "", NULL);
+}
+
+void
+cb_math_right_delimiter_6 (void)
+{
+ text_buffer_insert ("\\right] ", "", NULL);
+}
+
+void
+cb_math_right_delimiter_7 (void)
+{
+ text_buffer_insert ("\\right\\lbrace ", "", NULL);
+}
+
+void
+cb_math_right_delimiter_8 (void)
+{
+ text_buffer_insert ("\\right\\langle ", "", NULL);
+}
+
+void
+cb_math_right_delimiter_9 (void)
+{
+ text_buffer_insert ("\\right. ", "", NULL);
+}
diff --git a/src/cb_latex.h b/src/cb_latex.h
index e2c73b9..7150d08 100644
--- a/src/cb_latex.h
+++ b/src/cb_latex.h
@@ -76,4 +76,33 @@ void cb_text_font_shape_italic (void);
void cb_text_font_shape_slanted (void);
void cb_text_font_shape_small_caps (void);
+void cb_math_env_normal (void);
+void cb_math_env_centered (void);
+void cb_math_env_numbered (void);
+void cb_math_env_array (void);
+void cb_math_env_numbered_array (void);
+void cb_math_superscript (void);
+void cb_math_subscript (void);
+void cb_math_frac (void);
+void cb_math_square_root (void);
+void cb_math_nth_root (void);
+void cb_math_left_delimiter_1 (void);
+void cb_math_left_delimiter_2 (void);
+void cb_math_left_delimiter_3 (void);
+void cb_math_left_delimiter_4 (void);
+void cb_math_left_delimiter_5 (void);
+void cb_math_left_delimiter_6 (void);
+void cb_math_left_delimiter_7 (void);
+void cb_math_left_delimiter_8 (void);
+void cb_math_left_delimiter_9 (void);
+void cb_math_right_delimiter_1 (void);
+void cb_math_right_delimiter_2 (void);
+void cb_math_right_delimiter_3 (void);
+void cb_math_right_delimiter_4 (void);
+void cb_math_right_delimiter_5 (void);
+void cb_math_right_delimiter_6 (void);
+void cb_math_right_delimiter_7 (void);
+void cb_math_right_delimiter_8 (void);
+void cb_math_right_delimiter_9 (void);
+
#endif /* CB_LATEX_H */
diff --git a/src/ui.c b/src/ui.c
index febd338..ea70654 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -62,6 +62,16 @@ static struct {
{DATA_DIR "/images/icons/list-description.png", "list-description"},
{DATA_DIR "/images/icons/list-item.png", "list-item"},
{DATA_DIR "/images/icons/references.png", "references"},
+ {DATA_DIR "/images/icons/math.png", "math"},
+ {DATA_DIR "/images/icons/math-centered.png", "math-centered"},
+ {DATA_DIR "/images/icons/math-numbered.png", "math-numbered"},
+ {DATA_DIR "/images/icons/math-array.png", "math-array"},
+ {DATA_DIR "/images/icons/math-numbered-array.png", "math-numbered-array"},
+ {DATA_DIR "/images/icons/math-superscript.png", "math-superscript"},
+ {DATA_DIR "/images/icons/math-subscript.png", "math-subscript"},
+ {DATA_DIR "/images/icons/math-frac.png", "math-frac"},
+ {DATA_DIR "/images/icons/math-square-root.png", "math-square-root"},
+ {DATA_DIR "/images/icons/math-nth-root.png", "math-nth-root"},
};
// all the actions (for the menu and the toolbar)
@@ -278,6 +288,67 @@ static GtkActionEntry latex_entries[] = {
N_("Slanted - \\slshape"), G_CALLBACK (cb_text_font_shape_slanted)},
{"FontShapeSmallCaps", NULL, N_("Small Capitals - \\scshape"), NULL,
N_("Small Capitals - \\scshape"), G_CALLBACK (cb_text_font_shape_small_caps)},
+
+ {"Math", "math", N_("Math"), NULL, NULL, NULL},
+ {"MathEnvironments", NULL, N_("Math Environments"), NULL, NULL, NULL},
+ {"MathEnvNormal", "math", N_("Mathematical Environment - $...$"), NULL,
+ N_("Mathematical Environment - $...$"), G_CALLBACK (cb_math_env_normal)},
+ {"MathEnvCentered", "math-centered", N_("Centered Formula - $$...$$"), NULL,
+ N_("Centered Formula - $$...$$"), G_CALLBACK (cb_math_env_centered)},
+ {"MathEnvNumbered", "math-numbered", N_("Numbered Equation - \\begin{equation}"), NULL,
+ N_("Numbered Equation - \\begin{equation}"), G_CALLBACK (cb_math_env_numbered)},
+ {"MathEnvArray", "math-array", N_("Array of Equations - \\begin{align*}"), NULL,
+ N_("Array of Equations - \\begin{align*}"), G_CALLBACK (cb_math_env_array)},
+ {"MathEnvNumberedArray", "math-numbered-array", N_("Numbered Array of Equations - \\begin{align}"),
NULL,
+ N_("Numbered Array of Equations - \\begin{align}"), G_CALLBACK (cb_math_env_numbered_array)},
+ {"MathSuperscript", "math-superscript", N_("Superscript - ^{}"), NULL,
+ N_("Superscript - ^{}"), G_CALLBACK (cb_math_superscript)},
+ {"MathSubscript", "math-subscript", N_("Subscript - __{}"), NULL,
+ N_("Subscript - __{}"), G_CALLBACK (cb_math_subscript)},
+ {"MathFrac", "math-frac", N_("Fraction - \\frac{}{}"), NULL,
+ N_("Fraction - \\frac{}{}"), G_CALLBACK (cb_math_frac)},
+ {"MathSquareRoot", "math-square-root", N_("Square Root - \\sqrt{}"), NULL,
+ N_("Square Root - \\sqrt{}"), G_CALLBACK (cb_math_square_root)},
+ {"MathNthRoot", "math-nth-root", N_("N-th Root - \\sqrt[]{}"), NULL,
+ N_("N-th Root - \\sqrt[]{}"), G_CALLBACK (cb_math_nth_root)},
+ {"MathLeftDelimiters", NULL, N_("Left Delimiters"), NULL, NULL, NULL},
+ {"MathLeftDelimiter1", NULL, N_("left ("), NULL,
+ NULL, G_CALLBACK (cb_math_left_delimiter_1)},
+ {"MathLeftDelimiter2", NULL, N_("left ["), NULL,
+ NULL, G_CALLBACK (cb_math_left_delimiter_2)},
+ {"MathLeftDelimiter3", NULL, N_("left {"), NULL,
+ NULL, G_CALLBACK (cb_math_left_delimiter_3)},
+ {"MathLeftDelimiter4", NULL, N_("left <"), NULL,
+ NULL, G_CALLBACK (cb_math_left_delimiter_4)},
+ {"MathLeftDelimiter5", NULL, N_("left )"), NULL,
+ NULL, G_CALLBACK (cb_math_left_delimiter_5)},
+ {"MathLeftDelimiter6", NULL, N_("left ]"), NULL,
+ NULL, G_CALLBACK (cb_math_left_delimiter_6)},
+ {"MathLeftDelimiter7", NULL, N_("left }"), NULL,
+ NULL, G_CALLBACK (cb_math_left_delimiter_7)},
+ {"MathLeftDelimiter8", NULL, N_("left >"), NULL,
+ NULL, G_CALLBACK (cb_math_left_delimiter_8)},
+ {"MathLeftDelimiter9", NULL, N_("left ."), NULL,
+ NULL, G_CALLBACK (cb_math_left_delimiter_9)},
+ {"MathRightDelimiters", NULL, N_("Right Delimiters"), NULL, NULL, NULL},
+ {"MathRightDelimiter1", NULL, N_("right )"), NULL,
+ NULL, G_CALLBACK (cb_math_right_delimiter_1)},
+ {"MathRightDelimiter2", NULL, N_("right ]"), NULL,
+ NULL, G_CALLBACK (cb_math_right_delimiter_2)},
+ {"MathRightDelimiter3", NULL, N_("right }"), NULL,
+ NULL, G_CALLBACK (cb_math_right_delimiter_3)},
+ {"MathRightDelimiter4", NULL, N_("right >"), NULL,
+ NULL, G_CALLBACK (cb_math_right_delimiter_4)},
+ {"MathRightDelimiter5", NULL, N_("right ("), NULL,
+ NULL, G_CALLBACK (cb_math_right_delimiter_5)},
+ {"MathRightDelimiter6", NULL, N_("right ["), NULL,
+ NULL, G_CALLBACK (cb_math_right_delimiter_6)},
+ {"MathRightDelimiter7", NULL, N_("right {"), NULL,
+ NULL, G_CALLBACK (cb_math_right_delimiter_7)},
+ {"MathRightDelimiter8", NULL, N_("right <"), NULL,
+ NULL, G_CALLBACK (cb_math_right_delimiter_8)},
+ {"MathRightDelimiter9", NULL, N_("right ."), NULL,
+ NULL, G_CALLBACK (cb_math_right_delimiter_9)},
};
// {name, stock_id, label, accelerator, tooltip, callback}
@@ -335,8 +406,7 @@ init_ui (GtkWidget *box)
// menus under toolitems
GtkAction *sectioning = tool_menu_action_new ("SectioningToolItem",
_("Sectioning"), _("Sectioning"), "sectioning-section");
- GtkToolItem *sectioning_menu_tool_button = gtk_menu_tool_button_new (NULL,
- NULL);
+ GtkToolItem *sectioning_menu_tool_button = gtk_menu_tool_button_new (NULL, NULL);
gtk_activatable_set_related_action (
GTK_ACTIVATABLE (sectioning_menu_tool_button), sectioning);
@@ -348,11 +418,28 @@ init_ui (GtkWidget *box)
GtkAction *references = tool_menu_action_new ("ReferencesToolItem",
_("References"), _("References"), "references");
- GtkToolItem *references_menu_tool_button = gtk_menu_tool_button_new (NULL,
- NULL);
+ GtkToolItem *references_menu_tool_button = gtk_menu_tool_button_new (NULL, NULL);
gtk_activatable_set_related_action (
GTK_ACTIVATABLE (references_menu_tool_button), references);
+ GtkAction *math_env = tool_menu_action_new ("MathEnvironmentsToolItem",
+ _("Math Environments"), _("Math Environments"), "math");
+ GtkToolItem *math_env_menu_tool_button = gtk_menu_tool_button_new (NULL, NULL);
+ gtk_activatable_set_related_action (
+ GTK_ACTIVATABLE (math_env_menu_tool_button), math_env);
+
+ GtkAction *math_left_del = tool_menu_action_new ("MathLeftDelimitersToolItem",
+ _("Left Delimiters"), _("Left Delimiters"), NULL);
+ GtkToolItem *math_left_del_menu_tool_button = gtk_menu_tool_button_new (NULL, NULL);
+ gtk_activatable_set_related_action (
+ GTK_ACTIVATABLE (math_left_del_menu_tool_button), math_left_del);
+
+ GtkAction *math_right_del = tool_menu_action_new ("MathRightDelimitersToolItem",
+ _("Right Delimiters"), _("Right Delimiters"), NULL);
+ GtkToolItem *math_right_del_menu_tool_button = gtk_menu_tool_button_new (NULL, NULL);
+ gtk_activatable_set_related_action (
+ GTK_ACTIVATABLE (math_right_del_menu_tool_button), math_right_del);
+
// create the action group and the ui manager
GtkActionGroup *action_group = gtk_action_group_new ("menuActionGroup");
#ifdef LATEXILA_NLS_ENABLED
@@ -361,6 +448,9 @@ init_ui (GtkWidget *box)
gtk_action_group_add_action (action_group, sectioning);
gtk_action_group_add_action (action_group, sizes);
gtk_action_group_add_action (action_group, references);
+ gtk_action_group_add_action (action_group, math_env);
+ gtk_action_group_add_action (action_group, math_left_del);
+ gtk_action_group_add_action (action_group, math_right_del);
gtk_action_group_add_actions (action_group, entries, nb_entries, NULL);
gtk_action_group_add_actions (action_group, latex_entries, nb_latex_entries,
NULL);
diff --git a/src/ui.xml b/src/ui.xml
index f020f82..17976b5 100644
--- a/src/ui.xml
+++ b/src/ui.xml
@@ -163,6 +163,46 @@ In the code, GtkUIManager is used to construct them.
<menuitem action="FontShapeSmallCaps" />
</menu>
</menu>
+
+ <menu action="Math">
+ <menu action="MathEnvironments">
+ <menuitem action="MathEnvNormal" />
+ <menuitem action="MathEnvCentered" />
+ <menuitem action="MathEnvNumbered" />
+ <menuitem action="MathEnvArray" />
+ <menuitem action="MathEnvNumberedArray" />
+ </menu>
+ <separator />
+ <menuitem action="MathSuperscript" />
+ <menuitem action="MathSubscript" />
+ <separator />
+ <menuitem action="MathFrac" />
+ <menuitem action="MathSquareRoot" />
+ <menuitem action="MathNthRoot" />
+ <separator />
+ <menu action="MathLeftDelimiters">
+ <menuitem action="MathLeftDelimiter1" />
+ <menuitem action="MathLeftDelimiter2" />
+ <menuitem action="MathLeftDelimiter3" />
+ <menuitem action="MathLeftDelimiter4" />
+ <menuitem action="MathLeftDelimiter5" />
+ <menuitem action="MathLeftDelimiter6" />
+ <menuitem action="MathLeftDelimiter7" />
+ <menuitem action="MathLeftDelimiter8" />
+ <menuitem action="MathLeftDelimiter9" />
+ </menu>
+ <menu action="MathRightDelimiters">
+ <menuitem action="MathRightDelimiter1" />
+ <menuitem action="MathRightDelimiter2" />
+ <menuitem action="MathRightDelimiter3" />
+ <menuitem action="MathRightDelimiter4" />
+ <menuitem action="MathRightDelimiter5" />
+ <menuitem action="MathRightDelimiter6" />
+ <menuitem action="MathRightDelimiter7" />
+ <menuitem action="MathRightDelimiter8" />
+ <menuitem action="MathRightDelimiter9" />
+ </menu>
+ </menu>
</menu>
<menu action="Tools">
@@ -267,5 +307,50 @@ In the code, GtkUIManager is used to construct them.
<toolitem action="ListEnvEnumerate" />
<toolitem action="ListEnvDescription" />
<toolitem action="ListEnvItem" />
+
+ <separator />
+
+ <toolitem action="MathEnvironmentsToolItem">
+ <menu action="MathEnvironments">
+ <menuitem action="MathEnvNormal" />
+ <menuitem action="MathEnvCentered" />
+ <menuitem action="MathEnvNumbered" />
+ <menuitem action="MathEnvArray" />
+ <menuitem action="MathEnvNumberedArray" />
+ </menu>
+ </toolitem>
+ <separator />
+ <toolitem action="MathSuperscript" />
+ <toolitem action="MathSubscript" />
+ <separator />
+ <toolitem action="MathFrac" />
+ <toolitem action="MathSquareRoot" />
+ <separator />
+ <toolitem action="MathLeftDelimitersToolItem">
+ <menu action="MathLeftDelimiters">
+ <menuitem action="MathLeftDelimiter1" />
+ <menuitem action="MathLeftDelimiter2" />
+ <menuitem action="MathLeftDelimiter3" />
+ <menuitem action="MathLeftDelimiter4" />
+ <menuitem action="MathLeftDelimiter5" />
+ <menuitem action="MathLeftDelimiter6" />
+ <menuitem action="MathLeftDelimiter7" />
+ <menuitem action="MathLeftDelimiter8" />
+ <menuitem action="MathLeftDelimiter9" />
+ </menu>
+ </toolitem>
+ <toolitem action="MathRightDelimitersToolItem">
+ <menu action="MathRightDelimiters">
+ <menuitem action="MathRightDelimiter1" />
+ <menuitem action="MathRightDelimiter2" />
+ <menuitem action="MathRightDelimiter3" />
+ <menuitem action="MathRightDelimiter4" />
+ <menuitem action="MathRightDelimiter5" />
+ <menuitem action="MathRightDelimiter6" />
+ <menuitem action="MathRightDelimiter7" />
+ <menuitem action="MathRightDelimiter8" />
+ <menuitem action="MathRightDelimiter9" />
+ </menu>
+ </toolitem>
</toolbar>
</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]