[gnome-games] display-header: Add restart button to secondary menu
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] display-header: Add restart button to secondary menu
- Date: Tue, 28 Jan 2020 13:39:11 +0000 (UTC)
commit e01ad1437af45555bf0fbb2a83dbfe914c572bc5
Author: sevagen <sevagenv gmail com>
Date: Tue Jan 28 17:12:28 2020 +0530
display-header: Add restart button to secondary menu
data/ui/display-header-bar.ui | 14 ++++++++++++++
src/command/command-runner.vala | 3 +++
src/core/runner.vala | 1 +
src/retro/retro-runner.vala | 5 +++++
src/ui/display-header-bar.vala | 9 ++++++++-
5 files changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/data/ui/display-header-bar.ui b/data/ui/display-header-bar.ui
index 4f379967..3021b6bc 100644
--- a/data/ui/display-header-bar.ui
+++ b/data/ui/display-header-bar.ui
@@ -183,6 +183,20 @@
<object class="GtkBox" id="secondary_menu_box">
<property name="visible">True</property>
<property name="margin">6</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkModelButton">
+ <property name="visible">True</property>
+ <property name="text" translatable="yes">_Restart</property>
+ <signal name="clicked" handler="on_restart_clicked"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="orientation">vertical</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
<child>
<object class="GtkModelButton" id="savestates_menu_button">
<property name="visible">True</property>
diff --git a/src/command/command-runner.vala b/src/command/command-runner.vala
index a472c2f8..9a945c80 100644
--- a/src/command/command-runner.vala
+++ b/src/command/command-runner.vala
@@ -90,6 +90,9 @@ public class Games.CommandRunner : Object, Runner {
}
}
+ public void restart () {
+ }
+
public void resume () {
}
diff --git a/src/core/runner.vala b/src/core/runner.vala
index 7a10160b..82e71976 100644
--- a/src/core/runner.vala
+++ b/src/core/runner.vala
@@ -16,6 +16,7 @@ public interface Games.Runner : Object {
public abstract bool try_init_phase_one (out string error_message);
public abstract void start () throws Error;
+ public abstract void restart ();
public abstract void resume ();
public abstract void pause ();
public abstract void stop ();
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index d35c3cf3..48bd684d 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -246,6 +246,11 @@ public class Games.RetroRunner : Object, Runner {
running = true;
}
+ public void restart () {
+ try_create_savestate (true);
+ core.reset ();
+ }
+
public void resume () {
if (!is_ready) {
critical ("RetroRunner.resume() cannot be called if the game isn't playing");
diff --git a/src/ui/display-header-bar.vala b/src/ui/display-header-bar.vala
index 4ef34f08..45158831 100644
--- a/src/ui/display-header-bar.vala
+++ b/src/ui/display-header-bar.vala
@@ -38,8 +38,8 @@ private class Games.DisplayHeaderBar : Gtk.Bin {
if (runner != null) {
extra_widget = runner.get_extra_widget ();
- secondary_menu_button.sensitive = runner.supports_savestates;
secondary_menu_button.visible = runner.can_support_savestates;
+ savestates_menu_button.sensitive = runner.supports_savestates;
}
else
extra_widget = null;
@@ -74,6 +74,8 @@ private class Games.DisplayHeaderBar : Gtk.Bin {
[GtkChild]
private Gtk.MenuButton secondary_menu_button;
[GtkChild]
+ private Gtk.ModelButton savestates_menu_button;
+ [GtkChild]
private Gtk.HeaderBar savestates_header_bar;
private Settings settings;
@@ -114,6 +116,11 @@ private class Games.DisplayHeaderBar : Gtk.Bin {
is_showing_snapshots = true;
}
+ [GtkCallback]
+ private void on_restart_clicked () {
+ runner.restart ();
+ }
+
[GtkCallback]
private void on_showing_snapshots_changed () {
if (is_showing_snapshots)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]