[f-spot] move SidebarPageNode and SidebarPage to the Extensions ns
- From: Stephane Delcroix <sdelcroix src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [f-spot] move SidebarPageNode and SidebarPage to the Extensions ns
- Date: Wed, 6 Jan 2010 10:50:39 +0000 (UTC)
commit 5db46c17ac4cb60b2554f6fbc3602cee6cb44811
Author: Stephane Delcroix <stephane delcroix org>
Date: Wed Jan 6 11:50:14 2010 +0100
move SidebarPageNode and SidebarPage to the Extensions ns
src/Extensions/ServiceNode.cs | 2 +-
src/Extensions/SidebarPage.cs | 78 +++++++++++++++++++++++++++++++++++++
src/Extensions/SidebarPageNode.cs | 27 +++++++++++++
src/FSpot.addin.xml | 2 +-
src/MainWindow.cs | 2 +-
src/Makefile.am | 2 +
src/SingleView.cs | 2 +-
src/Widgets/EditorPage.cs | 11 +++--
src/Widgets/FolderTreePage.cs | 1 +
src/Widgets/MetadataDisplay.cs | 10 +++--
src/Widgets/Sidebar.cs | 69 +-------------------------------
11 files changed, 126 insertions(+), 80 deletions(-)
---
diff --git a/src/Extensions/ServiceNode.cs b/src/Extensions/ServiceNode.cs
index ab79432..32e8952 100644
--- a/src/Extensions/ServiceNode.cs
+++ b/src/Extensions/ServiceNode.cs
@@ -1,5 +1,5 @@
/*
- * FSpot.Extensions.ServiceNodea.cs
+ * FSpot.Extensions.ServiceNode.cs
*
* Author(s):
* Stephane Delcroix <stephane delcroix org>
diff --git a/src/Extensions/SidebarPage.cs b/src/Extensions/SidebarPage.cs
new file mode 100644
index 0000000..a8eecdb
--- /dev/null
+++ b/src/Extensions/SidebarPage.cs
@@ -0,0 +1,78 @@
+/*
+ * Widgets.SidebarPage.cs
+ *
+ * Author(s)
+ * Mike Gemuende <mike gemuende de>
+ * Stephane Delcroix <stephane delcroix org>
+ * Ruben Vermeersch <ruben savanne be>
+ *
+ * This is free software. See COPYING for details.
+ */
+
+using FSpot.Extensions;
+using FSpot.Utils;
+using Gtk;
+using Mono.Addins;
+using Mono.Unix;
+using System;
+using System.Collections.Generic;
+
+namespace FSpot.Extensions
+{
+ public class SidebarPage {
+ // The widget shown on the sidebar page.
+ private readonly Widget widget;
+ public Widget SidebarWidget {
+ get { return widget; }
+ }
+
+ // Whether this page can be selected
+ private bool can_select;
+ public bool CanSelect {
+ protected set {
+ can_select = value;
+ if (CanSelectChanged != null)
+ CanSelectChanged (this, null);
+ }
+ get { return can_select; }
+ }
+
+ public event EventHandler CanSelectChanged;
+
+ // The label of the sidebar page.
+ private readonly string label;
+ public string Label {
+ get { return label; }
+ }
+
+ // The icon name, used for the selector
+ private readonly string icon_name;
+ public string IconName {
+ get { return icon_name; }
+ }
+
+ // The sidebar onto which this page is attached
+ private Gtk.Widget sidebar;
+ public Gtk.Widget Sidebar {
+ get { return sidebar; }
+ set {
+ sidebar = value;
+ AddedToSidebar ();
+ }
+ }
+
+ // Can be overriden to get notified as soon as we're added to a sidebar.
+ protected virtual void AddedToSidebar () { }
+
+// // Whether this page is currently visible
+// public bool IsActive {
+// get { return Sidebar.IsActive (this); }
+// }
+
+ public SidebarPage (Widget widget, string label, string icon_name) {
+ this.widget = widget;
+ this.label = label;
+ this.icon_name = icon_name;
+ }
+ }
+}
diff --git a/src/Extensions/SidebarPageNode.cs b/src/Extensions/SidebarPageNode.cs
new file mode 100644
index 0000000..21f044f
--- /dev/null
+++ b/src/Extensions/SidebarPageNode.cs
@@ -0,0 +1,27 @@
+/*
+ * FSpot.Extensions.ServiceNode.cs
+ *
+ * Author(s):
+ * Ruben Vermeersch <ruben savanne be>
+ * Stephane Delcroix <stephane delcroix org>
+ *
+ * Copyright (c) 2010 Stephane Delcroix <stephane delcroix org>
+ *
+ * This is free software. See COPYING for details.
+ *
+ */
+
+using System;
+using Mono.Addins;
+
+namespace FSpot.Extensions
+{
+ public class SidebarPageNode : ExtensionNode {
+ [NodeAttribute (Required=true)]
+ protected string sidebar_page_type;
+
+ public SidebarPage GetPage () {
+ return (SidebarPage) Addin.CreateInstance (sidebar_page_type);
+ }
+ }
+}
diff --git a/src/FSpot.addin.xml b/src/FSpot.addin.xml
index e54e6b3..ea7e04d 100644
--- a/src/FSpot.addin.xml
+++ b/src/FSpot.addin.xml
@@ -18,7 +18,7 @@
</ExtensionPoint>
<ExtensionPoint path = "/FSpot/Sidebar">
- <ExtensionNode type="FSpot.Widgets.SidebarPageNode"/>
+ <ExtensionNode name="SidebarPage" type="FSpot.Extensions.SidebarPageNode"/>
</ExtensionPoint>
<ExtensionPoint path = "/FSpot/Services">
diff --git a/src/MainWindow.cs b/src/MainWindow.cs
index d2a4bc8..69cbfae 100644
--- a/src/MainWindow.cs
+++ b/src/MainWindow.cs
@@ -568,7 +568,7 @@ namespace FSpot
private void OnSidebarExtensionChanged (object s, ExtensionNodeEventArgs args) {
// FIXME: No sidebar page removal yet!
if (args.Change == ExtensionChange.Add)
- Sidebar.AppendPage ((args.ExtensionNode as SidebarPageNode).GetSidebarPage ());
+ Sidebar.AppendPage ((args.ExtensionNode as SidebarPageNode).GetPage ());
}
private Photo CurrentPhoto {
diff --git a/src/Makefile.am b/src/Makefile.am
index a6ac4d7..8d7eb29 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -159,6 +159,8 @@ F_SPOT_CSDISTFILES = \
$(srcdir)/Extensions/PhotoSelectionCondition.cs \
$(srcdir)/Extensions/PopupCommands.cs \
$(srcdir)/Extensions/ServiceNode.cs \
+ $(srcdir)/Extensions/SidebarPage.cs \
+ $(srcdir)/Extensions/SidebarPageNode.cs \
$(srcdir)/Extensions/TransitionNode.cs \
$(srcdir)/Extensions/ViewModeCondition.cs \
$(srcdir)/Fader.cs \
diff --git a/src/SingleView.cs b/src/SingleView.cs
index 70d1c60..6cf74e1 100644
--- a/src/SingleView.cs
+++ b/src/SingleView.cs
@@ -177,7 +177,7 @@ namespace FSpot {
private void OnSidebarExtensionChanged (object s, ExtensionNodeEventArgs args) {
// FIXME: No sidebar page removal yet!
if (args.Change == ExtensionChange.Add)
- sidebar.AppendPage ((args.ExtensionNode as SidebarPageNode).GetSidebarPage ());
+ sidebar.AppendPage ((args.ExtensionNode as SidebarPageNode).GetPage ());
}
void HandleExportActivated (object o, EventArgs e)
diff --git a/src/Widgets/EditorPage.cs b/src/Widgets/EditorPage.cs
index 09589b3..bb4664a 100644
--- a/src/Widgets/EditorPage.cs
+++ b/src/Widgets/EditorPage.cs
@@ -8,6 +8,7 @@
*/
using FSpot;
+using FSpot.Extensions;
using FSpot.Editors;
using FSpot.UI.Dialog;
using FSpot.Utils;
@@ -35,13 +36,13 @@ namespace FSpot.Widgets {
}
protected override void AddedToSidebar () {
- Sidebar.SelectionChanged += delegate (IBrowsableCollection collection) { EditorPageWidget.ShowTools (); };
- Sidebar.ContextChanged += HandleContextChanged;
+ (Sidebar as Sidebar).SelectionChanged += delegate (IBrowsableCollection collection) { EditorPageWidget.ShowTools (); };
+ (Sidebar as Sidebar).ContextChanged += HandleContextChanged;
}
private void HandleContextChanged (object sender, EventArgs args)
{
- InPhotoView = (Sidebar.Context == ViewContext.Edit);
+ InPhotoView = ((Sidebar as Sidebar).Context == ViewContext.Edit);
EditorPageWidget.ChangeButtonVisibility ();
}
}
@@ -180,9 +181,9 @@ namespace FSpot.Widgets {
state.Selection = Gdk.Rectangle.Zero;
state.PhotoImageView = null;
}
- if (Page.Sidebar.Selection == null)
+ if ((Page.Sidebar as Sidebar).Selection == null)
return false;
- state.Items = Page.Sidebar.Selection.Items;
+ state.Items = (Page.Sidebar as Sidebar).Selection.Items;
editor.Initialize (state);
return true;
diff --git a/src/Widgets/FolderTreePage.cs b/src/Widgets/FolderTreePage.cs
index f99faa8..6221794 100644
--- a/src/Widgets/FolderTreePage.cs
+++ b/src/Widgets/FolderTreePage.cs
@@ -10,6 +10,7 @@
using System;
using Gtk;
using Mono.Unix;
+using FSpot.Extensions;
namespace FSpot.Widgets
{
diff --git a/src/Widgets/MetadataDisplay.cs b/src/Widgets/MetadataDisplay.cs
index ce2fabf..cb7cc5f 100644
--- a/src/Widgets/MetadataDisplay.cs
+++ b/src/Widgets/MetadataDisplay.cs
@@ -17,6 +17,8 @@ using Gtk;
using Mono.Unix;
+using FSpot.Extensions;
+
namespace FSpot.Widgets {
public class MetadataDisplayPage : SidebarPage {
public MetadataDisplayPage() : base(new MetadataDisplayWidget(),
@@ -28,8 +30,8 @@ namespace FSpot.Widgets {
protected override void AddedToSidebar ()
{
MetadataDisplayWidget widget = SidebarWidget as MetadataDisplayWidget;
- Sidebar.SelectionChanged += widget.HandleSelectionChanged;
- Sidebar.SelectionItemsChanged += widget.HandleSelectionItemsChanged;
+ (Sidebar as Sidebar).SelectionChanged += widget.HandleSelectionChanged;
+ (Sidebar as Sidebar).SelectionItemsChanged += widget.HandleSelectionItemsChanged;
}
}
@@ -135,7 +137,7 @@ namespace FSpot.Widgets {
exif_info = null;
}
- if (!Page.IsActive) {
+ if (!((Page.Sidebar as Sidebar).IsActive (Page))) {
up_to_date = false;
} else {
update_delay.Start ();
@@ -162,7 +164,7 @@ namespace FSpot.Widgets {
if (!args.Changes.MetadataChanged)
return;
- if (!Page.IsActive)
+ if (!((Page.Sidebar as Sidebar).IsActive (Page)))
up_to_date = false;
else
update_delay.Start ();
diff --git a/src/Widgets/Sidebar.cs b/src/Widgets/Sidebar.cs
index 2eafd34..75b9ddc 100644
--- a/src/Widgets/Sidebar.cs
+++ b/src/Widgets/Sidebar.cs
@@ -17,16 +17,8 @@ using Mono.Unix;
using System;
using System.Collections.Generic;
-namespace FSpot.Widgets {
- [ExtensionNode ("SidebarPage")]
- public class SidebarPageNode : ExtensionNode {
- [NodeAttribute (Required=true)]
- protected string sidebar_page_type;
-
- public SidebarPage GetSidebarPage () {
- return (SidebarPage) Addin.CreateInstance (sidebar_page_type);
- }
- }
+namespace FSpot.Widgets
+{
// Decides which sidebar page should be shown for each context. Implemented
// using the Strategy pattern, to make it swappable easily, in case the
@@ -65,63 +57,6 @@ namespace FSpot.Widgets {
}
}
- public class SidebarPage {
- // The widget shown on the sidebar page.
- private readonly Widget widget;
- public Widget SidebarWidget {
- get { return widget; }
- }
-
- // Whether this page can be selected
- private bool can_select;
- public bool CanSelect {
- protected set {
- can_select = value;
- if (CanSelectChanged != null)
- CanSelectChanged (this, null);
- }
- get { return can_select; }
- }
-
- public event EventHandler CanSelectChanged;
-
- // The label of the sidebar page.
- private readonly string label;
- public string Label {
- get { return label; }
- }
-
- // The icon name, used for the selector
- private readonly string icon_name;
- public string IconName {
- get { return icon_name; }
- }
-
- // The sidebar onto which this page is attached
- private Sidebar sidebar;
- public Sidebar Sidebar {
- get { return sidebar; }
- set {
- sidebar = value;
- AddedToSidebar ();
- }
- }
-
- // Can be overriden to get notified as soon as we're added to a sidebar.
- protected virtual void AddedToSidebar () { }
-
- // Whether this page is currently visible
- public bool IsActive {
- get { return Sidebar.IsActive (this); }
- }
-
- public SidebarPage (Widget widget, string label, string icon_name) {
- this.widget = widget;
- this.label = label;
- this.icon_name = icon_name;
- }
- }
-
public class Sidebar : VBox {
private HBox button_box;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]