Both network and standalone use NetworkControlBox object containing vbox with all the UI. The object share self.builder with spokes. We might consider putting NCB into separate module so that it can be imported (and tested or used) without importing the spokes. --- pyanaconda/ui/gui/spokes/network.py | 148 +++++++++++++++++++++++++---------- pyanaconda/ui/gui/spokes/network.ui | 72 +++++++++++++++++- 2 files changed, 178 insertions(+), 42 deletions(-) diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py index d59fc59..ad60d62 100644 --- a/pyanaconda/ui/gui/spokes/network.py +++ b/pyanaconda/ui/gui/spokes/network.py @@ -36,7 +36,7 @@ from gi.repository import Gtk, AnacondaWidgets from pyanaconda.ui.gui import UIObject -from pyanaconda.ui.gui.spokes import NormalSpoke +from pyanaconda.ui.gui.spokes import NormalSpoke, StandaloneSpoke from pyanaconda.ui.gui.categories.software import SoftwareCategory from gi.repository import GLib, GObject, Pango, Gio, NetworkManager, NMClient @@ -215,24 +215,16 @@ class CellRendererSecurity(Gtk.CellRendererPixbuf): self.set_property("icon-name", self.icon_name) - -class NetworkSpoke(NormalSpoke): - builderObjects = ["networkWindow", "liststore_devices", "liststore_wireless_network"] - mainWidgetName = "networkWindow" - uiFile = "spokes/network.ui" - - title = N_("NETWORK CONFIGURATION") - icon = "network-transmit-receive-symbolic" - - category = SoftwareCategory +class NetworkControlBox(): supported_device_types = [ NetworkManager.DeviceType.ETHERNET, NetworkManager.DeviceType.WIFI, ] - def __init__(self, *args, **kwargs): - NormalSpoke.__init__(self, *args, **kwargs) + def __init__(self, builder): + + self.builder = builder # these buttons are only for vpn and proxy self.builder.get_object("add_toolbutton").set_sensitive(False) @@ -296,6 +288,11 @@ class NetworkSpoke(NormalSpoke): self.builder.get_object("button_wireless_options").connect("clicked", self.on_edit_connection) + @property + def vbox(self): + return self.builder.get_object("networkControlBox_vbox") + + def _add_ap_icons(self, combobox): cell = CellRendererSecurity() cell.set_padding(4, 0) @@ -322,16 +319,19 @@ class NetworkSpoke(NormalSpoke): col.set_expand(True) treeview.append_column(col) - def apply(self): - pass + def populate(self): + for device in self.client.get_devices(): + self.add_device(device) - @property - def completed(self): - return self.status != _("Not connected") + treeview = self.builder.get_object("treeview_devices") + devices_store = self.builder.get_object("liststore_devices") + selection = treeview.get_selection() + selection.select_iter(devices_store.get_iter_first()) + + def setup(self): + self.refresh_ui() - @property def status(self): - """ A short string describing which devices are connected. """ active_wired_devs = [] active_wireless_devs = [] @@ -360,25 +360,8 @@ class NetworkSpoke(NormalSpoke): else: msg = _("Not connected") - # active connections? - return msg - def populate(self): - NormalSpoke.populate(self) - - for device in self.client.get_devices(): - self.add_device(device) - - treeview = self.builder.get_object("treeview_devices") - devices_store = self.builder.get_object("liststore_devices") - selection = treeview.get_selection() - selection.select_iter(devices_store.get_iter_first()) - - def setup(self): - NormalSpoke.setup(self) - self.refresh_ui() - # Signal handlers. def on_device_selection_changed(self, *args): print "DBG: on_device_selection_changed" @@ -479,10 +462,6 @@ class NetworkSpoke(NormalSpoke): elif dev_type == NetworkManager.DeviceType.WIFI: self.client.wireless_set_enabled(active) - def on_back_clicked(self, window): - self.window.hide() - Gtk.main_quit() - def selected_device(self): selection = self.builder.get_object("treeview_devices").get_selection() (model, iter) = selection.get_selected() @@ -915,3 +894,90 @@ class NetworkSpoke(NormalSpoke): return sec_str +class NetworkSpoke(NormalSpoke): + builderObjects = ["networkWindow", "liststore_wireless_network", "liststore_devices"] + mainWidgetName = "networkWindow" + uiFile = "spokes/network.ui" + + title = N_("NETWORK CONFIGURATION") + icon = "network-transmit-receive-symbolic" + + category = SoftwareCategory + + def __init__(self, *args, **kwargs): + NormalSpoke.__init__(self, *args, **kwargs) + self.network_control_box = NetworkControlBox(self.builder) + + def apply(self): + pass + + @property + def completed(self): + return self.status != _("Not connected") + + @property + def status(self): + """ A short string describing which devices are connected. """ + return self.network_control_box.status() + + def populate(self): + NormalSpoke.populate(self) + self.network_control_box.populate() + + def setup(self): + NormalSpoke.setup(self) + self.network_control_box.setup() + + def on_back_clicked(self, window): + self.window.hide() + Gtk.main_quit() + + +class NetworkStandaloneSpoke(StandaloneSpoke): + builderObjects = ["networkStandaloneWindow", "networkControlBox_vbox", "liststore_wireless_network", "liststore_devices"] + mainWidgetName = "networkStandaloneWindow" + uiFile = "spokes/network.ui" + + + def __init__(self, *args, **kwargs): + StandaloneSpoke.__init__(self, *args, **kwargs) + self.network_control_box = NetworkControlBox(self.builder) + parent = self.builder.get_object("AnacondaStandaloneWindow-action_area5") + parent.add(self.network_control_box.vbox) + + def apply(self): + pass + + def populate(self): + StandaloneSpoke.populate(self) + self.network_control_box.populate() + + def setup(self): + StandaloneSpoke.setup(self) + self.network_control_box.setup() + + def on_back_clicked(self, window): + self.window.hide() + Gtk.main_quit() + + +if __name__ == "__main__": + + win = Gtk.Window() + win.connect("delete-event", Gtk.main_quit) + + builder = Gtk.Builder() + import os + ui_file_path = os.environ.get('UIPATH')+'spokes/network.ui' + builder.add_from_file(ui_file_path) + + n = NetworkControlBox(builder) + n.populate() + n.setup() + + n.vbox.reparent(win) + + win.show_all() + Gtk.main() + + diff --git a/pyanaconda/ui/gui/spokes/network.ui b/pyanaconda/ui/gui/spokes/network.ui index a677186..4e9d300 100644 --- a/pyanaconda/ui/gui/spokes/network.ui +++ b/pyanaconda/ui/gui/spokes/network.ui @@ -30,6 +30,76 @@ <column type="guint"/> </columns> </object> + <object class="AnacondaStandaloneWindow" id="networkStandaloneWindow"> + <property name="startup_id">filler</property> + <property name="can_focus">False</property> + <property name="startup_id">filler</property> + <property name="window_name">NETWORK CONFIGURATION</property> + <signal name="quit-clicked" handler="on_back_clicked" swapped="no"/> + <child internal-child="main_box"> + <object class="GtkBox" id="AnacondaStandaloneWindow-main_box5"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child internal-child="nav_area"> + <object class="GtkGrid" id="AnacondaStandaloneWindow-nav_area5"> + <property name="can_focus">False</property> + <property name="margin_left">6</property> + <property name="margin_right">6</property> + <property name="margin_top">6</property> + <property name="n_rows">2</property> + <property name="n_columns">2</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child internal-child="alignment"> + <object class="GtkAlignment" id="AnacondaStandaloneWindow-alignment5"> + <property name="can_focus">False</property> + <property name="yalign">0</property> + <property name="xscale">0</property> + <property name="yscale">0.5</property> + <child internal-child="action_area"> + <object class="GtkBox" id="AnacondaStandaloneWindow-action_area5"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel" id="networkNeedLabel1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">We'll need network access to fetch information about your location and to make software updates available for you</property> + <attributes> + <attribute name="font-desc" value="Sans 14"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> <object class="AnacondaSpokeWindow" id="networkWindow"> <property name="startup_id">filler</property> <property name="can_focus">False</property> @@ -64,7 +134,7 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <child> - <object class="GtkVBox" id="vbox1"> + <object class="GtkVBox" id="networkControlBox_vbox"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">10</property> -- 1.7.7.5 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list