First half of #5084. This adds the framework for the help system.

This commit is contained in:
Nate Lillich 2012-04-25 12:16:56 -07:00
parent ff88b2cec5
commit e63bf0fa70
6 changed files with 55 additions and 4 deletions

View file

@ -22,6 +22,7 @@ add_subdirectory(src)
add_subdirectory(icons)
add_subdirectory(sql)
add_subdirectory(ui)
add_subdirectory(help)
#
# Install geary.desktop

8
help/CMakeLists.txt Normal file
View file

@ -0,0 +1,8 @@
set(HELP_DEST share/gnome/help/geary/C)
set(HELP_FILES
index.page
)
install(FILES ${HELP_FILES} DESTINATION ${HELP_DEST})

5
help/index.page Normal file
View file

@ -0,0 +1,5 @@
<page xmlns="http://projectmallard.org/1.0/" type="guide" id="index">
<title>Geary Help</title>
<p>Documentation coming soon</p>
</page>

View file

@ -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() {

View file

@ -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,

View file

@ -2,6 +2,7 @@
<popup name="ToolbarMenu">
<menuitem name="Preferences" action="GearyPreferences" />
<separator />
<menuitem name="Help" action="GearyHelp" />
<menuitem name="About" action="GearyAbout" />
<separator />
<menuitem name="Quit" action="GearyQuit" />