1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

Cfg: Convert 'App - Startup' (finished)

This commit is contained in:
gnosygnu 2016-12-16 17:51:43 -05:00
parent 5b42a90cd5
commit 66e1c3ecc2
14 changed files with 121 additions and 249 deletions

View File

@ -58,6 +58,10 @@ public class Xocfg_mgr {
String rv = Get_str(wiki.Domain_itm().Abrv_xo_str(), key); String rv = Get_str(wiki.Domain_itm().Abrv_xo_str(), key);
return rv == null ? or : Yn.parse_or(rv, or); return rv == null ? or : Yn.parse_or(rv, or);
} }
public int Get_int_app_or(String key, int or) {
String rv = cache_mgr.Get_or(Ctx__app, key, null);
return rv == null ? or : Int_.parse_or(rv, or);
}
public String Get_str_app_or(String key, String or) {return cache_mgr.Get_or(Ctx__app, key, or);} public String Get_str_app_or(String key, String or) {return cache_mgr.Get_or(Ctx__app, key, or);}
public String Get_str_app(String key) {return Get_str(Xocfg_mgr.Ctx__app, key);} public String Get_str_app(String key) {return Get_str(Xocfg_mgr.Ctx__app, key);}
public boolean Get_bool_or(String ctx, String key, boolean or) { public boolean Get_bool_or(String ctx, String key, boolean or) {
@ -99,6 +103,7 @@ public class Xocfg_mgr {
public String To_ctx(Xow_wiki wiki) {return wiki.Domain_itm().Abrv_xo_str();} public String To_ctx(Xow_wiki wiki) {return wiki.Domain_itm().Abrv_xo_str();}
public String Get_str(String ctx, String key) {return cache_mgr.Get(ctx, key);} public String Get_str(String ctx, String key) {return cache_mgr.Get(ctx, key);}
public void Set_str_app(String key, String val) {Set_str(Xocfg_mgr.Ctx__app, key, val);} public void Set_str_app(String key, String val) {Set_str(Xocfg_mgr.Ctx__app, key, val);}
public void Set_int_app(String key, int val) {Set_str(Xocfg_mgr.Ctx__app, key, Int_.To_str(val));}
public void Set_str(String ctx, String key, String val) { public void Set_str(String ctx, String key, String val) {
cache_mgr.Set(ctx, key, val); cache_mgr.Set(ctx, key, val);
} }

View File

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; package gplx.xowa.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
import gplx.xowa.guis.views.*; import gplx.xowa.guis.views.*;
import gplx.xowa.apps.apis.xowa.apps.*; import gplx.xowa.apps.apis.xowa.envs.*; import gplx.xowa.apps.apis.xowa.startups.*; import gplx.xowa.apps.apis.xowa.apps.*; import gplx.xowa.apps.apis.xowa.envs.*;
public class Xoapi_app implements Gfo_invk { public class Xoapi_app implements Gfo_invk {
private Xog_win_itm win; private Xog_win_itm win;
public void Ctor_by_app(Xoae_app app) { public void Ctor_by_app(Xoae_app app) {
@ -29,14 +29,12 @@ public class Xoapi_app implements Gfo_invk {
public Xoapi_fsys Fsys() {return fsys;} private Xoapi_fsys fsys = new Xoapi_fsys(); public Xoapi_fsys Fsys() {return fsys;} private Xoapi_fsys fsys = new Xoapi_fsys();
public void Exit() {win.App__exit();} public void Exit() {win.App__exit();}
public Xoapi_env Env() {return env;} private Xoapi_env env = new Xoapi_env(); public Xoapi_env Env() {return env;} private Xoapi_env env = new Xoapi_env();
public Xoapi_startups Startup() {return startup;} private Xoapi_startups startup = new Xoapi_startups();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_exit)) this.Exit(); if (ctx.Match(k, Invk_exit)) this.Exit();
else if (ctx.Match(k, Invk_fsys)) return fsys; else if (ctx.Match(k, Invk_fsys)) return fsys;
else if (ctx.Match(k, Invk_startup)) return startup;
else if (ctx.Match(k, Invk_env)) return env; else if (ctx.Match(k, Invk_env)) return env;
else return Gfo_invk_.Rv_unhandled; else return Gfo_invk_.Rv_unhandled;
return this; return this;
} }
private static final String Invk_exit = "exit", Invk_startup = "startup", Invk_env = "env", Invk_fsys = "fsys"; private static final String Invk_exit = "exit", Invk_env = "env", Invk_fsys = "fsys";
} }

View File

@ -1,29 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.startups; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
import gplx.xowa.apps.apis.xowa.startups.tabs.*;
public class Xoapi_startups implements Gfo_invk {
public void Init_by_kit(Xoae_app app) {
}
public Xoapi_startup_tabs Tabs() {return tabs;} private Xoapi_startup_tabs tabs = new Xoapi_startup_tabs();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_tabs)) return tabs;
else return Gfo_invk_.Rv_unhandled;
}
private static final String Invk_tabs = "tabs";
}

