summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <none@none>2012-12-06 11:10:23 +0100
committerportix <none@none>2012-12-06 11:10:23 +0100
commitcfe31126f94c76ee9c2f1d5c7bfb13f31b9efcc1 (patch)
treeda5a2e74c2d65b7ffbac09bda9f4837189389297 /src
parentbe66d769983932d782e669257f95a6a71114c6cf (diff)
downloaddwb-cfe31126f94c76ee9c2f1d5c7bfb13f31b9efcc1.zip
Indentation of adblock.c, renaming static variables
Diffstat (limited to 'src')
-rw-r--r--src/adblock.c1451
-rw-r--r--src/application.c102
-rw-r--r--src/completion.c56
-rw-r--r--src/domain.c16
-rw-r--r--src/download.c38
-rw-r--r--src/dwb.c10
-rw-r--r--src/entry.c8
-rw-r--r--src/scratchpad.c24
-rw-r--r--src/scripts.c411
-rw-r--r--src/session.c28
-rw-r--r--src/soup.c54
-rw-r--r--src/view.c26
12 files changed, 1153 insertions, 1071 deletions
diff --git a/src/adblock.c b/src/adblock.c
index aa6a52b1..e45f6b68 100644
--- a/src/adblock.c
+++ b/src/adblock.c
@@ -29,29 +29,29 @@
/* DECLARATIONS {{{*/
/* Type definitions {{{*/
typedef enum _AdblockOption {
- AO_BEGIN = 1<<2,
- AO_BEGIN_DOMAIN = 1<<3,
- AO_END = 1<<4,
- AO_MATCH_CASE = 1<<7,
- AO_THIRDPARTY = 1<<8,
- AO_NOTHIRDPARTY = 1<<9,
+ AO_BEGIN = 1<<2,
+ AO_BEGIN_DOMAIN = 1<<3,
+ AO_END = 1<<4,
+ AO_MATCH_CASE = 1<<7,
+ AO_THIRDPARTY = 1<<8,
+ AO_NOTHIRDPARTY = 1<<9,
} AdblockOption;
/* Attributes */
typedef enum _AdblockAttribute {
- AA_SCRIPT = 1<<0,
- AA_IMAGE = 1<<1,
- AA_STYLESHEET = 1<<2,
- AA_OBJECT = 1<<3,
- AA_XBL = 1<<4,
- AA_PING = 1<<5,
- AA_XMLHTTPREQUEST = 1<<6,
- AA_OBJECT_SUBREQUEST = 1<<7,
- AA_DTD = 1<<8,
- AA_SUBDOCUMENT = 1<<9,
- AA_DOCUMENT = 1<<10,
- AA_ELEMHIDE = 1<<11,
- AA_OTHER = 1<<12,
- /* inverse */
+ AA_SCRIPT = 1<<0,
+ AA_IMAGE = 1<<1,
+ AA_STYLESHEET = 1<<2,
+ AA_OBJECT = 1<<3,
+ AA_XBL = 1<<4,
+ AA_PING = 1<<5,
+ AA_XMLHTTPREQUEST = 1<<6,
+ AA_OBJECT_SUBREQUEST = 1<<7,
+ AA_DTD = 1<<8,
+ AA_SUBDOCUMENT = 1<<9,
+ AA_DOCUMENT = 1<<10,
+ AA_ELEMHIDE = 1<<11,
+ AA_OTHER = 1<<12,
+ /* inverse */
} AdblockAttribute;
#define AA_CLEAR_FRAME(X) (X & ~(AA_SUBDOCUMENT|AA_DOCUMENT))
@@ -61,91 +61,98 @@ typedef enum _AdblockAttribute {
#define AB_CLEAR_LOWER 0x3fff8000
typedef struct _AdblockRule {
- GRegex *pattern;
- AdblockOption options;
- AdblockAttribute attributes;
- char **domains;
+ GRegex *pattern;
+ AdblockOption options;
+ AdblockAttribute attributes;
+ char **domains;
} AdblockRule;
typedef struct _AdblockElementHider {
- char *selector;
- char **domains;
- gboolean exception;
+ char *selector;
+ char **domains;
+ gboolean exception;
} AdblockElementHider;
/*}}}*/
/* Static variables {{{*/
-static GPtrArray *m_simple_rules;
-static GPtrArray *m_simple_exceptions;
-static GPtrArray *m_rules;
-static GPtrArray *m_exceptions;
-static GHashTable *m_hider_rules;
-gboolean m_has_hider_rules;
+static GPtrArray *s_simple_rules;
+static GPtrArray *s_simple_exceptions;
+static GPtrArray *s_rules;
+static GPtrArray *s_exceptions;
+static GHashTable *s_hider_rules;
+gboolean s_has_hider_rules;
/* only used to freeing elementhider */
-static GSList *m_hider_list;
-static GString *m_css_exceptions;
-static gboolean m_init = false;
-static GSList *m_css_hider_list;
+static GSList *s_hider_list;
+static GString *s_css_exceptions;
+static gboolean s_init = false;
+static GSList *s_css_hider_list;
#define HIDER_LIST_MAX 3000
/*}}}*//*}}}*/
/* NEW AND FREE {{{*/
/* adblock_rule_new {{{*/
static AdblockRule *
-adblock_rule_new() {
- AdblockRule *rule = dwb_malloc(sizeof(AdblockRule));
- rule->pattern = NULL;
- rule->options = 0;
- rule->attributes = 0;
- rule->domains = NULL;
- return rule;
+adblock_rule_new()
+{
+ AdblockRule *rule = dwb_malloc(sizeof(AdblockRule));
+ rule->pattern = NULL;
+ rule->options = 0;
+ rule->attributes = 0;
+ rule->domains = NULL;
+ return rule;
}/*}}}*/
/* adblock_rule_free {{{*/
static void
-adblock_rule_free(AdblockRule *rule) {
- if (rule->pattern != NULL) {
- g_regex_unref(rule->pattern);
- }
- if (rule->domains != NULL) {
- g_strfreev(rule->domains);
- }
- g_free(rule);
+adblock_rule_free(AdblockRule *rule)
+{
+ if (rule->pattern != NULL)
+ g_regex_unref(rule->pattern);
+
+ if (rule->domains != NULL)
+ g_strfreev(rule->domains);
+
+ g_free(rule);
}/*}}}*/
/* adblock_element_hider_new {{{*/
static AdblockElementHider *
-adblock_element_hider_new(const char *selector, char **domains) {
- AdblockElementHider *hider = dwb_malloc(sizeof(AdblockElementHider));
- hider->selector = g_strdup(selector);
- hider->domains = domains;
- return hider;
+adblock_element_hider_new(const char *selector, char **domains)
+{
+ AdblockElementHider *hider = dwb_malloc(sizeof(AdblockElementHider));
+ hider->selector = g_strdup(selector);
+ hider->domains = domains;
+ return hider;
}/*}}}*/
/* adblock_element_hider_free {{{*/
static void
-adblock_element_hider_free(AdblockElementHider *hider) {
- if (hider) {
- if (hider->selector) {
- g_free(hider->selector);
- }
- if (hider->domains) {
- g_strfreev(hider->domains);
+adblock_element_hider_free(AdblockElementHider *hider)
+{
+ if (hider)
+ {
+ if (hider->selector)
+ g_free(hider->selector);
+
+ if (hider->domains)
+ g_strfreev(hider->domains);
+
+ g_free(hider);
}
- g_free(hider);
- }
}/*}}}*//*}}}*/
/* MATCH {{{*/
/* inline adblock_do_match(AdblockRule *, const char *) {{{*/
static inline gboolean
-adblock_do_match(AdblockRule *rule, const char *uri) {
- if (g_regex_match(rule->pattern, uri, 0, NULL)) {
- PRINT_DEBUG("blocked %s %s\n", uri, g_regex_get_pattern(rule->pattern));
- return true;
- }
- return false;
+adblock_do_match(AdblockRule *rule, const char *uri)
+{
+ if (g_regex_match(rule->pattern, uri, 0, NULL))
+ {
+ PRINT_DEBUG("blocked %s %s\n", uri, g_regex_get_pattern(rule->pattern));
+ return true;
+ }
+ return false;
}/*}}}*/
/* adblock_match(GPtrArray *, SoupURI *, const char *base_domain, * AdblockAttribute, gboolean thirdparty) {{{
@@ -159,193 +166,208 @@ adblock_do_match(AdblockRule *rule, const char *uri) {
* thirdparty - thirdparty request ?
* */
gboolean
-adblock_match(GPtrArray *array, const char *uri, const char *uri_host, const char *uri_base, const char *host, const char *domain, AdblockAttribute attributes, gboolean thirdparty) {
- if (array->len == 0)
- return false;
- const char *base_start = strstr(uri, uri_base);
- const char *uri_start = strstr(uri, uri_host);
- const char *suburis[SUBDOMAIN_MAX];
- int uc = 0;
- const char *cur = uri_start;
- const char *nextdot;
- AdblockRule *rule;
- /* Get all suburis */
- suburis[uc++] = cur;
- while (cur != base_start) {
- nextdot = strchr(cur, '.');
- cur = nextdot + 1;
+adblock_match(GPtrArray *array, const char *uri, const char *uri_host, const char *uri_base, const char *host, const char *domain, AdblockAttribute attributes, gboolean thirdparty)
+{
+ if (array->len == 0)
+ return false;
+ const char *base_start = strstr(uri, uri_base);
+ const char *uri_start = strstr(uri, uri_host);
+ const char *suburis[SUBDOMAIN_MAX];
+ int uc = 0;
+ const char *cur = uri_start;
+ const char *nextdot;
+ AdblockRule *rule;
+ /* Get all suburis */
suburis[uc++] = cur;
- if (uc == SUBDOMAIN_MAX-1)
- break;
- }
- suburis[uc++] = NULL;
-
- for (guint i=0; i<array->len; i++) {
- rule = g_ptr_array_index(array, i);
- if ( (attributes & AA_DOCUMENT && !(rule->attributes & AA_DOCUMENT)) || (attributes & AA_SUBDOCUMENT && !(rule->attributes & AA_SUBDOCUMENT)) )
- continue;
- /* If exception attributes exists, check if exception is matched */
- if (AA_CLEAR_FRAME(rule->attributes) & AB_CLEAR_LOWER && (AA_CLEAR_FRAME(rule->attributes) == (AA_CLEAR_FRAME(attributes)<<AB_INVERSE)))
- continue;
- /* If attribute restriction exists, check if attribute is matched */
- if (AA_CLEAR_FRAME(rule->attributes) & AB_CLEAR_UPPER && (AA_CLEAR_FRAME(rule->attributes) != AA_CLEAR_FRAME(attributes))) {
- continue;
- }
- if (rule->domains && !domain_match(rule->domains, host, domain)) {
- continue;
- }
- if ( (rule->options & AO_THIRDPARTY && !thirdparty)
- || (rule->options & AO_NOTHIRDPARTY && thirdparty) )
- continue;
- if (rule->options & AO_BEGIN_DOMAIN) {
- for (int i=0; suburis[i]; i++) {
- if ( adblock_do_match(rule, suburis[i]) )
- return true;
- }
+ while (cur != base_start)
+ {
+ nextdot = strchr(cur, '.');
+ cur = nextdot + 1;
+ suburis[uc++] = cur;
+ if (uc == SUBDOMAIN_MAX-1)
+ break;
}
- else if (adblock_do_match(rule, uri)) {
- return true;
+ suburis[uc++] = NULL;
+
+ for (guint i=0; i<array->len; i++)
+ {
+ rule = g_ptr_array_index(array, i);
+ if ( (attributes & AA_DOCUMENT && !(rule->attributes & AA_DOCUMENT)) || (attributes & AA_SUBDOCUMENT && !(rule->attributes & AA_SUBDOCUMENT)) )
+ continue;
+ /* If exception attributes exists, check if exception is matched */
+ if (AA_CLEAR_FRAME(rule->attributes) & AB_CLEAR_LOWER && (AA_CLEAR_FRAME(rule->attributes) == (AA_CLEAR_FRAME(attributes)<<AB_INVERSE)))
+ continue;
+ /* If attribute restriction exists, check if attribute is matched */
+ if (AA_CLEAR_FRAME(rule->attributes) & AB_CLEAR_UPPER && (AA_CLEAR_FRAME(rule->attributes) != AA_CLEAR_FRAME(attributes)))
+ continue;
+ if (rule->domains && !domain_match(rule->domains, host, domain))
+ continue;
+ if ( (rule->options & AO_THIRDPARTY && !thirdparty)
+ || (rule->options & AO_NOTHIRDPARTY && thirdparty) )
+ continue;
+ if (rule->options & AO_BEGIN_DOMAIN)
+ {
+ for (int i=0; suburis[i]; i++)
+ {
+ if ( adblock_do_match(rule, suburis[i]) )
+ return true;
+ }
+ }
+ else if (adblock_do_match(rule, uri))
+ return true;
}
- }
- return false;
+ return false;
}/*}}}*/
/* adblock_prepare_match (const char *uri, const char *baseURI, AdblockAttribute attributes {{{ */
static gboolean
-adblock_prepare_match(const char *uri, const char *baseURI, AdblockAttribute attributes) {
- char *realuri = NULL;
- SoupURI *suri = NULL, *sbaseuri = NULL;
- gboolean ret = false;
-
- if (! g_regex_match_simple("^https?://", uri, 0, 0)) {
- gboolean last_slash = g_str_has_suffix(baseURI, "/");
- if (*uri == '/' && last_slash)
- realuri = g_strconcat(baseURI, uri+1, NULL);
- else if (*uri != '/' && !last_slash)
- realuri = g_strconcat(baseURI, "/", uri, NULL);
+adblock_prepare_match(const char *uri, const char *baseURI, AdblockAttribute attributes)
+{
+ char *realuri = NULL;
+ SoupURI *suri = NULL, *sbaseuri = NULL;
+ gboolean ret = false;
+
+ if (! g_regex_match_simple("^https?://", uri, 0, 0))
+ {
+ gboolean last_slash = g_str_has_suffix(baseURI, "/");
+ if (*uri == '/' && last_slash)
+ realuri = g_strconcat(baseURI, uri+1, NULL);
+ else if (*uri != '/' && !last_slash)
+ realuri = g_strconcat(baseURI, "/", uri, NULL);
+ else
+ realuri = g_strconcat(baseURI, uri, NULL);
+ }
else
- realuri = g_strconcat(baseURI, uri, NULL);
- }
- else
- realuri = g_strdup(uri);
-
- /* FIXME: soup_uri_get_host is just used to get parse the uri */
- suri = soup_uri_new(realuri);
- if (suri == NULL)
- goto error_out;
- const char *host = soup_uri_get_host(suri);
- if (host == NULL)
- goto error_out;
-
- sbaseuri = soup_uri_new(baseURI);
- if (sbaseuri == NULL)
- goto error_out;
-
- const char *basehost = soup_uri_get_host(sbaseuri);
- if (basehost == NULL)
- goto error_out;
-
- const char *domain = domain_get_base_for_host(host);
- const char *basedomain = domain_get_base_for_host(basehost);
- gboolean thirdparty = g_strcmp0(domain, basedomain);
-
- if (!adblock_match(m_exceptions, realuri, host, domain, basehost, basedomain, attributes, thirdparty)) {
- if (adblock_match(m_rules, realuri, host, domain, basehost, basedomain, attributes, thirdparty)) {
- ret = true;
+ realuri = g_strdup(uri);
+
+ /* FIXME: soup_uri_get_host is just used to get parse the uri */
+ suri = soup_uri_new(realuri);
+ if (suri == NULL)
+ goto error_out;
+ const char *host = soup_uri_get_host(suri);
+ if (host == NULL)
+ goto error_out;
+
+ sbaseuri = soup_uri_new(baseURI);
+ if (sbaseuri == NULL)
+ goto error_out;
+
+ const char *basehost = soup_uri_get_host(sbaseuri);
+ if (basehost == NULL)
+ goto error_out;
+
+ const char *domain = domain_get_base_for_host(host);
+ const char *basedomain = domain_get_base_for_host(basehost);
+ gboolean thirdparty = g_strcmp0(domain, basedomain);
+
+ if (!adblock_match(s_exceptions, realuri, host, domain, basehost, basedomain, attributes, thirdparty))
+ {
+ if (adblock_match(s_rules, realuri, host, domain, basehost, basedomain, attributes, thirdparty))
+ ret = true;
}
- }
error_out:
- if (realuri != NULL) g_free(realuri);
- if (sbaseuri != NULL) soup_uri_free(sbaseuri);
- if (suri != NULL) soup_uri_free(suri);
- return ret;
+ if (realuri != NULL) g_free(realuri);
+ if (sbaseuri != NULL) soup_uri_free(sbaseuri);
+ if (suri != NULL) soup_uri_free(suri);
+ return ret;
}/*}}}*/
/* adblock_apply_element_hider(WebKitWebFrame *frame, GList *gl) {{{*/
void
-adblock_apply_element_hider(WebKitWebFrame *frame, GList *gl) {
- GSList *list;
-
- WebKitWebDataSource *datasource = webkit_web_frame_get_data_source(frame);
- WebKitNetworkRequest *request = webkit_web_data_source_get_request(datasource);
-
- SoupMessage *msg = webkit_network_request_get_message(request);
- if (msg == NULL)
- return;
-
- SoupURI *suri = soup_message_get_first_party(msg);
- g_return_if_fail(suri != NULL);
-
- const char *host = soup_uri_get_host(suri);
- const char *base_domain = domain_get_base_for_host(host);
- g_return_if_fail(host != NULL);
- g_return_if_fail(base_domain != NULL);
-
- AdblockElementHider *hider;
- GString *css_rule = g_string_new(NULL);
-
- /* get all subdomains */
- const char *subdomains[SUBDOMAIN_MAX];
- char *nextdot = NULL;
- int uc = 0;
- const char *tmphost = host;
- subdomains[uc++] = tmphost;
- while (tmphost != base_domain) {
- nextdot = strchr(tmphost, '.');
- tmphost = nextdot + 1;
+adblock_apply_element_hider(WebKitWebFrame *frame, GList *gl)
+{
+ GSList *list;
+
+ WebKitWebDataSource *datasource = webkit_web_frame_get_data_source(frame);
+ WebKitNetworkRequest *request = webkit_web_data_source_get_request(datasource);
+
+ SoupMessage *msg = webkit_network_request_get_message(request);
+ if (msg == NULL)
+ return;
+
+ SoupURI *suri = soup_message_get_first_party(msg);
+ g_return_if_fail(suri != NULL);
+
+ const char *host = soup_uri_get_host(suri);
+ const char *base_domain = domain_get_base_for_host(host);
+ g_return_if_fail(host != NULL);
+ g_return_if_fail(base_domain != NULL);
+
+ AdblockElementHider *hider;
+ GString *css_rule = g_string_new(NULL);
+
+ /* get all subdomains */
+ const char *subdomains[SUBDOMAIN_MAX];
+ char *nextdot = NULL;
+ int uc = 0;
+ const char *tmphost = host;
subdomains[uc++] = tmphost;
- if (uc == SUBDOMAIN_MAX-1)
- break;
- }
- subdomains[uc++] = NULL;
-
- gboolean has_exception = false;
- for (int i=0; subdomains[i]; i++) {
- list = g_hash_table_lookup(m_hider_rules, subdomains[i]);
- if (list) {
- for (GSList *l = list; l; l=l->next) {
- hider = l->data;
- if (hider->exception)
- has_exception = true;
- else if (domain_match(hider->domains, host, base_domain)) {
- g_string_append(css_rule, hider->selector);
- g_string_append_c(css_rule, ',');
+ while (tmphost != base_domain)
+ {
+ nextdot = strchr(tmphost, '.');
+ tmphost = nextdot + 1;
+ subdomains[uc++] = tmphost;
+ if (uc == SUBDOMAIN_MAX-1)
+ break;
+ }
+ subdomains[uc++] = NULL;
+
+ gboolean has_exception = false;
+ for (int i=0; subdomains[i]; i++)
+ {
+ list = g_hash_table_lookup(s_hider_rules, subdomains[i]);
+ if (list)
+ {
+ for (GSList *l = list; l; l=l->next)
+ {
+ hider = l->data;
+ if (hider->exception)
+ has_exception = true;
+ else if (domain_match(hider->domains, host, base_domain))
+ {
+ g_string_append(css_rule, hider->selector);
+ g_string_append_c(css_rule, ',');
+ }
+ }
+ break;
}
- }
- break;
}
- }
- /* Adding replaced exceptions */
- if (! has_exception) {
- g_string_append(css_rule, m_css_exceptions->str);
- }
- if (css_rule->str[css_rule->len-1] == ',')
- g_string_erase(css_rule, css_rule->len-1, 1);
- g_string_append(css_rule, "{display:none!important;}");
- if (frame == webkit_web_view_get_main_frame(WEBVIEW(gl))) {
- WebKitDOMDocument *doc = webkit_web_view_get_dom_document(WEBVIEW(gl));
- WebKitDOMHTMLHeadElement *head = webkit_dom_document_get_head(doc);
+ /* Adding replaced exceptions */
+ if (! has_exception)
+ g_string_append(css_rule, s_css_exceptions->str);
- g_return_if_fail(G_IS_OBJECT(head));
+ if (css_rule->str[css_rule->len-1] == ',')
+ g_string_erase(css_rule, css_rule->len-1, 1);
- for (GSList *l = VIEW(gl)->status->styles; l; l=l->next) {
- webkit_dom_node_append_child(WEBKIT_DOM_NODE(head), WEBKIT_DOM_NODE(l->data), NULL);
- }
- if (css_rule->len > 0) {
- webkit_dom_html_element_set_inner_html(WEBKIT_DOM_HTML_ELEMENT(VIEW(gl)->status->exc_style),
- css_rule->str, NULL);
- webkit_dom_node_append_child(WEBKIT_DOM_NODE(head), WEBKIT_DOM_NODE(VIEW(gl)->status->exc_style), NULL);
+ g_string_append(css_rule, "{display:none!important;}");
+
+ if (frame == webkit_web_view_get_main_frame(WEBVIEW(gl)))
+ {
+ WebKitDOMDocument *doc = webkit_web_view_get_dom_document(WEBVIEW(gl));
+ WebKitDOMHTMLHeadElement *head = webkit_dom_document_get_head(doc);
+
+ g_return_if_fail(G_IS_OBJECT(head));
+
+ for (GSList *l = VIEW(gl)->status->styles; l; l=l->next)
+ webkit_dom_node_append_child(WEBKIT_DOM_NODE(head), WEBKIT_DOM_NODE(l->data), NULL);
+
+ if (css_rule->len > 0)
+ {
+ webkit_dom_html_element_set_inner_html(WEBKIT_DOM_HTML_ELEMENT(VIEW(gl)->status->exc_style),
+ css_rule->str, NULL);
+ webkit_dom_node_append_child(WEBKIT_DOM_NODE(head), WEBKIT_DOM_NODE(VIEW(gl)->status->exc_style), NULL);
+ }
}
- }
- else {
- if (css_rule->len > 0)
+ else
{
- js_call_as_function(frame, VIEW(gl)->js_base, "insertAdblockRule", css_rule->str, kJSTypeString, NULL);
+ if (css_rule->len > 0)
+ {
+ js_call_as_function(frame, VIEW(gl)->js_base, "insertAdblockRule", css_rule->str, kJSTypeString, NULL);
+ }
+ for (GSList *l = s_css_hider_list; l; l=l->next)
+ js_call_as_function(frame, VIEW(gl)->js_base, "insertAdblockRule", l->data, kJSTypeString, NULL);
}
- for (GSList *l = m_css_hider_list; l; l=l->next)
- js_call_as_function(frame, VIEW(gl)->js_base, "insertAdblockRule", l->data, kJSTypeString, NULL);
- }
- g_string_free(css_rule, true);
+ g_string_free(css_rule, true);
}/*}}}*/
/*}}}*/
@@ -354,127 +376,139 @@ adblock_apply_element_hider(WebKitWebFrame *frame, GList *gl) {
/* adblock_before_load_cb (domcallback) {{{*/
static gboolean
-adblock_before_load_cb(WebKitDOMDOMWindow *win, WebKitDOMEvent *event, GList *gl) {
- WebKitDOMElement *src = (void*)webkit_dom_event_get_src_element(event);
- char *tagname = webkit_dom_element_get_tag_name(src);
- const char *url = NULL;
-
- gboolean ret = false;
-
- WebKitDOMDocument *doc = webkit_dom_dom_window_get_document(win);
- char *baseURI = webkit_dom_document_get_document_uri(doc);
-
- WebKitDOMDocument *main_doc = webkit_web_view_get_dom_document(WEBVIEW(gl));
- WebKitDOMDOMWindow *main_win = webkit_dom_document_get_default_view(main_doc);
- AdblockAttribute attributes = win == main_win ? AA_DOCUMENT : AA_SUBDOCUMENT;
-
- if (webkit_dom_element_has_attribute(src, "src"))
- url = webkit_dom_element_get_attribute(src, "src");
- else if (webkit_dom_element_has_attribute(src, "href"))
- url = webkit_dom_element_get_attribute(src, "href");
- else if (webkit_dom_element_has_attribute(src, "data"))
- url = webkit_dom_element_get_attribute(src, "data");
- if (url == NULL)
- goto error_out;
-
- if (!g_strcmp0(tagname, "IMG")) {
- attributes |= AA_IMAGE;
- }
- else if (!g_strcmp0(tagname, "SCRIPT"))
- attributes |= AA_SCRIPT;
- else if (!g_strcmp0(tagname, "LINK") ) {
- char *rel = webkit_dom_html_link_element_get_rel((void*)src);
- char *type = webkit_dom_element_get_attribute(src, "type");
- if (!g_strcmp0(rel, "stylesheet") || !g_strcmp0(type, "text/css")) {
- attributes |= AA_STYLESHEET;
+adblock_before_load_cb(WebKitDOMDOMWindow *win, WebKitDOMEvent *event, GList *gl)
+{
+ WebKitDOMElement *src = (void*)webkit_dom_event_get_src_element(event);
+ char *tagname = webkit_dom_element_get_tag_name(src);
+ const char *url = NULL;
+
+ gboolean ret = false;
+
+ WebKitDOMDocument *doc = webkit_dom_dom_window_get_document(win);
+ char *baseURI = webkit_dom_document_get_document_uri(doc);
+
+ WebKitDOMDocument *main_doc = webkit_web_view_get_dom_document(WEBVIEW(gl));
+ WebKitDOMDOMWindow *main_win = webkit_dom_document_get_default_view(main_doc);
+ AdblockAttribute attributes = win == main_win ? AA_DOCUMENT : AA_SUBDOCUMENT;
+
+ if (webkit_dom_element_has_attribute(src, "src"))
+ url = webkit_dom_element_get_attribute(src, "src");
+ else if (webkit_dom_element_has_attribute(src, "href"))
+ url = webkit_dom_element_get_attribute(src, "href");
+ else if (webkit_dom_element_has_attribute(src, "data"))
+ url = webkit_dom_element_get_attribute(src, "data");
+ if (url == NULL)
+ goto error_out;
+
+ if (!g_strcmp0(tagname, "IMG"))
+ attributes |= AA_IMAGE;
+ else if (!g_strcmp0(tagname, "SCRIPT"))
+ attributes |= AA_SCRIPT;
+ else if (!g_strcmp0(tagname, "LINK") )
+ {
+ char *rel = webkit_dom_html_link_element_get_rel((void*)src);
+ char *type = webkit_dom_element_get_attribute(src, "type");
+ if (!g_strcmp0(rel, "stylesheet") || !g_strcmp0(type, "text/css"))
+ attributes |= AA_STYLESHEET;
+
+ g_free(rel);
+ g_free(type);
}
- g_free(rel);
- g_free(type);
- }
- else if (!g_strcmp0(tagname, "OBJECT") || ! g_strcmp0(tagname, "EMBED")) {
- attributes |= AA_OBJECT;
- }
- if (adblock_prepare_match(url, baseURI, attributes)) {
- webkit_dom_event_prevent_default(event);
- }
- ret = true;
+ else if (!g_strcmp0(tagname, "OBJECT") || ! g_strcmp0(tagname, "EMBED"))
+ attributes |= AA_OBJECT;
+
+ if (adblock_prepare_match(url, baseURI, attributes))
+ webkit_dom_event_prevent_default(event);
+
+ ret = true;
error_out:
- g_object_unref(src);
- g_free(tagname);
- g_free(baseURI);
- return ret;
+ g_object_unref(src);
+ g_free(tagname);
+ g_free(baseURI);
+ return ret;
}/*}}}*/
static void
-adblock_frame_load_status_cb(WebKitWebFrame *frame, GParamSpec *p, GList *gl) {
- WebKitLoadStatus status = webkit_web_frame_get_load_status(frame);
- if (status == WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT) {
- adblock_apply_element_hider(frame, gl);
- }
- else if (status == WEBKIT_LOAD_COMMITTED) {
- dwb_dom_add_frame_listener(frame, "beforeload", G_CALLBACK(adblock_before_load_cb), true, gl);
- }
+adblock_frame_load_status_cb(WebKitWebFrame *frame, GParamSpec *p, GList *gl)
+{
+ WebKitLoadStatus status = webkit_web_frame_get_load_status(frame);
+ if (status == WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT)
+ adblock_apply_element_hider(frame, gl);
+ else if (status == WEBKIT_LOAD_COMMITTED)
+ dwb_dom_add_frame_listener(frame, "beforeload", G_CALLBACK(adblock_before_load_cb), true, gl);
}
/* adblock_frame_created_cb {{{*/
void
-adblock_frame_created_cb(WebKitWebView *wv, WebKitWebFrame *frame, GList *gl) {
- g_signal_connect(frame, "notify::load-status", G_CALLBACK(adblock_frame_load_status_cb), gl);
+adblock_frame_created_cb(WebKitWebView *wv, WebKitWebFrame *frame, GList *gl)
+{
+ g_signal_connect(frame, "notify::load-status", G_CALLBACK(adblock_frame_load_status_cb), gl);
}/*}}}*/
/* adblock_resource_request_cb {{{*/
static void
adblock_resource_request_cb(WebKitWebView *wv, WebKitWebFrame *frame,
WebKitWebResource *resource, WebKitNetworkRequest *request,
- WebKitNetworkResponse *response, GList *gl) {
- if (request == NULL)
- return;
- AdblockAttribute attribute = webkit_web_view_get_main_frame(wv) == frame ? AA_DOCUMENT : AA_SUBDOCUMENT;
-
- const char *uri = webkit_network_request_get_uri(request);
- if (uri == NULL)
- return;
- SoupMessage *msg = webkit_network_request_get_message(request);
- if (msg == NULL)
- return;
- SoupURI *suri = soup_message_get_uri(msg);
- const char *host = soup_uri_get_host(suri);
- if (host == NULL)
- return;
- const char *domain = domain_get_base_for_host(host);
- if (domain == NULL)
- return;
-
- SoupURI *sfirst_party = soup_message_get_first_party(msg);
- if (sfirst_party == NULL)
- return;
- const char *firsthost = soup_uri_get_host(sfirst_party);
- if (firsthost == NULL)
- return;
- const char *firstdomain = domain_get_base_for_host(firsthost);
- if (firstdomain == NULL)
- return;
- gboolean thirdparty = g_strcmp0(domain, firstdomain);
-
- if (!adblock_match(m_simple_exceptions, uri, host, domain, firsthost, firstdomain, attribute, thirdparty)) {
- if (adblock_match(m_simple_rules, uri, host, domain, firsthost, firstdomain, attribute, thirdparty)) {
- webkit_network_request_set_uri(request, "about:blank");
+ WebKitNetworkResponse *response, GList *gl)
+{
+ if (request == NULL)
+ return;
+
+ AdblockAttribute attribute = webkit_web_view_get_main_frame(wv) == frame ? AA_DOCUMENT : AA_SUBDOCUMENT;
+
+ const char *uri = webkit_network_request_get_uri(request);
+ if (uri == NULL)
+ return;
+
+ SoupMessage *msg = webkit_network_request_get_message(request);
+ if (msg == NULL)
+ return;
+
+ SoupURI *suri = soup_message_get_uri(msg);
+ const char *host = soup_uri_get_host(suri);
+ if (host == NULL)
+ return;
+
+ const char *domain = domain_get_base_for_host(host);
+ if (domain == NULL)
+ return;
+
+ SoupURI *sfirst_party = soup_message_get_first_party(msg);
+ if (sfirst_party == NULL)
+ return;
+
+ const char *firsthost = soup_uri_get_host(sfirst_party);
+ if (firsthost == NULL)
+ return;
+
+ const char *firstdomain = domain_get_base_for_host(firsthost);
+ if (firstdomain == NULL)
+ return;
+
+ gboolean thirdparty = g_strcmp0(domain, firstdomain);
+
+ if (!adblock_match(s_simple_exceptions, uri, host, domain, firsthost, firstdomain, attribute, thirdparty))
+ {
+ if (adblock_match(s_simple_rules, uri, host, domain, firsthost, firstdomain, attribute, thirdparty))
+ webkit_network_request_set_uri(request, "about:blank");
}
- }
}/*}}}*/
/* adblock_load_status_cb(WebKitWebView *, GParamSpec *, GList *) {{{*/
static void
-adblock_load_status_cb(WebKitWebView *wv, GParamSpec *p, GList *gl) {
- WebKitLoadStatus status = webkit_web_view_get_load_status(wv);
- if (status == WEBKIT_LOAD_COMMITTED) {
- WebKitDOMDocument *doc = webkit_web_view_get_dom_document(wv);
- WebKitDOMDOMWindow *win = webkit_dom_document_get_default_view(doc);
- webkit_dom_event_target_add_event_listener(WEBKIT_DOM_EVENT_TARGET(win), "beforeload", G_CALLBACK(adblock_before_load_cb), true, gl);
- }
- else if (status == WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT) {
- WebKitWebFrame *frame = webkit_web_view_get_main_frame(wv);
- adblock_apply_element_hider(frame, gl);
- }
+adblock_load_status_cb(WebKitWebView *wv, GParamSpec *p, GList *gl)
+{
+ WebKitLoadStatus status = webkit_web_view_get_load_status(wv);
+ if (status == WEBKIT_LOAD_COMMITTED)
+ {
+ WebKitDOMDocument *doc = webkit_web_view_get_dom_document(wv);
+ WebKitDOMDOMWindow *win = webkit_dom_document_get_default_view(doc);
+ webkit_dom_event_target_add_event_listener(WEBKIT_DOM_EVENT_TARGET(win), "beforeload", G_CALLBACK(adblock_before_load_cb), true, gl);
+ }
+ else if (status == WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT)
+ {
+ WebKitWebFrame *frame = webkit_web_view_get_main_frame(wv);
+ adblock_apply_element_hider(frame, gl);
+ }
}/*}}}*//*}}}*/
@@ -482,381 +516,432 @@ adblock_load_status_cb(WebKitWebView *wv, GParamSpec *p, GList *gl) {
gboolean
adblock_running() {
- return m_init && GET_BOOL("adblocker");
+ return s_init && GET_BOOL("adblocker");
}
/* adblock_disconnect(GList *) {{{*/
void
-adblock_disconnect(GList *gl) {
- View *v = VIEW(gl);
- if (v->status->signals[SIG_AD_LOAD_STATUS] > 0) {
- g_signal_handler_disconnect(WEBVIEW(gl), VIEW(gl)->status->signals[SIG_AD_LOAD_STATUS]);
- v->status->signals[SIG_AD_LOAD_STATUS] = 0;
- }
- if (v->status->signals[SIG_AD_FRAME_CREATED] > 0) {
- g_signal_handler_disconnect(WEBVIEW(gl), (VIEW(gl)->status->signals[SIG_AD_FRAME_CREATED]));
- v->status->signals[SIG_AD_FRAME_CREATED] = 0;
- }
- if (v->status->signals[SIG_AD_RESOURCE_REQUEST] > 0) {
- g_signal_handler_disconnect(WEBVIEW(gl), (VIEW(gl)->status->signals[SIG_AD_RESOURCE_REQUEST]));
- v->status->signals[SIG_AD_RESOURCE_REQUEST] = 0;
- }
+adblock_disconnect(GList *gl)
+{
+ View *v = VIEW(gl);
+ if (v->status->signals[SIG_AD_LOAD_STATUS] > 0)
+ {
+ g_signal_handler_disconnect(WEBVIEW(gl), VIEW(gl)->status->signals[SIG_AD_LOAD_STATUS]);
+ v->status->signals[SIG_AD_LOAD_STATUS] = 0;
+ }
+ if (v->status->signals[SIG_AD_FRAME_CREATED] > 0)
+ {
+ g_signal_handler_disconnect(WEBVIEW(gl), (VIEW(gl)->status->signals[SIG_AD_FRAME_CREATED]));
+ v->status->signals[SIG_AD_FRAME_CREATED] = 0;
+ }
+ if (v->status->signals[SIG_AD_RESOURCE_REQUEST] > 0)
+ {
+ g_signal_handler_disconnect(WEBVIEW(gl), (VIEW(gl)->status->signals[SIG_AD_RESOURCE_REQUEST]));
+ v->status->signals[SIG_AD_RESOURCE_REQUEST] = 0;
+ }
}/*}}}*/
/* adblock_connect() {{{*/
void
-adblock_connect(GList *gl) {
- if (!m_init && !adblock_init())
- return;
- if (m_rules->len > 0 || m_css_hider_list != NULL || m_has_hider_rules) {
- VIEW(gl)->status->signals[SIG_AD_LOAD_STATUS] = g_signal_connect(WEBVIEW(gl), "notify::load-status", G_CALLBACK(adblock_load_status_cb), gl);
- VIEW(gl)->status->signals[SIG_AD_FRAME_CREATED] = g_signal_connect(WEBVIEW(gl), "frame-created", G_CALLBACK(adblock_frame_created_cb), gl);
- }
- if (m_simple_rules->len > 0) {
- VIEW(gl)->status->signals[SIG_AD_RESOURCE_REQUEST] = g_signal_connect(WEBVIEW(gl), "resource-request-starting", G_CALLBACK(adblock_resource_request_cb), gl);
- }
- WebKitDOMDocument *doc = webkit_web_view_get_dom_document(WEBVIEW(gl));
- for (GSList *l = m_css_hider_list; l; l=l->next) {
- WebKitDOMElement *style = webkit_dom_document_create_element(doc, "style", NULL);
- webkit_dom_html_element_set_inner_html(WEBKIT_DOM_HTML_ELEMENT(style), l->data, NULL);
- VIEW(gl)->status->styles = g_slist_prepend(VIEW(gl)->status->styles, style);
- }
- VIEW(gl)->status->exc_style = webkit_dom_document_create_element(doc, "style", NULL);
+adblock_connect(GList *gl)
+{
+ if (!s_init && !adblock_init())
+ return;
+ if (s_rules->len > 0 || s_css_hider_list != NULL || s_has_hider_rules)
+ {
+ VIEW(gl)->status->signals[SIG_AD_LOAD_STATUS] = g_signal_connect(WEBVIEW(gl), "notify::load-status", G_CALLBACK(adblock_load_status_cb), gl);
+ VIEW(gl)->status->signals[SIG_AD_FRAME_CREATED] = g_signal_connect(WEBVIEW(gl), "frame-created", G_CALLBACK(adblock_frame_created_cb), gl);
+ }
+ if (s_simple_rules->len > 0)
+ VIEW(gl)->status->signals[SIG_AD_RESOURCE_REQUEST] = g_signal_connect(WEBVIEW(gl), "resource-request-starting", G_CALLBACK(adblock_resource_request_cb), gl);
+
+ WebKitDOMDocument *doc = webkit_web_view_get_dom_document(WEBVIEW(gl));
+ for (GSList *l = s_css_hider_list; l; l=l->next)
+ {
+ WebKitDOMElement *style = webkit_dom_document_create_element(doc, "style", NULL);
+ webkit_dom_html_element_set_inner_html(WEBKIT_DOM_HTML_ELEMENT(style), l->data, NULL);
+ VIEW(gl)->status->styles = g_slist_prepend(VIEW(gl)->status->styles, style);
+ }
+ VIEW(gl)->status->exc_style = webkit_dom_document_create_element(doc, "style", NULL);
}/*}}}*/
/* adblock_warn_ignored(const char *message, const char *rule){{{*/
static void
-adblock_warn_ignored(const char *message, const char *rule) {
- fprintf(stderr, "Adblock warning: %s\n", message);
- fprintf(stderr, "Adblock warning: Rule %s will be ignored\n", rule);
+adblock_warn_ignored(const char *message, const char *rule)
+{
+ fprintf(stderr, "Adblock warning: %s\n", message);
+ fprintf(stderr, "Adblock warning: Rule %s will be ignored\n", rule);
}/*}}}*/
/* adblock_rule_parse(char *filterlist) {{{*/
static void
-adblock_rule_parse(char *filterlist) {
- char **lines = NULL;
- if (g_file_test(filterlist, G_FILE_TEST_IS_DIR)) {
- GString *string = g_string_new(NULL);
- util_get_directory_content(string, filterlist, NULL);
- if (string->str)
- lines = g_strsplit(string->str, "\n", -1);
- g_string_free(string, true);
- }
- else
- lines = util_get_lines(filterlist);
- if (lines == NULL)
- return;
- char *pattern;
- GError *error = NULL;
- char **domain_arr = NULL;
- char *domains;
- const char *domain;
- const char *tmp;
- const char *option_string;
- const char *o;
- char *tmp_a, *tmp_b, *tmp_c;
- int length = 0;
- int option, attributes, inverse;
- gboolean exception;
- GRegex *rule;
- char **options_arr;
- char warning[256];
- int n_css_rules = 0;
- GString *css_rule = g_string_new(NULL);
- for (int i=0; lines[i] != NULL; i++) {
- pattern = lines[i];
-
- //DwbStatus ret = STATUS_OK;
- GRegexCompileFlags regex_flags = G_REGEX_OPTIMIZE | G_REGEX_CASELESS;
- g_strchomp(pattern);
- util_str_chug(pattern);
- if (*pattern == '\0' || *pattern == '!' || *pattern == '[')
- continue;
-
- tmp_a = tmp_b = tmp_c = NULL;
- /* Element hiding rules */
- if ( (tmp = strstr(pattern, "##")) != NULL) {
- /* Match domains */
- if (*pattern != '#') {
- domains = g_strndup(pattern, tmp-pattern);
- domain_arr = g_strsplit(domains, ",", -1);
-
- AdblockElementHider *hider = adblock_element_hider_new(tmp+2, domain_arr);
- GSList *list;
- gboolean hider_exc = true;
- for (; *domain_arr; domain_arr++) {
- domain = *domain_arr;
- if (*domain == '~')
- domain++;
- else
- hider_exc = false;
- list = g_hash_table_lookup(m_hider_rules, domain);
- if (list == NULL) {
- list = g_slist_append(list, hider);
- g_hash_table_insert(m_hider_rules, g_strdup(domain), list);
- }
- else {
- list = g_slist_append(list, hider);
- (void) list;
- }
- m_has_hider_rules = true;
- }
- hider->exception = hider_exc;
- if (hider_exc) {
- g_string_append(m_css_exceptions, tmp + 2);
- g_string_append_c(m_css_exceptions, ',');
- }
- m_hider_list = g_slist_append(m_hider_list, hider);
- g_free(domains);
- }
- /* general rules */
- else {
- g_string_append(css_rule, tmp+2);
- n_css_rules++;
- if (n_css_rules == HIDER_LIST_MAX)
+adblock_rule_parse(char *filterlist)
+{
+ char **lines = NULL;
+ if (g_file_test(filterlist, G_FILE_TEST_IS_DIR))
+ {
+ GString *string = g_string_new(NULL);
+ util_get_directory_content(string, filterlist, NULL);
+ if (string->str)
+ lines = g_strsplit(string->str, "\n", -1);
+
+ g_string_free(string, true);
+ }
+ else
+ lines = util_get_lines(filterlist);
+
+ if (lines == NULL)
+ return;
+
+ char *pattern;
+ GError *error = NULL;
+ char **domain_arr = NULL;
+ char *domains;
+ const char *domain;
+ const char *tmp;
+ const char *option_string;
+ const char *o;
+ char *tmp_a, *tmp_b, *tmp_c;
+ int length = 0;
+ int option, attributes, inverse;
+ gboolean exception;
+ GRegex *rule;
+ char **options_arr;
+ char warning[256];
+ int n_css_rules = 0;
+ GString *css_rule = g_string_new(NULL);
+
+ for (int i=0; lines[i] != NULL; i++)
+ {
+ pattern = lines[i];
+
+ //DwbStatus ret = STATUS_OK;
+ GRegexCompileFlags regex_flags = G_REGEX_OPTIMIZE | G_REGEX_CASELESS;
+ g_strchomp(pattern);
+ util_str_chug(pattern);
+ if (*pattern == '\0' || *pattern == '!' || *pattern == '[')
+ continue;
+
+ tmp_a = tmp_b = tmp_c = NULL;
+ /* Element hiding rules */
+ if ( (tmp = strstr(pattern, "##")) != NULL)
{
- g_string_append(css_rule, "{display:none!important;}");
- m_css_hider_list = g_slist_prepend(m_css_hider_list, css_rule->str);
- n_css_rules = 0;
- g_string_free(css_rule, false);
- css_rule = g_string_new(NULL);
- }
- else {
- g_string_append_c(css_rule, ',');
+ /* Match domains */
+ if (*pattern != '#')
+ {
+ domains = g_strndup(pattern, tmp-pattern);
+ domain_arr = g_strsplit(domains, ",", -1);
+
+ AdblockElementHider *hider = adblock_element_hider_new(tmp+2, domain_arr);
+ GSList *list;
+ gboolean hider_exc = true;
+ for (; *domain_arr; domain_arr++)
+ {
+ domain = *domain_arr;
+ if (*domain == '~')
+ domain++;
+ else
+ hider_exc = false;
+ list = g_hash_table_lookup(s_hider_rules, domain);
+ if (list == NULL)
+ {
+ list = g_slist_append(list, hider);
+ g_hash_table_insert(s_hider_rules, g_strdup(domain), list);
+ }
+ else
+ {
+ list = g_slist_append(list, hider);
+ (void) list;
+ }
+ s_has_hider_rules = true;
+ }
+ hider->exception = hider_exc;
+ if (hider_exc)
+ {
+ g_string_append(s_css_exceptions, tmp + 2);
+ g_string_append_c(s_css_exceptions, ',');
+ }
+ s_hider_list = g_slist_append(s_hider_list, hider);
+ g_free(domains);
+ }
+ /* general rules */
+ else
+ {
+ g_string_append(css_rule, tmp+2);
+ n_css_rules++;
+ if (n_css_rules == HIDER_LIST_MAX)
+ {
+ g_string_append(css_rule, "{display:none!important;}");
+ s_css_hider_list = g_slist_prepend(s_css_hider_list, css_rule->str);
+ n_css_rules = 0;
+ g_string_free(css_rule, false);
+ css_rule = g_string_new(NULL);
+ }
+ else
+ g_string_append_c(css_rule, ',');
+ }
}
- }
- }
- /* Request patterns */
- else {
- exception = false;
- option = 0;
- attributes = 0;
- rule = NULL;
- domain_arr = NULL;
- /* Exception */
- tmp = pattern;
- if (tmp[0] == '@' && tmp[1] == '@') {
- exception = true;
- tmp +=2;
- }
- option_string = strstr(tmp, "$");
- if (option_string != NULL) {
- tmp_a = g_strndup(tmp, option_string - tmp);
- options_arr = g_strsplit(option_string+1, ",", -1);
- for (int i=0; options_arr[i] != NULL; i++) {
- inverse = 0;
- o = options_arr[i];
- /* attributes */
- if (*o == '~') {
- inverse = AB_INVERSE;
- o++;
- }
- if (!g_strcmp0(o, "script"))
- attributes |= (AA_SCRIPT << inverse);
- else if (!g_strcmp0(o, "image"))
- attributes |= (AA_IMAGE << inverse);
- else if (!g_strcmp0(o, "stylesheet"))
- attributes |= (AA_STYLESHEET << inverse);
- else if (!g_strcmp0(o, "object")) {
- attributes |= (AA_OBJECT << inverse);
- }
- else if (!g_strcmp0(o, "subdocument")) {
- attributes |= inverse ? AA_DOCUMENT : AA_SUBDOCUMENT;
- }
- else if (!g_strcmp0(o, "document")) {
- if (exception)
- attributes |= inverse ? AA_DOCUMENT : AA_SUBDOCUMENT;
+ /* Request patterns */
+ else
+ {
+ exception = false;
+ option = 0;
+ attributes = 0;
+ rule = NULL;
+ domain_arr = NULL;
+ /* Exception */
+ tmp = pattern;
+ if (tmp[0] == '@' && tmp[1] == '@')
+ {
+ exception = true;
+ tmp +=2;
+ }
+ option_string = strstr(tmp, "$");
+ if (option_string != NULL)
+ {
+ tmp_a = g_strndup(tmp, option_string - tmp);
+ options_arr = g_strsplit(option_string+1, ",", -1);
+ for (int i=0; options_arr[i] != NULL; i++)
+ {
+ inverse = 0;
+ o = options_arr[i];
+ /* attributes */
+ if (*o == '~')
+ {
+ inverse = AB_INVERSE;
+ o++;
+ }
+ if (!g_strcmp0(o, "script"))
+ attributes |= (AA_SCRIPT << inverse);
+ else if (!g_strcmp0(o, "image"))
+ attributes |= (AA_IMAGE << inverse);
+ else if (!g_strcmp0(o, "stylesheet"))
+ attributes |= (AA_STYLESHEET << inverse);
+ else if (!g_strcmp0(o, "object"))
+ attributes |= (AA_OBJECT << inverse);
+ else if (!g_strcmp0(o, "subdocument"))
+ attributes |= inverse ? AA_DOCUMENT : AA_SUBDOCUMENT;
+ else if (!g_strcmp0(o, "document"))
+ {
+ if (exception)
+ attributes |= inverse ? AA_DOCUMENT : AA_SUBDOCUMENT;
+ else
+ adblock_warn_ignored("Adblock option 'document' can only be applied to exception rules", pattern);
+ }
+ else if (!g_strcmp0(o, "match-case"))
+ option |= AO_MATCH_CASE;
+ else if (!g_strcmp0(o, "third-party"))
+ {
+ if (inverse)
+ option |= AO_NOTHIRDPARTY;
+ else
+ option |= AO_THIRDPARTY;
+ }
+ else if (g_str_has_prefix(o, "domain="))
+ domain_arr = g_strsplit(options_arr[i] + 7, "|", -1);
+ /* Unsupported should only be ignored if they are actually rules, not
+ * exceptions */
+ else if ((inverse && exception) || (!inverse && !exception))
+ {
+ /* currently unsupported xbl, ping, xmlhttprequest, dtd, elemhide,
+ * other, collapse, donottrack, object-subrequest, popup
+ * */
+ snprintf(warning, sizeof(warning), "Adblock option '%s' isn't supported", o);
+ adblock_warn_ignored(warning, pattern);
+ goto error_out;
+ }
+ }
+ tmp = tmp_a;
+ g_strfreev(options_arr);
+ }
+ length = strlen(tmp);
+ /* Beginning of pattern / domain */
+ if (length > 0 && tmp[0] == '|')
+ {
+ if (length > 1 && tmp[1] == '|')
+ {
+ option |= AO_BEGIN_DOMAIN;
+ tmp += 2;
+ length -= 2;
+ }
+ else
+ {
+ option |= AO_BEGIN;
+ tmp++;
+ length--;
+ }
+ }
+ /* End of pattern */
+ if (length > 0 && tmp[length-1] == '|')
+ {
+ tmp_b = g_strndup(tmp, length-1);
+ tmp = tmp_b;
+ option |= AO_END;
+ length--;
+ }
+ /* Regular Expression */
+ if (length > 0 && tmp[0] == '/' && tmp[length-1] == '/')
+ {
+ tmp_c = g_strndup(tmp+1, length-2);
+
+ if ( (option & AO_MATCH_CASE) != 0)
+ regex_flags &= ~G_REGEX_CASELESS;
+ rule = g_regex_new(tmp_c, regex_flags, 0, &error);
+
+ g_free(tmp_c);
+ if (error != NULL)
+ {
+ adblock_warn_ignored("Invalid regular expression", pattern);
+ //ret = STATUS_ERROR;
+ g_clear_error(&error);
+ goto error_out;
+ }
+ }
else
- adblock_warn_ignored("Adblock option 'document' can only be applied to exception rules", pattern);
- }
- else if (!g_strcmp0(o, "match-case"))
- option |= AO_MATCH_CASE;
- else if (!g_strcmp0(o, "third-party")) {
- if (inverse) {
- option |= AO_NOTHIRDPARTY;
+ {
+ GString *buffer = g_string_new(NULL);
+ if (option & AO_BEGIN || option & AO_BEGIN_DOMAIN)
+ g_string_append_c(buffer, '^');
+
+ /* FIXME: possibly use g_regex_escape_string */
+ for (const char *regexp_tmp = tmp; *regexp_tmp; regexp_tmp++ )
+ {
+ switch (*regexp_tmp) {
+ case '^' : g_string_append(buffer, "([\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\x60\\x7B-\\x80]|$)");
+ break;
+ case '*' : g_string_append(buffer, ".*");
+ break;
+ case '?' :
+ case '{' :
+ case '}' :
+ case '(' :
+ case ')' :
+ case '[' :
+ case ']' :
+ case '+' :
+ case '.' :
+ case '\\' :
+ case '|' : g_string_append_c(buffer, '\\');
+ default : g_string_append_c(buffer, *regexp_tmp);
+ }
+ }
+ if (option & AO_END)
+ g_string_append_c(buffer, '$');
+
+ if ( (option & AO_MATCH_CASE) != 0)
+ regex_flags &= ~G_REGEX_CASELESS;
+
+ rule = g_regex_new(buffer->str, regex_flags, 0, &error);
+
+ g_string_free(buffer, true);
+
+ if (error != NULL)
+ {
+ fprintf(stderr, "dwb warning: ignoring adblock rule %s: %s\n", pattern, error->message);
+ g_clear_error(&error);
+ goto error_out;
+ }
}
- else {
- option |= AO_THIRDPARTY;
+
+ AdblockRule *adrule = adblock_rule_new();
+ adrule->attributes = attributes;
+ adrule->pattern = rule;
+ adrule->options = option;
+ adrule->domains = domain_arr;
+
+ if (! (attributes & (AA_DOCUMENT | AA_SUBDOCUMENT)) )
+ adrule->attributes |= AA_SUBDOCUMENT | AA_DOCUMENT;
+
+ if (!(attributes & ~(AA_SUBDOCUMENT | AA_DOCUMENT)))
+ {
+ if (exception)
+ g_ptr_array_add(s_simple_exceptions, adrule);
+ else
+ g_ptr_array_add(s_simple_rules, adrule);
+ }
+ else
+ {
+ if (exception)
+ g_ptr_array_add(s_exceptions, adrule);
+ else
+ g_ptr_array_add(s_rules, adrule);
}
- }
- else if (g_str_has_prefix(o, "domain=")) {
- domain_arr = g_strsplit(options_arr[i] + 7, "|", -1);
- }
- /* Unsupported should only be ignored if they are actually rules, not
- * exceptions */
- else if ((inverse && exception) || (!inverse && !exception)) {
- /* currently unsupported xbl, ping, xmlhttprequest, dtd, elemhide,
- * other, collapse, donottrack, object-subrequest, popup
- * */
- snprintf(warning, sizeof(warning), "Adblock option '%s' isn't supported", o);
- adblock_warn_ignored(warning, pattern);
- goto error_out;
- }
- }
- tmp = tmp_a;
- g_strfreev(options_arr);
- }
- length = strlen(tmp);
- /* Beginning of pattern / domain */
- if (length > 0 && tmp[0] == '|') {
- if (length > 1 && tmp[1] == '|') {
- option |= AO_BEGIN_DOMAIN;
- tmp += 2;
- length -= 2;
- }
- else {
- option |= AO_BEGIN;
- tmp++;
- length--;
- }
- }
- /* End of pattern */
- if (length > 0 && tmp[length-1] == '|') {
- tmp_b = g_strndup(tmp, length-1);
- tmp = tmp_b;
- option |= AO_END;
- length--;
- }
- /* Regular Expression */
- if (length > 0 && tmp[0] == '/' && tmp[length-1] == '/') {
- tmp_c = g_strndup(tmp+1, length-2);
-
- if ( (option & AO_MATCH_CASE) != 0)
- regex_flags &= ~G_REGEX_CASELESS;
- rule = g_regex_new(tmp_c, regex_flags, 0, &error);
-
- g_free(tmp_c);
- if (error != NULL) {
- adblock_warn_ignored("Invalid regular expression", pattern);
- //ret = STATUS_ERROR;
- g_clear_error(&error);
- goto error_out;
- }
- }
- else {
- GString *buffer = g_string_new(NULL);
- if (option & AO_BEGIN || option & AO_BEGIN_DOMAIN) {
- g_string_append_c(buffer, '^');
- }
- /* FIXME: possibly use g_regex_escape_string */
- for (const char *regexp_tmp = tmp; *regexp_tmp; regexp_tmp++ ) {
- switch (*regexp_tmp) {
- case '^' : g_string_append(buffer, "([\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\x60\\x7B-\\x80]|$)");
- break;
- case '*' : g_string_append(buffer, ".*");
- break;
- case '?' :
- case '{' :
- case '}' :
- case '(' :
- case ')' :
- case '[' :
- case ']' :
- case '+' :
- case '.' :
- case '\\' :
- case '|' : g_string_append_c(buffer, '\\');
- default : g_string_append_c(buffer, *regexp_tmp);
- }
- }
- if (option & AO_END) {
- g_string_append_c(buffer, '$');
- }
- if ( (option & AO_MATCH_CASE) != 0)
- regex_flags &= ~G_REGEX_CASELESS;
- rule = g_regex_new(buffer->str, regex_flags, 0, &error);
- g_string_free(buffer, true);
- if (error != NULL) {
- fprintf(stderr, "dwb warning: ignoring adblock rule %s: %s\n", pattern, error->message);
- g_clear_error(&error);
- goto error_out;
}
- }
- AdblockRule *adrule = adblock_rule_new();
- adrule->attributes = attributes;
- adrule->pattern = rule;
- adrule->options = option;
- adrule->domains = domain_arr;
-
- if (! (attributes & (AA_DOCUMENT | AA_SUBDOCUMENT)) )
- adrule->attributes |= AA_SUBDOCUMENT | AA_DOCUMENT;
-
- if (!(attributes & ~(AA_SUBDOCUMENT | AA_DOCUMENT))) {
- if (exception)
- g_ptr_array_add(m_simple_exceptions, adrule);
- else
- g_ptr_array_add(m_simple_rules, adrule);
- }
- else {
- if (exception)
- g_ptr_array_add(m_exceptions, adrule);
- else
- g_ptr_array_add(m_rules, adrule);
- }
- }
error_out:
- g_free(tmp_a);
- g_free(tmp_b);
- }
- if (css_rule->len > 0) {
- g_string_erase(css_rule, css_rule->len-1, 1);
- g_string_append(css_rule, "{display:none!important;}");
- m_css_hider_list = g_slist_prepend(m_css_hider_list, css_rule->str);
- }
- g_string_free(css_rule, false);
- g_strfreev(lines);
+ g_free(tmp_a);
+ g_free(tmp_b);
+ }
+ if (css_rule->len > 0)
+ {
+ g_string_erase(css_rule, css_rule->len-1, 1);
+ g_string_append(css_rule, "{display:none!important;}");
+ s_css_hider_list = g_slist_prepend(s_css_hider_list, css_rule->str);
+ }
+ g_string_free(css_rule, false);
+ g_strfreev(lines);
}/*}}}*/
/* adblock_end() {{{*/
void
-adblock_end() {
- for (GSList *l = m_css_hider_list; l; l=l->next) {
- g_free(l->data);
- }
- g_slist_free(m_css_hider_list);
- if (m_css_exceptions != NULL)
- g_string_free(m_css_exceptions, true);
- if (m_rules != NULL)
- g_ptr_array_free(m_rules, true);
- if (m_simple_rules != NULL)
- g_ptr_array_free(m_simple_rules, true);
- if (m_simple_exceptions != NULL)
- g_ptr_array_free(m_simple_exceptions, true);
- if(m_exceptions != NULL)
- g_ptr_array_free(m_exceptions, true);
- if (m_hider_rules != NULL)
- g_hash_table_remove_all(m_hider_rules);
- if (m_hider_list != NULL) {
- for (GSList *l = m_hider_list; l; l=l->next)
- adblock_element_hider_free((AdblockElementHider*)l->data);
- g_slist_free(m_hider_list);
- }
+adblock_end()
+{
+ for (GSList *l = s_css_hider_list; l; l=l->next)
+ g_free(l->data);
+
+ g_slist_free(s_css_hider_list);
+ if (s_css_exceptions != NULL)
+ g_string_free(s_css_exceptions, true);
+ if (s_rules != NULL)
+ g_ptr_array_free(s_rules, true);
+ if (s_simple_rules != NULL)
+ g_ptr_array_free(s_simple_rules, true);
+ if (s_simple_exceptions != NULL)
+ g_ptr_array_free(s_simple_exceptions, true);
+ if(s_exceptions != NULL)
+ g_ptr_array_free(s_exceptions, true);
+ if (s_hider_rules != NULL)
+ g_hash_table_remove_all(s_hider_rules);
+ if (s_hider_list != NULL)
+ {
+ for (GSList *l = s_hider_list; l; l=l->next)
+ adblock_element_hider_free((AdblockElementHider*)l->data);
+
+ g_slist_free(s_hider_list);
+ }
}/*}}}*/
/* adblock_init() {{{*/
gboolean
-adblock_init() {
- if (m_init)
+adblock_init()
+{
+ if (s_init)
+ return true;
+ if (!GET_BOOL("adblocker"))
+ return false;
+
+ char *filterlist = GET_CHAR("adblocker-filterlist");
+ if (filterlist == NULL)
+ return false;
+
+ char buffer[PATH_MAX];
+
+ filterlist = util_expand_home(buffer, filterlist, sizeof(buffer));
+ if (!g_file_test(filterlist, G_FILE_TEST_EXISTS))
+ {
+ fprintf(stderr, "Filterlist not found: %s\n", filterlist);
+ return false;
+ }
+
+ s_rules = g_ptr_array_new_with_free_func((GDestroyNotify)adblock_rule_free);
+ s_exceptions = g_ptr_array_new_with_free_func((GDestroyNotify)adblock_rule_free);
+ s_simple_rules = g_ptr_array_new_with_free_func((GDestroyNotify)adblock_rule_free);
+ s_simple_exceptions = g_ptr_array_new_with_free_func((GDestroyNotify)adblock_rule_free);
+ s_hider_rules = g_hash_table_new_full((GHashFunc)g_str_hash, (GEqualFunc)g_str_equal, (GDestroyNotify)g_free, NULL);
+ s_css_exceptions = g_string_new(NULL);
+
+ adblock_rule_parse(filterlist);
+ s_init = true;
+
return true;
- if (!GET_BOOL("adblocker"))
- return false;
- char *filterlist = GET_CHAR("adblocker-filterlist");
- if (filterlist == NULL)
- return false;
- char buffer[PATH_MAX];
- filterlist = util_expand_home(buffer, filterlist, sizeof(buffer));
- if (!g_file_test(filterlist, G_FILE_TEST_EXISTS)) {
- fprintf(stderr, "Filterlist not found: %s\n", filterlist);
- return false;
- }
- m_rules = g_ptr_array_new_with_free_func((GDestroyNotify)adblock_rule_free);
- m_exceptions = g_ptr_array_new_with_free_func((GDestroyNotify)adblock_rule_free);
- m_simple_rules = g_ptr_array_new_with_free_func((GDestroyNotify)adblock_rule_free);
- m_simple_exceptions = g_ptr_array_new_with_free_func((GDestroyNotify)adblock_rule_free);
- m_hider_rules = g_hash_table_new_full((GHashFunc)g_str_hash, (GEqualFunc)g_str_equal, (GDestroyNotify)g_free, NULL);
- m_css_exceptions = g_string_new(NULL);
- adblock_rule_parse(filterlist);
- m_init = true;
- return true;
}/*}}}*//*}}}*/
diff --git a/src/application.c b/src/application.c
index 7de9646d..255685b7 100644
--- a/src/application.c
+++ b/src/application.c
@@ -31,26 +31,26 @@ static GOptionContext * application_get_option_context(void);
static void application_start(GApplication *, char **);
/* Option parsing arguments {{{ */
-static gboolean m_opt_list_sessions = false;
-static gboolean m_opt_single = false;
-static gboolean m_opt_override_restore = false;
-static gboolean m_opt_version = false;
-static gboolean m_opt_force = false;
-static gboolean m_opt_enable_scripts = false;
-static gchar *m_opt_restore = NULL;
-static gchar **m_opt_exe = NULL;
-static GIOChannel *m_fallback_channel;
+static gboolean s_opt_list_sessions = false;
+static gboolean s_opt_single = false;
+static gboolean s_opt_override_restore = false;
+static gboolean s_opt_version = false;
+static gboolean s_opt_force = false;
+static gboolean s_opt_enable_scripts = false;
+static gchar *s_opt_restore = NULL;
+static gchar **s_opt_exe = NULL;
+static GIOChannel *s_fallback_channel;
static GOptionEntry options[] = {
{ "embed", 'e', 0, G_OPTION_ARG_INT64, &dwb.gui.wid, "Embed into window with window id wid", "wid"},
- { "force", 'f', 0, G_OPTION_ARG_NONE, &m_opt_force, "Force restoring a saved session, even if another process has restored the session", NULL },
- { "list-sessions", 'l', 0, G_OPTION_ARG_NONE, &m_opt_list_sessions, "List saved sessions and exit", NULL },
- { "new-instance", 'n', 0, G_OPTION_ARG_NONE, &m_opt_single, "Open a new instance, overrides 'single-instance'", NULL},
+ { "force", 'f', 0, G_OPTION_ARG_NONE, &s_opt_force, "Force restoring a saved session, even if another process has restored the session", NULL },
+ { "list-sessions", 'l', 0, G_OPTION_ARG_NONE, &s_opt_list_sessions, "List saved sessions and exit", NULL },
+ { "new-instance", 'n', 0, G_OPTION_ARG_NONE, &s_opt_single, "Open a new instance, overrides 'single-instance'", NULL},
{ "restore", 'r', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, &application_parse_option, "Restore session with name 'sessionname' or default if name is omitted", "sessionname"},
- { "override-restore", 'R', 0, G_OPTION_ARG_NONE, &m_opt_override_restore, "Don't restore last session even if 'save-session' is set", NULL},
+ { "override-restore", 'R', 0, G_OPTION_ARG_NONE, &s_opt_override_restore, "Don't restore last session even if 'save-session' is set", NULL},
{ "profile", 'p', 0, G_OPTION_ARG_STRING, &dwb.misc.profile, "Load configuration for 'profile'", "profile" },
- { "execute", 'x', 0, G_OPTION_ARG_STRING_ARRAY, &m_opt_exe, "Execute commands", NULL},
- { "version", 'v', 0, G_OPTION_ARG_NONE, &m_opt_version, "Show version information and exit", NULL},
- { "enable-scripts", 'S', 0, G_OPTION_ARG_NONE, &m_opt_enable_scripts, "Enable javascript api", NULL},
+ { "execute", 'x', 0, G_OPTION_ARG_STRING_ARRAY, &s_opt_exe, "Execute commands", NULL},
+ { "version", 'v', 0, G_OPTION_ARG_NONE, &s_opt_version, "Show version information and exit", NULL},
+ { "enable-scripts", 'S', 0, G_OPTION_ARG_NONE, &s_opt_enable_scripts, "Enable javascript api", NULL},
{ NULL }
};
static GOptionContext *option_context;
@@ -79,7 +79,7 @@ struct _DwbApplicationClass
};
G_DEFINE_TYPE(DwbApplication, dwb_application, G_TYPE_APPLICATION);
-static DwbApplication *m_app;
+static DwbApplication *s_app;
static void
dwb_application_main(GApplication *app) {
@@ -155,14 +155,14 @@ dwb_application_local_command_line(GApplication *app, gchar ***argv, gint *exit_
argc_remain = g_strv_length(*argv);
- if (m_opt_exe != NULL)
- argc_exe = g_strv_length(m_opt_exe);
+ if (s_opt_exe != NULL)
+ argc_exe = g_strv_length(s_opt_exe);
- if (m_opt_list_sessions) {
+ if (s_opt_list_sessions) {
session_list();
return true;
}
- if (m_opt_version) {
+ if (s_opt_version) {
dwb_version();
return true;
}
@@ -171,7 +171,7 @@ dwb_application_local_command_line(GApplication *app, gchar ***argv, gint *exit_
dwb_init_settings();
single_instance = GET_BOOL("single-instance");
- if (m_opt_single || !single_instance) {
+ if (s_opt_single || !single_instance) {
g_application_set_flags(app, G_APPLICATION_NON_UNIQUE);
}
GDBusConnection *bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
@@ -186,10 +186,10 @@ dwb_application_local_command_line(GApplication *app, gchar ***argv, gint *exit_
return false;
count = i = 0;
restore_args[count++] = g_strdup((*argv)[0]);
- if (m_opt_exe != NULL) {
- for (; m_opt_exe[i] != NULL; i++) {
+ if (s_opt_exe != NULL) {
+ for (; s_opt_exe[i] != NULL; i++) {
restore_args[2*i + count] = g_strdup("-x");
- restore_args[2*i + 1 + count] = m_opt_exe[i];
+ restore_args[2*i + 1 + count] = s_opt_exe[i];
}
}
for (; (*argv)[count]; count++) {
@@ -228,7 +228,7 @@ dwb_application_local_command_line(GApplication *app, gchar ***argv, gint *exit_
if ( (ff = fdopen(fd, "w")) )
remote = true;
if ( remote ) {
- if (argc_remain > 1 || m_opt_exe != NULL) {
+ if (argc_remain > 1 || s_opt_exe != NULL) {
for (int i=1; (*argv)[i]; i++) {
if ( (path = application_local_path((*argv)[i])) ) {
fprintf(ff, "tabopen %s\n", path);
@@ -238,22 +238,22 @@ dwb_application_local_command_line(GApplication *app, gchar ***argv, gint *exit_
fprintf(ff, "tabopen %s\n", (*argv)[i]);
}
}
- if (m_opt_exe != NULL) {
- for (int i = 0; m_opt_exe[i]; i++) {
- fprintf(ff, "%s\n", m_opt_exe[i]);
+ if (s_opt_exe != NULL) {
+ for (int i = 0; s_opt_exe[i]; i++) {
+ fprintf(ff, "%s\n", s_opt_exe[i]);
}
}
goto clean;
}
}
else {
- GIOChannel *m_fallback_channel = g_io_channel_new_file(unififo, "r+", NULL);
- g_io_add_watch(m_fallback_channel, G_IO_IN, (GIOFunc)application_handle_channel, NULL);
+ GIOChannel *s_fallback_channel = g_io_channel_new_file(unififo, "r+", NULL);
+ g_io_add_watch(s_fallback_channel, G_IO_IN, (GIOFunc)application_handle_channel, NULL);
}
}
}
- if (GET_BOOL("save-session") && !remote && !m_opt_single)
- m_opt_force = true;
+ if (GET_BOOL("save-session") && !remote && !s_opt_single)
+ s_opt_force = true;
application_start(app, *argv);
clean:
if (ff != NULL)
@@ -294,10 +294,10 @@ application_execute_args(char **argv) {
view_add(argv[i], false);
}
}
- if (m_opt_exe != NULL) {
- int length = g_strv_length(m_opt_exe);
+ if (s_opt_exe != NULL) {
+ int length = g_strv_length(s_opt_exe);
for (int i=offset; i<length; i++) {
- dwb_parse_commands(m_opt_exe[i]);
+ dwb_parse_commands(s_opt_exe[i]);
}
offset = length;
}
@@ -313,18 +313,18 @@ application_start(GApplication *app, char **argv) {
dwb_init();
dwb_pack(GET_CHAR("widget-packing"), false);
- scripts_init(m_opt_enable_scripts);
+ scripts_init(s_opt_enable_scripts);
- if (m_opt_force)
+ if (s_opt_force)
session_flags |= SESSION_FORCE;
/* restore session */
- if (! m_opt_override_restore) {
- if (GET_BOOL("save-session") || m_opt_restore != NULL) {
- restored = session_restore(m_opt_restore, session_flags);
+ if (! s_opt_override_restore) {
+ if (GET_BOOL("save-session") || s_opt_restore != NULL) {
+ restored = session_restore(s_opt_restore, session_flags);
}
}
else {
- session_restore(m_opt_restore, session_flags | SESSION_ONLY_MARK);
+ session_restore(s_opt_restore, session_flags | SESSION_ONLY_MARK);
}
if ((! restored && g_strv_length(argv) == 1)) {
view_add(NULL, false);
@@ -360,9 +360,9 @@ static gboolean /* application_parse_option(const gchar *key, const gchar *value
application_parse_option(const gchar *key, const gchar *value, gpointer data, GError **error) {
if (!g_strcmp0(key, "-r") || !g_strcmp0(key, "--restore")) {
if (value != NULL)
- m_opt_restore = g_strdup(value);
+ s_opt_restore = g_strdup(value);
else
- m_opt_restore = g_strdup("default");
+ s_opt_restore = g_strdup("default");
return true;
}
else {
@@ -373,17 +373,17 @@ application_parse_option(const gchar *key, const gchar *value, gpointer data, GE
void /* application_stop() {{{*/
application_stop(void) {
- if (m_fallback_channel != NULL) {
- g_io_channel_shutdown(m_fallback_channel, true, NULL);
- g_io_channel_unref(m_fallback_channel);
+ if (s_fallback_channel != NULL) {
+ g_io_channel_shutdown(s_fallback_channel, true, NULL);
+ g_io_channel_unref(s_fallback_channel);
}
- g_application_release(G_APPLICATION(m_app));
+ g_application_release(G_APPLICATION(s_app));
}/*}}}*/
gint /* application_run(gint, char **) {{{*/
application_run(gint argc, gchar **argv) {
- m_app = dwb_application_new("org.bitbucket.dwb", 0);
- gint ret = g_application_run(G_APPLICATION(m_app), argc, argv);
- g_object_unref(m_app);
+ s_app = dwb_application_new("org.bitbucket.dwb", 0);
+ gint ret = g_application_run(G_APPLICATION(s_app), argc, argv);
+ g_object_unref(s_app);
return ret;
}/*}}}*/
diff --git a/src/completion.c b/src/completion.c
index c9df8223..41159758 100644
--- a/src/completion.c
+++ b/src/completion.c
@@ -29,11 +29,11 @@ static GList * completion_update_completion(GtkWidget *box, GList *comps, GList
static GList * completion_get_simple_completion(GList *gl);
typedef gboolean (*Match_Func)(char*, const char*);
-static char *m_typed;
-static int m_last_buf;
-static gboolean m_leading0 = false;
-static char *m_current_command;
-static int m_command_len;
+static char *s_typed;
+static int s_last_buf;
+static gboolean s_leading0 = false;
+static char *s_current_command;
+static int s_command_len;
/* GUI_FUNCTIONS {{{*/
/* completion_modify_completion_item(Completion *c, GdkColor *fg, GdkColor *bg, PangoFontDescription *fd) {{{*/
@@ -101,7 +101,7 @@ completion_init_completion(GList *store, GList *gl, gboolean word_beginnings, vo
const char *input = GET_TEXT();
gboolean match;
char **token = NULL;
- m_typed = g_strdup(input);
+ s_typed = g_strdup(input);
if (dwb.state.mode & COMMAND_MODE)
input = strchr(input, ' ');
if (input == NULL)
@@ -156,10 +156,10 @@ completion_set_entry_text(Completion *c)
break;
}
- if (dwb.state.mode & COMMAND_MODE && m_current_command)
+ if (dwb.state.mode & COMMAND_MODE && s_current_command)
{
- gtk_entry_set_text(GTK_ENTRY(dwb.gui.entry), m_current_command);
- l = strlen(m_current_command);
+ gtk_entry_set_text(GTK_ENTRY(dwb.gui.entry), s_current_command);
+ l = strlen(s_current_command);
gtk_editable_insert_text(GTK_EDITABLE(dwb.gui.entry), " ", -1, &l);
gtk_editable_insert_text(GTK_EDITABLE(dwb.gui.entry), text, -1, &l);
}
@@ -278,18 +278,18 @@ completion_clean_completion(gboolean set_text)
dwb.comps.view = NULL;
dwb.comps.completions = NULL;
dwb.comps.active_comp = NULL;
- if (set_text && m_typed != NULL)
- entry_set_text(m_typed);
+ if (set_text && s_typed != NULL)
+ entry_set_text(s_typed);
- FREE0(m_current_command);
- m_command_len = 0;
+ FREE0(s_current_command);
+ s_command_len = 0;
- FREE0(m_typed);
+ FREE0(s_typed);
if (dwb.state.mode & COMPLETE_BUFFER)
{
- m_last_buf = 0;
- m_leading0 = false;
+ s_last_buf = 0;
+ s_leading0 = false;
dwb.state.mode &= ~COMPLETE_BUFFER;
dwb_change_mode(NORMAL_MODE, true);
}
@@ -471,7 +471,7 @@ completion_get_quickmarks(int back)
Quickmark *q;
char *escaped = NULL;
const char *input = GET_TEXT();
- m_typed = g_strdup(input);
+ s_typed = g_strdup(input);
for (GList *l = dwb.fc.quickmarks; l; l=l->next)
{
@@ -520,18 +520,18 @@ completion_buffer_key_press(GdkEventKey *e)
}
else
{
- m_last_buf = 10*m_last_buf + value;
- if (m_last_buf > length) {
+ s_last_buf = 10*s_last_buf + value;
+ if (s_last_buf > length) {
completion_clean_completion(false);
dwb_change_mode(NORMAL_MODE, true);
return;
}
- if (m_last_buf != 0) {
- if ((m_last_buf < 10 && m_leading0 == true) || m_last_buf >= 10)
- completion_buffer_exec(g_list_nth(dwb.state.views, m_last_buf-1));
+ if (s_last_buf != 0) {
+ if ((s_last_buf < 10 && s_leading0 == true) || s_last_buf >= 10)
+ completion_buffer_exec(g_list_nth(dwb.state.views, s_last_buf-1));
}
else
- m_leading0 = true;
+ s_leading0 = true;
}
}
}
@@ -620,13 +620,13 @@ completion_command_line()
}
if (ret)
{
- m_command_len = util_strlen_trailing_space(text);
- if ((m_command_len > 0 && g_ascii_isspace(text[m_command_len-1])) || token[1] != NULL)
+ s_command_len = util_strlen_trailing_space(text);
+ if ((s_command_len > 0 && g_ascii_isspace(text[s_command_len-1])) || token[1] != NULL)
{
- FREE0(m_current_command);
- m_current_command = g_strdup(token[0]);
+ FREE0(s_current_command);
+ s_current_command = g_strdup(token[0]);
dwb.state.mode |= COMPLETE_COMMAND_MODE;
- m_command_len++;
+ s_command_len++;
}
else
ret = false;
diff --git a/src/domain.c b/src/domain.c
index 437466f1..70e16b75 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -21,7 +21,7 @@
#include "domain.h"
#include "tlds.h"
-static GHashTable *m_tld_table;
+static GHashTable *s_tld_table;
GSList *
domain_get_cookie_domains(WebKitWebView *wv)
@@ -129,7 +129,7 @@ domain_get_base_for_host(const char *host)
{
if (host == NULL)
return NULL;
- g_return_val_if_fail(m_tld_table != NULL, NULL);
+ g_return_val_if_fail(s_tld_table != NULL, NULL);
const char *cur_domain = host;
const char *prev_domain = host;
@@ -140,7 +140,7 @@ domain_get_base_for_host(const char *host)
while (1)
{
- entry = g_hash_table_lookup(m_tld_table, cur_domain);
+ entry = g_hash_table_lookup(s_tld_table, cur_domain);
if (entry != NULL)
{
if (*entry == '*')
@@ -177,10 +177,10 @@ domain_get_base_for_host(const char *host)
void
domain_end()
{
- if (m_tld_table)
+ if (s_tld_table)
{
- g_hash_table_unref(m_tld_table);
- m_tld_table = NULL;
+ g_hash_table_unref(s_tld_table);
+ s_tld_table = NULL;
}
}
@@ -188,7 +188,7 @@ domain_end()
void
domain_init()
{
- m_tld_table = g_hash_table_new((GHashFunc)g_str_hash, (GEqualFunc)g_str_equal);
+ s_tld_table = g_hash_table_new((GHashFunc)g_str_hash, (GEqualFunc)g_str_equal);
char *eff_tld;
for (int i=0; (eff_tld = TLDS_EFFECTIVE[i]); i++)
{
@@ -198,6 +198,6 @@ domain_init()
if (*eff_tld == '.')
eff_tld++;
- g_hash_table_insert(m_tld_table, eff_tld, TLDS_EFFECTIVE[i]);
+ g_hash_table_insert(s_tld_table, eff_tld, TLDS_EFFECTIVE[i]);
}
}
diff --git a/src/download.c b/src/download.c
index e4e2a3c1..b84047fd 100644
--- a/src/download.c
+++ b/src/download.c
@@ -48,9 +48,9 @@ typedef struct _DwbDownloadStatus {
#define DWB_DOWNLOAD(X) ((DwbDownload*)((X)->data))
-static GList *m_downloads = NULL;
-static char *m_lastdir = NULL;
-static DownloadAction m_lastaction;
+static GList *s_downloads = NULL;
+static char *s_lastdir = NULL;
+static DownloadAction s_lastaction;
/* dwb_get_command_from_mimetype(char *mimetype){{{*/
static char *
@@ -146,7 +146,7 @@ download_spawn_external(const char *uri, const char *filename, WebKitDownload *d
static GList *
download_get_download_label(WebKitDownload *download)
{
- for (GList *l = m_downloads; l; l=l->next)
+ for (GList *l = s_downloads; l; l=l->next)
{
DwbDownload *label = l->data;
if (label->download == download)
@@ -284,7 +284,7 @@ download_delay(DwbDownload *download)
g_free(download->path);
g_free(download->mimetype);
g_free(download);
- if (!m_downloads)
+ if (!s_downloads)
gtk_widget_hide(dwb.gui.downloadbar);
return false;
@@ -331,7 +331,7 @@ download_status_cb(WebKitDownload *download, GParamSpec *p, DwbDownloadStatus *d
g_signal_handler_disconnect(label->event, label->sig_button);
label->download = NULL;
g_timeout_add_seconds(dwb.misc.message_delay, (GSourceFunc)download_delay, label);
- m_downloads = g_list_delete_link(m_downloads, list);
+ s_downloads = g_list_delete_link(s_downloads, list);
}
if (dwb.state.mimetype_request)
{
@@ -356,15 +356,15 @@ download_button_press_cb(GtkWidget *w, GdkEventButton *e, GList *gl)
DwbStatus
download_cancel(int number)
{
- if (m_downloads == NULL)
+ if (s_downloads == NULL)
return STATUS_ERROR;
if (number <= 0)
{
- webkit_download_cancel(DWB_DOWNLOAD(m_downloads)->download);
+ webkit_download_cancel(DWB_DOWNLOAD(s_downloads)->download);
return STATUS_OK;
}
- for (GList *l = m_downloads; l; l=l->next)
+ for (GList *l = s_downloads; l; l=l->next)
{
if ((gint)DWB_DOWNLOAD(l)->n == number)
{
@@ -509,7 +509,7 @@ download_start(const char *path)
char *cache_name = g_build_filename(dwb.files[FILES_CACHEDIR], filename, NULL);
fullpath = g_strconcat("file://", cache_name, NULL);
g_free(cache_name);
- m_lastaction = DL_ACTION_EXECUTE;
+ s_lastaction = DL_ACTION_EXECUTE;
}
else
{
@@ -545,7 +545,7 @@ download_start(const char *path)
path = path_buffer;
}
}
- m_lastaction = DL_ACTION_DOWNLOAD;
+ s_lastaction = DL_ACTION_DOWNLOAD;
}
if (external && dwb.state.dl_action == DL_ACTION_DOWNLOAD)
@@ -556,7 +556,7 @@ download_start(const char *path)
else
{
webkit_download_set_destination_uri(dwb.state.download, fullpath);
- int n = g_list_length(m_downloads)+1;
+ int n = g_list_length(s_downloads)+1;
DwbDownload *active = download_add_progress_label(dwb.state.fview, filename, n);
active->action = dwb.state.dl_action;
@@ -565,7 +565,7 @@ download_start(const char *path)
active->mimetype = dwb.state.mimetype_request != NULL ? g_strdup(dwb.state.mimetype_request) : NULL;
gtk_widget_show_all(dwb.gui.downloadbar);
- m_downloads = g_list_prepend(m_downloads, active);
+ s_downloads = g_list_prepend(s_downloads, active);
DwbDownloadStatus *s = dwb_malloc(sizeof(DwbDownloadStatus));
s->blue = s->time = 0;
@@ -573,17 +573,17 @@ download_start(const char *path)
s->progress = 0;
s->speedtime = g_get_monotonic_time();
- active->sig_button = g_signal_connect(active->event, "button-press-event", G_CALLBACK(download_button_press_cb), m_downloads);
+ active->sig_button = g_signal_connect(active->event, "button-press-event", G_CALLBACK(download_button_press_cb), s_downloads);
g_signal_connect(dwb.state.download, "notify::current-size", G_CALLBACK(download_progress_cb), s);
g_signal_connect(dwb.state.download, "notify::status", G_CALLBACK(download_status_cb), s);
webkit_download_start(dwb.state.download);
dwb.state.download_ref_count++;
}
- g_free(m_lastdir);
+ g_free(s_lastdir);
if (dwb.state.dl_action != DL_ACTION_EXECUTE)
{
- m_lastdir = g_strdup(path);
+ s_lastdir = g_strdup(path);
}
}
@@ -606,9 +606,9 @@ download_entry_set_directory()
entry_set_text(default_dir);
return;
}
- else if (m_lastdir != NULL)
+ else if (s_lastdir != NULL)
{
- entry_set_text(m_lastdir);
+ entry_set_text(s_lastdir);
return;
}
else
@@ -659,7 +659,7 @@ download_get_path(GList *gl, WebKitDownload *d)
entry_focus();
dwb.state.mode = DOWNLOAD_GET_PATH;
dwb.state.download = d;
- if ( m_lastaction != DL_ACTION_DOWNLOAD &&
+ if ( s_lastaction != DL_ACTION_DOWNLOAD &&
( command != NULL || g_file_test(uri, G_FILE_TEST_EXISTS)) )
{
dwb.state.dl_action = DL_ACTION_EXECUTE;
diff --git a/src/dwb.c b/src/dwb.c
index 4447c0ac..f258bf4e 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -99,11 +99,11 @@ static Navigation * dwb_get_search_completion(const char *text);
static void dwb_clean_vars(void);
typedef struct _EditorInfo {
- char *filename;
- char *id;
- GList *gl;
- WebKitDOMElement *element;
- char *tagname;
+ char *filename;
+ char *id;
+ GList *gl;
+ WebKitDOMElement *element;
+ char *tagname;
} EditorInfo;
typedef struct _UserScriptEnv {
diff --git a/src/entry.c b/src/entry.c
index 1f69a871..f291e395 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -18,7 +18,7 @@
#include "dwb.h"
#include "entry.h"
-static char *m_store;
+static char *s_store;
/* dwb_entry_history_forward {{{*/
DwbStatus
entry_history_forward(GList **last) {
@@ -26,7 +26,7 @@ entry_history_forward(GList **last) {
GList *prev = NULL;
if (*last != NULL) {
if ((*last)->prev == NULL) {
- text = m_store;
+ text = s_store;
}
else {
prev = (*last)->prev;
@@ -50,8 +50,8 @@ entry_history_back(GList **list, GList **last) {
GList *next;
if (*last == NULL) {
next = *list;
- g_free(m_store);
- m_store = g_strdup(GET_TEXT());
+ g_free(s_store);
+ s_store = g_strdup(GET_TEXT());
}
else if ((*last)->next != NULL)
next = (*last)->next;
diff --git a/src/scratchpad.c b/src/scratchpad.c
index 0b9db069..11028c33 100644
--- a/src/scratchpad.c
+++ b/src/scratchpad.c
@@ -21,7 +21,7 @@
#include "scripts.h"
#include <JavaScriptCore/JavaScript.h>
-GtkWidget *g_scratchpad;
+GtkWidget *s_scratchpad;
static gboolean
navigation_cb(WebKitWebView *wv, WebKitWebFrame *frame, WebKitNetworkRequest *request,
WebKitWebNavigationAction *action, WebKitWebPolicyDecision *decision)
@@ -69,11 +69,11 @@ void
scratchpad_load(const char *text)
{
if (g_str_has_prefix(text, "file://"))
- webkit_web_view_load_uri(WEBKIT_WEB_VIEW(g_scratchpad), text);
+ webkit_web_view_load_uri(WEBKIT_WEB_VIEW(s_scratchpad), text);
else
{
char *basepath = g_strconcat("file://", g_getenv("HOME"), NULL);
- webkit_web_view_load_string(WEBKIT_WEB_VIEW(g_scratchpad), text, NULL, NULL, basepath);
+ webkit_web_view_load_string(WEBKIT_WEB_VIEW(s_scratchpad), text, NULL, NULL, basepath);
g_free(basepath);
}
}
@@ -81,30 +81,30 @@ scratchpad_load(const char *text)
void
scratchpad_show(void)
{
- gtk_widget_show(g_scratchpad);
- gtk_widget_grab_focus(g_scratchpad);
+ gtk_widget_show(s_scratchpad);
+ gtk_widget_grab_focus(s_scratchpad);
}
void
scratchpad_hide(void)
{
- gtk_widget_hide(g_scratchpad);
+ gtk_widget_hide(s_scratchpad);
dwb_focus_scroll(dwb.state.fview);
}
static void
scratchpad_init(void)
{
- g_scratchpad = webkit_web_view_new();
- g_signal_connect(g_scratchpad, "navigation-policy-decision-requested", G_CALLBACK(navigation_cb), NULL);
- g_signal_connect(g_scratchpad, "window-object-cleared", G_CALLBACK(window_object_cb), NULL);
- gtk_widget_set_size_request(g_scratchpad, -1, 200);
+ s_scratchpad = webkit_web_view_new();
+ g_signal_connect(s_scratchpad, "navigation-policy-decision-requested", G_CALLBACK(navigation_cb), NULL);
+ g_signal_connect(s_scratchpad, "window-object-cleared", G_CALLBACK(window_object_cb), NULL);
+ gtk_widget_set_size_request(s_scratchpad, -1, 200);
}
GtkWidget *
scratchpad_get(void)
{
- if (g_scratchpad == NULL)
+ if (s_scratchpad == NULL)
scratchpad_init();
- return g_scratchpad;
+ return s_scratchpad;
}
diff --git a/src/scripts.c b/src/scripts.c
index caadd778..b60629c6 100644
--- a/src/scripts.c
+++ b/src/scripts.c
@@ -41,7 +41,7 @@
#define PROP_LENGTH 128
#define G_FILE_TEST_VALID (G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK | G_FILE_TEST_IS_DIR | G_FILE_TEST_IS_EXECUTABLE | G_FILE_TEST_EXISTS)
-typedef struct m_Sigmap {
+typedef struct Sigmap_s {
int sig;
const char *name;
} Sigmap;
@@ -62,11 +62,11 @@ struct _SSignal {
GObject *object;
JSObjectRef func;
};
-//static GSList *m_signals;
+//static GSList *s_signals;
#define S_SIGNAL(X) ((SSignal*)X->data)
-static Sigmap m_sigmap[] = {
+static Sigmap s_sigmap[] = {
{ SCRIPTS_SIG_NAVIGATION, "navigation" },
{ SCRIPTS_SIG_LOAD_STATUS, "loadStatus" },
{ SCRIPTS_SIG_MIME_TYPE, "mimeType" },
@@ -200,18 +200,18 @@ static void make_callback(JSContextRef ctx, JSObjectRef this, GObject *gobject,
static JSObjectRef make_object(JSContextRef ctx, GObject *o);
/* Static variables */
-static JSObjectRef m_sig_objects[SCRIPTS_SIG_LAST];
-static JSGlobalContextRef m_global_context;
-static GSList *m_script_list;
-static JSClassRef m_gobject_class, m_webview_class, m_frame_class, m_download_class, m_download_class, m_message_class;
-static gboolean m_commandline = false;
-static JSObjectRef m_array_contructor;
-static JSObjectRef m_completion_callback;
-static JSObjectRef m_sp_scripts_cb;
-static JSObjectRef m_sp_scratchpad_cb;
+static JSObjectRef s_sig_objects[SCRIPTS_SIG_LAST];
+static JSGlobalContextRef s_global_context;
+static GSList *s_script_list;
+static JSClassRef s_gobject_class, s_webview_class, s_frame_class, s_download_class, s_download_class, s_message_class;
+static gboolean s_commandline = false;
+static JSObjectRef s_array_contructor;
+static JSObjectRef s_completion_callback;
+static JSObjectRef s_sp_scripts_cb;
+static JSObjectRef s_sp_scratchpad_cb;
static GQuark ref_quark;
-static JSObjectRef m_init_before, m_init_after;
-static JSObjectRef m_constructors[CONSTRUCTOR_LAST];
+static JSObjectRef s_init_before, s_init_after;
+static JSObjectRef s_constructors[CONSTRUCTOR_LAST];
/* Only defined once */
static JSValueRef UNDEFINED, NIL;
@@ -248,14 +248,14 @@ uncamelize(char *uncamel, const char *camel, char rep, size_t length)
static JSValueRef
inject(JSContextRef ctx, JSContextRef wctx, JSObjectRef function, JSObjectRef this, size_t argc, const JSValueRef argv[], JSValueRef* exc)
{
- JSValueRef ret = NULL;
+ JSValueRef ret = NIL;
gboolean global = false;
JSValueRef args[1];
int count = 0;
if (argc < 1)
{
- js_make_exception(ctx, exc, EXCEPTION("webview.inject: missing argument"));
- return JSValueMakeBoolean(ctx, false);
+ js_make_exception(ctx, exc, EXCEPTION("inject: missing argument"));
+ return NIL;
}
if (argc > 1 && !JSValueIsNull(ctx, argv[1]))
{
@@ -270,10 +270,7 @@ inject(JSContextRef ctx, JSContextRef wctx, JSObjectRef function, JSObjectRef th
return NIL;
if (global)
- {
JSEvaluateScript(wctx, script, NULL, NULL, 0, NULL);
- ret = NIL;
- }
else
{
JSObjectRef func = JSObjectMakeFunction(wctx, NULL, 0, NULL, script, NULL, 0, NULL);
@@ -286,8 +283,6 @@ inject(JSContextRef ctx, JSContextRef wctx, JSObjectRef function, JSObjectRef th
ret = js_char_to_value(ctx, retx);
g_free(retx);
}
- else
- ret = UNDEFINED;
}
}
JSStringRelease(script);
@@ -304,12 +299,12 @@ callback_data_new(GObject *gobject, JSObjectRef object, JSObjectRef callback, St
c->gobject = gobject != NULL ? g_object_ref(gobject) : NULL;
if (object != NULL)
{
- JSValueProtect(m_global_context, object);
+ JSValueProtect(s_global_context, object);
c->object = object;
}
if (object != NULL)
{
- JSValueProtect(m_global_context, callback);
+ JSValueProtect(s_global_context, callback);
c->callback = callback;
}
c->notify = notify;
@@ -325,10 +320,10 @@ callback_data_free(CallbackData *c)
if (c->gobject != NULL)
g_object_unref(c->gobject);
if (c->object != NULL)
- JSValueUnprotect(m_global_context, c->object);
- JSValueUnprotect(m_global_context, c->object);
+ JSValueUnprotect(s_global_context, c->object);
+ JSValueUnprotect(s_global_context, c->object);
if (c->object != NULL)
- JSValueUnprotect(m_global_context, c->callback);
+ JSValueUnprotect(s_global_context, c->callback);
g_free(c);
}
}/*}}}*/
@@ -375,9 +370,9 @@ callback(CallbackData *c)
{
gboolean ret = false;
JSValueRef val[] = { c->object != NULL ? c->object : NIL };
- JSValueRef jsret = JSObjectCallAsFunction(m_global_context, c->callback, NULL, 1, val, NULL);
- if (JSValueIsBoolean(m_global_context, jsret))
- ret = JSValueToBoolean(m_global_context, jsret);
+ JSValueRef jsret = JSObjectCallAsFunction(s_global_context, c->callback, NULL, 1, val, NULL);
+ if (JSValueIsBoolean(s_global_context, jsret))
+ ret = JSValueToBoolean(s_global_context, jsret);
if (ret || (c != NULL && c->gobject != NULL && c->notify != NULL && c->notify(c)))
{
g_signal_handlers_disconnect_by_func(c->gobject, callback, c);
@@ -668,7 +663,7 @@ wv_get_tab_widget(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSV
GList *gl = find_webview(object);
if (gl == NULL)
return NIL;
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(VIEW(gl)->tabevent), true);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(VIEW(gl)->tabevent), true);
}
static JSValueRef
wv_get_tab_box(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception)
@@ -676,7 +671,7 @@ wv_get_tab_box(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValu
GList *gl = find_webview(object);
if (gl == NULL)
return NIL;
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(VIEW(gl)->tabbox), true);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(VIEW(gl)->tabbox), true);
}
static JSValueRef
wv_get_tab_label(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception)
@@ -684,7 +679,7 @@ wv_get_tab_label(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSVa
GList *gl = find_webview(object);
if (gl == NULL)
return NIL;
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(VIEW(gl)->tablabel), true);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(VIEW(gl)->tablabel), true);
}
static JSValueRef
wv_get_tab_icon(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception)
@@ -692,7 +687,7 @@ wv_get_tab_icon(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSVal
GList *gl = find_webview(object);
if (gl == NULL)
return NIL;
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(VIEW(gl)->tabicon), true);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(VIEW(gl)->tabicon), true);
}
static JSValueRef
@@ -701,7 +696,7 @@ wv_get_scrolled_window(JSContextRef ctx, JSObjectRef object, JSStringRef js_name
GList *gl = find_webview(object);
if (gl == NULL)
return NIL;
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(VIEW(gl)->scroll), true);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(VIEW(gl)->scroll), true);
}
@@ -745,13 +740,13 @@ sp_callback_create(JSContextRef ctx, size_t argc, const JSValueRef argv[], JSVal
static JSValueRef
sp_get(JSContextRef ctx, JSObjectRef function, JSObjectRef this, size_t argc, const JSValueRef argv[], JSValueRef* exc)
{
- m_sp_scripts_cb = sp_callback_create(ctx, argc, argv, exc);
+ s_sp_scripts_cb = sp_callback_create(ctx, argc, argv, exc);
return UNDEFINED;
}
void
scripts_scratchpad_get(JSContextRef ctx, JSObjectRef function, JSObjectRef this, size_t argc, const JSValueRef argv[], JSValueRef* exc)
{
- m_sp_scratchpad_cb = sp_callback_create(ctx, argc, argv, exc);
+ s_sp_scratchpad_cb = sp_callback_create(ctx, argc, argv, exc);
}
void
sp_context_change(JSContextRef src_ctx, JSContextRef dest_ctx, JSObjectRef func, JSValueRef val)
@@ -768,7 +763,7 @@ static JSValueRef
sp_send(JSContextRef ctx, JSObjectRef function, JSObjectRef this, size_t argc, const JSValueRef argv[], JSValueRef* exc)
{
if (argc > 0)
- sp_context_change(m_global_context, webkit_web_frame_get_global_context(webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(scratchpad_get()))), m_sp_scratchpad_cb, argv[0]);
+ sp_context_change(s_global_context, webkit_web_frame_get_global_context(webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(scratchpad_get()))), s_sp_scratchpad_cb, argv[0]);
return UNDEFINED;
}
@@ -776,7 +771,7 @@ sp_send(JSContextRef ctx, JSObjectRef function, JSObjectRef this, size_t argc, c
void
scripts_scratchpad_send(JSContextRef ctx, JSValueRef val)
{
- sp_context_change(ctx, m_global_context, m_sp_scripts_cb, val);
+ sp_context_change(ctx, s_global_context, s_sp_scripts_cb, val);
}
/* SOUP_MESSAGE {{{*/
@@ -917,8 +912,8 @@ scripts_eval_key(KeyMap *m, Arg *arg)
else
json = util_create_json(2, INTEGER, "nummod", dwb.state.nummod, CHAR, "arg", arg->p);
- JSValueRef argv[] = { js_json_to_value(m_global_context, json) };
- JSObjectCallAsFunction(m_global_context, arg->arg, NULL, 1, argv, NULL);
+ JSValueRef argv[] = { js_json_to_value(s_global_context, json) };
+ JSObjectCallAsFunction(s_global_context, arg->arg, NULL, 1, argv, NULL);
g_free(json);
return STATUS_OK;
@@ -1042,7 +1037,7 @@ global_execute(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, s
static JSValueRef
global_exit(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exc)
{
- if (m_commandline)
+ if (s_commandline)
application_stop();
else
dwb_end();
@@ -1110,17 +1105,17 @@ get_message_data(SoupMessage *msg)
JSObjectRef o, ho;
JSStringRef s;
- o = JSObjectMake(m_global_context, NULL, NULL);
- js_set_object_property(m_global_context, o, "body", msg->response_body->data, NULL);
+ o = JSObjectMake(s_global_context, NULL, NULL);
+ js_set_object_property(s_global_context, o, "body", msg->response_body->data, NULL);
- ho = JSObjectMake(m_global_context, NULL, NULL);
+ ho = JSObjectMake(s_global_context, NULL, NULL);
soup_message_headers_iter_init(&iter, msg->response_headers);
while (soup_message_headers_iter_next(&iter, &name, &value))
- js_set_object_property(m_global_context, ho, name, value, NULL);
+ js_set_object_property(s_global_context, ho, name, value, NULL);
s = JSStringCreateWithUTF8CString("headers");
- JSObjectSetProperty(m_global_context, o, s, ho, kJSDefaultProperty, NULL);
+ JSObjectSetProperty(s_global_context, o, s, ho, kJSDefaultProperty, NULL);
JSStringRelease(s);
return o;
}
@@ -1130,10 +1125,10 @@ request_callback(SoupSession *session, SoupMessage *message, JSObjectRef functio
if (message->response_body->data != NULL)
{
JSObjectRef o = get_message_data(message);
- JSValueRef vals[] = { o, make_object(m_global_context, G_OBJECT(message)) };
- JSObjectCallAsFunction(m_global_context, function, NULL, 2, vals, NULL);
+ JSValueRef vals[] = { o, make_object(s_global_context, G_OBJECT(message)) };
+ JSObjectCallAsFunction(s_global_context, function, NULL, 2, vals, NULL);
}
- JSValueUnprotect(m_global_context, function);
+ JSValueUnprotect(s_global_context, function);
}
static JSValueRef
global_send_request(JSContextRef ctx, JSObjectRef f, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exc)
@@ -1211,23 +1206,23 @@ void
scripts_completion_activate(void)
{
const char *text = GET_TEXT();
- JSValueRef val[] = { js_char_to_value(m_global_context, text) };
- JSObjectCallAsFunction(m_global_context, m_completion_callback, NULL, 1, val, NULL);
+ JSValueRef val[] = { js_char_to_value(s_global_context, text) };
+ JSObjectCallAsFunction(s_global_context, s_completion_callback, NULL, 1, val, NULL);
completion_clean_completion(false);
dwb_change_mode(NORMAL_MODE, true);
}
static JSValueRef
global_tab_complete(JSContextRef ctx, JSObjectRef f, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exc)
{
- if (argc < 3 || !JSValueIsInstanceOfConstructor(ctx, argv[1], m_array_contructor, exc))
+ if (argc < 3 || !JSValueIsInstanceOfConstructor(ctx, argv[1], s_array_contructor, exc))
{
js_make_exception(ctx, exc, EXCEPTION("tabComplete: invalid argument."));
return UNDEFINED;
}
- m_completion_callback = JSValueToObject(ctx, argv[2], exc);
- if (m_completion_callback == NULL)
+ s_completion_callback = JSValueToObject(ctx, argv[2], exc);
+ if (s_completion_callback == NULL)
return UNDEFINED;
- if (!JSObjectIsFunction(ctx, m_completion_callback))
+ if (!JSObjectIsFunction(ctx, s_completion_callback))
{
js_make_exception(ctx, exc, EXCEPTION("tabComplete: arguments[2] is not a function."));
return UNDEFINED;
@@ -1283,14 +1278,14 @@ static gboolean
timeout_callback(JSObjectRef obj)
{
gboolean ret;
- JSValueRef val = JSObjectCallAsFunction(m_global_context, obj, NULL, 0, NULL, NULL);
+ JSValueRef val = JSObjectCallAsFunction(s_global_context, obj, NULL, 0, NULL, NULL);
if (val == NULL)
ret = false;
else
- ret = !JSValueIsBoolean(m_global_context, val) || JSValueToBoolean(m_global_context, val);
+ ret = !JSValueIsBoolean(s_global_context, val) || JSValueToBoolean(s_global_context, val);
if (! ret )
- JSValueUnprotect(m_global_context, obj);
+ JSValueUnprotect(s_global_context, obj);
return ret;
}/*}}}*/
@@ -1473,11 +1468,11 @@ spawn_output(GIOChannel *channel, GIOCondition condition, JSObjectRef callback)
}
else if (g_io_channel_read_to_end(channel, &content, &length, NULL) == G_IO_STATUS_NORMAL && content != NULL)
{
- JSValueRef arg = js_char_to_value(m_global_context, content);
+ JSValueRef arg = js_char_to_value(s_global_context, content);
if (arg != NULL)
{
JSValueRef argv[] = { arg };
- JSObjectCallAsFunction(m_global_context, callback, NULL, 1, argv , NULL);
+ JSObjectCallAsFunction(s_global_context, callback, NULL, 1, argv , NULL);
}
g_free(content);
return true;
@@ -1910,7 +1905,7 @@ download_constructor_cb(JSContextRef ctx, JSObjectRef constructor, size_t argc,
}
WebKitDownload *download = webkit_download_new(request);
- return JSObjectMake(ctx, m_download_class, download);
+ return JSObjectMake(ctx, s_download_class, download);
}/*}}}*/
/* stop_download_notify {{{*/
@@ -1956,95 +1951,97 @@ download_cancel(JSContextRef ctx, JSObjectRef function, JSObjectRef this, size_t
}/*}}}*/
/*}}}*/
-/* SIGNALS {{{*/
-/* signal_set {{{*/
-static bool
-signal_set(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef value, JSValueRef* exception)
-{
- char *name = js_string_to_char(ctx, js_name, -1);
- JSObjectRef o;
-
- if (name == NULL)
- return false;
-
- for (int i = SCRIPTS_SIG_FIRST; i<SCRIPTS_SIG_LAST; i++)
- {
- if (strcmp(name, m_sigmap[i].name))
- continue;
-
- if (JSValueIsNull(ctx, value))
- dwb.misc.script_signals &= ~(1<<i);
- else if ( (o = JSValueToObject(ctx, value, exception)) != NULL && JSObjectIsFunction(ctx, o))
- {
- m_sig_objects[i] = o;
- dwb.misc.script_signals |= (1<<i);
- }
- break;
- }
- return false;
-}/*}}}*/
-
+/* gui {{{*/
static JSValueRef
gui_get_window(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef* exception)
{
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(dwb.gui.window), false);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(dwb.gui.window), false);
}
static JSValueRef
gui_get_main_box(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef* exception)
{
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(dwb.gui.vbox), false);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(dwb.gui.vbox), false);
}
static JSValueRef
gui_get_tab_box(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef* exception)
{
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(dwb.gui.topbox), false);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(dwb.gui.topbox), false);
}
static JSValueRef
gui_get_content_box(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef* exception)
{
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(dwb.gui.mainbox), false);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(dwb.gui.mainbox), false);
}
static JSValueRef
gui_get_status_widget(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef* exception)
{
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(dwb.gui.statusbox), false);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(dwb.gui.statusbox), false);
}
static JSValueRef
gui_get_status_alignment(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef* exception)
{
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(dwb.gui.alignment), false);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(dwb.gui.alignment), false);
}
static JSValueRef
gui_get_status_box(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef* exception)
{
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(dwb.gui.status_hbox), false);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(dwb.gui.status_hbox), false);
}
static JSValueRef
gui_get_message_label(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef* exception)
{
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(dwb.gui.lstatus), false);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(dwb.gui.lstatus), false);
}
static JSValueRef
gui_get_entry(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef* exception)
{
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(dwb.gui.entry), false);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(dwb.gui.entry), false);
}
static JSValueRef
gui_get_uri_label(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef* exception)
{
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(dwb.gui.urilabel), false);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(dwb.gui.urilabel), false);
}
static JSValueRef
gui_get_status_label(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef* exception)
{
- return make_object_for_class(ctx, m_gobject_class, G_OBJECT(dwb.gui.rstatus), false);
+ return make_object_for_class(ctx, s_gobject_class, G_OBJECT(dwb.gui.rstatus), false);
}
+/*}}}*/
+
+/* SIGNALS {{{*/
+/* signal_set {{{*/
+static bool
+signal_set(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef value, JSValueRef* exception)
+{
+ char *name = js_string_to_char(ctx, js_name, -1);
+ JSObjectRef o;
+
+ if (name == NULL)
+ return false;
+
+ for (int i = SCRIPTS_SIG_FIRST; i<SCRIPTS_SIG_LAST; i++)
+ {
+ if (strcmp(name, s_sigmap[i].name))
+ continue;
+
+ if (JSValueIsNull(ctx, value))
+ dwb.misc.script_signals &= ~(1<<i);
+ else if ( (o = JSValueToObject(ctx, value, exception)) != NULL && JSObjectIsFunction(ctx, o))
+ {
+ s_sig_objects[i] = o;
+ dwb.misc.script_signals |= (1<<i);
+ }
+ break;
+ }
+ return false;
+}/*}}}*/
/* scripts_emit {{{*/
gboolean
scripts_emit(ScriptSignal *sig)
{
- JSObjectRef function = m_sig_objects[sig->signal];
+ JSObjectRef function = s_sig_objects[sig->signal];
if (function == NULL)
return false;
@@ -2059,18 +2056,18 @@ scripts_emit(ScriptSignal *sig)
for (int j=0; j<sig->numobj; j++)
{
if (sig->objects[j] != NULL)
- val[i++] = make_object(m_global_context, G_OBJECT(sig->objects[j]));
+ val[i++] = make_object(s_global_context, G_OBJECT(sig->objects[j]));
else
val[i++] = NIL;
}
- JSValueRef vson = js_json_to_value(m_global_context, sig->json);
+ JSValueRef vson = js_json_to_value(s_global_context, sig->json);
val[i++] = vson == NULL ? NIL : vson;
- JSValueRef js_ret = JSObjectCallAsFunction(m_global_context, function, NULL, numargs, val, NULL);
+ JSValueRef js_ret = JSObjectCallAsFunction(s_global_context, function, NULL, numargs, val, NULL);
- if (JSValueIsBoolean(m_global_context, js_ret))
- return JSValueToBoolean(m_global_context, js_ret);
+ if (JSValueIsBoolean(s_global_context, js_ret))
+ return JSValueToBoolean(s_global_context, js_ret);
return false;
}/*}}}*/
@@ -2082,7 +2079,7 @@ static void
object_destroy_cb(JSObjectRef o)
{
JSObjectSetPrivate(o, NULL);
- JSValueUnprotect(m_global_context, o);
+ JSValueUnprotect(s_global_context, o);
}
static JSObjectRef
@@ -2096,7 +2093,7 @@ make_object_for_class(JSContextRef ctx, JSClassRef class, GObject *o, gboolean p
if (protect)
{
g_object_set_qdata_full(o, ref_quark, retobj, (GDestroyNotify)object_destroy_cb);
- JSValueProtect(m_global_context, retobj);
+ JSValueProtect(s_global_context, retobj);
}
else
g_object_set_qdata_full(o, ref_quark, retobj, NULL);
@@ -2115,15 +2112,15 @@ make_object(JSContextRef ctx, GObject *o)
}
JSClassRef class;
if (WEBKIT_IS_WEB_VIEW(o))
- class = m_webview_class;
+ class = s_webview_class;
else if (WEBKIT_IS_WEB_FRAME(o))
- class = m_frame_class;
+ class = s_frame_class;
else if (WEBKIT_IS_DOWNLOAD(o))
- class = m_download_class;
+ class = s_download_class;
else if (SOUP_IS_MESSAGE(o))
- class = m_message_class;
+ class = s_message_class;
else
- class = m_gobject_class;
+ class = s_gobject_class;
return make_object_for_class(ctx, class, o, true);
}/*}}}*/
@@ -2136,7 +2133,7 @@ connect_callback(SSignal *sig, ...)
va_start(args, sig);
#define CHECK_NUMBER(GTYPE, TYPE) G_STMT_START if (gtype == G_TYPE_##GTYPE) { \
TYPE MM_value = va_arg(args, TYPE); \
- cur = JSValueMakeNumber(m_global_context, MM_value); goto apply;} G_STMT_END
+ cur = JSValueMakeNumber(s_global_context, MM_value); goto apply;} G_STMT_END
for (guint i=0; i<sig->query->n_params; i++)
{
GType gtype = sig->query->param_types[i], act;
@@ -2155,18 +2152,18 @@ connect_callback(SSignal *sig, ...)
if (sig->query->param_types[i] == G_TYPE_BOOLEAN)
{
gboolean value = va_arg(args, gboolean);
- cur = JSValueMakeBoolean(m_global_context, value);
+ cur = JSValueMakeBoolean(s_global_context, value);
}
else if (sig->query->param_types[i] == G_TYPE_STRING)
{
char *value = va_arg(args, char *);
- cur = js_char_to_value(m_global_context, value);
+ cur = js_char_to_value(s_global_context, value);
}
else if (G_TYPE_IS_CLASSED(gtype))
{
GObject *value = va_arg(args, gpointer);
if (value != NULL) // avoid conversion to JSObjectRef
- cur = make_object(m_global_context, value);
+ cur = make_object(s_global_context, value);
else
cur = NIL;
}
@@ -2179,11 +2176,11 @@ apply:
argv[i+1] = cur;
}
#undef CHECK_NUMBER
- argv[0] = make_object(m_global_context, va_arg(args, gpointer));
- JSValueRef ret = JSObjectCallAsFunction(m_global_context, sig->func, NULL, sig->query->n_params+1, argv, NULL);
- if (JSValueIsBoolean(m_global_context, ret))
+ argv[0] = make_object(s_global_context, va_arg(args, gpointer));
+ JSValueRef ret = JSObjectCallAsFunction(s_global_context, sig->func, NULL, sig->query->n_params+1, argv, NULL);
+ if (JSValueIsBoolean(s_global_context, ret))
{
- return JSValueToBoolean(m_global_context, ret);
+ return JSValueToBoolean(s_global_context, ret);
}
return false;
}
@@ -2195,8 +2192,8 @@ on_disconnect_object(SSignal *sig, GClosure *closure)
static void
notify_callback(GObject *o, GParamSpec *param, JSObjectRef func)
{
- JSValueRef argv[] = { make_object(m_global_context, o) };
- JSObjectCallAsFunction(m_global_context, func, NULL, 1, argv, NULL);
+ JSValueRef argv[] = { make_object(s_global_context, o) };
+ JSObjectCallAsFunction(s_global_context, func, NULL, 1, argv, NULL);
}
static JSValueRef
connect_object(JSContextRef ctx, JSObjectRef function, JSObjectRef this, size_t argc, const JSValueRef argv[], JSValueRef* exc)
@@ -2487,11 +2484,11 @@ create_global_object()
};
JSClassRef class = create_class("dwb", global_functions, NULL);
- m_global_context = JSGlobalContextCreate(class);
+ s_global_context = JSGlobalContextCreate(class);
JSClassRelease(class);
- JSObjectRef global_object = JSContextGetGlobalObject(m_global_context);
+ JSObjectRef global_object = JSContextGetGlobalObject(s_global_context);
JSStaticValue data_values[] = {
{ "profile", data_get_profile, NULL, kJSDefaultAttributes },
@@ -2502,7 +2499,7 @@ create_global_object()
{ 0, 0, 0, 0 },
};
class = create_class("data", NULL, data_values);
- create_object(m_global_context, class, global_object, kJSDefaultAttributes, "data", NULL);
+ create_object(s_global_context, class, global_object, kJSDefaultAttributes, "data", NULL);
JSClassRelease(class);
JSStaticFunction io_functions[] = {
@@ -2517,7 +2514,7 @@ create_global_object()
{ 0, 0, 0 },
};
class = create_class("io", io_functions, NULL);
- create_object(m_global_context, class, global_object, kJSPropertyAttributeDontDelete, "io", NULL);
+ create_object(s_global_context, class, global_object, kJSPropertyAttributeDontDelete, "io", NULL);
JSClassRelease(class);
JSStaticFunction system_functions[] = {
@@ -2529,7 +2526,7 @@ create_global_object()
{ 0, 0, 0 },
};
class = create_class("system", system_functions, NULL);
- create_object(m_global_context, class, global_object, kJSDefaultAttributes, "system", NULL);
+ create_object(s_global_context, class, global_object, kJSDefaultAttributes, "system", NULL);
JSClassRelease(class);
JSStaticFunction tab_functions[] = {
@@ -2543,7 +2540,7 @@ create_global_object()
{ 0, 0, 0, 0 },
};
class = create_class("tabs", tab_functions, tab_values);
- create_object(m_global_context, class, global_object, kJSDefaultAttributes, "tabs", NULL);
+ create_object(s_global_context, class, global_object, kJSDefaultAttributes, "tabs", NULL);
JSClassRelease(class);
JSClassDefinition cd = kJSClassDefinitionEmpty;
@@ -2551,11 +2548,11 @@ create_global_object()
cd.setProperty = signal_set;
class = JSClassCreate(&cd);
- create_object(m_global_context, class, global_object, kJSDefaultAttributes, "signals", NULL);
+ create_object(s_global_context, class, global_object, kJSDefaultAttributes, "signals", NULL);
JSClassRelease(class);
class = create_class("extensions", NULL, NULL);
- create_object(m_global_context, class, global_object, kJSDefaultAttributes, "extensions", NULL);
+ create_object(s_global_context, class, global_object, kJSDefaultAttributes, "extensions", NULL);
JSClassRelease(class);
JSStaticFunction util_functions[] = {
@@ -2565,7 +2562,7 @@ create_global_object()
{ 0, 0, 0 },
};
class = create_class("util", util_functions, NULL);
- create_object(m_global_context, class, global_object, kJSDefaultAttributes, "util", NULL);
+ create_object(s_global_context, class, global_object, kJSDefaultAttributes, "util", NULL);
JSClassRelease(class);
/* Default gobject class */
@@ -2574,36 +2571,36 @@ create_global_object()
cd.staticFunctions = default_functions;
cd.getProperty = get_property;
cd.setProperty = set_property;
- m_gobject_class = JSClassCreate(&cd);
+ s_gobject_class = JSClassCreate(&cd);
- m_constructors[CONSTRUCTOR_DEFAULT] = create_constructor(m_global_context, "GObject", m_gobject_class, NULL, NULL);
+ s_constructors[CONSTRUCTOR_DEFAULT] = create_constructor(s_global_context, "GObject", s_gobject_class, NULL, NULL);
/* Webview */
cd.className = "WebKitWebView";
cd.staticFunctions = wv_functions;
cd.staticValues = wv_values;
- cd.parentClass = m_gobject_class;
- m_webview_class = JSClassCreate(&cd);
+ cd.parentClass = s_gobject_class;
+ s_webview_class = JSClassCreate(&cd);
- m_constructors[CONSTRUCTOR_WEBVIEW] = create_constructor(m_global_context, "WebKitWebView", m_webview_class, NULL, NULL);
+ s_constructors[CONSTRUCTOR_WEBVIEW] = create_constructor(s_global_context, "WebKitWebView", s_webview_class, NULL, NULL);
/* Frame */
cd.className = "WebKitWebFrame";
cd.staticFunctions = frame_functions;
cd.staticValues = frame_values;
- cd.parentClass = m_gobject_class;
- m_frame_class = JSClassCreate(&cd);
+ cd.parentClass = s_gobject_class;
+ s_frame_class = JSClassCreate(&cd);
- m_constructors[CONSTRUCTOR_FRAME] = create_constructor(m_global_context, "WebKitWebFrame", m_frame_class, NULL, NULL);
+ s_constructors[CONSTRUCTOR_FRAME] = create_constructor(s_global_context, "WebKitWebFrame", s_frame_class, NULL, NULL);
/* SoupMessage */
cd.className = "SoupMessage";
cd.staticFunctions = default_functions;
cd.staticValues = message_values;
- cd.parentClass = m_gobject_class;
- m_message_class = JSClassCreate(&cd);
+ cd.parentClass = s_gobject_class;
+ s_message_class = JSClassCreate(&cd);
- m_constructors[CONSTRUCTOR_SOUP_MESSAGE] = create_constructor(m_global_context, "SoupMessage", m_frame_class, NULL, NULL);
+ s_constructors[CONSTRUCTOR_SOUP_MESSAGE] = create_constructor(s_global_context, "SoupMessage", s_frame_class, NULL, NULL);
static JSStaticValue gui_values[] = {
{ "window", gui_get_window, NULL, kJSDefaultAttributes },
@@ -2623,17 +2620,17 @@ create_global_object()
cd = kJSClassDefinitionEmpty;
cd.staticValues = gui_values;
class = JSClassCreate(&cd);
- create_object(m_global_context, class, global_object, kJSDefaultAttributes, "gui", NULL);
+ create_object(s_global_context, class, global_object, kJSDefaultAttributes, "gui", NULL);
JSClassRelease(class);
/* download */
cd.className = "Download";
cd.staticFunctions = download_functions;
cd.staticValues = NULL;
- cd.parentClass = m_gobject_class;
- m_download_class = JSClassCreate(&cd);
+ cd.parentClass = s_gobject_class;
+ s_download_class = JSClassCreate(&cd);
- m_constructors[CONSTRUCTOR_DOWNLOAD] = create_constructor(m_global_context, "Download", m_download_class, download_constructor_cb, NULL);
+ s_constructors[CONSTRUCTOR_DOWNLOAD] = create_constructor(s_global_context, "Download", s_download_class, download_constructor_cb, NULL);
JSStaticFunction scratchpad_functions[] = {
{ "show", sp_show, kJSDefaultAttributes },
@@ -2646,12 +2643,12 @@ create_global_object()
cd.className = "Scratchpad";
cd.staticFunctions = scratchpad_functions;
cd.staticValues = NULL;
- cd.parentClass = m_gobject_class;
+ cd.parentClass = s_gobject_class;
class = JSClassCreate(&cd);
- JSObjectRef o = make_object_for_class(m_global_context, class, G_OBJECT(scratchpad_get()), true);
- js_set_property(m_global_context, global_object, "scratchpad", o, kJSDefaultAttributes, NULL);
+ JSObjectRef o = make_object_for_class(s_global_context, class, G_OBJECT(scratchpad_get()), true);
+ js_set_property(s_global_context, global_object, "scratchpad", o, kJSDefaultAttributes, NULL);
}/*}}}*/
/*}}}*/
@@ -2660,41 +2657,41 @@ create_global_object()
static void
apply_scripts()
{
- int length = g_slist_length(m_script_list);
+ int length = g_slist_length(s_script_list);
int i=0;
// XXX Not needed?
JSValueRef *scripts = g_try_malloc(length * sizeof(JSValueRef));
JSObjectRef *objects = g_try_malloc(length * sizeof(JSObjectRef));
- for (GSList *l=m_script_list; l; l=l->next, i++)
+ for (GSList *l=s_script_list; l; l=l->next, i++)
{
- scripts[i] = JSObjectMake(m_global_context, NULL, NULL);
- objects[i] = JSObjectMake(m_global_context, NULL, NULL);
- js_set_property(m_global_context, objects[i], "self", scripts[i], 0, NULL);
- js_set_property(m_global_context, objects[i], "func", l->data, 0, NULL);
+ scripts[i] = JSObjectMake(s_global_context, NULL, NULL);
+ objects[i] = JSObjectMake(s_global_context, NULL, NULL);
+ js_set_property(s_global_context, objects[i], "self", scripts[i], 0, NULL);
+ js_set_property(s_global_context, objects[i], "func", l->data, 0, NULL);
}
- if (m_init_before != NULL)
+ if (s_init_before != NULL)
{
- JSValueRef argv[] = { JSObjectMakeArray(m_global_context, length, (JSValueRef*)objects, NULL) };
- JSObjectCallAsFunction(m_global_context, m_init_before, NULL, 1, argv, NULL);
- JSValueUnprotect(m_global_context, m_init_before);
+ JSValueRef argv[] = { JSObjectMakeArray(s_global_context, length, (JSValueRef*)objects, NULL) };
+ JSObjectCallAsFunction(s_global_context, s_init_before, NULL, 1, argv, NULL);
+ JSValueUnprotect(s_global_context, s_init_before);
}
i=0;
- for (GSList *l = m_script_list; l; l=l->next, i++)
+ for (GSList *l = s_script_list; l; l=l->next, i++)
{
- JSObjectRef apply = js_get_object_property(m_global_context, l->data, "apply");
+ JSObjectRef apply = js_get_object_property(s_global_context, l->data, "apply");
JSValueRef argv[] = { scripts[i] };
- JSObjectCallAsFunction(m_global_context, apply, l->data, 1, argv, NULL);
+ JSObjectCallAsFunction(s_global_context, apply, l->data, 1, argv, NULL);
}
- g_slist_free(m_script_list);
- m_script_list = NULL;
+ g_slist_free(s_script_list);
+ s_script_list = NULL;
- if (m_init_after != NULL)
+ if (s_init_after != NULL)
{
- JSObjectCallAsFunction(m_global_context, m_init_after, NULL, 0, NULL, NULL);
- JSValueUnprotect(m_global_context, m_init_after);
+ JSObjectCallAsFunction(s_global_context, s_init_after, NULL, 0, NULL, NULL);
+ JSValueUnprotect(s_global_context, s_init_after);
}
g_free(scripts);
g_free(objects);
@@ -2705,7 +2702,7 @@ void
scripts_create_tab(GList *gl)
{
static gboolean applied = false;
- if (m_global_context == NULL )
+ if (s_global_context == NULL )
{
VIEW(gl)->script_wv = NULL;
return;
@@ -2715,9 +2712,9 @@ scripts_create_tab(GList *gl)
apply_scripts();
applied = true;
}
- JSObjectRef o = make_object(m_global_context, G_OBJECT(VIEW(gl)->web));
+ JSObjectRef o = make_object(s_global_context, G_OBJECT(VIEW(gl)->web));
- JSValueProtect(m_global_context, o);
+ JSValueProtect(s_global_context, o);
VIEW(gl)->script_wv = o;
}/*}}}*/
@@ -2732,7 +2729,7 @@ scripts_remove_tab(JSObjectRef obj)
ScriptSignal signal = { obj, SCRIPTS_SIG_META(NULL, CLOSE_TAB, 0) };
scripts_emit(&signal);
}
- JSValueUnprotect(m_global_context, obj);
+ JSValueUnprotect(s_global_context, obj);
}
}/*}}}*/
@@ -2741,14 +2738,14 @@ void
scripts_init_script(const char *path, const char *script)
{
char *debug = NULL;
- if (m_global_context == NULL)
+ if (s_global_context == NULL)
create_global_object();
debug = g_strdup_printf("\ntry{/*<dwb*/%s/*dwb>*/}catch(e){io.debug({message:\"In file %s\",error:e});};", script, path);
- JSObjectRef function = js_make_function(m_global_context, debug);
+ JSObjectRef function = js_make_function(s_global_context, debug);
if (function != NULL)
- m_script_list = g_slist_prepend(m_script_list, function);
+ s_script_list = g_slist_prepend(s_script_list, function);
g_free(debug);
}/*}}}*/
@@ -2757,7 +2754,7 @@ void
evaluate(const char *script)
{
JSStringRef js_script = JSStringCreateWithUTF8CString(script);
- JSEvaluateScript(m_global_context, js_script, NULL, NULL, 0, NULL);
+ JSEvaluateScript(s_global_context, js_script, NULL, NULL, 0, NULL);
JSStringRelease(js_script);
}
@@ -2765,11 +2762,11 @@ JSObjectRef
get_private(JSContextRef ctx, char *name)
{
JSStringRef js_name = JSStringCreateWithUTF8CString(name);
- JSObjectRef global_object = JSContextGetGlobalObject(m_global_context);
+ JSObjectRef global_object = JSContextGetGlobalObject(s_global_context);
- JSObjectRef ret = js_get_object_property(m_global_context, global_object, name);
- JSValueProtect(m_global_context, ret);
- JSObjectDeleteProperty(m_global_context, global_object, js_name, NULL);
+ JSObjectRef ret = js_get_object_property(s_global_context, global_object, name);
+ JSValueProtect(s_global_context, ret);
+ JSObjectDeleteProperty(s_global_context, global_object, js_name, NULL);
JSStringRelease(js_name);
return ret;
@@ -2780,7 +2777,7 @@ void
scripts_init(gboolean force)
{
dwb.misc.script_signals = 0;
- if (m_global_context == NULL)
+ if (s_global_context == NULL)
{
if (force)
create_global_object();
@@ -2797,30 +2794,30 @@ scripts_init(gboolean force)
if (content != NULL)
{
JSStringRef js_script = JSStringCreateWithUTF8CString(content->str);
- JSEvaluateScript(m_global_context, js_script, NULL, NULL, 0, NULL);
+ JSEvaluateScript(s_global_context, js_script, NULL, NULL, 0, NULL);
JSStringRelease(js_script);
}
g_string_free(content, true);
g_free(dir);
}
- UNDEFINED = JSValueMakeUndefined(m_global_context);
- JSValueProtect(m_global_context, UNDEFINED);
- NIL = JSValueMakeNull(m_global_context);
- JSValueProtect(m_global_context, NIL);
+ UNDEFINED = JSValueMakeUndefined(s_global_context);
+ JSValueProtect(s_global_context, UNDEFINED);
+ NIL = JSValueMakeNull(s_global_context);
+ JSValueProtect(s_global_context, NIL);
- m_init_before = get_private(m_global_context, "_initBefore");
- m_init_after = get_private(m_global_context, "_initAfter");
+ s_init_before = get_private(s_global_context, "_initBefore");
+ s_init_after = get_private(s_global_context, "_initAfter");
- JSObjectRef o = JSObjectMakeArray(m_global_context, 0, NULL, NULL);
- m_array_contructor = js_get_object_property(m_global_context, o, "constructor");
- JSValueProtect(m_global_context, m_array_contructor);
+ JSObjectRef o = JSObjectMakeArray(s_global_context, 0, NULL, NULL);
+ s_array_contructor = js_get_object_property(s_global_context, o, "constructor");
+ JSValueProtect(s_global_context, s_array_contructor);
}/*}}}*/
gboolean
scripts_execute_one(const char *script)
{
- if (m_global_context != NULL)
- return js_execute(m_global_context, script, NULL) != NULL;
+ if (s_global_context != NULL)
+ return js_execute(s_global_context, script, NULL) != NULL;
return false;
}
@@ -2828,26 +2825,26 @@ void
scripts_unbind(JSObjectRef obj)
{
if (obj != NULL)
- JSValueUnprotect(m_global_context, obj);
+ JSValueUnprotect(s_global_context, obj);
}
/* scripts_end {{{*/
void
scripts_end()
{
- if (m_global_context != NULL)
+ if (s_global_context != NULL)
{
for (int i=0; i<CONSTRUCTOR_LAST; i++)
- JSValueUnprotect(m_global_context, m_constructors[i]);
- JSValueUnprotect(m_global_context, m_array_contructor);
- JSValueUnprotect(m_global_context, UNDEFINED);
- JSValueUnprotect(m_global_context, NIL);
- JSClassRelease(m_gobject_class);
- JSClassRelease(m_webview_class);
- JSClassRelease(m_frame_class);
- JSClassRelease(m_download_class);
- JSClassRelease(m_message_class);
- JSGlobalContextRelease(m_global_context);
- m_global_context = NULL;
+ JSValueUnprotect(s_global_context, s_constructors[i]);
+ JSValueUnprotect(s_global_context, s_array_contructor);
+ JSValueUnprotect(s_global_context, UNDEFINED);
+ JSValueUnprotect(s_global_context, NIL);
+ JSClassRelease(s_gobject_class);
+ JSClassRelease(s_webview_class);
+ JSClassRelease(s_frame_class);
+ JSClassRelease(s_download_class);
+ JSClassRelease(s_message_class);
+ JSGlobalContextRelease(s_global_context);
+ s_global_context = NULL;
}
}/*}}}*//*}}}*/
diff --git a/src/session.c b/src/session.c
index bf86d003..a6105f75 100644
--- a/src/session.c
+++ b/src/session.c
@@ -23,8 +23,8 @@
#include "view.h"
#include "session.h"
-static char *m_session_name;
-static gboolean m_has_marked = true;
+static char *s_session_name;
+static gboolean s_has_marked = true;
typedef struct _SessionTab {
GList *gl;
@@ -125,7 +125,7 @@ session_load_status_callback(WebKitWebView *wv, GParamSpec *p, SessionTab *tab)
}
void
session_clear_session() {
- session_save_file(m_session_name ? m_session_name : "default", "", true);
+ session_save_file(s_session_name ? s_session_name : "default", "", true);
}
/* session_load_webview(WebKitWebView *, char *, int *){{{*/
@@ -180,24 +180,24 @@ session_restore(char *name, int flags) {
gboolean ret = false;
int locked_state = 0;
if (name == NULL) {
- m_session_name = g_strdup("default");
+ s_session_name = g_strdup("default");
}
else
- m_session_name = name;
+ s_session_name = name;
- char *group = session_get_group(m_session_name, &is_marked);
+ char *group = session_get_group(s_session_name, &is_marked);
if (is_marked && (flags & SESSION_FORCE) == 0) {
- fprintf(stderr, "Warning: Session '%s' will not be restored.\n", m_session_name);
- fprintf(stderr, "There is already a restored session open with name '%s'.\n", m_session_name);
+ fprintf(stderr, "Warning: Session '%s' will not be restored.\n", s_session_name);
+ fprintf(stderr, "There is already a restored session open with name '%s'.\n", s_session_name);
fputs("To force opening a saved session use -f or --force.\n", stderr);
- m_has_marked = false;
+ s_has_marked = false;
goto clean;
}
if (group == NULL) {
return false;
}
char *group_begin = strchr(group, '\n');
- session_save_file(m_session_name, group_begin+1, true);
+ session_save_file(s_session_name, group_begin+1, true);
if (flags & SESSION_ONLY_MARK)
goto clean;
char **lines = g_strsplit(group, "\n", -1);
@@ -251,12 +251,12 @@ clean:
gboolean
session_save(const char *name, int flags) {
if (!name) {
- if (m_session_name)
- name = m_session_name;
+ if (s_session_name)
+ name = s_session_name;
else if (flags & SESSION_FORCE)
name = "default";
}
- if (!m_has_marked && (flags & SESSION_FORCE) == 0)
+ if (!s_has_marked && (flags & SESSION_FORCE) == 0)
return false;
GString *buffer = g_string_new(NULL);
@@ -276,7 +276,7 @@ session_save(const char *name, int flags) {
}
session_save_file(name, buffer->str, (flags & SESSION_SYNC) != 0);
if (! (flags & SESSION_SYNC))
- g_free(m_session_name);
+ g_free(s_session_name);
g_string_free(buffer, true);
return true;
}/*}}}*/
diff --git a/src/soup.c b/src/soup.c
index 4ed8c3d2..98fda978 100644
--- a/src/soup.c
+++ b/src/soup.c
@@ -22,10 +22,10 @@
#include "util.h"
#include "domain.h"
#include "soup.h"
-static SoupCookieJar *m_jar;
-static guint m_changed_id;
-static SoupCookieJar *m_tmp_jar;
-static SoupCookieJar *m_pers_jar;
+static SoupCookieJar *s_jar;
+static guint s_changed_id;
+static SoupCookieJar *s_tmp_jar;
+static SoupCookieJar *s_pers_jar;
/*{{{*/
static void
@@ -130,7 +130,7 @@ dwb_soup_allow_cookie(GList **whitelist, const char *filename, CookieStorePolicy
SoupCookie *c;
GSList *asked = NULL, *allowed = NULL;
- GSList *last_cookies = soup_cookie_jar_all_cookies(m_tmp_jar);
+ GSList *last_cookies = soup_cookie_jar_all_cookies(s_tmp_jar);
if (last_cookies == NULL)
return dwb_soup_allow_cookie_simple(whitelist, filename, policy);
@@ -168,7 +168,7 @@ dwb_soup_allow_cookie(GList **whitelist, const char *filename, CookieStorePolicy
/* Save all cookies to the jar */
for (GSList *l = allowed; l; l=l->next)
- soup_cookie_jar_add_cookie(m_jar, l->data);
+ soup_cookie_jar_add_cookie(s_jar, l->data);
dwb_reload(dwb.state.fview);
@@ -183,7 +183,7 @@ dwb_soup_allow_cookie(GList **whitelist, const char *filename, CookieStorePolicy
void
dwb_soup_clean()
{
- dwb_soup_clear_jar(m_tmp_jar);
+ dwb_soup_clear_jar(s_tmp_jar);
}/*}}}*/
/* dwb_soup_get_host_from_request(WebKitNetworkRequest ) {{{*/
@@ -252,7 +252,7 @@ dwb_soup_set_cookie_accept_policy(const char *policy)
apo = 0;
ret = STATUS_ERROR;
}
- soup_cookie_jar_set_accept_policy(m_jar, apo);
+ soup_cookie_jar_set_accept_policy(s_jar, apo);
return ret;
}/*}}}*/
@@ -276,19 +276,19 @@ dwb_soup_cookie_changed_cb(SoupCookieJar *jar, SoupCookie *old, SoupCookie *new,
{
//SoupCookieJar *j = soup_cookie_jar_text_new(dwb.files[FILES_COOKIES], false);
if (old)
- soup_cookie_jar_delete_cookie(m_pers_jar, old);
+ soup_cookie_jar_delete_cookie(s_pers_jar, old);
if (new)
{
if (dwb.state.cookie_store_policy == COOKIE_STORE_PERSISTENT || dwb_soup_test_cookie_allowed(dwb.fc.cookies_allow, new))
- soup_cookie_jar_add_cookie(m_pers_jar, soup_cookie_copy(new));
+ soup_cookie_jar_add_cookie(s_pers_jar, soup_cookie_copy(new));
else
{
- soup_cookie_jar_add_cookie(m_tmp_jar, soup_cookie_copy(new));
+ soup_cookie_jar_add_cookie(s_tmp_jar, soup_cookie_copy(new));
if (dwb.state.cookie_store_policy == COOKIE_STORE_NEVER && !dwb_soup_test_cookie_allowed(dwb.fc.cookies_session_allow, new) )
{
- g_signal_handler_block(jar, m_changed_id);
+ g_signal_handler_block(jar, s_changed_id);
soup_cookie_jar_delete_cookie(jar, new);
- g_signal_handler_unblock(jar, m_changed_id);
+ g_signal_handler_unblock(jar, s_changed_id);
}
}
}
@@ -300,7 +300,7 @@ dwb_soup_sync_cookies()
int fd = open(dwb.files[FILES_COOKIES], 0);
flock(fd, LOCK_EX);
- GSList *all_cookies = soup_cookie_jar_all_cookies(m_pers_jar);
+ GSList *all_cookies = soup_cookie_jar_all_cookies(s_pers_jar);
SoupCookieJar *j = soup_cookie_jar_text_new(dwb.files[FILES_COOKIES], false);
for (GSList *l = all_cookies; l; l=l->next)
soup_cookie_jar_add_cookie(j, l->data);
@@ -315,32 +315,32 @@ dwb_soup_sync_cookies()
void
dwb_soup_clear_cookies()
{
- dwb_soup_clear_jar(m_tmp_jar);
- dwb_soup_clear_jar(m_pers_jar);
- dwb_soup_clear_jar(m_jar);
+ dwb_soup_clear_jar(s_tmp_jar);
+ dwb_soup_clear_jar(s_pers_jar);
+ dwb_soup_clear_jar(s_jar);
}
/* dwb_soup_init_cookies {{{*/
void
dwb_soup_init_cookies(SoupSession *s)
{
- m_jar = soup_cookie_jar_new();
- m_tmp_jar = soup_cookie_jar_new();
- //m_pers_jar = soup_cookie_jar_new();
- m_pers_jar = soup_cookie_jar_new();
+ s_jar = soup_cookie_jar_new();
+ s_tmp_jar = soup_cookie_jar_new();
+ //s_pers_jar = soup_cookie_jar_new();
+ s_pers_jar = soup_cookie_jar_new();
dwb_soup_set_cookie_accept_policy(GET_CHAR("cookies-accept-policy"));
SoupCookieJar *old_cookies = soup_cookie_jar_text_new(dwb.files[FILES_COOKIES], true);
GSList *l = soup_cookie_jar_all_cookies(old_cookies);
for (; l; l=l->next )
- soup_cookie_jar_add_cookie(m_jar, soup_cookie_copy(l->data));
+ soup_cookie_jar_add_cookie(s_jar, soup_cookie_copy(l->data));
soup_cookies_free(l);
g_object_unref(old_cookies);
- soup_session_add_feature(s, SOUP_SESSION_FEATURE(m_jar));
- m_changed_id = g_signal_connect(m_jar, "changed", G_CALLBACK(dwb_soup_cookie_changed_cb), NULL);
+ soup_session_add_feature(s, SOUP_SESSION_FEATURE(s_jar));
+ s_changed_id = g_signal_connect(s_jar, "changed", G_CALLBACK(dwb_soup_cookie_changed_cb), NULL);
}/*}}}*/
/* dwb_init_proxy{{{*/
@@ -395,9 +395,9 @@ dwb_soup_init_session_features()
void
dwb_soup_end()
{
- g_object_unref(m_tmp_jar);
- g_object_unref(m_jar);
- g_object_unref(m_pers_jar);
+ g_object_unref(s_tmp_jar);
+ g_object_unref(s_jar);
+ g_object_unref(s_pers_jar);
g_free(dwb.misc.proxyuri);
}/*}}}*/
diff --git a/src/view.c b/src/view.c
index 5a47d597..67560899 100644
--- a/src/view.c
+++ b/src/view.c
@@ -34,9 +34,9 @@
#include "scripts.h"
static void view_ssl_state(GList *);
-static unsigned long m_click_time;
-static guint m_sig_caret_button_release;
-static guint m_sig_caret_motion;
+static unsigned long s_click_time;
+static guint s_sig_caret_button_release;
+static guint s_sig_caret_motion;
static const char const* dummy_icon[] = { "1 1 1 1 ", "- c NONE", "", };
@@ -106,15 +106,15 @@ view_document_finished(WebKitWebView *wv, WebKitWebFrame *frame, GList *gl)
static void
view_disconnect_caret(WebKitWebView *web)
{
- if (m_sig_caret_button_release > 0)
+ if (s_sig_caret_button_release > 0)
{
- g_signal_handler_disconnect(web, m_sig_caret_button_release);
- m_sig_caret_button_release = 0;
+ g_signal_handler_disconnect(web, s_sig_caret_button_release);
+ s_sig_caret_button_release = 0;
}
- if (m_sig_caret_motion > 0)
+ if (s_sig_caret_motion > 0)
{
- g_signal_handler_disconnect(web, m_sig_caret_motion);
- m_sig_caret_motion = 0;
+ g_signal_handler_disconnect(web, s_sig_caret_motion);
+ s_sig_caret_motion = 0;
}
}
void
@@ -157,7 +157,7 @@ view_button_press_cb(WebKitWebView *web, GdkEventButton *e, GList *gl)
WebKitHitTestResultContext context;
g_object_get(result, "context", &context, NULL);
gboolean ret = false;
- m_click_time = e->time;
+ s_click_time = e->time;
if (EMIT_SCRIPT(BUTTON_PRESS))
{
char *json = util_create_json(8,
@@ -186,8 +186,8 @@ view_button_press_cb(WebKitWebView *web, GdkEventButton *e, GList *gl)
WebKitDOMDOMSelection *selection = webkit_dom_dom_window_get_selection(webkit_dom_document_get_default_view(doc));
webkit_dom_dom_selection_remove_all_ranges(selection);
webkit_dom_dom_selection_add_range(selection, range);
- m_sig_caret_button_release = g_signal_connect(web, "button-release-event", G_CALLBACK(view_caret_release_cb), range);
- m_sig_caret_motion = g_signal_connect(web, "motion-notify-event", G_CALLBACK(view_caret_motion_cb), range);
+ s_sig_caret_button_release = g_signal_connect(web, "button-release-event", G_CALLBACK(view_caret_release_cb), range);
+ s_sig_caret_motion = g_signal_connect(web, "motion-notify-event", G_CALLBACK(view_caret_motion_cb), range);
return false;
}
else if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION && e->type == GDK_BUTTON_PRESS && e->state & GDK_BUTTON1_MASK)
@@ -252,7 +252,7 @@ view_button_release_cb(WebKitWebView *web, GdkEventButton *e, GList *gl)
if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
{
- if (e->button == 2 || (e->time - m_click_time < 200 && (e->button == 1 && e->state & GDK_CONTROL_MASK)))
+ if (e->button == 2 || (e->time - s_click_time < 200 && (e->button == 1 && e->state & GDK_CONTROL_MASK)))
{
g_object_get(result, "link-uri", &uri, NULL);
view_add(uri, dwb.state.background_tabs);