[banshee] [GlobalUIActions] DBus iface for showing dialogs



commit 624d363706bfe38e837951901151803f054f04ea
Author: Aaron Bockover <abockover novell com>
Date:   Mon Apr 5 11:53:53 2010 -0400

    [GlobalUIActions] DBus iface for showing dialogs
    
    Added a new DBus interface, org.bansheeproject.Banshee.GlobalUIActions,
    used for showing some global dialog boxes, such as import media.
    
    Command line arguments can be used to queue the dialog box to be shown
    on first startup (no instance already running) or can be proxied from
    the DBus command client to the running instance:
    
      --show-import-media
      --show-about
      --show-open-location
      --show-preferences

 src/Clients/Booter/Booter/Entry.cs                 |    6 ++-
 src/Clients/Halie/Halie/Client.cs                  |   34 ++++++++++++-
 .../Banshee.Gui/GlobalActions.cs                   |   54 +++++++++++++++++++-
 .../Banshee.Gui/IGlobalUIActions.cs                |   42 +++++++++++++++
 .../Banshee.Gui/InterfaceActionService.cs          |    2 +
 .../Banshee.ThickClient/Banshee.ThickClient.csproj |    1 +
 src/Core/Banshee.ThickClient/Makefile.am           |    1 +
 7 files changed, 137 insertions(+), 3 deletions(-)
---
diff --git a/src/Clients/Booter/Booter/Entry.cs b/src/Clients/Booter/Booter/Entry.cs
index 2d1cfd8..a60d81b 100644
--- a/src/Clients/Booter/Booter/Entry.cs
+++ b/src/Clients/Booter/Booter/Entry.cs
@@ -197,7 +197,11 @@ namespace Booter
                 new LayoutGroup ("ui", Catalog.GetString ("User Interface Options"),
                     new LayoutOption ("show|--present", Catalog.GetString ("Present the user interface on the active workspace")),
                     new LayoutOption ("hide", Catalog.GetString ("Hide the user interface")),
-                    new LayoutOption ("no-present", Catalog.GetString ("Do not present the user interface, regardless of any other options"))
+                    new LayoutOption ("no-present", Catalog.GetString ("Do not present the user interface, regardless of any other options")),
+                    new LayoutOption ("show-import-media", Catalog.GetString ("Present the import media dialog box")),
+                    new LayoutOption ("show-about", Catalog.GetString ("Present the about dialog")),
+                    new LayoutOption ("show-open-location", Catalog.GetString ("Present the open location dialog")),
+                    new LayoutOption ("show-preferences", Catalog.GetString ("Present the preferences dialog"))
                 ),
 
                 new LayoutGroup ("debugging", Catalog.GetString ("Debugging and Development Options"),
diff --git a/src/Clients/Halie/Halie/Client.cs b/src/Clients/Halie/Halie/Client.cs
index 980d64f..113e5a8 100644
--- a/src/Clients/Halie/Halie/Client.cs
+++ b/src/Clients/Halie/Halie/Client.cs
@@ -43,7 +43,7 @@ namespace Halie
 {
     public static class Client
     {
-        // NOTE: Interface is copied from Banshee.ThickClient/Banshee.Gui
+        // NOTE: Interfaces are copied from Banshee.ThickClient/Banshee.Gui
         // since we don't want to link against any GUI assemblies for this
         // client. It's a simple interface
         [Interface ("org.bansheeproject.Banshee.ClientWindow")]
@@ -53,6 +53,15 @@ namespace Halie
             void Hide ();
         }
 
+        [Interface ("org.bansheeproject.Banshee.GlobalUIActions")]
+        public interface IGlobalUIActions
+        {
+            void ShowImportDialog ();
+            void ShowAboutDialog ();
+            void ShowOpenLocationDialog ();
+            void ShowPreferencesDialog ();
+        }
+
         private static bool hide_field;
         private static DBusCommandService command;
 
@@ -74,6 +83,7 @@ namespace Halie
             hide_field = ApplicationContext.CommandLine.Contains ("hide-field");
 
             bool present = HandlePlayerCommands () && !ApplicationContext.CommandLine.Contains ("indexer");
+            HandleGlobalUIActions ();
             HandleWindowCommands (present);
             HandleFiles ();
         }
@@ -113,6 +123,28 @@ namespace Halie
             }
         }
 
