mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Cfg: Convert 'App - Startup' (finished)
This commit is contained in:
@@ -19,23 +19,20 @@ package gplx.xowa.users; import gplx.*; import gplx.xowa.*;
|
||||
public class Xou_cfg implements Gfo_invk {
|
||||
public Xou_cfg(Xoue_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());
|
||||
}
|
||||
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_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 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 Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
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_layout)) return layout_mgr;
|
||||
else if (ctx.Match(k, Invk_log)) return log_mgr;
|
||||
return this;
|
||||
}
|
||||
public static final String
|
||||
Invk_pages = "pages", Invk_startup = "startup", Invk_setup = "setup", Invk_layout = "layout", Invk_log = "log";
|
||||
public static final String Invk_pages = "pages", Invk_setup = "setup", Invk_layout = "layout", Invk_log = "log";
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class Xoue_user implements Xou_user, Gfo_evt_mgr_owner, Gfo_invk {
|
||||
}
|
||||
}
|
||||
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);
|
||||
if (app.Gui_mgr().Browser_win().Tab_mgr().Page_load_mode_is_url())
|
||||
Io_mgr.Instance.DeleteDirDeep(fsys_mgr.App_temp_html_dir());
|
||||
|
||||
Reference in New Issue
Block a user