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

Kiosk improvements #445

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
25 changes: 21 additions & 4 deletions core/app.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ namespace Midori {
static bool help_execute = false;
static int inactivity_reset = 0;
static bool incognito = false;
static bool single_app = false;
static bool version = false;
const OptionEntry[] options = {
{ "app", 'a', 0, OptionArg.STRING, ref app, N_("Run ADDRESS as a web application"), N_("ADDRESS") },
{ "single-app", 'S', 0, OptionArg.NONE, ref single_app, N_("With --app, prefer currently open browser window (if any)"), null },
{ "execute", 'e', 0, OptionArg.STRING_ARRAY, ref execute, N_("Execute the specified command"), null },
{ "help-execute", 0, 0, OptionArg.NONE, ref help_execute, N_("List available commands to execute with -e/ --execute"), null },
{ "inactivity-reset", 'i', 0, OptionArg.INT, ref inactivity_reset, N_("Reset Midori after SECONDS seconds of inactivity"), N_("SECONDS") },
Expand Down Expand Up @@ -426,6 +428,7 @@ namespace Midori {
// Propagate options processed in the primary instance
options.insert_value ("app", app ?? "");
options.insert_value ("execute", execute);
options.insert_value ("single-app", single_app);
options.insert_value ("help-execute", help_execute);
options.insert_value ("inactivity-reset", inactivity_reset);
options.insert_value ("private", incognito);
Expand All @@ -438,6 +441,7 @@ namespace Midori {
// Retrieve values for options passed from another process
var options = command_line.get_options_dict ();
app = options.lookup_value ("app", VariantType.STRING).get_string ();
single_app = options.lookup_value ("single-app", VariantType.BOOLEAN).get_boolean ();
execute = options.lookup_value ("execute", VariantType.STRING_ARRAY).dup_strv ();
help_execute = options.lookup_value ("help-execute", VariantType.BOOLEAN).get_boolean ();
inactivity_reset = options.lookup_value ("inactivity-reset", VariantType.INT32).get_int32 ();
Expand All @@ -456,11 +460,24 @@ namespace Midori {
}

if (app != "") {
var browser = new Browser (this, true);
var tab = new Tab (null, browser.web_context, app);
tab.pinned = true;
browser.add (tab);
var create_new = !single_app || (active_window == null);

var browser = (create_new) ? new Browser (this, true) : (active_window as Browser) ;
Tab tab = null ;

var num_tabs = browser.tabs.get_children().length();

if (create_new || (num_tabs==0)) {
tab = new Tab (null, browser.web_context, app);
tab.pinned = true;
browser.add (tab);
} else {
tab = (Tab)browser.tabs.get_children().nth_data(0);
tab.load_uri(app);
}

browser.show ();

if (inactivity_reset > 0) {
Timeout.add_seconds (inactivity_reset, () => {
if (browser.idle) {
Expand Down
7 changes: 7 additions & 0 deletions core/browser.vala
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace Midori {
{ "clear-private-data", clear_private_data_activated },
{ "preferences", preferences_activated },
{ "about", about_activated },
{ "force-fullscreen", force_fullscreen_activated },
};
[GtkChild]
Gtk.HeaderBar panelbar;
Expand Down Expand Up @@ -605,6 +606,12 @@ namespace Midori {
}
}

void force_fullscreen_activated () {
if (!is_fullscreen) {
fullscreen_activated ();
}
}

void show_downloads_activated () {
downloads.show_downloads ();
}
Expand Down