Skip to content

Commit

Permalink
remove template, styleDir as Cmake variable, fix exchange rates loading
Browse files Browse the repository at this point in the history
  • Loading branch information
pa committed Sep 27, 2017
1 parent 13a74f6 commit 89c3d75
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ include_directories(${QALCULATE_INCLUDE_PATH})
add_definitions(-w)

set (DATADIR "/usr/share/nasc")
set (STYLEDIR "/usr/share/qalculate/styles/")
set (PKGDATADIR "${DATADIR}")
set (GETTEXT_PACKAGE "nasc")
set (RELEASE_NAME "nasc")
Expand Down
2 changes: 1 addition & 1 deletion compile.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
cmake -DCMAKE_INSTALL_LIBDIR=/usr/lib -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
make
1 change: 0 additions & 1 deletion data/nasc_template.sheets

This file was deleted.

4 changes: 2 additions & 2 deletions recompile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ rm libqalculatenasc/libqalculatenasc.so
rm libqalculatenasc/librarian.sh
rm libqalculatenasc/Makefile
rm libqalculatenasc/QalculateNasc.o
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
mkdir build && cd build
cmake -DCMAKE_INSTALL_LIBDIR=/usr/lib -DCMAKE_INSTALL_PREFIX:PATH=/usr ..
make
3 changes: 2 additions & 1 deletion src/Calculator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ internal class UpdateThread {
/* update it */
try {
var target_dir = File.new_for_path (Path.get_dirname (file));
target_dir.make_directory_with_parents ();
if(!target_dir.query_exists ())
target_dir.make_directory_with_parents ();

debug ("update exchange rates file");
var exch_file = File.new_for_uri (url);
Expand Down
15 changes: 6 additions & 9 deletions src/Controller.vala
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ public class Controller : Object {
if (!dir.query_exists ()) {
dir.make_directory ();
}

var template_file = File.new_for_path (NascSettings.template_path);
template_file.copy (file, FileCopyFlags.NONE);
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
Expand All @@ -159,12 +156,10 @@ public class Controller : Object {
debug ("getting sheets");
get_sheets ();

if (NascSettings.get_instance ().open_sheet >= sheet_list.size) {
NascSettings.get_instance ().open_sheet = sheet_list.size - 1;
}

debug ("set last sheet");
set_sheet (sheet_list.get (NascSettings.get_instance ().open_sheet));
if(sheet_list.size > 0) {
set_sheet (sheet_list.get (0));
}
}

public string get_content () {
Expand Down Expand Up @@ -272,11 +267,13 @@ public class Controller : Object {
if (sheet_list == null) {
sheet_list = new Gee.ArrayList<NascSheet> ();
string[] sheets_split = sheets_file.split (NascSettings.sheet_split_char);

foreach (string sheet in sheets_split) {
string[] content = sheet.split (NascSettings.name_split_char);
sheet_list.add (new NascSheet (content[0], content[1].replace ("\\n", "\n")));
}
if (sheet_list.size == 0){
sheet_list.add (new NascSheet ("sheet",""));
}
}

return sheet_list;
Expand Down
2 changes: 1 addition & 1 deletion src/InputView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public class InputView : Gtk.Box {
});
this.pack_start (alignment);
/* setup syntax highlighting */
string[] dirs = { "/usr/share/qalculate/styles/" };
string[] dirs = { Constants.STYLEDIR};
var lang_manager = Gtk.SourceLanguageManager.get_default ();
lang_manager.set_search_path (dirs);
this.buffer.set_language (lang_manager.get_language ("nasc"));
Expand Down
1 change: 0 additions & 1 deletion src/NascSettings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class NascSettings : Granite.Services.Settings {
public const string sheet_split_char = "|§§|";
public const string name_split_char = "-§-";
public const string sheet_path = "/.local/share/nasc/";
public const string template_path = "/usr/share/qalculate/nasc_template.sheets";

public bool show_tutorial { get; set; }
public bool advanced_mode { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/config.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Constants {
public const string DATADIR = "/usr/share/nasc";
public const string STYLEDIR = "/usr/share/qalculate/styles/";
public const string PKGDATADIR = "/usr/share/nasc";
public const string GETTEXT_PACKAGE = "nasc";
public const string RELEASE_NAME = "nasc";
Expand Down
1 change: 1 addition & 0 deletions src/config.vala.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Constants {
public const string DATADIR = "@DATADIR@";
public const string STYLEDIR = "@STYLEDIR@";
public const string PKGDATADIR = "@PKGDATADIR@";
public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@";
public const string RELEASE_NAME = "@RELEASE_NAME@";
Expand Down

0 comments on commit 89c3d75

Please sign in to comment.