~ted/ubuntu/lucid/tomboy/with-patch

« back to all changes in this revision

Viewing changes to Tomboy/Tomboy.cs

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2008-01-15 11:32:52 UTC
  • mfrom: (1.1.31 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20080115113252-p59wg7nqkl6vcg7a
Tags: 0.9.4-0ubuntu1
* New upstream release (LP: #181798)
  - Fix crash during note deletion 
  - Fix null reference exception 
  - Fix mnemonics in sync preferences dialog 
  - Fix fuse mount timeout for sync 
  - New port option for SSH sync 
  - New multi-select notes support in Search All Notes window
  - New config dialog for Insert Timestamp Add-in 
  - New gconf preference, middle-click paste on Tomboy icon
  - New gconf preference, disable ESC closing notes 
  - New paragraph within a bullet with SHIFT + ENTER
  - New bug numbers as links in Export to HTML 
  - New notebook notes can be created off notebook's context menu.
  - New sketching add-in (still incomplete, --enable-sketching)
  - New "Unfiled Notes" item to notebook list 
  - New drag note to "Unfiled Notes" to remove from notebook 
 * debian/tomboy.menu: updated

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
using Tomboy.Sync;
8
8
 
9
 
namespace Tomboy 
 
9
namespace Tomboy
10
10
{
11
11
        public class Tomboy : Application
12
12
        {
17
17
                static bool is_panel_applet = false;
18
18
                static PreferencesDialog prefs_dlg;
19
19
                static SyncDialog sync_dlg;
20
 
#if ENABLE_DBUS
 
20
                #if ENABLE_DBUS
21
21
                static RemoteControl remote_control;
22
 
#endif
 
22
                #endif
23
23
 
24
 
                public static void Main (string [] args) 
 
24
                public static void Main (string [] args)
25
25
                {
26
26
                        // Initialize GETTEXT
27
27
                        Catalog.Init ("tomboy", Defines.GNOME_LOCALE_DIR);
28
 
                        
 
28
 
29
29
                        TomboyCommandLine cmd_line = new TomboyCommandLine (args);
30
30
 
31
 
#if ENABLE_DBUS // Run command-line earlier with DBus enabled
 
31
                        #if ENABLE_DBUS // Run command-line earlier with DBus enabled
32
32
                        if (cmd_line.NeedsExecute) {
33
33
                                // Execute args at an existing tomboy instance...
34
34
                                cmd_line.Execute ();
35
35
                                return;
36
36
                        }
37
 
#endif // ENABLE_DBUS
 
37
                        #endif // ENABLE_DBUS
38
38
 
39
39
                        Initialize ("tomboy", "Tomboy", "tomboy", args);
40
40
 
41
 
//                      PluginManager.CheckPluginUnloading = cmd_line.CheckPluginUnloading;
 
41
//   PluginManager.CheckPluginUnloading = cmd_line.CheckPluginUnloading;
42
42
 
43
43
                        // Create the default note manager instance.
44
44
                        string note_path = GetNotePath (cmd_line.NotePath);
48
48
 
49
49
                        // Register the manager to handle remote requests.
50
50
                        RegisterRemoteControl (manager);
51
 
                        
 
51
 
52
52
                        SetupGlobalActions ();
 
53
                        ActionManager am = Tomboy.ActionManager;
53
54
 
54
 
#if !ENABLE_DBUS
55
 
                        if (cmd_line.NeedsExecute) {
56
 
                                cmd_line.Execute ();
57
 
                        }
58
 
#endif
59
 
                        ActionManager am = Tomboy.ActionManager;
60
 
                        
61
55
                        ApplicationAddin [] addins =
62
 
                                manager.AddinManager.GetApplicationAddins ();
 
56
                                manager.AddinManager.GetApplicationAddins ();
63
57
                        foreach (ApplicationAddin addin in addins) {
64
58
                                addin.Initialize ();
65
59
                        }
66
60
 
 
61
                        #if !ENABLE_DBUS
 
62
                        if (cmd_line.NeedsExecute) {
 
63
                                cmd_line.Execute ();
 
64
                        }
 
65
                        #endif
 
66
 
67
67
                        if (cmd_line.UsePanelApplet) {
68
68
                                tray_icon_showing = true;
69
69
                                is_panel_applet = true;
75
75
                                RegisterPanelAppletFactory ();
76
76
                        } else {
77
77
                                RegisterSessionManagerRestart (
78
 
                                        Environment.GetEnvironmentVariable ("TOMBOY_WRAPPER_PATH"),
79
 
                                        args,
80
 
                                        new string [] { "TOMBOY_PATH=" + note_path  });
 
78
                                        Environment.GetEnvironmentVariable ("TOMBOY_WRAPPER_PATH"),
 
79
                                        args,
 
80
                                        new string [] { "TOMBOY_PATH=" + note_path  });
81
81
                                StartTrayIcon ();
82
82
                        }
83
 
                        
 
83
 
84
84
                        Logger.Log ("All done.  Ciao!");
85
85
                }
86
86
 
87
87
                static string GetNotePath (string override_path)
88
88
                {
89
89
                        // Default note location, as specified in --note-path or $TOMBOY_PATH
90
 
                        string note_path = 
91
 
                                (override_path != null) ? 
92
 
                                       override_path : 
93
 
                                       Environment.GetEnvironmentVariable ("TOMBOY_PATH");
 
90
                        string note_path =
 
91
                                (override_path != null) ?
 
92
                                override_path :
 
93
                                Environment.GetEnvironmentVariable ("TOMBOY_PATH");
94
94
                        if (note_path == null)
95
95
                                note_path = "~/.tomboy";
96
96
 
109
109
                {
110
110
                        // Create the tray icon and run the main loop
111
111
                        tray_icon = new TomboyTrayIcon (DefaultNoteManager);
112
 
                        
 
112
 
113
113
                        // Give the TrayIcon 2 seconds to appear.  If it
114
114
                        // doesn't by then, open the SearchAllNotes window.
115
115
                        tray_icon.Embedded += TrayIconEmbedded;
118
118
 
119
119
                        StartMainLoop ();
120
120
                }
121
 
                
 
121
 
122
122
                // This event is signaled when Tomboy's TrayIcon is added to the
123
123
                // Notification Area.  If it's never signaled, the Notification Area
124
124
                // is not available.
126
126
                {
127
127
                        tray_icon_showing = true;
128
128
                }
129
 
                
 
129
 
130
130
                static bool CheckTrayIconShowing ()
131
131
                {
132
132
                        // Check to make sure the tray icon is showing.  If it's not,
135
135
                        // can still use Tomboy.
136
136
                        if (tray_icon_showing == false)
137
137
                                ActionManager ["ShowSearchAllNotesAction"].Activate ();
138
 
                        
 
138
 
139
139
                        return false; // prevent GLib.Timeout from calling this method again
140
140
                }
141
141
 
142
142
                static void RegisterRemoteControl (NoteManager manager)
143
143
                {
144
 
#if ENABLE_DBUS
 
144
                        #if ENABLE_DBUS
145
145
                        try {
146
146
                                remote_control = RemoteControlProxy.Register (manager);
147
147
                                if (remote_control != null) {
161
161
                                }
162
162
                        } catch (Exception e) {
163
163
                                Logger.Log ("Tomboy remote control disabled (DBus exception): {0}",
164
 
                                                   e.Message);
 
164
                                            e.Message);
165
165
                        }
166
 
#endif
 
166
                        #endif
167
167
                }
168
168
 
169
169
                // These actions can be called from anywhere in Tomboy
179
179
                        am ["ShowSearchAllNotesAction"].Activated += OpenSearchAll;
180
180
                        am ["NoteSynchronizationAction"].Activated += OpenNoteSyncWindow;
181
181
                }
182
 
                
 
182
 
183
183
                static void OnNewNoteAction (object sender, EventArgs args)
184
184
                {
185
185
                        try {
186
186
                                Note new_note = manager.Create ();
187
187
                                new_note.Window.Show ();
188
188
                        } catch (Exception e) {
189
 
                                HIGMessageDialog dialog = 
190
 
                                        new HIGMessageDialog (
191
 
                                                null,
192
 
                                                0,
193
 
                                                Gtk.MessageType.Error,
194
 
                                                Gtk.ButtonsType.Ok,
195
 
                                                Catalog.GetString ("Cannot create new note"),
196
 
                                                e.Message);
 
189
                                HIGMessageDialog dialog =
 
190
                                        new HIGMessageDialog (
 
191
                                        null,
 
192
                                        0,
 
193
                                        Gtk.MessageType.Error,
 
194
                                        Gtk.ButtonsType.Ok,
 
195
                                        Catalog.GetString ("Cannot create new note"),
 
196
                                        e.Message);
197
197
                                dialog.Run ();
198
198
                                dialog.Destroy ();
199
199
                        }
200
200
                }
201
 
                
 
201
 
202
202
                static void OpenNoteSyncWindow (object sender, EventArgs args)
203
203
                {
204
204
                        if (sync_dlg == null) {
205
205
                                sync_dlg = new SyncDialog ();
206
206
                                sync_dlg.Response += OnSyncDialogResponse;
207
207
                        }
208
 
                        
 
208
 
209
209
                        sync_dlg.Present ();
210
210
                }
211
 
                
 
211
 
212
212
                static void OnSyncDialogResponse (object sender, Gtk.ResponseArgs args)
213
213
                {
214
214
                        ((Gtk.Widget) sender).Destroy ();
215
215
                        sync_dlg = null;
216
216
                }
217
 
                         
218
 
            static void OnQuitTomboyAction (object sender, EventArgs args)
 
217
 
 
218
                static void OnQuitTomboyAction (object sender, EventArgs args)
219
219
                {
220
220
                        if (Tomboy.IsPanelApplet)
221
221
                                return; // Ignore the quit action
223
223
                        Logger.Log ("Quitting Tomboy.  Ciao!");
224
224
                        Exit (0);
225
225
                }
226
 
                
 
226
 
227
227
                static void OnShowPreferencesAction (object sender, EventArgs args)
228
228
                {
229
229
                        if (prefs_dlg == null) {
238
238
                        ((Gtk.Widget) sender).Destroy ();
239
239
                        prefs_dlg = null;
240
240
                }
241
 
                
 
241
 
242
242
                static void OnShowHelpAction (object sender, EventArgs args)
243
243
                {
244
244
                        // Pass in null for the screen when we're running as a panel applet
245
245
                        GuiUtils.ShowHelp("tomboy.xml", null,
246
 
                                        tray_icon == null ? null : tray_icon.TomboyTray.Screen,
247
 
                                        null);
 
246
                                          tray_icon == null ? null : tray_icon.TomboyTray.Screen,
 
247
                                          null);
248
248
                }
249
 
                
 
249
 
250
250
                static void OnShowAboutAction (object sender, EventArgs args)
251
251
                {
252
252
                        string [] authors = new string [] {
256
256
                                "David Trowbridge <trowbrds@gmail.com>",
257
257
                                "Ryan Lortie <desrt@desrt.ca>",
258
258
                                "Sandy Armstrong <sanfordarmstrong@gmail.com>",
259
 
                                "Sebastian Rittau <srittau@jroger.in-berlin.de>"
 
259
                                "Sebastian Rittau <srittau@jroger.in-berlin.de>",
 
260
                                "Kevin Kubasik <kevin@kubasik.net>"
260
261
                        };
261
262
 
262
263
                        string [] documenters = new string [] {
271
272
                        about.Name = "Tomboy";
272
273
                        about.Version = Defines.VERSION;
273
274
                        about.Logo = GuiUtils.GetIcon ("tomboy", 48);
274
 
                        about.Copyright = 
275
 
                                Catalog.GetString ("Copyright \xa9 2004-2007 Alex Graveley");
 
275
                        about.Copyright =
 
276
                                Catalog.GetString ("Copyright \xa9 2004-2007 Alex Graveley");
276
277
                        about.Comments = Catalog.GetString ("A simple and easy to use desktop " +
277
 
                                                            "note-taking application.");
 
278
                                                            "note-taking application.");
278
279
                        about.Website = Defines.TOMBOY_WEBSITE;
279
280
                        about.WebsiteLabel = Catalog.GetString("Homepage");
280
281
                        about.Authors = authors;
284
285
                        about.Run ();
285
286
                        about.Destroy ();
286
287
                }
287
 
                
 
288
 
288
289
                static void OpenSearchAll (object sender, EventArgs args)
289
290
                {
290
291
                        NoteRecentChanges.GetInstance (manager).Present ();
291
292
                }
292
 
                
 
293
 
293
294
                public static NoteManager DefaultNoteManager
294
295
                {
295
 
                        get { return manager; }
 
296
                        get {
 
297
                                return manager;
 
298
                        }
296
299
                }
297
 
                
 
300
 
298
301
                public static bool TrayIconShowing
299
302
                {
300
 
                        get { return tray_icon_showing; }
 
303
                        get {
 
304
                                return tray_icon_showing;
 
305
                        }
301
306
                }
302
 
                
 
307
 
303
308
                public static bool IsPanelApplet
304
309
                {
305
 
                        get { return is_panel_applet; }
 
310
                        get {
 
311
                                return is_panel_applet;
 
312
                        }
306
313
                }
307
 
                
 
314
 
308
315
                public static TomboyTray Tray
309
316
                {
310
317
                        get {
313
320
                                else
314
321
                                        return tomboy_tray;
315
322
                        }
316
 
                        set { tomboy_tray = value; }
 
323
                        set {
 
324
                                tomboy_tray = value;
 
325
                        }
317
326
                }
318
 
                
 
327
 
319
328
                public static SyncDialog SyncDialog
320
329
                {
321
 
                        get { return sync_dlg; }
 
330
                        get {
 
331
                                return sync_dlg;
 
332
                        }
322
333
                }
323
334
        }
324
335
 
335
346
                string note_path;
336
347
                string search_text;
337
348
                bool open_search;
338
 
//              bool check_plugin_unloading;
 
349
//  bool check_plugin_unloading;
339
350
 
340
351
                public TomboyCommandLine (string [] args)
341
352
                {
344
355
 
345
356
                public bool UsePanelApplet
346
357
                {
347
 
                        get { return panel_applet; }
 
358
                        get {
 
359
                                return panel_applet;
 
360
                        }
348
361
                }
349
362
 
350
363
                public bool NeedsExecute
351
364
                {
352
 
                        get { 
353
 
                                return new_note || 
354
 
                                                open_note_name != null ||
355
 
                                                open_note_uri != null || 
356
 
                                                open_search ||
357
 
                                                open_start_here ||
358
 
                                                open_external_note_path != null;
 
365
                        get {
 
366
                                return new_note ||
 
367
                                open_note_name != null ||
 
368
                                open_note_uri != null ||
 
369
                                open_search ||
 
370
                                open_start_here ||
 
371
                                open_external_note_path != null;
359
372
                        }
360
373
                }
361
374
 
362
375
                public string NotePath
363
376
                {
364
 
                        get { return note_path; }
 
377
                        get {
 
378
                                return note_path;
 
379
                        }
365
380
                }
366
381
 
367
 
//              public bool CheckPluginUnloading
368
 
//              {
369
 
//                      get { return check_plugin_unloading; }
370
 
//              }
 
382
//  public bool CheckPluginUnloading
 
383
//  {
 
384
//   get { return check_plugin_unloading; }
 
385
//  }
371
386
 
372
 
                public static void PrintAbout () 
 
387
                public static void PrintAbout ()
373
388
                {
374
 
            string about = 
375
 
                                Catalog.GetString (
376
 
                                        "Tomboy: A simple, easy to use desktop note-taking " +
377
 
                                        "application.\n" +
378
 
                                        "Copyright (C) 2004-2006 Alex Graveley " +
379
 
                                        "<alex@beatniksoftware.com>\n\n");
 
389
                        string about =
 
390
                                Catalog.GetString (
 
391
                                        "Tomboy: A simple, easy to use desktop note-taking " +
 
392
                                        "application.\n" +
 
393
                                        "Copyright (C) 2004-2006 Alex Graveley " +
 
394
                                        "<alex@beatniksoftware.com>\n\n");
380
395
 
381
396
                        Console.Write (about);
382
397
                }
383
398
 
384
 
                public static void PrintUsage () 
 
399
                public static void PrintUsage ()
385
400
                {
386
 
                        string usage = 
387
 
                                Catalog.GetString (
388
 
                                        "Usage:\n" +
389
 
                                        "  --version\t\t\tPrint version information.\n" +
390
 
                                        "  --help\t\t\tPrint this usage message.\n" +
391
 
                                        "  --note-path [path]\t\tLoad/store note data in this " +
392
 
                                        "directory.\n" +
393
 
                                        "  --search [text]\t\tOpen the search all notes window with " +
394
 
                                        "the search text.\n");
 
401
                        string usage =
 
402
                                Catalog.GetString (
 
403
                                        "Usage:\n" +
 
404
                                        "  --version\t\t\tPrint version information.\n" +
 
405
                                        "  --help\t\t\tPrint this usage message.\n" +
 
406
                                        "  --note-path [path]\t\tLoad/store note data in this " +
 
407
                                        "directory.\n" +
 
408
                                        "  --search [text]\t\tOpen the search all notes window with " +
 
409
                                        "the search text.\n");
395
410
 
396
 
#if ENABLE_DBUS
397
 
                        usage += 
398
 
                                Catalog.GetString (
399
 
                                        "  --new-note\t\t\tCreate and display a new note.\n" +
400
 
                                        "  --new-note [title]\t\tCreate and display a new note, " +
401
 
                                        "with a title.\n" +
402
 
                                        "  --open-note [title/url]\tDisplay the existing note " +
403
 
                                        "matching title.\n" +
404
 
                                        "  --start-here\t\t\tDisplay the 'Start Here' note.\n" +
405
 
                                        "  --highlight-search [text]\tSearch and highlight text " +
406
 
                                        "in the opened note.\n");
407
 
#endif
 
411
                        #if ENABLE_DBUS
 
412
                        usage +=
 
413
                                Catalog.GetString (
 
414
                                        "  --new-note\t\t\tCreate and display a new note.\n" +
 
415
                                        "  --new-note [title]\t\tCreate and display a new note, " +
 
416
                                        "with a title.\n" +
 
417
                                        "  --open-note [title/url]\tDisplay the existing note " +
 
418
                                        "matching title.\n" +
 
419
                                        "  --start-here\t\t\tDisplay the 'Start Here' note.\n" +
 
420
                                        "  --highlight-search [text]\tSearch and highlight text " +
 
421
                                        "in the opened note.\n");
 
422
                        #endif
408
423
 
409
424
// TODO: Restore this functionality with addins
410
 
//                      usage +=
411
 
//                              Catalog.GetString (
412
 
//                                      "  --check-plugin-unloading\tCheck if plugins are " +
413
 
//                                      "unloaded properly.\n");
 
425
//   usage +=
 
426
//    Catalog.GetString (
 
427
//     "  --check-plugin-unloading\tCheck if plugins are " +
 
428
//     "unloaded properly.\n");
414
429
 
415
 
#if !ENABLE_DBUS
 
430
                        #if !ENABLE_DBUS
416
431
                        usage += Catalog.GetString ("D-BUS remote control disabled.\n");
417
 
#endif
 
432
                        #endif
418
433
 
419
434
                        Console.WriteLine (usage);
420
435
                }
430
445
                                bool quit = false;
431
446
 
432
447
                                switch (args [idx]) {
433
 
#if ENABLE_DBUS
 
448
                                        #if ENABLE_DBUS
434
449
                                case "--new-note":
435
450
                                        // Get optional name for new note...
436
451
                                        if (idx + 1 < args.Length
437
 
                                                        && args [idx + 1] != null
438
 
                                                        && args [idx + 1] != String.Empty
439
 
                                                        && args [idx + 1][0] != '-') {
 
452
                                                        && args [idx + 1] != null
 
453
                                                        && args [idx + 1] != String.Empty
 
454
                                                        && args [idx + 1][0] != '-') {
440
455
                                                new_note_name = args [++idx];
441
456
                                        }
442
457
 
446
461
                                case "--open-note":
447
462
                                        // Get required name for note to open...
448
463
                                        if (idx + 1 >= args.Length ||
449
 
                                                        (args [idx + 1] != null
450
 
                                                                && args [idx + 1] != String.Empty
451
 
                                                                && args [idx + 1][0] == '-')) {
 
464
                                                        (args [idx + 1] != null
 
465
                                                         && args [idx + 1] != String.Empty
 
466
                                                         && args [idx + 1][0] == '-')) {
452
467
                                                PrintUsage ();
453
468
                                                quit = true;
454
469
                                        }
455
470
 
456
471
                                        ++idx;
457
 
                                        
 
472
 
458
473
                                        // If the argument looks like a Uri, treat it like a Uri.
459
474
                                        if (args [idx].StartsWith ("note://tomboy/"))
460
475
                                                open_note_uri = args [idx];
474
489
                                case "--highlight-search":
475
490
                                        // Get required search string to highlight
476
491
                                        if (idx + 1 >= args.Length ||
477
 
                                                        (args [idx + 1] != null
478
 
                                                                && args [idx + 1] != String.Empty
479
 
                                                                && args [idx + 1][0] == '-')) {
 
492
                                                        (args [idx + 1] != null
 
493
                                                         && args [idx + 1] != String.Empty
 
494
                                                         && args [idx + 1][0] == '-')) {
480
495
                                                PrintUsage ();
481
496
                                                quit = true;
482
497
                                        }
484
499
                                        ++idx;
485
500
                                        highlight_search = args [idx];
486
501
                                        break;
487
 
#else
 
502
                                        #else
488
503
                                case "--new-note":
489
504
                                case "--open-note":
490
505
                                case "--start-here":
491
506
                                case "--highlight-search":
492
 
                                        string unknown_opt = 
493
 
                                                Catalog.GetString (
494
 
                                                        "Tomboy: unsupported option '{0}'\n" +
495
 
                                                        "Try 'tomboy --help' for more " +
496
 
                                                        "information.\n" +
497
 
                                                        "D-BUS remote control disabled.");
 
507
                                        string unknown_opt =
 
508
                                                Catalog.GetString (
 
509
                                                        "Tomboy: unsupported option '{0}'\n" +
 
510
                                                        "Try 'tomboy --help' for more " +
 
511
                                                        "information.\n" +
 
512
                                                        "D-BUS remote control disabled.");
498
513
                                        Console.WriteLine (unknown_opt, args [idx]);
499
514
                                        quit = true;
500
515
                                        break;
501
 
#endif // ENABLE_DBUS
 
516
                                        #endif // ENABLE_DBUS
502
517
 
503
518
                                case "--panel-applet":
504
519
                                        panel_applet = true;
505
520
                                        break;
506
521
 
507
522
                                case "--note-path":
508
 
                                        if (idx + 1 >= args.Length || 
509
 
                                                        (args [idx + 1] != null
510
 
                                                                && args [idx + 1] != String.Empty
511
 
                                                                && args [idx + 1][0] == '-')) {
 
523
                                        if (idx + 1 >= args.Length ||
 
524
                                                        (args [idx + 1] != null
 
525
                                                         && args [idx + 1] != String.Empty
 
526
                                                         && args [idx + 1][0] == '-')) {
512
527
                                                PrintUsage ();
513
528
                                                quit = true;
514
529
                                        }
517
532
 
518
533
                                        if (!Directory.Exists (note_path)) {
519
534
                                                Console.WriteLine (
520
 
                                                        "Tomboy: Invalid note path: " +
521
 
                                                        "\"{0}\" does not exist.",
522
 
                                                        note_path);
 
535
                                                        "Tomboy: Invalid note path: " +
 
536
                                                        "\"{0}\" does not exist.",
 
537
                                                        note_path);
523
538
                                                quit = true;
524
539
                                        }
525
540
 
528
543
                                case "--search":
529
544
                                        // Get optional search text...
530
545
                                        if (idx + 1 < args.Length
531
 
                                                        && args [idx + 1] != null
532
 
                                                        && args [idx + 1] != String.Empty
533
 
                                                        && args [idx + 1][0] != '-') {
 
546
                                                        && args [idx + 1] != null
 
547
                                                        && args [idx + 1] != String.Empty
 
548
                                                        && args [idx + 1][0] != '-') {
534
549
                                                search_text = args [++idx];
535
550
                                        }
536
 
                                        
 
551
 
537
552
                                        open_search = true;
538
553
                                        break;
539
554
 
540
 
//                              case "--check-plugin-unloading":
541
 
//                                      check_plugin_unloading = true;
542
 
//                                      break;
 
555
//    case "--check-plugin-unloading":
 
556
//     check_plugin_unloading = true;
 
557
//     break;
543
558
 
544
559
                                case "--version":
545
560
                                        PrintAbout ();
565
580
 
566
581
                public void Execute ()
567
582
                {
568
 
#if ENABLE_DBUS
 
583
                        #if ENABLE_DBUS
569
584
                        RemoteControl remote = null;
570
585
                        try {
571
586
                                remote = RemoteControlProxy.GetInstance ();
572
587
                        } catch (Exception e) {
573
588
                                Logger.Log ("Unable to connect to Tomboy remote control: {0}",
574
 
                                        e.Message);
 
589
                                            e.Message);
575
590
                        }
576
591
 
577
592
                        if (remote == null)
597
612
 
598
613
                        if (open_note_name != null)
599
614
                                open_note_uri = remote.FindNote (open_note_name);
600
 
                        
 
615
 
601
616
                        if (open_note_uri != null) {
602
617
                                if (highlight_search != null)
603
 
                                        remote.DisplayNoteWithSearch (open_note_uri, 
604
 
                                                                      highlight_search);
 
618
                                        remote.DisplayNoteWithSearch (open_note_uri,
 
619
                                                                      highlight_search);
605
620
                                else
606
621
                                        remote.DisplayNote (open_note_uri);
607
622
                        }
608
 
                        
 
623
 
609
624
                        if (open_external_note_path != null) {
610
625
                                string note_id = Path.GetFileNameWithoutExtension (open_external_note_path);
611
626
                                if (note_id != null && note_id != string.Empty) {
612
627
                                        // Attempt to load the note, assuming it might already
613
628
                                        // be part of our notes list.
614
629
                                        if (remote.DisplayNote (
615
 
                                                        string.Format ("note://tomboy/{0}", note_id)) == false) {
 
630
                                                                string.Format ("note://tomboy/{0}", note_id)) == false) {
616
631
 
617
632
                                                StreamReader sr = File.OpenText (open_external_note_path);
618
633
                                                if (sr != null) {
619
634
                                                        string noteTitle = null;
620
635
                                                        string noteXml = sr.ReadToEnd ();
621
 
                                                        
 
636
 
622
637
                                                        // Make sure noteXml is parseable
623
638
                                                        XmlDocument xmlDoc = new XmlDocument ();
624
639
                                                        try {
625
640
                                                                xmlDoc.LoadXml (noteXml);
626
641
                                                        } catch {
627
 
                                                                noteXml = null;
628
 
                                                        }
629
 
                                                        
630
 
                                                        if (noteXml != null) {
 
642
                                                        noteXml = null;
 
643
                                                }
 
644
 
 
645
                                                if (noteXml != null) {
631
646
                                                                noteTitle = NoteArchiver.Instance.GetTitleFromNoteXml (noteXml);
632
647
                                                                if (noteTitle != null) {
633
648
                                                                        // Check for conflicting titles
634
649
                                                                        string baseTitle = (string)noteTitle.Clone ();
635
650
                                                                        for (int i = 1; remote.FindNote (noteTitle) != string.Empty; i++)
636
651
                                                                                noteTitle = baseTitle + " (" + i.ToString() + ")";
637
 
                                                                        
 
652
 
638
653
                                                                        string note_uri = remote.CreateNamedNote (noteTitle);
639
 
                                                                        
 
654
 
640
655
                                                                        // Update title in the note XML
641
656
                                                                        noteXml = NoteArchiver.Instance.GetRenamedNoteXml (noteXml, baseTitle, noteTitle);
642
657
 
651
666
                                        }
652
667
                                }
653
668
                        }
654
 
                        
 
669
 
655
670
                        if (open_search) {
656
671
                                if (search_text != null)
657
672
                                        remote.DisplaySearchWithText (search_text);
658
673
                                else
659
674
                                        remote.DisplaySearch ();
660
675
                        }
661
 
#else
 
676
                        #else
662
677
                        if (open_search) {
663
678
                                NoteRecentChanges recent_changes =
664
 
                                        NoteRecentChanges.GetInstance (Tomboy.DefaultNoteManager);
 
679
                                        NoteRecentChanges.GetInstance (Tomboy.DefaultNoteManager);
665
680
                                if (recent_changes == null)
666
681
                                        return;
667
 
                                
 
682
 
668
683
                                if (search_text != null)
669
684
                                        recent_changes.SearchText = search_text;
670
685
 
671
686
                                recent_changes.Present ();
672
687
                        }
673
 
#endif // ENABLE_DBUS
 
688
                        #endif // ENABLE_DBUS
674
689
                }
675
690
        }
676
691
}