Move menu models to the game class
This commit is contained in:
@@ -44,7 +44,6 @@ template game : Box {
|
|||||||
margin-bottom: 6;
|
margin-bottom: 6;
|
||||||
margin-end: 6;
|
margin-end: 6;
|
||||||
margin-start: 6;
|
margin-start: 6;
|
||||||
menu-model: game_options;
|
|
||||||
hexpand: true;
|
hexpand: true;
|
||||||
halign: end;
|
halign: end;
|
||||||
|
|
||||||
|
|||||||
@@ -404,41 +404,3 @@ menu add_games {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
menu game_options {
|
|
||||||
section {
|
|
||||||
item {
|
|
||||||
label: _("Edit");
|
|
||||||
action: "app.edit_details";
|
|
||||||
}
|
|
||||||
|
|
||||||
item {
|
|
||||||
label: _("Hide");
|
|
||||||
action: "app.hide_game";
|
|
||||||
}
|
|
||||||
|
|
||||||
item {
|
|
||||||
label: _("Remove");
|
|
||||||
action: "app.remove_game";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
menu hidden_game_options {
|
|
||||||
section {
|
|
||||||
item {
|
|
||||||
label: _("Edit");
|
|
||||||
action: "app.edit_details";
|
|
||||||
}
|
|
||||||
|
|
||||||
item {
|
|
||||||
label: _("Unhide");
|
|
||||||
action: "app.hide_game";
|
|
||||||
}
|
|
||||||
|
|
||||||
item {
|
|
||||||
label: _("Remove");
|
|
||||||
action: "app.remove_game";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -37,9 +37,10 @@ class game(Gtk.Box): # pylint: disable=invalid-name
|
|||||||
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()
|
|
||||||
play_revealer = Gtk.Template.Child()
|
play_revealer = Gtk.Template.Child()
|
||||||
title_revealer = Gtk.Template.Child()
|
title_revealer = Gtk.Template.Child()
|
||||||
|
game_options = Gtk.Template.Child()
|
||||||
|
hidden_game_options = Gtk.Template.Child()
|
||||||
|
|
||||||
def __init__(self, parent_widget, data, **kwargs):
|
def __init__(self, parent_widget, data, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
@@ -67,6 +68,11 @@ class game(Gtk.Box): # pylint: disable=invalid-name
|
|||||||
self.button_play.connect("clicked", self.launch_game)
|
self.button_play.connect("clicked", self.launch_game)
|
||||||
self.event_contoller_motion.connect("enter", self.show_play)
|
self.event_contoller_motion.connect("enter", self.show_play)
|
||||||
self.event_contoller_motion.connect("leave", self.hide_play)
|
self.event_contoller_motion.connect("leave", self.hide_play)
|
||||||
|
|
||||||
|
if self.hidden:
|
||||||
|
self.menu_button.set_menu_model(self.hidden_game_options)
|
||||||
|
else:
|
||||||
|
self.menu_button.set_menu_model(self.game_options)
|
||||||
self.menu_button.get_popover().connect("notify::visible", self.hide_play)
|
self.menu_button.get_popover().connect("notify::visible", self.hide_play)
|
||||||
|
|
||||||
def launch(self):
|
def launch(self):
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
|||||||
library_bin = Gtk.Template.Child()
|
library_bin = Gtk.Template.Child()
|
||||||
notice_empty = Gtk.Template.Child()
|
notice_empty = Gtk.Template.Child()
|
||||||
notice_no_results = Gtk.Template.Child()
|
notice_no_results = Gtk.Template.Child()
|
||||||
game_options = Gtk.Template.Child()
|
|
||||||
search_bar = Gtk.Template.Child()
|
search_bar = Gtk.Template.Child()
|
||||||
search_entry = Gtk.Template.Child()
|
search_entry = Gtk.Template.Child()
|
||||||
search_button = Gtk.Template.Child()
|
search_button = Gtk.Template.Child()
|
||||||
@@ -62,7 +61,6 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
|||||||
hidden_scrolledwindow = Gtk.Template.Child()
|
hidden_scrolledwindow = Gtk.Template.Child()
|
||||||
hidden_library_bin = Gtk.Template.Child()
|
hidden_library_bin = Gtk.Template.Child()
|
||||||
hidden_notice_empty = Gtk.Template.Child()
|
hidden_notice_empty = Gtk.Template.Child()
|
||||||
hidden_game_options = Gtk.Template.Child()
|
|
||||||
hidden_search_bar = Gtk.Template.Child()
|
hidden_search_bar = Gtk.Template.Child()
|
||||||
hidden_search_entry = Gtk.Template.Child()
|
hidden_search_entry = Gtk.Template.Child()
|
||||||
hidden_search_button = Gtk.Template.Child()
|
hidden_search_button = Gtk.Template.Child()
|
||||||
@@ -153,7 +151,6 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
|||||||
self.library.append(entry)
|
self.library.append(entry)
|
||||||
else:
|
else:
|
||||||
self.hidden_widgets[game_id] = entry
|
self.hidden_widgets[game_id] = entry
|
||||||
entry.menu_button.set_menu_model(entry.hidden_game_options)
|
|
||||||
self.hidden_library.append(entry)
|
self.hidden_library.append(entry)
|
||||||
|
|
||||||
entry.cover_button.connect("clicked", self.show_overview, game_id)
|
entry.cover_button.connect("clicked", self.show_overview, game_id)
|
||||||
@@ -241,10 +238,9 @@ class CartridgesWindow(Adw.ApplicationWindow):
|
|||||||
else:
|
else:
|
||||||
self.overview_developer.set_visible(False)
|
self.overview_developer.set_visible(False)
|
||||||
|
|
||||||
if not current_game.hidden:
|
self.overview_menu_button.set_menu_model(
|
||||||
self.overview_menu_button.set_menu_model(self.game_options)
|
current_game.menu_button.get_menu_model()
|
||||||
else:
|
)
|
||||||
self.overview_menu_button.set_menu_model(self.hidden_game_options)
|
|
||||||
|
|
||||||
if self.stack.get_visible_child() != self.overview:
|
if self.stack.get_visible_child() != self.overview:
|
||||||
self.stack.set_transition_type(Gtk.StackTransitionType.OVER_LEFT)
|
self.stack.set_transition_type(Gtk.StackTransitionType.OVER_LEFT)
|
||||||
|
|||||||
Reference in New Issue
Block a user