From b6fd218a5f27311f6b6334a8c42d58513ac9cd30 Mon Sep 17 00:00:00 2001 From: Giant Pink Robots! Date: Wed, 30 Oct 2024 03:02:12 +0300 Subject: [PATCH] Bug fixes & adjustments - Bug fix regarding pause buttons in download lists (got rid of overly complicated system) - Shutdown after completion now works on Windows - Small UI adjustments --- src/download/actionrow.py | 3 +-- src/download/listen.py | 15 ++++++++++----- src/initiate.py | 3 +-- src/variamain.py | 10 +++++----- src/window/content.py | 2 +- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/download/actionrow.py b/src/download/actionrow.py index 28e477e..fc6f24e 100644 --- a/src/download/actionrow.py +++ b/src/download/actionrow.py @@ -52,7 +52,6 @@ def create_actionrow(self, filename): pause_button.get_style_context().add_class("circular") pause_button.connect("clicked", on_pause_clicked, self, pause_button, download_item, False) - self.pause_buttons.append(pause_button) button_box.append(pause_button) stop_button = Gtk.Button.new_from_icon_name("process-stop-symbolic") @@ -77,7 +76,7 @@ def create_actionrow(self, filename): create_status_page(self, 1) - return [progress_bar, speed_label, self.pause_buttons[len(self.pause_buttons)-1], download_item, filename_label] + return [progress_bar, speed_label, pause_button, download_item, filename_label] def on_pause_clicked(button, self, pause_button, download_item, force_pause): download_thread = self.downloads[download_item.index] diff --git a/src/download/listen.py b/src/download/listen.py index 15d6795..0489771 100644 --- a/src/download/listen.py +++ b/src/download/listen.py @@ -7,6 +7,7 @@ import string import random import textwrap +import os from gettext import gettext as _ def listen_to_aria2(self, variaapp): @@ -113,11 +114,15 @@ def shutdown_dialog_cancel_pressed(dialog, response_id, 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) + if os.name == 'nt': + os.system('shutdown -s -t 0') + else: + 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() def raise_exit_dialog(variamain, variaapp): diff --git a/src/initiate.py b/src/initiate.py index 07f1b3d..ee1ff19 100644 --- a/src/initiate.py +++ b/src/initiate.py @@ -67,14 +67,13 @@ def initiate(self, variaapp, variaVersion, first_run): self.terminating = False if ("dev" in variaVersion): - #self.get_style_context().add_class("devel") + self.get_style_context().add_class("devel") Gtk.Settings.get_default().set_property("gtk-icon-theme-name", "Adwaita") self.overlay_split_view = Adw.OverlaySplitView.new() self.set_content(self.overlay_split_view) self.downloads = [] - self.pause_buttons = [] self.all_paused = False self.shutdown_mode = False diff --git a/src/variamain.py b/src/variamain.py index 10fedb9..1ee245b 100644 --- a/src/variamain.py +++ b/src/variamain.py @@ -189,7 +189,7 @@ def check_download_status(self): if (download_thread.download.is_complete == 1): download_thread.cancelled = True download_thread.speed_label.set_text(_("Download complete.")) - GLib.idle_add(self.pause_buttons[i].set_visible, False) + GLib.idle_add(download_thread.pause_button.set_visible, False) self.filter_download_list("no", self.applied_filter) elif (download_thread.download.status == "error") or (download_thread.download.status == "removed"): @@ -202,10 +202,10 @@ def check_download_status(self): download_thread.speed_label.set_text(_("An error occurred:") + " " + str(download_thread.download.error_code)) download_thread.stop(False) - GLib.idle_add(self.pause_buttons[i].set_visible, False) + GLib.idle_add(download_thread.pause_button.set_visible, False) self.filter_download_list("no", self.applied_filter) except: - GLib.idle_add(self.pause_buttons[i].set_visible, False) + GLib.idle_add(download_thread.pause_button.set_visible, False) self.filter_download_list("no", self.applied_filter) pass i += 1 @@ -242,7 +242,7 @@ def pause_all(self, header_pause_content): pause_button_images.append(Gtk.Image.new()) pause_button_images[i].set_from_icon_name("media-playback-start-symbolic") - self.pause_buttons[i].set_child(pause_button_images[i]) + download_thread.pause_button.set_child(pause_button_images[i]) download_thread.save_state() @@ -257,7 +257,7 @@ def pause_all(self, header_pause_content): pause_button_images.append(Gtk.Image.new()) pause_button_images[i].set_from_icon_name("media-playback-pause-symbolic") - self.pause_buttons[i].set_child(pause_button_images[i]) + download_thread.pause_button.set_child(pause_button_images[i]) i += 1 if ((header_pause_content != "no") and (i > 0)): diff --git a/src/window/content.py b/src/window/content.py index 9c88e3d..46888c6 100644 --- a/src/window/content.py +++ b/src/window/content.py @@ -46,7 +46,7 @@ def window_create_content(self, threading): self.download_list.set_margin_start(6) self.download_list.set_margin_end(6) self.download_list.set_margin_bottom(6) - self.download_list.set_margin_top(6) + self.download_list.set_margin_top(1) self.download_list_box.set_hexpand(True) self.download_list_box.set_vexpand(True)