[f-spot] Refactored main method and added CleanRoomStartup.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [f-spot] Refactored main method and added CleanRoomStartup.
- Date: Tue, 22 Jun 2010 07:16:55 +0000 (UTC)
commit 49f831c57f93209641fd515781f8ee1a536083b4
Author: Evan Briones <erbriones gmail com>
Date: Sun Jun 20 17:10:01 2010 -0700
Refactored main method and added CleanRoomStartup.
https://bugzilla.gnome.org/show_bug.cgi?id=622247
build/build.environment.mk | 4 +-
src/main.cs | 108 +++++++++++++++++++------------------------
2 files changed, 50 insertions(+), 62 deletions(-)
---
diff --git a/build/build.environment.mk b/build/build.environment.mk
index b74c261..763fcf0 100644
--- a/build/build.environment.mk
+++ b/build/build.environment.mk
@@ -79,7 +79,7 @@ LINK_HYENA_DATA_SQLITE_DEPS = $(REF_HYENA_DATA_SQLITE) $(LINK_HYENA_DATA_SQLITE)
# Hyena.Gui
REF_HYENA_GUI = $(LINK_HYENA_DEPS)
LINK_HYENA_GUI = -r:$(DIR_BIN)/Hyena.Gui.dll
-LINK_HENA_GUI_DEPS = $(REF_HYENA_GUI) $(LINK_HYENA_GUI)
+LINK_HYENA_GUI_DEPS = $(REF_HYENA_GUI) $(LINK_HYENA_GUI)
# FSpot.Cms
REF_FSPOT_CMS = $(LINK_GTK)
@@ -126,7 +126,7 @@ REF_FSPOT = $(LINK_FSPOT_WIDGETS_DEPS) $(LINK_FSPOT_PLATFORM_DEPS) $(LINK_FSPOT_
$(LINK_GLIB) $(LINK_MONO_ADDINS_DEPS) $(LINK_UNIQUE_DEPS) $(LINK_MONO_ADDINS_SETUP_DEPS) \
$(LINK_SEMWEB_DEPS) $(LINK_GLADE) $(LINK_MONODATA) $(LINK_MONO_DATA_SQLITECLIENT) \
$(LINK_MONO_ADDINS_GUI_DEPS) $(LINK_FSPOT_JOB_SCHEDULER_DEPS) $(LINK_ICSHARP_ZIP_LIB) \
- $(LINK_GNOME)
+ $(LINK_GNOME) $(LINK_HYENA_GUI_DEPS)
# FIXME: do not link executables
LINK_FSPOT = -r:$(DIR_BIN)/f-spot.exe
LINK_FSPOT_DEPS = $(REF_FSPOT) $(LINK_FSPOT)
diff --git a/src/main.cs b/src/main.cs
index 81684fb..a95625c 100644
--- a/src/main.cs
+++ b/src/main.cs
@@ -14,6 +14,7 @@ using FSpot.UI.Dialog;
using FSpot.Extensions;
using Hyena;
using Hyena.CommandLine;
+using Hyena.Gui;
namespace FSpot
{
@@ -133,7 +134,7 @@ namespace FSpot
{
args = FixArgs (args);
- Unix.SetProcessName (Defines.PACKAGE);
+ ApplicationContext.TrySetProcessName (Defines.PACKAGE);
ThreadAssist.InitializeMainThread ();
ThreadAssist.ProxyToMainHandler = RunIdle;
@@ -145,7 +146,7 @@ namespace FSpot
bool shutdown = false;
bool view = false;
bool slideshow = false;
- string import_uri = null;
+ bool import = false;
GLib.GType.Init ();
Catalog.Init ("f-spot", Defines.LOCALE_DIR);
@@ -205,31 +206,11 @@ namespace FSpot
}
}
- if (ApplicationContext.CommandLine.Contains ("import")) {
- string dir = ApplicationContext.CommandLine ["import"];
-
- if (!string.IsNullOrEmpty (dir))
- {
- import_uri = dir;
- } else {
- Log.Error ("f-spot: -import option takes one argument");
- return 1;
- }
- }
+ if (ApplicationContext.CommandLine.Contains ("import"))
+ import = true;
- List <string> uris = new List <string> ();
- if (ApplicationContext.CommandLine.Contains ("view")) {
+ if (ApplicationContext.CommandLine.Contains ("view"))
view = true;
- var items = ApplicationContext.CommandLine.Files;
-
- if (items.Count > 0)
- {
- uris = new List<string> (items);
- } else {
- Log.Error ("f-spot: -view option takes at least one argument");
- return 1;
- }
- }
if (ApplicationContext.CommandLine.Contains ("debug")) {
Log.Debugging = true;
@@ -250,9 +231,9 @@ namespace FSpot
}
// Validate command line options
- if ( (import_uri != null && (view || shutdown || slideshow)) ||
+ if ((import && (view || shutdown || slideshow)) ||
(view && (shutdown || slideshow)) ||
- (shutdown && slideshow) )
+ (shutdown && slideshow))
{
Log.Error ("Can't mix -import, -view, -shutdown or -slideshow");
return 1;
@@ -297,41 +278,48 @@ namespace FSpot
};
} catch {}
- try {
- if (slideshow == true) {
- App.Instance.Slideshow (null);
- } else if (shutdown) {
- try {
- App.Instance.Shutdown ();
- } catch (System.Exception) { // trap errors
- }
- System.Environment.Exit (0);
- } else if (view) {
- UriList list = new UriList ();
- foreach (string s in uris)
- list.AddUnknown (s);
- if (list.Count == 0) {
- ShowHelp ();
- return 1;
- }
- App.Instance.View (list);
- } else if (import_uri != null) {
- App.Instance.Import (import_uri);
- } else {
- App.Instance.Organize ();
+ CleanRoomStartup.Startup (Startup);
+
+ return 0;
+ }
+
+ static void Startup ()
+ {
+ if (ApplicationContext.CommandLine.Contains ("slideshow"))
+ App.Instance.Slideshow (null);
+ else if (ApplicationContext.CommandLine.Contains ("shutdown"))
+ App.Instance.Shutdown ();
+ else if (ApplicationContext.CommandLine.Contains ("view")) {
+ if (ApplicationContext.CommandLine.Files.Count == 0) {
+ Log.Error ("f-spot: -view option takes at least one argument");
+ System.Environment.Exit (1);
+ }
+
+ var list = new UriList ();
+
+ foreach (var f in ApplicationContext.CommandLine.Files)
+ list.AddUnknown (f);
+
+ if (list.Count == 0) {
+ ShowHelp ();
+ System.Environment.Exit (1);
}
-
- if (App.Instance.IsRunning)
- return 0;
+
+ App.Instance.View (list);
+ } else if (ApplicationContext.CommandLine.Contains ("import")) {
+ string dir = ApplicationContext.CommandLine ["import"];
+
+ if (string.IsNullOrEmpty (dir)) {
+ Log.Error ("f-spot: -import option takes one argument");
+ System.Environment.Exit (1);
+ }
+
+ App.Instance.Import (dir);
+ } else
+ App.Instance.Organize ();
+
+ if (!App.Instance.IsRunning)
Gtk.Application.Run ();
- } catch (System.Exception e) {
- Log.Exception (e);
- ExceptionDialog dlg = new ExceptionDialog(e);
- dlg.Run();
- dlg.Destroy();
- System.Environment.Exit(1);
- }
- return 0;
}
public static void RunIdle (InvokeHandler handler)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]