View File

@ -1,87 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.startups.tabs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.startups.*;
import gplx.xowa.specials.*;
public class Xoapi_startup_tabs implements Gfo_invk {
public String Custom() {return custom;} private String custom;
public boolean Custom_is_expr() {return custom_is_expr;} private boolean custom_is_expr;
public String Previous() {return previous;} private String previous;
public String Manual() {return manual;} public void Manual_(String v) {manual = v;} private String manual;
public byte Type() {return type;} private byte type = Xoapi_startup_tabs_tid_.Tid_previous;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_type)) return Xoapi_startup_tabs_tid_.Xto_key(type);
else if (ctx.Match(k, Invk_type_)) type = Xoapi_startup_tabs_tid_.Xto_tid(m.ReadStr("v"));
else if (ctx.Match(k, Invk_type_list)) return Xoapi_startup_tabs_tid_.Options__list;
else if (ctx.Match(k, Invk_previous)) return previous;
else if (ctx.Match(k, Invk_previous_)) previous = m.ReadStr("v");
else if (ctx.Match(k, Invk_custom)) return custom;
else if (ctx.Match(k, Invk_custom_)) custom = m.ReadStr("v");
else if (ctx.Match(k, Invk_custom_is_expr)) return Yn.To_str(custom_is_expr);
else if (ctx.Match(k, Invk_custom_is_expr_)) custom_is_expr = m.ReadYn("v");
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String
Invk_type = "type", Invk_type_ = "type_", Invk_type_list = "type_list"
, Invk_custom = "custom", Invk_custom_ = "custom_"
, Invk_previous = "previous", Invk_previous_ = "previous_"
, Invk_custom_is_expr = "custom_is_expr", Invk_custom_is_expr_ = "custom_is_expr_"
;
public String[] Calc_startup_strs(Xoae_app app) {
List_adp rv = List_adp_.New();
String xowa_home = gplx.xowa.users.Xouc_pages_mgr.Page_xowa;
if (manual == null) {
switch (type) {
case Xoapi_startup_tabs_tid_.Tid_blank: rv.Add(Xow_special_meta_.Itm__default_tab.Ttl_str()); break;
case Xoapi_startup_tabs_tid_.Tid_xowa: rv.Add(xowa_home); break;
case Xoapi_startup_tabs_tid_.Tid_custom: Add_ary(rv, custom); break;
case Xoapi_startup_tabs_tid_.Tid_previous: Add_ary(rv, previous); break;
default: throw Err_.new_unhandled(type);
}
}
else
rv.Add(manual);
Add_xowa_home_if_new_version(rv, app, xowa_home);
return rv.To_str_ary();
}
private static void Add_ary(List_adp list, String s) {
if (String_.Len_eq_0(s)) return;
String[] ary = String_.SplitLines_nl(String_.Trim(s));
int len = ary.length;
for (int i = 0; i < len; ++i) {
String itm = ary[i];
if (String_.Len_eq_0(itm)) continue;
list.Add(itm);
}
}
private static void Add_xowa_home_if_new_version(List_adp rv, Xoae_app app, String xowa_home) {
if (gplx.xowa.apps.versions.Xoa_version_.Compare(app.Api_root().App().Env().Version_previous(), Xoa_app_.Version) == CompareAble_.Less) {
boolean xowa_home_exists = false;
int len = rv.Count();
for (int i = 0; i < len; ++i) {
String itm = (String)rv.Get_at(i);
if (String_.Eq(itm, xowa_home)) {
xowa_home_exists = true;
break;
}
}
if (!xowa_home_exists)
rv.Add(xowa_home);
}
}
}

