[vinagre/vala-rewrite: 3/3] Incomplete VinagreWindow port to Vala



commit acee3cb187f10324ee6c5f615bb691e40f588455
Author: David King <amigadave amigadave com>
Date:   Thu Jun 16 22:20:39 2011 +0200

    Incomplete VinagreWindow port to Vala

 vinagre/vinagre-window.vala |  170 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 170 insertions(+), 0 deletions(-)
---
diff --git a/vinagre/vinagre-window.vala b/vinagre/vinagre-window.vala
new file mode 100644
index 0000000..3cfd8d0
--- /dev/null
+++ b/vinagre/vinagre-window.vala
@@ -0,0 +1,170 @@
+/*  Vinagre - GNOME Remote Desktop viewer
+ *
+ *  Copyright (C) 2011  David King <amigadave amigadave com>
+ *
+ *  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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+using Gtk;
+
+// Handles everything related to the toplevel window(s).
+class Vinagre.Window : Gtk.Window {
+    private Vinagre.Notebook notebook;
+    private Gtk.StatusBar statusbar;
+    private Gtk.UIManager ui_manager;
+    private Gtk.Toolbar toolbar;
+    private Gtk.MenuBar menubar;
+
+    private Gtk.ActionGroup always_sensitive_actions;
+    private Gtk.ActionGroup remote_connected_actions;
+    private Gtk.ActionGroup remote_initialized_actions;
+    private Gtk.ActionGroup bookmarks_actions;
+    private Gtk.ActionGroup recent_connections_actions;
+
+    private bool fullscreen;
+    private bool toolbar_visible;
+    private bool statusbar_visible;
+
+    const Gtk.ActionEntry[] always_sensitive_entries = {
+        // Toplevel (menu) actions.
+        {null, "Remote", null, N_("_Remote"), null, null},
+        {null, "Edit", null, N_("_Edit"), null, null},
+        {null, "View", null, N_("_View"), null, null},
+        {null, "Bookmarks", null, N_("_Bookmarks"), null, null},
+        {null, "Help", null, N_("_Help"), null, null},
+
+        // Remote menu.
+        {Command.remote_connect, "RemoteConnect", Gtk.Stock.CONNECT,
+            "<control>N", N_("Connect to a remote desktop")},
+        {Command.remote_open, "RemoteOpen", Gtk.Stock.OPEN, "<control>O",
+            N_("Open a .VNC file")},
+        {Command.remote_vnc_listener, "VNCListener", null,
+            N_("_Reverse Connectionsâ"), null,
+            N_("Configure incoming VNC connections")},
+        {Command.remote_quit, "RemoteQuit", Gtk.Stock.QUIT, "<control>Q",
+            N_("Quit the program")},
+
+        // Edit menu.
+        {Command.edit_preferences, "EditPreferences", Gtk.Stock.PREFERENCES,
+            null, null, N_("Edit the application preferences")},
+
+        // Help menu.
+        {Command.help_contents, "HelpContents", Gtk.Stock.HELP, null, "F1",
+            N_("Open the Vinagre help")},
+        {Command.help_about, "HelpAbout", Gtk.Stock.ABOUT, null, null,
+            N_("About this application")}
+    };
+
+    const Gtk.ActionEntry[] remote_connected_entries = {
+        // Remote menu.
+        {Command.remote_disconnect, "RemoteDisconnect", Gtk.Stock.DISCONNECT,
+            "<control>W", N_("Disconnect the current connection")},
+        {Command.remote_disconnect_all, "RemoteDisconnectAll", null,
+            "<control><shift>W", N_("Disconnect all connections")},
+        
+        // Bookmarks menu.
+        {Command.bookmarks_add, "BookmarksAdd", Gtk.Stock.ADD, "<control>D",
+            N_("Add the current connection to your bookmarks")}
+    };
+
+    const Gtk.ActionEntry[] remote_initialized_entries = {
+        // Remote menu.
+        {Command.remote_take_screenshot, "RemoteTakeScreenshot",
+            "applets-screenshooter", N_("_Take Screenshot"), null,
+            N_("Take a screenshot of the current remote desktop")},
+
+        // View menu.
+        {Command.view_fullscreen, "ViewFullscreen", Gtk.Stock.FULLSCREEN, null,
+            "F11", N_("View the current remote desktop in fullscreen mode")}
+    };
+
+    const Gtk.ToggleActionEntry[] always_sensitive_toggle_entries = {
+        // View menu.
+        {Command.view_show_toolbar, "ViewToolbar", null, N_("_Toolbar"), null,
+            N_("Show or hide the toolbar")},
+        {Command.view_show_statusbar, "ViewStatusbar", null, N_("_Statusbar"),
+            null, N_("Show or hide the statusbar")}
+    };
+
+    public Window () {
+        set_title (GLib.get_application_name ());
+
+        create_menubar_and_toolbar ();
+    }
+
+    private void create_menubar_and_toolbar () {
+        ui_manager = new UIManager ();
+
+        // For showing tooltips in the status bar.
+        ui_manager.connect_proxy.connect (on_ui_manager_connect_proxy);
+        ui_manager.disconnect_proxy.connect (on_ui_manager_disconnect_proxy);
+
+        add_accel_group (ui_manager.accel_group);
+
+        // Actions which are always sensitive.
+        always_sensitive_actions = new Gtk.ActionGroup
+            ("VinagreWindowAlwaysSensitiveActions");
+        always_sensitive_actions.set_translation_domain (null);
+        always_sensitive_actions.add_actions (always_sensitive_entries, this);
+        always_sensitive_actions.add_toggle_actions
+            (always_sensitive_toggle_entries, this);
+        ui_manager.insert_action_group (always_sensitive_actions, 0);
+
+        // Only set the connect action to be important, but 591369.
+        var connect_action = always_sensitive_actions.get_action
+            ("RemoteConnect");
+        connect_action.is_important = true;
+
+        // Actions which are sensitive when connected to a remote.
+        remote_connected_actions = new Gtk.ActionGroup
+            ("VinagreWindowRemoteConnectedActions");
+        remote_connected_actions.set_translation_domain (null);
+        remote_connected_actions.add_actions (remote_connected_entries, this);
+        remote_connected_actions.sensitive = false;
+        ui_manager.insert_action_group (remote_connected_actions, 0);
+
+        // Actions which are sensitive when the remote connection is active.
+        remote_initialized_actions = new GtkActionGroup
+            ("VinagreWindowRemoteInitializedActions");
+        remote_initialized_actions.set_translation_domain (null);
+        remote_initialized_actions.add_actions
+            (remote_initialized_entries, this);
+        remote_initialized_actions.sensitive = false;
+        ui_manager.insert_action_group (remote_initialized_actions, 0);
+
+        // Load the UI definition.
+        try {
+            ui_manager.add_ui_from_file (get_uimanager_filename ());
+        } catch (Error error) {
+            error ("Error while loading UI manager file: %s", error.message);
+        }
+
+        // Bookmarks.
+        bookmarks_actions = new Gtk.ActionGroup ("BookmarksActions");
+        bookmarks_actions.set_translation_domain (null);
+        ui_manager.insert_action_group (bookmarks_actions);
+
+        // Menubar and toolbar.
+        menubar = ui_manager.get_widget ("/Menubar");
+        main_box.pack_start (menubar, false, false, 0);
+
+        toolbar = ui_manager.get_widget ("/Toolbar");
+        Gtk.StyleContext.add_class (toolbar.get_style_context (),
+            Gtk.StyleClass.PRIMARY_TOOLBAR);
+        toolbar.hide ();
+        main_box.pack_start (toolbar, false, false, 0);
+
+        // Recent connections.
+    }
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]