Skip to content

Commit

Permalink
Merge pull request #78 from giantpinkrobots/next
Browse files Browse the repository at this point in the history
Merge next into main for v2024.3.20
  • Loading branch information
giantpinkrobots committed Mar 20, 2024
2 parents 26e3b36 + a175291 commit ead2ba7
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 77 deletions.
4 changes: 2 additions & 2 deletions data/io.github.giantpinkrobots.varia.desktop.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[Desktop Entry]
# Translators: Do NOT translate or localize the application name.
Name=Varia
Comment=Download files quickly and efficiently
Comment=Download files and torrents quickly
Exec=varia
Icon=io.github.giantpinkrobots.varia
Terminal=false
Type=Application
Categories=Network
# Translators: These are search terms to find this application. Do NOT translate or localize the semicolons. The list MUST also end with a semicolon.
Keywords=varia;aria;download;manager;
Keywords=varia;aria;download;manager;torrent;
StartupNotify=true
21 changes: 13 additions & 8 deletions data/io.github.giantpinkrobots.varia.metainfo.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<name>Varia</name>
<summary>Download files quickly and efficiently</summary>
<summary>Download files and torrents</summary>
<id>io.github.giantpinkrobots.varia</id>

<metadata_license>FSFAP</metadata_license>
Expand All @@ -27,14 +27,20 @@
<lang>fr_FR</lang>
<lang>zh_TW</lang>
<lang>nb_NO</lang>
<lang>ja_JP</lang>
</languages>

<branding>
<color type="primary" scheme_preference="light">#75A3DC</color>
<color type="primary" scheme_preference="dark">#242424</color>
</branding>

<description>
<p>
Varia is a download manager for all your download needs. It can download multiple files at once very quickly with aria2.
Varia is a download manager for all your download needs. It can download regular files and torrents, and do it very quickly.
</p>
<p>
Varia utilizes GTK4 and Libadwaita to provide a easy to use interface that integrates well with the GNOME desktop.
Using Varia is very easy and straightforward, and with its aria2 backend it can potentially increase the speed of your downloads. It can integrate with Firefox or Chrome/ium through a browser extension, configured to your liking, and even support a remote aria2 instance on another computer.
</p>
</description>

Expand All @@ -53,12 +59,11 @@ Varia utilizes GTK4 and Libadwaita to provide a easy to use interface that integ
</screenshots>

