@@ -29,7 +29,7 @@ namespace Gabut {
29
29
public signal void update_agid (string ariagid , string newgid );
30
30
public signal string get_host ();
31
31
private Gtk . ListBox list_box;
32
- private Gtk . Label labelall ;
32
+ private Gtk . Label labelview ;
33
33
private Gtk . Stack headerstack;
34
34
private Preferences preferences;
35
35
private QrCode qrcode;
@@ -45,6 +45,10 @@ namespace Gabut {
45
45
private Gtk . MenuButton shortbutton;
46
46
private Gtk . CheckButton showtime;
47
47
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;
48
52
private int64 animation = 0 ;
49
53
50
54
SortBy _sorttype = null ;
@@ -243,16 +247,83 @@ namespace Gabut {
243
247
headerstack. visible_child_name = " mode" ;
244
248
headerstack. show ();
245
249
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 ) {
247
257
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 ,
251
310
attributes = set_attribute (Pango .Weight .SEMIBOLD )
252
311
};
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
+ };
253
324
254
325
var mainwindow = new Gtk .Grid ();
255
- mainwindow.attach (labelall , 0 , 0 );
326
+ mainwindow.attach (ceninfo , 0 , 0 );
256
327
mainwindow.attach (scrolled , 0 , 1 );
257
328
mainwindow.attach (headerstack , 0 , 2 );
258
329
child = mainwindow;
@@ -758,6 +829,7 @@ namespace Gabut {
758
829
listrow. get (0 ). remove_down ();
759
830
}
760
831
aria_purge_all ();
832
+ view_status ();
761
833
}
762
834
763
835
public void load_dowanload () {
@@ -805,9 +877,9 @@ namespace Gabut {
805
877
list_box. remove (row);
806
878
remove_dbus. begin (row. rowbus);
807
879
next_download ();
808
- view_status ();
809
880
listrow. remove (row);
810
881
stop_launcher ();
882
+ view_status ();
811
883
});
812
884
row. update_agid. connect ((ariagid, newgid)= > {
813
885
update_agid (ariagid, newgid);
@@ -817,6 +889,7 @@ namespace Gabut {
817
889
});
818
890
listrow. sort (sort_dm);
819
891
update_info ();
892
+ view_status ();
820
893
}
821
894
822
895
public void add_url_box (string url, Gee . HashMap<string, string> options, bool later, int linkmode) {
@@ -863,9 +936,9 @@ namespace Gabut {
863
936
list_box. remove (row);
864
937
remove_dbus. begin (row. rowbus);
865
938
next_download ();
866
- view_status ();
867
939
listrow. remove (row);
868
940
stop_launcher ();
941
+ view_status ();
869
942
});
870
943
row.update_agid.connect ((ariagid , newgid )=> {
871
944
update_agid (ariagid, newgid);
@@ -883,6 +956,7 @@ namespace Gabut {
883
956
}
884
957
listrow.sort (sort_dm );
885
958
update_info ();
959
+ view_status ();
886
960
}
887
961
888
962
public int activedm () {
@@ -898,12 +972,14 @@ namespace Gabut {
898
972
899
973
private void update_info () {
900
974
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 ();
903
979
if (! indmenu) {
904
980
return ;
905
981
}
906
- if (activedmapp > 0 ) {
982
+ if (allactive > 0 ) {
907
983
if (animation % 2 == 0 ) {
908
984
dbusindicator. updateiconame = " com.github.gabutakut.gabutdm.seed" ;
909
985
dbusindicator. new_icon ();
@@ -917,7 +993,7 @@ namespace Gabut {
917
993
animation++ ;
918
994
}
919
995
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 ));
921
997
dbusindicator. x_ayatana_new_label (dbusindicator. updateLabel, " " );
922
998
}
923
999
}
@@ -1091,9 +1167,12 @@ namespace Gabut {
1091
1167
}
1092
1168
1093
1169
public void view_status () {
1170
+ int indexv = 0 ;
1094
1171
if (headerstack. visible_child_name == " search" ) {
1172
+ modeview. gicon = new ThemedIcon (" com.github.gabutakut.gabutdm.find" );
1095
1173
if (search_entry. text. strip () == " " ) {
1096
1174
list_box. set_filter_func ((item) = > {
1175
+ indexv = 0 ;
1097
1176
return false ;
1098
1177
});
1099
1178
var search_alert = new AlertView (
@@ -1103,6 +1182,7 @@ namespace Gabut {
1103
1182
);
1104
1183
search_alert. show ();
1105
1184
list_box. set_placeholder (search_alert);
1185
+ labelview. label = indexv. to_string ();
1106
1186
return ;
1107
1187
}
1108
1188
bool item_visible = false ;
@@ -1113,6 +1193,10 @@ namespace Gabut {
1113
1193
if (((DownloadRow ) item). filename == null ) {
1114
1194
return false ;
1115
1195
}
1196
+ if (((DownloadRow ) item). filename. casefold (). contains (search_entry. text. casefold ())) {
1197
+ indexv++ ;
1198
+ }
1199
+ labelview. label = indexv. to_string ();
1116
1200
return ((DownloadRow ) item). filename. casefold (). contains (search_entry. text. casefold ());
1117
1201
});
1118
1202
if (! item_visible) {
@@ -1129,61 +1213,81 @@ namespace Gabut {
1129
1213
switch (view_mode. selected) {
1130
1214
case 1 :
1131
1215
list_box. set_filter_func ((item) = > {
1216
+ if (((DownloadRow )item). status == StatusMode . ACTIVE ) {
1217
+ indexv++ ;
1218
+ }
1132
1219
return ((DownloadRow ) item). status == StatusMode . ACTIVE ;
1133
1220
});
1134
1221
var active_alert = new AlertView (
1135
1222
_(" No Active Download" ),
1136
1223
_(" Drag and Drop URL, Torrent, Metalink, Magnet URIs." ),
1137
1224
" com.github.gabutakut.gabutdm.active"
1138
1225
);
1226
+ modeview. gicon = new ThemedIcon (" com.github.gabutakut.gabutdm.active" );
1139
1227
active_alert. show ();
1140
1228
list_box. set_placeholder (active_alert);
1141
1229
break ;
1142
1230
case 2 :
1143
1231
list_box. set_filter_func ((item) = > {
1232
+ if (((DownloadRow )item). status == StatusMode . PAUSED ) {
1233
+ indexv++ ;
1234
+ }
1144
1235
return ((DownloadRow ) item). status == StatusMode . PAUSED ;
1145
1236
});
1146
1237
var nopause_alert = new AlertView (
1147
1238
_(" No Paused Download" ),
1148
1239
_(" Drag and Drop URL, Torrent, Metalink, Magnet URIs." ),
1149
1240
" com.github.gabutakut.gabutdm.pause"
1150
1241
);
1242
+ modeview. gicon = new ThemedIcon (" com.github.gabutakut.gabutdm.pause" );
1151
1243
nopause_alert. show ();
1152
1244
list_box. set_placeholder (nopause_alert);
1153
1245
break ;
1154
1246
case 3 :
1155
1247
list_box. set_filter_func ((item) = > {
1248
+ if (((DownloadRow )item). status == StatusMode . COMPLETE ) {
1249
+ indexv++ ;
1250
+ }
1156
1251
return ((DownloadRow ) item). status == StatusMode . COMPLETE ;
1157
1252
});
1158
1253
var nocomp_alerst = new AlertView (
1159
1254
_(" No Complete Download" ),
1160
1255
_(" Drag and Drop URL, Torrent, Metalink, Magnet URIs." ),
1161
1256
" com.github.gabutakut.gabutdm.complete"
1162
1257
);
1258
+ modeview. gicon = new ThemedIcon (" com.github.gabutakut.gabutdm.complete" );
1163
1259
nocomp_alerst. show ();
1164
1260
list_box. set_placeholder (nocomp_alerst);
1165
1261
break ;
1166
1262
case 4 :
1167
1263
list_box. set_filter_func ((item) = > {
1264
+ if (((DownloadRow )item). status == StatusMode . WAIT ) {
1265
+ indexv++ ;
1266
+ }
1168
1267
return ((DownloadRow ) item). status == StatusMode . WAIT ;
1169
1268
});
1170
1269
var nowait_alert = new AlertView (
1171
1270
_(" No Waiting Download" ),
1172
1271
_(" Drag and Drop URL, Torrent, Metalink, Magnet URIs." ),
1173
1272
" com.github.gabutakut.gabutdm.waiting"
1174
1273
);
1274
+ modeview. gicon = new ThemedIcon (" com.github.gabutakut.gabutdm.waiting" );
1175
1275
nowait_alert. show ();
1176
1276
list_box. set_placeholder (nowait_alert);
1177
1277
break ;
1178
1278
case 5 :
1179
1279
list_box. set_filter_func ((item) = > {
1280
+ if (((DownloadRow )item). status == StatusMode . ERROR ) {
1281
+ indexv++ ;
1282
+ }
1180
1283
return ((DownloadRow ) item). status == StatusMode . ERROR ;
1181
1284
});
1182
1285
var noerr_alert = new AlertView (
1183
1286
_(" No Error Download" ),
1184
1287
_(" Drag and Drop URL, Torrent, Metalink, Magnet URIs." ),
1185
1288
" com.github.gabutakut.gabutdm.error"
1186
1289
);
1290
+ modeview. gicon = new ThemedIcon (" com.github.gabutakut.gabutdm.error" );
1187
1291
noerr_alert. show ();
1188
1292
list_box. set_placeholder (noerr_alert);
1189
1293
break ;
@@ -1195,11 +1299,14 @@ namespace Gabut {
1195
1299
}
1196
1300
return true ;
1197
1301
});
1302
+ indexv = listrow. size;
1303
+ modeview. gicon = new ThemedIcon (" com.github.gabutakut.gabutdm" );
1198
1304
if (! hide_alert) {
1199
1305
list_box. set_placeholder (nodown_alert);
1200
1306
}
1201
1307
break ;
1202
1308
}
1309
+ labelview. label = indexv. to_string ();
1203
1310
list_box. set_sort_func ((Gtk . ListBoxSortFunc ) sort_dm);
1204
1311
listrow. sort (sort_dm);
1205
1312
}
0 commit comments