Skip to content

Commit

Permalink
fix #27
Browse files Browse the repository at this point in the history
  • Loading branch information
artemanufrij committed Jul 16, 2019
1 parent f3a94c9 commit 69054dd
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 1 deletion.
15 changes: 15 additions & 0 deletions data/com.github.artemanufrij.hashit.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@
</screenshot>
</screenshots>
<releases>
<release version="1.1.0" date="2019-07-17">
<description>
<p>New:</p>
<ul>
<li>Save last used algorithm</li>
</ul>
<p>Translation:</p>
<ul>
<li>Dutch (by Heimen Stoffels)</li>
<li>French (by Nathan Bonnemains)</li>
<li>Catalan (by Mario Rodrigo)</li>
<li>Spanish (by Mario Rodrigo)</li>
</ul>
</description>
</release>
<release version="1.0.0" date="2018-10-30">
<description>
<p>New:</p>
Expand Down
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ executable(
meson.project_name(),
'src/Application.vala',
'src/MainWindow.vala',
'src/Settings.vala',
dependencies: [
dependency('gtk+-3.0'),
dependency('granite'),
Expand Down Expand Up @@ -54,4 +55,5 @@ foreach i : icon_sizes
endforeach

subdir('po')
subdir('schemas')
meson.add_install_script('meson/post_install.py')
9 changes: 9 additions & 0 deletions schemas/com.github.artemanufrij.hashit.gschema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<schemalist>
<schema path="/com/github/artemanufrij/hashit/" id="com.github.artemanufrij.hashit" gettext-domain="com.github.artemanufrij.hashit">
<key name="hash" type="s">
<default>"SHA256"</default>
<summary>Hash Value.</summary>
<description>Hash Value.</description>
</key>
</schema>
</schemalist>
4 changes: 4 additions & 0 deletions schemas/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
install_data(
meson.project_name() + '.gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0', 'schemas')
)
11 changes: 11 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {"<Control>q", "0"};
set_accels_for_action ("app.quit", accel_quit);
action_quit.activate.connect (
() => {
if (mainwindow != null) {
mainwindow.destroy ();
}
});
}

Gtk.Window mainwindow;
Expand Down
8 changes: 7 additions & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ namespace HashIt {
Gtk.HeaderBar headerbar;
Gtk.Menu menu;

Settings settings;

private const Gtk.TargetEntry[] targets = {
{"text/uri-list",0,0}
};
Expand All @@ -64,6 +66,8 @@ namespace HashIt {
}

public MainWindow () {
settings = Settings.get_default ();

this.resizable = false;
this.width_request = 660;

Expand Down Expand Up @@ -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 ();
}
Expand Down Expand Up @@ -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));
Expand Down
44 changes: 44 additions & 0 deletions src/Settings.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*-
* Copyright (c) 2019-2019 Artem Anufrij <[email protected]>
*
* 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 <https://www.gnu.org/licenses/>.
*
* 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 <[email protected]>
*/

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");
}
}
}

0 comments on commit 69054dd

Please sign in to comment.