[gnome-latex: 108/205] File browser: save the current folder in the prefs
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 108/205] File browser: save the current folder in the prefs
- Date: Fri, 14 Dec 2018 10:55:58 +0000 (UTC)
commit 24b7af7eff52ea7be79e5b300921ebb744f56168
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Sun Nov 8 00:52:41 2009 +0100
File browser: save the current folder in the prefs
TODO | 2 +-
src/callbacks.c | 1 +
src/file_browser.c | 11 +++++------
src/main.h | 2 +-
src/prefs.c | 20 ++++++++++++++++----
5 files changed, 24 insertions(+), 12 deletions(-)
---
diff --git a/TODO b/TODO
index 258f564..89a4368 100644
--- a/TODO
+++ b/TODO
@@ -4,7 +4,7 @@ TODO LaTeXila
x tabs to switch between "Symbols" and "File Browser"
x file browser integrated
x sort the files in alphabetical order
- - save the current folder in the prefs
+ x save the current folder in the prefs
- other pixbuf for *.pdf, *.dvi and *.ps files
- if clicking on a *.pdf, *.dvi or *.ps file, show the document (add a new action)
- add an option in the preferences: show only *.tex, *.pdf, *.dvi and *.ps files
diff --git a/src/callbacks.c b/src/callbacks.c
index cea26cd..eeed847 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -1310,6 +1310,7 @@ free_latexila (void)
g_free (latexila.prefs.command_dvipdf);
g_free (latexila.prefs.command_dvips);
g_free (latexila.prefs.file_chooser_dir);
+ g_free (latexila.prefs.file_browser_dir);
for (int i = 0 ; i < 7 ; i++)
g_object_unref (latexila.symbols.list_stores[i]);
diff --git a/src/file_browser.c b/src/file_browser.c
index 66e96a2..67fe6ed 100644
--- a/src/file_browser.c
+++ b/src/file_browser.c
@@ -42,7 +42,6 @@ init_file_browser (void)
GtkListStore *store = gtk_list_store_new (N_COLUMNS_FILE_BROWSER,
GDK_TYPE_PIXBUF, G_TYPE_STRING);
latexila.file_browser.list_store = store;
- latexila.file_browser.current_dir = g_strdup (g_get_home_dir ());
fill_list_store_with_current_dir ();
@@ -78,7 +77,7 @@ static void
fill_list_store_with_current_dir (void)
{
GError *error = NULL;
- GDir *dir = g_dir_open (latexila.file_browser.current_dir, 0, &error);
+ GDir *dir = g_dir_open (latexila.prefs.file_browser_dir, 0, &error);
if (error != NULL)
{
print_warning ("File browser: %s", error->message);
@@ -113,7 +112,7 @@ fill_list_store_with_current_dir (void)
if (read_name[0] == '.')
continue;
- gchar *full_path = g_build_filename (latexila.file_browser.current_dir,
+ gchar *full_path = g_build_filename (latexila.prefs.file_browser_dir,
read_name, NULL);
if (g_file_test (full_path, G_FILE_TEST_IS_DIR))
@@ -184,14 +183,14 @@ cb_file_browser_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
gchar *file = NULL;
gtk_tree_model_get (model, &iter, COLUMN_FILE_BROWSER_FILE, &file, -1);
- gchar *full_path = g_build_filename (latexila.file_browser.current_dir,
+ gchar *full_path = g_build_filename (latexila.prefs.file_browser_dir,
file, NULL);
// open the directory
if (g_file_test (full_path, G_FILE_TEST_IS_DIR))
{
- g_free (latexila.file_browser.current_dir);
- latexila.file_browser.current_dir = full_path;
+ g_free (latexila.prefs.file_browser_dir);
+ latexila.prefs.file_browser_dir = full_path;
fill_list_store_with_current_dir ();
}
diff --git a/src/main.h b/src/main.h
index 90bb804..bd445ff 100644
--- a/src/main.h
+++ b/src/main.h
@@ -67,7 +67,6 @@ typedef struct
{
GtkWidget *vbox;
GtkListStore *list_store;
- gchar *current_dir;
} file_browser_t;
// preferences, settings
@@ -91,6 +90,7 @@ typedef struct
gchar *command_dvipdf;
gchar *command_dvips;
gchar *file_chooser_dir;
+ gchar *file_browser_dir;
} preferences_t;
typedef struct
diff --git a/src/prefs.c b/src/prefs.c
index 85d1e4e..83125b4 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -260,6 +260,16 @@ load_preferences (preferences_t *prefs)
error = NULL;
}
+ prefs->file_browser_dir = g_key_file_get_string (key_file, PROGRAM_NAME,
+ "file_browser_directory", &error);
+ if (error != NULL)
+ {
+ print_warning ("%s", error->message);
+ prefs->file_browser_dir = g_strdup (g_get_home_dir ());
+ g_error_free (error);
+ error = NULL;
+ }
+
print_info ("load user preferences: OK");
g_key_file_free (key_file);
}
@@ -287,10 +297,11 @@ save_preferences (preferences_t *prefs)
prefs->command_dvipdf);
g_key_file_set_string (key_file, PROGRAM_NAME, "command_dvips",
prefs->command_dvips);
-
- if (prefs->file_chooser_dir != NULL)
- g_key_file_set_string (key_file, PROGRAM_NAME, "file_chooser_directory",
- prefs->file_chooser_dir);
+ //if (prefs->file_chooser_dir != NULL)
+ g_key_file_set_string (key_file, PROGRAM_NAME, "file_chooser_directory",
+ prefs->file_chooser_dir);
+ g_key_file_set_string (key_file, PROGRAM_NAME, "file_browser_directory",
+ prefs->file_browser_dir);
/* set the keys that must be taken from the widgets */
GdkWindowState flag = gdk_window_get_state (gtk_widget_get_window (
@@ -379,6 +390,7 @@ load_default_preferences (preferences_t *prefs)
prefs->command_dvipdf = g_strdup (command_dvipdf_);
prefs->command_dvips = g_strdup (command_dvips_);
prefs->file_chooser_dir = NULL;
+ prefs->file_browser_dir = g_strdup (g_get_home_dir ());
set_current_font_prefs (prefs);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]