Migrate to Gtk.Application for proper app lifecycle and custom icon
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a8b8548346
commit
20fc27fbdf
1 changed files with 19 additions and 4 deletions
23
bterminal.py
23
bterminal.py
|
|
@ -1860,7 +1860,7 @@ class BTerminalApp(Gtk.Window):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(title=APP_NAME)
|
super().__init__(title=APP_NAME)
|
||||||
self.set_default_size(1200, 700)
|
self.set_default_size(1200, 700)
|
||||||
self.set_icon_name("utilities-terminal")
|
self.set_icon_name("bterminal")
|
||||||
|
|
||||||
# Apply CSS
|
# Apply CSS
|
||||||
css_provider = Gtk.CssProvider()
|
css_provider = Gtk.CssProvider()
|
||||||
|
|
@ -2062,15 +2062,30 @@ class BTerminalApp(Gtk.Window):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _on_delete_event(self, widget, event):
|
def _on_delete_event(self, widget, event):
|
||||||
Gtk.main_quit()
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
# ─── Main ─────────────────────────────────────────────────────────────────────
|
# ─── Main ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = BTerminalApp()
|
GLib.set_prgname("bterminal")
|
||||||
Gtk.main()
|
GLib.set_application_name("BTerminal")
|
||||||
|
|
||||||
|
application = Gtk.Application(
|
||||||
|
application_id="com.github.DexterFromLab.BTerminal",
|
||||||
|
flags=Gio.ApplicationFlags.FLAGS_NONE,
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_activate(app):
|
||||||
|
windows = app.get_windows()
|
||||||
|
if windows:
|
||||||
|
windows[0].present()
|
||||||
|
return
|
||||||
|
win = BTerminalApp()
|
||||||
|
app.add_window(win)
|
||||||
|
|
||||||
|
application.connect("activate", on_activate)
|
||||||
|
application.run(None)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue