[gnome-latex: 146/205] Side pane: remember the current page of the notebook



commit a57fce1bdcdc00820bfda2a5b453e75d8630efe8
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date:   Sat Dec 19 20:25:36 2009 +0100

    Side pane: remember the current page of the notebook
    
    The page number of the notebook of the side pane is saved in the
    preferences.
    
    For the 0.1 version there is only two pages in the notebook (symbols and
    file browser) and I think it's better than a ComboBox, but maybe in the
    future it will be replaced by a ComboBox with a close button.

 TODO        |  3 ---
 src/main.c  |  3 +++
 src/main.h  |  1 +
 src/prefs.c | 17 +++++++++++++++++
 4 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/TODO b/TODO
index 5c673cd..936d31f 100644
--- a/TODO
+++ b/TODO
@@ -4,9 +4,6 @@ TODO LaTeXila
 
 [-] documentation
 
-[-] replace the notebook in the side pane by a combo box with a close button
-[-] remember which element is showed (symbols or file browser)
-
 [-] verbose option
 
 [-] bug correction
diff --git a/src/main.c b/src/main.c
index a9532cf..e2902a2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -499,6 +499,9 @@ main (int argc, char *argv[])
        gtk_widget_hide (latexila.under_source_view.find);
        gtk_widget_hide (latexila.under_source_view.replace);
 
+       gtk_notebook_set_current_page (GTK_NOTEBOOK (latexila.side_pane),
+                       latexila.prefs.side_pane_page);
+
        /* reopen files on startup */
        gchar ** list_opened_docs = (gchar **) latexila.prefs.list_opened_docs->pdata;
        for (int i = 0 ; i < latexila.prefs.list_opened_docs->len
diff --git a/src/main.h b/src/main.h
index 30e6081..54728a4 100644
--- a/src/main.h
+++ b/src/main.h
@@ -101,6 +101,7 @@ typedef struct
        gboolean                                highlight_current_line;
        gboolean                                highlight_matching_brackets;
        gboolean                                toolbars_horizontal;
+       gint                                    side_pane_page;
 } preferences_t;
 
 typedef struct
diff --git a/src/prefs.c b/src/prefs.c
index 1b4e766..f4b6e5a 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -92,6 +92,7 @@ static gboolean       spaces_instead_of_tabs_                 = TRUE;
 static gboolean        highlight_current_line_                 = TRUE;
 static gboolean highlight_matching_brackets_   = TRUE;
 static gboolean        toolbars_horizontal_                    = FALSE;
+static gint            side_pane_page_         = 0;
 
 void
 load_preferences (preferences_t *prefs)
@@ -412,6 +413,16 @@ load_preferences (preferences_t *prefs)
                error = NULL;
        }
 
+       prefs->side_pane_page = g_key_file_get_integer (key_file,
+                       PROGRAM_NAME, "side_pane_page", &error);
+       if (error != NULL)
+       {
+               print_warning ("%s", error->message);
+               prefs->side_pane_page = side_pane_page_;
+               g_error_free (error);
+               error = NULL;
+       }
+
        print_info ("load user preferences: OK");
        g_key_file_free (key_file);
 }
@@ -503,6 +514,11 @@ save_preferences (preferences_t *prefs)
        g_key_file_set_integer (key_file, PROGRAM_NAME, "log_hpaned_pos",
                        log_hpaned_pos);
 
+       gint side_pane_page = gtk_notebook_get_current_page (
+                       GTK_NOTEBOOK (latexila.side_pane));
+       g_key_file_set_integer (key_file, PROGRAM_NAME, "side_pane_page",
+                       side_pane_page);
+
        /* save the rc file */
        gchar *rc_file = get_rc_file ();
        gchar *rc_path = g_path_get_dirname (rc_file);
@@ -564,6 +580,7 @@ load_default_preferences (preferences_t *prefs)
        prefs->highlight_current_line = highlight_current_line_;
        prefs->highlight_matching_brackets = highlight_matching_brackets_;
        prefs->toolbars_horizontal = toolbars_horizontal_;
+       prefs->side_pane_page = side_pane_page_;
 
        set_current_font_prefs (prefs);
 }


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