Merge pull request #216 from MightyCreak/fix-version-option
fix: error when runnin with arg --version
This commit is contained in:
commit
95f23def7a
|
@ -22,6 +22,7 @@ import sys
|
||||||
import encodings
|
import encodings
|
||||||
|
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from diffuse import constants, utils
|
from diffuse import constants, utils
|
||||||
from diffuse.resources import theResources
|
from diffuse.resources import theResources
|
||||||
|
@ -35,13 +36,14 @@ from gi.repository import Gio, GLib, Gtk # type: ignore # noqa: E402
|
||||||
class DiffuseApplication(Gtk.Application):
|
class DiffuseApplication(Gtk.Application):
|
||||||
"""The main application class."""
|
"""The main application class."""
|
||||||
|
|
||||||
def __init__(self, sysconfigdir):
|
def __init__(self, sysconfigdir: str):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
application_id=constants.APP_ID,
|
application_id=constants.APP_ID,
|
||||||
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE | Gio.ApplicationFlags.NON_UNIQUE)
|
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE | Gio.ApplicationFlags.NON_UNIQUE)
|
||||||
|
|
||||||
self.window = None
|
|
||||||
self.sysconfigdir = sysconfigdir
|
self.sysconfigdir = sysconfigdir
|
||||||
|
self.window: Optional[DiffuseWindow] = None
|
||||||
|
self.statepath: str = ""
|
||||||
|
|
||||||
self.connect('shutdown', self.on_shutdown)
|
self.connect('shutdown', self.on_shutdown)
|
||||||
|
|
||||||
|
@ -196,6 +198,7 @@ also retrieve revisions of files from several VCSs for comparison and merging.''
|
||||||
|
|
||||||
def do_activate(self) -> None:
|
def do_activate(self) -> None:
|
||||||
"""Called when the application is activated."""
|
"""Called when the application is activated."""
|
||||||
|
if self.window is not None:
|
||||||
self.window.present()
|
self.window.present()
|
||||||
|
|
||||||
def do_command_line(self, command_line):
|
def do_command_line(self, command_line):
|
||||||
|
@ -369,6 +372,7 @@ also retrieve revisions of files from several VCSs for comparison and merging.''
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def on_shutdown(self, application: Gio.Application) -> None:
|
def on_shutdown(self, application: Gio.Application) -> None:
|
||||||
|
if self.window is not None and self.statepath != '':
|
||||||
self.window.save_state(self.statepath)
|
self.window.save_state(self.statepath)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue