Merged soc.2013.gobjectification branch soc.2013.gobjectification.plugins

Sat, 17 Aug 2013 06:08:35 +0530

author
Ankit Vani <a@nevitus.org>
date
Sat, 17 Aug 2013 06:08:35 +0530
branch
soc.2013.gobjectification.plugins
changeset 36541
25bbce98aeb6
parent 36540
10eb918682fc (current diff)
parent 34883
7d9d0d7b7b62 (diff)
child 36542
30f40ecc4631

Merged soc.2013.gobjectification branch

libpurple/core.c file | annotate | diff | comparison | revisions
libpurple/keyring.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/jabber.c file | annotate | diff | comparison | revisions
libpurple/protocols/mxit/mxit.c file | annotate | diff | comparison | revisions
libpurple/protocols/myspace/myspace.c file | annotate | diff | comparison | revisions
libpurple/protocols/sametime/sametime.c file | annotate | diff | comparison | revisions
libpurple/util.c file | annotate | diff | comparison | revisions
pidgin/gtkmain.c file | annotate | diff | comparison | revisions
pidgin/gtkwebviewtoolbar.c file | annotate | diff | comparison | revisions
--- a/libpurple/core.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/core.c	Sat Aug 17 06:08:35 2013 +0530
@@ -78,6 +78,29 @@
 STATIC_PROTO_LOAD
 STATIC_PROTO_UNLOAD
 
+static void
+purple_core_print_version(void)
+{
+	GHashTable *ui_info = purple_core_get_ui_info();
+	const gchar *ui_name;
+	const gchar *ui_version;
+	gchar *ui_full_name = NULL;
+
+	ui_name = ui_info ? g_hash_table_lookup(ui_info, "name") : NULL;
+	ui_version = ui_info ? g_hash_table_lookup(ui_info, "version") : NULL;
+
+	if (ui_name) {
+		ui_full_name = g_strdup_printf("%s%s%s", ui_name,
+			ui_version ? " " : "", ui_version);
+	}
+
+	purple_debug_info("main", "Launching %s%slibpurple %s",
+		ui_full_name ? ui_full_name : "",
+		ui_full_name ? " with " : "",
+		purple_core_get_version());
+
+}
+
 gboolean
 purple_core_init(const char *ui)
 {
@@ -122,6 +145,8 @@
 	purple_signal_register(core, "core-initialized", purple_marshal_VOID,
 		G_TYPE_NONE, 0);
 
+	purple_core_print_version();
+
 	/* The prefs subsystem needs to be initialized before static protocols
 	 * for protocol prefs to work. */
 	purple_prefs_init();
--- a/libpurple/dbus-server.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/dbus-server.c	Sat Aug 17 06:08:35 2013 +0530
@@ -625,8 +625,6 @@
 
 	dbus_connection_setup_with_g_main(purple_dbus_connection, NULL);
 
-	purple_debug_misc("dbus", "okkk\n");
-
 	purple_signal_register(purple_dbus_get_handle(), "dbus-method-called",
 			 purple_marshal_BOOLEAN__POINTER_POINTER,
 			 G_TYPE_BOOLEAN, 2, G_TYPE_POINTER, G_TYPE_POINTER);
@@ -636,6 +634,9 @@
 			 G_TYPE_POINTER); /* pointer to a pointer */
 
 	PURPLE_DBUS_REGISTER_BINDINGS(purple_dbus_get_handle());
+
+	if (purple_debug_is_verbose())
+		purple_debug_misc("dbus", "initialized");
 }
 
 
--- a/libpurple/debug.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/debug.c	Sat Aug 17 06:08:35 2013 +0530
@@ -50,6 +50,8 @@
 static gboolean debug_verbose = FALSE;
 static gboolean debug_unsafe = FALSE;
 
+static gboolean debug_colored = FALSE;
+
 static void
 purple_debug_vargs(PurpleDebugLevel level, const char *category,
 				 const char *format, va_list args)
@@ -67,20 +69,40 @@
 		return;
 
 	arg_s = g_strdup_vprintf(format, args);
