After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 686775 - Move force shutdown to properties view
Move force shutdown to properties view
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: properties
unspecified
Other Linux
: Normal normal
: --
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks: 686781
 
 
Reported: 2012-10-24 10:07 UTC by Alexander Larsson
Modified: 2016-03-31 14:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Rename machine to libvirt_machine (1.39 KB, patch)
2012-10-25 15:04 UTC, Alexander Larsson
committed Details | Review
Add machine local var (1.47 KB, patch)
2012-10-25 15:04 UTC, Alexander Larsson
committed Details | Review
Add force shutdown button to properties view (1.49 KB, patch)
2012-10-25 15:04 UTC, Alexander Larsson
committed Details | Review
Remove force shutdown from app menu (2.28 KB, patch)
2012-10-25 15:04 UTC, Alexander Larsson
committed Details | Review

Description Alexander Larsson 2012-10-24 10:07:41 UTC
As per the latest mockups[1] we should have a force shutdown button
in the sidebar in the properties view. This is much easier to find
than the weird placement of this in the global app menu.

[1] https://raw.github.com/gnome-design-team/gnome-mockups/master/boxes/boxes-properties.png
Comment 1 Christophe Fergeau 2012-10-24 10:12:55 UTC
This design may change if we decide to make it possible for the user to suspend running boxes, dunno if it's worth waiting for design input for that one.
Comment 2 Alexander Larsson 2012-10-25 15:04:12 UTC
Created attachment 227269 [details] [review]
Rename machine to libvirt_machine

We will later use the machine name for another use.
Comment 3 Alexander Larsson 2012-10-25 15:04:15 UTC
Created attachment 227270 [details] [review]
Add machine local var

This is resued twice and will be used more
Comment 4 Alexander Larsson 2012-10-25 15:04:19 UTC
Created attachment 227271 [details] [review]
Add force shutdown button to properties view
Comment 5 Alexander Larsson 2012-10-25 15:04:22 UTC
Created attachment 227272 [details] [review]
Remove force shutdown from app menu
Comment 6 Zeeshan Ali 2012-10-25 15:34:26 UTC
Review of attachment 227269 [details] [review]:

ACK but would be nice to say in the log that you are talking of a local variable (as opposed to the classes).
Comment 7 Zeeshan Ali 2012-10-25 15:34:44 UTC
Review of attachment 227270 [details] [review]:

ACK

::: src/properties.vala
@@ -142,3 +142,4 @@
             notebook.remove_page (-1);
 
-        if (App.app.current_item == null)
+        var machine = App.app.current_item as Machine;
+

nitpick: I'd remove this line
Comment 8 Zeeshan Ali 2012-10-25 15:39:49 UTC
Review of attachment 227271 [details] [review]:

Looks good otherwise.

::: src/properties.vala
@@ -144,2 +145,3 @@
         var machine = App.app.current_item as Machine;
 
+        shutdown_button.sensitive = machine != null && machine is LibvirtMachine;

Shouldn't this be setting 'visible' prop instead?

@@ -259,1 +262,5 @@
 
+        shutdown_button = new Button.with_label (_("Force Shutdown"));
+        shutdown_button.clicked.connect ( () => {
+            var machine = App.app.current_item as LibvirtMachine;
+            if (machine != null)

1. I prefer explicit type checking instead of 'casting and then checking of null':

if (App.app.current_item is LibvirtMachine)
    (App.app.current_item as LibvirtMachine).shutdown ();

2. Since the button can only be pressed for LibvirtMachine, do we need a check here?
Comment 9 Alexander Larsson 2012-10-25 15:46:47 UTC
Review of attachment 227270 [details] [review]:

::: src/properties.vala
@@ -142,3 +142,4 @@
             notebook.remove_page (-1);
 
-        if (App.app.current_item == null)
+        var machine = App.app.current_item as Machine;
+

Well, the next patch inserts something inbetween here.
Comment 10 Alexander Larsson 2012-10-25 15:50:13 UTC
Review of attachment 227271 [details] [review]:

::: src/properties.vala
@@ -144,2 +145,3 @@
         var machine = App.app.current_item as Machine;
 
+        shutdown_button.sensitive = machine != null && machine is LibvirtMachine;

I don't think so, I think its nice that UIs don't relayout themselves base on the content to much, it means things are in the same place all the time and you can learn what features there are, even if they are not always available.

@@ -259,1 +262,5 @@
 
+        shutdown_button = new Button.with_label (_("Force Shutdown"));
+        shutdown_button.clicked.connect ( () => {
+            var machine = App.app.current_item as LibvirtMachine;
+            if (machine != null)

1. That is longer to read and less efficient at runtime. I'm not sure its better.

2. We don't, but better safe than sorry.
Comment 11 Alexander Larsson 2012-10-25 15:51:48 UTC
Comment on attachment 227270 [details] [review]
Add machine local var

Attachment 227270 [details] pushed as 660314e - Add machine local var
Comment 12 Zeeshan Ali 2012-10-25 15:56:37 UTC
Review of attachment 227272 [details] [review]:

ACK
Comment 13 Zeeshan Ali 2012-10-25 16:21:42 UTC
Review of attachment 227271 [details] [review]:

::: src/properties.vala
@@ -259,1 +262,5 @@
 
+        shutdown_button = new Button.with_label (_("Force Shutdown"));
+        shutdown_button.clicked.connect ( () => {
+            var machine = App.app.current_item as LibvirtMachine;
+            if (machine != null)

1.  More verbose and uglier, I agree but more explicit and therefore more readable. No strong feelings though.
Comment 14 Alexander Larsson 2012-10-25 16:33:00 UTC
Attachment 227271 [details] pushed as 91d5763 - Add force shutdown button to properties view
Attachment 227272 [details] pushed as 7b1ef80 - Remove force shutdown from app menu
Comment 15 Marc-Andre Lureau 2012-10-26 10:07:48 UTC
Review of attachment 227272 [details] [review]:

::: src/app.vala
@@ -88,3 @@
-        action_shutdown = new GLib.SimpleAction ("display.shutdown", null);
-        action_shutdown.activate.connect (() => { (current_item as LibvirtMachine).force_shutdown (); });
-        application.add_action (action_shutdown);

we could have left the action though, couldn't we?
Comment 16 Alexander Larsson 2012-10-26 15:07:54 UTC
Review of attachment 227272 [details] [review]:

::: src/app.vala
@@ -88,3 @@
-        action_shutdown = new GLib.SimpleAction ("display.shutdown", null);
-        action_shutdown.activate.connect (() => { (current_item as LibvirtMachine).force_shutdown (); });
-        application.add_action (action_shutdown);

I don't know if that is very useful. Its not accessed from anywhere and you can't really use it from another app as it picks whatever item happens to be current. What do you expect it to be used for?
Comment 17 Marc-Andre Lureau 2012-10-26 16:29:01 UTC
Review of attachment 227272 [details] [review]:

::: src/app.vala
@@ -88,3 @@
-        action_shutdown = new GLib.SimpleAction ("display.shutdown", null);
-        action_shutdown.activate.connect (() => { (current_item as LibvirtMachine).force_shutdown (); });
-        application.add_action (action_shutdown);

I thought it was exposed on the bus, it could be useful for outside extensions & scripts