Skip to content

Commit

Permalink
Merge pull request #571 from orende/feature/download-success-tooltip
Browse files Browse the repository at this point in the history
Add notification popup on game installed
  • Loading branch information
sharkwouter committed Jun 23, 2023
2 parents 458a732 + 874965f commit f49c4cd
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Update Traditional Chinese translation (thanks to s8321414)
- Added additional tooltips to buttons, labels, menu items and radio buttons (thanks to orende)
- Hide CDPR Goodie Pack Content
- Add notifications on successful download and installation of games (thanks to orende)

**1.2.2**
- Fix progress bar not showing up for downloads
Expand Down
5 changes: 4 additions & 1 deletion minigalaxy/ui/gametile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from minigalaxy.installer import uninstall_game, install_game, check_diskspace
from minigalaxy.paths import ICON_WINE_PATH
from minigalaxy.api import NoDownloadLinkFound, Api
from minigalaxy.ui.gtk import Gtk, GLib
from minigalaxy.ui.gtk import Gtk, GLib, Notify
from minigalaxy.ui.information import Information
from minigalaxy.ui.properties import Properties

Expand Down Expand Up @@ -343,6 +343,9 @@ def __install(self, save_location, update=False, dlc_title=""):
self.game.set_dlc_info("version", self.api.get_version(self.game, dlc_name=dlc_title), dlc_title)
else:
self.game.set_info("version", self.api.get_version(self.game))
popup = Notify.Notification.new("Minigalaxy", _("Finished downloading and installing {}")
.format(self.game.name), "dialog-information")
popup.show()
else:
GLib.idle_add(self.parent.parent.show_error, _("Failed to install {}").format(self.game.name), err_msg)
GLib.idle_add(self.update_to_state, failed_state)
Expand Down
6 changes: 5 additions & 1 deletion minigalaxy/ui/gametilelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from minigalaxy.css import CSS_PROVIDER
from minigalaxy.paths import ICON_WINE_PATH
from minigalaxy.api import NoDownloadLinkFound, Api
from minigalaxy.ui.gtk import Gtk, GLib
from minigalaxy.ui.gtk import Gtk, GLib, Notify
from minigalaxy.ui.information import Information
from minigalaxy.ui.properties import Properties

Expand Down Expand Up @@ -324,6 +324,10 @@ def __install_game(self, save_location):
install_success = self.__install(save_location)
if install_success:
self.__check_for_dlc(self.api.get_info(self.game))
popup = Notify.Notification.new("Minigalaxy", _("Finished downloading and installing {}")
.format(self.game.name), "dialog-information")
popup.show()
popup.close()

def __install(self, save_location, update=False, dlc_title=""):
if update:
Expand Down
2 changes: 2 additions & 0 deletions minigalaxy/ui/gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, Gio, GLib, GdkPixbuf # noqa: E402,F401
gi.require_version('Notify', '0.7')
from gi.repository import Notify # noqa: E402,F401
5 changes: 4 additions & 1 deletion minigalaxy/ui/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from minigalaxy.paths import UI_DIR, LOGO_IMAGE_PATH, THUMBNAIL_DIR, COVER_DIR, ICON_DIR
from minigalaxy.translation import _
from minigalaxy.ui.library import Library
from minigalaxy.ui.gtk import Gtk, Gdk, GdkPixbuf
from minigalaxy.ui.gtk import Gtk, Gdk, GdkPixbuf, Notify
from minigalaxy.config import Config


Expand Down Expand Up @@ -43,6 +43,9 @@ def __init__(self, config: Config, api: 'Api', download_manager: DownloadManager
self.search_string = ""
self.offline = False

# Initialize notifications module
Notify.init("minigalaxy")

# Set library
self.library = Library(self, config, api, download_manager)

Expand Down
3 changes: 3 additions & 0 deletions tests/test_ui_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class Gio:
class GLib:
pass

class Notify:
pass


u_gi_repository = UnitTestGiRepository()
sys.modules['gi.repository'] = u_gi_repository
Expand Down
1 change: 1 addition & 0 deletions tests/test_ui_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, title):
GdkPixbuf = MagicMock()
Gio = MagicMock()
GLib = MagicMock
Notify = MagicMock()


u_gi_repository = UnitTestGiRepository()
Expand Down

0 comments on commit f49c4cd

Please sign in to comment.