diff options
-rwxr-xr-x | bin/draknetcenter | 8 | ||||
-rwxr-xr-x | lib/network/drakroam.pm | 42 | ||||
-rwxr-xr-x | lib/network/netcenter.pm | 17 |
3 files changed, 38 insertions, 29 deletions
diff --git a/bin/draknetcenter b/bin/draknetcenter index fcd04e2..738e61e 100755 --- a/bin/draknetcenter +++ b/bin/draknetcenter @@ -10,5 +10,11 @@ use lib qw(/usr/lib/libDrakX); BEGIN { unshift @::textdomains, 'drakx-net' } use standalone; +use network::network; use network::netcenter; -network::netcenter::main(); + +my $in = 'interactive'->vnew; +my $net = {}; +network::network::read_net_conf($net); + +network::netcenter::main($in, $net); diff --git a/lib/network/drakroam.pm b/lib/network/drakroam.pm index 6346caa..7da17c7 100755 --- a/lib/network/drakroam.pm +++ b/lib/network/drakroam.pm @@ -257,9 +257,8 @@ sub toggle_connection { update_on_network_change($droam); } -sub build_pixbufs { - my ($droam) = @_; - $droam->{gui}{pixbufs} = { +sub get_pixbufs() { + { state => { map { $_ => gtkcreate_pixbuf($_) } qw(connected disconnected refresh) }, link_level => { map { $_ => gtkcreate_pixbuf('wifi-' . sprintf('%03d', $_) . '.png')->scale_simple(24, 24, 'hyper'); @@ -270,7 +269,12 @@ sub build_pixbufs { }; } -sub build_network_frame { +sub create_drakroam { + my ($in, $net, $w, $pixbufs) = @_; + { in => $in, net => $net, gui => { w => $w }, pixbufs => $pixbufs }; +} + +sub create_networks_list { my ($droam) = @_; $droam->{gui}{networks_list} = Gtk2::SimpleList->new( @@ -296,8 +300,8 @@ sub build_network_frame { $droam->{gui}{networks_list}->set_has_tooltip(1); } -sub build_drakroam_gui { - my ($droam, $dbus) = @_; +sub create_drakroam_gui { + my ($droam, $dbus, $title, $icon) = @_; $droam->{gui}{model} = Gtk2::ListStore->new('Gtk2::Gdk::Pixbuf', 'Glib::String'); $droam->{gui}{connections_combo} = Gtk2::ComboBox->new($droam->{gui}{model}); @@ -312,8 +316,6 @@ sub build_drakroam_gui { $droam->{gui}{empty_pixbuf} = Gtk2::Gdk::Pixbuf->new('rgb', 1, 8, $droam->{gui}{pixbuf_size}, $droam->{gui}{pixbuf_size}); $droam->{gui}{empty_pixbuf}->fill(0); - build_network_frame($droam); - my $status_bar = Gtk2::Statusbar->new; my $status_bar_cid = $status_bar->get_context_id("Network event"); if ($dbus) { @@ -330,16 +332,6 @@ sub build_drakroam_gui { dbus_object::set_gtk2_watch_helper($dbus); } - build_pixbufs($droam); - - my $title = N("Wireless connection"); - my $icon = '/usr/share/mcc/themes/default/drakroam-mdk.png'; - - $ugtk2::wm_icon = $icon; - $droam->{gui}{w} = ugtk2->new($title); - #- so that transient_for is defined, for wait messages and popups to be centered - $::main_window = $droam->{gui}{w}{real_window}; - gtkadd($droam->{gui}{w}{window}, gtknew('VBox', spacing => 5, children => [ $::isEmbedded ? () : (0, Gtk2::Banner->new($icon, $title)), @@ -360,8 +352,18 @@ sub build_drakroam_gui { sub main { my ($in, $net, $dbus, $o_interface, $o_ap) = @_; - my $droam = { in => $in, net => $net }; - build_drakroam_gui($droam, $dbus); + my $title = N("Wireless connection"); + my $icon = '/usr/share/mcc/themes/default/drakroam-mdk.png'; + + $ugtk2::wm_icon = $icon; + my $w = ugtk2->new($title); + #- so that transient_for is defined, for wait messages and popups to be centered + $::main_window = $w->{real_window}; + + my $pixbufs = get_pixbufs(); + my $droam = create_drakroam($in, $net, $w, $pixbufs); + create_networks_list($droam); + create_drakroam_gui($droam, $dbus, $title, $icon); my @connection_types = qw(network::connection::wireless network::connection::cellular_card); @{$droam->{all_connections}} = map { $_->get_connections(automatic_only => 1) } @connection_types; diff --git a/lib/network/netcenter.pm b/lib/network/netcenter.pm index 9c3d3e6..1804851 100755 --- a/lib/network/netcenter.pm +++ b/lib/network/netcenter.pm @@ -31,11 +31,11 @@ sub filter_networks { } sub build_networks_list { - my ($connection, $net) = @_; + my ($in, $net, $w, $pixbufs, $connection) = @_; - my $droam = { connection => $connection, net => $net }; - network::drakroam::build_pixbufs($droam); - network::drakroam::build_network_frame($droam); + my $droam = network::drakroam::create_drakroam($in, $net, $w, $pixbufs); + network::drakroam::create_networks_list($droam); + $droam->{connection} = $connection; $droam->{filter_networks} = sub { filter_networks($connection) }; network::drakroam::update_networks($droam); @@ -51,7 +51,9 @@ sub gtkset_image { $w; } -sub main() { +sub main { + my ($in, $net) = @_; + my $title = N("Network Center"); my $icon = '/usr/share/mcc/themes/default/drakroam-mdk.png'; @@ -63,8 +65,7 @@ sub main() { my @connections = map { $_->get_connections(automatic_only => 1) } network::connection::get_types; @connections = reverse(uniq_ { $_->{device} } reverse(@connections)); - my $net = {}; - network::network::read_net_conf($net); + my $pixbufs = network::drakroam::get_pixbufs(); gtkadd($w->{window}, gtknew('VBox', spacing => 5, children => [ @@ -78,7 +79,7 @@ sub main() { gtknew('HBox', children_tight => [ gtknew('Label', padding => [ 5, 0 ]), gtknew('VBox', children_tight => [ - ($_->can('get_networks') && !$_->network_scan_is_slow ? build_networks_list($_, $net) : ()), + ($_->can('get_networks') && !$_->network_scan_is_slow ? build_networks_list($in, $net, $w, $pixbufs, $_) : ()), gtknew('HBox', children_tight => [ gtknew('VBox', children_tight => [ gtknew('HButtonBox', children_tight => [ |