diff --git a/Screenshot0.png b/Screenshot0.png index 42632e3..c3865cb 100644 Binary files a/Screenshot0.png and b/Screenshot0.png differ diff --git a/Screenshot1.png b/Screenshot1.png index c88663d..7f5adb6 100644 Binary files a/Screenshot1.png and b/Screenshot1.png differ diff --git a/Screenshot2.png b/Screenshot2.png index bff7917..b757a6b 100644 Binary files a/Screenshot2.png and b/Screenshot2.png differ diff --git a/Screenshot3.png b/Screenshot3.png index 090b406..6ca6ec4 100644 Binary files a/Screenshot3.png and b/Screenshot3.png differ diff --git a/src/Application.vala b/src/Application.vala index 8bcd31f..8d76d2c 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -170,7 +170,7 @@ namespace Gabut { open_now (); } lastclipboard = get_dbsetting (Gabut.DBSettings.LASTCLIPBOARD); - clipboard = Gdk.Display.get_default ().get_clipboard (); + clipboard = gabutwindow.get_clipboard (); Timeout.add_seconds (1, on_clipboard); } else { open_now (); diff --git a/src/DownloadRow.vala b/src/DownloadRow.vala index a8e2355..9d4c2fd 100644 --- a/src/DownloadRow.vala +++ b/src/DownloadRow.vala @@ -32,6 +32,7 @@ namespace Gabut { public Gtk.Image badge_img; public DbusmenuItem rowbus; private bool stoptimer; + private uint timeout_id = 0; public Gee.HashMap hashoption = new Gee.HashMap (); private int _linkmode; @@ -570,7 +571,6 @@ namespace Gabut { GLib.Application.get_default ().lookup_action ("downloader").activate (new Variant.string (ariagid)); } - private uint timeout_id = 0; private void add_timeout () { if (timeout_id == 0) { stoptimer = GLib.Source.CONTINUE; diff --git a/src/Downloader.vala b/src/Downloader.vala index d4351f2..4dd4958 100644 --- a/src/Downloader.vala +++ b/src/Downloader.vala @@ -49,6 +49,9 @@ namespace Gabut { private Gtk.Stack connpeers; private ModeButton view_mode; private bool stoptimer; + private int loadfile = 0; + private int totalfile = 0; + private uint timeout_id = 0; private bool _switch_rev; public bool switch_rev { @@ -187,13 +190,9 @@ namespace Gabut { } } - public Downloader () { - Object (resizable: false, - use_header_bar: 1 - ); - } - construct { + resizable = false; + use_header_bar = 1; view_mode = new ModeButton () { hexpand = true, homogeneous = true, @@ -209,14 +208,16 @@ namespace Gabut { switch (view_mode.selected) { case 1: torrentmode.label = _("Mode: %s").printf (aria_tell_bittorent (ariagid, TellBittorrent.MODE)); - var timesn = new GLib.DateTime.from_unix_local (int64.parse (aria_tell_bittorent (ariagid, TellBittorrent.CREATIONDATE))); - timecreation.label = _("Time Creation: %s").printf (timesn.format ("%a, %I:%M %p %x")); + var datetime = aria_tell_bittorent (ariagid, TellBittorrent.CREATIONDATE); + timecreation.label = _("Time Creation: %s").printf (datetime.strip () != ""? new GLib.DateTime.from_unix_local (int64.parse (datetime)).format ("%a, %I:%M %p %x") : ""); infotorrent.buffer.text = aria_tell_bittorent (ariagid, TellBittorrent.ANNOUNCELIST).strip (); var commenttorrent = aria_tell_bittorent (ariagid, TellBittorrent.COMMENT); commenttext.buffer.text = commenttorrent.contains ("\\/")? GLib.Uri.unescape_string (commenttorrent.replace ("\\/", "/")) : commenttorrent; break; case 2: - show_files (); + if (status != StatusMode.ACTIVE) { + show_files (); + } break; case 3: down_limit.value = double.parse (aria_get_option (ariagid, AriaOptions.MAX_DOWNLOAD_LIMIT)) / 1024; @@ -383,6 +384,7 @@ namespace Gabut { }; listboxtorrent = new Gtk.ListBox (); listtorrent = new Gee.ArrayList (); + listboxtorrent.set_sort_func ((Gtk.ListBoxSortFunc) sort_index); var torrscrolled = new Gtk.ScrolledWindow () { hexpand = true, @@ -558,6 +560,19 @@ namespace Gabut { }); } + [CCode (instance_pos = -1)] + private int sort_index (TorrentRow row1, TorrentRow row2) { + var total1 = row1.index; + var total2 = row2.index; + if (total1 > total2) { + return 1; + } + if (total1 < total2) { + return -1; + } + return 0; + } + public override void show () { update_progress (); base.show (); @@ -567,7 +582,6 @@ namespace Gabut { status = status_aria (aria_tell_status (ariagid, TellStatus.STATUS)); } - private uint timeout_id = 0; private void add_timeout () { if (timeout_id == 0) { stoptimer = GLib.Source.CONTINUE; @@ -638,6 +652,7 @@ namespace Gabut { } } else if (view_mode.selected == 2) { show_files (); + loadfile++; } if (switch_rev) { if (connpeers.get_visible_child_name () == "serverconn") { @@ -736,60 +751,62 @@ namespace Gabut { } private void show_files () { - aria_files_store (ariagid).foreach ((torrentstore) => { - if (torrentstore.filepath == "" || torrentstore.filepath == null) { - return true; - } - if (torrentstore.filepath.contains ("[METADATA]")) { - return true; - } - if (torrentstore.filebasename == null || torrentstore.filesize == null || torrentstore.completesize == null) { - return true; - } - if (!files_exist (torrentstore)) { - listtorrent.add (torrentstore); - listboxtorrent.append (torrentstore); - torrentstore.show (); - torrentstore.selecting.connect ((index, selected)=> { - var builder = new StringBuilder (); - uint hashb = builder.str.hash (); - listtorrent.foreach ((torrentrow)=> { - var selectfile = torrentrow.selected; - if (torrentrow.index == index) { - selectfile = selected; - } - if (selectfile) { - if (hashb == builder.str.hash ()) { - builder.append (torrentrow.index.to_string ()); - } else { - builder.append (","); - builder.append (torrentrow.index.to_string ()); + if (loadfile >= totalfile) { + var fileshow = aria_files_store (ariagid); + totalfile = fileshow.size > 100? 6 : 2; + fileshow.foreach ((torrentstore) => { + if (torrentstore.value.filepath == "" || torrentstore.value.filepath == null) { + return true; + } + if (torrentstore.value.filepath.contains ("[METADATA]")) { + return true; + } + if (torrentstore.value.filebasename == null || torrentstore.value.sizetransfered == null || torrentstore.value.completesize == null) { + return true; + } + if (!files_exist (torrentstore.key, torrentstore.value)) { + listtorrent.add (torrentstore.value); + listboxtorrent.append (torrentstore.value); + torrentstore.value.show (); + torrentstore.value.selecting.connect ((index, selected)=> { + var builder = new StringBuilder (); + uint hashb = builder.str.hash (); + listtorrent.foreach ((torrentrow)=> { + var selectfile = torrentrow.selected; + if (torrentrow.index == index) { + selectfile = selected; } + if (selectfile) { + if (hashb == builder.str.hash ()) { + builder.append (torrentrow.index.to_string ()); + } else { + builder.append (","); + builder.append (torrentrow.index.to_string ()); + } + } + return true; + }); + if (hashb == builder.str.hash ()) { + return; } - return true; + string aria_gid = sendselected (ariagid, builder.str); + this.ariagid = aria_gid; + update_progress (); }); - if (hashb == builder.str.hash ()) { - return; - } - string aria_gid = sendselected (ariagid, builder.str); - this.ariagid = aria_gid; - update_progress (); - }); - } - return true; - }); + } + return true; + }); + loadfile = 0; + } } - private bool files_exist (TorrentRow torrentrw) { + private bool files_exist (string path, TorrentRow torrentrw) { bool exist = false; listtorrent.foreach ((torrentrow)=> { - if (torrentrow.filepath == torrentrw.filepath) { + if (torrentrow.filepath == path) { exist = true; - torrentrow.index = torrentrw.index; torrentrow.selected = torrentrw.selected; - torrentrow.filebasename = torrentrw.filebasename; - torrentrow.filesize = torrentrw.filesize; - torrentrow.completesize = torrentrw.completesize; + torrentrow.sizetransfered = torrentrw.sizetransfered; torrentrow.fraction = torrentrw.fraction; torrentrow.status = torrentrw.status; torrentrow.persen = torrentrw.persen; diff --git a/src/GabutWindow.vala b/src/GabutWindow.vala index f505b72..ba232e0 100644 --- a/src/GabutWindow.vala +++ b/src/GabutWindow.vala @@ -838,6 +838,9 @@ namespace Gabut { } public void remove_all () { + if (starting || stoping || removing) { + return; + } var totalsize = listrow.size; int index = 0; Idle.add (()=> { @@ -1044,7 +1047,7 @@ namespace Gabut { } private void start_all () { - if (stoping) { + if (starting || stoping || removing) { return; } int index = activedm (); @@ -1074,7 +1077,7 @@ namespace Gabut { } private void stop_all () { - if (starting) { + if (starting || stoping || removing) { return; } int index = 0; diff --git a/src/GdmMenu.vala b/src/GdmMenu.vala index fffbb10..d04f784 100755 --- a/src/GdmMenu.vala +++ b/src/GdmMenu.vala @@ -25,7 +25,6 @@ namespace Gabut { public GdmMenu (DownloadMenu downloadmenu) { this.downloadmenu = downloadmenu; - halign = Gtk.Align.CENTER; var title = new Gtk.Label (downloadmenu.to_string ()) { xalign = 0, margin_top = 6, @@ -38,6 +37,7 @@ namespace Gabut { }; var imgstatus = new Gtk.Image () { valign = Gtk.Align.CENTER, + halign = Gtk.Align.START, gicon = new ThemedIcon (downloadmenu.to_icon ()) }; var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); diff --git a/src/OpenMenu.vala b/src/OpenMenu.vala index cc06e06..5ee5162 100755 --- a/src/OpenMenu.vala +++ b/src/OpenMenu.vala @@ -25,7 +25,6 @@ namespace Gabut { public OpenMenu (OpenMenus openmn) { this.openmn = openmn; - halign = Gtk.Align.CENTER; var title = new Gtk.Label (openmn.to_string ()) { xalign = 0, margin_top = 6, @@ -38,6 +37,7 @@ namespace Gabut { }; var imgstatus = new Gtk.Image () { valign = Gtk.Align.CENTER, + halign = Gtk.Align.START, gicon = new ThemedIcon (openmn.to_icon ()) }; var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); diff --git a/src/ProgressPaint.vala b/src/ProgressPaint.vala index baa3c8c..e5fc48c 100644 --- a/src/ProgressPaint.vala +++ b/src/ProgressPaint.vala @@ -40,7 +40,7 @@ namespace Gabut { cr.set_source_rgba (0.0, 1.0, 0.0 , 1.0); cr.arc (0, 0, width / 2.0 + 1, -GLib.Math.PI / 2, arc_end); cr.stroke (); - cr.set_source_rgba (1.0, 0.0, 0.0, 1.0); + cr.set_source_rgba (1.0, 0.5, 0.0, 1.0); cr.arc (0, 0, width / 2.0 + 1, arc_end, 3.0 * GLib.Math.PI / 2.0); cr.stroke (); } diff --git a/src/TorrentRow.vala b/src/TorrentRow.vala index e03ee46..03df86f 100644 --- a/src/TorrentRow.vala +++ b/src/TorrentRow.vala @@ -30,6 +30,7 @@ namespace Gabut { private Gtk.Label filesizelabel; private Gtk.Label statuslabel; private Gtk.Label persenlabel; + private Gtk.Label index_label; private ProgressPaintable progrespaint; private int _index; @@ -39,7 +40,7 @@ namespace Gabut { } set { _index = value; - checkbtn.tooltip_text = _index.to_string (); + index_label.label = _index.to_string (); } } @@ -76,14 +77,14 @@ namespace Gabut { } } - private string _filesize; - public string filesize { + private string _sizetransfered; + public string sizetransfered { get { - return _filesize; + return _sizetransfered; } set { - _filesize = value; - filesizelabel.label = _filesize; + _sizetransfered = value; + filesizelabel.label = _sizetransfered; } } @@ -116,7 +117,7 @@ namespace Gabut { } set { _persen = value; - persenlabel.label = _("%s%s").printf (_persen.to_string (), "%"); + persenlabel.tooltip_text = persenlabel.label = _("%s%s").printf (_persen.to_string (), "%"); } } @@ -138,6 +139,14 @@ namespace Gabut { selecting (index, !selected); }); + index_label = new Gtk.Label (null) { + use_markup = true, + valign = Gtk.Align.CENTER, + width_request = 35, + tooltip_text = _("Index"), + attributes = color_attribute (60000, 0, 0) + }; + fileimg = new Gtk.Image () { valign = Gtk.Align.CENTER }; @@ -173,7 +182,7 @@ namespace Gabut { use_markup = true, width_request = 55, valign = Gtk.Align.CENTER, - attributes = color_attribute (60000, 0, 0) + attributes = color_attribute (60000, 30000, 0) }; progrespaint = new ProgressPaintable (); var progresimg = new Gtk.Image () { @@ -186,11 +195,14 @@ namespace Gabut { persenlabel = new Gtk.Label (null) { xalign = 0, use_markup = true, - width_request = 35, valign = Gtk.Align.CENTER, halign = Gtk.Align.CENTER, - attributes = set_attribute (Pango.Weight.SEMIBOLD) + attributes = set_attribute (Pango.Weight.BOLD, 0.5) + }; + var prgoverlay = new Gtk.Overlay () { + child = progresimg }; + prgoverlay.add_overlay (persenlabel); imgstatus = new Gtk.Image () { valign = Gtk.Align.CENTER, @@ -216,14 +228,14 @@ namespace Gabut { valign = Gtk.Align.CENTER }; grid.attach (checkbtn, 0, 0); - grid.attach (fileimg, 1, 0); - grid.attach (file_label, 2, 0); - grid.attach (downloadingimg, 3, 0); - grid.attach (filesizelabel, 4, 0); - grid.attach (imgfilesize, 5, 0); - grid.attach (coplatelabel, 6, 0); - grid.attach (progresimg, 7, 0); - grid.attach (persenlabel, 8, 0); + grid.attach (index_label, 1, 0); + grid.attach (fileimg, 2, 0); + grid.attach (file_label, 3, 0); + grid.attach (downloadingimg, 4, 0); + grid.attach (filesizelabel, 5, 0); + grid.attach (imgfilesize, 6, 0); + grid.attach (coplatelabel, 7, 0); + grid.attach (prgoverlay, 8, 0); grid.attach (imgstatus, 9, 0); grid.attach (statuslabel, 10, 0); child = grid; diff --git a/src/Utils.vala b/src/Utils.vala index ae8b22d..f821935 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -1853,8 +1853,8 @@ namespace Gabut { return listgid; } - private Gee.ArrayList aria_files_store (string gid) { - var torrentstore = new Gee.ArrayList (); + private Gee.HashMap aria_files_store (string gid) { + var torrentstore = new Gee.HashMap (); string result = get_soupmess (@"{\"jsonrpc\":\"2.0\", \"id\":\"qwer\", \"method\":\"aria2.getFiles\", \"params\":[\"$(gid)\"]}"); if (!result.down ().contains ("result") || result == null) { return torrentstore; @@ -1877,12 +1877,12 @@ namespace Gabut { filebasename = file.get_basename (), filepath = file.get_path (), completesize = GLib.format_size (total), - filesize = GLib.format_size (transfer), + sizetransfered = GLib.format_size (transfer), fraction = fraction, status = status, persen = persen }; - torrentstore.add (torrentfile); + torrentstore.set (file.get_path (), torrentfile); match_info.next (); } }