Show play button on hover - closes #4
This commit is contained in:
@@ -28,12 +28,31 @@ template game : Box {
|
|||||||
maximum-size: 200;
|
maximum-size: 200;
|
||||||
|
|
||||||
Box {
|
Box {
|
||||||
Label title {
|
Overlay overlay {
|
||||||
label: _("Title");
|
[overlay]
|
||||||
ellipsize: end;
|
Revealer button_revealer {
|
||||||
hexpand: true;
|
reveal-child: false;
|
||||||
halign: start;
|
transition-type: crossfade;
|
||||||
margin-start: 12;
|
Button button_play {
|
||||||
|
halign: start;
|
||||||
|
label: _("Play");
|
||||||
|
margin-start: 6;
|
||||||
|
margin-end: 6;
|
||||||
|
margin-top: 6;
|
||||||
|
margin-bottom: 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Revealer title_revealer {
|
||||||
|
transition-type: crossfade;
|
||||||
|
reveal-child: true;
|
||||||
|
Label title {
|
||||||
|
label: _("Title");
|
||||||
|
ellipsize: end;
|
||||||
|
hexpand: true;
|
||||||
|
halign: start;
|
||||||
|
margin-start: 12;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuButton menu_button {
|
MenuButton menu_button {
|
||||||
@@ -57,13 +76,6 @@ template game : Box {
|
|||||||
}
|
}
|
||||||
|
|
||||||
menu game_options {
|
menu game_options {
|
||||||
section {
|
|
||||||
item {
|
|
||||||
label: _("Play");
|
|
||||||
action: "app.launch_game";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
section {
|
section {
|
||||||
item {
|
item {
|
||||||
label: _("Edit");
|
label: _("Edit");
|
||||||
@@ -83,13 +95,6 @@ menu game_options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
menu hidden_game_options {
|
menu hidden_game_options {
|
||||||
section {
|
|
||||||
item {
|
|
||||||
label: _("Play");
|
|
||||||
action: "app.launch_game";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
section {
|
section {
|
||||||
item {
|
item {
|
||||||
label: _("Edit");
|
label: _("Edit");
|
||||||
|
|||||||
22
src/game.py
22
src/game.py
@@ -23,18 +23,38 @@ from gi.repository import Gtk
|
|||||||
class game(Gtk.Box):
|
class game(Gtk.Box):
|
||||||
__gtype_name__ = 'game'
|
__gtype_name__ = 'game'
|
||||||
|
|
||||||
|
overlay = Gtk.Template.Child()
|
||||||
title = Gtk.Template.Child()
|
title = Gtk.Template.Child()
|
||||||
|
button_play = Gtk.Template.Child()
|
||||||
cover = Gtk.Template.Child()
|
cover = Gtk.Template.Child()
|
||||||
cover_button = Gtk.Template.Child()
|
cover_button = Gtk.Template.Child()
|
||||||
menu_button = Gtk.Template.Child()
|
menu_button = Gtk.Template.Child()
|
||||||
hidden_game_options = Gtk.Template.Child()
|
hidden_game_options = Gtk.Template.Child()
|
||||||
|
button_revealer = Gtk.Template.Child()
|
||||||
|
title_revealer = Gtk.Template.Child()
|
||||||
|
|
||||||
def __init__(self, title, pixbuf, game_id, **kwargs):
|
def __init__(self, parent_widget, title, pixbuf, game_id, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
self.parent_widget = parent_widget
|
||||||
self.name = title
|
self.name = title
|
||||||
self.pixbuf = pixbuf
|
self.pixbuf = pixbuf
|
||||||
self.game_id = game_id
|
self.game_id = game_id
|
||||||
|
|
||||||
self.title.set_label(title)
|
self.title.set_label(title)
|
||||||
self.cover.set_pixbuf(pixbuf)
|
self.cover.set_pixbuf(pixbuf)
|
||||||
|
|
||||||
|
self.event_contoller_motion = Gtk.EventControllerMotion.new()
|
||||||
|
self.overlay.add_controller(self.event_contoller_motion)
|
||||||
|
|
||||||
|
self.button_play.connect("clicked", self.launch_game)
|
||||||
|
self.event_contoller_motion.connect("enter", self.toggle_show_play)
|
||||||
|
self.event_contoller_motion.connect("leave", self.toggle_show_play)
|
||||||
|
|
||||||
|
def toggle_show_play(self, widget, *args):
|
||||||
|
self.button_revealer.set_reveal_child(not self.button_revealer.get_reveal_child())
|
||||||
|
self.title_revealer.set_reveal_child(not self.title_revealer.get_reveal_child())
|
||||||
|
|
||||||
|
def launch_game(self, widget):
|
||||||
|
self.parent_widget.set_active_game(None, None, self.game_id)
|
||||||
|
self.parent_widget.get_application().on_launch_game_action(None)
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
|||||||
if "removed" in current_game.keys():
|
if "removed" in current_game.keys():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
entry = game(current_game["name"], get_cover(current_game, self), game_id)
|
entry = game(self, current_game["name"], get_cover(current_game, self), game_id)
|
||||||
|
|
||||||
if not self.games[game_id]["hidden"]:
|
if not self.games[game_id]["hidden"]:
|
||||||
self.visible_widgets[game_id] = entry
|
self.visible_widgets[game_id] = entry
|
||||||
|
|||||||
Reference in New Issue
Block a user