Skip to content

Commit

Permalink
Merge pull request #141 from torikulhabib/master
Browse files Browse the repository at this point in the history
interface host and fix dm
  • Loading branch information
torikulhabib authored Jul 4, 2022
2 parents 94a467e + 450c273 commit e78bd55
Show file tree
Hide file tree
Showing 13 changed files with 382 additions and 272 deletions.
23 changes: 17 additions & 6 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ namespace Gabut {
gabutserver.stop_server ();
gabutserver.set_listent.begin (int.parse (get_dbsetting (DBSettings.PORTLOCAL)));
});
gabutwindow.update_agid.connect ((ariagid, newgid)=> {
downloaders.foreach ((downloader)=> {
if (downloader.ariagid == ariagid) {
downloader.ariagid = newgid;
downloader.get_active_status ();
}
});
});
gabutserver.address_url.connect ((url, options, later, linkmode)=> {
gabutwindow.add_url_box (url, options, later, linkmode);
});
Expand All @@ -137,12 +145,6 @@ namespace Gabut {
}
});
add_action (action_download);
var action_status = new SimpleAction ("status", VariantType.STRING);
action_status.activate.connect ((parameter) => {
string aria_gid = parameter.get_string (null);
gabutwindow.fast_respond (aria_gid);
});
add_action (action_status);
var action_succes = new SimpleAction ("succes", VariantType.STRING);
action_succes.activate.connect ((parameter) => {
string succes = parameter.get_string (null);
Expand All @@ -160,6 +162,12 @@ namespace Gabut {
gabutserver.get_dl_row.connect ((status)=> {
return gabutwindow.get_dl_row (status);
});
gabutserver.updat_row.connect ((status)=> {
gabutwindow.server_action (status);
});
gabutserver.delete_row.connect ((status)=> {
gabutwindow.remove_item (status);
});
clipboard = gabutwindow.get_display ().get_clipboard ();
clipboard.changed.connect (on_clipboard);
pantheon_theme.begin ();
Expand Down Expand Up @@ -354,6 +362,9 @@ namespace Gabut {
downloader.sendselected.connect ((ariagid, selected)=> {
return gabutwindow.set_selected (ariagid, selected);
});
downloader.actions_button.connect ((ariagid, status)=> {
return gabutwindow.server_action (ariagid, status);
});
}

private void on_clipboard () {
Expand Down
51 changes: 25 additions & 26 deletions src/DownloadRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace Gabut {
public class DownloadRow : Gtk.ListBoxRow {
public signal void delete_me (DownloadRow row);
public signal void update_agid (string ariagid, string newgid);
private Gtk.Button start_button;
private Gtk.Label transfer_rate;
private Gtk.ProgressBar progressbar;
Expand Down Expand Up @@ -123,6 +124,7 @@ namespace Gabut {
if (ariagid == aria_tell_status (strgid, TellStatus.FOLLOWING)) {
status = status_aria (aria_tell_status (strgid, TellStatus.STATUS));
filename = aria_tell_bittorent (strgid, TellBittorrent.NAME);
update_agid (ariagid, strgid);
ariagid = strgid;
linkmode = LinkMode.TORRENT;
progressbar.fraction = 0.0;
Expand Down Expand Up @@ -268,12 +270,16 @@ namespace Gabut {
}
set {
_transferred = value.abs ();
double fraction = (double) transferred / (double) totalsize;
if (fraction > 0.0) {
progressbar.fraction = fraction;
}
if (status == StatusMode.ACTIVE) {
set_progress_visible.begin (progressbar.fraction);
if (totalsize > 0) {
double fraction = (double) transferred / (double) totalsize;
if (fraction > 0.0) {
progressbar.fraction = fraction;
}
if (status == StatusMode.ACTIVE) {
set_progress_visible.begin (progressbar.fraction);
}
} else {
progressbar.pulse ();
}
}
}
Expand Down Expand Up @@ -352,7 +358,8 @@ namespace Gabut {
valign = Gtk.Align.CENTER
};
progressbar = new Gtk.ProgressBar () {
hexpand = true
hexpand = true,
pulse_step = 0.2
};

filename_label = new Gtk.Label (filename) {
Expand All @@ -366,20 +373,7 @@ namespace Gabut {
valign = Gtk.Align.CENTER
};
start_button.clicked.connect (()=> {
if (status == StatusMode.COMPLETE) {
send_dialog ();
return;
}
if (linkmode != LinkMode.URL) {
action_dowload ();
} else {
if (aria_geturis (ariagid) != "") {
action_dowload ();
} else {
ariagid = aria_url (url, hashoption);
status = status_aria (aria_tell_status (ariagid, TellStatus.STATUS));
}
}
action_btn ();
});

var remove_button = new Gtk.Button.from_icon_name ("edit-delete") {
Expand Down Expand Up @@ -407,6 +401,15 @@ namespace Gabut {
child = grid;
}

public string action_btn (int stats = 2) {
if (stats != StatusMode.NOTHING && status == StatusMode.COMPLETE) {
send_dialog ();
return ariagid;
}
action_dowload ();
return ariagid;
}

public void if_not_exist (string ariag, int linkm, int stats) {
if (stats == StatusMode.COMPLETE || stats == StatusMode.ERROR) {
return;
Expand Down Expand Up @@ -448,11 +451,7 @@ namespace Gabut {
}

public void idle_progress () {
Idle.add (()=> {
update_progress ();
add_timeout ();
return false;
});
Idle.add (()=> { update_progress (); return false; });
}

private void action_dowload () {
Expand Down
78 changes: 21 additions & 57 deletions src/Downloader.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace Gabut {
public class Downloader : Gtk.Dialog {
public signal string sendselected (string ariagid, string selected);
public signal string actions_button (string ariagid, int status);
private Gtk.Button start_button;
private Gtk.ProgressBar progressbar;
private Gtk.Label transfer_rate;
Expand All @@ -43,7 +44,6 @@ namespace Gabut {
private Gtk.TreeView infotorrent;
private Gtk.TreeView peerstree;
private Gtk.TextView commenttext;
private Gtk.Revealer download_rev;
private bool stoptimer;

private string _url;
Expand Down Expand Up @@ -72,30 +72,27 @@ namespace Gabut {
remove_timeout ();
break;
case StatusMode.COMPLETE:
start_button.set_label (_("Open"));
statuslabel.label = _("Complete");
start_button.set_label (_("Complete"));
statuslabel.attributes = color_attribute (60000, 30000, 19764);
remove_timeout ();
if (aria_str_files (AriaGetfiles.PATH, ariagid).contains ("[METADATA]")) {
close ();
}
break;
case StatusMode.WAIT:
start_button.set_label (_("Wait"));
start_button.set_label (_("Pause"));
statuslabel.label = _("Waiting");
statuslabel.attributes = color_attribute (0, 0, 42588);
remove_timeout ();
break;
case StatusMode.ERROR:
start_button.set_label (_("Resume"));
statuslabel.label = _("Error");
statuslabel.attributes = color_attribute (60000, 0, 0);
remove_timeout ();
close ();
break;
case StatusMode.NOTHING:
statuslabel.label = _("Nothing Process!, Press Download for continue");
statuslabel.attributes = color_attribute (28705, 4000, 9882);
download_rev.reveal_child = true;
start_button.set_label (_("New Process"));
statuslabel.label = _("Nothing Process!");
statuslabel.attributes = color_attribute (49647, 22352, 44235);
remove_timeout ();
break;
default:
Expand Down Expand Up @@ -148,9 +145,13 @@ namespace Gabut {
set {
_transferred = value;
downloaded.label = GLib.format_size (_transferred, GLib.FormatSizeFlags.LONG_FORMAT);
double fraction = (double) transferred / (double) totalsize;
if (fraction > 0.0) {
progressbar.fraction = fraction;
if (totalsize > 0) {
double fraction = (double) transferred / (double) totalsize;
if (fraction > 0.0) {
progressbar.fraction = fraction;
}
} else {
progressbar.pulse ();
}
}
}
Expand Down Expand Up @@ -189,6 +190,7 @@ namespace Gabut {

progressbar = new Gtk.ProgressBar () {
hexpand = true,
pulse_step = 0.2,
width_request = 600
};

Expand Down Expand Up @@ -417,21 +419,6 @@ namespace Gabut {
boxstatus.attach (stack, 0, 1);
boxstatus.attach (progressbar, 0, 2);

var download = new Gtk.Button.with_label (_("Redownload")) {
width_request = 120,
height_request = 25,
halign = Gtk.Align.START
};
((Gtk.Label) download.get_last_child ()).attributes = set_attribute (Pango.Weight.SEMIBOLD);
download.clicked.connect (()=> {
sendselected (ariagid, "");
remove_timeout ();
close ();
});
download_rev = new Gtk.Revealer () {
transition_type = Gtk.RevealerTransitionType.CROSSFADE,
child = download
};
var close_button = new Gtk.Button.with_label (_("Close")) {
width_request = 120,
height_request = 25,
Expand All @@ -449,14 +436,17 @@ namespace Gabut {
halign = Gtk.Align.END
};
((Gtk.Label) start_button.get_last_child ()).attributes = set_attribute (Pango.Weight.SEMIBOLD);
start_button.clicked.connect (action_status);
start_button.clicked.connect (()=> {
string agid = actions_button (ariagid, status);
ariagid = agid;
get_active_status ();
});

var box_action = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 5) {
halign = Gtk.Align.END,
margin_top = 10,
margin_bottom = 10
};
box_action.append (download_rev);
box_action.append (start_button);
box_action.append (close_button);

Expand Down Expand Up @@ -493,11 +483,7 @@ namespace Gabut {

public override void show () {
base.show ();
Idle.add (()=> {
update_progress ();
add_timeout ();
return false;
});
Idle.add (()=> { update_progress (); return false; });
}

private Gtk.TreeViewColumn text_column (string title, int column) {
Expand Down Expand Up @@ -573,28 +559,6 @@ namespace Gabut {
status = status_aria (aria_tell_status (ariagid, TellStatus.STATUS));
}

private void action_status () {
status = status_aria (aria_tell_status (ariagid, TellStatus.STATUS));
if (status == StatusMode.ACTIVE) {
aria_pause (ariagid);
remove_timeout ();
} else if (status == StatusMode.PAUSED) {
aria_unpause (ariagid);
add_timeout ();
} else if (status == StatusMode.COMPLETE) {
remove_timeout ();
} else if (status == StatusMode.WAIT) {
add_timeout ();
} else {
remove_timeout ();
close ();
}
status = status_aria (aria_tell_status (ariagid, TellStatus.STATUS));
if (status != StatusMode.COMPLETE) {
application.activate_action ("status", new Variant.string (ariagid));
}
}

public void aria_gid (string ariagid) {
this.ariagid = ariagid;
down_limit.value = double.parse (aria_get_option (ariagid, AriaOptions.MAX_DOWNLOAD_LIMIT)) / 1024;
Expand Down
Loading

0 comments on commit e78bd55

Please sign in to comment.