<releases>
<release version="v2024.2.29-2" date="2024-03-03">
<release version="v2024.3.20" date="2024-03-20">
<description translatable="yes">
<p>- Support for Firefox and Chromium extension.</p>
<p>- Initial torrenting support.</p>
<p>- Remote mode that allows connection to a remote aria2 instance.</p>
<p>- Background mode that allows the window to be hidden while still downloading.</p>
<p>- Shutdown after completion option added.</p>
<p>- Update to GNOME 46 and Libadwaita 1.5.</p>
<p>- Japanese language support.</p>
<p>- Bug fixes and adjustments.</p>
</description>
</release>
Expand Down
7 changes: 4 additions & 3 deletions io.github.giantpinkrobots.varia.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"app-id" : "io.github.giantpinkrobots.varia",
"runtime" : "org.gnome.Platform",
"runtime-version" : "45",
"runtime-version" : "46",
"sdk" : "org.gnome.Sdk",
"command" : "varia",
"//": "Justifications for the permissions: This program utilizes aria2c, and aria2c requires the networking permission and the xdg-download directory in order to download files.",
"//": "Justifications for the permissions: This program utilizes aria2c, and aria2c requires the networking permission and the xdg-download directory in order to download files. It also has a 'shut down once all downloads are completed' feature that requires access to org.freedesktop.login1.",
"finish-args" : [
"--share=network",
"--share=ipc",
"--socket=fallback-x11",
"--device=dri",
"--socket=wayland",
"--filesystem=xdg-download"
"--filesystem=xdg-download",
"--system-talk-name=org.freedesktop.login1"
],
"cleanup" : [
"/include",
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('varia',
version: 'v2024.2.29-2',
version: 'v2024.3.20',
meson_version: '>= 0.62.0',
default_options: [ 'warning_level=2', 'werror=false', ],
)
Expand Down
15 changes: 15 additions & 0 deletions po/Varia.pot
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,21 @@ msgstr ""
msgid "Browser Extension"
msgstr ""

msgid "Shutdown on Completion"
msgstr ""

msgid "Varia is about to shut down your computer."
msgstr ""

msgid "Press Cancel to cancel and disable."
msgstr ""

msgid "Cancel"
msgstr ""

msgid "Warning"
msgstr ""

#: src/gtk/help-overlay.ui:11
msgctxt "shortcut window"
msgid "General"
Expand Down
19 changes: 17 additions & 2 deletions po/tr.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-30 03:17+0300\n"
"PO-Revision-Date: 2023-11-30 03:18+0300\n"
"Last-Translator: Sabri Ünal <libreajans@gmail.com>\n"
"Language-Team: Turkish <takim@gnome.org.tr>\n"
"Last-Translator: Giant Pink Robots! <giantpinkrobots@protonmail.com>\n"
"Language-Team: \n"
"Language: tr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -222,6 +222,21 @@ msgstr "İndirmeler arka planda devam ediyor."
msgid "Browser Extension"
msgstr "Tarayıcı Uzantısı"

msgid "Shutdown on Completion"
msgstr "İndirmeler Bittiğinde Bilgisayarı Kapat"

msgid "Varia is about to shut down your computer."
msgstr "Varia birazdan bilgisayarınızı kapatacak."

msgid "Press Cancel to cancel and disable."
msgstr "İptal edip devre dışı bırakmak için Vazgeç'e basın."

msgid "Cancel"
msgstr "Vazgeç"

msgid "Warning"
msgstr "Uyarı"

#: src/gtk/help-overlay.ui:11
msgctxt "shortcut window"
msgid "General"
Expand Down
15 changes: 8 additions & 7 deletions src/download/actionrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ def create_actionrow(self, filename):

pause_button = Gtk.Button.new_from_icon_name("media-playback-pause-symbolic")
pause_button.set_valign(Gtk.Align.CENTER)
pause_button.get_style_context().add_class("circular")
pause_button.connect("clicked", on_pause_clicked, self, pause_button, download_item)

self.pause_buttons.append(pause_button)
button_box.append(pause_button)

stop_button = Gtk.Button.new_from_icon_name("process-stop-symbolic")
stop_button.set_valign(Gtk.Align.CENTER)
stop_button.get_style_context().add_class("circular")
stop_button.connect("clicked", on_stop_clicked, self, download_item)
button_box.append(stop_button)

Expand All @@ -70,7 +72,7 @@ def create_actionrow(self, filename):
box_2.append(progress_bar)

self.download_list.append(download_item)
download_item.index = len(self.downloads)-1
download_item.index = len(self.downloads)

return [progress_bar, speed_label, self.pause_buttons[len(self.pause_buttons)-1], download_item, filename_label]

Expand All @@ -94,10 +96,9 @@ def on_pause_clicked(button, self, pause_button, download_item):

all_paused = True

for download_thread in self.downloads:
if (download_thread.download):
if (download_thread.download.is_paused) == False:
all_paused = False
for download_thread in self.downloads.copy():
if (download_thread.download) and (download_thread.is_alive()) and (download_thread.download.is_paused == False):
all_paused = False

if (all_paused == True):
self.all_paused = True
Expand All @@ -107,9 +108,9 @@ def on_pause_clicked(button, self, pause_button, download_item):

def on_stop_clicked(button, self, download_item):
index = download_item.index
download_thread = self.downloads[index+1]
download_thread = self.downloads[index]
deletefiles = True
if ((download_thread.download.is_torrent) and (download_thread.download.seeder)):
if (download_thread.download) and ((download_thread.download.is_torrent) and (download_thread.download.seeder)):
deletefiles = False
try:
download_thread.stop(deletefiles)
Expand Down
76 changes: 65 additions & 11 deletions src/download/listen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,49 @@
import requests
import json
import gi
from gi.repository import GLib
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
from gi.repository import Gtk, Adw, GLib, Gio
from download.actionrow import create_actionrow
from download.thread import DownloadThread
import threading
import string
import random
import textwrap

def listen_to_aria2(self, variaapp):
if not (self.terminating) and not (self.shutdown_dialog_raised):
currently_downloading = False

def listen_to_aria2(self):
if not self.terminating:
for frontend_download_item in self.downloads.copy():
if ( (frontend_download_item.download) and ( ((frontend_download_item.download.is_metadata) or (frontend_download_item.download.name.endswith(".torrent"))) and (frontend_download_item.download.is_complete) ) ):
frontend_download_item.cancelled = True
frontend_download_item.stop(True)
self.download_list.remove(frontend_download_item.actionrow)
self.downloads.remove(frontend_download_item)
if frontend_download_item.download:
if (frontend_download_item.is_alive()):
currently_downloading = True
if ( ((frontend_download_item.download.is_metadata) or (frontend_download_item.download.name.endswith(".torrent"))) and (frontend_download_item.download.is_complete) ):
frontend_download_item.cancelled = True
frontend_download_item.stop(True)
self.download_list.remove(frontend_download_item.actionrow)
self.downloads.remove(frontend_download_item)

try:
downloads_in_frontend = set(download_item.download.info_hash for download_item in self.downloads.copy())
downloads_in_frontend = set(download_item.download.gid for download_item in self.downloads.copy())
for download_item_to_be_added in self.api.get_downloads():
if ((download_item_to_be_added.info_hash not in downloads_in_frontend) and (download_item_to_be_added.is_metadata == False) and (download_item_to_be_added.is_complete == False)):
if ((download_item_to_be_added.gid not in downloads_in_frontend) and (download_item_to_be_added.is_metadata == False) and (download_item_to_be_added.is_complete == False)):
if not download_item_to_be_added.is_torrent:
print('Download added directly to aria2c, adding it to the UI: ' + download_item_to_be_added.files[0].uris[0]["uri"])
add_download_to_ui(self, download_item_to_be_added)
except:
pass

GLib.timeout_add(2000, listen_to_aria2, self)
if currently_downloading == True:
self.shutdown_action.set_enabled(True)
else:
self.shutdown_action.set_enabled(False)
if (self.shutdown_dialog_raised == False) and (self.shutdown_mode == True):
self.shutdown_dialog_raised = True
raise_shutdown_dialog(self, variaapp)

GLib.timeout_add(2000, listen_to_aria2, self, variaapp)

def add_download_to_ui(self, download_item_to_be_added):
if download_item_to_be_added.is_torrent:
Expand All @@ -39,3 +57,39 @@ def add_download_to_ui(self, download_item_to_be_added):
self.downloads.append(download_thread)
download_thread.start()
download_thread.pause_button.show()

def raise_shutdown_dialog(variamain, variaapp):
while (True):
shutdown_id = ''.join(random.choices(string.ascii_lowercase + string.digits, k=10))
if (shutdown_id != variamain.shutdown_id):
variamain.shutdown_id = shutdown_id
break

notification = Gio.Notification.new(_("Warning"))
notification.set_body(_("Varia is about to shut down your computer."))
variaapp.send_notification(None, notification)

dialog = Adw.AlertDialog()
dialog.set_body(textwrap.fill(_("Varia is about to shut down your computer.") + " " + _("Press Cancel to cancel and disable."), 50))
dialog.add_response("cancel", _("Cancel"))
dialog.set_default_response("cancel")
dialog.set_close_response("cancel")
dialog.connect("response", shutdown_dialog_cancel_pressed, variamain, variaapp)
dialog.present(variamain)

GLib.timeout_add(30000, initiate_shutdown, variamain, shutdown_id)

def shutdown_dialog_cancel_pressed(dialog, response_id, variamain, variaapp):
variamain.shutdown_dialog_raised = False
variamain.shutdown_mode = False
variamain.sidebar_remote_mode_label.set_text("")
GLib.timeout_add(2000, listen_to_aria2, variamain, variaapp)

def initiate_shutdown(variamain, shutdown_id):
if (variamain.shutdown_dialog_raised == True) and (shutdown_id == variamain.shutdown_id):
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
proxy = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE, None,
'org.freedesktop.login1', '/org/freedesktop/login1',
'org.freedesktop.login1.Manager', None)
proxy.call_sync('PowerOff', GLib.Variant('(b)', (True,)), Gio.DBusCallFlags.NONE, -1, None)
exit()
7 changes: 5 additions & 2 deletions src/initiate.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def initiate(self):

