[california/wip/732302-help] Launch help with F1 key
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/732302-help] Launch help with F1 key
- Date: Thu, 18 Sep 2014 23:57:06 +0000 (UTC)
commit da2136c415126b8471b93c42b141741c6c8a84c2
Author: Jim Nelson <jim yorba org>
Date: Thu Sep 18 16:56:33 2014 -0700
Launch help with F1 key
Also, Quick Add help button goes directly to Quick Add topic.
help/Makefile.am | 5 +++-
src/Makefile.am | 4 +++
src/application/california-application.vala | 35 +++++++++++++++++++++++---
src/host/host-quick-create-event.vala | 2 +-
4 files changed, 40 insertions(+), 6 deletions(-)
---
diff --git a/help/Makefile.am b/help/Makefile.am
index e69a8c2..6aa364a 100644
--- a/help/Makefile.am
+++ b/help/Makefile.am
@@ -1,5 +1,7 @@
@YELP_HELP_RULES@
+NULL =
+
HELP_ID = california
HELP_MEDIA = \
@@ -22,9 +24,10 @@ HELP_FILES = \
gnome-help.sct \
index.page \
legal.xml \
- schematron.sh \
$(NULL)
+HELP_LINGUAS =
+
GITIGNOREFILES = \
Makefile \
Makefile.in \
diff --git a/src/Makefile.am b/src/Makefile.am
index c619de6..5b025d7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -236,9 +236,13 @@ california_VALAFLAGS = \
--pkg langinfo \
$(NULL)
+# Note that code for SOURCE_ROOT_DIR must be changed if this file is moved to different directory
+SOURCE_ROOT_DIR = `cd ..; pwd`
+
california_CFLAGS = \
-DGETTEXT_PACKAGE=\""california"\" \
-DPREFIX=\"$(prefix)\" \
+ -DSOURCE_ROOT_DIR=\"$(SOURCE_ROOT_DIR)\" \
$(NULL)
LIBS = \
diff --git a/src/application/california-application.vala b/src/application/california-application.vala
index 605b941..d65c5d9 100644
--- a/src/application/california-application.vala
+++ b/src/application/california-application.vala
@@ -7,6 +7,7 @@
extern const string PACKAGE_VERSION;
extern const string GETTEXT_PACKAGE;
extern const string PREFIX;
+extern const string SOURCE_ROOT_DIR;
namespace California {
@@ -22,7 +23,6 @@ public class Application : Gtk.Application {
public const string WEBSITE_NAME = _("Visit California's home page");
public const string WEBSITE_URL = "https://wiki.gnome.org/Apps/California";
public const string BUGREPORT_URL = "https://bugzilla.gnome.org/enter_bug.cgi?product=california";
- public const string QUICK_ADD_HELP_URL = "https://wiki.gnome.org/Apps/California/HowToUseQuickAdd";
public const string ID = "org.yorba.california";
public const string ICON_NAME = "x-office-calendar";
@@ -277,9 +277,36 @@ public class Application : Gtk.Application {
private void on_help() {
try {
- Gtk.show_uri(null, WEBSITE_URL, Gdk.CURRENT_TIME);
- } catch (Error error) {
- message("Error opening help URL: %s", error.message);
+ help();
+ } catch (Error err) {
+ error_message(main_window, err.message);
+ }
+ }
+
+ /**
+ * Launch help for the specified topic.
+ *
+ * topic should be the name of the help page without its extension (i.e. no .page).
+ *
+ * If null, the main help page will be launched.
+ */
+ public void help(string? topic = null) throws Error {
+ if (is_installed) {
+ Gtk.show_uri(null,
+ String.is_empty(topic) ? "help:california" : "help:california/%s".printf(topic),
+ Gdk.CURRENT_TIME);
+ } else {
+ string path = String.is_empty(topic)
+ ? "%s/help/C/".printf(SOURCE_ROOT_DIR)
+ : "%s/help/C/%s.page".printf(SOURCE_ROOT_DIR, topic);
+
+ string[] argv = { "gnome-help", path };
+
+ Pid pid;
+ 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.");
+ }
}
}
diff --git a/src/host/host-quick-create-event.vala b/src/host/host-quick-create-event.vala
index c30fe73..2624cc5 100644
--- a/src/host/host-quick-create-event.vala
+++ b/src/host/host-quick-create-event.vala
@@ -94,7 +94,7 @@ public class QuickCreateEvent : Gtk.Grid, Toolkit.Card {
[GtkCallback]
private void on_help_button_clicked() {
try {
- Gtk.show_uri(null, Application.QUICK_ADD_HELP_URL, Gtk.get_current_event_time());
+ Application.instance.help("cal-event-quick-add");
} catch (Error err) {
report_error(_("Error opening help: %s").printf(err.message));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]