+	g_strchomp(arg_s); /* strip trailing linefeeds */
 
 	if (debug_enabled) {
 		gchar *ts_s;
 		const char *mdate;
 		time_t mtime = time(NULL);
+		const gchar *format_pre, *format_post;
 
+		format_pre = "";
+		format_post = "";
+
+		if (!debug_colored)
+			format_pre = "";
+		else if (level == PURPLE_DEBUG_MISC)
+			format_pre = "\033[0;37m";
+		else if (level == PURPLE_DEBUG_INFO)
+			format_pre = "";
+		else if (level == PURPLE_DEBUG_WARNING)
+			format_pre = "\033[0;33m";
+		else if (level == PURPLE_DEBUG_ERROR)
+			format_pre = "\033[1;31m";
+		else if (level == PURPLE_DEBUG_FATAL)
+			format_pre = "\033[1;33;41m";
+
+		if (format_pre[0] != '\0')
+			format_post = "\033[0m";
 
 		mdate = purple_utf8_strftime("%H:%M:%S", localtime(&mtime));
 		ts_s = g_strdup_printf("(%s) ", mdate);
 
 		if (category == NULL)
-			g_print("%s%s", ts_s, arg_s);
+			g_print("%s%s%s%s\n", format_pre, ts_s, arg_s, format_post);
 		else
-			g_print("%s%s: %s", ts_s, category, arg_s);
+			g_print("%s%s%s: %s%s\n", format_pre, ts_s, category, arg_s, format_post);
 
 		g_free(ts_s);
 	}
@@ -207,6 +229,12 @@
 	debug_unsafe = unsafe;
 }
 
+void
+purple_debug_set_colored(gboolean colored)
+{
+	debug_colored = colored;
+}
+
 PurpleDebugUiOps *
 purple_debug_get_ui_ops(void)
 {
--- a/libpurple/debug.h	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/debug.h	Sat Aug 17 06:08:35 2013 +0530
@@ -189,6 +189,13 @@
  */
 gboolean purple_debug_is_unsafe(void);
 
+/**
+ * Enable or disable colored output for bash console.
+ *
+ * @param colored TRUE to enable colored output, FALSE to disable it.
+ */
+void purple_debug_set_colored(gboolean colored);
+
 /*@}*/
 
 /**************************************************************************/
--- a/libpurple/keyring.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/keyring.c	Sat Aug 17 06:08:35 2013 +0530
@@ -479,8 +479,8 @@
 	/* If this is the configured keyring, use it. */
 	if (purple_keyring_inuse == NULL &&
 		g_strcmp0(keyring_id, purple_keyring_to_use) == 0) {
-		purple_debug_info("keyring", "Keyring %s matches keyring to "
-			"use, using it.\n", keyring_id);
+		purple_debug_misc("keyring", "Keyring %s matches keyring to "
+			"use, using it.", keyring_id);
 		purple_keyring_set_inuse(keyring, TRUE, NULL, NULL);
 	}
 
--- a/libpurple/prefs.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/prefs.c	Sat Aug 17 06:08:35 2013 +0530
@@ -386,7 +386,7 @@
 		return FALSE;
 	}
 
-	purple_debug_info("prefs", "Reading %s\n", filename);
+	purple_debug_misc("prefs", "Reading %s", filename);
 
 	if(!g_file_get_contents(filename, &contents, &length, &error)) {
 #ifdef _WIN32
@@ -438,7 +438,8 @@
 		return FALSE;
 	}
 
-	purple_debug_info("prefs", "Finished reading %s\n", filename);
+	if (purple_debug_is_verbose())
+		purple_debug_misc("prefs", "Finished reading %s", filename);
 	g_markup_parse_context_free(context);
 	g_free(contents);
 	g_free(filename);
