[gnome-latex: 64/205] Menu: LaTeX: Font Styles



commit 6535feea40ffbb7d63ef3396193c59a8fd77c3e5
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date:   Mon Sep 14 23:53:13 2009 +0200

    Menu: LaTeX: Font Styles

 TODO            |  2 +-
 src/callbacks.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 src/callbacks.h | 14 ++++++++-
 src/ui.c        | 38 +++++++++++++++++++++-
 src/ui.xml      | 32 ++++++++++++++++++-
 5 files changed, 173 insertions(+), 11 deletions(-)
---
diff --git a/TODO b/TODO
index 7f2b655..810f263 100644
--- a/TODO
+++ b/TODO
@@ -15,8 +15,8 @@ Wed Sep 9, 2009 to Wed Sep 16, 2009
 
 [-] new toolbar
        x bold, italic, typewriter, underline
+       x font styles
        - structure: part, chapter, section, subsection, subsubsection, paragraph, subparagraph
-       - font styles
        - size of characters
        - center
        - lists: itemize, enumerate, description
diff --git a/src/callbacks.c b/src/callbacks.c
index efe97e7..7a9f9b5 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -52,7 +52,8 @@ static gboolean find_next_match (const gchar *what, GtkSourceSearchFlags flags,
 static void change_font_source_view (void);
 static void create_preferences (void);
 static void free_latexila (void);
-static void text_buffer_insert (gchar *text_before, gchar *text_after);
+static void text_buffer_insert (gchar *text_before, gchar *text_after,
+               gchar *text_if_no_selection);
 
 static GtkWidget *pref_dialog = NULL;
 
@@ -861,7 +862,8 @@ cb_show_symbol_tables (GtkToggleAction *toggle_action, gpointer user_data)
 }
 
 static void
-text_buffer_insert (gchar *text_before, gchar *text_after)
+text_buffer_insert (gchar *text_before, gchar *text_after,
+               gchar *text_if_no_selection)
 {
        if (latexila.active_doc == NULL)
                return;
@@ -892,7 +894,11 @@ text_buffer_insert (gchar *text_before, gchar *text_after)
                gtk_text_buffer_select_range (buffer, &end, &end);
        }
 
