Skip to content

Commit

Permalink
Merge pull request #73 from torikulhabib/master
Browse files Browse the repository at this point in the history
New feature
  • Loading branch information
torikulhabib authored Dec 30, 2021
2 parents 8862210 + a22ee46 commit f933523
Show file tree
Hide file tree
Showing 13 changed files with 1,539 additions and 227 deletions.
813 changes: 813 additions & 0 deletions data/icons/actions/com.github.gabutakut.gabutdm.seed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ actions = [
'.pause.svg',
'.magnet.svg',
'.waiting.svg',
'.auto-symbolic.svg'
'.auto-symbolic.svg',
'.seed.svg'
]

foreach m : actions
Expand Down
260 changes: 175 additions & 85 deletions src/AddUrl.vala

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ namespace Gabut {
perform_key_event ("<Control>v", false, 0);
pantheon_theme.begin ();
gabutwindow.load_dowanload ();
check_optdown ();
} else {
if (startingup) {
gabutwindow.show_all ();
Expand Down
41 changes: 19 additions & 22 deletions src/DownloadRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ namespace Gabut {
public Gtk.Image imagefile;
public Gtk.Image badge_img;
private bool stoptimer;
private uint completedl = 0U;
public Gee.HashMap<string, string> hashoption = new Gee.HashMap<string, string> ();

private int _linkmode;
Expand Down Expand Up @@ -88,28 +87,26 @@ namespace Gabut {
remove_timeout ();
break;
case StatusMode.COMPLETE:
((Gtk.Image) start_button.image).icon_name = "process-completed";
start_button.tooltip_text = _("Complete");
if (ariagid != null) {
if (aria_tell_status (ariagid, TellStatus.SEEDER) == "true") {
((Gtk.Image) start_button.image).icon_name = "com.github.gabutakut.gabutdm.seed";
start_button.tooltip_text = _("Seeding");
return;
} else {
((Gtk.Image) start_button.image).icon_name = "process-completed";
start_button.tooltip_text = _("Complete");
}
}
if (linkmode != LinkMode.MAGNETLINK) {
if (filename != null) {
if (completedl != 0) {
Source.remove (completedl);
completedl = 0;
GabutApp.gabutwindow.application.activate_action ("destroy", new Variant.string (ariagid));
notify_app (_("Download Complete"), filename, imagefile.gicon);
if (bool.parse (get_dbsetting (DBSettings.DIALOGNOTIF))) {
send_dialog ();
}
if (db_download_exist (url)) {
update_download (this);
}
completedl = Timeout.add (50, ()=> {
if (timeout_id == 0) {
GabutApp.gabutwindow.application.activate_action ("destroy", new Variant.string (ariagid));
notify_app (_("Download Complete"), filename, imagefile.gicon);
if (bool.parse (get_dbsetting (DBSettings.DIALOGNOTIF))) {
send_dialog ();
}
}
if (db_download_exist (url)) {
update_download (this);
}
completedl = 0;
return false;
});
}
} else {
bool foundgid = false;
Expand Down Expand Up @@ -276,8 +273,8 @@ namespace Gabut {

public DownloadRow (Sqlite.Statement stmt) {
linkmode = stmt.column_int (DBDownload.LINKMODE);
status = stmt.column_int (DBDownload.STATUS);
ariagid = stmt.column_text (DBDownload.ARIAGID);
status = stmt.column_int (DBDownload.STATUS);
transferrate = stmt.column_int (DBDownload.TRANSFERRATE);
totalsize = stmt.column_int64 (DBDownload.TOTALSIZE);
transferred = stmt.column_int64 (DBDownload.TRANSFERRED);
Expand Down Expand Up @@ -520,7 +517,7 @@ namespace Gabut {
return stoptimer;
}

private int status_aria (string input) {
public int status_aria (string input) {
switch (input) {
case "paused":
return StatusMode.PAUSED;
Expand Down
3 changes: 2 additions & 1 deletion src/Downloader.vala
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,8 @@ namespace Gabut {
infostore.set (iters, 0, announce);
}
}
commenttext.buffer.text = aria_tell_bittorent (ariagid, TellBittorrent.COMMENT);
var commenttorrent = aria_tell_bittorent (ariagid, TellBittorrent.COMMENT);
commenttext.buffer.text = commenttorrent.contains ("\\/")? Soup.URI.decode (commenttorrent.replace ("\\/", "/")) : commenttorrent;
}

private uint timeout_id = 0;
Expand Down
41 changes: 9 additions & 32 deletions src/GabutWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ namespace Gabut {
private Gtk.SearchEntry search_entry;
private ModeButton view_mode;
private AlertView nodown_alert;
private int64 statusactive = 0;
private GLib.List<AddUrl> properties;

public GabutWindow (Gtk.Application application) {
Expand Down Expand Up @@ -91,7 +90,7 @@ namespace Gabut {
});

Timeout.add (500, ()=> {
bool statact = statusactive > 0;
bool statact = int.parse (aria_globalstat (GlobalStat.NUMACTIVE)) > 0;
set_progress_visible.begin (!is_active && statact);
set_badge_visible.begin (!is_active && statact);
return true;
Expand Down Expand Up @@ -181,8 +180,8 @@ namespace Gabut {
property.show_all ();
properties.append (property);
property.property (row);
property.saveproperty.connect ((hashoption)=> {
row.hashoption = hashoption;
property.save_button.clicked.connect (()=> {
row = property.row;
});
property.destroy.connect (()=> {
properties.foreach ((proper)=> {
Expand Down Expand Up @@ -252,7 +251,6 @@ namespace Gabut {

public override void destroy () {
base.destroy ();
check_optdown ();
var downloads = new GLib.List<DownloadRow> ();
foreach (var row in list_box.get_children ()) {
if (((DownloadRow) row).url == "") {
Expand Down Expand Up @@ -297,7 +295,7 @@ namespace Gabut {
}
}
});
get_active ();
set_badge.begin (int.parse (aria_globalstat (GlobalStat.NUMACTIVE)));
}

private Hdy.HeaderBar mode_headerbar () {
Expand Down Expand Up @@ -353,7 +351,7 @@ namespace Gabut {
((DownloadRow) row).add_timeout ();
}
}
get_active ();
set_badge.begin (int.parse (aria_globalstat (GlobalStat.NUMACTIVE)));
}

public void fast_respond (string ariagid) {
Expand All @@ -362,19 +360,7 @@ namespace Gabut {
((DownloadRow) row).update_progress ();
}
}
get_active ();
}

private bool get_active () {
statusactive = 0;
foreach (var row in list_box.get_children ()) {
if (((DownloadRow) row).status == StatusMode.ACTIVE) {
statusactive++;
}
}
set_badge.begin (statusactive);
remove_time = 0;
return false;
set_badge.begin (int.parse (aria_globalstat (GlobalStat.NUMACTIVE)));
}

public void remove_all () {
Expand Down Expand Up @@ -405,7 +391,7 @@ namespace Gabut {
}
if (!later) {
row.download ();
get_active ();
set_badge.begin (int.parse (aria_globalstat (GlobalStat.NUMACTIVE)));
}
}

Expand All @@ -419,7 +405,6 @@ namespace Gabut {
return linkexist;
}

private uint remove_time = 0U;
private void start_all () {
foreach (var row in list_box.get_children ()) {
if (((DownloadRow) row).status != StatusMode.COMPLETE) {
Expand All @@ -428,11 +413,7 @@ namespace Gabut {
}
}
view_status ();
if (remove_time > 0) {
Source.remove (remove_time);
}
remove_time = 0;
remove_time = Timeout.add (50, get_active);
set_badge.begin (int.parse (aria_globalstat (GlobalStat.NUMACTIVE)));
}

private void stop_all () {
Expand All @@ -444,11 +425,7 @@ namespace Gabut {
}
}
view_status ();
if (remove_time > 0) {
Source.remove (remove_time);
}
remove_time = 0;
remove_time = Timeout.add (50, get_active);
set_badge.begin (int.parse (aria_globalstat (GlobalStat.NUMACTIVE)));
}

public string set_selected (string ariagid, string selected) {
Expand Down
48 changes: 48 additions & 0 deletions src/PieceSelector.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) {2021} torikulhabib (https://github.com/gabutakut)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: torikulhabib <torik.habib@Gmail.com>
*/

namespace Gabut {
public class PieceSelector : Gtk.FlowBoxChild {
private Gtk.Grid content;
public PieceSelectors selector { get; private set; }

construct {
content = new Gtk.Grid () {
row_spacing = 12,
halign = Gtk.Align.CENTER
};
add (content);
}

public PieceSelector (PieceSelectors selector) {
this.selector = selector;
var title = new Gtk.Label (selector.get_name ()) {
halign = Gtk.Align.CENTER,
margin_top = 6,
margin_bottom = 6,
margin_start = 12,
margin_end = 12
};
content.add (title);
show_all ();
}
}
}
Loading

0 comments on commit f933523

Please sign in to comment.