[banshee/gtk3] Remove X11 notification area and sync features in gtk notification area to have same beahaviour It n
- From: Olivier Dufour <dufoli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/gtk3] Remove X11 notification area and sync features in gtk notification area to have same beahaviour It n
- Date: Fri, 22 Jul 2011 20:20:26 +0000 (UTC)
commit cb0f11772365f6e640d61933296beb9580c7b7cf
Author: Olivier Dufour <olivier duff gmail com>
Date: Fri Jul 22 00:16:01 2011 +0200
Remove X11 notification area and sync features in gtk notification area to have same beahaviour
It need test because, can not test it until banshee works
.../GtkNotificationAreaBox.cs | 114 ++++-
.../NotificationAreaService.cs | 11 +-
.../Banshee.NotificationArea/TrackInfoPopup.cs | 11 +-
.../X11NotificationArea.cs | 647 --------------------
.../X11NotificationAreaBox.cs | 412 -------------
5 files changed, 111 insertions(+), 1084 deletions(-)
---
diff --git a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/GtkNotificationAreaBox.cs b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/GtkNotificationAreaBox.cs
index 533a022..fa890c3 100644
--- a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/GtkNotificationAreaBox.cs
+++ b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/GtkNotificationAreaBox.cs
@@ -40,15 +40,9 @@ namespace Banshee.NotificationArea
{
public event EventHandler Disconnected;
- public event EventHandler Activated {
- add { base.Activate += value; }
- remove { base.Activate -= value; }
- }
-
- public event PopupMenuHandler PopupMenuEvent {
- add { base.PopupMenu += value; }
- remove { base.PopupMenu -= value; }
- }
+ public event EventHandler Activated;
+ public event PopupMenuHandler PopupMenuEvent;
+ private TrackInfoPopup custom_tooltip;
public Widget Widget {
get { return null; }
@@ -60,8 +54,10 @@ namespace Banshee.NotificationArea
IconName = (IconThemeUtils.HasIcon ("banshee-panel")) ?
"banshee-panel" : Banshee.ServiceStack.Application.IconName;
- Tooltip = window.Title;
- window.TitleChanged += delegate { Tooltip = window.Title; };
+ HasTooltip = true;
+ base.Activate += delegate {OnActivated ();};
+ base.PopupMenu += delegate {OnPopupMenuEvent ();};
+ custom_tooltip = new TrackInfoPopup ();
}
public void PositionMenu (Menu menu, out int x, out int y, out bool push_in)
@@ -71,6 +67,86 @@ namespace Banshee.NotificationArea
public void OnPlayerEvent (PlayerEventArgs args)
{
+/* switch (args.Event) {
+ case PlayerEvent.StartOfStream:
+ can_show_popup = true;
+ break;
+
+ case PlayerEvent.EndOfStream:
+ // only hide the popup when we don't play again after 250ms
+ GLib.Timeout.Add (250, delegate {
+ if (ServiceManager.PlayerEngine.CurrentState != PlayerState.Playing) {
+ HidePopup ();
+ }
+ return false;
+ });
+ break;
+ }*/
+ }
+
+ protected bool OnScrollEvent (Gdk.EventScroll evnt)
+ {
+ switch (evnt.Direction) {
+ case Gdk.ScrollDirection.Up:
+ if ((evnt.State & Gdk.ModifierType.ControlMask) != 0) {
+ ServiceManager.PlayerEngine.Volume += (ushort)PlayerEngine.VolumeDelta;
+ } else if((evnt.State & Gdk.ModifierType.ShiftMask) != 0) {
+ ServiceManager.PlayerEngine.Position += PlayerEngine.SkipDelta;
+ } else {
+ ServiceManager.PlaybackController.Next ();
+ }
+ break;
+
+ case Gdk.ScrollDirection.Down:
+ if ((evnt.State & Gdk.ModifierType.ControlMask) != 0) {
+ if (ServiceManager.PlayerEngine.Volume < (ushort)PlayerEngine.VolumeDelta) {
+ ServiceManager.PlayerEngine.Volume = 0;
+ } else {
+ ServiceManager.PlayerEngine.Volume -= (ushort)PlayerEngine.VolumeDelta;
+ }
+ } else if((evnt.State & Gdk.ModifierType.ShiftMask) != 0) {
+ ServiceManager.PlayerEngine.Position -= PlayerEngine.SkipDelta;
+ } else {
+ ServiceManager.PlaybackController.Previous ();
+ }
+ break;
+ }
+ return true;
+ }
+
+ protected override bool OnButtonPressEvent (Gdk.EventButton evnt)
+ {
+ if (evnt.Type != Gdk.EventType.ButtonPress) {
+ return false;
+ }
+
+ switch (evnt.Button) {
+ case 1:
+ if ((evnt.State & Gdk.ModifierType.ControlMask) != 0) {
+ ServiceManager.PlaybackController.Next ();
+ } else {
+ OnActivated ();
+ }
+ break;
+ case 2:
+ ServiceManager.PlayerEngine.TogglePlaying ();
+ break;
+ case 3:
+ if ((evnt.State & Gdk.ModifierType.ControlMask) != 0) {
+ ServiceManager.PlaybackController.Next ();
+ } else {
+ OnPopupMenuEvent ();
+ }
+ break;
+ }
+ return true;
+ }
+
+
+ protected override bool OnQueryTooltip (int x, int y, bool keyboard_mode, Tooltip tooltip)
+ {
+ tooltip.Custom = custom_tooltip;
+ return true;
}
public void Show ()
@@ -82,5 +158,21 @@ namespace Banshee.NotificationArea
{
Visible = false;
}
+
+ protected virtual void OnActivated ()
+ {
+ EventHandler handler = Activated;
+ if (handler != null) {
+ handler (this, EventArgs.Empty);
+ }
+ }
+
+ protected virtual void OnPopupMenuEvent ()
+ {
+ PopupMenuHandler handler = PopupMenuEvent;
+ if (handler != null) {
+ handler (this, new PopupMenuArgs ());
+ }
+ }
}
}
diff --git a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
index ef510df..cd64629 100644
--- a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
+++ b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/NotificationAreaService.cs
@@ -208,16 +208,7 @@ namespace Banshee.NotificationArea
private bool BuildNotificationArea ()
{
- if (Environment.OSVersion.Platform == PlatformID.Unix) {
- try {
- notif_area = new X11NotificationAreaBox ();
- } catch {
- }
- }
-
- if (notif_area == null) {
- notif_area = new GtkNotificationAreaBox (elements_service.PrimaryWindow);
- }
+ notif_area = new GtkNotificationAreaBox (elements_service.PrimaryWindow);
if (notif_area == null) {
return false;
diff --git a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs
index cd19f88..c6865ac 100644
--- a/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs
+++ b/src/Extensions/Banshee.NotificationArea/Banshee.NotificationArea/TrackInfoPopup.cs
@@ -76,11 +76,14 @@ namespace Banshee.NotificationArea
base.Dispose (disposing);
}
- protected override bool OnExposeEvent (Gdk.EventExpose evnt)
+ protected override bool OnDrawn (Cairo.Context cr)
{
- Gtk.Style.PaintFlatBox (Style, GdkWindow, StateType.Normal, ShadowType.Out, evnt.Area, this, "tooltip",
- 0, 0, Allocation.Width, Allocation.Height);
- return base.OnExposeEvent (evnt);
+ StyleContext.Save ();
+ StyleContext.AddClass ("tooltip");
+ StyleContext.RenderBackground (cr, 0, 0, Allocation.Width, Allocation.Height);
+ StyleContext.RenderFrame (cr, 0, 0, Allocation.Width, Allocation.Height);
+ StyleContext.Restore ();
+ return base.OnDrawn (cr);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]