[gnome-latex: 66/205] Menu: LaTeX: Sectioning
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 66/205] Menu: LaTeX: Sectioning
- Date: Fri, 14 Dec 2018 10:52:26 +0000 (UTC)
commit 7c1f42b948510d533b6bb19e323b69e9b10c27e0
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Fri Sep 18 00:17:33 2009 +0200
Menu: LaTeX: Sectioning
The sectioning menu contain: part, chapter, section, subsection,
subsubsection, paragraph and subparagraph.
For inserting the menu into the toolbar it was more complicated than
expicted... There is now a composite widget called ToolMenuAction
(implemented in tool_menu_action.*). This widget is a derived class of
GtkAction, and sets GtkActionClass:toolbar_item_type to
GTK_TYPE_MENU_TOOL_BUTTON in the class_init function.
TODO | 4 +-
images/icons/sectioning-chapter.png | Bin 0 -> 471 bytes
images/icons/sectioning-paragraph.png | Bin 0 -> 499 bytes
images/icons/sectioning-part.png | Bin 0 -> 445 bytes
images/icons/sectioning-section.png | Bin 0 -> 478 bytes
images/icons/sectioning-subsection.png | Bin 0 -> 484 bytes
images/icons/sectioning-subsubsection.png | Bin 0 -> 485 bytes
src/CMakeLists.txt | 17 ++--
src/cb_latex.c | 126 ++++++++++++++++++++----------
src/cb_latex.h | 24 ++++--
src/tool_menu_action.c | 59 ++++++++++++++
src/tool_menu_action.h | 33 ++++++++
src/ui.c | 68 +++++++++++-----
src/ui.xml | 24 ++++++
14 files changed, 276 insertions(+), 79 deletions(-)
---
diff --git a/TODO b/TODO
index d1c04c2..ad6293a 100644
--- a/TODO
+++ b/TODO
@@ -16,10 +16,10 @@ Wed Sep 9, 2009 to Wed Sep 16, 2009
[x] open recent
x when "save as", add the file to the recent manager
-[-] new toolbar
+[-] LaTeX menu + new toolbar
x font styles: bold, italic, ...
x environments: center, flushleft, ...
- - structures: part, chapter, section, ...
+ - sectioning: part, chapter, section, ...
- size of characters
- lists: itemize, enumerate, description
- various: label, ref, pageref, cite, footnote, index
diff --git a/images/icons/sectioning-chapter.png b/images/icons/sectioning-chapter.png
new file mode 100644
index 0000000..d884ceb
Binary files /dev/null and b/images/icons/sectioning-chapter.png differ
diff --git a/images/icons/sectioning-paragraph.png b/images/icons/sectioning-paragraph.png
new file mode 100644
index 0000000..1a52ed5
Binary files /dev/null and b/images/icons/sectioning-paragraph.png differ
diff --git a/images/icons/sectioning-part.png b/images/icons/sectioning-part.png
new file mode 100644
index 0000000..ef60aaa
Binary files /dev/null and b/images/icons/sectioning-part.png differ
diff --git a/images/icons/sectioning-section.png b/images/icons/sectioning-section.png
new file mode 100644
index 0000000..199da18
Binary files /dev/null and b/images/icons/sectioning-section.png differ
diff --git a/images/icons/sectioning-subsection.png b/images/icons/sectioning-subsection.png
new file mode 100644
index 0000000..52b6c84
Binary files /dev/null and b/images/icons/sectioning-subsection.png differ
diff --git a/images/icons/sectioning-subsubsection.png b/images/icons/sectioning-subsubsection.png
new file mode 100644
index 0000000..6833df9
Binary files /dev/null and b/images/icons/sectioning-subsubsection.png differ
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b46845f..91b3da0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,11 +1,12 @@
-SET(latexila_src main.c main.h
- callbacks.c callbacks.h
- cb_latex.c cb_latex.h
- print.c print.h
- symbols.c symbols.h
- actions.c actions.h
- prefs.c prefs.h
- ui.c ui.h)
+SET(latexila_src main.c main.h
+ callbacks.c callbacks.h
+ cb_latex.c cb_latex.h
+ print.c print.h
+ symbols.c symbols.h
+ actions.c actions.h
+ prefs.c prefs.h
+ ui.c ui.h
+ tool_menu_action.c tool_menu_action.h)
ADD_EXECUTABLE(latexila ${latexila_src})
TARGET_LINK_LIBRARIES(latexila ${GTK2_LIBRARIES})
diff --git a/src/cb_latex.c b/src/cb_latex.c
index c579baf..7c009b7 100644
--- a/src/cb_latex.c
+++ b/src/cb_latex.c
@@ -87,6 +87,90 @@ text_buffer_insert (gchar *text_before, gchar *text_after,
gtk_text_buffer_end_user_action (buffer);
}
+void
+cb_sectioning_part (void)
+{
+ text_buffer_insert ("\\part{", "}", NULL);
+}
+
+void
+cb_sectioning_chapter (void)
+{
+ text_buffer_insert ("\\chapter{", "}", NULL);
+}
+
+void
+cb_sectioning_section (void)
+{
+ text_buffer_insert ("\\section{", "}", NULL);
+}
+
+void
+cb_sectioning_subsection (void)
+{
+ text_buffer_insert ("\\subsection{", "}", NULL);
+}
+
+void
+cb_sectioning_subsubsection (void)
+{
+ text_buffer_insert ("\\subsubsection{", "}", NULL);
+}
+
+void
+cb_sectioning_paragraph (void)
+{
+ text_buffer_insert ("\\paragraph{", "}", NULL);
+}
+
+void
+cb_sectioning_subparagraph (void)
+{
+ text_buffer_insert ("\\subparagraph{", "}", NULL);
+}
+
+void
+cb_env_center (void)
+{
+ text_buffer_insert ("\\begin{center}\n", "\n\\end{center}", NULL);
+}
+
+void
+cb_env_left (void)
+{
+ text_buffer_insert ("\\begin{flushleft}\n", "\n\\end{flushleft}", NULL);
+}
+
+void
+cb_env_right (void)
+{
+ text_buffer_insert ("\\begin{flushright}\n", "\n\\end{flushright}", NULL);
+}
+
+void
+cb_env_minipage (void)
+{
+ text_buffer_insert ("\\begin{minipage}\n", "\n\\end{minipage}", NULL);
+}
+
+void
+cb_env_quote (void)
+{
+ text_buffer_insert ("\\begin{quote}\n", "\n\\end{quote}", NULL);
+}
+
+void
+cb_env_quotation (void)
+{
+ text_buffer_insert ("\\begin{quotation}\n", "\n\\end{quotation}", NULL);
+}
+
+void
+cb_env_verse (void)
+{
+ text_buffer_insert ("\\begin{verse}\n", "\n\\end{verse}", NULL);
+}
+
void
cb_text_bold (void)
{
@@ -189,45 +273,3 @@ cb_text_font_shape_small_caps (void)
text_buffer_insert ("{\\scshape ", "}", "\\scshape ");
}
-void
-cb_env_center (void)
-{
- text_buffer_insert ("\\begin{center}\n", "\n\\end{center}", NULL);
-}
-
-void
-cb_env_left (void)
-{
- text_buffer_insert ("\\begin{flushleft}\n", "\n\\end{flushleft}", NULL);
-}
-
-void
-cb_env_right (void)
-{
- text_buffer_insert ("\\begin{flushright}\n", "\n\\end{flushright}", NULL);
-}
-
-void
-cb_env_minipage (void)
-{
- text_buffer_insert ("\\begin{minipage}\n", "\n\\end{minipage}", NULL);
-}
-
-void
-cb_env_quote (void)
-{
- text_buffer_insert ("\\begin{quote}\n", "\n\\end{quote}", NULL);
-}
-
-void
-cb_env_quotation (void)
-{
- text_buffer_insert ("\\begin{quotation}\n", "\n\\end{quotation}", NULL);
-}
-
-void
-cb_env_verse (void)
-{
- text_buffer_insert ("\\begin{verse}\n", "\n\\end{verse}", NULL);
-}
-
diff --git a/src/cb_latex.h b/src/cb_latex.h
index 362bd77..4fed764 100644
--- a/src/cb_latex.h
+++ b/src/cb_latex.h
@@ -1,6 +1,22 @@
#ifndef CB_LATEX_H
#define CB_LATEX_H
+void cb_sectioning_part (void);
+void cb_sectioning_chapter (void);
+void cb_sectioning_section (void);
+void cb_sectioning_subsection (void);
+void cb_sectioning_subsubsection (void);
+void cb_sectioning_paragraph (void);
+void cb_sectioning_subparagraph (void);
+
+void cb_env_center (void);
+void cb_env_left (void);
+void cb_env_right (void);
+void cb_env_minipage (void);
+void cb_env_quote (void);
+void cb_env_quotation (void);
+void cb_env_verse (void);
+
void cb_text_bold (void);
void cb_text_italic (void);
void cb_text_typewriter (void);
@@ -19,12 +35,4 @@ void cb_text_font_shape_italic (void);
void cb_text_font_shape_slanted (void);
void cb_text_font_shape_small_caps (void);
-void cb_env_center (void);
-void cb_env_left (void);
-void cb_env_right (void);
-void cb_env_minipage (void);
-void cb_env_quote (void);
-void cb_env_quotation (void);
-void cb_env_verse (void);
-
#endif /* CB_LATEX_H */
diff --git a/src/tool_menu_action.c b/src/tool_menu_action.c
new file mode 100644
index 0000000..9cfea61
--- /dev/null
+++ b/src/tool_menu_action.c
@@ -0,0 +1,59 @@
+#include <gtk/gtkmenutoolbutton.h>
+#include "tool_menu_action.h"
+
+static void tool_menu_action_init (ToolMenuAction *tma);
+static void tool_menu_action_class_init (ToolMenuActionClass *klass);
+
+GType
+tool_menu_action_get_type (void)
+{
+ static GType type = 0;
+ if (! type)
+ {
+ static const GTypeInfo type_info =
+ {
+ sizeof (ToolMenuActionClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) tool_menu_action_class_init,
+ NULL,
+ NULL,
+ sizeof (ToolMenuAction),
+ 0,
+ (GInstanceInitFunc) tool_menu_action_init,
+ NULL
+ };
+
+ type = g_type_register_static (GTK_TYPE_ACTION, "ToolMenuAction",
+ &type_info, 0);
+ }
+
+ return type;
+}
+
+static void
+tool_menu_action_class_init (ToolMenuActionClass *klass)
+{
+ GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
+ action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
+}
+
+static void
+tool_menu_action_init (ToolMenuAction *tma)
+{
+}
+
+GtkAction *
+tool_menu_action_new (const gchar *name, const gchar *label,
+ const gchar *tooltip, const gchar *stock_id)
+{
+ g_return_val_if_fail (name != NULL, NULL);
+
+ return g_object_new (TYPE_TOOL_MENU_ACTION,
+ "name", name,
+ "label", label,
+ "tooltip", tooltip,
+ "stock-id", stock_id,
+ NULL);
+}
+
diff --git a/src/tool_menu_action.h b/src/tool_menu_action.h
new file mode 100644
index 0000000..a6d6b68
--- /dev/null
+++ b/src/tool_menu_action.h
@@ -0,0 +1,33 @@
+#ifndef __TOOL_MENU_ACTION_H__
+#define __TOOL_MENU_ACTION_H__
+
+#include <gtk/gtkaction.h>
+
+G_BEGIN_DECLS
+
+#define TYPE_TOOL_MENU_ACTION (tool_menu_action_get_type ())
+#define TOOL_MENU_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
TYPE_TOOL_MENU_ACTION, ToolMenuAction))
+#define TOOL_MENU_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TOOL_MENU_ACTION,
ToolMenuActionClass))
+#define IS_TOOL_MENU_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
TYPE_TOOL_MENU_ACTION))
+#define IS_TOOL_MENU_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TOOL_MENU_ACTION))
+
+typedef struct _ToolMenuAction ToolMenuAction;
+typedef struct _ToolMenuActionClass ToolMenuActionClass;
+
+struct _ToolMenuAction
+{
+ GtkAction parent_instance;
+};
+
+struct _ToolMenuActionClass
+{
+ GtkActionClass parent_class;
+};
+
+GType tool_menu_action_get_type (void);
+GtkAction * tool_menu_action_new (const gchar *name, const gchar *label,
+ const gchar *tooltip, const gchar *stock_id);
+
+G_END_DECLS
+
+#endif /* __TOOL_MENU_ACTION_H__ */
diff --git a/src/ui.c b/src/ui.c
index 8175930..e695f35 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -29,6 +29,7 @@
#include "print.h"
#include "callbacks.h"
#include "cb_latex.h"
+#include "tool_menu_action.h"
static void register_my_stock_icons (void);
@@ -50,6 +51,12 @@ static struct {
{DATA_DIR "/images/icons/justify-center.png", "justify_center"},
{DATA_DIR "/images/icons/justify-left.png", "justify_left"},
{DATA_DIR "/images/icons/justify-right.png", "justify_right"},
+ {DATA_DIR "/images/icons/sectioning-part.png", "sectioning-part"},
+ {DATA_DIR "/images/icons/sectioning-chapter.png", "sectioning-chapter"},
+ {DATA_DIR "/images/icons/sectioning-section.png", "sectioning-section"},
+ {DATA_DIR "/images/icons/sectioning-subsection.png", "sectioning-subsection"},
+ {DATA_DIR "/images/icons/sectioning-subsubsection.png", "sectioning-subsubsection"},
+ {DATA_DIR "/images/icons/sectioning-paragraph.png", "sectioning-paragraph"},
};
// all the actions (for the menu and the toolbar)
@@ -127,6 +134,38 @@ static GtkActionEntry entries[] = {
static GtkActionEntry latex_entries[] = {
{"Latex", NULL, N_("LaTeX"), NULL, NULL, NULL},
+ {"Sectioning", NULL, N_("Sectioning"), NULL, NULL, NULL},
+ {"SectioningPart", "sectioning-part", N_("part"), NULL,
+ N_("part"), G_CALLBACK (cb_sectioning_part)},
+ {"SectioningChapter", "sectioning-chapter", N_("chapter"), NULL,
+ N_("chapter"), G_CALLBACK (cb_sectioning_chapter)},
+ {"SectioningSection", "sectioning-section", N_("section"), NULL,
+ N_("section"), G_CALLBACK (cb_sectioning_section)},
+ {"SectioningSubsection", "sectioning-subsection", N_("subsection"), NULL,
+ N_("subsection"), G_CALLBACK (cb_sectioning_subsection)},
+ {"SectioningSubsubsection", "sectioning-subsubsection", N_("subsubsection"), NULL,
+ N_("subsubsection"), G_CALLBACK (cb_sectioning_subsubsection)},
+ {"SectioningParagraph", "sectioning-paragraph", N_("paragraph"), NULL,
+ N_("paragraph"), G_CALLBACK (cb_sectioning_paragraph)},
+ {"SectioningSubparagraph", "sectioning-paragraph", N_("subparagraph"), NULL,
+ N_("subparagraph"), G_CALLBACK (cb_sectioning_subparagraph)},
+
+ {"Environments", NULL, N_("Environments"), NULL, NULL, NULL},
+ {"EnvironmentCenter", "justify_center", N_("Center - \\begin{center}"), NULL,
+ N_("Center - \\begin{center}"), G_CALLBACK (cb_env_center)},
+ {"EnvironmentLeft", "justify_left", N_("Align Left - \\begin{flushleft}"), NULL,
+ N_("Align Left - \\begin{flushleft}"), G_CALLBACK (cb_env_left)},
+ {"EnvironmentRight", "justify_right", N_("Align Right - \\begin{flushright}"), NULL,
+ N_("Align Right - \\begin{flushright}"), G_CALLBACK (cb_env_right)},
+ {"EnvironmentMinipage", NULL, N_("Minipage - \\begin{minipage}"), NULL,
+ N_("Minipage - \\begin{minipage}"), G_CALLBACK (cb_env_minipage)},
+ {"EnvironmentQuote", NULL, N_("Quote - \\begin{quote}"), NULL,
+ N_("Quote - \\begin{quote}"), G_CALLBACK (cb_env_quote)},
+ {"EnvironmentQuotation", NULL, N_("Quotation - \\begin{quotation}"), NULL,
+ N_("Quotation - \\begin{quotation}"), G_CALLBACK (cb_env_quotation)},
+ {"EnvironmentVerse", NULL, N_("Verse - \\begin{verse}"), NULL,
+ N_("Verse - \\begin{verse}"), G_CALLBACK (cb_env_verse)},
+
{"FontStyles", NULL, N_("Font Styles"), NULL, NULL, NULL},
{"Bold", "bold", N_("Bold - \\textbf{}"), NULL,
N_("Bold - \\textbf{}"), G_CALLBACK (cb_text_bold)},
@@ -144,7 +183,6 @@ static GtkActionEntry latex_entries[] = {
N_("Emphasized - \\emph{}"), G_CALLBACK (cb_text_emph)},
{"Strong", NULL, N_("Strong - \\strong{}"), NULL,
N_("Strong - \\strong{}"), G_CALLBACK (cb_text_strong)},
-
{"FontFamily", NULL, N_("Font Family"), NULL, NULL, NULL},
{"FontFamilyRoman", NULL, N_("Roman - \\rmfamily"), NULL,
N_("Roman - \\rmfamily"), G_CALLBACK (cb_text_font_family_roman)},
@@ -152,13 +190,11 @@ static GtkActionEntry latex_entries[] = {
N_("Sans Serif - \\sffamily"), G_CALLBACK (cb_text_font_family_sans_serif)},
{"FontFamilyMonospace", NULL, N_("Monospace - \\ttfamily"), NULL,
N_("Monospace - \\ttfamily"), G_CALLBACK (cb_text_font_family_monospace)},
-
{"FontSeries", NULL, N_("Font Series"), NULL, NULL, NULL},
{"FontSeriesMedium", NULL, N_("Medium - \\mdseries"), NULL,
N_("Medium - \\mdseries"), G_CALLBACK (cb_text_font_series_medium)},
{"FontSeriesBold", NULL, N_("Bold - \\bfseries"), NULL,
N_("Bold - \\bfseries"), G_CALLBACK (cb_text_font_series_bold)},
-
{"FontShape", NULL, N_("Font Shape"), NULL, NULL, NULL},
{"FontShapeUpright", NULL, N_("Upright - \\upshape"), NULL,
N_("Upright - \\upshape"), G_CALLBACK (cb_text_font_shape_upright)},
@@ -168,22 +204,6 @@ 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)},
-
- {"Environments", NULL, N_("Environments"), NULL, NULL, NULL},
- {"EnvironmentCenter", "justify_center", N_("Center - \\begin{center}"), NULL,
- N_("Center - \\begin{center}"), G_CALLBACK (cb_env_center)},
- {"EnvironmentLeft", "justify_left", N_("Align Left - \\begin{flushleft}"), NULL,
- N_("Align Left - \\begin{flushleft}"), G_CALLBACK (cb_env_left)},
- {"EnvironmentRight", "justify_right", N_("Align Right - \\begin{flushright}"), NULL,
- N_("Align Right - \\begin{flushright}"), G_CALLBACK (cb_env_right)},
- {"EnvironmentMinipage", NULL, N_("Minipage - \\begin{minipage}"), NULL,
- N_("Minipage - \\begin{minipage}"), G_CALLBACK (cb_env_minipage)},
- {"EnvironmentQuote", NULL, N_("Quote - \\begin{quote}"), NULL,
- N_("Quote - \\begin{quote}"), G_CALLBACK (cb_env_quote)},
- {"EnvironmentQuotation", NULL, N_("Quotation - \\begin{quotation}"), NULL,
- N_("Quotation - \\begin{quotation}"), G_CALLBACK (cb_env_quotation)},
- {"EnvironmentVerse", NULL, N_("Verse - \\begin{verse}"), NULL,
- N_("Verse - \\begin{verse}"), G_CALLBACK (cb_env_verse)}
};
// {name, stock_id, label, accelerator, tooltip, callback}
@@ -235,11 +255,21 @@ init_ui (GtkWidget *box)
gtk_recent_filter_add_application (filter, "latexila");
gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (recent), filter);
+ // 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);
+ gtk_activatable_set_related_action (
+ GTK_ACTIVATABLE (sectioning_menu_tool_button),
+ sectioning);
+
// create the action group and the ui manager
GtkActionGroup *action_group = gtk_action_group_new ("menuActionGroup");
#ifdef LATEXILA_NLS_ENABLED
gtk_action_group_set_translation_domain (action_group, LATEXILA_NLS_PACKAGE);
#endif
+ gtk_action_group_add_action (action_group, sectioning);
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 0a29288..e69add9 100644
--- a/src/ui.xml
+++ b/src/ui.xml
@@ -75,6 +75,17 @@ In the code, GtkUIManager is used to construct them.
</menu>
<menu action="Latex">
+ <menu action="Sectioning">
+ <menuitem action="SectioningPart" />
+ <menuitem action="SectioningChapter" />
+ <separator />
+ <menuitem action="SectioningSection" />
+ <menuitem action="SectioningSubsection" />
+ <menuitem action="SectioningSubsubsection" />
+ <menuitem action="SectioningParagraph" />
+ <menuitem action="SectioningSubparagraph" />
+ </menu>
+
<menu action="Environments">
<menuitem action="EnvironmentCenter" />
<menuitem action="EnvironmentLeft" />
@@ -151,5 +162,18 @@ In the code, GtkUIManager is used to construct them.
<toolitem action="Underline" />
<separator />
<toolitem action="EnvironmentCenter" />
+ <separator />
+ <toolitem action="SectioningToolItem">
+ <menu action="Sectioning">
+ <menuitem action="SectioningPart" />
+ <menuitem action="SectioningChapter" />
+ <separator />
+ <menuitem action="SectioningSection" />
+ <menuitem action="SectioningSubsection" />
+ <menuitem action="SectioningSubsubsection" />
+ <menuitem action="SectioningParagraph" />
+ <menuitem action="SectioningSubparagraph" />
+ </menu>
+ </toolitem>
</toolbar>
</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]