f-spot r4557 - in trunk/src: . Extensions Widgets
- From: sdelcroix svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r4557 - in trunk/src: . Extensions Widgets
- Date: Mon, 3 Nov 2008 13:42:59 +0000 (UTC)
Author: sdelcroix
Date: Mon Nov 3 13:42:59 2008
New Revision: 4557
URL: http://svn.gnome.org/viewvc/f-spot?rev=4557&view=rev
Log:
moving OpenWithMenu from Extensions to Widgets
Added:
trunk/src/Widgets/OpenWithMenu.cs
- copied, changed from r4556, /trunk/src/Extensions/OpenWithMenu.cs
Removed:
trunk/src/Extensions/OpenWithMenu.cs
Modified:
trunk/src/Extensions/PopupCommands.cs
trunk/src/Makefile.am
Modified: trunk/src/Extensions/PopupCommands.cs
==============================================================================
--- trunk/src/Extensions/PopupCommands.cs (original)
+++ trunk/src/Extensions/PopupCommands.cs Mon Nov 3 13:42:59 2008
@@ -54,11 +54,11 @@
public class OpenWith : IMenuGenerator
{
- private OpenWithMenu owm;
+ private Widgets.OpenWithMenu owm;
public Gtk.Menu GetMenu ()
{
- owm = new OpenWithMenu (MainWindow.Toplevel.SelectedMimeTypes);
+ owm = new Widgets.OpenWithMenu (MainWindow.Toplevel.SelectedMimeTypes);
owm.IgnoreApp = "f-spot";
owm.ApplicationActivated += delegate (Gnome.Vfs.MimeApplication app) { MainWindow.Toplevel.HandleOpenWith (this, app); };
return (Gtk.Menu) owm;
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon Nov 3 13:42:59 2008
@@ -70,6 +70,7 @@
$(srcdir)/Widgets/CustomPrintWidget.cs \
$(srcdir)/Widgets/HighlightedBox.cs \
$(srcdir)/Widgets/MenuButton.cs \
+ $(srcdir)/Widgets/OpenWithMenu.cs \
$(srcdir)/Widgets/Rating.cs \
$(srcdir)/Widgets/SaneTreeView.cs \
$(srcdir)/Widgets/ScrolledView.cs
@@ -123,7 +124,6 @@
$(srcdir)/Extensions/IMenuGenerator.cs \
$(srcdir)/Extensions/IService.cs \
$(srcdir)/Extensions/MenuNode.cs \
- $(srcdir)/Extensions/OpenWithMenu.cs \
$(srcdir)/Extensions/CommandMenuItemNode.cs \
$(srcdir)/Extensions/ComplexMenuItemNode.cs \
$(srcdir)/Extensions/PhotoSelectionCondition.cs \
Copied: trunk/src/Widgets/OpenWithMenu.cs (from r4556, /trunk/src/Extensions/OpenWithMenu.cs)
==============================================================================
--- /trunk/src/Extensions/OpenWithMenu.cs (original)
+++ trunk/src/Widgets/OpenWithMenu.cs Mon Nov 3 13:42:59 2008
@@ -17,67 +17,67 @@
using Gdk;
using Mono.Unix;
-namespace FSpot.Extensions {
+namespace FSpot.Widgets {
public class OpenWithMenu: Gtk.Menu {
public delegate void OpenWithHandler (Gnome.Vfs.MimeApplication app);
public event OpenWithHandler ApplicationActivated;
-
+
public delegate string [] MimeFetcher ();
private MimeFetcher mime_fetcher;
-
+
private string [] mime_types;
private bool populated = false;
-
+
private string ignore_app = null;
public string IgnoreApp {
get { return ignore_app; }
set { ignore_app = value; }
}
-
+
private bool show_icons = false;
public bool ShowIcons {
get { return show_icons; }
set { show_icons = value; }
}
-
+
private bool hide_invalid = true;
public bool HideInvalid {
get { return hide_invalid; }
set { hide_invalid = value; }
}
-
+
static OpenWithMenu () {
Gnome.Vfs.Vfs.Initialize ();
}
-
+
public OpenWithMenu (MimeFetcher mime_fetcher)
{
this.mime_fetcher = mime_fetcher;
}
-
+
public void Populate (object sender, EventArgs args)
{
string [] mime_types = mime_fetcher ();
-
+
//foreach (string mime in mime_types)
// System.Console.WriteLine ("Populating open with menu for {0}", mime);
-
+
if (this.mime_types != mime_types && populated) {
populated = false;
-
+
Widget [] dead_pool = Children;
for (int i = 0; i < dead_pool.Length; i++)
dead_pool [i].Destroy ();
}
-
+
if (populated)
return;
-
+
ArrayList union, intersection;
ApplicationsFor (this, mime_types, out union, out intersection);
-
+
ArrayList list = (HideInvalid) ? intersection : union;
-
+
foreach (Gnome.Vfs.MimeApplication app in list) {
//System.Console.WriteLine ("Adding app {0} to open with menu (binary name = {1}", app.Name, app.BinaryName);
//System.Console.WriteLine ("Desktop file path: {0}, id : {1}", app.DesktopFilePath);
@@ -87,54 +87,54 @@
i.Sensitive = (HideInvalid || intersection.Contains (app));
Append (i);
}
-
+
if (Children.Length == 0) {
MenuItem none = new Gtk.MenuItem (Catalog.GetString ("No applications available"));
none.Sensitive = false;
Append (none);
}
-
+
ShowAll ();
-
+
populated = true;
}
-
+
private static void ApplicationsFor (OpenWithMenu menu, string [] mime_types, out ArrayList union, out ArrayList intersection)
{
//Console.WriteLine ("Getting applications");
union = new ArrayList ();
intersection = new ArrayList ();
-
+
if (mime_types == null || mime_types.Length < 1)
return;
-
+
bool first = true;
foreach (string mime_type in mime_types) {
if (mime_type == null)
continue;
-
+
Gnome.Vfs.MimeApplication [] apps = Gnome.Vfs.Mime.GetAllApplications (mime_type);
for (int i = 0; i < apps.Length; i++) {
apps [i] = apps [i].Copy ();
}
-
+
foreach (Gnome.Vfs.MimeApplication app in apps) {
// Skip apps that don't take URIs
if (! app.SupportsUris ())
continue;
-
+
// Skip apps that we were told to ignore
if (menu.IgnoreApp != null)
if (app.BinaryName.IndexOf (menu.IgnoreApp) != -1)
continue;
-
+
if (! union.Contains (app))
union.Add (app);
-
+
if (first)
intersection.Add (app);
}
-
+
if (! first) {
for (int i = 0; i < intersection.Count; i++) {
Gnome.Vfs.MimeApplication app = intersection [i] as Gnome.Vfs.MimeApplication;
@@ -144,40 +144,40 @@
}
}
}
-
+
first = false;
}
}
-
+
private void HandleItemActivated (object sender, EventArgs args)
{
AppMenuItem app = (sender as AppMenuItem);
-
+
if (ApplicationActivated != null)
ApplicationActivated (app.App);
}
-
+
private class AppMenuItem : ImageMenuItem {
public Gnome.Vfs.MimeApplication App;
-
+
public AppMenuItem (OpenWithMenu menu, Gnome.Vfs.MimeApplication mime_application) : base (mime_application.Name)
{
App = mime_application;
-
+
if (menu.ShowIcons) {
if (mime_application.Icon != null) {
- Gdk.Pixbuf pixbuf = null;
-
+ Gdk.Pixbuf pixbuf = null;
+
try {
if (mime_application.Icon.StartsWith ("/"))
pixbuf = new Gdk.Pixbuf (mime_application.Icon, 16, 16);
- else
+ else
pixbuf = IconTheme.Default.LoadIcon (mime_application.Icon,
16, (IconLookupFlags)0);
} catch (System.Exception) {
pixbuf = null;
}
-
+
if (pixbuf != null)
Image = new Gtk.Image (pixbuf);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]