[gnome-latex: 17/205] font for the source view: Monospace



commit 378a242d46d417d277b437bcde61fc8cf675b496
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date:   Thu Aug 6 14:02:45 2009 +0200

    font for the source view: Monospace

 TODO            |  1 +
 src/callbacks.c | 30 ++++++++++++++++++++++++++++++
 src/callbacks.h |  1 +
 src/main.c      |  6 ++++--
 src/main.h      |  3 +++
 5 files changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/TODO b/TODO
index fedeb8f..5d03c2c 100644
--- a/TODO
+++ b/TODO
@@ -18,4 +18,5 @@ Jul 31, 2009 to Aug 7, 2009
        x syntaxic color
        x show/hide line numbers
        x undo/redo
+       x font monospace
 
diff --git a/src/callbacks.c b/src/callbacks.c
index 5936038..4f1b61b 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -218,6 +218,32 @@ cb_line_numbers (GtkToggleAction *action, gpointer user_data)
        }
 }
 
+void
+cb_pdflatex (void)
+{
+       if (docs.active != NULL)
+       {
+               gchar *command = g_strdup_printf ("pdflatex -interaction=nonstopmode %s",
+                               docs.active->path);
+               gchar *output;
+               GError *error = NULL;
+               
+               g_spawn_command_line_sync (command, &output, NULL, NULL, &error);
+               
+               // an error occured
+               if (error != NULL)
+               {
+                       print_warning ("execution failed: %s", error->message);
+                       return;
+               }
+
+               GtkTextBuffer *log_buffer = gtk_text_view_get_buffer (docs.log);
+               gtk_text_buffer_set_text (log_buffer, output, -1);
+
+               g_free (command);
+               g_free (output);
+       }
+}
 
 void
 cb_about_dialog (void)
@@ -312,6 +338,10 @@ create_document_in_new_tab (gchar *path, gchar *text, GtkWidget *label)
        // set auto indentation
        gtk_source_view_set_auto_indent (GTK_SOURCE_VIEW (new_doc->source_view), TRUE);
 
+       // set the font
+       PangoFontDescription *font_desc = pango_font_description_from_string (FONT);
+       gtk_widget_modify_font (new_doc->source_view, font_desc);
+
        // put the text into the buffer
        gtk_source_buffer_begin_not_undoable_action (new_doc->source_buffer);
        gtk_text_buffer_set_text (GTK_TEXT_BUFFER (new_doc->source_buffer), text, -1);
diff --git a/src/callbacks.h b/src/callbacks.h
index 600c8ea..b9645db 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -9,6 +9,7 @@ void cb_close (void);
 void cb_quit (void);
 void cb_undo (void);
 void cb_redo (void);
+void cb_pdflatex (void);
 void cb_about_dialog (void);
 void cb_text_changed (GtkWidget *widget, gpointer user_data);
 void cb_page_change (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data);
diff --git a/src/main.c b/src/main.c
index 4f67124..5624102 100644
--- a/src/main.c
+++ b/src/main.c
@@ -11,7 +11,7 @@
 #include "callbacks.h"
 #include "error.h"
 
-docs_t docs = {NULL, NULL, NULL, NULL, NULL}; 
+docs_t docs = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; 
 
 int
 main (int argc, char *argv[])
@@ -75,7 +75,7 @@ main (int argc, char *argv[])
                {"viewDVI", GTK_STOCK_FILE, _("View DVI"), "<Release>F6",
                        _("View the DVI file"), NULL},
                {"compile_pdflatex", GTK_STOCK_EXECUTE, _("Compile (pdflatex)"), "<Release>F7",
-                       _("Produce the document in PDF format"), NULL},
+                       _("Produce the document in PDF format"), G_CALLBACK (cb_pdflatex)},
                {"viewPDF", GTK_STOCK_FILE, _("View PDF"), "<Release>F8",
                        _("View the PDF file"), NULL},
                
@@ -155,6 +155,8 @@ main (int argc, char *argv[])
        gtk_paned_pack2 (GTK_PANED (vpaned), sw, TRUE, TRUE);
        gtk_container_add (GTK_CONTAINER (sw), log_view);
 
+       docs.log = GTK_TEXT_VIEW (log_view);
+
        /* statusbar */
        GtkWidget *statusbar = gtk_statusbar_new ();
        gtk_box_pack_start (GTK_BOX (main_vbox), statusbar, FALSE, FALSE, 0);
diff --git a/src/main.h b/src/main.h
index 7f18009..418aa57 100644
--- a/src/main.h
+++ b/src/main.h
@@ -6,6 +6,8 @@
 #define PROGRAM_NAME "LaTeXila"
 #define PROGRAM_VERSION "0.0.1"
 
+#define FONT "Monospace"
+
 // each document opened is represented by a document_t structure
 typedef struct
 {
@@ -21,6 +23,7 @@ typedef struct
        document_t *active;
        GtkWindow *main_window;
        GtkNotebook *notebook;
+       GtkTextView *log;
        GtkSourceLanguageManager *lm;
        GtkAction *undo;
        GtkAction *redo;


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