[latexila] Refresh file browser: take into account project
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Refresh file browser: take into account project
- Date: Wed, 22 Jun 2011 20:18:12 +0000 (UTC)
commit bcd47cdc4c79de5b821bff70abaed6167c278b15
Author: SÃbastien Wilmet <swilmet src gnome org>
Date: Wed Jun 22 22:12:58 2011 +0200
Refresh file browser: take into account project
The file browser is refreshed when build files are cleaned up, and when
a document is compiled. But it's refreshed only if the directory
displayed have a "link" with the document (it depends if the document is
part of a project or not).
src/file_browser.vala | 26 ++++++++++++++++++++++++--
src/main_window.vala | 8 ++------
2 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/src/file_browser.vala b/src/file_browser.vala
index e2299b3..fe4586f 100644
--- a/src/file_browser.vala
+++ b/src/file_browser.vala
@@ -292,10 +292,32 @@ public class FileBrowser : VBox
fill_stores_with_dir (current_directory);
}
- public void refresh_if_in_dir (File dir)
+ // Refresh the file browser if the document has a "link" with the directory currently
+ // displayed.
+ public void refresh_for_document (Document doc)
{
- if (dir.equal (current_directory))
+ // If the document is not part of a project, refresh only if the document's
+ // directory is the same as the current directory.
+ if (doc.project_id == -1)
+ {
+ if (doc.location != null
+ && current_directory.equal (doc.location.get_parent ()))
+ {
+ refresh ();
+ }
+
+ return;
+ }
+
+ // If a project is defined, refresh if the current dir is part of the project.
+ Project? project = Projects.get_default ().get (doc.project_id);
+ File project_dir = project.directory;
+
+ if (current_directory.equal (project_dir)
+ || current_directory.has_prefix (project_dir))
+ {
refresh ();
+ }
}
private void fill_stores_with_dir (File? dir)
diff --git a/src/main_window.vala b/src/main_window.vala
index a65c56a..a27f539 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -1248,7 +1248,7 @@ public class MainWindow : Window
{
build_tool_runner.finished.connect (() =>
{
- file_browser.refresh_if_in_dir (main_file.get_parent ());
+ file_browser.refresh_for_document (active_document);
});
}
}
@@ -1705,11 +1705,7 @@ public class MainWindow : Window
CleanBuildFiles build_files = new CleanBuildFiles (this, active_document);
if (build_files.clean ())
- {
- File? main_file = active_document.get_main_file ();
- if (main_file != null)
- file_browser.refresh_if_in_dir (main_file.get_parent ());
- }
+ file_browser.refresh_for_document (active_document);
}
public void on_build_view_log ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]