Skip to content

Commit 291f5b3

Browse files
authored
Merge pull request #261 from torikulhabib/master
Style
2 parents 542d95d + 4f344ee commit 291f5b3

File tree

4 files changed

+122
-14
lines changed

4 files changed

+122
-14
lines changed

Screenshot0.png

-5.12 KB
Loading

src/Downloader.vala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ namespace Gabut {
532532
maingrid.append (revcon);
533533

534534
notify["switch-rev"].connect (()=> {
535-
revcon.queue_allocate ();
536535
if (switch_rev) {
537536
lisboxserver.show ();
538537
listboxpeers.show ();
@@ -542,7 +541,6 @@ namespace Gabut {
542541
listboxpeers.hide ();
543542
revcon.reveal_child = false;
544543
}
545-
revcon.queue_allocate ();
546544
});
547545

548546
view_mode.notify["selected"].connect (() => {

src/GabutWindow.vala

Lines changed: 119 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace Gabut {
2929
public signal void update_agid (string ariagid, string newgid);
3030
public signal string get_host ();
3131
private Gtk.ListBox list_box;
32-
private Gtk.Label labelall;
32+
private Gtk.Label labelview;
3333
private Gtk.Stack headerstack;
3434
private Preferences preferences;
3535
private QrCode qrcode;
@@ -45,6 +45,10 @@ namespace Gabut {
4545
private Gtk.MenuButton shortbutton;
4646
private Gtk.CheckButton showtime;
4747
private Gtk.CheckButton showdate;
48+
private Gtk.Label download_rate;
49+
private Gtk.Label upload_rate;
50+
private Gtk.Label labelact;
51+
private Gtk.Image modeview;
4852
private int64 animation = 0;
4953

5054
SortBy _sorttype = null;
@@ -243,16 +247,83 @@ namespace Gabut {
243247
headerstack.visible_child_name = "mode";
244248
headerstack.show ();
245249

246-
labelall = new Gtk.Label ("Active: 0 Download: 0 Upload: 0") {
250+
modeview = new Gtk.Image () {
251+
margin_start = 6,
252+
valign = Gtk.Align.CENTER,
253+
gicon = new ThemedIcon ("com.github.gabutakut.gabutdm")
254+
};
255+
256+
labelview = new Gtk.Label (null) {
247257
ellipsize = Pango.EllipsizeMode.END,
248-
hexpand = true,
249-
margin_top = 4,
250-
margin_bottom = 4,
258+
valign = Gtk.Align.CENTER,
259+
margin_start = 10,
260+
attributes = set_attribute (Pango.Weight.SEMIBOLD)
261+
};
262+
var boxinfo = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
263+
boxinfo.append (modeview);
264+
boxinfo.append (labelview);
265+
266+
var img_download = new Gtk.Image () {
267+
valign = Gtk.Align.CENTER,
268+
gicon = new ThemedIcon ("com.github.gabutakut.gabutdm.down"),
269+
tooltip_text = _("Download Speed")
270+
};
271+
download_rate = new Gtk.Label (null) {
272+
xalign = 0,
273+
use_markup = true,
274+
width_request = 70,
275+
valign = Gtk.Align.CENTER,
276+
attributes = color_attribute (0, 60000, 0)
277+
};
278+
var img_upload = new Gtk.Image () {
279+
valign = Gtk.Align.CENTER,
280+
gicon = new ThemedIcon ("com.github.gabutakut.gabutdm.up"),
281+
tooltip_text = _("Upload Speed")
282+
};
283+
upload_rate = new Gtk.Label (null) {
284+
xalign = 0,
285+
use_markup = true,
286+
width_request = 70,
287+
valign = Gtk.Align.CENTER,
288+
attributes = color_attribute (60000, 0, 0)
289+
};
290+
var gridinf = new Gtk.Grid () {
291+
valign = Gtk.Align.CENTER,
292+
halign = Gtk.Align.CENTER
293+
};
294+
gridinf.attach (img_download, 0, 0);
295+
gridinf.attach (download_rate, 1, 0);
296+
gridinf.attach (img_upload, 2, 0);
297+
gridinf.attach (upload_rate, 3, 0);
298+
299+
var imgactive = new Gtk.Image () {
300+
valign = Gtk.Align.CENTER,
301+
margin_end = 6,
302+
gicon = new ThemedIcon ("com.github.gabutakut.gabutdm.active"),
303+
tooltip_text = _("Active Download")
304+
};
305+
306+
labelact = new Gtk.Label (null) {
307+
ellipsize = Pango.EllipsizeMode.END,
308+
valign = Gtk.Align.CENTER,
309+
margin_end = 10,
251310
attributes = set_attribute (Pango.Weight.SEMIBOLD)
252311
};
312+
var boxact = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
313+
boxact.append (imgactive);
314+
boxact.append (labelact);
315+
316+
var ceninfo = new Gtk.CenterBox () {
317+
orientation = Gtk.Orientation.HORIZONTAL,
318+
margin_top = 2,
319+
margin_bottom = 2,
320+
start_widget = boxinfo,
321+
center_widget = gridinf,
322+
end_widget = boxact
323+
};
253324

254325
var mainwindow = new Gtk.Grid ();
255-
mainwindow.attach (labelall, 0, 0);
326+
mainwindow.attach (ceninfo, 0, 0);
256327
mainwindow.attach (scrolled, 0, 1);
257328
mainwindow.attach (headerstack, 0, 2);
258329
child = mainwindow;
@@ -758,6 +829,7 @@ namespace Gabut {
758829
listrow.get (0).remove_down ();
759830
}
760831
aria_purge_all ();
832+
view_status ();
761833
}
762834

763835
public void load_dowanload () {
@@ -805,9 +877,9 @@ namespace Gabut {
805877
list_box.remove (row);
806878
remove_dbus.begin (row.rowbus);
807879
next_download ();
808-
view_status ();
809880
listrow.remove (row);
810881
stop_launcher ();
882+
view_status ();
811883
});
812884
row.update_agid.connect ((ariagid, newgid)=> {
813885
update_agid (ariagid, newgid);
@@ -817,6 +889,7 @@ namespace Gabut {
817889
});
818890
listrow.sort (sort_dm);
819891
update_info ();
892+
view_status ();
820893
}
821894

822895
public void add_url_box (string url, Gee.HashMap<string, string> options, bool later, int linkmode) {
@@ -863,9 +936,9 @@ namespace Gabut {
863936
list_box.remove (row);
864937
remove_dbus.begin (row.rowbus);
865938
next_download ();
866-
view_status ();
867939
listrow.remove (row);
868940
stop_launcher ();
941+
view_status ();
869942
});
870943
row.update_agid.connect ((ariagid, newgid)=> {
871944
update_agid (ariagid, newgid);
@@ -883,6 +956,7 @@ namespace Gabut {
883956
}
884957
listrow.sort (sort_dm);
885958
update_info ();
959+
view_status ();
886960
}
887961

888962
public int activedm () {
@@ -898,12 +972,14 @@ namespace Gabut {
898972

899973
private void update_info () {
900974
var infol = aria_label_info ();
901-
var activedmapp = int64.parse (infol.fetch (2));
902-
labelall.label = _("List: %i Active: %i Download: %s Upload: %s").printf (listrow.size, (int)activedmapp, GLib.format_size (activedmapp > 0? int64.parse (infol.fetch (1)) : 0), GLib.format_size (activedmapp > 0? int64.parse (infol.fetch (6)) : 0));
975+
var allactive = int64.parse (infol.fetch (2));
976+
download_rate.label = GLib.format_size (allactive > 0? int64.parse (infol.fetch (1)) : 0);
977+
upload_rate.label = GLib.format_size (allactive > 0? int64.parse (infol.fetch (6)) : 0);
978+
labelact.label = allactive.to_string ();
903979
if (!indmenu) {
904980
return;
905981
}
906-
if (activedmapp > 0) {
982+
if (allactive > 0) {
907983
if (animation % 2 == 0) {
908984
dbusindicator.updateiconame = "com.github.gabutakut.gabutdm.seed";
909985
dbusindicator.new_icon ();
@@ -917,7 +993,7 @@ namespace Gabut {
917993
animation++;
918994
}
919995
if (menulabel == 2) {
920-
dbusindicator.updateLabel = " %s".printf (GLib.format_size (activedmapp > 0? int64.parse (infol.fetch (6)) + int64.parse (infol.fetch (1)) : 0));
996+
dbusindicator.updateLabel = " %s".printf (GLib.format_size (allactive > 0? int64.parse (infol.fetch (6)) + int64.parse (infol.fetch (1)) : 0));
921997
dbusindicator.x_ayatana_new_label (dbusindicator.updateLabel, "");
922998
}
923999
}
@@ -1091,9 +1167,12 @@ namespace Gabut {
10911167
}
10921168

10931169
public void view_status () {
1170+
int indexv = 0;
10941171
if (headerstack.visible_child_name == "search") {
1172+
modeview.gicon = new ThemedIcon ("com.github.gabutakut.gabutdm.find");
10951173
if (search_entry.text.strip () == "") {
10961174
list_box.set_filter_func ((item) => {
1175+
indexv = 0;
10971176
return false;
10981177
});
10991178
var search_alert = new AlertView (
@@ -1103,6 +1182,7 @@ namespace Gabut {
11031182
);
11041183
search_alert.show ();
11051184
list_box.set_placeholder (search_alert);
1185+
labelview.label = indexv.to_string ();
11061186
return;
11071187
}
11081188
bool item_visible = false;
@@ -1113,6 +1193,10 @@ namespace Gabut {
11131193
if (((DownloadRow) item).filename == null) {
11141194
return false;
11151195
}
1196+
if (((DownloadRow) item).filename.casefold ().contains (search_entry.text.casefold ())) {
1197+
indexv++;
1198+
}
1199+
labelview.label = indexv.to_string ();
11161200
return ((DownloadRow) item).filename.casefold ().contains (search_entry.text.casefold ());
11171201
});
11181202
if (!item_visible) {
@@ -1129,61 +1213,81 @@ namespace Gabut {
11291213
switch (view_mode.selected) {
11301214
case 1:
11311215
list_box.set_filter_func ((item) => {
1216+
if (((DownloadRow)item).status == StatusMode.ACTIVE) {
1217+
indexv++;
1218+
}
11321219
return ((DownloadRow) item).status == StatusMode.ACTIVE;
11331220
});
11341221
var active_alert = new AlertView (
11351222
_("No Active Download"),
11361223
_("Drag and Drop URL, Torrent, Metalink, Magnet URIs."),
11371224
"com.github.gabutakut.gabutdm.active"
11381225
);
1226+
modeview.gicon = new ThemedIcon ("com.github.gabutakut.gabutdm.active");
11391227
active_alert.show ();
11401228
list_box.set_placeholder (active_alert);
11411229
break;
11421230
case 2:
11431231
list_box.set_filter_func ((item) => {
1232+
if (((DownloadRow)item).status == StatusMode.PAUSED) {
1233+
indexv++;
1234+
}
11441235
return ((DownloadRow) item).status == StatusMode.PAUSED;
11451236
});
11461237
var nopause_alert = new AlertView (
11471238
_("No Paused Download"),
11481239
_("Drag and Drop URL, Torrent, Metalink, Magnet URIs."),
11491240
"com.github.gabutakut.gabutdm.pause"
11501241
);
1242+
modeview.gicon = new ThemedIcon ("com.github.gabutakut.gabutdm.pause");
11511243
nopause_alert.show ();
11521244
list_box.set_placeholder (nopause_alert);
11531245
break;
11541246
case 3:
11551247
list_box.set_filter_func ((item) => {
1248+
if (((DownloadRow)item).status == StatusMode.COMPLETE) {
1249+
indexv++;
1250+
}
11561251
return ((DownloadRow) item).status == StatusMode.COMPLETE;
11571252
});
11581253
var nocomp_alerst = new AlertView (
11591254
_("No Complete Download"),
11601255
_("Drag and Drop URL, Torrent, Metalink, Magnet URIs."),
11611256
"com.github.gabutakut.gabutdm.complete"
11621257
);
1258+
modeview.gicon = new ThemedIcon ("com.github.gabutakut.gabutdm.complete");
11631259
nocomp_alerst.show ();
11641260
list_box.set_placeholder (nocomp_alerst);
11651261
break;
11661262
case 4:
11671263
list_box.set_filter_func ((item) => {
1264+
if (((DownloadRow)item).status == StatusMode.WAIT) {
1265+
indexv++;
1266+
}
11681267
return ((DownloadRow) item).status == StatusMode.WAIT;
11691268
});
11701269
var nowait_alert = new AlertView (
11711270
_("No Waiting Download"),
11721271
_("Drag and Drop URL, Torrent, Metalink, Magnet URIs."),
11731272
"com.github.gabutakut.gabutdm.waiting"
11741273
);
1274+
modeview.gicon = new ThemedIcon ("com.github.gabutakut.gabutdm.waiting");
11751275
nowait_alert.show ();
11761276
list_box.set_placeholder (nowait_alert);
11771277
break;
11781278
case 5:
11791279
list_box.set_filter_func ((item) => {
1280+
if (((DownloadRow)item).status == StatusMode.ERROR) {
1281+
indexv++;
1282+
}
11801283
return ((DownloadRow) item).status == StatusMode.ERROR;
11811284
});
11821285
var noerr_alert = new AlertView (
11831286
_("No Error Download"),
11841287
_("Drag and Drop URL, Torrent, Metalink, Magnet URIs."),
11851288
"com.github.gabutakut.gabutdm.error"
11861289
);
1290+
modeview.gicon = new ThemedIcon ("com.github.gabutakut.gabutdm.error");
11871291
noerr_alert.show ();
11881292
list_box.set_placeholder (noerr_alert);
11891293
break;
@@ -1195,11 +1299,14 @@ namespace Gabut {
11951299
}
11961300
return true;
11971301
});
1302+
indexv = listrow.size;
1303+
modeview.gicon = new ThemedIcon ("com.github.gabutakut.gabutdm");
11981304
if (!hide_alert) {
11991305
list_box.set_placeholder (nodown_alert);
12001306
}
12011307
break;
12021308
}
1309+
labelview.label = indexv.to_string ();
12031310
list_box.set_sort_func ((Gtk.ListBoxSortFunc) sort_dm);
12041311
listrow.sort (sort_dm);
12051312
}

src/Preferences.vala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,9 +678,11 @@ namespace Gabut {
678678
label_rev.reveal_child = menuindicator.active;
679679
menuindicator.toggled.connect (()=> {
680680
label_rev.reveal_child = menuindicator.active;
681+
label_mode.sensitive = dbusmenu.active && menuindicator.active;
681682
});
682683
dbusmenu.toggled.connect (()=> {
683684
menuindicator.sensitive = dbusmenu.active;
685+
label_mode.sensitive = dbusmenu.active && menuindicator.active;
684686
});
685687
var tdefault = new Gtk.CheckButton.with_label (_("Theme")) {
686688
margin_top = 5,
@@ -755,6 +757,7 @@ namespace Gabut {
755757
notifyopt.attach (headerlabel (_("File Download:"), 450), 0, 16, 1, 1);
756758
notifyopt.attach (allowrepl, 0, 17, 1, 1);
757759
notifyopt.attach (autorename, 0, 18, 1, 1);
760+
label_mode.sensitive = dbusmenu.active && menuindicator.active;
758761

759762
var notyscr = new Gtk.ScrolledWindow () {
760763
width_request = 455,

0 commit comments

Comments
 (0)