[gnome-latex: 2/205] GUI: menubar and toolbar
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 2/205] GUI: menubar and toolbar
- Date: Fri, 14 Dec 2018 10:47:03 +0000 (UTC)
commit 080357ca29567f59e9044adf39098dbc2cbf4ce5
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Sun Jul 26 17:59:18 2009 +0200
GUI: menubar and toolbar
TODO | 20 +++++++++-----------
main.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
ui.xml | 47 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 111 insertions(+), 15 deletions(-)
---
diff --git a/TODO b/TODO
index c186761..69870c2 100644
--- a/TODO
+++ b/TODO
@@ -1,23 +1,21 @@
-TODO
+TODO LaTeXila
-23/07/2009
-au
-30/07/2009
+23/07/2009 au 30/07/2009
[-] faire l'interface graphique
- - menu
- - barre d'outils
+ x menu
+ x barre d'outils
- zone de texte éditable (comme gedit)
- zone de log/messages
- barre de status
[-] trouver plus de doc sur le développement d'application GNOME (un site qui regroupe tout ?)
- - barre d'outils : boutons avec texte et icône qui changent selon les préférences définies dans GNOME
: texte en-dessous, icônes seules, etc.
- - icônes de base changeant selon le thème
+ x barre d'outils : boutons avec texte et icône qui changent selon les préférences définies dans GNOME
: texte en-dessous, icônes seules, etc.
+ x icônes de base changeant selon le thème
x traduction, internationalisation
- gestion et enregistrement des préférences utilisateurs (avec gconf)
- ...
-[-] GIT
- - mettre en place GIT en local
- - comprendre les commandes de base
+[x] GIT
+ x mettre en place GIT en local
+ x comprendre les commandes de base
diff --git a/main.c b/main.c
index 9bc6eb5..e553398 100644
--- a/main.c
+++ b/main.c
@@ -3,21 +3,72 @@
#include <stdbool.h>
#include <gtk/gtk.h>
+static void
+menu_add_widget(GtkUIManager *ui_manager, GtkWidget *widget, GtkContainer *box)
+{
+ gtk_box_pack_start(GTK_BOX(box), widget, FALSE, FALSE, 0);
+ gtk_widget_show(widget);
+}
+
int
main (int argc, char *argv[])
{
- GtkWidget *window;
+ // all the actions (for the menu and the toolbar)
+ // name, stock_id, label, accelerator, tooltip, callback
+ // the names come from the XML file
+ GtkActionEntry entries[] =
+ {
+ {"File", NULL, "File", NULL, NULL, NULL},
+ {"FileNew", GTK_STOCK_NEW, "New", "<Control>N", "New file", NULL},
+ {"FileOpen", GTK_STOCK_OPEN, "Open...", "<Control>O", "Open a file", NULL},
+ {"FileSave", GTK_STOCK_SAVE, "Save...", "<Control>S", "Save the current file", NULL},
+ {"FileSaveAs", GTK_STOCK_SAVE_AS, "Save as...", "<Shift><Control>S", "Save the current file
with a different name", NULL},
+ {"FileQuit", GTK_STOCK_QUIT, "Quit", "<Control>Q", "Quit the program", gtk_main_quit},
+
+ {"Edit", NULL, "Edit", NULL, NULL, NULL},
+ {"EditUndo", GTK_STOCK_UNDO, "Undo", "<Control>Z", "Undo the last action", NULL},
+ {"EditRedo", GTK_STOCK_REDO, "Redo", "<Shift><Control>Z", "Redo the last undone action",
NULL},
+
+ {"LaTeX", NULL, "LaTeX", NULL, NULL, NULL},
+ {"compile_latex", GTK_STOCK_EXECUTE, "Compile (latex)", "<Release>F5", "Produce the document
in DVI format", NULL},
+ {"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},
+ {"viewPDF", GTK_STOCK_FILE, "View PDF", "<Release>F8", "View the PDF file", NULL},
+
+ {"Help", NULL, "Help", NULL, NULL, NULL},
+ {"HelpAbout", GTK_STOCK_ABOUT, "About", NULL, "About LaTeXila", NULL}
+ };
+
+ int nb_entries = sizeof(entries) / sizeof(entries[0]);
+
gtk_init(&argc, &argv);
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(gtk_main_quit), NULL);
- gtk_container_set_border_width(GTK_CONTAINER(window), 10);
+ gtk_window_set_title(GTK_WINDOW(window), "LaTeXila");
+
+ GtkWidget *main_vbox = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(window), main_vbox);
+
+ /* menubar */
+ GtkUIManager *ui_manager = gtk_ui_manager_new();
+ GtkActionGroup *action_group = gtk_action_group_new("menuActionGroup");
+ gtk_action_group_add_actions(action_group, entries, nb_entries, NULL);
+ gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
+ int tmp = gtk_ui_manager_add_ui_from_file(ui_manager, "ui.xml", NULL);
+ if (tmp == 0)
+ {
+ fprintf(stderr, "Error with ui.xml\n");
+ return EXIT_FAILURE;
+ }
+ g_signal_connect(ui_manager, "add-widget", G_CALLBACK(menu_add_widget), main_vbox);
+
- gtk_widget_show(window);
+ gtk_widget_show_all(window);
gtk_main();
diff --git a/ui.xml b/ui.xml
new file mode 100644
index 0000000..0deceee
--- /dev/null
+++ b/ui.xml
@@ -0,0 +1,47 @@
+<!--
+This XML file describe the menu and the toolbar based on action.
+In the code, GtkUIManager is used to construct them.
+-->
+
+<ui>
+ <menubar>
+ <menu action="File">
+ <menuitem action="FileNew" />
+ <menuitem action="FileOpen" />
+ <menuitem action="FileSave" />
+ <menuitem action="FileSaveAs" />
+ <menuitem action="FileQuit" />
+ </menu>
+
+ <menu action="Edit">
+ <menuitem action="EditUndo" />
+ <menuitem action="EditRedo" />
+ </menu>
+
+ <menu action="LaTeX">
+ <menuitem action="compile_latex" />
+ <menuitem action="viewDVI" />
+ <separator />
+ <menuitem action="compile_pdflatex" />
+ <menuitem action="viewPDF" />
+ </menu>
+
+ <menu action="Help">
+ <menuitem action="HelpAbout" />
+ </menu>
+ </menubar>
+
+ <toolbar>
+ <toolitem action="FileNew" />
+ <toolitem action="FileOpen" />
+ <toolitem action="FileSave" />
+ <toolitem action="EditUndo" />
+ <toolitem action="EditRedo" />
+ <separator />
+ <toolitem action="compile_latex" />
+ <toolitem action="viewDVI" />
+ <separator />
+ <toolitem action="compile_pdflatex" />
+ <toolitem action="viewPDF" />
+ </toolbar>
+</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]