Add About window
This commit is contained in:
parent
76233709cd
commit
6c4f43a947
7 changed files with 46 additions and 10 deletions
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This is just a helper for development
|
||||
|
||||
# Compile resources
|
||||
glib-compile-resources src/resources/resources.xml \
|
||||
--target=src/recoder/resources.gresource \
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
post_install() {
|
||||
glib-compile-schemas /usr/share/glib-2.0/schemas
|
||||
gtk-update-icon-cache -q /usr/share/icons/hicolor
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
glib-compile-schemas /usr/share/glib-2.0/schemas
|
||||
gtk-update-icon-cache -q /usr/share/icons/hicolor
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
glib-compile-schemas /usr/share/glib-2.0/schemas
|
||||
gtk-update-icon-cache -q /usr/share/icons/hicolor
|
||||
}
|
||||
|
|
|
@ -5,12 +5,19 @@ import gi
|
|||
gi.require_version('Gtk', '4.0')
|
||||
gi.require_version('Adw', '1')
|
||||
|
||||
from gi.repository import Adw, Gio
|
||||
from gi.repository import Adw, Gio, Gtk
|
||||
from importlib.resources import files
|
||||
from importlib.metadata import version, PackageNotFoundError
|
||||
|
||||
try:
|
||||
__version__ = version("recoder")
|
||||
except PackageNotFoundError:
|
||||
__version__ = "unknown"
|
||||
|
||||
APP_NAME = "Recoder"
|
||||
|
||||
Adw.init()
|
||||
|
||||
|
||||
def load_resources():
|
||||
resource_path = files("recoder").joinpath("resources.gresource")
|
||||
resource = Gio.Resource.load(str(resource_path))
|
||||
|
@ -30,6 +37,7 @@ def main():
|
|||
application_id="net.jeena.Recoder",
|
||||
flags=Gio.ApplicationFlags.FLAGS_NONE
|
||||
)
|
||||
|
||||
self.window = None
|
||||
self.preferences_window = None
|
||||
|
||||
|
@ -45,15 +53,31 @@ def main():
|
|||
preferences_action = Gio.SimpleAction.new("preferences", None)
|
||||
preferences_action.connect("activate", self.on_preferences_activate)
|
||||
self.add_action(preferences_action)
|
||||
# Add the accelerator for Preferences (Ctrl+,)
|
||||
self.set_accels_for_action("app.preferences", ["<Primary>comma"])
|
||||
|
||||
about_action = Gio.SimpleAction.new("about", None)
|
||||
about_action.connect("activate", self.on_about_activate)
|
||||
self.add_action(about_action)
|
||||
|
||||
def do_activate(self):
|
||||
if not self.window:
|
||||
self.window = RecoderWindow(self)
|
||||
self.window.connect("close-request", self.on_window_close)
|
||||
self.window.present()
|
||||
|
||||
def on_about_activate(self, action, param):
|
||||
about = Adw.AboutWindow(
|
||||
application_name=APP_NAME,
|
||||
application_icon=self.get_application_id(),
|
||||
version=__version__,
|
||||
developer_name="Jeena",
|
||||
license_type=Gtk.License.GPL_3_0,
|
||||
website="https://github.com/jeena/recoder",
|
||||
issue_url="https://github.com/jeena/recoder/issues",
|
||||
transient_for=self.window,
|
||||
)
|
||||
about.present()
|
||||
|
||||
def on_preferences_activate(self, action, param):
|
||||
if not self.preferences_window:
|
||||
self.preferences_window = RecoderPreferences()
|
||||
|
|
|
@ -2,6 +2,8 @@ import gi
|
|||
gi.require_version("GObject", "2.0")
|
||||
from gi.repository import GObject
|
||||
|
||||
from recoder.app import APP_NAME
|
||||
|
||||
|
||||
class AppState(GObject.GEnum):
|
||||
IDLE = 0
|
||||
|
@ -43,11 +45,10 @@ class UIStateManager:
|
|||
|
||||
def _update_title(self, folder_name=None):
|
||||
w = self.window
|
||||
base = "Recoder"
|
||||
if folder_name:
|
||||
w.folder_label.set_text(f"{base} — {folder_name}")
|
||||
w.folder_label.set_text(f"{APP_NAME} — {folder_name}")
|
||||
else:
|
||||
w.folder_label.set_text(base)
|
||||
w.folder_label.set_text(APP_NAME)
|
||||
|
||||
def _handle_idle(self):
|
||||
self._update_title(None)
|
||||
|
|
|
@ -15,6 +15,7 @@ from recoder.file_entry_row import FileEntryRow
|
|||
from recoder.drop_handler import DropHandler
|
||||
from recoder.app_state import AppState, AppStateManager, UIStateManager
|
||||
from recoder.preferences import RecoderPreferences
|
||||
from recoder.app import APP_NAME
|
||||
|
||||
|
||||
@Gtk.Template(resource_path="/net/jeena/recoder/window.ui")
|
||||
|
@ -68,7 +69,7 @@ class RecoderWindow(Adw.ApplicationWindow):
|
|||
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
)
|
||||
|
||||
Notify.init("Recoder")
|
||||
Notify.init(APP_NAME)
|
||||
|
||||
|
||||
def process_drop_value(self, value):
|
||||
|
@ -148,12 +149,12 @@ class RecoderWindow(Adw.ApplicationWindow):
|
|||
def on_transcoder_status(self, transcoder, param):
|
||||
if transcoder.batch_status == BatchStatus.DONE:
|
||||
play_complete_sound()
|
||||
notify_done("Recoder", "Transcoding finished!")
|
||||
notify_done(APP_NAME, "Transcoding finished!")
|
||||
self.app_state_manager.state = AppState.DONE
|
||||
|
||||
elif transcoder.batch_status == BatchStatus.STOPPED:
|
||||
self.app_state_manager.state = AppState.STOPPED
|
||||
|
||||
elif transcoder.batch_status == BatchStatus.ERROR:
|
||||
notify_done("Recoder", "An error occurred during transcoding.")
|
||||
notify_done(APP_NAME, "An error occurred during transcoding.")
|
||||
self.app_state_manager.state = AppState.ERROR
|
||||
|
|
|
@ -4,5 +4,6 @@
|
|||
<file>preferences.ui</file>
|
||||
<file>file_entry_row.ui</file>
|
||||
<file>style.css</file>
|
||||
<file alias="net.jeena.Recoder.svg">../resources/net.jeena.Recoder.svg</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
<attribute name="label">Preferences</attribute>
|
||||
<attribute name="action">app.preferences</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label">About Recoder</attribute>
|
||||
<attribute name="action">app.about</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label">Quit</attribute>
|
||||
<attribute name="action">app.quit</attribute>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue