[banshee] [Banshee.Moblin] Adapt the Nereid UI to Moblin
- From: Aaron Bockover <abock src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee] [Banshee.Moblin] Adapt the Nereid UI to Moblin
- Date: Thu, 15 Oct 2009 08:34:42 +0000 (UTC)
commit e36cd426ece6bac6e2bcdf1284899358ddf68a68
Author: Aaron Bockover <abockover novell com>
Date: Thu Oct 15 04:39:27 2009 -0400
[Banshee.Moblin] Adapt the Nereid UI to Moblin
Implemented a number of ugly hacks to force-adapt parts
of the Nereid UI to the Moblin look and feel.
.../Banshee.Moblin/Banshee.Moblin/MoblinService.cs | 106 +++++++++++++++++---
.../Banshee.Moblin/Banshee.Moblin/SearchHeader.cs | 2 +-
2 files changed, 94 insertions(+), 14 deletions(-)
---
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/MoblinService.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/MoblinService.cs
index cf869ac..37b652d 100644
--- a/src/Extensions/Banshee.Moblin/Banshee.Moblin/MoblinService.cs
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/MoblinService.cs
@@ -27,6 +27,7 @@
//
using System;
+using Gtk;
using Hyena;
@@ -83,25 +84,104 @@ namespace Banshee.Moblin
private void Initialize ()
{
- Application.ShutdownRequested += () => {
+ ReflectionHackeryUpTheNereid ();
+
+ if (MoblinPanel.Instance == null) {
+ return;
+ }
+
+ var container = MoblinPanel.Instance.ParentContainer;
+ foreach (var child in container.Children) {
+ container.Remove (child);
+ }
+ container.Add (new MediaPanelContents ());
+ container.ShowAll ();
+
+ if (MoblinPanel.Instance.ToolbarPanel != null) {
+ container.SetSizeRequest (
+ (int)MoblinPanel.Instance.ToolbarPanelWidth,
+ (int)MoblinPanel.Instance.ToolbarPanelHeight);
+ }
+
+ // Since the Panel is running, we don't actually ever want to quit!
+ Banshee.ServiceStack.Application.ShutdownRequested += () => {
elements_service.PrimaryWindow.Hide ();
return false;
};
-
+ }
+
+ private void ReflectionHackeryUpTheNereid ()
+ {
+ // This is a horribly abusive method, but hey, this kind
+ // of stuff is what Firefox extensions are made of!
+
+ // First grab the type and instance of the primary window
+ // and make sure we're only hacking the Nereid UI
+ var pwin = elements_service.PrimaryWindow;
+ var pwin_type = pwin.GetType ();
+ if (pwin_type.FullName != "Nereid.PlayerInterface") {
+ return;
+ }
+
+ // regular metacity does not seem to like this at all, crashing
+ // and complaining "Window manager warning: Buggy client sent a
+ // _NET_ACTIVE_WINDOW message with a timestamp of 0 for 0x2e00020"
if (MoblinPanel.Instance != null) {
- var container = MoblinPanel.Instance.ParentContainer;
- foreach (var child in container.Children) {
- container.Remove (child);
- }
- container.Add (new MediaPanelContents ());
- container.ShowAll ();
-
- if (MoblinPanel.Instance.ToolbarPanel != null) {
- container.SetSizeRequest (
- (int)MoblinPanel.Instance.ToolbarPanelWidth,
- (int)MoblinPanel.Instance.ToolbarPanelHeight);
+ pwin.Decorated = false;
+ pwin.Maximize ();
+ }
+
+ // Now we want to make the Toolbar work in the Moblin GTK theme
+ var pwin_toolbar = (Toolbar)pwin_type.GetProperty ("HeaderToolbar").GetValue (pwin, null);
+ var pwin_toolbar_align = (Alignment)pwin_toolbar.Parent;
+ pwin_toolbar_align.TopPadding = 0;
+ pwin_toolbar_align.BottomPadding = 6;
+ pwin_type.GetMethod ("DisableHeaderToolbarExposeEvent").Invoke (pwin, null);
+
+ // Remove the volume button since Moblin enforces the global volume
+ foreach (var child in pwin_toolbar.Children) {
+ if (child.GetType ().FullName.StartsWith ("Banshee.Widgets.GenericToolItem")) {
+ var c = child as Container;
+ if (c != null && c.Children[0] is Banshee.Gui.Widgets.ConnectedVolumeButton) {
+ pwin_toolbar.Remove (child);
+ break;
+ }
}
}
+
+ // Incredibly ugly hack to pack in a close button in a separate
+ // toolbar so that it may be aligned at the top right of the
+ // window (appears to float in the menubar)
+ var pwin_header_table = (Table)pwin_type.GetProperty ("HeaderTable").GetValue (pwin, null);
+
+ var close_button = new Banshee.Widgets.HoverImageButton (IconSize.Menu, "window-close") { DrawFocus = false };
+ close_button.Image.Xpad = 1;
+ close_button.Image.Ypad = 1;
+ close_button.Clicked += (o, e) => Banshee.ServiceStack.Application.Shutdown ();
+
+ var close_toolbar = new Toolbar () {
+ ShowArrow = false,
+ ToolbarStyle = ToolbarStyle.Icons
+ };
+
+ close_toolbar.Add (close_button);
+ close_toolbar.ShowAll ();
+
+ pwin_header_table.Attach (close_toolbar, 1, 2, 0, 1,
+ AttachOptions.Shrink, AttachOptions.Fill | AttachOptions.Expand, 0, 0);
+
+ // Set the internal engine volume to 100%
+ // FIXME: We should have something like PlayerEngine.InternalVolumeEnabled = false
+ ServiceManager.PlayerEngine.Volume = 100;
+ }
+
+ public void PresentPrimaryInterface ()
+ {
+ elements_service.PrimaryWindow.Maximize ();
+ elements_service.PrimaryWindow.Present ();
+ if (MoblinPanel.Instance != null && MoblinPanel.Instance.ToolbarPanel != null) {
+ MoblinPanel.Instance.ToolbarPanel.RequestHide ();
+ }
}
public void Dispose ()
diff --git a/src/Extensions/Banshee.Moblin/Banshee.Moblin/SearchHeader.cs b/src/Extensions/Banshee.Moblin/Banshee.Moblin/SearchHeader.cs
index 12e3af7..8760d79 100644
--- a/src/Extensions/Banshee.Moblin/Banshee.Moblin/SearchHeader.cs
+++ b/src/Extensions/Banshee.Moblin/Banshee.Moblin/SearchHeader.cs
@@ -52,8 +52,8 @@ namespace Banshee.Moblin
source.FilterType = (TrackFilterType)search.Entry.ActiveFilterID;
source.FilterQuery = search.Entry.Query;
ServiceManager.SourceManager.SetActiveSource (source);
- ServiceManager.Get<GtkElementsService> ().PrimaryWindow.Present ();
search.Entry.Query = String.Empty;
+ ServiceManager.Get<MoblinService> ().PresentPrimaryInterface ();
}
};
PackStart (search, true, true, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]