Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add help action linked to Github wiki #875

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Scratch {
public const int FONT_SIZE_MAX = 72;
public const int FONT_SIZE_MIN = 7;
private const uint MAX_SEARCH_TEXT_LENGTH = 255;
private const string HELP_URI = "https://github.com/elementary/code/wiki";

public weak Scratch.Application app { get; construct; }

Expand Down Expand Up @@ -90,6 +91,7 @@ namespace Scratch {
public const string ACTION_ZOOM_OUT = "action_zoom_out";
public const string ACTION_TOGGLE_COMMENT = "action_toggle_comment";
public const string ACTION_TOGGLE_SIDEBAR = "action_toggle_sidebar";
public const string ACTION_HELP = "action_help";

public static Gee.MultiMap<string, string> action_accelerators = new Gee.HashMultiMap<string, string> ();

Expand Down Expand Up @@ -124,7 +126,8 @@ namespace Scratch {
{ ACTION_ZOOM_IN, action_zoom_in },
{ ACTION_ZOOM_OUT, action_zoom_out},
{ ACTION_TOGGLE_COMMENT, action_toggle_comment },
{ ACTION_TOGGLE_SIDEBAR, action_toggle_sidebar }
{ ACTION_TOGGLE_SIDEBAR, action_toggle_sidebar },
{ ACTION_HELP, action_help }
};

public MainWindow (Scratch.Application scratch_app) {
Expand Down Expand Up @@ -166,6 +169,7 @@ namespace Scratch {
action_accelerators.set (ACTION_TOGGLE_COMMENT, "<Control>slash");
action_accelerators.set (ACTION_TOGGLE_SIDEBAR, "F9"); // GNOME
action_accelerators.set (ACTION_TOGGLE_SIDEBAR, "<Control>backslash"); // Atom
action_accelerators.set (ACTION_HELP, "F1");

var provider = new Gtk.CssProvider ();
provider.load_from_resource ("io/elementary/code/Application.css");
Expand Down Expand Up @@ -957,5 +961,13 @@ namespace Scratch {

sidebar.visible = !sidebar.visible;
}

private void action_help () {
try {
Gtk.show_uri (null, HELP_URI, (uint32)(Gdk.CURRENT_TIME));
} catch (Error e) {
warning ("Could not show help uri %s - %s", HELP_URI, e.message);
}
}
}
}