--- a/libpurple/protocols/jabber/data.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/protocols/jabber/data.c	Sat Aug 17 06:08:35 2013 +0530
@@ -437,7 +437,8 @@
 void
 jabber_data_init(void)
 {
-	purple_debug_info("jabber", "creating hash tables for data objects\n");
+	if (purple_debug_is_verbose())
+		purple_debug_misc("jabber", "creating hash tables for data objects");
 	local_data_by_alt = g_hash_table_new_full(g_str_hash, g_str_equal,
 		g_free, NULL);
 	local_data_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal,
@@ -451,7 +452,8 @@
 void
 jabber_data_uninit(void)
 {
-	purple_debug_info("jabber", "destroying hash tables for data objects\n");
+	if (purple_debug_is_verbose())
+		purple_debug_info("jabber", "destroying hash tables for data objects");
 	g_hash_table_destroy(local_data_by_alt);
 	g_hash_table_destroy(local_data_by_cid);
 	g_hash_table_destroy(remote_data_by_cid);
--- a/libpurple/protocols/jabber/jabber.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/protocols/jabber/jabber.c	Sat Aug 17 06:08:35 2013 +0530
@@ -658,7 +658,7 @@
 	while((len = purple_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) {
 		purple_connection_update_last_received(gc);
 		buf[len] = '\0';
-		purple_debug_info("jabber", "Recv (ssl)(%d): %s\n", len, buf);
+		purple_debug_misc("jabber", "Recv (ssl)(%d): %s", len, buf);
 		jabber_parser_process(js, buf, len);
 		if(js->reinit)
 			jabber_stream_init(js);
@@ -718,7 +718,7 @@
 		}
 #endif
 		buf[len] = '\0';
-		purple_debug_info("jabber", "Recv (%d): %s\n", len, buf);
+		purple_debug_misc("jabber", "Recv (%d): %s", len, buf);
 		jabber_parser_process(js, buf, len);
 		if(js->reinit)
 			jabber_stream_init(js);
--- a/libpurple/protocols/mxit/mxit.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/protocols/mxit/mxit.c	Sat Aug 17 06:08:35 2013 +0530
@@ -488,8 +488,6 @@
 {
 	struct contact*		contact;
 
-	purple_debug_info( MXIT_PLUGIN_ID, "mxit_free_buddy\n" );
-
 	contact = purple_buddy_get_protocol_data( buddy );
 	if ( contact ) {
 		if ( contact->statusMsg )
@@ -837,8 +835,6 @@
 {
 	PurpleAccountOption*	option;
 
-	purple_debug_info( MXIT_PLUGIN_ID, "Loading MXit libPurple plugin...\n" );
-
 	/* Configuration options */
 
 	/* WAP server (reference: "libpurple/accountopt.h") */
--- a/libpurple/protocols/myspace/myspace.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/protocols/myspace/myspace.c	Sat Aug 17 06:08:35 2013 +0530
@@ -455,8 +455,6 @@
 	GList *types;
 	PurpleStatusType *status;
 
-	purple_debug_info("myspace", "returning status types\n");
-
 	types = NULL;
 
 	/* Statuses are almost all the same. Define a macro to reduce code repetition. */
--- a/libpurple/protocols/sametime/sametime.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/protocols/sametime/sametime.c	Sat Aug 17 06:08:35 2013 +0530
@@ -5100,7 +5100,7 @@
   }
 }
 
-
+#if 0
 static PurplePluginPrefFrame *
 mw_plugin_get_plugin_pref_frame(PurplePlugin *plugin) {
   PurplePluginPrefFrame *frame;
@@ -5129,7 +5129,7 @@
 
   return frame;
 }
-
+#endif
 
 static void st_import_action_cb(PurpleConnection *gc, char *filename) {
   struct mwSametimeList *l;
@@ -5693,18 +5693,17 @@
 plugin_query(GError **error)
 {
 	return purple_plugin_info_new(
-		"id",                 PLUGIN_ID,
-		"name",               PLUGIN_NAME,
-		"version",            DISPLAY_VERSION,
-		"category",           PLUGIN_CATEGORY,
-		"summary",            PLUGIN_SUMMARY,
-		"description",        PLUGIN_DESC,
-		"author",             PLUGIN_AUTHOR,
-		"website",            PLUGIN_HOMEPAGE,
-		"abi-version",        PURPLE_ABI_VERSION,
-		"preferences-frame",  mw_plugin_get_plugin_pref_frame,
-		"flags",              GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL |
-		                      GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY,
+		"id",           PLUGIN_ID,
+		"name",         PLUGIN_NAME,
+		"version",      DISPLAY_VERSION,
+		"category",     PLUGIN_CATEGORY,
+		"summary",      PLUGIN_SUMMARY,
+		"description",  PLUGIN_DESC,
+		"author",       PLUGIN_AUTHOR,
+		"website",      PLUGIN_HOMEPAGE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		"flags",        GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL |
+		                GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY,
 		NULL
 	);
 }
--- a/libpurple/util.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/util.c	Sat Aug 17 06:08:35 2013 +0530
@@ -2942,7 +2942,7 @@
 
 	g_return_val_if_fail(user_dir != NULL, FALSE);
 
-	purple_debug_info("util", "Writing file %s to directory %s\n",
+	purple_debug_misc("util", "Writing file %s to directory %s",
 					filename, user_dir);
 
 	/* Ensure the user directory exists */
@@ -2975,7 +2975,7 @@
 	int fd;
 #endif
 
-	purple_debug_info("util", "Writing file %s\n",
+	purple_debug_misc("util", "Writing file %s",
 					filename_full);
 
 	g_return_val_if_fail((size >= -1), FALSE);
--- a/libpurple/xmlnode.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/libpurple/xmlnode.c	Sat Aug 17 06:08:35 2013 +0530
@@ -835,7 +835,7 @@
 
 	g_return_val_if_fail(dir != NULL, NULL);
 
-	purple_debug_info(process, "Reading file %s from directory %s\n",
+	purple_debug_misc(process, "Reading file %s from directory %s\n",
 					filename, dir);
 
 	filename_full = g_build_filename(dir, filename, NULL);
--- a/pidgin/gtkmain.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/pidgin/gtkmain.c	Sat Aug 17 06:08:35 2013 +0530
@@ -387,7 +387,7 @@
 		g_string_append_printf(str, _("Usage: %s [OPTION]...\n\n"), name);
 		g_string_append_printf(str, "  -c, --config=%s    %s\n",
 				_("DIR"), _("use DIR for config files"));
-		g_string_append_printf(str, "  -d, --debug         %s\n",
+		g_string_append_printf(str, "  -d, --debug[=colored] %s\n",
 				_("print debugging messages to stdout"));
 		g_string_append_printf(str, "  -f, --force-online  %s\n",
 				_("force online, regardless of network status"));
@@ -457,13 +457,13 @@
 #endif
 	int opt;
 	gboolean gui_check;
-	gboolean debug_enabled;
+	gboolean debug_enabled, debug_colored;
 	GList *active_accounts;
 	GStatBuf st;
 
 	struct option long_options[] = {
 		{"config",       required_argument, NULL, 'c'},
-		{"debug",        no_argument,       NULL, 'd'},
+		{"debug",        optional_argument, NULL, 'd'},
 		{"force-online", no_argument,       NULL, 'f'},
 		{"help",         no_argument,       NULL, 'h'},
 		{"login",        optional_argument, NULL, 'l'},
@@ -476,6 +476,7 @@
 		{0, 0, 0, 0}
 	};
 
+	debug_colored = FALSE;
 #ifdef DEBUG
 	debug_enabled = TRUE;
 #else
@@ -623,6 +624,8 @@
 			break;
 		case 'd':	/* debug */
 			debug_enabled = TRUE;
+			if (g_strcmp0(optarg, "colored") == 0)
+				debug_colored = TRUE;
 			break;
 		case 'f':	/* force-online */
 			opt_force_online = TRUE;
@@ -702,6 +705,7 @@
 	 */
 
 	purple_debug_set_enabled(debug_enabled);
+	purple_debug_set_colored(debug_colored);
 
 #if !GTK_CHECK_VERSION(3,0,0)
 	search_path = g_build_filename(purple_user_dir(), "gtkrc-2.0", NULL);
--- a/pidgin/gtkprefs.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/pidgin/gtkprefs.c	Sat Aug 17 06:08:35 2013 +0530
@@ -4285,8 +4285,6 @@
 void
 pidgin_prefs_update_old(void)
 {
-	const char *str = NULL;
-
 	/* Rename some old prefs */
 	purple_prefs_rename(PIDGIN_PREFS_ROOT "/logging/log_ims", "/purple/logging/log_ims");
 	purple_prefs_rename(PIDGIN_PREFS_ROOT "/logging/log_chats", "/purple/logging/log_chats");
@@ -4299,13 +4297,19 @@
 									 PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting");
 
 	/*
-	 * this path pref changed to a string, so migrate.  I know this will break
-	 * things for and confuse users that use multiple versions with the same
-	 * config directory, but I'm not inclined to want to deal with that at the
-	 * moment. -- rekkanoryo
+	 * This path pref changed to a string, so migrate. I know this will
+	 * break things for and confuse users that use multiple versions with
+	 * the same config directory, but I'm not inclined to want to deal with
+	 * that at the moment. -- rekkanoryo
 	 */
-	if((str = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/browsers/command")) != NULL) {
-		purple_prefs_set_string(PIDGIN_PREFS_ROOT "/browsers/manual_command", str);
+	if (purple_prefs_exists(PIDGIN_PREFS_ROOT "/browsers/command") &&
+		purple_prefs_get_type(PIDGIN_PREFS_ROOT "/browsers/command") ==
+			PURPLE_PREF_PATH)
+	{
+		const char *str = purple_prefs_get_path(
+			PIDGIN_PREFS_ROOT "/browsers/command");
+		purple_prefs_set_string(
+			PIDGIN_PREFS_ROOT "/browsers/manual_command", str);
 		purple_prefs_remove(PIDGIN_PREFS_ROOT "/browsers/command");
 	}
 
--- a/pidgin/gtksession.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/pidgin/gtksession.c	Sat Aug 17 06:08:35 2013 +0530
@@ -72,7 +72,10 @@
 		IceSetShutdownNegotiation(conninfo->connection, False);
 		IceCloseConnection(conninfo->connection);
 
-		purple_debug(PURPLE_DEBUG_INFO, NULL, "done.\n");
+		if (purple_debug_is_verbose()) {
+			purple_debug_misc("Session Management",
+				"Connection closed.");
+		}
 
 		/* cancel the handler */
 		purple_input_remove(conninfo->input_id);
@@ -84,8 +87,8 @@
 	struct ice_connection_info *conninfo = NULL;
 
 	if (opening) {
-		purple_debug(PURPLE_DEBUG_INFO, "Session Management",
-				   "Handling new ICE connection... \n");
+		purple_debug_misc("Session Management",
+			"Handling new ICE connection...");
 
 		/* ensure ICE connection is not passed to child processes */
 		fcntl(IceConnectionNumber(connection), F_SETFD, FD_CLOEXEC);
@@ -107,7 +110,10 @@
 		g_free(conninfo);
 	}
 
-	purple_debug(PURPLE_DEBUG_INFO, NULL, "done.\n");
+	if (purple_debug_is_verbose()) {
+		purple_debug_misc("Session Management",
+			"ICE connection handled.");
+	}
 }
 
 /* We call any handler installed before (or after) ice_init but
@@ -124,7 +130,10 @@
 	if (ice_installed_io_error_handler)
 		(*ice_installed_io_error_handler)(connection);
 
-	purple_debug(PURPLE_DEBUG_INFO, NULL, "done.\n");
+	if (purple_debug_is_verbose()) {
+		purple_debug_misc("Session Management",
+			"ICE IO error handled.");
+	}
 }
 
 static void ice_init(void) {
@@ -138,8 +147,9 @@
 
 	IceAddConnectionWatch(ice_connection_watch, NULL);
 
-	purple_debug(PURPLE_DEBUG_INFO, "Session Management",
-			   "ICE initialized.\n");
+	if (purple_debug_is_verbose()) {
+		purple_debug_misc("Session Management", "ICE initialized.");
+	}
 }
 
 /* my magic utility function */
--- a/pidgin/gtkwebview.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/pidgin/gtkwebview.c	Sat Aug 17 06:08:35 2013 +0530
@@ -131,6 +131,10 @@
 	char *protocol_name;
 	GHashTable *smiley_data;
 	GtkSmileyTree *default_smilies;
+
+	/* WebKit inspector */
+	WebKitWebView *inspector_view;
+	GtkWindow *inspector_win;
 } GtkWebViewPriv;
 
 /******************************************************************************
@@ -837,11 +841,41 @@
 }
 
 static void
-webview_show_inspector_cb(GtkWidget *item, GtkWebViewInspectData *data)
+webview_inspector_inspect_element(GtkWidget *item, GtkWebViewInspectData *data)
 {
 	webkit_web_inspector_inspect_node(data->inspector, data->node);
 }
 
+static WebKitWebView *
+webview_inspector_create(WebKitWebInspector *inspector,
+	WebKitWebView *webview, gpointer _unused)
+{
+	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+
+	if (priv->inspector_view != NULL)
+		return priv->inspector_view;
+
+	priv->inspector_win = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
+	gtk_window_set_title(priv->inspector_win, _("WebKit inspector"));
+	gtk_window_set_default_size(priv->inspector_win, 600, 400);
+
+	priv->inspector_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+	gtk_container_add(GTK_CONTAINER(priv->inspector_win),
+		GTK_WIDGET(priv->inspector_view));
+
+	return priv->inspector_view;
+}
+
+static gboolean
+webview_inspector_show(WebKitWebInspector *inspector, GtkWidget *webview)
+{
+	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+
+	gtk_widget_show_all(GTK_WIDGET(priv->inspector_win));
+
+	return TRUE;
+}
+
 static GtkWebViewProtocol *
 webview_find_protocol(const char *url, gboolean reverse)
 {
@@ -997,8 +1031,6 @@
 {
 	GtkWidget *menu;
 	GtkWidget *cut, *copy, *paste, *delete, *select;
-	WebKitWebSettings *settings;
-	gboolean inspector;
 
 	menu = gtk_menu_new();
 	g_signal_connect(menu, "selection-done",
@@ -1077,12 +1109,16 @@
 			webkit_web_view_can_cut_clipboard(webview));
 	}
 
-	settings = webkit_web_view_get_settings(webview);
-	g_object_get(G_OBJECT(settings), "enable-developer-extras", &inspector, NULL);
-	if (inspector) {
+	if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT
+		"/webview/inspector_enabled"))
+	{
+		WebKitWebSettings *settings;
 		GtkWidget *inspect;
 		GtkWebViewInspectData *data;
 
+		settings = webkit_web_view_get_settings(webview);
+		g_object_set(G_OBJECT(settings), "enable-developer-extras", TRUE, NULL);
+
 		data = g_new0(GtkWebViewInspectData, 1);
 		data->inspector = webkit_web_view_get_inspector(webview);
 		data->node = node;
@@ -1092,7 +1128,7 @@
 		inspect = pidgin_new_item_from_stock(menu, _("Inspect _Element"), NULL,
 		                                     NULL, NULL, 0, 0, NULL);
 		g_signal_connect_data(G_OBJECT(inspect), "activate",
-		                      G_CALLBACK(webview_show_inspector_cb),
+		                      G_CALLBACK(webview_inspector_inspect_element),
 		                      data, (GClosureNotify)g_free, 0);
 	}
 
@@ -1391,6 +1427,9 @@
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
 	gpointer temp;
 
+	if (priv->inspector_win != NULL)
+		gtk_widget_destroy(GTK_WIDGET(priv->inspector_win));
+
 	if (priv->loader)
 		g_source_remove(priv->loader);
 
@@ -1492,12 +1531,16 @@
 	binding_set = gtk_binding_set_by_class(klass);
 	gtk_binding_entry_add_signal(binding_set, GDK_KEY_r, GDK_CONTROL_MASK,
 	                             "format-cleared", 0);
+
+	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/webview");
+	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/webview/inspector_enabled", FALSE);
 }
 
 static void
 gtk_webview_init(GtkWebView *webview, gpointer userdata)
 {
 	GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+	WebKitWebInspector *inspector;
 
 	priv->load_queue = g_queue_new();
 
@@ -1522,6 +1565,12 @@
 
 	g_signal_connect(G_OBJECT(webview), "resource-request-starting",
 	                 G_CALLBACK(webview_resource_loading), NULL);
+
+	inspector = webkit_web_view_get_inspector(WEBKIT_WEB_VIEW(webview));
+	g_signal_connect(G_OBJECT(inspector), "inspect-web-view",
+		G_CALLBACK(webview_inspector_create), NULL);
+	g_signal_connect(G_OBJECT(inspector), "show-window",
+		G_CALLBACK(webview_inspector_show), webview);
 }
 
 GType
--- a/pidgin/gtkwebviewtoolbar.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/pidgin/gtkwebviewtoolbar.c	Sat Aug 17 06:08:35 2013 +0530
@@ -1097,6 +1097,12 @@
 	g_free(tmp);
 
 	tmp = gtk_webview_get_current_forecolor(GTK_WEBVIEW(toolbar->webview));
+	/* TODO: rgb()/rgba() colors are not supported by GTK, so let's get rid
+	 * of such warnings for now. There are two solutions: rewrite those
+	 * colors to #aabbcc or implement the toolbar in javascript.
+	 */
+	if (tmp && strncmp(tmp, "rgb", 3) == 0)
+		tmp[0] = '\0';
 	toggle_action_set_active_block(GTK_TOGGLE_ACTION(priv->fgcolor),
 	                               (tmp && *tmp), toolbar);
 	if (tmp && *tmp) {
@@ -1108,6 +1114,9 @@
 	g_free(tmp);
 
 	tmp = gtk_webview_get_current_backcolor(GTK_WEBVIEW(toolbar->webview));
+	/* TODO: see comment above */
+	if (tmp && strncmp(tmp, "rgb", 3) == 0)
+		tmp[0] = '\0';
 	toggle_action_set_active_block(GTK_TOGGLE_ACTION(priv->bgcolor),
 	                               (tmp && *tmp), toolbar);
 	if (tmp && *tmp) {
--- a/pidgin/plugins/webkit.c	Thu Aug 15 03:33:44 2013 +0530
+++ b/pidgin/plugins/webkit.c	Sat Aug 17 06:08:35 2013 +0530
@@ -21,114 +21,15 @@
 
 #include "version.h"
 
-#include "pidgin.h"
-
-#include "gtkconv.h"
 #include "gtkplugin.h"
-#include "gtkwebview.h"
-
-static WebKitWebView *
-create_gtk_window_around_it(WebKitWebInspector *inspector,
-                            WebKitWebView      *webview,
-                            PidginConversation *gtkconv)
-{
-	GtkWidget *win;
-	GtkWidget *view;
-	char *title;
-
-	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-	title = g_strdup_printf(_("%s - Inspector"),
-	                        gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)));
-	gtk_window_set_title(GTK_WINDOW(win), title);
-	g_free(title);
-	gtk_window_set_default_size(GTK_WINDOW(win), 600, 400);
-	g_signal_connect_swapped(G_OBJECT(gtkconv->tab_cont), "destroy", G_CALLBACK(gtk_widget_destroy), win);
-
-	view = webkit_web_view_new();
-	gtk_container_add(GTK_CONTAINER(win), view);
-	g_object_set_data(G_OBJECT(webview), "inspector-window", win);
-
-	return WEBKIT_WEB_VIEW(view);
-}
-
-static gboolean
-show_inspector_window(WebKitWebInspector *inspector,
-                      GtkWidget          *webview)
-{
-	GtkWidget *win;
-
-	win = g_object_get_data(G_OBJECT(webview), "inspector-window");
-
-	gtk_widget_show_all(win);
-
-	return TRUE;
-}
-
-static void
-setup_inspector(PidginConversation *gtkconv)
-{
-	GtkWidget *webview = gtkconv->webview;
-	WebKitWebSettings *settings;
-	WebKitWebInspector *inspector;
-
-	settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webview));
-	inspector = webkit_web_view_get_inspector(WEBKIT_WEB_VIEW(webview));
-
-	g_object_set(G_OBJECT(settings), "enable-developer-extras", TRUE, NULL);
-
-	g_signal_connect(G_OBJECT(inspector), "inspect-web-view",
-	                 G_CALLBACK(create_gtk_window_around_it), gtkconv);
-	g_signal_connect(G_OBJECT(inspector), "show-window",
-	                 G_CALLBACK(show_inspector_window), webview);
-}
-
-static void
-remove_inspector(PidginConversation *gtkconv)
-{
-	GtkWidget *webview = gtkconv->webview;
-	GtkWidget *win;
-	WebKitWebSettings *settings;
-
-	win = g_object_get_data(G_OBJECT(webview), "inspector-window");
-	gtk_widget_destroy(win);
-	g_object_set_data(G_OBJECT(webview), "inspector-window", NULL);
-
-	settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webview));
-
-	g_object_set(G_OBJECT(settings), "enable-developer-extras", FALSE, NULL);
-}
-
-static void
-conversation_displayed_cb(PidginConversation *gtkconv)
-{
-	GtkWidget *inspect = NULL;
-
-	inspect = g_object_get_data(G_OBJECT(gtkconv->webview),
-	                            "inspector-window");
-	if (inspect == NULL) {
-		setup_inspector(gtkconv);
-	}
-}
 
 static gboolean
 plugin_load(PurplePlugin *plugin)
 {
-	GList *convs = purple_conversations_get_all();
-	void *gtk_conv_handle = pidgin_conversations_get_handle();
-
-	purple_signal_connect(gtk_conv_handle, "conversation-displayed", plugin,
-	                      PURPLE_CALLBACK(conversation_displayed_cb), NULL);
+	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/webview");
+	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/webview/inspector_enabled", FALSE);
 
-	while (convs) {
-		PurpleConversation *conv = (PurpleConversation *)convs->data;
-
-		/* Setup WebKit Inspector */
-		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
-			setup_inspector(PIDGIN_CONVERSATION(conv));
-		}
-
-		convs = convs->next;
-	}
+	purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/webview/inspector_enabled", TRUE);
 
 	return TRUE;
 }
@@ -136,18 +37,7 @@
 static gboolean
 plugin_unload(PurplePlugin *plugin)
 {
-	GList *convs = purple_conversations_get_all();
-
-	while (convs) {
-		PurpleConversation *conv = (PurpleConversation *)convs->data;
-
-		/* Remove WebKit Inspector */
-		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
-			remove_inspector(PIDGIN_CONVERSATION(conv));
-		}
-
-		convs = convs->next;
-	}
+	purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/webview/inspector_enabled", FALSE);
 
 	return TRUE;
 }
@@ -167,10 +57,9 @@
 	N_("WebKit Development"),                       /**< name */
 	DISPLAY_VERSION,                                /**< version */
 	N_("Enables WebKit Inspector."),                /**< summary */
-	N_("Enables WebKit's built-in inspector in a "
-	   "conversation window. This may be viewed "
-	   "by right-clicking a WebKit widget and "
-	   "selecting 'Inspect Element'."),             /**< description */
+	N_("Enables WebKit's built-in inspector. This "
+	   "may be viewed by right-clicking a WebKit "
+	   "widget and selecting 'Inspect Element'."),  /**< description */
 	"Elliott Sales de Andrade <qulogic@pidgin.im>", /**< author */
 	PURPLE_WEBSITE,                                 /**< homepage */
 	plugin_load,                                    /**< load */
@@ -194,4 +83,3 @@
 }
 
 PURPLE_INIT_PLUGIN(webkit-devel, init_plugin, info)
-

mercurial