/cpw/tomkiewicz/masterpassword: e46890ebd08f: Merge from main
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Thu May 9 14:24:37 EDT 2013
Changeset: e46890ebd08fc30a44d805d61a89f7a27861d141
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2013-05-09 13:15 +0200
Branch: soc.2008.masterpassword
URL: https://hg.pidgin.im/cpw/tomkiewicz/masterpassword/rev/e46890ebd08f
Description:
Merge from main
diffstat:
.hgignore | 1 +
configure.ac | 1 +
libpurple/cipher.c | 2 +-
pidgin/Makefile.am | 8 +
pidgin/gtkdebug.c | 408 ++++++++++----------------------------------------
pidgin/gtkdebug.html | 251 +++++++++++++++++++++++++++++++
pidgin/gtkmain.c | 28 +++
pidgin/gtkprefs.c | 48 ++++++
8 files changed, 421 insertions(+), 326 deletions(-)
diffs (truncated from 969 to 300 lines):
diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -89,6 +89,7 @@ pidgin-.*.tar.gz
pidgin.apspec$
pidgin.desktop$
pidgin.spec$
+pidgin/.*\.html\.h$
pidgin/pidgin$
pidgin/pixmaps/emotes/default/24/theme
pidgin/pixmaps/emotes/none/theme
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -102,6 +102,7 @@ GNT_LT_VERSION_INFO="gnt_lt_current:gnt_
AC_SUBST(GNT_LT_VERSION_INFO)
AC_PATH_PROG(sedpath, sed)
+AC_PATH_PROG(xxdpath, xxd)
dnl Storing configure arguments
AC_DEFINE_UNQUOTED(CONFIG_ARGS, "$ac_configure_args", [configure arguments])
diff --git a/libpurple/cipher.c b/libpurple/cipher.c
--- a/libpurple/cipher.c
+++ b/libpurple/cipher.c
@@ -513,7 +513,7 @@ purple_cipher_context_encrypt(PurpleCiph
g_return_val_if_fail(context != NULL, -1);
g_return_val_if_fail(input != NULL, -1);
g_return_val_if_fail(output != NULL, -1);
- g_return_val_if_fail(out_size < in_len, -1);
+ g_return_val_if_fail(out_size >= in_len, -1);
cipher = context->cipher;
g_return_val_if_fail(cipher, -1);
diff --git a/pidgin/Makefile.am b/pidgin/Makefile.am
--- a/pidgin/Makefile.am
+++ b/pidgin/Makefile.am
@@ -152,6 +152,14 @@ pidginincludedir=$(includedir)/pidgin
pidgininclude_HEADERS = \
$(pidgin_headers)
+pidgin_builtheaders = gtkdebug.html.h
+
+BUILT_SOURCES = $(pidgin_builtheaders)
+
+%.html.h: %.html
+ $(AM_V_GEN)echo "static const char $*_html[] = {" > $@
+ $(AM_V_at)$(sedpath) -e 's/^[ ]\+//g' -e 's/[ ]\+/ /g' $< | $(xxdpath) -i | sed -e 's/\(0x[0-9a-f][0-9a-f]\)$$/\1, 0x00/' >> $@
+ $(AM_V_at)echo "};" >> $@
pidgin_DEPENDENCIES = @LIBOBJS@
pidgin_LDFLAGS = -export-dynamic
diff --git a/pidgin/gtkdebug.c b/pidgin/gtkdebug.c
--- a/pidgin/gtkdebug.c
+++ b/pidgin/gtkdebug.c
@@ -41,6 +41,8 @@
#include "gtk3compat.h"
+#include "gtkdebug.html.h"
+
typedef struct
{
GtkWidget *window;
@@ -57,42 +59,6 @@ typedef struct
GRegex *regex;
} DebugWindow;
-#define EMPTY_HTML \
- "<html><head><style>" \
- "body{white-space:pre-wrap;}" \
- "div.l0{color:#000000;}" /* All debug levels. */ \
- "div.l1{color:#666666;}" /* Misc. */ \
- "div.l2{color:#000000;}" /* Information. */ \
- "div.l3{color:#660000;}" /* Warnings. */ \
- "div.l4{color:#FF0000;}" /* Errors. */ \
- "div.l5{color:#FF0000;font-weight:bold;}" /* Fatal errors. */ \
- /* Filter levels */ \
- "div#pause~div{display:none;}" \
- "body.l1 div.l0{display:none;}" \
- "body.l2 div.l0,body.l2 div.l1{display:none;}" \
- "body.l3 div.l0,body.l3 div.l1,body.l3 div.l2{display:none;}" \
- "body.l4 div.l0,body.l4 div.l1,body.l4 div.l2,body.l4 div.l3{display:none;}" \
- "body.l5 div.l0,body.l5 div.l1,body.l5 div.l2,body.l5 div.l3,body.l5 div.l4{display:none;}" \
- /* Regex */ \
- "div.hide{display:none;}" \
- "span.regex{background-color:#ffafaf;font-weight:bold;}" \
- "</style><script>" \
- "function append(level, time, cat, msg) {" \
- "var div = document.createElement('div');" \
- "div.className = 'l' + level;" \
- "div.appendChild(document.createTextNode('(' + time + ') '));" \
- "if (cat) {" \
- "var cat_n = document.createElement('b');" \
- "cat_n.appendChild(document.createTextNode(cat + ':'));" \
- "div.appendChild(cat_n);" \
- "div.appendChild(document.createTextNode(' '));" \
- "}" \
- "div.appendChild(document.createTextNode(msg));" \
- "document.body.appendChild(div);" \
- "alert('appended');" \
- "}" \
- "</script></head><body class=l%d></body></html>"
-
static DebugWindow *debug_win = NULL;
static guint debug_enabled_timer = 0;
@@ -166,13 +132,7 @@ save_cb(GtkWidget *w, DebugWindow *win)
static void
clear_cb(GtkWidget *w, DebugWindow *win)
{
- char *tmp;
- int level;
-
- level = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/filterlevel");
- tmp = g_strdup_printf(EMPTY_HTML, level);
- gtk_webview_load_html_string(GTK_WEBVIEW(win->text), tmp);
- g_free(tmp);
+ gtk_webview_safe_execute_script(GTK_WEBVIEW(win->text), "clear();");
}
static void
@@ -180,20 +140,10 @@ pause_cb(GtkWidget *w, DebugWindow *win)
{
win->paused = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(w));
- if (win->paused) {
- gtk_webview_append_html(GTK_WEBVIEW(win->text), "<div id=pause></div>");
- } else {
- WebKitDOMDocument *dom;
- WebKitDOMElement *pause;
-
- dom = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(win->text));
- pause = webkit_dom_document_get_element_by_id(dom, "pause");
- if (pause) {
- WebKitDOMNode *parent;
- parent = webkit_dom_node_get_parent_node(WEBKIT_DOM_NODE(pause));
- webkit_dom_node_remove_child(parent, WEBKIT_DOM_NODE(pause), NULL);
- }
- }
+ if (win->paused)
+ gtk_webview_safe_execute_script(GTK_WEBVIEW(win->text), "pauseOutput();");
+ else
+ gtk_webview_safe_execute_script(GTK_WEBVIEW(win->text), "resumeOutput();");
}
/******************************************************************************
@@ -201,243 +151,63 @@ pause_cb(GtkWidget *w, DebugWindow *win)
*****************************************************************************/
static void
regex_clear_color(GtkWidget *w) {
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *context = gtk_widget_get_style_context(w);
+ gtk_style_context_remove_class(context, "good-filter");
+ gtk_style_context_remove_class(context, "bad-filter");
+#else
gtk_widget_modify_base(w, GTK_STATE_NORMAL, NULL);
+#endif
}
static void
-regex_change_color(GtkWidget *w, guint16 r, guint16 g, guint16 b) {
+regex_change_color(GtkWidget *w, gboolean success) {
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *context = gtk_widget_get_style_context(w);
+
+ if (success) {
+ gtk_style_context_add_class(context, "good-filter");
+ gtk_style_context_remove_class(context, "bad-filter");
+ } else {
+ gtk_style_context_add_class(context, "bad-filter");
+ gtk_style_context_remove_class(context, "good-filter");
+ }
+#else
GdkColor color;
- color.red = r;
- color.green = g;
- color.blue = b;
+ if (success) {
+ color.red = 0xAFFF;
+ color.green = 0xFFFF;
+ color.blue = 0xAFFF;
+ } else {
+ color.red = 0xFFFF;
+ color.green = 0xAFFF;
+ color.blue = 0xAFFF;
+ }
gtk_widget_modify_base(w, GTK_STATE_NORMAL, &color);
-}
-
-static void
-regex_toggle_div(WebKitDOMNode *div)
-{
- WebKitDOMDOMTokenList *classes;
-
- if (!WEBKIT_DOM_IS_HTML_ELEMENT(div))
- return;
-
-#if (WEBKIT_MAJOR_VERSION == 1 && \
- WEBKIT_MINOR_VERSION == 9 && \
- WEBKIT_MICRO_VERSION == 90)
- /* Workaround WebKit API bug. */
- classes = webkit_dom_element_get_class_list(WEBKIT_DOM_ELEMENT(div));
-#else
- classes = webkit_dom_html_element_get_class_list(WEBKIT_DOM_HTML_ELEMENT(div));
#endif
- webkit_dom_dom_token_list_toggle(classes, "hide", NULL);
- g_object_unref(classes);
-}
-
-static void
-regex_highlight_clear(WebKitDOMDocument *dom)
-{
- WebKitDOMNodeList *nodes;
- gulong i;
-
- /* Remove highlighting SPANs */
- nodes = webkit_dom_document_get_elements_by_class_name(dom, "regex");
- i = webkit_dom_node_list_get_length(nodes);
- while (i--) {
- WebKitDOMNode *span, *parent;
- char *content;
- WebKitDOMText *text;
- GError *err = NULL;
-
- span = webkit_dom_node_list_item(nodes, i);
- parent = webkit_dom_node_get_parent_node(span);
-
- content = webkit_dom_node_get_text_content(span);
- text = webkit_dom_document_create_text_node(dom, content);
- g_free(content);
-
- webkit_dom_node_replace_child(parent, WEBKIT_DOM_NODE(text), span, &err);
- }
-
- g_object_unref(nodes);
-}
-
-static void
-regex_highlight_text_nodes(WebKitDOMDocument *dom, WebKitDOMNode *div,
- gint start_pos, gint end_pos)
-{
- GSList *data = NULL;
- WebKitDOMNode *node;
- WebKitDOMRange *range;
- WebKitDOMElement *span;
- gint ind, end_ind;
- gint this_start, this_end;
-
- ind = 0;
- webkit_dom_node_normalize(div);
- node = div;
-
- /* First, find the container nodes and offsets to apply highlighting. */
- do {
- if (webkit_dom_node_get_node_type(node) == 3/*TEXT_NODE*/) {
- /* The GObject model does not correctly reflect the type, hence the
- regular cast. */
- end_ind = ind + webkit_dom_character_data_get_length((WebKitDOMCharacterData*)node);
-
- if (start_pos <= ind)
- this_start = 0;
- else if (start_pos < end_ind)
- this_start = start_pos - ind;
- else
- this_start = -1;
-
- if (end_pos < end_ind)
- this_end = end_pos - ind;
- else
- this_end = end_ind - ind;
-
- if (this_start != -1 && this_start < this_end) {
- data = g_slist_prepend(data, GINT_TO_POINTER(this_end));
- data = g_slist_prepend(data, GINT_TO_POINTER(this_start));
- data = g_slist_prepend(data, node);
- }
-
- ind = end_ind;
- }
-
- if (webkit_dom_node_has_child_nodes(node)) {
- node = webkit_dom_node_get_first_child(node);
- } else {
- while (node != div) {
- WebKitDOMNode *next;
-
- next = webkit_dom_node_get_next_sibling(node);
- if (next) {
- node = next;
- break;
- } else {
- node = webkit_dom_node_get_parent_node(node);
- }
- }
- }
- } while (node != div);
-
More information about the Commits
mailing list