Fix #46: Crash if installed via flatpak and there is an update

parent 1efb581e
Version 0.12.2
==============
Released: 2019-02-24
* Fix #46: Crash if installed via flatpak and there is an update
Version 0.12.1
==============
Released: 2019-02-24
......
......@@ -27,6 +27,13 @@
<url type="bugtracker">https://gitlab.com/leinardi/gwe/issues</url>
<update_contact>roberto@leinardi.com</update_contact>
<releases>
<release date="2019-02-24" version="0.12.2">
<description>
<ul>
<li>Fix #46: Crash if installed via flatpak and there is an update</li>
</ul>
</description>
</release>
<release date="2019-02-24" version="0.12.1">
<description>
<ul>
......
......@@ -21,7 +21,7 @@ from gettext import gettext as _
from typing import Any, Optional, List
from gi.repository import Gtk, Gio, GLib
from injector import inject
from injector import inject, singleton
from gwe.conf import APP_NAME, APP_ID, APP_VERSION, APP_ICON_NAME
from gwe.di import MainBuilder
......@@ -37,6 +37,7 @@ from gwe.view.main import MainView
LOG = logging.getLogger(__name__)
@singleton
class Application(Gtk.Application):
@inject
def __init__(self,
......@@ -59,7 +60,6 @@ class Application(Gtk.Application):
self.add_main_option_entries(self._get_main_option_entries())
self._view = view
self._presenter = presenter
self._presenter.application_quit = self.quit
self._nvidia_repository = nvidia_repository
self._window: Optional[Gtk.ApplicationWindow] = None
self._builder: Gtk.Builder = builder
......
......@@ -26,8 +26,8 @@ from rx.concurrency import GtkScheduler, ThreadPoolScheduler
from rx.concurrency.schedulerbase import SchedulerBase
from rx.disposables import CompositeDisposable
from gwe.conf import APP_NAME, APP_SOURCE_URL, APP_VERSION
from gwe.di import FanProfileChangedSubject, SpeedStepChangedSubject, OverclockProfileChangedSubject
from gwe.conf import APP_NAME, APP_SOURCE_URL, APP_VERSION, APP_ID
from gwe.di import FanProfileChangedSubject, SpeedStepChangedSubject, OverclockProfileChangedSubject, INJECTOR
from gwe.interactor import GetStatusInteractor, SettingsInteractor, \
CheckNewVersionInteractor, SetOverclockInteractor, SetPowerLimitInteractor, SetFanSpeedInteractor
from gwe.model import Status, FanProfile, CurrentFanProfile, DbChange, FanProfileType, GpuStatus, \
......@@ -123,7 +123,6 @@ class MainPresenter:
self._fan_profile_applied: Optional[FanProfile] = None
self._overclock_profile_selected: Optional[OverclockProfile] = None
self._overclock_profile_applied: Optional[OverclockProfile] = None
self.application_quit: Callable = lambda *args: None # will be set by the Application
self._latest_status: Optional[Status] = None
self._gpu_index: int = 0
......@@ -205,8 +204,11 @@ class MainPresenter:
profile_id = widget.get_model()[active][0]
self._select_overclock_profile(profile_id)
def on_quit_clicked(self, *_: Any) -> None:
self.application_quit()
@staticmethod
def on_quit_clicked(*_: Any) -> None:
from gwe.app import Application
application: Application = INJECTOR.get(Application)
application.quit()
def on_toggle_app_window_clicked(self, *_: Any) -> None:
self.main_view.toggle_window_visibility()
......@@ -449,9 +451,9 @@ class MainPresenter:
message = f"{APP_NAME} version <b>{version}</b> is available! " \
f"Click <a href=\"{self._get_changelog_uri(version)}\"><b>here</b></a> to see what's new."
self.main_view.show_main_infobar_message(message, True)
message = f"{APP_NAME} version <b>{version}</b> is available! " \
f"lick here to see what's new: {self._get_changelog_uri(version)}"
show_notification("GWE update available!", message, "dialog-information")
message = f"Version {version} is available! " \
f"Click here to see what's new: {self._get_changelog_uri(version)}"
show_notification("GWE update available!", message, APP_ID)
@staticmethod
def _get_changelog_uri(version: str = APP_VERSION) -> str:
......
......@@ -16,13 +16,14 @@
# along with gwe. If not, see <http://www.gnu.org/licenses/>.
from typing import Optional, Any, Dict
from gi.repository import Notify
from gi.repository import Gio
from gi.repository import GLib, Gtk, Gdk
from matplotlib.axes import Axes
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
from matplotlib.figure import Figure
from gwe.conf import MIN_TEMP, MAX_TEMP, FAN_MAX_DUTY, GRAPH_COLOR_HEX, APP_NAME
from gwe.conf import MIN_TEMP, MAX_TEMP, FAN_MAX_DUTY, GRAPH_COLOR_HEX
from gwe.di import INJECTOR
from gwe.model import FanProfile
......@@ -112,10 +113,14 @@ def is_dazzle_version_supported() -> bool:
return False
def show_notification(summary: str, body: str, icon: str) -> None:
if Notify.init(APP_NAME):
notification = Notify.Notification.new(summary=summary, body=body, icon=icon)
notification.show()
def show_notification(summary: str, body: str, iconname: str) -> None:
from gwe.app import Application
application: Application = INJECTOR.get(Application)
notification = Gio.Notification.new(title=summary)
notification.set_body(body)
iconname = Gio.ThemedIcon.new(iconname=iconname)
notification.set_icon(iconname)
application.send_notification(None, notification)
def open_uri(uri: str, parent: Gtk.Window = None, timestamp: int = Gdk.CURRENT_TIME) -> None:
......
......@@ -262,7 +262,7 @@ class MainView(MainViewInterface):
gpu_status.info.memory_used,
gpu_status.info.memory_total)
self._set_entry_text(self._info_memory_usage_entry, "{}%", gpu_status.info.memory_usage)
self._set_entry_text(self._info_gpu_usage_entry, "{}%%", gpu_status.info.gpu_usage)
self._set_entry_text(self._info_gpu_usage_entry, "{}%", gpu_status.info.gpu_usage)
self._set_entry_text(self._info_encoder_usage_entry, "{}%", gpu_status.info.encoder_usage)
self._set_entry_text(self._info_decoder_usage_entry, "{}%", gpu_status.info.decoder_usage)
self._set_entry_text(self._power_draw_entry, "{:.2f} W", gpu_status.power.draw)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment