[gnome-latex: 123/205] File browser: option: show all files
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 123/205] File browser: option: show all files
- Date: Fri, 14 Dec 2018 10:57:13 +0000 (UTC)
commit d38ca7ce0b87d7ce07ba6c2a8639df84bc46a9ef
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Thu Nov 19 16:19:29 2009 +0100
File browser: option: show all files
By default, this option is not activated and only *.tex, *.pdf, *.dvi,
*.ps and *.bib files are showed in the file browser.
If the option is activated, only the hidden files (beginning with a
point) are not showed.
TODO | 3 ++-
src/file_browser.c | 27 ++++++++++++++++++---------
src/file_browser.h | 1 +
src/main.h | 1 +
src/prefs.c | 43 ++++++++++++++++++++++++++++++++++++++-----
5 files changed, 60 insertions(+), 15 deletions(-)
---
diff --git a/TODO b/TODO
index 7937217..de5d6ae 100644
--- a/TODO
+++ b/TODO
@@ -8,7 +8,8 @@ TODO LaTeXila
x add a link to the home user directory
x other pixbuf for *.pdf, *.dvi and *.ps files
x 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
+ x add an option in the preferences: show only *.tex, *.pdf, *.dvi, *.ps and *.bib files
+ - add a button to jump to the directory of the current document
[-] Templates
- create a few default templates
diff --git a/src/file_browser.c b/src/file_browser.c
index 39e4e6a..5c79596 100644
--- a/src/file_browser.c
+++ b/src/file_browser.c
@@ -35,7 +35,6 @@
static void fill_list_store_with_current_dir (void);
static void cb_go_to_home_dir (GtkButton *button, gpointer user_data);
static void cb_go_to_parent_dir (GtkButton *button, gpointer user_data);
-static void cb_refresh (GtkButton *button, gpointer user_data);
static void cb_file_browser_row_activated (GtkTreeView *tree_view,
GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data);
static gint sort_list_alphabetical_order (gconstpointer a, gconstpointer b);
@@ -72,7 +71,7 @@ init_file_browser (void)
gtk_container_add (GTK_CONTAINER (refresh_button), refresh_icon);
gtk_widget_set_tooltip_text (refresh_button, _("Refresh"));
g_signal_connect (G_OBJECT (refresh_button), "clicked",
- G_CALLBACK (cb_refresh), NULL);
+ G_CALLBACK (cb_file_browser_refresh), NULL);
GtkWidget *hbox = gtk_hbox_new (TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), home_button, TRUE, TRUE, 0);
@@ -120,6 +119,13 @@ init_file_browser (void)
TRUE, TRUE, 0);
}
+void
+cb_file_browser_refresh (GtkButton *button, gpointer user_data)
+{
+ fill_list_store_with_current_dir ();
+}
+
+
static void
fill_list_store_with_current_dir (void)
{
@@ -153,8 +159,17 @@ fill_list_store_with_current_dir (void)
if (g_file_test (full_path, G_FILE_TEST_IS_DIR))
directory_list = g_list_prepend (directory_list, (gpointer) tmp);
- else
+
+ // show all files or only *.tex, *.pdf, *.dvi, *.ps and *.bib
+ else if (latexila.prefs.file_browser_show_all_files
+ || g_str_has_suffix (full_path, ".tex")
+ || g_str_has_suffix (full_path, ".pdf")
+ || g_str_has_suffix (full_path, ".dvi")
+ || g_str_has_suffix (full_path, ".ps")
+ || g_str_has_suffix (full_path, ".bib"))
+ {
file_list = g_list_prepend (file_list, (gpointer) tmp);
+ }
g_free (full_path);
}
@@ -261,12 +276,6 @@ cb_go_to_parent_dir (GtkButton *button, gpointer user_data)
fill_list_store_with_current_dir ();
}
-static void
-cb_refresh (GtkButton *button, gpointer user_data)
-{
- fill_list_store_with_current_dir ();
-}
-
static void
cb_file_browser_row_activated (GtkTreeView *tree_view, GtkTreePath *path,
GtkTreeViewColumn *column, gpointer user_data)
diff --git a/src/file_browser.h b/src/file_browser.h
index bf6c313..474bcf5 100644
--- a/src/file_browser.h
+++ b/src/file_browser.h
@@ -21,6 +21,7 @@
#define FILE_BROWSER_H
void init_file_browser (void);
+void cb_file_browser_refresh (GtkButton *button, gpointer user_data);
enum
{
diff --git a/src/main.h b/src/main.h
index 0898576..338e8d8 100644
--- a/src/main.h
+++ b/src/main.h
@@ -91,6 +91,7 @@ typedef struct
gchar *command_dvips;
gchar *file_chooser_dir;
gchar *file_browser_dir;
+ gboolean file_browser_show_all_files;
GPtrArray *list_opened_docs;
gboolean reopen_files_on_startup;
} preferences_t;
diff --git a/src/prefs.c b/src/prefs.c
index c9bcf46..88be78d 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -30,6 +30,7 @@
#include "config.h"
#include "print.h"
#include "callbacks.h"
+#include "file_browser.h"
static void load_default_preferences (preferences_t *prefs);
static gchar * get_rc_file (void);
@@ -62,7 +63,8 @@ static gchar *command_latex_ = COMMAND_LATEX;
static gchar *command_pdflatex_ = COMMAND_PDFLATEX;
static gchar *command_dvipdf_ = COMMAND_DVIPDF;
static gchar *command_dvips_ = COMMAND_DVIPS;
-static gboolean reopen_files_on_startup_ = TRUE;
+static gboolean reopen_files_on_startup_ = TRUE;
+static gboolean file_browser_show_all_files_ = FALSE;
void
load_preferences (preferences_t *prefs)
@@ -219,8 +221,6 @@ load_preferences (preferences_t *prefs)
error = NULL;
}
- // look, I see light, we are close to the exit!
-
prefs->command_pdflatex = g_key_file_get_string (key_file, PROGRAM_NAME,
"command_pdflatex", &error);
if (error != NULL)
@@ -261,6 +261,8 @@ load_preferences (preferences_t *prefs)
error = NULL;
}
+ // look, I see light, we are close to the exit!
+
prefs->file_browser_dir = g_key_file_get_string (key_file, PROGRAM_NAME,
"file_browser_directory", &error);
if (error != NULL)
@@ -303,6 +305,16 @@ load_preferences (preferences_t *prefs)
error = NULL;
}
+ prefs->file_browser_show_all_files = g_key_file_get_boolean (key_file,
+ PROGRAM_NAME, "file_browser_show_all_files", &error);
+ if (error != NULL)
+ {
+ print_warning ("%s", error->message);
+ prefs->file_browser_show_all_files = file_browser_show_all_files_;
+ g_error_free (error);
+ error = NULL;
+ }
+
print_info ("load user preferences: OK");
g_key_file_free (key_file);
}
@@ -338,9 +350,10 @@ save_preferences (preferences_t *prefs)
g_key_file_set_string_list (key_file, PROGRAM_NAME, "list_opened_documents",
(const gchar **) prefs->list_opened_docs->pdata,
prefs->list_opened_docs->len);
-
g_key_file_set_boolean (key_file, PROGRAM_NAME, "reopen_files_on_startup",
prefs->reopen_files_on_startup);
+ g_key_file_set_boolean (key_file, PROGRAM_NAME, "file_browser_show_all_files",
+ prefs->file_browser_show_all_files);
/* set the keys that must be taken from the widgets */
GdkWindowState flag = gdk_window_get_state (gtk_widget_get_window (
@@ -432,6 +445,7 @@ load_default_preferences (preferences_t *prefs)
prefs->file_browser_dir = g_strdup (g_get_home_dir ());
prefs->list_opened_docs = g_ptr_array_new ();
prefs->reopen_files_on_startup = reopen_files_on_startup_;
+ prefs->file_browser_show_all_files = file_browser_show_all_files_;
set_current_font_prefs (prefs);
}
@@ -545,7 +559,17 @@ cb_pref_command_dvips (GtkEditable *editable, gpointer user_data)
static void
cb_reopen_files_on_startup (GtkToggleButton *toggle_button, gpointer user_data)
{
- latexila.prefs.reopen_files_on_startup = gtk_toggle_button_get_active (toggle_button);
+ latexila.prefs.reopen_files_on_startup =
+ gtk_toggle_button_get_active (toggle_button);
+}
+
+static void
+cb_file_browser_show_all_files (GtkToggleButton *toggle_button,
+ gpointer user_data)
+{
+ latexila.prefs.file_browser_show_all_files =
+ gtk_toggle_button_get_active (toggle_button);
+ cb_file_browser_refresh (NULL, NULL);
}
@@ -653,6 +677,15 @@ create_preferences (void)
G_CALLBACK (cb_reopen_files_on_startup), NULL);
gtk_box_pack_start (GTK_BOX (content_area), reopen, FALSE, FALSE, 5);
+ /* file browser: show all files */
+ GtkWidget *fb_show_all_files = gtk_check_button_new_with_label (
+ _("File browser: show all files"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fb_show_all_files),
+ latexila.prefs.file_browser_show_all_files);
+ g_signal_connect (G_OBJECT (fb_show_all_files), "toggled",
+ G_CALLBACK (cb_file_browser_show_all_files), NULL);
+ gtk_box_pack_start (GTK_BOX (content_area), fb_show_all_files, FALSE, FALSE, 5);
+
gtk_widget_show_all (content_area);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]