mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Cfg: Remove parts of old config system
This commit is contained in:
@@ -1,45 +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.guis.bnds; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import org.junit.*; import gplx.gfui.*; import gplx.gfui.ipts.*; import gplx.xowa.apps.cfgs.old.*;
|
||||
public class Xog_bnd_itm_srl_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xog_bnd_itm_srl_fxt fxt = new Xog_bnd_itm_srl_fxt();
|
||||
@Test public void Src_get() {
|
||||
Xog_bnd_itm bnd = fxt.bnd_(Xog_bnd_box_.Tid_browser, IptKey_.A);
|
||||
fxt.Test_src_get(bnd, "box='browser';ipt='key.a';");
|
||||
}
|
||||
@Test public void Src_set() {
|
||||
fxt.Test_src_set("box='browser.html';ipt='key.b';", Xog_bnd_box_.Tid_browser_html, IptKey_.B);
|
||||
}
|
||||
}
|
||||
class Xog_bnd_itm_srl_fxt {
|
||||
private Xoae_app app;
|
||||
public void Reset() {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
}
|
||||
public Xog_bnd_itm bnd_(int box, IptArg ipt) {return new Xog_bnd_itm("test.key", true, "test.cmd", box, ipt);}
|
||||
public void Test_src_get(Xog_bnd_itm bnd, String expd) {
|
||||
Tfds.Eq(expd, Xocfg_bnd_itm_srl.Src(app, bnd.Box(), bnd.Ipt()));
|
||||
}
|
||||
public void Test_src_set(String src, int expd_box, IptArg expd_ipt) {
|
||||
Xocfg_bnd_itm_srl itm = new Xocfg_bnd_itm_srl(app, "test.key");
|
||||
Xocfg_bnd_itm_srl.Src_(app, itm, src);
|
||||
Tfds.Eq(expd_box, itm.Box());
|
||||
Tfds.Eq(expd_ipt.Key(), itm.Ipt().Key());
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,6 @@ public class Xog_bnd_mgr implements Gfo_invk {
|
||||
Add_system_bnds();
|
||||
Add_custom_bnds(); // NOTE: should go after Add_system_bnds in case user overrides any;
|
||||
Bind_all();
|
||||
app.Cfg_regy().App().Gui_mgr().Bnd_mgr().Init();
|
||||
|
||||
app.Cfg().Bind_many_app(this
|
||||
, "xowa.gui.shortcuts.xowa.app.exit-1"
|
||||
@@ -184,7 +183,6 @@ public class Xog_bnd_mgr implements Gfo_invk {
|
||||
else if ( new_ipt_exists
|
||||
&& String_.Eq(old_bnd.Ipt().Key(), new_ipt.Key())) {
|
||||
Xog_bnd_box_.Set_bnd_for_grp(Xog_bnd_box_.Set_del_ipt, win, invk_mgr, old_box, old_bnd, old_bnd.Ipt());
|
||||
Xog_bnd_mgr_srl.Update_cfg(win.App(), old_bnd, i, IptKey_.None);
|
||||
old_bnd.Ipt_to_none();
|
||||
}
|
||||
}
|
||||
@@ -378,5 +376,4 @@ public class Xog_bnd_mgr implements Gfo_invk {
|
||||
Set(bnd, box, IptArg_.parse(flds[1]));
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,68 +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.guis.bnds; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import gplx.core.primitives.*; import gplx.langs.dsvs.*; import gplx.gfui.*; import gplx.gfui.ipts.*; import gplx.xowa.apps.cfgs.old.*;
|
||||
public class Xog_bnd_mgr_srl extends Dsv_wkr_base {
|
||||
private Xoae_app app;
|
||||
private Xog_bnd_mgr bnd_mgr;
|
||||
private int uid; private byte[] box_bry, ipt_bry;
|
||||
public Xog_bnd_mgr_srl(Xoae_app app, Xog_bnd_mgr bnd_mgr) {
|
||||
this.app = app;
|
||||
this.bnd_mgr = bnd_mgr;
|
||||
}
|
||||
@Override public Dsv_fld_parser[] Fld_parsers() {return new Dsv_fld_parser[] {Dsv_fld_parser_.Int_parser, Dsv_fld_parser_.Bry_parser, Dsv_fld_parser_.Bry_parser};}
|
||||
@Override public boolean Write_int(Dsv_tbl_parser parser, int fld_idx, int pos, int val_int) {
|
||||
switch (fld_idx) {
|
||||
case 0: uid = val_int; return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
@Override public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {
|
||||
switch (fld_idx) {
|
||||
case 1: box_bry = Bry_.Mid(src, bgn, end); return true;
|
||||
case 2: ipt_bry = Bry_.Mid(src, bgn, end); return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
private void Init() {
|
||||
uids = Ordered_hash_.New();
|
||||
int len = bnd_mgr.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xog_bnd_itm bnd = (Xog_bnd_itm)bnd_mgr.Get_at(i);
|
||||
uids.Add(new Int_obj_val(bnd.Uid()), bnd);
|
||||
}
|
||||
bnd_parser = bnd_mgr.Bnd_parser();
|
||||
} private Ordered_hash uids; private Gfui_bnd_parser bnd_parser;
|
||||
@Override public void Commit_itm(Dsv_tbl_parser parser, int pos) {
|
||||
if (uid == -1) throw parser.Err_row_bgn("bnd missing uid", pos);
|
||||
if (box_bry == null) throw parser.Err_row_bgn("bnd missing box", pos);
|
||||
if (ipt_bry == null) throw parser.Err_row_bgn("bnd missing ipt", pos);
|
||||
if (uids == null) Init();
|
||||
Xog_bnd_itm bnd = (Xog_bnd_itm)uids.Get_by(new Int_obj_val(uid));
|
||||
int box = Xog_bnd_box_.Xby_gui_str(String_.new_u8(box_bry));
|
||||
IptArg ipt = IptArg_.parse_or_none_(bnd_parser.Xto_gfui(String_.new_u8(ipt_bry)));
|
||||
bnd_mgr.Del(bnd, ipt);
|
||||
Xog_bnd_mgr_srl.Update_cfg(app, bnd, box, ipt);
|
||||
uid = -1; box_bry = ipt_bry = null;
|
||||
}
|
||||
public static void Update_cfg(Xoae_app app, Xog_bnd_itm bnd, int box, IptArg ipt) {
|
||||
String src = Xocfg_bnd_itm_srl.Src(app, box, ipt);
|
||||
String cfg_key = String_.Concat("app.cfg.get.gui.bnds.init('", bnd.Key(), "').src");
|
||||
app.Cfg_mgr().Set_by_app(cfg_key, src);
|
||||
}
|
||||
}
|
||||
@@ -120,12 +120,13 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
, Invk_page_goto = "page_goto", Invk_page_goto_recent = "page_goto_recent"
|
||||
;
|
||||
private void Win__link_click() { // NOTE: only applies when content_editable=y; if n, then link_click will be handled by SwtBrowser location changed (Win__link_clicked)
|
||||
Xog_tab_itm tab = tab_mgr.Active_tab(); Xowe_wiki wiki = tab.Wiki();
|
||||
if (wiki.Gui_mgr().Cfg_browser().Content_editable()) {
|
||||
String href = tab.Html_itm().Html_box().Html_js_eval_proc_as_str(Xog_js_procs.Selection__get_active_for_editable_mode, Gfui_html.Atr_href, null);
|
||||
if (String_.Len_eq_0(href)) return; // NOTE: href can be null for images; EX: [[File:Loudspeaker.svg|11px|link=|alt=play]]; link= basically means don't link to image
|
||||
Page__navigate_by_href(tab, href);
|
||||
}
|
||||
// COMMENT: ignore content editable; DATE:2016-12-25
|
||||
//Xog_tab_itm tab = tab_mgr.Active_tab(); Xowe_wiki wiki = tab.Wiki();
|
||||
//if (wiki.Gui_mgr().Cfg_browser().Content_editable()) {
|
||||
// String href = tab.Html_itm().Html_box().Html_js_eval_proc_as_str(Xog_js_procs.Selection__get_active_for_editable_mode, Gfui_html.Atr_href, null);
|
||||
// if (String_.Len_eq_0(href)) return; // NOTE: href can be null for images; EX: [[File:Loudspeaker.svg|11px|link=|alt=play]]; link= basically means don't link to image
|
||||
// Page__navigate_by_href(tab, href);
|
||||
//}
|
||||
}
|
||||
private void Win__link_clicked(String anchor_raw) {
|
||||
String url = url_box.Text();
|
||||
|
||||
Reference in New Issue
Block a user