/* * app_wifi - zavai Wifi ui functions * * Copyright (C) 2010 Enrico Zini * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ using GLib; namespace zavai { namespace ui { namespace wifi { public class WifiIcon : Gtk.StatusIcon { bool requested = false; public WifiIcon() { activate += on_activate; update_icon(); } private void on_activate() { requested = !requested; update_icon(); if (requested) { //zavai.wifi.wifi.start(); stderr.printf("wifi should be started here\n"); stderr.printf("wifi status: %d\n", (int) zavai.wifi.wifi.started); } else { //zavai.wifi.wifi.stop(); stderr.printf("wifi should be stopped here\n"); stderr.printf("wifi status: %d\n", (int) zavai.wifi.wifi.started); } } protected void update_icon() { string name = zavai.config.icondir + "/"; name += (active() ? "wifi_1.png" : "wifi_0.png"); stderr.printf("load icon from %s\n", name); set_from_file(name); } private bool active() { return zavai.wifi.wifi.started; } } WifiIcon icon; public void init() { // Menus zavai.menu_misc.add_service_toggle(zavai.wifi.wifi, "Start Wifi", "Stop Wifi"); // Icon icon = new WifiIcon(); icon.set_visible(true); } } } }