-       // no text is selected
+       // no selection
+       else if (text_if_no_selection != NULL)
+               gtk_text_buffer_insert_at_cursor (buffer, text_if_no_selection, -1);
+
+       // no selection
        // move the cursor between the 2 texts inserted
        else
        {
@@ -916,25 +922,103 @@ text_buffer_insert (gchar *text_before, gchar *text_after)
 void
 cb_text_bold (void)
 {
-       text_buffer_insert ("\\textbf{", "}");
+       text_buffer_insert ("\\textbf{", "}", NULL);
 }
 
 void
 cb_text_italic (void)
 {
-       text_buffer_insert ("\\textit{", "}");
+       text_buffer_insert ("\\textit{", "}", NULL);
 }
 
 void
 cb_text_typewriter (void)
 {
-       text_buffer_insert ("\\texttt{", "}");
+       text_buffer_insert ("\\texttt{", "}", NULL);
 }
 
 void
 cb_text_underline (void)
 {
-       text_buffer_insert ("\\underline{", "}");
+       text_buffer_insert ("\\underline{", "}", NULL);
+}
+
+void
+cb_text_slanted (void)
+{
+       text_buffer_insert ("\\textsl{", "}", NULL);
+}
+
+void
+cb_text_small_caps (void)
+{
+       text_buffer_insert ("\\textsc{", "}", NULL);
+}
+
+void
+cb_text_emph (void)
+{
+       text_buffer_insert ("\\emph{", "}", NULL);
+}
+
+void
+cb_text_strong (void)
+{
+       text_buffer_insert ("\\strong{", "}", NULL);
+}
+
+void
+cb_text_font_family_roman (void)
+{
+       text_buffer_insert ("{\\rmfamily ", "}", "\\rmfamily ");
+}
+
+void
+cb_text_font_family_sans_serif (void)
+{
+       text_buffer_insert ("{\\sffamily ", "}", "\\sffamily ");
+}
+
+void
+cb_text_font_family_monospace (void)
+{
+       text_buffer_insert ("{\\ttfamily ", "}", "\\ttfamily ");
+}
+
+void
+cb_text_font_series_medium (void)
+{
+       text_buffer_insert ("{\\mdseries ", "}", "\\mdseries ");
+}
+
+void
+cb_text_font_series_bold (void)
+{
+       text_buffer_insert ("{\\bfseries ", "}", "\\bfseries ");
+}
+
+void
+cb_text_font_shape_upright (void)
+{
+       text_buffer_insert ("{\\upshape ", "}", "\\upshape ");
+}
+
+void
+cb_text_font_shape_italic (void)
+{
+       text_buffer_insert ("{\\itshape ", "}", "\\itshape ");
+}
+
+void
+cb_text_font_shape_slanted (void)
+{
+       text_buffer_insert ("{\\slshape ", "}", "\\slshape ");
+}
+
+void
+cb_text_font_shape_small_caps (void)
+{
+       text_buffer_insert ("{\\scshape ", "}", "\\scshape ");
 }
 
 void
diff --git a/src/callbacks.h b/src/callbacks.h
index 12878e2..735cdc6 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -67,11 +67,23 @@ void cb_category_symbols_selected (GtkIconView *icon_view, gpointer user_data);
 void cb_symbol_selected (GtkIconView *icon_view, gpointer user_data);
 void cb_show_symbol_tables (GtkToggleAction *toggle_action, gpointer user_data);
 
-// edit toolbar
 void cb_text_bold (void);
 void cb_text_italic (void);
 void cb_text_typewriter (void);
 void cb_text_underline (void);
+void cb_text_slanted (void);
+void cb_text_small_caps (void);
+void cb_text_emph (void);
+void cb_text_strong (void);
+void cb_text_font_family_roman (void);
+void cb_text_font_family_sans_serif (void);
+void cb_text_font_family_monospace (void);
+void cb_text_font_series_medium (void);
+void cb_text_font_series_bold (void);
+void cb_text_font_shape_upright (void);
+void cb_text_font_shape_italic (void);
+void cb_text_font_shape_slanted (void);
+void cb_text_font_shape_small_caps (void);
 
 void open_new_document (const gchar *filename, const gchar *uri);
 
diff --git a/src/ui.c b/src/ui.c
index 983471e..21a2466 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -121,6 +121,9 @@ static GtkActionEntry entries[] = {
 
 // {name, stock_id, label, accelerator, tooltip, callback}
 static GtkActionEntry edit_entries[] = {
+       {"Latex", NULL, N_("LaTeX"), NULL, NULL, NULL},
+
+       {"FontStyles", NULL, N_("Font Styles"), NULL, NULL, NULL},
        {"Bold", "bold", N_("Bold - \\textbf{}"), NULL,
                N_("Bold - \\textbf{}"), G_CALLBACK (cb_text_bold)},
        {"Italic", "italic", N_("Italic - \\textit{}"), NULL,
@@ -128,7 +131,40 @@ static GtkActionEntry edit_entries[] = {
        {"Typewriter", "typewriter", N_("Typewriter - \\texttt{}"), NULL,
                N_("Typewriter - \\texttt{}"), G_CALLBACK (cb_text_typewriter)},
        {"Underline", "underline", N_("Underline - \\underline{}"), NULL,
-               N_("Underline - \\underline{}"), G_CALLBACK (cb_text_underline)}
+               N_("Underline - \\underline{}"), G_CALLBACK (cb_text_underline)},
+       {"Slanted", NULL, N_("Slanted - \\textsl{}"), NULL,
+               N_("Slanted - \\textsl{}"), G_CALLBACK (cb_text_slanted)},
+       {"SmallCaps", NULL, N_("Small Capitals - \\textsc{}"), NULL,
+               N_("Small Capitals - \\textsc{}"), G_CALLBACK (cb_text_small_caps)},
+       {"Emph", NULL, N_("Emphasized - \\emph{}"), NULL,
+               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)},
+       {"FontFamilySansSerif", NULL, N_("Sans Serif - \\sffamily"), NULL,
+               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)},
+       {"FontShapeItalic", NULL, N_("Italic - \\itshape"), NULL,
+               N_("Italic - \\itshape"), G_CALLBACK (cb_text_font_shape_italic)},
+       {"FontShapeSlanted", NULL, N_("Slanted - \\slshape"), NULL,
+               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)}
+
 };
 
 // {name, stock_id, label, accelerator, tooltip, callback}
diff --git a/src/ui.xml b/src/ui.xml
index 80b157f..dbd6082 100644
--- a/src/ui.xml
+++ b/src/ui.xml
@@ -46,7 +46,7 @@ In the code, GtkUIManager is used to construct them.
       <menuitem action="EditDelete" />
       <separator />
       <menuitem action="EditSelectAll" />
-         <menuitem action="EditPreferences" />
+      <menuitem action="EditPreferences" />
     </menu>
 
     <menu action="View">
@@ -73,6 +73,36 @@ In the code, GtkUIManager is used to construct them.
       <menuitem action="DVItoPS" />
       <menuitem action="viewPS" />
     </menu>
+
+    <menu action="Latex">
+      <menu action="FontStyles">
+        <menuitem action="Bold" />
+        <menuitem action="Italic" />
+        <menuitem action="Typewriter" />
+        <menuitem action="Underline" />
+        <menuitem action="Slanted" />
+        <menuitem action="SmallCaps" />
+        <separator />
+        <menuitem action="Emph" />
+        <menuitem action="Strong" />
+        <separator />
+        <menu action="FontFamily">
+          <menuitem action="FontFamilyRoman" />
+          <menuitem action="FontFamilySansSerif" />
+          <menuitem action="FontFamilyMonospace" />
+        </menu>
+        <menu action="FontSeries">
+          <menuitem action="FontSeriesMedium" />
+          <menuitem action="FontSeriesBold" />
+        </menu>
+        <menu action="FontShape">
+          <menuitem action="FontShapeUpright" />
+          <menuitem action="FontShapeItalic" />
+          <menuitem action="FontShapeSlanted" />
+          <menuitem action="FontShapeSmallCaps" />
+        </menu>
+      </menu>
+    </menu>
     
     <menu action="Help">
       <menuitem action="HelpAbout" />


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]