[d-feet/pygi] Fix Spinner handling



commit ea26b156e77a06f1d13d0251b6b682e27359d7ea
Author: Thomas Bechtold <thomasbechtold jpberlin de>
Date:   Tue Oct 9 17:44:33 2012 +0200

    Fix Spinner handling

 dfeet/introspection.py |   18 +++++++-----------
 ui/introspection.ui    |   36 ++++++++++++++++++++++++++++--------
 2 files changed, 35 insertions(+), 19 deletions(-)
---
diff --git a/dfeet/introspection.py b/dfeet/introspection.py
index 68135bc..74acfdc 100644
--- a/dfeet/introspection.py
+++ b/dfeet/introspection.py
@@ -34,7 +34,7 @@ class AddressInfo():
 
         #setup UI
         ui = UILoader(UILoader.UI_INTROSPECTION)
-        self.introspect_box = ui.get_root_widget() #this is the main box with the treeview (or the spinner during the introspection)
+        self.introspect_box = ui.get_root_widget() #this is the main box with the treeview
         self.__spinner = ui.get_widget('spinner') #the spinner is used to show progress during the introspection
         self.__scrolledwindow = ui.get_widget('scrolledwindow') #the scrolledwindow contains the treeview
         self.__treemodel = ui.get_widget('treestore')
@@ -120,10 +120,6 @@ class AddressInfo():
 
     def introspect_start(self):
         """ introspect the given bus name and update the tree model """
-        #remove scrolledwindow and add the spinner
-        self.introspect_box.remove(self.__scrolledwindow)
-        self.__spinner.start()
-        self.introspect_box.pack_end(self.__spinner, True, False, 0)
         #cleanup current tree model
         self.__treemodel.clear()
         #start introspection
@@ -142,8 +138,6 @@ class AddressInfo():
         except Exception, e:
             #got an exception (eg dbus timeout). show the exception
             print "Exception: '%s'" % (str(e))
-            self.__spinner.stop()
-            self.introspect_box.remove(self.__spinner)
             self.__messagedialog.set_title("DBus Exception")
             self.__messagedialog.set_property("text", "%s : %s" % (self.name, str(e)))
             self.__messagedialog.run()
@@ -197,6 +191,8 @@ class AddressInfo():
                     self.__dbus_node_introspect(object_path_new)
             else:
                 #no nodes left. we finished the introspection
+                self.__spinner.stop()
+                self.__spinner.set_visible(False)
                 #update name, unique name, ...
                 self.__label_name.set_text(self.name)
                 try:
@@ -204,10 +200,6 @@ class AddressInfo():
                 except:
                     pass
 
-                #remove the spinner and add the scrolledwindow (with the treeview)
-                self.introspect_box.remove(self.__spinner)
-                self.__spinner.stop()
-                self.introspect_box.pack_end(self.__scrolledwindow, True, True, 0)
                 self.introspect_box.show_all()
                 #TODO: remove this and add a button to expand the whole tree!?
                 self.__treeview.expand_all()
@@ -215,6 +207,10 @@ class AddressInfo():
 
     def __dbus_node_introspect(self, object_path):
         """ Introspect the given object path. This function will be called recursive """
+        #start spinner
+        self.__spinner.start()
+        self.__spinner.set_visible(True)
+        #start async dbus call
         self.connection.call(self.name, object_path, 'org.freedesktop.DBus.Introspectable', 'Introspect',
                              None, GLib.VariantType.new("(s)"), Gio.DBusCallFlags.NONE, -1,
                              None, self.__dbus_node_introspect_cb, object_path)
diff --git a/ui/introspection.ui b/ui/introspection.ui
index 73a94d6..450e04c 100644
--- a/ui/introspection.ui
+++ b/ui/introspection.ui
@@ -107,6 +107,21 @@
           </packing>
         </child>
         <child>
+          <object class="GtkSpinner" id="spinner">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="no_show_all">True</property>
+            <property name="tooltip_text" translatable="yes">Introspecting...</property>
+            <property name="margin_left">5</property>
+            <property name="margin_right">5</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
           <object class="GtkButton" id="button_reload">
             <property name="label">gtk-refresh</property>
             <property name="visible">True</property>
@@ -118,7 +133,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">1</property>
+            <property name="position">2</property>
           </packing>
         </child>
       </object>
@@ -162,7 +177,7 @@
         </child>
       </object>
       <packing>
-        <property name="expand">False</property>
+        <property name="expand">True</property>
         <property name="fill">True</property>
         <property name="position">1</property>
       </packing>
@@ -181,15 +196,20 @@
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="messagedialog-action_area2">
+            <property name="can_focus">False</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
       </object>
     </child>
   </object>
-  <object class="GtkSpinner" id="spinner">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="has_tooltip">True</property>
-    <property name="tooltip_text" translatable="yes">Introspecting...</property>
-  </object>
   <object class="GtkTreeStore" id="treestore">
     <columns>
       <!-- column-name gchararray1 -->



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]