[gnome-latex: 44/205] Show/hide symbol tables



commit f9f4317aa31b91cf4ff745a455d1f9569f61ab53
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date:   Mon Sep 7 14:44:33 2009 +0200

    Show/hide symbol tables

 TODO            |  6 +++++-
 src/callbacks.c | 12 ++++++++++++
 src/callbacks.h |  1 +
 src/main.c      | 21 +++++++++++++++++----
 src/main.h      |  1 +
 src/ui.xml      |  2 ++
 6 files changed, 38 insertions(+), 5 deletions(-)
---
diff --git a/TODO b/TODO
index 41036ac..40a73f6 100644
--- a/TODO
+++ b/TODO
@@ -12,6 +12,7 @@ Thu Sep 3, 2009 to Thu Sep 10, 2009
        - various: label, ref, pageref, cite, footnote, index
 
 [-] symbol tables
+       x show/hide symbol tables
        x Greek alphabet
        x arrows
        - relation
@@ -21,7 +22,8 @@ Thu Sep 3, 2009 to Thu Sep 10, 2009
        - miscellaneous text
        - ...
 
-[-] save and load dimensions
+[-] save and load
+       - show/hide symbol tables
        - size of the window
        - position of the panes
        - sceen position (center by default)
@@ -31,3 +33,5 @@ Thu Sep 3, 2009 to Thu Sep 10, 2009
          Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion `g_utf8_validate (text, len, NULL)' failed
        x open files from the command line:
          can not open relative path, only absolute
+
+[-] update French translation
diff --git a/src/callbacks.c b/src/callbacks.c
index deeb20a..f654e48 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -848,6 +848,18 @@ cb_symbol_selected (GtkIconView *icon_view, gpointer user_data)
        g_list_free (selected_items);
 }
 
+void
+cb_show_symbol_tables (GtkToggleAction *toggle_action, gpointer user_data)
+{
+       if (latexila.symbol_tables == NULL)
+               return;
+
+       if (gtk_toggle_action_get_active (toggle_action))
+               gtk_widget_show_all (latexila.symbol_tables);
+       else
+               gtk_widget_hide (latexila.symbol_tables);
+}
+
 void
 open_new_document (const gchar *filename, const gchar *uri)
 {
diff --git a/src/callbacks.h b/src/callbacks.h
index 8da7839..67fd45b 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -65,6 +65,7 @@ void cb_command_view (GtkButton *button, gpointer user_data);
 void cb_font_set (GtkFontButton *font_button, gpointer user_data);
 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);
 
 void open_new_document (const gchar *filename, const gchar *uri);
 void save_preferences (void);
diff --git a/src/main.c b/src/main.c
index f6e03cc..ea077c7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -313,8 +313,7 @@ main (int argc, char *argv[])
        //
        // TODO try to place "entries" out of the main function without errors
        // because of gettext (the _() macro)
-       GtkActionEntry entries[] =
-       {
+       GtkActionEntry entries[] = {
                {"File", NULL, _("File"), NULL, NULL, NULL},
                {"FileNew", GTK_STOCK_NEW, _("New"), "<Control>N",
                        _("New file"), G_CALLBACK (cb_new)},
@@ -382,7 +381,15 @@ main (int argc, char *argv[])
                        _("About LaTeXila"), G_CALLBACK (cb_about_dialog)}
        };
 
+       // {name, stock_id, label, accelerator, tooltip, callback}
+       GtkToggleActionEntry toggle_entries[] = {
+               {"ViewSymbols", NULL, _("Symbol tables"), NULL,
+                       _("Show or hide the symbol tables in the current window"),
+                       G_CALLBACK (cb_show_symbol_tables)}
+       };
+
        guint nb_entries = G_N_ELEMENTS (entries);
+       guint nb_toggle_entries = G_N_ELEMENTS (toggle_entries);
 
        // recent document
        GtkAction *recent = gtk_recent_action_new ("FileOpenRecent",
@@ -397,6 +404,8 @@ main (int argc, char *argv[])
        // create the action group and the ui manager
        GtkActionGroup *action_group = gtk_action_group_new ("menuActionGroup");
        gtk_action_group_add_actions (action_group, entries, nb_entries, NULL);
+       gtk_action_group_add_toggle_actions (action_group, toggle_entries,
+                       nb_toggle_entries, NULL);
        gtk_action_group_add_action (action_group, recent);
        GtkUIManager *ui_manager = gtk_ui_manager_new ();
        gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
@@ -423,8 +432,11 @@ main (int argc, char *argv[])
                        gtk_ui_manager_get_accel_group (ui_manager));
 
        // get actions
-       latexila.undo = gtk_ui_manager_get_action (ui_manager, "/MainMenu/Edit/Undo");
-       latexila.redo = gtk_ui_manager_get_action (ui_manager, "/MainMenu/Edit/Redo");
+       latexila.undo = gtk_action_group_get_action (action_group, "EditUndo");
+       latexila.redo = gtk_action_group_get_action (action_group, "EditRedo");
+       GtkToggleAction *show_symbol_tables = GTK_TOGGLE_ACTION (
+                       gtk_action_group_get_action (action_group, "ViewSymbols"));
+       gtk_toggle_action_set_active (show_symbol_tables, TRUE);
 
        /* horizontal pane
         * left: symbol tables
@@ -436,6 +448,7 @@ main (int argc, char *argv[])
 
        /* symbol tables */
        GtkWidget *vbox_symbols = gtk_vbox_new (FALSE, 0);
+       latexila.symbol_tables = vbox_symbols;
        gtk_paned_pack1 (GTK_PANED (main_hpaned), vbox_symbols, TRUE, TRUE);
 
        // store the categories
diff --git a/src/main.h b/src/main.h
index 4997783..fc847dc 100644
--- a/src/main.h
+++ b/src/main.h
@@ -67,6 +67,7 @@ typedef struct
        gchar                           *pref_file;
        PangoFontDescription *font_desc;
        gint                            font_size;
+       GtkWidget                       *symbol_tables;
        GtkListStore            *symbol_stores[2];
        GtkIconView                     *symbol_view;
 } latexila_t;
diff --git a/src/ui.xml b/src/ui.xml
index 4762ec6..8258e6e 100644
--- a/src/ui.xml
+++ b/src/ui.xml
@@ -50,6 +50,8 @@ In the code, GtkUIManager is used to construct them.
     </menu>
 
     <menu action="View">
+      <menuitem action="ViewSymbols" />
+      <separator />
       <menuitem action="ViewZoomIn" />
       <menuitem action="ViewZoomOut" />
       <menuitem action="ViewZoomReset" />


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