1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Special: Broadcast events to one specific tab, not all tabs with same name

This commit is contained in:
gnosygnu
2017-03-19 03:08:57 -04:00
parent 67548465fc
commit cc8c120982
15 changed files with 59 additions and 17 deletions

View File

@@ -15,11 +15,19 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.guis.cbks; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
public class Xog_cbk_trg {
Xog_cbk_trg(byte tid, byte[] page_ttl) {this.tid = tid; this.page_ttl = page_ttl;}
public Xog_cbk_trg(byte tid, byte[] page_ttl) {
this.tid = tid; this.page_ttl = page_ttl;
}
public Xog_cbk_trg(String page_guid) {
this.tid = Tid__page_guid;
this.page_ttl = Bry_.Empty;
this.Page_guid = page_guid;
}
public byte Tid() {return tid;} private final byte tid;
public byte[] Page_ttl() {return page_ttl;} private final byte[] page_ttl; // same as ttl.Full_db(); EX: Special:XowaDownloadCentral
public String Page_guid;
public static final byte Tid__cbk_enabled = 0, Tid__specific_page = 1;
public static final byte Tid__cbk_enabled = 0, Tid__specific_page = 1, Tid__page_guid = 2;
public static final Xog_cbk_trg Any = new Xog_cbk_trg(Tid__cbk_enabled, null);
public static Xog_cbk_trg New(byte[] page_ttl) {return new Xog_cbk_trg(Tid__specific_page, page_ttl);}
}

View File

@@ -26,8 +26,12 @@ public class Xog_cbk_wkr__swt implements Xog_cbk_wkr {
}
public Object Send_json(Xog_cbk_trg trg, String func, Gfobj_nde data) {
if (gui_mgr.Kit().Tid() != Gfui_kit_.Swt_tid) return null; // guard against calling when HTTP_server
// create cmd for script
String script = json_wtr.Write_as_func__swt(func, data);
GfuiInvkCmd swt_cmd = gui_mgr.Kit().New_cmd_sync(browser_func.Script_(script));
// iterate tabs
Xog_tab_mgr tab_mgr = gui_mgr.Browser_win().Tab_mgr();
int tabs_len = tab_mgr.Tabs_len();
Object rv = null;
@@ -36,6 +40,9 @@ public class Xog_cbk_wkr__swt implements Xog_cbk_wkr {
Xoa_page page = tab.Page();
boolean match = false;
switch (trg.Tid()) {
case Xog_cbk_trg.Tid__page_guid:
match = String_.Eq(trg.Page_guid, page.Page_guid().To_str());
break;
case Xog_cbk_trg.Tid__cbk_enabled:
match = page.Html_data().Cbk_enabled();
break;