[Xfce4-commits] <design:master> Add a spinner to be displayed once the disconnect button is clicked.

Jannis Pohlmann noreply at xfce.org
Tue May 31 01:46:01 CEST 2011


Updating branch refs/heads/master
         to e2857b9b6a06bff09782f34b8c2c9c87b24d5955 (commit)
       from 0f779dca328f61b7301956e744a5edfbf681eb31 (commit)

commit e2857b9b6a06bff09782f34b8c2c9c87b24d5955
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Tue May 31 01:43:53 2011 +0200

    Add a spinner to be displayed once the disconnect button is clicked.

 .../demo-code/custom-view/shortcut-row.vala        |   49 ++++++++++++++++---
 1 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/thunar/shortcuts-pane/demo-code/custom-view/shortcut-row.vala b/thunar/shortcuts-pane/demo-code/custom-view/shortcut-row.vala
index e8f8ef9..4e997f1 100644
--- a/thunar/shortcuts-pane/demo-code/custom-view/shortcut-row.vala
+++ b/thunar/shortcuts-pane/demo-code/custom-view/shortcut-row.vala
@@ -27,6 +27,10 @@ public class ShortcutRow : EventBox {
   public string icon_name { get; set; }
   public bool connected { get; set; }
 
+  private Image disconnect_icon { get; set; }
+  private Button disconnect_button { get; set; }
+  private Spinner connect_spinner { get; set; }
+
   public ShortcutRow (string title, string icon_name, bool connected) {
     this.title = title;
     this.icon_name = icon_name;
@@ -53,16 +57,45 @@ public class ShortcutRow : EventBox {
     box.add (label);
     label.show ();
 
+    disconnect_icon = new Image.from_icon_name ("media-eject", IconSize.MENU);
+    disconnect_icon.set_pixel_size (16);
+
+    disconnect_icon.ref ();
+
+    disconnect_button = new Button ();
+    disconnect_button.set_relief (ReliefStyle.NONE);
+    disconnect_button.set_image (disconnect_icon);
+    disconnect_button.set_no_show_all (true);
+    box.pack_start (disconnect_button, false, true, 0);
+
+    disconnect_button.clicked.connect (connect_device);
+
     if (connected) {
-      var button_icon = new Image.from_icon_name ("media-eject", IconSize.MENU);
-      button_icon.set_pixel_size (16);
-
-      var button = new Button ();
-      button.set_relief (ReliefStyle.NONE);
-      button.set_image (button_icon);
-      box.pack_start (button, false, true, 0);
-      button.show ();
+      disconnect_button.show ();
     }
+
+    connect_spinner = new Spinner ();
+    connect_spinner.set_size_request (16, 16);
+    connect_spinner.stop ();
+    connect_spinner.show ();
+
+    connect_spinner.ref ();
+  }
+
+  public void connect_device () {
+    disconnect_button.set_image (connect_spinner);
+
+    connect_spinner.start ();
+
+    GLib.Timeout.add (1000, stop_spinner);
+  }
+
+  public bool stop_spinner () {
+    connect_spinner.stop ();
+
+    disconnect_button.set_image (disconnect_icon);
+
+    return false;
   }
 
   public override bool expose_event (Gdk.EventExpose event) {



More information about the Xfce4-commits mailing list