mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Rename to Warehouse
This commit is contained in:
102
src/main.py
102
src/main.py
@@ -19,33 +19,48 @@
|
||||
|
||||
import sys
|
||||
import gi
|
||||
#import subprocess
|
||||
|
||||
gi.require_version('Gtk', '4.0')
|
||||
gi.require_version('Adw', '1')
|
||||
# import subprocess
|
||||
|
||||
gi.require_version("Gtk", "4.0")
|
||||
gi.require_version("Adw", "1")
|
||||
|
||||
from gi.repository import Gtk, Gio, Adw, GLib
|
||||
from .window import FlattoolGuiWindow
|
||||
from .window import WarehouseWindow
|
||||
|
||||
|
||||
class FlattoolGuiApplication(Adw.Application):
|
||||
class WarehouseApplication(Adw.Application):
|
||||
"""The main application singleton class."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(application_id='io.github.heliguy4599.FlattoolGUI',
|
||||
flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
|
||||
self.create_action('quit', lambda *_: self.quit(), ['<primary>q'])
|
||||
self.create_action('about', self.on_about_action)
|
||||
self.create_action('preferences', self.on_preferences_action)
|
||||
self.create_action('search', self.on_search_action, ['<primary>f'])
|
||||
self.create_action('manage-data-folders', self.on_manage_data_folders_action)
|
||||
self.create_action('toggle-batch-mode', self.batch_mode_shortcut, ['<primary>b', '<primary>Return'])
|
||||
self.create_action('select-all-in-batch-mode', self.select_all_shortcut, ['<primary>a'])
|
||||
self.create_action('manage-data-folders', self.manage_data_shortcut, ['<primary>d'])
|
||||
self.create_action('refresh-list', self.refresh_list_shortcut, ['<primary>r','F5'])
|
||||
self.create_action('show-runtimes', self.show_runtimes_shortcut, ['<primary>t'])
|
||||
super().__init__(
|
||||
application_id="io.github.heliguy4599.Warehouse",
|
||||
flags=Gio.ApplicationFlags.DEFAULT_FLAGS,
|
||||
)
|
||||
self.create_action("quit", lambda *_: self.quit(), ["<primary>q"])
|
||||
self.create_action("about", self.on_about_action)
|
||||
self.create_action("preferences", self.on_preferences_action)
|
||||
self.create_action("search", self.on_search_action, ["<primary>f"])
|
||||
self.create_action("manage-data-folders", self.on_manage_data_folders_action)
|
||||
self.create_action(
|
||||
"toggle-batch-mode",
|
||||
self.batch_mode_shortcut,
|
||||
["<primary>b", "<primary>Return"],
|
||||
)
|
||||
self.create_action(
|
||||
"select-all-in-batch-mode", self.select_all_shortcut, ["<primary>a"]
|
||||
)
|
||||
self.create_action(
|
||||
"manage-data-folders", self.manage_data_shortcut, ["<primary>d"]
|
||||
)
|
||||
self.create_action(
|
||||
"refresh-list", self.refresh_list_shortcut, ["<primary>r", "F5"]
|
||||
)
|
||||
self.create_action("show-runtimes", self.show_runtimes_shortcut, ["<primary>t"])
|
||||
|
||||
self.show_runtimes_stateful = Gio.SimpleAction.new_stateful("show-runtimes", None, GLib.Variant.new_boolean(False))
|
||||
self.show_runtimes_stateful = Gio.SimpleAction.new_stateful(
|
||||
"show-runtimes", None, GLib.Variant.new_boolean(False)
|
||||
)
|
||||
self.show_runtimes_stateful.connect("activate", self.on_show_runtimes_action)
|
||||
self.add_action(self.show_runtimes_stateful)
|
||||
|
||||
@@ -78,37 +93,54 @@ class FlattoolGuiApplication(Adw.Application):
|
||||
"""
|
||||
win = self.props.active_window
|
||||
if not win:
|
||||
win = FlattoolGuiWindow(application=self)
|
||||
win = WarehouseWindow(application=self)
|
||||
win.present()
|
||||
#try:
|
||||
#subprocess.run(['flattool', 'id', 'abcdefg'], check=True)
|
||||
#except subprocess.CalledProcessError:
|
||||
#print("Not found")
|
||||
# try:
|
||||
# subprocess.run(['flattool', 'id', 'abcdefg'], check=True)
|
||||
# except subprocess.CalledProcessError:
|
||||
# print("Not found")
|
||||
|
||||
def on_about_action(self, widget, _):
|
||||
"""Callback for the app.about action."""
|
||||
about = Adw.AboutWindow(transient_for=self.props.active_window,
|
||||
application_name='Warehouse',
|
||||
application_icon='io.github.heliguy4599.FlattoolGUI',
|
||||
developer_name='Heliguy',
|
||||
version='0.3.0',
|
||||
developers=['Heliguy https://github.com/heliguy4599', 'kramo https://kramo.hu'],
|
||||
artists=['Heliguy https://github.com/heliguy4599', 'kramo https://kramo.hu', 'eryn https://github.com/hericiumvevo'],
|
||||
copyright='© 2023 The Files Authors\n\nThis application comes with absolutely no warranty. See the <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU General Public License, version 3 only</a> for details.')
|
||||
about = Adw.AboutWindow(
|
||||
transient_for=self.props.active_window,
|
||||
application_name="Warehouse",
|
||||
application_icon="io.github.heliguy4599.Warehouse",
|
||||
developer_name="Heliguy",
|
||||
version="0.3.0",
|
||||
developers=[
|
||||
"Heliguy https://github.com/heliguy4599",
|
||||
"kramo https://kramo.hu",
|
||||
],
|
||||
artists=[
|
||||
"Heliguy https://github.com/heliguy4599",
|
||||
"kramo https://kramo.hu",
|
||||
"eryn https://github.com/hericiumvevo",
|
||||
],
|
||||
copyright='© 2023 The Files Authors\n\nThis application comes with absolutely no warranty. See the <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU General Public License, version 3 only</a> for details.',
|
||||
)
|
||||
about.present()
|
||||
|
||||
def on_preferences_action(self, widget, _):
|
||||
"""Callback for the app.preferences action."""
|
||||
print('app.preferences action activated')
|
||||
print("app.preferences action activated")
|
||||
|
||||
def on_search_action(self, widget, _):
|
||||
self.props.active_window.search_bar.set_search_mode(not self.props.active_window.search_bar.get_search_mode())
|
||||
self.props.active_window.search_bar.set_search_mode(
|
||||
not self.props.active_window.search_bar.get_search_mode()
|
||||
)
|
||||
|
||||
def on_manage_data_folders_action(self, widget, _):
|
||||
self.props.active_window.orphans_window()
|
||||
|
||||
def on_show_runtimes_action(self, widget, _):
|
||||
self.show_runtimes_stateful.set_state(GLib.Variant.new_boolean(state := (not self.show_runtimes_stateful.get_property("state").get_boolean())))
|
||||
self.show_runtimes_stateful.set_state(
|
||||
GLib.Variant.new_boolean(
|
||||
state := (
|
||||
not self.show_runtimes_stateful.get_property("state").get_boolean()
|
||||
)
|
||||
)
|
||||
)
|
||||
self.props.active_window.show_runtimes_toggle_handler(state)
|
||||
|
||||
def create_action(self, name, callback, shortcuts=None):
|
||||
@@ -129,5 +161,5 @@ class FlattoolGuiApplication(Adw.Application):
|
||||
|
||||
def main(version):
|
||||
"""The application's entry point."""
|
||||
app = FlattoolGuiApplication()
|
||||
app = WarehouseApplication()
|
||||
return app.run(sys.argv)
|
||||
|
||||
Reference in New Issue
Block a user