banshee r5048 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui src/Extensions/Banshee.MiniMode/Banshee.MiniMode
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r5048 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui src/Extensions/Banshee.MiniMode/Banshee.MiniMode
- Date: Thu, 19 Feb 2009 18:39:14 +0000 (UTC)
Author: gburt
Date: Thu Feb 19 18:39:14 2009
New Revision: 5048
URL: http://svn.gnome.org/viewvc/banshee?rev=5048&view=rev
Log:
2009-02-19 Gabriel Burt <gabriel burt gmail com>
This patch fixes support for hiding/restoring from the notification icon
properly even if you hid the window via the X/close button, and even if
you're in MiniMode (BGO #437938)
* src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeWindow.cs:
Subclass from BaseClientWindow so we can set the Minimode window as the
PrimaryWindow when it's enabled.
* src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeService.cs:
When entering Minimode, initialize the window w/ the current
PrimaryWindow, set it as the new one, and call the new Enable method.
* src/Core/Banshee.ThickClient/Banshee.Gui/PersistentWindowController.cs:
Check that the window is in an ok state before saving or restoring its
size/position. Speed up the save timeout, and grab the size/pos
immediately instead of after the timeout.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/PersistentWindowController.cs
trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeService.cs
trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeWindow.cs
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/PersistentWindowController.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/PersistentWindowController.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/PersistentWindowController.cs Thu Feb 19 18:39:14 2009
@@ -136,10 +136,21 @@
}
}
+ private int x, y, width, height;
+ private bool maximized;
+
public void Save ()
{
+ if (window == null || !window.Visible || !window.IsMapped || window.GdkWindow == null) {
+ return;
+ }
+
+ maximized = (window.GdkWindow.State & Gdk.WindowState.Maximized) != 0;
+ window.GetPosition (out x, out y);
+ window.GetSize (out width, out height);
+
if (timer_id == 0) {
- timer_id = GLib.Timeout.Add (500, OnTimeout);
+ timer_id = GLib.Timeout.Add (250, OnTimeout);
} else {
pending_changes = true;
}
@@ -148,6 +159,7 @@
private bool OnTimeout ()
{
if (pending_changes) {
+ // Wait another 250ms to see if we've stopped getting updates yet
pending_changes = false;
return true;
} else {
@@ -159,18 +171,14 @@
private void InnerSave ()
{
- if (window == null || window.GdkWindow == null)
- return;
-
- int x, y, width, height;
-
- if ((window.GdkWindow.State & Gdk.WindowState.Maximized) != 0) {
+ if (maximized) {
MaximizedSchema.Set (true);
return;
}
- window.GetPosition (out x, out y);
- window.GetSize (out width, out height);
+ if (x < 0 || y < 0 || width <= 0 || height <= 0) {
+ return;
+ }
MaximizedSchema.Set (false);
XPosSchema.Set (x);
Modified: trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeService.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeService.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeService.cs Thu Feb 19 18:39:14 2009
@@ -21,33 +21,34 @@
{
action_service = ServiceManager.Get<InterfaceActionService> ("InterfaceActionService");
- viewMenu = (action_service.UIManager.GetWidget("/MainMenu/ViewMenu") as MenuItem).Submenu as Menu;
- menuItem = new MenuItem(Catalog.GetString("_Mini Mode"));
+ viewMenu = (action_service.UIManager.GetWidget ("/MainMenu/ViewMenu") as MenuItem).Submenu as Menu;
+ menuItem = new MenuItem (Catalog.GetString ("_Mini Mode"));
menuItem.Activated += delegate {
if (mini_mode == null) {
- mini_mode = new MiniMode();
+ mini_mode = new MiniMode (ServiceManager.Get<GtkElementsService> ().PrimaryWindow);
}
- mini_mode.Show();
+ ServiceManager.Get<GtkElementsService> ().PrimaryWindow = mini_mode;
+ mini_mode.Enable ();
};
- viewMenu.Insert(menuItem, 2);
- menuItem.Show();
+ viewMenu.Insert (menuItem, 2);
+ menuItem.Show ();
}
- public void Dispose()
+ public void Dispose ()
{
- if(viewMenu != null && menuItem != null) {
- viewMenu.Remove(menuItem);
+ if (viewMenu != null && menuItem != null) {
+ viewMenu.Remove (menuItem);
}
- if(mini_mode != null) {
+ if (mini_mode != null) {
// We'll do our visual cleaning in a timeout to avoid
// glitches when Banshee quits. Besides, the plugin window is
// accessible only on the full mode, so this won't cause any
// trouble.
- GLib.Timeout.Add(1000, delegate {
+ GLib.Timeout.Add (1000, delegate {
try {
- mini_mode.Hide();
+ mini_mode.Hide ();
} catch {
}
return false;
Modified: trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeWindow.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeWindow.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.MiniMode/Banshee.MiniMode/MiniModeWindow.cs Thu Feb 19 18:39:14 2009
@@ -46,7 +46,7 @@
namespace Banshee.MiniMode
{
- public class MiniMode : Window
+ public class MiniMode : Banshee.Gui.BaseClientWindow
{
[Widget] private Gtk.Box SeekContainer;
[Widget] private Gtk.Box VolumeContainer;
@@ -64,80 +64,68 @@
private ConnectedSeekSlider seek_slider;
private object tooltip_host;
- private InterfaceActionService interface_action_service;
- private GtkElementsService elements_service;
private BaseClientWindow default_main_window;
private Glade.XML glade;
- public MiniMode() : base(Catalog.GetString("Banshee Music Player"))
+ public MiniMode (BaseClientWindow defaultMainWindow) : base (Catalog.GetString ("Banshee Media Player"), "minimode", 0, 0)
{
- elements_service = ServiceManager.Get<GtkElementsService>();
- interface_action_service = ServiceManager.Get<InterfaceActionService>();
+ default_main_window = defaultMainWindow;
- default_main_window = elements_service.PrimaryWindow;
-
- glade = new Glade.XML(System.Reflection.Assembly.GetExecutingAssembly(), "minimode.glade", "MiniModeWindow", null);
- glade.Autoconnect(this);
+ glade = new Glade.XML (System.Reflection.Assembly.GetExecutingAssembly (), "minimode.glade", "MiniModeWindow", null);
+ glade.Autoconnect (this);
Widget child = glade["mini_mode_contents"];
- (child.Parent as Container).Remove(child);
- Add(child);
+ (child.Parent as Container).Remove (child);
+ Add (child);
BorderWidth = 12;
Resizable = false;
- DeleteEvent += delegate {
- interface_action_service.GlobalActions["QuitAction"].Activate();
- };
-
// Playback Buttons
- Widget previous_button = interface_action_service.PlaybackActions["PreviousAction"].CreateToolItem ();
+ Widget previous_button = ActionService.PlaybackActions["PreviousAction"].CreateToolItem ();
- Widget playpause_button = interface_action_service.PlaybackActions["PlayPauseAction"].CreateToolItem ();
+ Widget playpause_button = ActionService.PlaybackActions["PlayPauseAction"].CreateToolItem ();
- Widget button = interface_action_service.PlaybackActions["NextAction"].CreateToolItem ();
- Menu menu = interface_action_service.PlaybackActions.ShuffleActions.CreateMenu ();
+ Widget button = ActionService.PlaybackActions["NextAction"].CreateToolItem ();
+ Menu menu = ActionService.PlaybackActions.ShuffleActions.CreateMenu ();
MenuButton next_button = new MenuButton (button, menu, true);
- PlaybackBox.PackStart(previous_button, false, false, 0);
- PlaybackBox.PackStart(playpause_button, false, false, 0);
- PlaybackBox.PackStart(next_button, false, false, 0);
- PlaybackBox.ShowAll();
+ PlaybackBox.PackStart (previous_button, false, false, 0);
+ PlaybackBox.PackStart (playpause_button, false, false, 0);
+ PlaybackBox.PackStart (next_button, false, false, 0);
+ PlaybackBox.ShowAll ();
// Seek Slider/Position Label
- seek_slider = new ConnectedSeekSlider();
+ seek_slider = new ConnectedSeekSlider ();
- SeekContainer.PackStart(seek_slider, false, false, 0);
- SeekContainer.ShowAll();
+ SeekContainer.PackStart (seek_slider, false, false, 0);
+ SeekContainer.ShowAll ();
// Volume button
- volume_button = new ConnectedVolumeButton();
- VolumeContainer.PackStart(volume_button, false, false, 0);
- volume_button.Show();
+ volume_button = new ConnectedVolumeButton ();
+ VolumeContainer.PackStart (volume_button, false, false, 0);
+ volume_button.Show ();
// Source combobox
- source_combo_box = new SourceComboBox();
- SourceBox.PackStart(source_combo_box, true, true, 0);
- source_combo_box.Show();
+ source_combo_box = new SourceComboBox ();
+ SourceBox.PackStart (source_combo_box, true, true, 0);
+ source_combo_box.Show ();
// Track info
track_info_display = new ClassicTrackInfoDisplay ();
track_info_display.Show ();
- CoverBox.PackStart(track_info_display, true, true, 0);
+ CoverBox.PackStart (track_info_display, true, true, 0);
// Repeat button
RepeatActionButton repeat_toggle_button = new RepeatActionButton ();
- LowerButtonsBox.PackEnd(repeat_toggle_button, false, false, 0);
- LowerButtonsBox.ShowAll();
+ LowerButtonsBox.PackEnd (repeat_toggle_button, false, false, 0);
+ LowerButtonsBox.ShowAll ();
tooltip_host = TooltipSetter.CreateHost ();
- SetTip(fullmode_button, Catalog.GetString("Switch back to full mode"));
- SetTip(repeat_toggle_button, Catalog.GetString("Change repeat playback mode"));
-
- // Use the hotkeys from the main window.
- AddAccelGroup(interface_action_service.UIManager.AccelGroup);
+ SetTip (fullmode_button, Catalog.GetString ("Switch back to full mode"));
+ SetTip (repeat_toggle_button, Catalog.GetString ("Change repeat playback mode"));
// Hook up everything
ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent,
@@ -145,45 +133,51 @@
PlayerEvent.StateChange |
PlayerEvent.TrackInfoUpdated);
- SetHeightLimit();
+ SetHeightLimit ();
+ }
+
+ protected override void Initialize ()
+ {
}
- private void SetTip(Widget widget, string tip)
+ private void SetTip (Widget widget, string tip)
{
TooltipSetter.Set (tooltip_host, widget, tip);
}
- private void SetHeightLimit()
+ private void SetHeightLimit ()
{
- Gdk.Geometry limits = new Gdk.Geometry();
+ Gdk.Geometry limits = new Gdk.Geometry ();
limits.MinHeight = -1;
limits.MaxHeight = -1;
- limits.MinWidth = SizeRequest().Width;
+ limits.MinWidth = SizeRequest ().Width;
limits.MaxWidth = Gdk.Screen.Default.Width;
- SetGeometryHints(this, limits, Gdk.WindowHints.MaxSize | Gdk.WindowHints.MinSize);
+ SetGeometryHints (this, limits, Gdk.WindowHints.MaxSize | Gdk.WindowHints.MinSize);
}
- public new void Show()
+ public void Enable ()
{
- source_combo_box.UpdateActiveSource();
- UpdateMetaDisplay();
+ source_combo_box.UpdateActiveSource ();
+ UpdateMetaDisplay ();
- default_main_window.Hide();
-
- base.Show();
+ default_main_window.Hide ();
+
+ Show ();
}
- public new void Hide()
+ public void Disable ()
{
- base.Hide();
- default_main_window.Show();
+ Hide ();
+ default_main_window.Show ();
}
-
- public void Hide(object o, EventArgs a)
+
+ // Called when the user clicks the fullmode_button
+ public void Hide (object o, EventArgs a)
{
- Hide();
+ ElementsService.PrimaryWindow = default_main_window;
+ Disable ();
}
// ---- Player Event Handlers ----
@@ -209,11 +203,11 @@
}
}
- protected void UpdateMetaDisplay()
+ protected void UpdateMetaDisplay ()
{
TrackInfo track = ServiceManager.PlayerEngine.CurrentTrack;
- if(track == null) {
+ if (track == null) {
InfoBox.Visible = false;
return;
}
@@ -221,8 +215,8 @@
InfoBox.Visible = true;
try {
- SetHeightLimit();
- } catch(Exception) {
+ SetHeightLimit ();
+ } catch (Exception) {
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]