+        private static void HandleGlobalUIActions ()
+        {
+            var global_ui_actions = DBusServiceManager.FindInstance<IGlobalUIActions> ("/GlobalUIActions");
+
+            if (ApplicationContext.CommandLine.Contains ("show-import-media")) {
+                global_ui_actions.ShowImportDialog ();
+            }
+
+            if (ApplicationContext.CommandLine.Contains ("show-about")) {
+                global_ui_actions.ShowAboutDialog ();
+            }
+
+            if (ApplicationContext.CommandLine.Contains ("show-preferences")) {
+                global_ui_actions.ShowPreferencesDialog ();
+            }
+
+            if (ApplicationContext.CommandLine.Contains ("show-open-location")) {
+                global_ui_actions.ShowOpenLocationDialog ();
+            }
+
+        }
+
         private static bool HandlePlayerCommands ()
         {
             IPlayerEngineService player = DBusServiceManager.FindInstance<IPlayerEngineService> ("/PlayerEngine");
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs
index 2274c82..6abeb3e 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/GlobalActions.cs
@@ -40,7 +40,7 @@ using Banshee.Playlist;
 
 namespace Banshee.Gui
 {
-    public class GlobalActions : BansheeActionGroup
+    public class GlobalActions : BansheeActionGroup, IGlobalUIActions
     {
         public GlobalActions () : base ("Global")
         {
@@ -126,6 +126,26 @@ namespace Banshee.Gui
             });
 
             this["ExtensionsAction"].Visible = false;
+
+            GLib.Timeout.Add (500, delegate {
+                if (ApplicationContext.CommandLine.Contains ("show-import-media")) {
+                    OnImport (null, null);
+                }
+
+                if (ApplicationContext.CommandLine.Contains ("show-about")) {
+                    OnAbout (null, null);
+                }
+
+                if (ApplicationContext.CommandLine.Contains ("show-open-location")) {
+                    OnOpenLocation (null, null);
+                }
+
+                if (ApplicationContext.CommandLine.Contains ("show-preferences")) {
+                    OnPreferences (null, null);
+                }
+
+                return false;
+            });
         }
 
 #region Media Menu Actions
@@ -225,5 +245,37 @@ namespace Banshee.Gui
 
 #endregion
 
+#region IGlobalUIActions
+
+        void IGlobalUIActions.ShowImportDialog ()
+        {
+            OnImport (null, null);
+        }
+
+        void IGlobalUIActions.ShowAboutDialog ()
+        {
+            OnAbout (null, null);
+        }
+
+        void IGlobalUIActions.ShowOpenLocationDialog ()
+        {
+            OnOpenLocation (null, null);
+        }
+
+        void IGlobalUIActions.ShowPreferencesDialog ()
+        {
+            OnPreferences (null, null);
+        }
+
+        IDBusExportable IDBusExportable.Parent {
+            get { return null; }
+        }
+
+        string IService.ServiceName {
+            get { return "GlobalUIActions"; }
+        }
+
+#endregion
+
     }
 }
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/IGlobalUIActions.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/IGlobalUIActions.cs
new file mode 100644
index 0000000..6f66b6e
--- /dev/null
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/IGlobalUIActions.cs
@@ -0,0 +1,42 @@
+// 
+// IGlobalUIActions.cs
+// 
+// Author:
+//   Aaron Bockover <abockover novell com>
+// 
+// Copyright 2010 Novell, Inc.
+// 
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using NDesk.DBus;
+
+using Banshee.ServiceStack;
+
+namespace Banshee.Gui
+{
+    [Interface ("org.bansheeproject.Banshee.GlobalUIActions")]
+    public interface IGlobalUIActions : IDBusExportable
+    {
+        void ShowImportDialog ();
+        void ShowAboutDialog ();
+        void ShowOpenLocationDialog ();
+        void ShowPreferencesDialog ();
+    }
+}
\ No newline at end of file
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs
index b8bf081..286fcfa 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs
@@ -71,6 +71,8 @@ namespace Banshee.Gui
             UIManager.AddUiFromResource ("core-ui-actions-layout.xml");
 
             AddinManager.AddExtensionNodeHandler ("/Banshee/ThickClient/ActionGroup", OnExtensionChanged);
+
+            ServiceManager.DBusServiceManager.RegisterObject (global_actions);
         }
 
         private void OnActiveSourceChanged (SourceEventArgs args)
diff --git a/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj b/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
index b19dbed..618346e 100644
--- a/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
+++ b/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
@@ -274,6 +274,7 @@
     <Compile Include="Banshee.Collection.Gui\SearchableListView.cs" />
     <Compile Include="Banshee.Gui.Widgets\CoverArtDisplay.cs" />
     <Compile Include="Banshee.CairoGlyphs\BansheeLineLogo.cs" />
+    <Compile Include="Banshee.Gui\IGlobalUIActions.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ProjectExtensions>
diff --git a/src/Core/Banshee.ThickClient/Makefile.am b/src/Core/Banshee.ThickClient/Makefile.am
index 4285c26..cf36e00 100644
--- a/src/Core/Banshee.ThickClient/Makefile.am
+++ b/src/Core/Banshee.ThickClient/Makefile.am
@@ -113,6 +113,7 @@ SOURCES =  \
 	Banshee.Gui/IClientWindow.cs \
 	Banshee.Gui/IconThemeUtils.cs \
 	Banshee.Gui/IDisableKeybindings.cs \
+	Banshee.Gui/IGlobalUIActions.cs \
 	Banshee.Gui/IHasSourceView.cs \
 	Banshee.Gui/InterfaceActionService.cs \
 	Banshee.Gui/PersistentPaneController.cs \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]