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

Menu for linux #198

Merged
merged 1 commit into from
Oct 11, 2022
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
4 changes: 2 additions & 2 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Gabut {
public GabutApp () {
Object (
application_id: "com.github.gabutakut.gabutdm",
flags: ApplicationFlags.HANDLES_COMMAND_LINE
flags: GLib.ApplicationFlags.HANDLES_COMMAND_LINE
);
}

Expand All @@ -50,7 +50,7 @@ namespace Gabut {
startingup = true;
}
if (dict.contains (GLib.OPTION_REMAINING)) {
foreach (string arg_file in dict.lookup_value (GLib.OPTION_REMAINING, VariantType.STRING_ARRAY).get_strv ()) {
foreach (string arg_file in dict.lookup_value (GLib.OPTION_REMAINING, GLib.VariantType.STRING_ARRAY).get_strv ()) {
if (GLib.FileUtils.test (arg_file, GLib.FileTest.EXISTS)) {
dialog_url (File.new_for_path (arg_file).get_uri ());
} else {
Expand Down
7 changes: 4 additions & 3 deletions src/DownloadRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,6 @@ namespace Gabut {
if (fraction > 0.0) {
progressbar.fraction = fraction;
}
if (status == StatusMode.ACTIVE) {
set_progress_visible.begin (progressbar.fraction);
}
} else {
progressbar.pulse ();
}
Expand Down Expand Up @@ -468,6 +465,10 @@ namespace Gabut {
Idle.add (()=> { update_progress (); return false; });
}

public void fraction_laucher () {
set_progress_visible.begin (progressbar.fraction);
}

private void action_dowload () {
status = status_aria (aria_tell_status (ariagid, TellStatus.STATUS));
if (status == StatusMode.ACTIVE) {
Expand Down
73 changes: 51 additions & 22 deletions src/GabutWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,20 @@ namespace Gabut {
}
}

private bool _dbmenu = false;
public bool dbmenu {
get {
return _dbmenu;
}
set {
_dbmenu = value;
}
}

public GabutWindow (Gtk.Application application) {
Object (application: application,
hide_on_close: bool.parse (get_dbsetting (DBSettings.ONBACKGROUND)),
dbmenu: bool.parse (get_dbsetting (DBSettings.DBUSMENU)),
title: _("Gabut Download Manager")
);
}
Expand Down Expand Up @@ -195,12 +206,18 @@ namespace Gabut {
if (bool.parse (get_dbsetting (DBSettings.ONBACKGROUND)) != hide_on_close) {
hide_on_close = bool.parse (get_dbsetting (DBSettings.ONBACKGROUND));
}
if (bool.parse (get_dbsetting (DBSettings.DBUSMENU)) != dbmenu) {
dbmenu = bool.parse (get_dbsetting (DBSettings.DBUSMENU));
}
preferences = null;
});
preferences.close_request.connect (()=> {
if (bool.parse (get_dbsetting (DBSettings.ONBACKGROUND)) != hide_on_close) {
hide_on_close = bool.parse (get_dbsetting (DBSettings.ONBACKGROUND));
}
if (bool.parse (get_dbsetting (DBSettings.DBUSMENU)) != dbmenu) {
dbmenu = bool.parse (get_dbsetting (DBSettings.DBUSMENU));
}
preferences = null;
return false;
});
Expand Down Expand Up @@ -488,26 +505,28 @@ namespace Gabut {
}

private bool set_menulauncher () {
var globalactive = int64.parse (aria_globalstat (GlobalStat.NUMACTIVE));
bool statact = globalactive > 0;
set_count_visible.begin (globalactive);
if (!statact) {
int stoped = 10;
Timeout.add (500, ()=> {
set_progress_visible.begin (0.0, false);
set_count_visible.begin (globalactive);
update_info ();
stoped--;
return stoped != 0;
});
}
if (timeout_id != 0) {
Source.remove (timeout_id);
timeout_id = 0;
}
if (rmtimeout_id != 0) {
Source.remove (rmtimeout_id);
rmtimeout_id = 0;
if (dbmenu) {
var globalactive = int64.parse (aria_globalstat (GlobalStat.NUMACTIVE));
bool statact = globalactive > 0;
set_count_visible.begin (globalactive);
if (!statact) {
int stoped = 3;
Timeout.add (500, ()=> {
set_progress_visible.begin (0.0, false);
set_count_visible.begin (globalactive);
update_info ();
stoped--;
return stoped != 0;
});
}
if (timeout_id != 0) {
Source.remove (timeout_id);
timeout_id = 0;
}
if (rmtimeout_id != 0) {
Source.remove (rmtimeout_id);
rmtimeout_id = 0;
}
}
return false;
}
Expand Down Expand Up @@ -639,6 +658,9 @@ namespace Gabut {
}
view_status ();
}
if (dbmenu) {
row.fraction_laucher ();
}
update_info ();
return;
}
Expand Down Expand Up @@ -697,6 +719,9 @@ namespace Gabut {
}
view_status ();
}
if (dbmenu) {
row.fraction_laucher ();
}
update_info ();
return;
}
Expand Down Expand Up @@ -817,14 +842,18 @@ namespace Gabut {
if (!menudbus.get_exist (rowbus)) {
menudbus.child_append (rowbus);
}
yield open_quicklist (dbusserver, menudbus);
if (dbmenu) {
yield open_quicklist (dbusserver, menudbus);
}
}

private async void remove_dbus (DbusmenuItem rowbus) throws GLib.Error {
if (menudbus.get_exist (rowbus)) {
menudbus.child_delete (rowbus);
}
yield open_quicklist (dbusserver, menudbus);
if (dbmenu) {
yield open_quicklist (dbusserver, menudbus);
}
}

[CCode (instance_pos = -1)]
Expand Down
20 changes: 14 additions & 6 deletions src/Preferences.vala
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,12 @@ namespace Gabut {
active = bool.parse (get_dbsetting (DBSettings.CLIPBOARD))
};

var dbusmenu = new Gtk.CheckButton.with_label (_("Dbus Menu")) {
margin_top = 5,
width_request = 450,
active = bool.parse (get_dbsetting (DBSettings.DBUSMENU))
};

var allowrepl = new Gtk.CheckButton.with_label (_("Replace File")) {
margin_top = 5,
width_request = 450,
Expand Down Expand Up @@ -649,12 +655,13 @@ namespace Gabut {
notifyopt.attach (retonhide, 0, 3, 1, 1);
notifyopt.attach (appstartup, 0, 4, 1, 1);
notifyopt.attach (appclipboard, 0, 5, 1, 1);
notifyopt.attach (headerlabel (_("Notify:"), 450), 0, 6, 1, 1);
notifyopt.attach (systemnotif, 0, 7, 1, 1);
notifyopt.attach (dialognotify, 0, 8, 1, 1);
notifyopt.attach (headerlabel (_("File Download:"), 450), 0, 9, 1, 1);
notifyopt.attach (allowrepl, 0, 10, 1, 1);
notifyopt.attach (autorename, 0, 11, 1, 1);
notifyopt.attach (dbusmenu, 0, 6, 1, 1);
notifyopt.attach (headerlabel (_("Notify:"), 450), 0, 7, 1, 1);
notifyopt.attach (systemnotif, 0, 8, 1, 1);
notifyopt.attach (dialognotify, 0, 9, 1, 1);
notifyopt.attach (headerlabel (_("File Download:"), 450), 0, 10, 1, 1);
notifyopt.attach (allowrepl, 0, 11, 1, 1);
notifyopt.attach (autorename, 0, 12, 1, 1);

var notyscr = new Gtk.ScrolledWindow () {
width_request = 455,
Expand Down Expand Up @@ -690,6 +697,7 @@ namespace Gabut {
set_dbsetting (DBSettings.SHAREDIR, selectfs.get_path ());
set_dbsetting (DBSettings.SWITCHDIR, sharebutton.active.to_string ());
set_dbsetting (DBSettings.SYSTEMNOTIF, systemnotif.active.to_string ());
set_dbsetting (DBSettings.DBUSMENU, dbusmenu.active.to_string ());
if (style_mode.id != int.parse (get_dbsetting (DBSettings.STYLE))) {
set_dbsetting (DBSettings.STYLE, style_mode.id.to_string ());
pantheon_theme.begin (get_display ());
Expand Down
14 changes: 9 additions & 5 deletions src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ namespace Gabut {
SORTBY = 38,
ASCEDESCEN = 39,
SHOWTIME = 40,
SHOWDATE = 41;
SHOWDATE = 41,
DBUSMENU = 42;

public string to_string () {
switch (this) {
Expand Down Expand Up @@ -148,6 +149,8 @@ namespace Gabut {
return "showtime";
case SHOWDATE:
return "showdate";
case DBUSMENU:
return "dbusmenu";
default:
return "id";
}
Expand Down Expand Up @@ -2668,13 +2671,14 @@ namespace Gabut {
sortby TEXT NOT NULL,
ascedescen TEXT NOT NULL,
showtime TEXT NOT NULL,
showdate 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)
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\");");
showdate TEXT NOT NULL,
dbusmenu 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)
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\");");
}

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