FINALLY implement UWT-based user interface for the BookmarksManager
This commit is contained in:
parent
f2b5dd57be
commit
2d01be239c
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkDialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Manage Bookmarks</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="label">gtk-save</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="tv">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="model">tm</property>
|
||||
<property name="search_column">0</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="tvcBookmarkTitle">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Title</property>
|
||||
<property name="clickable">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<property name="sort_column_id">0</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="tvcBookmarkPath">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Location</property>
|
||||
<property name="clickable">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<property name="sort_column_id">1</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkTreeStore" id="tm">
|
||||
<columns>
|
||||
<!-- column-name colBookmarkTitle -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name colBookmarkPath -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
</interface>
|
||||
@ -722,6 +722,7 @@
|
||||
<Content Include="Extensions\GameDeveloper\Extensions\SEGA\Associations\SegaA3DA.uexml" />
|
||||
<Content Include="Editors\PropertyList\PropertyListEditor.glade" />
|
||||
<Content Include="Editors\FileSystem\FileSystemEditor.glade" />
|
||||
<Content Include="Dialogs\ManageBookmarksDialog.glade" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Configuration\Application.upl" />
|
||||
|
||||
@ -0,0 +1,106 @@
|
||||
//
|
||||
// ManageBookmarksDialog.cs - provides a UWT ContainerLayout-based CustomDialog for managing bookmarks in Universal Editor
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2020 Mike Becker's Software
|
||||
//
|
||||
// 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 System;
|
||||
using MBS.Framework.UserInterface;
|
||||
using MBS.Framework.UserInterface.Controls;
|
||||
using MBS.Framework.UserInterface.Dialogs;
|
||||
using MBS.Framework.UserInterface.Input.Keyboard;
|
||||
|
||||
namespace UniversalEditor.UserInterface.Dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a UWT ContainerLayout-based <see cref="CustomDialog" /> for managing bookmarks in Universal Editor.
|
||||
/// </summary>
|
||||
[ContainerLayout("~/Dialogs/ManageBookmarksDialog.glade")]
|
||||
public class ManageBookmarksDialog : CustomDialog
|
||||
{
|
||||
private ListView tv;
|
||||
private DefaultTreeModel tm;
|
||||
|
||||
private System.Collections.Specialized.StringCollection _FileNames = new System.Collections.Specialized.StringCollection();
|
||||
|
||||
protected override void OnCreated(EventArgs e)
|
||||
{
|
||||
base.OnCreated(e);
|
||||
|
||||
tv.KeyDown += tv_KeyDown;
|
||||
tv.RowActivated += tv_RowActivated;
|
||||
|
||||
for (int i = 0; i < Engine.CurrentEngine.BookmarksManager.FileNames.Count; i++)
|
||||
{
|
||||
_FileNames.Add(Engine.CurrentEngine.BookmarksManager.FileNames[i]);
|
||||
|
||||
string filepath = Engine.CurrentEngine.BookmarksManager.FileNames[i];
|
||||
string filetitle = System.IO.Path.GetFileName(filepath);
|
||||
|
||||
tm.Rows.Add(new TreeModelRow(new TreeModelRowColumn[]
|
||||
{
|
||||
new TreeModelRowColumn(tm.Columns[0], filetitle),
|
||||
new TreeModelRowColumn(tm.Columns[1], filepath)
|
||||
}));
|
||||
tm.Rows[tm.Rows.Count - 1].SetExtraData<int>("index", i);
|
||||
}
|
||||
|
||||
Buttons[0].Click += cmdOK_Click;
|
||||
DefaultButton = Buttons[0];
|
||||
}
|
||||
|
||||
void cmdOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
Engine.CurrentEngine.BookmarksManager.FileNames.Clear();
|
||||
for (int i = 0; i < _FileNames.Count; i++)
|
||||
{
|
||||
Engine.CurrentEngine.BookmarksManager.FileNames.Add(_FileNames[i]);
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
||||
void tv_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case KeyboardKey.Delete:
|
||||
{
|
||||
int index = tv.SelectedRows[0].GetExtraData<int>("index");
|
||||
string filetitle = System.IO.Path.GetFileName(_FileNames[index]);
|
||||
|
||||
if (MessageDialog.ShowDialog(String.Format("Remove '{0}' from the list of bookmarks?", filetitle), "Remove Bookmark", MessageDialogButtons.YesNo, MessageDialogIcon.Warning) == DialogResult.No)
|
||||
return;
|
||||
|
||||
_FileNames.RemoveAt(index);
|
||||
tm.Rows.Remove(tv.SelectedRows[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tv_RowActivated(object sender, ListViewRowActivatedEventArgs e)
|
||||
{
|
||||
int index = e.Row.GetExtraData<int>("index");
|
||||
|
||||
Engine.CurrentEngine.LastWindow.OpenFile(Engine.CurrentEngine.BookmarksManager.FileNames[index]);
|
||||
Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -347,8 +347,27 @@ namespace UniversalEditor.UserInterface
|
||||
return new Engine[] { _TheEngine };
|
||||
}
|
||||
|
||||
private void Bookmarks_Bookmark_Click(object sender, EventArgs e)
|
||||
{
|
||||
Command cmd = (Command)sender;
|
||||
int i = Int32.Parse(cmd.ID.Substring("Bookmarks_Bookmark".Length));
|
||||
LastWindow.OpenFile(BookmarksManager.FileNames[i]);
|
||||
}
|
||||
|
||||
private void AfterInitialization()
|
||||
{
|
||||
if (Engine.CurrentEngine.BookmarksManager.FileNames.Count > 0)
|
||||
{
|
||||
Application.Commands["Bookmarks"].Items.Add(new SeparatorCommandItem());
|
||||
for (int i = 0; i < Engine.CurrentEngine.BookmarksManager.FileNames.Count; i++)
|
||||
{
|
||||
Application.Commands.Add(new Command(String.Format("Bookmarks_Bookmark{0}", i.ToString()), System.IO.Path.GetFileName(Engine.CurrentEngine.BookmarksManager.FileNames[i]).Replace("_", "__")));
|
||||
Application.Commands["Bookmarks"].Items.Add(new CommandReferenceCommandItem(String.Format("Bookmarks_Bookmark{0}", i.ToString())));
|
||||
|
||||
Application.AttachCommandEventHandler(String.Format("Bookmarks_Bookmark{0}", i.ToString()), Bookmarks_Bookmark_Click);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize all the commands that are common to UniversalEditor
|
||||
#region File
|
||||
Application.AttachCommandEventHandler("FileNewDocument", delegate(object sender, EventArgs e)
|
||||
@ -516,6 +535,63 @@ namespace UniversalEditor.UserInterface
|
||||
Application.Commands["ViewStatusBar"].Checked = HostApplication.CurrentWindow.StatusBar.Visible;
|
||||
});
|
||||
|
||||
#endregion
|
||||
#region Bookmarks
|
||||
Application.AttachCommandEventHandler("BookmarksAdd", delegate (object sender, EventArgs e)
|
||||
{
|
||||
Editor ed = LastWindow.GetCurrentEditor();
|
||||
if (ed == null) return;
|
||||
|
||||
// FIXME: BookmarksAdd copypasta
|
||||
string filename = ed.ObjectModel.Accessor.GetFileName();
|
||||
BookmarksManager.FileNames.Add(filename);
|
||||
|
||||
Command cmdBookmarks = Application.Commands["Bookmarks"];
|
||||
if (cmdBookmarks.Items.Count == 4)
|
||||
{
|
||||
cmdBookmarks.Items.Add(new SeparatorCommandItem());
|
||||
}
|
||||
|
||||
Application.Commands.Add(new Command(String.Format("Bookmarks_Bookmark{0}", (BookmarksManager.FileNames.Count - 1).ToString()), System.IO.Path.GetFileName(Engine.CurrentEngine.BookmarksManager.FileNames[(BookmarksManager.FileNames.Count - 1)])));
|
||||
Application.Commands["Bookmarks"].Items.Add(new CommandReferenceCommandItem(String.Format("Bookmarks_Bookmark{0}", (BookmarksManager.FileNames.Count - 1).ToString())));
|
||||
|
||||
Application.AttachCommandEventHandler(String.Format("Bookmarks_Bookmark{0}", (BookmarksManager.FileNames.Count - 1).ToString()), Bookmarks_Bookmark_Click);
|
||||
});
|
||||
Application.AttachCommandEventHandler("BookmarksAddAll", delegate (object sender, EventArgs e)
|
||||
{
|
||||
Page[] pages = CurrentEngine.LastWindow.GetPages();
|
||||
for (int i = 0; i < pages.Length; i++)
|
||||
{
|
||||
if (pages[i] is Pages.EditorPage)
|
||||
{
|
||||
Pages.EditorPage ep = (pages[i] as Pages.EditorPage);
|
||||
Editor ed = (ep.Controls[0] as Editor);
|
||||
|
||||
// FIXME: BookmarksAdd copypasta
|
||||
string filename = ed.ObjectModel.Accessor.GetFileName();
|
||||
BookmarksManager.FileNames.Add(filename);
|
||||
|
||||
Command cmdBookmarks = Application.Commands["Bookmarks"];
|
||||
if (cmdBookmarks.Items.Count == 4)
|
||||
{
|
||||
cmdBookmarks.Items.Add(new SeparatorCommandItem());
|
||||
}
|
||||
|
||||
Application.Commands.Add(new Command(String.Format("Bookmarks_Bookmark{0}", (BookmarksManager.FileNames.Count - 1).ToString()), System.IO.Path.GetFileName(Engine.CurrentEngine.BookmarksManager.FileNames[(BookmarksManager.FileNames.Count - 1)])));
|
||||
Application.Commands["Bookmarks"].Items.Add(new CommandReferenceCommandItem(String.Format("Bookmarks_Bookmark{0}", (BookmarksManager.FileNames.Count - 1).ToString())));
|
||||
|
||||
Application.AttachCommandEventHandler(String.Format("Bookmarks_Bookmark{0}", (BookmarksManager.FileNames.Count - 1).ToString()), Bookmarks_Bookmark_Click);
|
||||
}
|
||||
}
|
||||
});
|
||||
Application.AttachCommandEventHandler("BookmarksManage", delegate (object sender, EventArgs e)
|
||||
{
|
||||
ManageBookmarksDialog dlg = new ManageBookmarksDialog();
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// saving the BookmarksManager state is handled by the ManageBookmarksDialog
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
#region Tools
|
||||
// ToolsOptions should actually be under the Edit menu as "Preferences" on Linux systems
|
||||
|
||||
@ -129,6 +129,7 @@
|
||||
<Compile Include="View.cs" />
|
||||
<Compile Include="Panels\DocumentExplorerPanel.cs" />
|
||||
<Compile Include="Editors\FileSystem\FileSystemEditorDocumentPropertiesSettingsProvider.cs" />
|
||||
<Compile Include="Dialogs\ManageBookmarksDialog.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user