Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplecode And Optimize Download Menu #287

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion data/com.github.gabutakut.gabutdm.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
<binary>com.github.gabutakut.gabutdm</binary>
</provides>
​ <releases>
<release version="2.2.8" date="2024-6-20">
<release version="2.5.0" date="2024-7-6">
<description>
<p>Replace Treeview to Listbox</p>
<p>Remove and replace Deprecated library</p>
<p>Adwaita style</p>
<p>Fix</p>
<p>Optimize Download Menu</p>
</description>
</release>
<release version="2.2.1" date="2024-6-15">
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project ('com.github.gabutakut.gabutdm','vala', 'c', version: '2.2.9')
project ('com.github.gabutakut.gabutdm','vala', 'c', version: '2.5.0')

i18n = import ('i18n')

Expand Down
4 changes: 2 additions & 2 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ namespace Gabut {
gabutwindow.remove_item (status);
});
gdm_theme.begin ();
set_dbsetting (Gabut.DBSettings.THEMESYSTEM, Gtk.Settings.get_default ().gtk_theme_name);
gabutwindow.load_dowanload ();
download_table ();
if (!startingup && !dontopen) {
open_now ();
}
lastclipboard = get_dbsetting (Gabut.DBSettings.LASTCLIPBOARD);
clipboard = Gdk.Display.get_default ().get_clipboard ();
Timeout.add_seconds (1, on_clipboard);
} else {
Expand Down Expand Up @@ -386,7 +386,7 @@ namespace Gabut {
if (textclip != null && textclip != "" && textclip != lastclipboard) {
if (!url_active (textclip.strip ())) {
if (!dialog_url (textclip.strip ())) {
lastclipboard = textclip;
lastclipboard = set_dbsetting (Gabut.DBSettings.LASTCLIPBOARD, textclip);
}
}
}
Expand Down
23 changes: 9 additions & 14 deletions src/DownloadRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -453,18 +453,13 @@ namespace Gabut {
}

public void start_notif () {
if (linkmode == LinkMode.TORRENT) {
notify_app (_("Starting"),
_("Torrent"), new ThemedIcon ("com.github.gabutakut.gabutdm.torrent"));
} else if (linkmode == LinkMode.METALINK) {
notify_app (_("Starting"),
_("Metalink"), new ThemedIcon ("com.github.gabutakut.gabutdm.metalink"));
} else if (linkmode == LinkMode.MAGNETLINK) {
notify_app (_("Starting"), url, new ThemedIcon ("com.github.gabutakut.gabutdm.magnet"));
} else {
notify_app (_("Starting"), url, new ThemedIcon ("com.github.gabutakut.gabutdm.insertlink"));
}
play_sound ("device-added");
Idle.add (()=> {
if (status != StatusMode.ERROR) {
notify_app (_("Starting"), filename, imagefile.gicon);
play_sound ("device-added");
}
return false;
});
}

public void idle_progress () {
Expand Down Expand Up @@ -648,10 +643,10 @@ namespace Gabut {
if (url.has_prefix ("magnet:?")) {
gabutinfo.set_info (url, InfoSucces.ADDRESS);
} else {
gabutinfo.set_info ("File Torrent", InfoSucces.ADDRESS);
gabutinfo.set_info (filename, InfoSucces.ADDRESS);
}
} else if (linkmode == LinkMode.METALINK) {
gabutinfo.set_info ("File Metalink", InfoSucces.ADDRESS);
gabutinfo.set_info (filename, InfoSucces.ADDRESS);
} else {
gabutinfo.set_info (url, InfoSucces.ADDRESS);
}
Expand Down
43 changes: 20 additions & 23 deletions src/GabutWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Gabut {
private Gtk.SearchEntry search_entry;
private ModeButton view_mode;
private AlertView nodown_alert;
private GLib.List<AddUrl> properties;
private Gee.ArrayList<AddUrl> properties;
private Gee.ArrayList<DownloadRow> listrow;
private DbusmenuItem menudbus;
private DbusmenuItem openmenu;
Expand Down Expand Up @@ -520,7 +520,7 @@ namespace Gabut {
margin_start = 6,
tooltip_text = _("Property")
};
properties = new GLib.List<AddUrl> ();
properties = new Gee.ArrayList<AddUrl> ();
list_box.row_selected.connect ((rw)=> {
if (rw != null) {
var row = (DownloadRow) rw;
Expand All @@ -531,23 +531,19 @@ namespace Gabut {
transient_for = this,
row = row
};
properties.append (property);
properties.add (property);
property.save_button.clicked.connect (()=> {
row = property.row;
});
property.close.connect (()=> {
properties.foreach ((proper)=> {
if (proper == property) {
properties.delete_link (properties.find (proper));
}
});
if (properties.contains (property)) {
properties.remove (property);
}
});
property.close_request.connect (()=> {
properties.foreach ((proper)=> {
if (proper == property) {
properties.delete_link (properties.find (proper));
}
});
if (properties.contains (property)) {
properties.remove (property);
}
return false;
});
property.update_agid.connect ((ariagid, newgid)=> {
Expand Down Expand Up @@ -589,6 +585,17 @@ namespace Gabut {
return actionbar;
}

private bool property_active (DownloadRow row) {
bool active = false;
properties.foreach ((propet)=> {
if (propet.row == row) {
active = true;
}
return true;
});
return active;
}

public Gtk.Popover get_menu () {
var sort_flow = new Gtk.FlowBox ();
showtime = new Gtk.CheckButton.with_label (_("Time")) {
Expand Down Expand Up @@ -760,16 +767,6 @@ namespace Gabut {
}
}

private bool property_active (DownloadRow row) {
bool active = false;
properties.foreach ((propet)=> {
if (propet.row == row) {
active = true;
}
});
return active;
}

public void save_all_download () {
var downloads = new GLib.List<DownloadRow> ();
listrow.foreach ((row)=> {
Expand Down
9 changes: 9 additions & 0 deletions src/Preferences.vala
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,13 @@ namespace Gabut {
active = bool.parse (pharse_options (pack_data, AriaOptions.AUTO_FILE_RENAMING))
};

var optimdw = new Gtk.CheckButton.with_label (_("Optimizes the number of concurrent downloads")) {
margin_top = 5,
width_request = 450,
active = bool.parse (pharse_options (pack_data, AriaOptions.OPTIMIZE_CONCURRENT_DOWNLOADS)),
tooltip_text = _("Optimizes the number of concurrent downloads according to the bandwidth available")
};

var style_mode = new ModeTogle ();
style_mode.add_item (new ModeTogle.with_label (_("System Default")));
style_mode.add_item (new ModeTogle.with_label (_("Light")));
Expand Down Expand Up @@ -773,6 +780,7 @@ namespace Gabut {
notifyopt.attach (headerlabel (_("File Download:"), 450), 0, 16, 1, 1);
notifyopt.attach (allowrepl, 0, 17, 1, 1);
notifyopt.attach (autorename, 0, 18, 1, 1);
notifyopt.attach (optimdw, 0, 19, 1, 1);
label_mode.sensitive = dbusmenu.active && menuindicator.active;

var notyscr = new Gtk.ScrolledWindow () {
Expand Down Expand Up @@ -846,6 +854,7 @@ namespace Gabut {
aria_set_globalops (AriaOptions.LOWEST_SPEED_LIMIT, set_dbsetting (DBSettings.LOWESTSPEED, (lowestspd.value * 1024).to_string ()));
aria_set_globalops (AriaOptions.URI_SELECTOR, set_dbsetting (DBSettings.URISELECTOR, uriselector.selector.to_string ().down ()));
aria_set_globalops (AriaOptions.STREAM_PIECE_SELECTOR, set_dbsetting (DBSettings.PIECESELECTOR, pieceselector.selector.to_string ().down ()));
aria_set_globalops (AriaOptions.OPTIMIZE_CONCURRENT_DOWNLOADS, set_dbsetting (DBSettings.OPTIMIZEDOW, optimdw.active.to_string ()));
set_dbsetting (DBSettings.RPCPORT, rpc_port.value.to_string ());
set_dbsetting (DBSettings.RPCSIZE, maxrequest.value.to_string ());
set_dbsetting (DBSettings.DISKCACHE, diskcache.value.to_string ());
Expand Down
7 changes: 3 additions & 4 deletions src/QrCode.vala
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,15 @@ namespace Gabut {
var header = get_header_bar ();
header.title_widget = header_grid;
header.decoration_layout = "none";

qrpaint = new QrcodePaint ();
var imageqr = new Gtk.Image () {
halign = Gtk.Align.START,
valign = Gtk.Align.START,
pixel_size = 256,
margin_start = 10,
margin_end = 10
margin_end = 10,
paintable = qrpaint
};
qrpaint = new QrcodePaint ();
imageqr.paintable = qrpaint;
qrpaint.queue_draw.connect (imageqr.queue_draw);

linkbutton = new Gtk.LinkButton ("");
Expand Down
5 changes: 2 additions & 3 deletions src/TorrentRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,12 @@ namespace Gabut {
valign = Gtk.Align.CENTER,
attributes = color_attribute (60000, 0, 0)
};

progrespaint = new ProgressPaintable ();
var progresimg = new Gtk.Image () {
paintable = progrespaint,
valign = Gtk.Align.CENTER,
width_request = 20
};
progrespaint = new ProgressPaintable ();
progresimg.paintable = progrespaint;
progrespaint.queue_draw.connect (progresimg.queue_draw);

persenlabel = new Gtk.Label (null) {
Expand Down
24 changes: 17 additions & 7 deletions src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ namespace Gabut {
LABELMODE = 46,
THEMESELECT = 47,
THEMECUSTOM = 48,
THEMESYSTEM = 49;
LASTCLIPBOARD = 49,
OPTIMIZEDOW = 50;

public string to_string () {
switch (this) {
Expand Down Expand Up @@ -170,8 +171,10 @@ namespace Gabut {
return "themeselect";
case THEMECUSTOM:
return "themecustom";
case THEMESYSTEM:
return "themesystem";
case LASTCLIPBOARD:
return "lastclipboard";
case OPTIMIZEDOW:
return "optimizedow";
default:
return "id";
}
Expand Down Expand Up @@ -2061,6 +2064,9 @@ namespace Gabut {
if (get_dbsetting (DBSettings.PIECESELECTOR) != aria_get_option (ariagid, AriaOptions.STREAM_PIECE_SELECTOR)) {
aria_set_option (ariagid, AriaOptions.STREAM_PIECE_SELECTOR, get_dbsetting (DBSettings.PIECESELECTOR));
}
if (get_dbsetting (DBSettings.OPTIMIZEDOW) != aria_get_option (ariagid, AriaOptions.OPTIMIZE_CONCURRENT_DOWNLOADS)) {
aria_set_option (ariagid, AriaOptions.OPTIMIZE_CONCURRENT_DOWNLOADS, get_dbsetting (DBSettings.OPTIMIZEDOW));
}
}

private void set_startup () {
Expand Down Expand Up @@ -2127,6 +2133,9 @@ namespace Gabut {
do {
aria_set_globalops (AriaOptions.STREAM_PIECE_SELECTOR, get_dbsetting (DBSettings.PIECESELECTOR));
} while (get_dbsetting (DBSettings.PIECESELECTOR) != aria_get_globalops (AriaOptions.STREAM_PIECE_SELECTOR));
do {
aria_set_globalops (AriaOptions.OPTIMIZE_CONCURRENT_DOWNLOADS, get_dbsetting (DBSettings.OPTIMIZEDOW));
} while (get_dbsetting (DBSettings.OPTIMIZEDOW) != aria_get_globalops (AriaOptions.OPTIMIZE_CONCURRENT_DOWNLOADS));
}

private async void boot_strap () throws Error {
Expand Down Expand Up @@ -2790,13 +2799,14 @@ namespace Gabut {
labelmode TEXT NOT NULL,
themeselect TEXT NOT NULL,
themecustom TEXT NOT NULL,
themesystem TEXT NOT NULL);
INSERT INTO settings (id, rpcport, maxtries, connserver, timeout, dir, retry, rpcsize, btmaxpeers, diskcache, maxactive, bttimeouttrack, split, maxopenfile, dialognotif, systemnotif, onbackground, iplocal, portlocal, seedtime, overwrite, autorenaming, allocation, startup, style, uploadlimit, downloadlimit, btlistenport, dhtlistenport, bttracker, bttrackerexc, splitsize, lowestspeed, uriselector, pieceselector, clipboard, sharedir, switchdir, sortby, ascedescen, showtime, showdate, dbusmenu, tdefault, notifsound, menuindicator, labelmode, themeselect, themecustom, themesystem)
VALUES (1, \"6807\", \"5\", \"6\", \"60\", \"$(dir.replace ("/", "\\/"))\", \"0\", \"2097152\", \"55\", \"16777216\", \"5\", \"60\", \"5\", \"100\", \"true\", \"true\", \"true\", \"true\", \"2021\", \"0\", \"false\", \"false\", \"None\", \"true\", \"1\", \"128000\", \"0\", \"21301\", \"26701\", \"\", \"\", \"20971520\", \"0\", \"feedback\", \"default\", \"true\", \"$(dir)\", \"false\", \"0\", \"0\", \"false\", \"false\", \"false\", \"false\", \"false\", \"false\", \"0\", \"0\" ,\"Breeze\", \"\");");
lastclipboard TEXT NOT NULL,
optimizedow TEXT NOT NULL);
INSERT INTO settings (id, rpcport, maxtries, connserver, timeout, dir, retry, rpcsize, btmaxpeers, diskcache, maxactive, bttimeouttrack, split, maxopenfile, dialognotif, systemnotif, onbackground, iplocal, portlocal, seedtime, overwrite, autorenaming, allocation, startup, style, uploadlimit, downloadlimit, btlistenport, dhtlistenport, bttracker, bttrackerexc, splitsize, lowestspeed, uriselector, pieceselector, clipboard, sharedir, switchdir, sortby, ascedescen, showtime, showdate, dbusmenu, tdefault, notifsound, menuindicator, labelmode, themeselect, themecustom, lastclipboard, optimizedow)
VALUES (1, \"6807\", \"5\", \"6\", \"60\", \"$(dir.replace ("/", "\\/"))\", \"0\", \"2097152\", \"55\", \"16777216\", \"5\", \"60\", \"5\", \"100\", \"true\", \"true\", \"true\", \"true\", \"2021\", \"0\", \"false\", \"false\", \"None\", \"true\", \"1\", \"128000\", \"0\", \"21301\", \"26701\", \"\", \"\", \"20971520\", \"0\", \"feedback\", \"default\", \"true\", \"$(dir)\", \"false\", \"0\", \"0\", \"false\", \"false\", \"false\", \"false\", \"false\", \"false\", \"0\", \"0\" ,\"Breeze\", \"\", \"false\");");
}

private void settings_table () {
if ((db_get_cols ("settings") - 1) != DBSettings.THEMESYSTEM) {
if ((db_get_cols ("settings") - 1) != DBSettings.OPTIMIZEDOW) {
gabutdb.exec ("DROP TABLE settings;");
table_settings (gabutdb);
}
Expand Down
Loading