From e63bf0fa7029c971cfb6fd36530f84f0399a3d91 Mon Sep 17 00:00:00 2001 From: Nate Lillich Date: Wed, 25 Apr 2012 12:16:56 -0700 Subject: [PATCH] First half of #5084. This adds the framework for the help system. --- CMakeLists.txt | 1 + help/CMakeLists.txt | 8 +++++++ help/index.page | 5 +++++ src/client/geary-application.vala | 8 +++++-- src/client/geary-controller.vala | 36 +++++++++++++++++++++++++++++-- ui/toolbar_menu.ui | 1 + 6 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 help/CMakeLists.txt create mode 100644 help/index.page diff --git a/CMakeLists.txt b/CMakeLists.txt index c04cd4c0..76ab74ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ add_subdirectory(src) add_subdirectory(icons) add_subdirectory(sql) add_subdirectory(ui) +add_subdirectory(help) # # Install geary.desktop diff --git a/help/CMakeLists.txt b/help/CMakeLists.txt new file mode 100644 index 00000000..51f72197 --- /dev/null +++ b/help/CMakeLists.txt @@ -0,0 +1,8 @@ +set(HELP_DEST share/gnome/help/geary/C) + +set(HELP_FILES + index.page +) + +install(FILES ${HELP_FILES} DESTINATION ${HELP_DEST}) + diff --git a/help/index.page b/help/index.page new file mode 100644 index 00000000..3cc4e0c2 --- /dev/null +++ b/help/index.page @@ -0,0 +1,5 @@ + + Geary Help +

Documentation coming soon

+
+ diff --git a/src/client/geary-application.vala b/src/client/geary-application.vala index 315ae46b..50af79f8 100644 --- a/src/client/geary-application.vala +++ b/src/client/geary-application.vala @@ -128,7 +128,7 @@ along with Geary; if not, write to the Free Software Foundation, Inc., public override int startup() { exec_dir = (File.new_for_path(Environment.find_program_in_path(args[0]))).get_parent(); - Configuration.init(GearyApplication.instance.get_install_dir() != null, GSETTINGS_DIR); + Configuration.init(is_installed(), GSETTINGS_DIR); int result = base.startup(); result = parse_arguments(args); @@ -286,7 +286,11 @@ along with Geary; if not, write to the Free Software Foundation, Inc., public File get_exec_dir() { return exec_dir; } - + + public bool is_installed() { + return exec_dir.has_prefix(File.new_for_path(INSTALL_PREFIX)); + } + // Returns the installation directory, or null if we're running outside of the installation // directory. public File? get_install_dir() { diff --git a/src/client/geary-controller.vala b/src/client/geary-controller.vala index 9efe33c1..6d7a53b7 100644 --- a/src/client/geary-controller.vala +++ b/src/client/geary-controller.vala @@ -35,6 +35,7 @@ public class GearyController { } // Named actions. + public const string ACTION_HELP = "GearyHelp"; public const string ACTION_ABOUT = "GearyAbout"; public const string ACTION_QUIT = "GearyQuit"; public const string ACTION_NEW_MESSAGE = "GearyNewMessage"; @@ -126,7 +127,11 @@ public class GearyController { null, on_preferences }; prefs.label = _("_Preferences"); entries += prefs; - + + Gtk.ActionEntry help = { ACTION_HELP, Gtk.Stock.HELP, TRANSLATABLE, null, null, on_help }; + help.label = _("_Help"); + entries += help; + Gtk.ActionEntry about = { ACTION_ABOUT, Gtk.Stock.ABOUT, TRANSLATABLE, null, null, on_about }; about.label = _("_About"); entries += about; @@ -651,7 +656,34 @@ public class GearyController { public void on_quit() { GearyApplication.instance.exit(); } - + + private void on_help() { + try { + if (GearyApplication.instance.is_installed()) { + Gtk.show_uri(null, "ghelp:geary", Gdk.CURRENT_TIME); + } else { + Pid pid; + File exec_dir = GearyApplication.instance.get_exec_dir(); + string[] argv = new string[3]; + argv[0] = "gnome-help"; + argv[1] = exec_dir.get_parent().get_child("help").get_path(); + argv[2] = null; + if (!Process.spawn_async(exec_dir.get_path(), argv, null, + SpawnFlags.SEARCH_PATH | SpawnFlags.STDERR_TO_DEV_NULL, null, out pid)) { + debug("Failed to launch help locally."); + } + } + } catch (Error error) { + debug("Error showing help: %s", error.message); + Gtk.Dialog dialog = new Gtk.Dialog.with_buttons("Error", null, + Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.Stock.CLOSE, Gtk.ResponseType.CLOSE, null); + dialog.response.connect(() => { dialog.destroy(); }); + dialog.get_content_area().add(new Gtk.Label("Error showing help: %s".printf(error.message))); + dialog.show_all(); + dialog.run(); + } + } + public void on_about() { Gtk.show_about_dialog(main_window, "program-name", GearyApplication.NAME, diff --git a/ui/toolbar_menu.ui b/ui/toolbar_menu.ui index 873b4596..8b78c2bb 100644 --- a/ui/toolbar_menu.ui +++ b/ui/toolbar_menu.ui @@ -2,6 +2,7 @@ +