diff --git a/data/com.github.artemanufrij.hashit.appdata.xml.in b/data/com.github.artemanufrij.hashit.appdata.xml.in index a5d32dd..daecd31 100644 --- a/data/com.github.artemanufrij.hashit.appdata.xml.in +++ b/data/com.github.artemanufrij.hashit.appdata.xml.in @@ -33,6 +33,21 @@ + + +

New:

+
    +
  • Save last used algorithm
  • +
+

Translation:

+
    +
  • Dutch (by Heimen Stoffels)
  • +
  • French (by Nathan Bonnemains)
  • +
  • Catalan (by Mario Rodrigo)
  • +
  • Spanish (by Mario Rodrigo)
  • +
+
+

New:

diff --git a/meson.build b/meson.build index aa6aed7..cb5552e 100644 --- a/meson.build +++ b/meson.build @@ -12,6 +12,7 @@ executable( meson.project_name(), 'src/Application.vala', 'src/MainWindow.vala', + 'src/Settings.vala', dependencies: [ dependency('gtk+-3.0'), dependency('granite'), @@ -54,4 +55,5 @@ foreach i : icon_sizes endforeach subdir('po') +subdir('schemas') meson.add_install_script('meson/post_install.py') \ No newline at end of file diff --git a/schemas/com.github.artemanufrij.hashit.gschema.xml b/schemas/com.github.artemanufrij.hashit.gschema.xml new file mode 100644 index 0000000..021860c --- /dev/null +++ b/schemas/com.github.artemanufrij.hashit.gschema.xml @@ -0,0 +1,9 @@ + + + + "SHA256" + Hash Value. + Hash Value. + + + diff --git a/schemas/meson.build b/schemas/meson.build new file mode 100644 index 0000000..45ed0f7 --- /dev/null +++ b/schemas/meson.build @@ -0,0 +1,4 @@ +install_data( + meson.project_name() + '.gschema.xml', + install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas') +) \ No newline at end of file diff --git a/src/Application.vala b/src/Application.vala index 388ca48..7818e3c 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -45,6 +45,17 @@ namespace HashIt { application_id = "com.github.artemanufrij.hashit"; app_launcher = application_id + ".desktop"; this.flags |= GLib.ApplicationFlags.HANDLES_OPEN; + + var action_quit = new SimpleAction ("quit", null); + add_action (action_quit); + string[] accel_quit = {"q", "0"}; + set_accels_for_action ("app.quit", accel_quit); + action_quit.activate.connect ( + () => { + if (mainwindow != null) { + mainwindow.destroy (); + } + }); } Gtk.Window mainwindow; diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 06a2cea..9c5bee5 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -41,6 +41,8 @@ namespace HashIt { Gtk.HeaderBar headerbar; Gtk.Menu menu; + Settings settings; + private const Gtk.TargetEntry[] targets = { {"text/uri-list",0,0} }; @@ -64,6 +66,8 @@ namespace HashIt { } public MainWindow () { + settings = Settings.get_default (); + this.resizable = false; this.width_request = 660; @@ -122,9 +126,10 @@ namespace HashIt { hash_chooser.append ("MD5", "MD5"); hash_chooser.append ("SHA256", "SHA256"); hash_chooser.append ("SHA1", "SHA1"); - hash_chooser.active = 1; + hash_chooser.active_id = settings.hash; hash_chooser.tooltip_text = _("Choose an algorithm"); hash_chooser.changed.connect (() => { + settings.hash = hash_chooser.active_id; if (selected_file != null) { get_checksum.begin (); } @@ -217,6 +222,7 @@ namespace HashIt { } private async void get_checksum () { + warning(settings.hash); calculate_begin (); checksum_thread.begin ((obj, res) => { calculate_finished (checksum_thread.end (res)); diff --git a/src/Settings.vala b/src/Settings.vala new file mode 100644 index 0000000..76c74d7 --- /dev/null +++ b/src/Settings.vala @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 2019-2019 Artem Anufrij + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * The Noise authors hereby grant permission for non-GPL compatible + * GStreamer plugins to be used and distributed together with GStreamer + * and Noise. This permission is above and beyond the permissions granted + * by the GPL license by which Noise is covered. If you modify this code + * you may extend this exception to your version of the code, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * + * Authored by: Artem Anufrij + */ + +namespace HashIt { + public class Settings : Granite.Services.Settings { + + private static Settings settings; + public static Settings get_default () { + if (settings == null) + settings = new Settings (); + + return settings; + } + public string hash { get; set; } + + private Settings () { + base ("com.github.artemanufrij.hashit"); + } + } +}