self.set_default_size(800, 600)
self.set_size_request(650, 450)
self.set_titlebar(Gtk.Box())

self.total_download_speed = ""
self.terminating = False
Expand All @@ -73,11 +72,15 @@ def initiate(self):
Gtk.Settings.get_default().set_property("gtk-icon-theme-name", "Adwaita")

self.overlay_split_view = Adw.OverlaySplitView.new()
self.set_child(child=self.overlay_split_view)
self.set_content(self.overlay_split_view)

self.downloads = []
self.pause_buttons = []
self.all_paused = False

self.shutdown_mode = False
self.shutdown_dialog_raised = False
self.shutdown_id = ""

def on_dialog_dismiss(dialog, response_id):
dialog.destroy()
15 changes: 8 additions & 7 deletions src/variamain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variaVersion = "v2024.2.29-2"
variaVersion = "v2024.3.20"

import gi
import sys
Expand All @@ -22,11 +22,11 @@
from initiate import initiate
from download.listen import listen_to_aria2

class MainWindow(Gtk.Window):
class MainWindow(Adw.ApplicationWindow):
def __init__(self, variaapp, appdir, appconf, aria2c_subprocess, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_hide_on_close(True)
self.connect('close-request', self.exitProgram, variaapp, False, True)
self.connect('close-request', self.exitProgram, variaapp, False)

self.appdir = appdir
self.appconf = appconf
Expand Down Expand Up @@ -65,7 +65,7 @@ def __init__(self, variaapp, appdir, appconf, aria2c_subprocess, *args, **kwargs
set_aria2c_download_simultaneous_amount(self)

# Listen to aria2c:
thread = threading.Thread(target=listen_to_aria2(self))
thread = threading.Thread(target=listen_to_aria2(self, variaapp))
thread.start()

# Load incomplete downloads:
Expand Down Expand Up @@ -230,7 +230,7 @@ def save_appconf(self):
json.dump(self.appconf, f)
print("Config saved")

def exitProgram(self, app, variaapp, background, show_exit_window):
def exitProgram(self, app, variaapp, background):
if (background == True):
self.hide()
notification = Gio.Notification.new(_("Background Mode"))
Expand All @@ -247,7 +247,8 @@ def exitProgram(self, app, variaapp, background, show_exit_window):
self.pause_all("no")
self.api.client.shutdown()

if (show_exit_window == True):
if (self.is_visible() == True):
self.hide()
exiting_dialog = Adw.MessageDialog()
exiting_dialog_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=25)
exiting_dialog.set_child(exiting_dialog_box)
Expand Down Expand Up @@ -289,7 +290,7 @@ def aria2c_exiting_check(self, app, counter, variaapp, exiting_dialog):

def quit_action_received(self, variaapp):
if (self.terminating == False):
self.exitProgram(variaapp, variaapp, False, False)
self.exitProgram(variaapp, variaapp, False)

class MyApp(Adw.Application):
def __init__(self, appdir, appconf, aria2c_subprocess, **kwargs):
Expand Down

0 comments on commit ead2ba7

Please sign in to comment.