diff options
author | Thierry Vignaud <thierry.vignaud@gmail.com> | 2013-11-07 16:57:13 +0100 |
---|---|---|
committer | Thierry Vignaud <thierry.vignaud@gmail.com> | 2013-11-24 11:00:40 +0100 |
commit | 4a4453328a1a2051307f44e6c1c200625666ba16 (patch) | |
tree | 9fb9eb5089abd561cf1c857e448e3c63fcc4465e /bin/net_applet | |
parent | 7bf101337af175668274aaae14b6320a5224f480 (diff) | |
download | drakx-net-4a4453328a1a2051307f44e6c1c200625666ba16.tar drakx-net-4a4453328a1a2051307f44e6c1c200625666ba16.tar.gz drakx-net-4a4453328a1a2051307f44e6c1c200625666ba16.tar.bz2 drakx-net-4a4453328a1a2051307f44e6c1c200625666ba16.tar.xz drakx-net-4a4453328a1a2051307f44e6c1c200625666ba16.zip |
switch from gtk2 to gtk3
Diffstat (limited to 'bin/net_applet')
-rwxr-xr-x | bin/net_applet | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/bin/net_applet b/bin/net_applet index 146b5b9..d9c502f 100755 --- a/bin/net_applet +++ b/bin/net_applet @@ -16,14 +16,14 @@ use network::connection::ethernet; use network::vpn; use run_program; use do_pkgs; -use mygtk2 qw(gtknew gtkset); +use mygtk3 qw(gtknew gtkset); use dbus_object; use network::monitor; use network::signal_strength; use detect_devices; -use Gtk2::Notify -init, 'NetApplet'; +use Gtk3::Notify -init, 'NetApplet'; -use ugtk2 qw(:create :helpers :wrappers :dialogs); +use ugtk3 qw(:create :helpers :wrappers :dialogs); my $onstartupfile = "$ENV{HOME}/.net_applet"; my $system_file = '/etc/sysconfig/drakx-net'; @@ -34,7 +34,7 @@ is_running('net_applet') and die "net_applet already running\n"; package network::net_applet; -use mygtk2 qw(gtknew gtkset); +use mygtk3 qw(gtknew gtkset); use common; our ($current_state, $current_interface); @@ -220,7 +220,7 @@ my %actions = ( ); -$icon = Gtk2::StatusIcon->new; +$icon = Gtk3::StatusIcon->new; eval { $dbus = dbus_object::system_bus() } if !defined($global_settings{NET_APPLET_DBUS}) || text2bool($global_settings{NET_APPLET_DBUS}); eval { $net->{monitor} = network::monitor->new($dbus) } if $dbus; @@ -240,10 +240,10 @@ if ($dbus) { } }); $dbus->{connection}->add_match("type='signal',interface='org.mageia.network'"); - dbus_object::set_gtk2_watch_helper($dbus); + dbus_object::set_gtk3_watch_helper($dbus); } -$notification_queue = Gtk2::Notify::Queue->new($icon); +$notification_queue = Gtk3::Notify::Queue->new($icon); $icon->signal_connect(activate => sub { my ($_icon, $button, $time) = @_; @@ -284,9 +284,9 @@ sub harvester { } while $pid > 0; } -Gtk2->main; +Gtk3->main; -ugtk2::exit(0); +ugtk3::exit(0); sub is_running { my ($name, $o_user) = @_; @@ -340,12 +340,12 @@ sub run_drakids() { sub generate_wireless_menuitem { my ($wnet) = @_; my $menuitem = {}; - $menuitem->{widget} = Gtk2::CheckMenuItem->new; + $menuitem->{widget} = Gtk3::CheckMenuItem->new; $menuitem->{widget}->set_draw_as_radio(1); $menuitem->{widget}->add(gtkpack_(gtkshow(gtknew('HBox')), 1, gtkset_alignment($menuitem->{label} = gtknew('Label'), 0, 0.5), - 0, $menuitem->{strength} = Gtk2::Image->new, - 0, $menuitem->{security} = Gtk2::Image->new, + 0, $menuitem->{strength} = Gtk3::Image->new, + 0, $menuitem->{security} = Gtk3::Image->new, )); $menuitem->{activate} = $menuitem->{widget}->signal_connect('activate' => sub { if ($net->{monitor} && exists $wnet->{id}) { @@ -466,7 +466,7 @@ sub create_menu_choices { my $choice = $_; my $label = $format ? $format->($choice) : $choice; my $w = gtkshow(gtkset_active(gtkadd( - Gtk2::CheckMenuItem->new, + Gtk3::CheckMenuItem->new, gtknew('HBox', children => [ 1, gtkset_alignment(gtknew('Label', text => $label), 0, 0.5), $get_icon ? @@ -488,12 +488,12 @@ sub create_action_item { gtkshow(create_menu($name, $actions{$action}{header} ? ( create_action_item($actions{$action}{header}), - gtkshow(Gtk2::SeparatorMenuItem->new), + gtkshow(Gtk3::SeparatorMenuItem->new), ) : (), @menu, )); } else { - gtksignal_connect(gtkshow(Gtk2::MenuItem->new_with_label($name)), activate => sub { $actions{$action}{launch}->($current_interface) }); + gtksignal_connect(gtkshow(Gtk3::MenuItem->new_with_label($name)), activate => sub { $actions{$action}{launch}->($current_interface) }); } } @@ -501,7 +501,7 @@ sub empty_menu { my ($menu) = @_; delete $_->{menuitems} foreach values %wireless_networks; $menu->destroy if $menu; - Gtk2::Menu->new; + Gtk3::Menu->new; } sub get_wireless_networks_sorted() { @@ -519,7 +519,7 @@ sub generate_simple_menu() { gtkappend($simple_menu, (map { generate_wireless_menuitem($_) } @valuable_networks), (@networks ? create_menu(N("More networks"), map { generate_wireless_menuitem($_) } @networks) : ()), - Gtk2::SeparatorMenuItem->new, + Gtk3::SeparatorMenuItem->new, ); } gtkappend($simple_menu, create_menu_choices('setInterface', 'allow_single_choice')); @@ -545,25 +545,25 @@ sub generate_menu() { push @settings, create_action_item('chooseProfile'); if (defined $interactive) { - $interactive_cb = gtkshow(gtksignal_connect(gtkset_active(Gtk2::CheckMenuItem->new_with_label(N("Interactive Firewall automatic mode")), + $interactive_cb = gtkshow(gtksignal_connect(gtkset_active(Gtk3::CheckMenuItem->new_with_label(N("Interactive Firewall automatic mode")), !$interactive), toggled => sub { eval { $ifw->set_interactive(to_bool(!$_[0]->get_active)) } })); push @settings, $interactive_cb; } - push @settings, gtkshow(gtksignal_connect(gtkset_active(Gtk2::CheckMenuItem->new_with_label(N("Always launch on startup")), getAutoStart()), + push @settings, gtkshow(gtksignal_connect(gtkset_active(Gtk3::CheckMenuItem->new_with_label(N("Always launch on startup")), getAutoStart()), toggled => sub { setAutoStart(uc(bool2text($_[0]->get_active))) })); - $menu->append(gtkshow(Gtk2::SeparatorMenuItem->new)); + $menu->append(gtkshow(Gtk3::SeparatorMenuItem->new)); if ($current_state ne 'unconfigured' && $wireless_device) { $menu->append(gtkshow(create_menu(N("Wireless networks"), create_action_item('wireless'), - gtkshow(Gtk2::SeparatorMenuItem->new), + gtkshow(Gtk3::SeparatorMenuItem->new), map { generate_wireless_menuitem($_) } get_wireless_networks_sorted()))); } if (my $vpn = create_action_item('chooseVPN')) { $menu->append($vpn) } if (my $set = $current_state ne 'unconfigured' && create_action_item('setInterface')) { $menu->append($set) } $menu->append(gtkshow(create_menu(N("Settings"), @settings))); - $menu->append(gtkshow(Gtk2::SeparatorMenuItem->new)); + $menu->append(gtkshow(Gtk3::SeparatorMenuItem->new)); $menu->append(create_action_item('help')); $menu->append(create_action_item('quit')); $menu; @@ -571,7 +571,7 @@ sub generate_menu() { sub mainQuit() { Glib::Source->remove($timeout) if $timeout; Glib::Source->remove($update_timeout) if $update_timeout; - Gtk2->main_quit; + Gtk3->main_quit; } sub getAutoStart() { my %p = getVarsFromSh($onstartupfile); |