[banshee: 10/12] More platform-hyena merging and fixes
- From: Gabriel Burt <gburt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee: 10/12] More platform-hyena merging and fixes
- Date: Tue, 12 Jan 2010 19:47:20 +0000 (UTC)
commit cffd57d459e317bcac16451ba6afaa1b856f6749
Author: Gabriel Burt <gabriel burt gmail com>
Date: Sat Jan 9 14:22:28 2010 -0800
More platform-hyena merging and fixes
src/Core/Banshee.Core/Banshee.Base/Paths.cs | 12 ------
.../Banshee.Core/Banshee.Base/PlatformHacks.cs | 32 -----------------
.../Banshee.Library/MusicLibrarySource.cs | 2 +-
.../Banshee.Metadata/MetadataService.cs | 2 +-
.../Banshee.Addins.Gui/AddinView.cs | 4 +--
.../Banshee.Gui/BaseClientWindow.cs | 1 +
.../Banshee.Gui/GtkBaseClient.cs | 2 +-
.../Banshee.Gui/InterfaceActionService.cs | 26 --------------
.../Banshee.Audiobook/AudiobookLibrarySource.cs | 4 ++-
.../Banshee.InternetArchive/DetailsSource.cs | 1 +
.../Banshee.InternetArchive/SearchSource.cs | 1 +
.../ItunesPlayerImportSource.cs | 3 ++
src/Libraries/Hyena.Gui/Hyena.Gui/ActionManager.cs | 36 ++++++++++----------
.../Hyena.Gui/Hyena.Gui/HyenaActionGroup.cs | 20 +++++-----
.../Hyena.Gui/Hyena.Widgets/GenericToolItem.cs | 4 +-
src/Libraries/Hyena/Hyena/ApplicationContext.cs | 26 +++++++-------
src/Libraries/Hyena/Hyena/ThreadAssist.cs | 5 +--
src/Libraries/Hyena/Hyena/XdgBaseDirectorySpec.cs | 12 ++++++
18 files changed, 70 insertions(+), 123 deletions(-)
---
diff --git a/src/Core/Banshee.Core/Banshee.Base/Paths.cs b/src/Core/Banshee.Core/Banshee.Base/Paths.cs
index 402ca24..1eddc17 100644
--- a/src/Core/Banshee.Core/Banshee.Base/Paths.cs
+++ b/src/Core/Banshee.Core/Banshee.Base/Paths.cs
@@ -215,17 +215,5 @@ namespace Banshee.Base
{
return Path.Combine (InstalledApplicationData, path);
}
-
- public static string GetXdgDirectoryUnderHome (string key, string fallback)
- {
- string xdg_dir = Banshee.Base.XdgBaseDirectorySpec.GetUserDirectory (key, fallback);
- string home_dir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
-
- if (xdg_dir == null || xdg_dir == home_dir || !xdg_dir.StartsWith (home_dir)) {
- xdg_dir = Combine (home_dir, fallback);
- }
-
- return xdg_dir;
- }
}
}
diff --git a/src/Core/Banshee.Core/Banshee.Base/PlatformHacks.cs b/src/Core/Banshee.Core/Banshee.Base/PlatformHacks.cs
index 1e6cdd4..569f726 100644
--- a/src/Core/Banshee.Core/Banshee.Base/PlatformHacks.cs
+++ b/src/Core/Banshee.Core/Banshee.Base/PlatformHacks.cs
@@ -71,37 +71,5 @@ namespace Banshee.Base
} catch {
}
}
-
- [DllImport ("libc")] // Linux
- private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
-
- [DllImport ("libc")] // BSD
- private static extern void setproctitle (byte [] fmt, byte [] str_arg);
-
- public static void SetProcessName (string name)
- {
- if (Environment.OSVersion.Platform != PlatformID.Unix) {
- return;
- }
-
- try {
- if (prctl (15 /* PR_SET_NAME */, Encoding.ASCII.GetBytes (name + "\0"),
- IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) != 0) {
- throw new ApplicationException ("Error setting process name: " +
- Mono.Unix.Native.Stdlib.GetLastError ());
- }
- } catch (EntryPointNotFoundException) {
- setproctitle (Encoding.ASCII.GetBytes ("%s\0"),
- Encoding.ASCII.GetBytes (name + "\0"));
- }
- }
-
- public static void TrySetProcessName (string name)
- {
- try {
- SetProcessName (name);
- } catch {
- }
- }
}
}
diff --git a/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs b/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs
index 59f4f7f..9c39611 100644
--- a/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs
+++ b/src/Core/Banshee.Services/Banshee.Library/MusicLibrarySource.cs
@@ -77,7 +77,7 @@ namespace Banshee.Library
public static string GetDefaultBaseDirectory ()
{
- return Banshee.Base.Paths.GetXdgDirectoryUnderHome ("XDG_MUSIC_DIR", "Music");
+ return Hyena.XdgBaseDirectorySpec.GetXdgDirectoryUnderHome ("XDG_MUSIC_DIR", "Music");
}
public override string DefaultBaseDirectory {
diff --git a/src/Core/Banshee.Services/Banshee.Metadata/MetadataService.cs b/src/Core/Banshee.Services/Banshee.Metadata/MetadataService.cs
index 6f65974..f90f9bf 100644
--- a/src/Core/Banshee.Services/Banshee.Metadata/MetadataService.cs
+++ b/src/Core/Banshee.Services/Banshee.Metadata/MetadataService.cs
@@ -138,7 +138,7 @@ namespace Banshee.Metadata
internal void OnHaveResult (MetadataServiceJob job)
{
- Banshee.Base.ThreadAssist.ProxyToMain (delegate {
+ ThreadAssist.ProxyToMain (delegate {
OnHaveResult (job.Track, job.ResultTags);
});
}
diff --git a/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs b/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs
index 0b2be32..a921718 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Addins.Gui/AddinView.cs
@@ -36,8 +36,6 @@ using Hyena;
using Mono.Unix;
using Mono.Addins;
-using Hyena;
-
namespace Banshee.Addins.Gui
{
public class AddinView : VBox
@@ -72,7 +70,7 @@ namespace Banshee.Addins.Gui
var addins = AddinManager.Registry.GetAddins ().Where (a => { return
a.Name != a.Id && a.Description != null &&
!String.IsNullOrEmpty (a.Description.Category) && !a.Description.Category.StartsWith ("required:") &&
- (!a.Description.Category.Contains ("Debug") || Banshee.Base.ApplicationContext.Debugging);
+ (!a.Description.Category.Contains ("Debug") || ApplicationContext.Debugging);
});
var categorized_addins = addins.GroupBy<Addin, string> (a => a.Description.Category)
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs
index f0c429f..f83af17 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/BaseClientWindow.cs
@@ -32,6 +32,7 @@ using Mono.Unix;
using Hyena;
+using Banshee.Base;
using Banshee.ServiceStack;
using Banshee.MediaEngine;
using Banshee.Collection;
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
index 032a4e6..3492c8f 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs
@@ -110,7 +110,7 @@ namespace Banshee.Gui
protected void Initialize (bool registerCommonServices)
{
// Set the process name so system process listings and commands are pretty
- PlatformHacks.TrySetProcessName (Application.InternalName);
+ ApplicationContext.TrySetProcessName (Application.InternalName);
Application.Initialize ();
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs
index 48d8a57..b8bf081 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs
@@ -135,32 +135,6 @@ namespace Banshee.Gui
}
}
-<<<<<<< HEAD:src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs
-=======
- public uint AddUiFromFileInCurrentAssembly (string ui_file)
- {
- return AddUiFromFile (ui_file, Assembly.GetCallingAssembly ());
- }
-
- public uint AddUiFromFile (string ui_file, Assembly assembly)
- {
- if (ui_file != null) {
- using (StreamReader reader = new StreamReader (assembly.GetManifestResourceStream (ui_file))) {
- return ui_manager.AddUiFromString (reader.ReadToEnd ());
- }
- }
- return 0;
- }
-
- public Action this[string actionId] {
- get { return FindAction (actionId); }
- }
-
- public UIManager UIManager {
- get { return ui_manager; }
- }
-
->>>>>>> master:src/Core/Banshee.ThickClient/Banshee.Gui/InterfaceActionService.cs
public GlobalActions GlobalActions {
get { return global_actions; }
}
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
index bb11b30..016c6d1 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
@@ -31,6 +31,8 @@ using System.Collections.Generic;
using Mono.Unix;
+using Hyena;
+
using Banshee.Library;
using Banshee.Collection;
using Banshee.SmartPlaylist;
@@ -72,7 +74,7 @@ namespace Banshee.Audiobook
}
public override string DefaultBaseDirectory {
- get { return Banshee.Base.XdgBaseDirectorySpec.GetUserDirectory ("XDG_AUDIOBOOKS_DIR", "Audiobooks"); }
+ get { return XdgBaseDirectorySpec.GetXdgDirectoryUnderHome ("XDG_AUDIOBOOKS_DIR", "Audiobooks"); }
}
public override bool ShowBrowser {
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
index 2378f8d..a9c5ab5 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
@@ -32,6 +32,7 @@ using System.Linq;
using Mono.Unix;
+using Hyena;
using Hyena.Collections;
using Hyena.Data.Sqlite;
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/SearchSource.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/SearchSource.cs
index 51c7104..97502b5 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/SearchSource.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/SearchSource.cs
@@ -32,6 +32,7 @@ using System.Linq;
using Mono.Unix;
+using Hyena;
using Hyena.Collections;
using Hyena.Data;
diff --git a/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/ItunesPlayerImportSource.cs b/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/ItunesPlayerImportSource.cs
index 39bd1ef..5d2ee4d 100644
--- a/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/ItunesPlayerImportSource.cs
+++ b/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/ItunesPlayerImportSource.cs
@@ -35,9 +35,12 @@ using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
+
using Mono.Unix;
using Gtk;
+using Hyena;
+
using Banshee.Base;
using Banshee.Collection;
using Banshee.Collection.Database;
diff --git a/src/Libraries/Hyena.Gui/Hyena.Gui/ActionManager.cs b/src/Libraries/Hyena.Gui/Hyena.Gui/ActionManager.cs
index 1d65bcc..f1f0ba9 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Gui/ActionManager.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Gui/ActionManager.cs
@@ -64,29 +64,29 @@ namespace Hyena.Gui
if (action_groups.ContainsKey (name)) {
throw new ApplicationException ("Group already exists");
}
-
+
InnerAddActionGroup (new ActionGroup (name));
}
}
-
+
public void AddActionGroup (ActionGroup group)
{
lock (this) {
if (action_groups.ContainsKey (group.Name)) {
throw new ApplicationException ("Group already exists");
}
-
+
InnerAddActionGroup (group);
}
}
-
+
public void RemoveActionGroup (string name)
{
lock (this) {
if (action_groups.ContainsKey (name)) {
ActionGroup group = action_groups[name];
ui_manager.RemoveActionGroup (group);
- action_groups.Remove (name);
+ action_groups.Remove (name);
}
}
}
@@ -95,7 +95,7 @@ namespace Hyena.Gui
{
RemoveActionGroup (group.Name);
}
-
+
public ActionGroup FindActionGroup (string actionGroupId)
{
foreach (ActionGroup group in action_groups.Values) {
@@ -103,36 +103,36 @@ namespace Hyena.Gui
return group;
}
}
-
+
return null;
}
-
+
public Gtk.Action FindAction (string actionId)
{
string [] parts = actionId.Split ('.');
-
+
if (parts == null || parts.Length < 2) {
return null;
}
-
+
string group_name = parts[0];
string action_name = parts[1];
-
+
ActionGroup group = FindActionGroup (group_name);
return group == null ? null : group.GetAction (action_name);
}
-
+
public void PopulateToolbarPlaceholder (Toolbar toolbar, string path, Widget item)
{
PopulateToolbarPlaceholder (toolbar, path, item, false);
}
-
+
public void PopulateToolbarPlaceholder (Toolbar toolbar, string path, Widget item, bool expand)
{
ToolItem placeholder = (ToolItem)UIManager.GetWidget (path);
int position = toolbar.GetItemIndex (placeholder);
toolbar.Remove (placeholder);
-
+
if (item is ToolItem) {
((ToolItem)item).Expand = expand;
toolbar.Insert ((ToolItem)item, position);
@@ -143,12 +143,12 @@ namespace Hyena.Gui
toolbar.Insert (container_item, position);
}
}
-
+
public uint AddUiFromFileInCurrentAssembly (string ui_file)
{
return AddUiFromFile (ui_file, Assembly.GetCallingAssembly ());
}
-
+
public uint AddUiFromFile (string ui_file, Assembly assembly)
{
if (ui_file != null) {
@@ -158,11 +158,11 @@ namespace Hyena.Gui
}
return 0;
}
-
+
public Gtk.Action this[string actionId] {
get { return FindAction (actionId); }
}
-
+
public UIManager UIManager {
get { return ui_manager; }
}
diff --git a/src/Libraries/Hyena.Gui/Hyena.Gui/HyenaActionGroup.cs b/src/Libraries/Hyena.Gui/Hyena.Gui/HyenaActionGroup.cs
index fbbd6e2..c804bbc 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Gui/HyenaActionGroup.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Gui/HyenaActionGroup.cs
@@ -48,7 +48,7 @@ namespace Hyena.Gui
{
this.action_manager = action_manager;
}
-
+
public void AddUiFromFile (string ui_file)
{
Hyena.ThreadAssist.AssertInMainThread ();
@@ -93,11 +93,11 @@ namespace Hyena.Gui
base.Add (action_entries);
}
}
-
+
public void AddImportant (params ActionEntry [] action_entries)
{
base.Add (action_entries);
-
+
foreach (ActionEntry entry in action_entries) {
this[entry.name].IsImportant = true;
}
@@ -106,12 +106,12 @@ namespace Hyena.Gui
public void AddImportant (params ToggleActionEntry [] action_entries)
{
base.Add (action_entries);
-
+
foreach (ToggleActionEntry entry in action_entries) {
this[entry.name].IsImportant = true;
}
}
-
+
public void Remove (string actionName)
{
Gtk.Action action = this[actionName];
@@ -131,7 +131,7 @@ namespace Hyena.Gui
{
UpdateAction (this[action_name], visible_and_sensitive, visible_and_sensitive);
}
-
+
public void UpdateAction (string action_name, bool visible, bool sensitive)
{
UpdateAction (this[action_name], visible, sensitive);
@@ -141,13 +141,13 @@ namespace Hyena.Gui
{
UpdateAction (action, visible_and_sensitive, visible_and_sensitive);
}
-
+
public static void UpdateAction (Gtk.Action action, bool visible, bool sensitive)
{
action.Visible = visible;
action.Sensitive = visible && sensitive;
}
-
+
protected void ShowContextMenu (string menu_name)
{
Gtk.Menu menu = ActionManager.UIManager.GetWidget (menu_name) as Menu;
@@ -164,10 +164,10 @@ namespace Hyena.Gui
return;
}
- menu.Show ();
+ menu.Show ();
menu.Popup (null, null, null, 0, Gtk.Global.CurrentEventTime);
}
-
+
public ActionManager ActionManager {
get { return action_manager; }
}
diff --git a/src/Libraries/Hyena.Gui/Hyena.Widgets/GenericToolItem.cs b/src/Libraries/Hyena.Gui/Hyena.Widgets/GenericToolItem.cs
index c89ad25..ec83d0e 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Widgets/GenericToolItem.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Widgets/GenericToolItem.cs
@@ -34,13 +34,13 @@ namespace Hyena.Widgets
public class GenericToolItem<T> : ToolItem where T : Widget
{
private T widget;
-
+
public GenericToolItem (T widget)
{
this.widget = widget;
Add (widget);
}
-
+
public T Widget {
get { return widget; }
}
diff --git a/src/Libraries/Hyena/Hyena/ApplicationContext.cs b/src/Libraries/Hyena/Hyena/ApplicationContext.cs
index 9085f19..dcae020 100644
--- a/src/Libraries/Hyena/Hyena/ApplicationContext.cs
+++ b/src/Libraries/Hyena/Hyena/ApplicationContext.cs
@@ -38,23 +38,23 @@ namespace Hyena
public static class ApplicationContext
{
- static ApplicationContext ()
+ static ApplicationContext ()
{
Log.Debugging = Debugging;
}
-
+
private static CommandLineParser command_line = new CommandLineParser ();
public static CommandLineParser CommandLine {
set { command_line = value; }
get { return command_line; }
}
-
+
private static Layout command_line_layout;
public static Layout CommandLineLayout {
get { return command_line_layout; }
set { command_line_layout = value; }
}
-
+
private static bool? debugging = null;
public static bool Debugging {
get {
@@ -63,23 +63,23 @@ namespace Hyena
debugging |= CommandLine.Contains ("debug-sql");
debugging |= EnvironmentIsSet ("BANSHEE_DEBUG");
}
-
+
return debugging.Value;
}
}
-
+
public static bool EnvironmentIsSet (string env)
{
return !String.IsNullOrEmpty (Environment.GetEnvironmentVariable (env));
}
-
+
public static System.Globalization.CultureInfo InternalCultureInfo {
get { return System.Globalization.CultureInfo.InvariantCulture; }
}
[DllImport ("libc")] // Linux
private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
-
+
[DllImport ("libc")] // BSD
private static extern void setproctitle (byte [] fmt, byte [] str_arg);
@@ -88,19 +88,19 @@ namespace Hyena
if (Environment.OSVersion.Platform != PlatformID.Unix) {
return;
}
-
+
try {
- if (prctl (15 /* PR_SET_NAME */, Encoding.ASCII.GetBytes (name + "\0"),
+ if (prctl (15 /* PR_SET_NAME */, Encoding.ASCII.GetBytes (name + "\0"),
IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) != 0) {
- throw new ApplicationException ("Error setting process name: " +
+ throw new ApplicationException ("Error setting process name: " +
Mono.Unix.Native.Stdlib.GetLastError ());
}
} catch (EntryPointNotFoundException) {
- setproctitle (Encoding.ASCII.GetBytes ("%s\0"),
+ setproctitle (Encoding.ASCII.GetBytes ("%s\0"),
Encoding.ASCII.GetBytes (name + "\0"));
}
}
-
+
public static void TrySetProcessName (string name)
{
try {
diff --git a/src/Libraries/Hyena/Hyena/ThreadAssist.cs b/src/Libraries/Hyena/Hyena/ThreadAssist.cs
index ec9fb86..c685046 100644
--- a/src/Libraries/Hyena/Hyena/ThreadAssist.cs
+++ b/src/Libraries/Hyena/Hyena/ThreadAssist.cs
@@ -41,7 +41,7 @@ namespace Hyena
}
public static Action<InvokeHandler> ProxyToMainHandler { get; set; }
-
+
public static void InitializeMainThread ()
{
main_thread = Thread.CurrentThread;
@@ -77,7 +77,7 @@ namespace Hyena
if (!InMainThread) {
var reset_event = new System.Threading.ManualResetEvent (false);
- Banshee.ServiceStack.Application.Invoke (delegate {
+ ProxyToMainHandler (delegate {
try {
handler ();
} finally {
@@ -94,7 +94,6 @@ namespace Hyena
public static void ProxyToMain (InvokeHandler handler)
{
if (!InMainThread) {
- //Banshee.ServiceStack.Application.Invoke (handler);
ProxyToMainHandler (handler);
} else {
handler ();
diff --git a/src/Libraries/Hyena/Hyena/XdgBaseDirectorySpec.cs b/src/Libraries/Hyena/Hyena/XdgBaseDirectorySpec.cs
index 701e0c1..b190f8d 100644
--- a/src/Libraries/Hyena/Hyena/XdgBaseDirectorySpec.cs
+++ b/src/Libraries/Hyena/Hyena/XdgBaseDirectorySpec.cs
@@ -78,5 +78,17 @@ namespace Hyena
return Path.Combine (home_dir, fallback);
}
+
+ public static string GetXdgDirectoryUnderHome (string key, string fallback)
+ {
+ string xdg_dir = XdgBaseDirectorySpec.GetUserDirectory (key, fallback);
+ string home_dir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
+
+ if (xdg_dir == null || xdg_dir == home_dir || !xdg_dir.StartsWith (home_dir)) {
+ xdg_dir = Path.Combine (home_dir, fallback);
+ }
+
+ return xdg_dir;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]