Skip to content

Commit

Permalink
Merge pull request #216 from MightyCreak/fix-version-option
Browse files Browse the repository at this point in the history
fix: error when runnin with arg --version
  • Loading branch information
MightyCreak authored Dec 27, 2023
2 parents 7a616ce + f5e1173 commit 95f23de
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/diffuse/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import encodings

from gettext import gettext as _
from typing import Optional

from diffuse import constants, utils
from diffuse.resources import theResources
Expand All @@ -35,13 +36,14 @@
class DiffuseApplication(Gtk.Application):
"""The main application class."""

def __init__(self, sysconfigdir):
def __init__(self, sysconfigdir: str):
super().__init__(
application_id=constants.APP_ID,
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE | Gio.ApplicationFlags.NON_UNIQUE)

self.window = None
self.sysconfigdir = sysconfigdir
self.window: Optional[DiffuseWindow] = None
self.statepath: str = ""

self.connect('shutdown', self.on_shutdown)

Expand Down Expand Up @@ -196,7 +198,8 @@ def __init__(self, sysconfigdir):

def do_activate(self) -> None:
"""Called when the application is activated."""
self.window.present()
if self.window is not None:
self.window.present()

def do_command_line(self, command_line):
"""Called to treat the command line options."""
Expand Down Expand Up @@ -369,7 +372,8 @@ def do_command_line(self, command_line):
return 0

def on_shutdown(self, application: Gio.Application) -> None:
self.window.save_state(self.statepath)
if self.window is not None and self.statepath != '':
self.window.save_state(self.statepath)


def main(version: str, sysconfigdir: str) -> int:
Expand Down

0 comments on commit 95f23de

Please sign in to comment.