private MenuBar CreateShortcutsBar() { // Adds a hidden menubar that contains to enable keyboard // shortcuts to close the log MenuBar menu_bar = new MenuBar (); MenuItem file_item = new MenuItem ("File"); Menu file_menu = new Menu (); MenuItem close_1 = new MenuItem ("Close1"); MenuItem close_2 = new MenuItem ("Close2"); // adds specific Ctrl+W and Esc key accelerators to Log Window AccelGroup accel_group = new AccelGroup (); AddAccelGroup (accel_group); // Close on Esc close_1.AddAccelerator ("activate", accel_group, new AccelKey (Gdk.Key.W, Gdk.ModifierType.ControlMask, AccelFlags.Visible)); close_1.Activated += delegate { HideAll (); }; // Close on Ctrl+W close_2.AddAccelerator ("activate", accel_group, new AccelKey (Gdk.Key.Escape, Gdk.ModifierType.None, AccelFlags.Visible)); close_2.Activated += delegate { HideAll (); }; file_menu.Append (close_1); file_menu.Append (close_2); file_item.Submenu = file_menu; menu_bar.Append (file_item); // Hacky way to hide the menubar, but the accellerators // will simply be disabled when using Hide () menu_bar.HeightRequest = 1; menu_bar.ModifyBg (StateType.Normal, Style.Background (StateType.Normal)); return menu_bar; }
public SparkleLog(string path) : base("") { LocalPath = path; string name = System.IO.Path.GetFileName (LocalPath); SetDefaultSize (480, 640); SetPosition (WindowPosition.Center); BorderWidth = 0; // TRANSLATORS: {0} is a folder name, and {1} is a server address Title = String.Format(_("Recent Events in ‘{0}’"), name); IconName = "folder-sparkleshare"; DeleteEvent += delegate { Close (); }; // Adds a hidden menubar that contains to enable keyboard // shortcuts to close the log MenuBar = new MenuBar (); MenuItem file_item = new MenuItem ("File"); Menu file_menu = new Menu (); MenuItem close_1 = new MenuItem ("Close1"); MenuItem close_2 = new MenuItem ("Close2"); // adds specific Ctrl+W and Esc key accelerators to Log Window AccelGroup accel_group = new AccelGroup (); AddAccelGroup (accel_group); // Close on Esc close_1.AddAccelerator ("activate", accel_group, new AccelKey (Gdk.Key.W, Gdk.ModifierType.ControlMask, AccelFlags.Visible)); close_1.Activated += delegate { Close (); }; // Close on Ctrl+W close_2.AddAccelerator ("activate", accel_group, new AccelKey (Gdk.Key.Escape, Gdk.ModifierType.None, AccelFlags.Visible)); close_2.Activated += delegate { Close (); }; file_menu.Append (close_1); file_menu.Append (close_2); file_item.Submenu = file_menu; MenuBar.Append (file_item); // Hacky way to hide the menubar, but the accellerators // will simply be disabled when using Hide () MenuBar.HeightRequest = 1; MenuBar.ModifyBg (StateType.Normal, Style.Background (StateType.Normal)); LayoutVertical = new VBox (false, 0); LayoutVertical.PackStart (CreateEventLog (), true, true, 0); HButtonBox dialog_buttons = new HButtonBox { Layout = ButtonBoxStyle.Edge, BorderWidth = 12 }; Button open_folder_button = new Button (_("_Open Folder")) { UseUnderline = true }; open_folder_button.Clicked += delegate (object o, EventArgs args) { Process process = new Process (); process.StartInfo.FileName = Defines.OPEN_COMMAND; process.StartInfo.Arguments = LocalPath.Replace (" ", "\\ "); // Escape space-characters process.Start (); Close (); }; Button close_button = new Button (Stock.Close); close_button.Clicked += delegate { Close (); }; dialog_buttons.Add (open_folder_button); dialog_buttons.Add (close_button); LayoutVertical.PackStart (new HSeparator (), false, false, 0); // We have to hide the menubar somewhere... LayoutVertical.PackStart (MenuBar, false, false, 0); LayoutVertical.PackStart (dialog_buttons, false, false, 0); Add (LayoutVertical); }