[pdfmod] Allow deselecting bookmarks, and selecting multiple
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pdfmod] Allow deselecting bookmarks, and selecting multiple
- Date: Wed, 8 Sep 2010 21:51:54 +0000 (UTC)
commit 95f01da30a89e2fcbe79515c06c04ba60ae6c744
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue Sep 7 17:02:47 2010 -0500
Allow deselecting bookmarks, and selecting multiple
src/PdfMod/Gui/BookmarkView.cs | 31 ++++++++++++++++++++++++-------
src/PdfMod/Gui/Client.cs | 3 ++-
2 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/src/PdfMod/Gui/BookmarkView.cs b/src/PdfMod/Gui/BookmarkView.cs
index f9d20e7..f7c64e8 100644
--- a/src/PdfMod/Gui/BookmarkView.cs
+++ b/src/PdfMod/Gui/BookmarkView.cs
@@ -118,12 +118,26 @@ namespace PdfMod.Gui
}
}
+ private class BookmarkTreeView : TreeView
+ {
+ protected override bool OnButtonPressEvent (Gdk.EventButton press)
+ {
+ TreePath path;
+ if (!GetPathAtPos ((int)press.X, (int)press.Y, out path)) {
+ Selection.UnselectAll ();
+ return true;
+ } else {
+ return base.OnButtonPressEvent (press);
+ }
+ }
+ }
+
private void BuildTreeView ()
{
// outline, expanded/opened, title, page # destination, tooltip
model = new TreeStore (typeof(PdfSharp.Pdf.PdfOutline), typeof(bool), typeof(string), typeof(int), typeof(string));
- tree_view = new TreeView () {
+ tree_view = new BookmarkTreeView () {
Model = model,
SearchColumn = (int)ModelColumns.Title,
TooltipColumn = (int)ModelColumns.Tooltip,
@@ -133,7 +147,7 @@ namespace PdfMod.Gui
Reorderable = false,
ShowExpanders = true
};
- tree_view.Selection.Mode = SelectionMode.Browse;
+ tree_view.Selection.Mode = SelectionMode.Multiple;
var title = new CellRendererText () {
Editable = true,
@@ -182,9 +196,9 @@ namespace PdfMod.Gui
var sw = new Gtk.ScrolledWindow () {
HscrollbarPolicy = PolicyType.Never,
- VscrollbarPolicy = PolicyType.Automatic,
- Child = tree_view
+ VscrollbarPolicy = PolicyType.Automatic
};
+ sw.AddWithViewport (tree_view);
PackStart (sw, true, true, 0);
}
@@ -221,15 +235,18 @@ namespace PdfMod.Gui
var remove_button = new Button (Gtk.Stock.Remove);
remove_button.Clicked += (o, a) => {
- TreeIter iter;
- if (tree_view.Selection.GetSelected (out iter)) {
+ foreach (var path in tree_view.Selection.GetSelectedRows ()) {
+ TreeIter iter;
+ model.GetIter (out iter, path);
var outline = GetOutline (iter);
Hyena.Log.DebugFormat ("Removing bookmark '{0}'", outline.Title);
outline.Remove ();
model.Remove (ref iter);
- MarkModified ();
}
+ MarkModified ();
};
+ tree_view.Selection.Changed += (o, a) => remove_button.Sensitive = tree_view.Selection.CountSelectedRows () > 0;
+ remove_button.Sensitive = tree_view.Selection.CountSelectedRows () > 0;
box.PackStart (add_button, false, false, 0);
box.PackStart (remove_button, false, false, 0);
diff --git a/src/PdfMod/Gui/Client.cs b/src/PdfMod/Gui/Client.cs
index 8eba73c..fdd2021 100644
--- a/src/PdfMod/Gui/Client.cs
+++ b/src/PdfMod/Gui/Client.cs
@@ -92,7 +92,8 @@ namespace PdfMod.Gui
// PDF Icon View
IconView = new DocumentIconView (this);
- var iconview_sw = new Gtk.ScrolledWindow () { Child = IconView };
+ var iconview_sw = new Gtk.ScrolledWindow ();
+ iconview_sw.AddWithViewport (IconView);
query_box = new QueryBox (this) { NoShowAll = true };
query_box.Hide ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]