View File

@ -1,39 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.startups.tabs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.startups.*;
public class Xoapi_startup_tabs_tid_ {
public static final byte Tid_blank = 0, Tid_xowa = 1, Tid_previous = 2, Tid_custom = 3;
public static final String Key_blank = "blank", Key_xowa = "xowa", Key_previous = "previous", Key_custom = "custom";
public static String Xto_key(byte v) {
switch (v) {
case Tid_blank: return Key_blank;
case Tid_xowa: return Key_xowa;
case Tid_previous: return Key_previous;
case Tid_custom: return Key_custom;
default: throw Err_.new_unimplemented();
}
}
public static byte Xto_tid(String s) {
if (String_.Eq(s, Key_blank)) return Tid_blank;
else if (String_.Eq(s, Key_xowa)) return Tid_xowa;
else if (String_.Eq(s, Key_previous)) return Tid_previous;
else if (String_.Eq(s, Key_custom)) return Tid_custom;
else throw Err_.new_unimplemented();
}
public static Keyval[] Options__list = Keyval_.Ary(Keyval_.new_(Key_blank), Keyval_.new_(Key_xowa), Keyval_.new_(Key_previous), Keyval_.new_(Key_custom));
}

View File

@ -73,7 +73,7 @@ public class Xoa_boot_mgr {
try { try {
app.Sys_cfg().Lang_(System_lang()); app.Sys_cfg().Lang_(System_lang());
String launch_url = arg_mgr.Gui__home_page(); String launch_url = arg_mgr.Gui__home_page();
if (launch_url != null) app.Api_root().App().Startup().Tabs().Manual_(launch_url); if (launch_url != null) gplx.xowa.guis.views.Xog_startup_tabs_.Manual = launch_url;
app.Tcp_server().Rdr_port_(arg_mgr.Tcp__port_recv()).Wtr_port_(arg_mgr.Tcp__port_send()); app.Tcp_server().Rdr_port_(arg_mgr.Tcp__port_recv()).Wtr_port_(arg_mgr.Tcp__port_send());
gplx.xowa.apps.servers.http.Http_server_mgr server_mgr = app.Http_server(); gplx.xowa.apps.servers.http.Http_server_mgr server_mgr = app.Http_server();
server_mgr.Port_(arg_mgr.Http__port()); server_mgr.Port_(arg_mgr.Http__port());

View File

@ -20,7 +20,7 @@ public class Xoa_misc_mgr implements Gfo_invk {
private Xoa_app app; private Xoa_app app;
public void Init_by_app(Xoa_app app) { public void Init_by_app(Xoa_app app) {
this.app = app; this.app = app;
app.Cfg().Bind_many_app(this, Cfg__web_enabled, Cfg__logs_enabled); app.Cfg().Bind_many_app(this, Cfg__web_enabled, Cfg__logs_enabled, Cfg__script);
} }
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Cfg__web_enabled)) gplx.core.ios.IoEngine_system.Web_access_enabled = m.ReadYn("v"); if (ctx.Match(k, Cfg__web_enabled)) gplx.core.ios.IoEngine_system.Web_access_enabled = m.ReadYn("v");
@ -33,8 +33,15 @@ public class Xoa_misc_mgr implements Gfo_invk {
Io_mgr.Instance.DeleteFil_args(appe.Log_wtr().Session_fil()).MissingFails_off().Exec(); Io_mgr.Instance.DeleteFil_args(appe.Log_wtr().Session_fil()).MissingFails_off().Exec();
} }
} }
else if (ctx.Match(k, Cfg__script)) {
String script = m.ReadStr("v");
Object rslt = app.Gfs_mgr().Run_str(script);
if (rslt == Gfo_invk_.Rv_error) {
app.Usr_dlg().Warn_many("", "", "custom script failed: ~{0}", script);
}
}
else return Gfo_invk_.Rv_unhandled; else return Gfo_invk_.Rv_unhandled;
return this; return this;
} }
private static final String Cfg__web_enabled = "xowa.app.web.enabled", Cfg__logs_enabled = "xowa.app.logs.enabled"; private static final String Cfg__web_enabled = "xowa.app.web.enabled", Cfg__logs_enabled = "xowa.app.logs.enabled", Cfg__script = "xowa.app.startup.script";
} }

