Implement "-a" or "--app" to run web apps

At the moment this takes an URI and opens a standalone window
with a non-editable toolbar and a statusbar.
This commit is contained in:
Christian Dywan 2009-04-13 04:38:01 +02:00
parent adec1c7093
commit 94c1d3c713
2 changed files with 31 additions and 0 deletions

View file

@ -1322,6 +1322,7 @@ int
main (int argc, main (int argc,
char** argv) char** argv)
{ {
gchar* webapp;
gchar* config; gchar* config;
gboolean run; gboolean run;
gboolean version; gboolean version;
@ -1331,6 +1332,8 @@ main (int argc,
GError* error; GError* error;
GOptionEntry entries[] = GOptionEntry entries[] =
{ {
{ "app", 'a', 0, G_OPTION_ARG_STRING, &webapp,
N_("Run ADDRESS as a web application"), N_("ADDRESS") },
{ "config", 'c', 0, G_OPTION_ARG_FILENAME, &config, { "config", 'c', 0, G_OPTION_ARG_FILENAME, &config,
N_("Use FOLDER as configuration folder"), N_("FOLDER") }, N_("Use FOLDER as configuration folder"), N_("FOLDER") },
{ "run", 'r', 0, G_OPTION_ARG_NONE, &run, { "run", 'r', 0, G_OPTION_ARG_NONE, &run,
@ -1373,6 +1376,7 @@ main (int argc,
#endif #endif
/* Parse cli options */ /* Parse cli options */
webapp = NULL;
config = NULL; config = NULL;
run = FALSE; run = FALSE;
version = FALSE; version = FALSE;
@ -1408,6 +1412,29 @@ main (int argc,
return 0; return 0;
} }
/* Web Application support */
if (webapp)
{
MidoriBrowser* browser = midori_browser_new ();
settings = katze_object_get_object (browser, "settings");
g_object_set (settings,
"show-menubar", FALSE,
"show-navigationbar", TRUE,
"toolbar-items", "Back,Forward,ReloadStop,Location",
"show-statusbar", TRUE,
NULL);
g_object_unref (settings);
g_object_set (browser, "settings", settings, NULL);
midori_browser_add_uri (browser, webapp);
g_object_set_data (G_OBJECT (browser), "locked", (void*)1);
g_signal_connect (browser, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (GTK_WIDGET (browser));
midori_browser_activate_action (browser, "Location");
gtk_main ();
return 0;
}
/* Standalone javascript support */ /* Standalone javascript support */
if (run) if (run)
return midori_run_script (uris ? *uris : NULL); return midori_run_script (uris ? *uris : NULL);

View file

@ -1943,6 +1943,10 @@ midori_browser_toolbar_popup_context_menu_cb (GtkWidget* widget,
GtkWidget* menu; GtkWidget* menu;
GtkWidget* menuitem; GtkWidget* menuitem;
/* Unsupported trick used for web app mode */
if (g_object_get_data (G_OBJECT (browser), "locked"))
return FALSE;
menu = gtk_menu_new (); menu = gtk_menu_new ();
menuitem = sokoke_action_create_popup_menu_item ( menuitem = sokoke_action_create_popup_menu_item (
_action_by_name (browser, "Menubar")); _action_by_name (browser, "Menubar"));