Skip to content

Commit

Permalink
Connect to signals of the shown window
Browse files Browse the repository at this point in the history
In the case of OnboardingWindow and MainWindow, the class itself is not
shown as a window, but its 'window' field is shown, so when the window
is closed, the application does not terminate - the wrong signals is
connected to the handler.
  • Loading branch information
Gliese852 committed Nov 20, 2023
1 parent c5b1766 commit bcde184
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions howdy-gtk/src/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ def __init__(self):
# Make the class a GTK window
gtk.Window.__init__(self)

self.connect("destroy", self.exit)
self.connect("delete_event", self.exit)

self.builder = gtk.Builder()
self.builder.add_from_file(paths_factory.onboarding_wireframe_path())
self.builder.connect_signals(self)

self.window = self.builder.get_object("onboardingwindow")
self.nextbutton = self.builder.get_object("nextbutton")

self.window.connect("destroy", self.exit)
self.window.connect("delete_event", self.exit)

self.slides = [
self.builder.get_object("slide0"),
self.builder.get_object("slide1"),
Expand Down Expand Up @@ -317,7 +317,7 @@ def show_error(self, error, secon=""):
dialog.destroy()
self.exit()

def exit(self, widget=None):
def exit(self, widget=None, context=None):
"""Cleanly exit"""
gtk.main_quit()
sys.exit(0)
8 changes: 4 additions & 4 deletions howdy-gtk/src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ def __init__(self):
# Make the class a GTK window
gtk.Window.__init__(self)

self.connect("destroy", self.exit)
self.connect("delete_event", self.exit)

self.builder = gtk.Builder()
self.builder.add_from_file(paths_factory.main_window_wireframe_path())
self.builder.connect_signals(self)
Expand All @@ -35,6 +32,9 @@ def __init__(self):
self.modellistbox = self.builder.get_object("modellistbox")
self.opencvimage = self.builder.get_object("opencvimage")

self.window.connect("destroy", self.exit)
self.window.connect("delete_event", self.exit)

# Init capture for video tab
self.capture = None

Expand Down Expand Up @@ -105,7 +105,7 @@ def on_about_link(self, label, uri):
status, output = subprocess.getstatusoutput(["sudo -u " + user + " timeout 10 xdg-open " + uri])
return True

def exit(self, widget, context):
def exit(self, widget=None, context=None):
"""Cleanly exit"""
if self.capture is not None:
self.capture.release()
Expand Down

0 comments on commit bcde184

Please sign in to comment.