Commit 56f87054 authored by Florent Viard's avatar Florent Viard Committed by John (J5) Palmieri

Add a reconnect button to the main panel that will allow to close and...

Add a reconnect button to the main panel that will allow to close and reconnect the dbus connection for the current tab if this tab address is not either Session Bus or System Bus.
parent 81cff9ce
......@@ -23,6 +23,7 @@ class DFeetApp:
signal_dict = {'add_session_bus': self.add_session_bus_cb,
'add_system_bus': self.add_system_bus_cb,
'add_bus_address': self.add_bus_address_cb,
'reconnect_current_bus': self.reconnect_current_bus_cb,
'execute_method': self.execute_current_method_cb,
'quit': self.quit_cb}
......@@ -40,6 +41,9 @@ class DFeetApp:
self.notebook.show_all()
self.execute_method_action = ui.get_widget('execute_method')
self.reconnect_current_bus_action = ui.get_widget('reconnect_current_bus')
self.notebook.connect('switch-page', self.switch_tab_cb)
self.main_window.set_default_size(int(settings.general['windowwidth']),
int(settings.general['windowheight']))
......@@ -67,7 +71,7 @@ class DFeetApp:
if bus_add != '':
self.add_bus_history.append(bus_add)
def _add_bus_tab(self, bus_watch):
def _add_bus_tab(self, bus_watch, position=None):
name = bus_watch.get_bus_name()
bus_paned = _ui.BusBox(bus_watch)
bus_paned.connect('introspectnode-selected',
......@@ -85,9 +89,14 @@ class DFeetApp:
hbox.pack_start(close_btn, False, False)
hbox.show_all()
p = self.notebook.append_page(bus_paned, hbox)
self.notebook.set_current_page(p)
self.notebook.set_tab_reorderable(bus_paned, True)
if position:
self.notebook.insert_page(bus_paned, hbox, position)
self.notebook.set_current_page(position)
self.notebook.set_tab_reorderable(bus_paned, True)
else:
p = self.notebook.append_page(bus_paned, hbox)
self.notebook.set_current_page(p)
self.notebook.set_tab_reorderable(bus_paned, True)
def introspect_node_selected_cb(self, widget, node):
if isinstance(node, introspect_data.Method):
......@@ -109,6 +118,15 @@ class DFeetApp:
if child.get_bus_watch().get_bus_name() not in [u'Session Bus', u'System Bus']:
child.get_bus_watch().close_bus()
self.notebook.remove_page(n)
if self.notebook.get_n_pages() <= 0:
self.reconnect_current_bus_action.set_sensitive(False)
def switch_tab_cb(self, notebook, page, page_num):
child = self.notebook.get_nth_page(page_num)
if child.get_bus_watch().get_bus_name() not in [u'Session Bus', u'System Bus']:
self.reconnect_current_bus_action.set_sensitive(True)
else:
self.reconnect_current_bus_action.set_sensitive(False)
def select_or_add_bus(self, address):
for i in range(self.notebook.get_n_pages()):
......@@ -163,6 +181,26 @@ class DFeetApp:
dialog.destroy()
def reconnect_current_bus_cb(self, action):
page = self.notebook.get_current_page()
if page >= 0:
child = self.notebook.get_nth_page(page)
bus_watch = child.get_bus_watch()
bus_type = bus_watch.get_bus_type()
bus_address = bus_watch.get_bus_address()
if bus_type == dbus_introspector.SESSION_BUS or bus_type == dbus_introspector.SYSTEM_BUS:
pass
else:
bus_watch.close_bus()
self.notebook.remove_page(page)
try:
new_bus_watch = BusWatch(None, address=bus_address)
self._add_bus_tab(new_bus_watch, page)
except Exception, e:
print e
def quit_cb(self, action):
self._quit_dfeet(self.main_window, None)
......
......@@ -265,6 +265,15 @@ class BusWatch(gtk.GenericTreeModel):
else:
return self.address
def get_bus_type(self):
return self.bus_type
def get_bus_address(self):
return self.address
def close_bus(self):
self.bus.close()
def close_bus(self):
self.bus.close()
......
......@@ -19,6 +19,17 @@
<signal handler="add_bus_address" name="activate"/>
</object>
</child>
<child>
<object class="GtkAction" id="reconnect_current_bus">
<property name="name">reconnect_current_bus</property>
<property name="label" translatable="yes">Reconnect current Bus...</property>
<property name="short_label" translatable="yes">Reconnect</property>
<property name="tooltip" translatable="yes">Reconnect the bus of the current tab address</property>
<property name="sensitive">False</property>
<property name="stock_id">gtk-refresh</property>
<signal handler="reconnect_current_bus" name="activate"/>
</object>
</child>
<child>
<object class="GtkAction" id="add_session_bus">
<property name="name">add_session_bus</property>
......@@ -79,6 +90,7 @@
</menu>
-->
</toolitem>
<toolitem name="ConnReconnect" action="reconnect_current_bus"/>
<separator/>
<toolitem name="ExecuteMethod" action="execute_method"/>
</toolbar>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment