Skip to content

Commit

Permalink
Merge pull request #4 from manexim/fix-autosave
Browse files Browse the repository at this point in the history
Fix autosave
  • Loading branch information
meisenzahl committed Jan 1, 2022
2 parents d5ff362 + 68bb5a7 commit d2cb55c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
17 changes: 17 additions & 0 deletions data/com.manexim.codecard.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@
<binary>com.manexim.codecard</binary>
</provides>
​<releases>
<release date="2022-01-01" version="1.0.1">
<description>
<p>New:</p>
<ul>
</ul>
<p>Improved:</p>
<ul>
</ul>
<p>Fixed:</p>
<ul>
<li>Fix for autosave</li>
</ul>
<p>Translations:</p>
<ul>
</ul>
</description>
</release>
<release date="2022-01-01" version="1.0.0">
<description>
<p>Initial release</p>
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('com.manexim.codecard', 'vala', 'c', version: '1.0.0')
project('com.manexim.codecard', 'vala', 'c', version: '1.0.1')

# Include the translations module
i18n = import('i18n')
Expand Down
9 changes: 1 addition & 8 deletions src/Controllers/CodecardController.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,12 @@ public class Controllers.CodecardController {

public void save () {
if (settings.autosave) {
var file = new Gtk.SourceFile ();

try {
if (!model.directory.query_exists ()) {
model.directory.make_directory_with_parents ();
}
file.location = model.file;

if (file != null && !file.is_readonly ()) {

var file_saver = new Gtk.SourceFileSaver (model.buffer as Gtk.SourceBuffer, file);
file_saver.save_async.begin (Priority.DEFAULT, null, null);
}
FileUtils.set_contents (model.file.get_path (), model.buffer.text);
} catch (Error e) {
stderr.printf ("Could not autosave: %s\n", e.message);
}
Expand Down

0 comments on commit d2cb55c

Please sign in to comment.