View File

@ -34,13 +34,14 @@ class Xog_launcher_tabs {
app.Usr_dlg().Log_wkr().Log_to_session_direct(log_bfr.Xto_str()); app.Usr_dlg().Log_wkr().Log_to_session_direct(log_bfr.Xto_str());
} }
private boolean Restore_tabs(Xoae_app app, Xowe_wiki home_wiki, Xog_win_itm win, Io_fil_marker fil_marker) { private boolean Restore_tabs(Xoae_app app, Xowe_wiki home_wiki, Xog_win_itm win, Io_fil_marker fil_marker) {
String[] launch_urls = app.Api_root().App().Startup().Tabs().Calc_startup_strs(app); String[] launch_urls = Xog_startup_tabs_.Calc_startup_strs(app);
try { try {
int launch_urls_len = launch_urls.length; int launch_urls_len = launch_urls.length;
for (int i = 0; i < launch_urls_len; ++i) { for (int i = 0; i < launch_urls_len; ++i) {
String launch_url = launch_urls[i]; String launch_url = launch_urls[i];
Launch_tab(win, home_wiki, launch_url); Launch_tab(win, home_wiki, launch_url);
} }
Xog_startup_tabs_.Select_startup_tab(app);
fil_marker.End(); fil_marker.End();
return true; return true;
} }

View File

@ -0,0 +1,95 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.guis.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
import gplx.xowa.addons.apps.cfgs.*;
public class Xog_startup_tabs_ {
public static String Manual = null; // note should only be set once, at startup;
public static void Shutdown(Xoae_app app) {
if (String_.Eq(app.Cfg().Get_str_app_or(Cfg__tabs_type, Opt__tabs_type__previous), Opt__tabs_type__previous)) {
app.Cfg().Set_str_app(Cfg__prev_list , Calc_previous_tabs(app.Gui_mgr().Browser_win().Tab_mgr()));
app.Cfg().Set_int_app(Cfg__prev_selected, app.Gui_mgr().Browser_win().Tab_mgr().Active_tab().Tab_idx());
}
}
private static String Calc_previous_tabs(gplx.xowa.guis.views.Xog_tab_mgr tab_mgr) {
Bry_bfr bfr = Bry_bfr_.New();
int len = tab_mgr.Tabs_len();
for (int i = 0; i < len; ++i) {
if (i != 0) bfr.Add_byte_nl();
gplx.xowa.guis.views.Xog_tab_itm tab = tab_mgr.Tabs_get_at(i);
bfr.Add_str_u8(tab.Page().Url().To_str());
}
return bfr.To_str_and_clear();
}
public static void Select_startup_tab(Xoae_app app) {
if (String_.Eq(app.Cfg().Get_str_app_or(Cfg__tabs_type, Opt__tabs_type__previous), Opt__tabs_type__previous)) {
int selected_tab = app.Cfg().Get_int_app_or(Cfg__prev_selected, -1);
if (selected_tab != -1) {
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_select_by_idx(selected_tab);
}
}
}
public static String[] Calc_startup_strs(Xoae_app app) {
List_adp rv = List_adp_.New();
Xocfg_mgr cfg = app.Cfg();
String xowa_home = gplx.xowa.users.Xouc_pages_mgr.Page_xowa;
String type = cfg.Get_str_app_or(Cfg__tabs_type, Opt__tabs_type__previous);
if (Manual == null) {
if (String_.Eq(type, "blank")) {rv.Add(gplx.xowa.specials.Xow_special_meta_.Itm__default_tab.Ttl_str());}
else if (String_.Eq(type, "xowa")) {rv.Add(xowa_home);}
else if (String_.Eq(type, "custom")) {Add_pages_to_list(rv, cfg.Get_str_app_or(Cfg__tabs_custom, ""));}
else if (String_.Eq(type, Opt__tabs_type__previous)) {Add_pages_to_list(rv, cfg.Get_str_app_or(Cfg__prev_list, ""));}
else {throw Err_.new_unhandled(type);}
}
else
rv.Add(Manual);
Add_xowa_home_if_new_version(rv, app, xowa_home);
return rv.To_str_ary();
}
private static void Add_pages_to_list(List_adp list, String s) {
if (String_.Len_eq_0(s)) return;
String[] ary = String_.SplitLines_nl(String_.Trim(s));
int len = ary.length;
for (int i = 0; i < len; ++i) {
String itm = ary[i];
if (String_.Len_eq_0(itm)) continue;
list.Add(itm);
}
}
private static void Add_xowa_home_if_new_version(List_adp rv, Xoae_app app, String xowa_home) {
if (gplx.xowa.apps.versions.Xoa_version_.Compare(app.Api_root().App().Env().Version_previous(), Xoa_app_.Version) == CompareAble_.Less) {
boolean xowa_home_exists = false;
int len = rv.Count();
for (int i = 0; i < len; ++i) {
String itm = (String)rv.Get_at(i);
if (String_.Eq(itm, xowa_home)) {
xowa_home_exists = true;
break;
}
}
if (!xowa_home_exists)
rv.Add(xowa_home);
}
}
private static final String
Cfg__tabs_type = "xowa.app.startup.tabs.type"
, Cfg__tabs_custom = "xowa.app.startup.tabs.custom"
, Cfg__prev_list = "xowa.app.startup.tabs.previous_list"
, Cfg__prev_selected = "xowa.app.startup.tabs.previous_selected"
, Opt__tabs_type__previous = "previous"
;
}

View File

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.guis.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; package gplx.xowa.guis.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
import gplx.core.envs.*; import gplx.core.envs.*;
import gplx.gfui.*; import gplx.gfui.envs.*; import gplx.gfui.controls.windows.*; import gplx.gfui.*; import gplx.gfui.envs.*; import gplx.gfui.controls.windows.*;
public class Xog_win_itm_startup_ { public class Xog_startup_win_ {
public static void Startup(Xoa_app app, GfuiWin win) { public static void Startup(Xoa_app app, GfuiWin win) {
gplx.xowa.addons.apps.cfgs.Xocfg_mgr cfg_mgr = app.Cfg(); gplx.xowa.addons.apps.cfgs.Xocfg_mgr cfg_mgr = app.Cfg();
String window_mode = cfg_mgr.Get_str_app_or(Cfg__window_mode, "previous"); String window_mode = cfg_mgr.Get_str_app_or(Cfg__window_mode, "previous");
@ -79,25 +79,13 @@ public class Xog_win_itm_startup_ {
cfg_mgr.Set_str_app(Cfg__prev_rect , win.Rect().Xto_str()); cfg_mgr.Set_str_app(Cfg__prev_rect , win.Rect().Xto_str());
cfg_mgr.Set_str_app(Cfg__prev_maximized , Yn.To_str(win.Maximized())); cfg_mgr.Set_str_app(Cfg__prev_maximized , Yn.To_str(win.Maximized()));
} }
Xog_startup_tabs_.Shutdown(app);
gplx.xowa.apps.cfgs.Xoa_cfg_mgr cfg_mgr2 = app.Cfg_mgr(); gplx.xowa.apps.cfgs.Xoa_cfg_mgr cfg_mgr2 = app.Cfg_mgr();
gplx.xowa.apps.apis.xowa.startups.tabs.Xoapi_startup_tabs startup_tabs = app.Api_root().App().Startup().Tabs();
if (startup_tabs.Type() == gplx.xowa.apps.apis.xowa.startups.tabs.Xoapi_startup_tabs_tid_.Tid_previous) {
cfg_mgr2.Set_by_app("xowa.api.app.startup.tabs.previous" , Calc_previous_tabs(app.Gui_mgr().Browser_win().Tab_mgr()));
}
cfg_mgr2.Set_by_app("xowa.api.app.env.version_previous" , Xoa_app_.Version); cfg_mgr2.Set_by_app("xowa.api.app.env.version_previous" , Xoa_app_.Version);
app.Api_root().Html().Page().Toggle_mgr().Save(cfg_mgr2); app.Api_root().Html().Page().Toggle_mgr().Save(cfg_mgr2);
cfg_mgr2.Db_save_txt(); cfg_mgr2.Db_save_txt();
} }
private static String Calc_previous_tabs(gplx.xowa.guis.views.Xog_tab_mgr tab_mgr) {
Bry_bfr bfr = Bry_bfr_.New();
int len = tab_mgr.Tabs_len();
for (int i = 0; i < len; ++i) {
if (i != 0) bfr.Add_byte_nl();
gplx.xowa.guis.views.Xog_tab_itm tab = tab_mgr.Tabs_get_at(i);
bfr.Add_str_u8(tab.Page().Url().To_str());
}
return bfr.To_str_and_clear();
}
public static SizeAdp Screen_maximized_calc() { public static SizeAdp Screen_maximized_calc() {
Op_sys os = Op_sys.Cur(); Op_sys os = Op_sys.Cur();
SizeAdp screen = ScreenAdp_.screen_(0).Size(); SizeAdp screen = ScreenAdp_.screen_(0).Size();

View File

@ -27,7 +27,7 @@ public class Xog_win_itm_ {
win_box.BackColor_(ColorAdp_.White); win_box.BackColor_(ColorAdp_.White);
win.Tab_mgr().Tab_mgr().BackColor_(ColorAdp_.White); win.Tab_mgr().Tab_mgr().BackColor_(ColorAdp_.White);
Xog_win_itm_startup_.Startup(app, win_box); Xog_startup_win_.Startup(app, win_box);
win.Resizer().Exec_win_resize(app, win_box.Width(), win_box.Height()); win.Resizer().Exec_win_resize(app, win_box.Width(), win_box.Height());
win_box.Icon_(IconAdp.file_or_blank(app.Fsys_mgr().Bin_xowa_dir().GenSubFil_nest("file", "app.window", "app_icon.png"))); win_box.Icon_(IconAdp.file_or_blank(app.Fsys_mgr().Bin_xowa_dir().GenSubFil_nest("file", "app.window", "app_icon.png")));

View File

@ -19,23 +19,20 @@ package gplx.xowa.users; import gplx.*; import gplx.xowa.*;
public class Xou_cfg implements Gfo_invk { public class Xou_cfg implements Gfo_invk {
public Xou_cfg(Xoue_user user) { public Xou_cfg(Xoue_user user) {
this.user = user; this.user = user;
pages_mgr = new Xouc_pages_mgr(this); startup_mgr = new Xouc_startup_mgr(this); setup_mgr = new Xouc_setup_mgr(user); pages_mgr = new Xouc_pages_mgr(this); setup_mgr = new Xouc_setup_mgr(user);
layout_mgr = new Xoc_layout_mgr(user.Appe()); layout_mgr = new Xoc_layout_mgr(user.Appe());
} }
public Xoue_user User() {return user;} private Xoue_user user; public Xoue_user User() {return user;} private Xoue_user user;
public Xouc_pages_mgr Pages_mgr() {return pages_mgr;} private Xouc_pages_mgr pages_mgr; public Xouc_pages_mgr Pages_mgr() {return pages_mgr;} private Xouc_pages_mgr pages_mgr;
public Xouc_startup_mgr Startup_mgr() {return startup_mgr;} private Xouc_startup_mgr startup_mgr;
public Xouc_setup_mgr Setup_mgr() {return setup_mgr;} private Xouc_setup_mgr setup_mgr; public Xouc_setup_mgr Setup_mgr() {return setup_mgr;} private Xouc_setup_mgr setup_mgr;
public Xoc_layout_mgr Layout_mgr() {return layout_mgr;} private Xoc_layout_mgr layout_mgr; public Xoc_layout_mgr Layout_mgr() {return layout_mgr;} private Xoc_layout_mgr layout_mgr;
public Xou_log_mgr Log_mgr() {return log_mgr;} private final Xou_log_mgr log_mgr = new Xou_log_mgr(); public Xou_log_mgr Log_mgr() {return log_mgr;} private final Xou_log_mgr log_mgr = new Xou_log_mgr();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_pages)) return pages_mgr; if (ctx.Match(k, Invk_pages)) return pages_mgr;
else if (ctx.Match(k, Invk_startup)) return startup_mgr;
else if (ctx.Match(k, Invk_setup)) return setup_mgr; else if (ctx.Match(k, Invk_setup)) return setup_mgr;
else if (ctx.Match(k, Invk_layout)) return layout_mgr; else if (ctx.Match(k, Invk_layout)) return layout_mgr;
else if (ctx.Match(k, Invk_log)) return log_mgr; else if (ctx.Match(k, Invk_log)) return log_mgr;
return this; return this;
} }
public static final String public static final String Invk_pages = "pages", Invk_setup = "setup", Invk_layout = "layout", Invk_log = "log";
Invk_pages = "pages", Invk_startup = "startup", Invk_setup = "setup", Invk_layout = "layout", Invk_log = "log";
} }

View File

@ -1,64 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.users; import gplx.*; import gplx.xowa.*;
public class Xouc_startup_mgr implements Gfo_invk {
public Xouc_startup_mgr(Xou_cfg config) {this.config = config;} private Xou_cfg config;
public String Page() {return page;} public Xouc_startup_mgr Page_(String v) {page = v; return this;} private String page = "xowa";
public String Page_url() {
byte v = Page_parse(page);
switch (v) {
case Page_home: return config.Pages_mgr().Home();
case Page_last: return String_.new_u8(config.User().Appe().Gui_mgr().Browser_win().Active_page().Ttl().Raw());
case Page_xowa: return Xouc_pages_mgr.Page_xowa;
default: throw Err_.new_unhandled(page);
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_page)) return page;
else if (ctx.Match(k, Invk_page_)) page = m.ReadStr("v");
else if (ctx.Match(k, Invk_custom_config)) return Custom_config();
else if (ctx.Match(k, Invk_custom_config_)) Custom_config_(m.ReadStr("v"));
return this;
}
public static final String Invk_page = "page", Invk_page_ = "page_", Invk_custom_config = "custom_config", Invk_custom_config_ = "custom_config_";
private byte Page_parse(String s) {
if (String_.Eq(s, "home")) return Page_home;
else if (String_.Eq(s, "last")) return Page_last;
else if (String_.Eq(s, "xowa")) return Page_xowa;
else return Page_xowa;
}
private String Custom_config() {
if (custom_config == null) { // NOTE: LoadFilStr never returns null, so this will only execute once
Io_url custom_config_url = config.User().Fsys_mgr().App_data_cfg_custom_fil();
custom_config = Io_mgr.Instance.LoadFilStr_args(custom_config_url).MissingIgnored_().Exec();
}
return custom_config;
} private String custom_config;
private void Custom_config_(String v) {
Xoae_app app = config.User().Appe();
Object rslt = app.Gfs_mgr().Run_str(v);
if (rslt == Gfo_invk_.Rv_error) {
app.Usr_dlg().Warn_many("", "", "custom script failed: ~{0}", v);
return;
}
custom_config = v;
// Io_url custom_config_url = config.User().Fsys_mgr().App_data_cfg_custom_fil(); // DELETE: no longer sync user_cfg to custom.gfs; already saved in user.gfs; DATE:2014-05-30
// Io_mgr.Instance.SaveFilStr(custom_config_url, v);
}
public static final byte Page_home = 0, Page_last = 1, Page_xowa = 2;
}

View File

@ -65,7 +65,7 @@ public class Xoue_user implements Xou_user, Gfo_evt_mgr_owner, Gfo_invk {
} }
} }
public void App_term() { public void App_term() {
gplx.xowa.guis.views.Xog_win_itm_startup_.Shutdown(app, app.Gui_mgr().Browser_win().Win_box()); // save window position gplx.xowa.guis.views.Xog_startup_win_.Shutdown(app, app.Gui_mgr().Browser_win().Win_box()); // save window position
history_mgr.Save(app); history_mgr.Save(app);
if (app.Gui_mgr().Browser_win().Tab_mgr().Page_load_mode_is_url()) if (app.Gui_mgr().Browser_win().Tab_mgr().Page_load_mode_is_url())
Io_mgr.Instance.DeleteDirDeep(fsys_mgr.App_temp_html_dir()); Io_mgr.Instance.DeleteDirDeep(fsys_mgr.App_temp_html_dir());