diff --git a/data/gtk/game.blp b/data/gtk/game.blp index 3b2c58d..e48791f 100644 --- a/data/gtk/game.blp +++ b/data/gtk/game.blp @@ -44,7 +44,6 @@ template game : Box { margin-bottom: 6; margin-end: 6; margin-start: 6; - menu-model: game_options; hexpand: true; halign: end; diff --git a/data/gtk/window.blp b/data/gtk/window.blp index a3af739..9a4767a 100644 --- a/data/gtk/window.blp +++ b/data/gtk/window.blp @@ -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"; - } - } -} diff --git a/src/game.py b/src/game.py index 8b0dbf5..b767f78 100644 --- a/src/game.py +++ b/src/game.py @@ -37,9 +37,10 @@ class game(Gtk.Box): # pylint: disable=invalid-name cover = Gtk.Template.Child() cover_button = Gtk.Template.Child() menu_button = Gtk.Template.Child() - hidden_game_options = Gtk.Template.Child() play_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): super().__init__(**kwargs) @@ -67,6 +68,11 @@ class game(Gtk.Box): # pylint: disable=invalid-name self.button_play.connect("clicked", self.launch_game) self.event_contoller_motion.connect("enter", self.show_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) def launch(self): diff --git a/src/window.py b/src/window.py index c1824e0..ec142da 100644 --- a/src/window.py +++ b/src/window.py @@ -41,7 +41,6 @@ class CartridgesWindow(Adw.ApplicationWindow): library_bin = Gtk.Template.Child() notice_empty = Gtk.Template.Child() notice_no_results = Gtk.Template.Child() - game_options = Gtk.Template.Child() search_bar = Gtk.Template.Child() search_entry = Gtk.Template.Child() search_button = Gtk.Template.Child() @@ -62,7 +61,6 @@ class CartridgesWindow(Adw.ApplicationWindow): hidden_scrolledwindow = Gtk.Template.Child() hidden_library_bin = Gtk.Template.Child() hidden_notice_empty = Gtk.Template.Child() - hidden_game_options = Gtk.Template.Child() hidden_search_bar = Gtk.Template.Child() hidden_search_entry = Gtk.Template.Child() hidden_search_button = Gtk.Template.Child() @@ -153,7 +151,6 @@ class CartridgesWindow(Adw.ApplicationWindow): self.library.append(entry) else: self.hidden_widgets[game_id] = entry - entry.menu_button.set_menu_model(entry.hidden_game_options) self.hidden_library.append(entry) entry.cover_button.connect("clicked", self.show_overview, game_id) @@ -241,10 +238,9 @@ class CartridgesWindow(Adw.ApplicationWindow): else: self.overview_developer.set_visible(False) - if not current_game.hidden: - self.overview_menu_button.set_menu_model(self.game_options) - else: - self.overview_menu_button.set_menu_model(self.hidden_game_options) + self.overview_menu_button.set_menu_model( + current_game.menu_button.get_menu_model() + ) if self.stack.get_visible_child() != self.overview: self.stack.set_transition_type(Gtk.StackTransitionType.OVER_LEFT)