private void HandleOpenAction() { CustomFileChooserDialog dlg = new CustomFileChooserDialog(this, "Open pack", FileChooserAction.Open); dlg.FileChooser.SelectMultiple = false; Packer.SupportedExtensions.ToList().ForEach(ext => { using (Gtk.FileFilter filter = new Gtk.FileFilter()) { filter.Name = ext.ToUpper(); filter.AddPattern("*." + ext); dlg.FileChooser.AddFilter(filter); } }); dlg.Ok += (sender, e) => { if (fileSystem != null) { fileSystem.Close(); } fileSystem = null; OpenPack(dlg.FileChooser.Filename); dlg.Destroy(); }; dlg.Cancel += (sender, e) => dlg.Destroy(); dlg.Show(); }
private void InitActions() { // show about AboutAction.Activated += (sender, e) => new AboutWindow(this, About.Authors, About.Lines, About.Size).Show(); // show supported extensions SupportedFormatsAction.Activated += (sender, e) => new SupportedFormatsWindow(this).Show(); // create new pack MenuItem newMenuItem = this.UIManager.GetWidget(@"/mainMenuBar/FileAction/NewAction") as MenuItem; Menu newSubMenu = new Menu(); newMenuItem.Submenu = newSubMenu; Packer.SupportedExtensions.ToList().ForEach(ext => { Gtk.Action action = new Gtk.Action(String.Format("New{0}Action", ext), ext); action.Activated += (sender, e) => { if (fileSystem != null) { fileSystem.Close(); } fileSystem = null; if (Packer.Create(ext, out fileSystem)) { fileSystem.New(); ChangePackActionSensitive(true); } }; MenuItem menuItem = action.CreateMenuItem() as MenuItem; menuItem.AddAccelerator( "activate", this.UIManager.AccelGroup, new AccelKey((Gdk.Key)Gdk.Key.Parse(typeof(Gdk.Key), ext[0].ToString().ToLower()), Gdk.ModifierType.ControlMask, AccelFlags.Visible)); newSubMenu.Append(menuItem); }); // open pack action OpenAction.Activated += (sender, e) => HandleOpenAction(); // save current pack SaveAction.Activated += (sender, e) => HandleSaveAction(); // close pack and exit CloseAction.Activated += (sender, e) => { if (fileSystem != null) { fileSystem.Close(); } fileSystem = null; ChangePackActionSensitive(false); currentFolder = TreeIter.Zero; folderStore.Clear(); packStore.Clear(); }; // exit app ExitAction.Activated += (sender, e) => Program.Stop(); // add files to current pack AddFilesAction.Activated += (sender, e) => HandleAddFilesAction(); // add folder to current pack AddFolderAction.Activated += (sender, e) => HandleAddFolderAction(); // remove items from current pack RemoveAction.Activated += (sender, e) => HandleRemoveAction(); // extract items from current pack ExtractAction.Activated += (sender, e) => HandleExtractAction(); // extract all items from current pack ExtractAllAction.Activated += (sender, e) => HandleExtractAllAction(); }
private void InitActions() { // show about AboutAction.Activated += (sender, e) => new AboutWindow(this, About.Authors, About.Lines, About.Size).Show(); // show supported extensions SupportedFormatsAction.Activated += (sender, e) => new SupportedFormatsWindow(this).Show(); // create new pack MenuItem newMenuItem = this.UIManager.GetWidget(@"/mainMenuBar/FileAction/NewAction") as MenuItem; Menu newSubMenu = new Menu(); newMenuItem.Submenu = newSubMenu; Packer.SupportedExtensions.ToList().ForEach(ext => { Gtk.Action action = new Gtk.Action(String.Format("New{0}Action", ext), ext); action.Activated+= (sender, e) => { if (fileSystem != null) fileSystem.Close(); fileSystem = null; if (Packer.Create(ext, out fileSystem)) { fileSystem.New(); ChangePackActionSensitive(true); } }; MenuItem menuItem = action.CreateMenuItem() as MenuItem; menuItem.AddAccelerator( "activate", this.UIManager.AccelGroup, new AccelKey((Gdk.Key) Gdk.Key.Parse(typeof(Gdk.Key), ext[0].ToString().ToLower()), Gdk.ModifierType.ControlMask, AccelFlags.Visible)); newSubMenu.Append(menuItem); }); // open pack action OpenAction.Activated += (sender, e) => HandleOpenAction(); // save current pack SaveAction.Activated += (sender, e) => HandleSaveAction(); // close pack and exit CloseAction.Activated += (sender, e) => { if (fileSystem != null) fileSystem.Close(); fileSystem = null; ChangePackActionSensitive(false); currentFolder = TreeIter.Zero; folderStore.Clear(); packStore.Clear(); }; // exit app ExitAction.Activated += (sender, e) => Program.Stop(); // add files to current pack AddFilesAction.Activated += (sender, e) => HandleAddFilesAction(); // add folder to current pack AddFolderAction.Activated += (sender, e) => HandleAddFolderAction(); // remove items from current pack RemoveAction.Activated += (sender, e) => HandleRemoveAction(); // extract items from current pack ExtractAction.Activated += (sender, e) => HandleExtractAction(); // extract all items from current pack ExtractAllAction.Activated += (sender, e) => HandleExtractAllAction(); }
private void HandleOpenAction() { CustomFileChooserDialog dlg = new CustomFileChooserDialog(this, "Open pack", FileChooserAction.Open); dlg.FileChooser.SelectMultiple = false; Packer.SupportedExtensions.ToList().ForEach(ext => { using (Gtk.FileFilter filter = new Gtk.FileFilter()) { filter.Name = ext.ToUpper(); filter.AddPattern("*." + ext); dlg.FileChooser.AddFilter(filter); } }); dlg.Ok += (sender, e) => { if (fileSystem != null) fileSystem.Close(); fileSystem = null; OpenPack(dlg.FileChooser.Filename); dlg.Destroy(); }; dlg.Cancel += (sender, e) => dlg.Destroy(); dlg.Show(); }