[latexila] File Browser: use gtk_show_uri()
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] File Browser: use gtk_show_uri()
- Date: Sun, 8 Jul 2012 22:00:11 +0000 (UTC)
commit 76d72f60af92f33301d45bde4152b8c7b063180c
Author: SÃbastien Wilmet <swilmet src gnome org>
Date: Sun Jul 8 23:59:40 2012 +0200
File Browser: use gtk_show_uri()
Instead of getting a build tool to open DVI, PS and PDF files.
src/build_tools.vala | 26 --------------------------
src/file_browser.vala | 42 ++++++++++++------------------------------
2 files changed, 12 insertions(+), 56 deletions(-)
---
diff --git a/src/build_tools.vala b/src/build_tools.vala
index 818c905..1cc7e27 100644
--- a/src/build_tools.vala
+++ b/src/build_tools.vala
@@ -46,14 +46,6 @@ public struct BuildTool
Gee.ArrayList<BuildJob?> jobs;
}
-public enum DocType
-{
- DVI,
- PDF,
- PS,
- LAST
-}
-
public class BuildTools : GLib.Object
{
private static BuildTools _instance = null;
@@ -104,24 +96,6 @@ public class BuildTools : GLib.Object
return _build_tools.iterator ();
}
- // TODO use gtk_show_uri() instead of finding the right build tool to view a document
- public BuildTool? get_view_doc (DocType type)
- {
- string[] icon = new string[DocType.LAST];
- icon[DocType.DVI] = "view_dvi";
- icon[DocType.PDF] = "view_pdf";
- icon[DocType.PS] = "view_ps";
-
- // we take the first match
- foreach (BuildTool build_tool in _build_tools)
- {
- if (build_tool.icon == icon[type])
- return build_tool;
- }
-
- return null;
- }
-
public bool is_empty ()
{
return _build_tools.size == 0;
diff --git a/src/file_browser.vala b/src/file_browser.vala
index 0e110c4..37d88ca 100644
--- a/src/file_browser.vala
+++ b/src/file_browser.vala
@@ -255,42 +255,24 @@ public class FileBrowser : Grid
return;
}
- BuildTools build_tools = BuildTools.get_default ();
string extension = Utils.get_extension (basename);
- DocType doc_type;
-
- switch (extension)
+ if (extension != ".dvi" &&
+ extension != ".pdf" &&
+ extension != ".ps")
{
- // View DVI
- case ".dvi":
- doc_type = DocType.DVI;
- break;
-
- // View PDF
- case ".pdf":
- doc_type = DocType.PDF;
- break;
-
- // View PS
- case ".ps":
- doc_type = DocType.PS;
- break;
-
- // Open document
- default:
- _main_window.open_document (file);
- return;
+ _main_window.open_document (file);
+ return;
}
- BuildTool? tool = build_tools.get_view_doc (doc_type);
- if (tool == null)
+ try
{
- warning ("There is no build tool to view the file '%s'", basename);
- return;
+ Gtk.show_uri (this.get_screen (), file.get_uri (), Gdk.CURRENT_TIME);
+ }
+ catch (Error e)
+ {
+ warning ("Impossible to open the file '%s': %s",
+ file.get_uri (), e.message);
}
-
- new BuildToolRunner (file, tool, _build_view,
- _main_window.get_action_stop_exec ());
});
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]