Add both about and shortcuts window in the help service
Both screens are alike. Now the about window is also rendered from a Glade file.
This commit is contained in:
parent
4db1901b14
commit
8cc286320b
@ -1,53 +0,0 @@
|
||||
"""About and help services. (help browser anyone?)"""
|
||||
|
||||
|
||||
import importlib_metadata
|
||||
from gi.repository import GdkPixbuf, Gtk
|
||||
|
||||
from gaphor import __version__
|
||||
from gaphor.abc import ActionProvider, Service
|
||||
from gaphor.core import action
|
||||
|
||||
|
||||
class HelpService(Service, ActionProvider):
|
||||
def __init__(self, main_window):
|
||||
self.main_window = main_window
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
@action(name="app.about")
|
||||
def about(self):
|
||||
logo_file = importlib_metadata.distribution("gaphor").locate_file(
|
||||
"gaphor/ui/pixmaps/gaphor-96x96.png"
|
||||
)
|
||||
logo = GdkPixbuf.Pixbuf.new_from_file(str(logo_file))
|
||||
about = Gtk.AboutDialog.new()
|
||||
about.set_logo(logo)
|
||||
about.set_title("About Gaphor")
|
||||
about.set_program_name("Gaphor")
|
||||
about.set_comments("Gaphor is the simple modeling tool written in Python")
|
||||
about.set_version(str(__version__))
|
||||
about.set_copyright("Copyright (c) 2001-2019 Arjan J. Molenaar and Dan Yeaw")
|
||||
about.set_license(
|
||||
"This software is published under the terms of the\n"
|
||||
"Apache Software License, version 2.0.\n"
|
||||
"See the LICENSE.txt file for details."
|
||||
)
|
||||
about.set_website("https://github.com/gaphor/gaphor")
|
||||
about.set_website_label("Fork me on GitHub")
|
||||
about.set_authors(
|
||||
[
|
||||
"Arjan Molenaar, Artur Wroblewski,",
|
||||
"Jeroen Vloothuis, Dan Yeaw, ",
|
||||
"Enno Groeper, Adam Boduch, ",
|
||||
"Alexis Howells, Melis Doğan",
|
||||
]
|
||||
)
|
||||
about.set_translator_credits(
|
||||
"Jordi Mallach (ca), " "Antonin Delpeuch (fr), " "Ygor Mutti (pt_BR)"
|
||||
)
|
||||
about.set_transient_for(self.main_window.window)
|
||||
about.show_all()
|
||||
about.run()
|
||||
about.destroy()
|
50
gaphor/services/helpservice/__init__.py
Normal file
50
gaphor/services/helpservice/__init__.py
Normal file
@ -0,0 +1,50 @@
|
||||
"""About and help services. (help browser anyone?)"""
|
||||
|
||||
|
||||
import importlib
|
||||
|
||||
from gi.repository import GdkPixbuf, Gtk
|
||||
|
||||
from gaphor import __version__
|
||||
from gaphor.abc import ActionProvider, Service
|
||||
from gaphor.core import action
|
||||
|
||||
|
||||
class HelpService(Service, ActionProvider):
|
||||
def __init__(self, main_window):
|
||||
self.main_window = main_window
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
@action(name="app.about")
|
||||
def about(self):
|
||||
builder = Gtk.Builder()
|
||||
with importlib.resources.path(
|
||||
"gaphor.services.helpservice", "about.glade"
|
||||
) as glade_file:
|
||||
builder.add_objects_from_file(str(glade_file), ("about",))
|
||||
|
||||
about = builder.get_object("about")
|
||||
|
||||
about.set_version(str(__version__))
|
||||
|
||||
about.set_transient_for(self.main_window.window)
|
||||
|
||||
about.show_all()
|
||||
about.run()
|
||||
about.destroy()
|
||||
|
||||
@action(name="app.shortcuts")
|
||||
def shortcuts(self):
|
||||
builder = Gtk.Builder()
|
||||
with importlib.resources.path(
|
||||
"gaphor.services.helpservice", "shortcuts.glade"
|
||||
) as glade_file:
|
||||
builder.add_objects_from_file(str(glade_file), ("shortcuts-gaphor",))
|
||||
|
||||
shortcuts = builder.get_object("shortcuts-gaphor")
|
||||
shortcuts.set_transient_for(self.main_window.window)
|
||||
|
||||
shortcuts.show_all()
|
||||
return shortcuts
|
54
gaphor/services/helpservice/about.glade
Normal file
54
gaphor/services/helpservice/about.glade
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkAboutDialog" id="about">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<property name="program_name">Gaphor</property>
|
||||
<property name="version">1.1.0</property>
|
||||
<property name="copyright" translatable="yes">Copyright © 2001-2019 Arjan J. Molenaar and Dan Yeaw</property>
|
||||
<property name="comments" translatable="yes">Gaphor is the simple modeling tool written in Python</property>
|
||||
<property name="website">https://github.com/gaphor/gaphor</property>
|
||||
<property name="website_label" translatable="yes">Fork me on GitHub</property>
|
||||
<property name="license" translatable="yes">This software is published under the terms of the
|
||||
Apache Software License, version 2.0.
|
||||
See the LICENSE.txt file for details.</property>
|
||||
<property name="authors">Arjan Molenaar, Artur Wroblewski,
|
||||
Jeroen Vloothuis, Dan Yeaw,
|
||||
Enno Groeper, Adam Boduch,
|
||||
Alexis Howells, Melis Doğan</property>
|
||||
<property name="translator_credits" translatable="yes">Jordi Mallach (ca), Antonin Delpeuch (fr), Ygor Mutti (pt_BR)</property>
|
||||
<property name="logo">gaphor-96x96.png</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
BIN
gaphor/services/helpservice/gaphor-96x96.png
Normal file
BIN
gaphor/services/helpservice/gaphor-96x96.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
@ -1,27 +0,0 @@
|
||||
import importlib
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor.abc import ActionProvider, Service
|
||||
from gaphor.core import action
|
||||
from gaphor.ui.actiongroup import create_action_group, set_action_state
|
||||
|
||||
|
||||
class Shortcuts(Service, ActionProvider):
|
||||
def __init__(self, main_window, properties):
|
||||
self.main_window = main_window
|
||||
|
||||
@action(name="app.shortcuts")
|
||||
def open(self):
|
||||
builder = Gtk.Builder()
|
||||
with importlib.resources.path("gaphor.ui", "shortcuts.glade") as glade_file:
|
||||
builder.add_objects_from_file(str(glade_file), ("shortcuts-gaphor",))
|
||||
|
||||
shortcuts = builder.get_object("shortcuts-gaphor")
|
||||
shortcuts.set_transient_for(self.main_window.window)
|
||||
|
||||
shortcuts.show_all()
|
||||
return shortcuts
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
@ -71,7 +71,6 @@ gaphorconvert = 'gaphor.tools.gaphorconvert:main'
|
||||
"recent_files" = "gaphor.ui.recentfiles:RecentFiles"
|
||||
"main_window" = "gaphor.ui.mainwindow:MainWindow"
|
||||
"preferences" = "gaphor.ui.preferences:Preferences"
|
||||
"shortcuts" = "gaphor.ui.shortcuts:Shortcuts"
|
||||
"export_menu" = "gaphor.ui.menufragment:MenuFragment"
|
||||
"tools_menu" = "gaphor.ui.menufragment:MenuFragment"
|
||||
"copy" = "gaphor.services.copyservice:CopyService"
|
||||
|
Loading…
x
Reference in New Issue
Block a user