Add About/Info dialog (implement #26)
This commit is contained in:
parent
23742542af
commit
e555956c95
4 changed files with 93 additions and 1 deletions
|
|
@ -1307,4 +1307,49 @@
|
|||
<class name="bg-texture"/>
|
||||
</style>
|
||||
</object>
|
||||
<object class="GtkAboutDialog" id="info-dialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<property name="gravity">center</property>
|
||||
<property name="transient_for">appwindow</property>
|
||||
<property name="program_name">CoverGrid</property>
|
||||
<property name="version">0.6</property>
|
||||
<property name="comments" translatable="yes">CoverGrid is a client for the Music Player Daemon, focused on albums instead of single tracks.</property>
|
||||
<property name="website">http://www.coderkun.de/codes/mcg</property>
|
||||
<property name="logo">mcg.svg</property>
|
||||
<property name="license_type">gpl-3-0</property>
|
||||
<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>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
|||
|
|
@ -47,6 +47,11 @@
|
|||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="action">app.info</attribute>
|
||||
<attribute name="label" translatable="yes">Info</attribute>
|
||||
<attribute name="accel"><Primary>i</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="action">app.quit</attribute>
|
||||
<attribute name="label" translatable="yes">_Quit</attribute>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ class Application(Gtk.Application):
|
|||
def __init__(self):
|
||||
Gtk.Application.__init__(self, application_id=Application.ID, flags=Gio.ApplicationFlags.FLAGS_NONE)
|
||||
self._window = None
|
||||
self._verbosity = self._verbosity = logging.WARNING
|
||||
self._info_dialog = None
|
||||
self._verbosity = logging.WARNING
|
||||
self.add_main_option_entries([
|
||||
Application._get_option("v", "verbose", "Be verbose: show info messages"),
|
||||
Application._get_option("d", "debug", "Enable debugging: show debug messages")
|
||||
|
|
@ -67,6 +68,12 @@ class Application(Gtk.Application):
|
|||
self._window.present()
|
||||
|
||||
|
||||
def on_menu_info(self, action, value):
|
||||
if not self._info_dialog:
|
||||
self._info_dialog = widgets.InfoDialog(self._builder)
|
||||
self._info_dialog.run()
|
||||
|
||||
|
||||
def on_menu_quit(self, action, value):
|
||||
self.quit()
|
||||
|
||||
|
|
@ -112,6 +119,9 @@ class Application(Gtk.Application):
|
|||
|
||||
|
||||
def _setup_actions(self):
|
||||
action = Gio.SimpleAction.new("info", None)
|
||||
action.connect('activate', self.on_menu_info)
|
||||
self.add_action(action)
|
||||
action = Gio.SimpleAction.new("quit", None)
|
||||
action.connect('activate', self.on_menu_quit)
|
||||
self.add_action(action)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,38 @@ from mcg.zeroconf import ZeroconfProvider
|
|||
|
||||
|
||||
|
||||
class InfoDialog():
|
||||
|
||||
|
||||
def __init__(self, builder):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
# Widgets
|
||||
self._info_dialog = builder.get_object('info-dialog')
|
||||
self._resize_logo()
|
||||
|
||||
|
||||
def get(self):
|
||||
return self._info_dialog
|
||||
|
||||
|
||||
def run(self):
|
||||
self._info_dialog.run()
|
||||
self._info_dialog.hide()
|
||||
|
||||
|
||||
def _resize_logo(self):
|
||||
try:
|
||||
logo_pixbuf = self._info_dialog.get_logo()
|
||||
self._info_dialog.set_logo(
|
||||
logo_pixbuf.scale_simple(256, 256, GdkPixbuf.InterpType.HYPER)
|
||||
)
|
||||
except:
|
||||
self._logger.warn("Failed to resize logo")
|
||||
|
||||
|
||||
|
||||
|
||||
class Window():
|
||||
SETTING_HOST = 'host'
|
||||
SETTING_PORT = 'port'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue