// // OpenVPN Administrator // // Author(s): Everaldo Canuto // // (C) 2006 Everaldo Canuto // (C) 2006 The Gang // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library 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 // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // using System; using Mono.Unix; using Gtk; using Gdk; #if MAEMO using Hildon; #endif namespace OpenVPN.Admin { #if !MAEMO public class Appview : VBox { private Gtk.Toolbar toolbar; private Gtk.MenuShell menu; public Appview(string title) : base() { menu = new MenuBar(); PackStart(menu, false, true, 0); } public Gtk.MenuShell Menu { get { return menu; } } public Gtk.Toolbar Toolbar { get { return toolbar; } set { toolbar = value; PackStart(toolbar, false, true, 0); } } } #endif #if MAEMO public class BaseMainWindow : Hildon.App #else public class BaseMainWindow : Gtk.Window #endif { #if MAEMO public BaseMainWindow() : base() { Appview = new AppView(""); } public new string Title { get { return base.AppTitle; } set { this.AppTitle = value; } } private Gtk.Label statusbar; public string StatusText { get { return statusbar.Text; } set { if (statusbar == null) { statusbar = new Gtk.Label(); statusbar.Xalign = 1; Gtk.ToolItem toolitem = new Gtk.ToolItem(); toolitem.Expand = true; toolitem.Add(statusbar); Toolbar.Add(toolitem); } statusbar.Text = value; } } #else public BaseMainWindow() : base("") { WindowPosition = WindowPosition.Center; DeleteEvent += new DeleteEventHandler(on_window_delete); appview = new Appview(""); Add(appview); } public void on_window_delete(object o, DeleteEventArgs args) { Hide(); args.RetVal = true; } private Appview appview; public Appview Appview { get { return this.appview; } set { this.appview = value; } } private Gtk.Statusbar statusbar; private string statustext; public string StatusText { get { return statustext; } set { if (statusbar == null) { statusbar = new Gtk.Statusbar(); Appview.PackEnd(statusbar, false, true, 0); } statustext = value; statusbar.Pop(0); statusbar.Push(0, statustext); } } #endif public Gtk.MenuShell MainMenu { get { return this.Appview.Menu; } } public Gtk.Toolbar Toolbar { set { this.Appview.Toolbar = value; } get { if (this.Appview.Toolbar == null) this.Appview.Toolbar = new Gtk.Toolbar(); return this.Appview.Toolbar; } } private Gtk.AccelGroup accel_group; protected void ConnectAccelerator(Gtk.Action action, string key) { if (accel_group == null) { accel_group = new Gtk.AccelGroup(); this.AddAccelGroup(accel_group); } string path = "/MainWindow/" + key; AccelMap.AddEntry(path, Gdk.Keyval.FromName(key), Gdk.ModifierType.ControlMask); action.AccelGroup = accel_group; action.AccelPath = path; } } }