# HG changeset patch
# Node ID 2eb80ed38d7a
# Parent  2b22a4b216b6
diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -389,6 +389,7 @@ version 3.0.0 (??/??/????):
 		* Removed the general Purple DBus interface
 		* purple_date_format_long, use g_date_time_format instead.
 		* purple_date_format_short, use g_date_time_format instead.
+		* PurpleDebugUiOps
 		* purple_dnsquery_a_account
 		* purple_event_loop_{get|set}_ui_ops. Manually drive the GLib
 		  event loop yourself. See GLib Main Event Loop docs.
diff --git a/finch/gntdebug.h b/finch/gntdebug.h
--- a/finch/gntdebug.h
+++ b/finch/gntdebug.h
@@ -42,16 +42,6 @@ G_BEGIN_DECLS
  * GNT Debug API
  **********************************************************************/
 
-#define FINCH_TYPE_DEBUG_UI (finch_debug_ui_get_type())
-G_DECLARE_FINAL_TYPE(FinchDebugUi, finch_debug_ui, FINCH, DEBUG_UI, GObject)
-
-/**
- * finch_debug_ui_new:
- *
- * Perform necessary initializations.
- */
-FinchDebugUi *finch_debug_ui_new(void);
-
 /**
  * finch_debug_init_handler:
  *
diff --git a/finch/gntdebug.c b/finch/gntdebug.c
--- a/finch/gntdebug.c
+++ b/finch/gntdebug.c
@@ -44,12 +44,6 @@ struct _FinchDebugUi
 	/* Other members, including private data. */
 };
 
-static void finch_debug_ui_interface_init(PurpleDebugUiInterface *iface);
-
-G_DEFINE_TYPE_WITH_CODE(FinchDebugUi, finch_debug_ui, G_TYPE_OBJECT,
-                        G_IMPLEMENT_INTERFACE(PURPLE_TYPE_DEBUG_UI,
-                                              finch_debug_ui_interface_init));
-
 static gboolean
 handle_fprintf_stderr_cb(GIOChannel *source, GIOCondition cond, gpointer null)
 {
@@ -103,72 +97,6 @@ static struct
 	gboolean paused;
 } debug;
 
-static gboolean
-match_string(const char *category, const char *args)
-{
-	const char *str = gnt_entry_get_text(GNT_ENTRY(debug.search));
-	if (!str || !*str)
-		return TRUE;
-	if (g_strrstr(category, str) != NULL)
-		return TRUE;
-	if (g_strrstr(args, str) != NULL)
-		return TRUE;
-	return FALSE;
-}
-
-static void
-finch_debug_print(PurpleDebugUi *self,
-                  PurpleDebugLevel level, const char *category,
-                  const char *args)
-{
-	if (debug.window && !debug.paused && match_string(category, args))
-	{
-		int pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(debug.tview));
-		GntTextFormatFlags flag = GNT_TEXT_FLAG_NORMAL;
-		const char *mdate;
-		time_t mtime = time(NULL);
-		mdate = purple_utf8_strftime("%H:%M:%S ", localtime(&mtime));
-		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview),
-				mdate, flag);
-
-		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview),
-				category, GNT_TEXT_FLAG_BOLD);
-		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview),
-				": ", GNT_TEXT_FLAG_BOLD);
-
-		switch (level)
-		{
-			case PURPLE_DEBUG_WARNING:
-				flag |= GNT_TEXT_FLAG_UNDERLINE;
-				/* fall through */
-			case PURPLE_DEBUG_ERROR:
-			case PURPLE_DEBUG_FATAL:
-				flag |= GNT_TEXT_FLAG_BOLD;
-				break;
-			default:
-				break;
-		}
-
-		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), args, flag);
-		gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), "\n", GNT_TEXT_FLAG_NORMAL);
-		if (pos <= 1)
-			gnt_text_view_scroll(GNT_TEXT_VIEW(debug.tview), 0);
-	}
-}
-
-static gboolean
-finch_debug_is_enabled(PurpleDebugUi *self, PurpleDebugLevel level, const char *category)
-{
-	return debug.window && !debug.paused;
-}
-
-static void
-finch_debug_ui_interface_init(PurpleDebugUiInterface *iface)
-{
-	iface->print = finch_debug_print;
-	iface->is_enabled = finch_debug_is_enabled;
-}
-
 static void
 reset_debug_win(GntWidget *w, gpointer null)
 {
@@ -396,22 +324,6 @@ start_with_debugwin(gpointer null)
 	return FALSE;
 }
 
-static void
-finch_debug_ui_class_init(FinchDebugUiClass *klass)
-{
-}
-
-static void
-finch_debug_ui_init(FinchDebugUi *self)
-{
-}
-
-FinchDebugUi *
-finch_debug_ui_new(void)
-{
-	return g_object_new(FINCH_TYPE_DEBUG_UI, NULL);
-}
-
 void
 finch_debug_init_handler(void)
 {
diff --git a/finch/libfinch.c b/finch/libfinch.c
--- a/finch/libfinch.c
+++ b/finch/libfinch.c
@@ -39,13 +39,6 @@
 #include "config.h"
 #include "package_revision.h"
 
-static void
-debug_init(void)
-{
-	FinchDebugUi *ui = finch_debug_ui_new();
-	purple_debug_set_ui(PURPLE_DEBUG_UI(ui));
-}
-
 static PurpleUiInfo *
 finch_ui_get_info(void) {
 	return purple_ui_info_new(_("Finch"), VERSION, "https://pidgin.im",
@@ -61,7 +54,6 @@ finch_quit(void)
 static PurpleCoreUiOps core_ops =
 {
 	finch_prefs_init,
-	debug_init,
 	finch_ui_init,
 	finch_quit,
 	finch_ui_get_info,
diff --git a/libpurple/core.h b/libpurple/core.h
--- a/libpurple/core.h
+++ b/libpurple/core.h
@@ -48,11 +48,6 @@ typedef struct _PurpleCoreUiOps PurpleCo
  * @ui_prefs_init: Called just after the preferences subsystem is initialized;
  *                 the UI could use this callback to add some preferences it
  *                 needs to be in place when other subsystems are initialized.
- * @debug_ui_init: Called just after the debug subsystem is initialized, but
- *                 before just about every other component's initialization. The
- *                 UI should use this hook to call purple_debug_set_ui() so
- *                 that debugging information for other components can be logged
- *                 during their initialization.
  * @ui_init:       Called after all of libpurple has been initialized. The UI
  *                 should use this hook to set all other necessary
  *                 <link linkend="chapter-ui-ops"><literal>UiOps structures</literal></link>.
@@ -67,7 +62,6 @@ typedef struct _PurpleCoreUiOps PurpleCo
 struct _PurpleCoreUiOps
 {
 	void (*ui_prefs_init)(void);
-	void (*debug_ui_init)(void);
 	void (*ui_init)(void);
 
 	void (*quit)(void);
diff --git a/libpurple/core.c b/libpurple/core.c
--- a/libpurple/core.c
+++ b/libpurple/core.c
@@ -134,13 +134,10 @@ purple_core_init(const char *ui)
 
 	purple_debug_init();
 
-	if (ops != NULL)
-	{
-		if (ops->ui_prefs_init != NULL)
+	if (ops != NULL) {
+		if (ops->ui_prefs_init != NULL) {
 			ops->ui_prefs_init();
-
-		if (ops->debug_ui_init != NULL)
-			ops->debug_ui_init();
+		}
 	}
 
 	purple_cmds_init();
diff --git a/libpurple/debug.h b/libpurple/debug.h
--- a/libpurple/debug.h
+++ b/libpurple/debug.h
@@ -218,32 +218,6 @@ gboolean purple_debug_is_unsafe(void);
 void purple_debug_set_colored(gboolean colored);
 
 /******************************************************************************
- * UI Registration Functions
- *****************************************************************************/
-
-/**
- * purple_debug_set_ui:
- * @ui: The UI operations structure.
- *
- * Sets the UI operations structure to be used when outputting debug
- * information.
- *
- * Since: 3.0.0
- */
-void purple_debug_set_ui(PurpleDebugUi *ui);
-
-/**
- * purple_debug_get_ui:
- *
- * Get the #PurpleDebugUi instance used for outputting debug information.
- *
- * Returns: (transfer none): The #PurpleDebugUi instance in use.
- *
- * Since: 3.0.0
- */
-PurpleDebugUi *purple_debug_get_ui(void);
-
-/******************************************************************************
  * Debug Subsystem
  *****************************************************************************/
 
diff --git a/libpurple/debug.c b/libpurple/debug.c
--- a/libpurple/debug.c
+++ b/libpurple/debug.c
@@ -23,8 +23,6 @@
 #include "debug.h"
 #include "prefs.h"
 
-static PurpleDebugUi *debug_ui = NULL;
-
 /*
  * This determines whether debug info should be written to the
  * console or not.
@@ -159,11 +157,6 @@ purple_debug_is_enabled() {
 	return debug_enabled;
 }
 
-void
-purple_debug_set_ui(PurpleDebugUi *ui) {
-	g_set_object(&debug_ui, ui);
-}
-
 gboolean
 purple_debug_is_verbose() {
 	return debug_verbose;
@@ -189,11 +182,6 @@ purple_debug_set_colored(gboolean colore
 	debug_colored = colored;
 }
 
-PurpleDebugUi *
-purple_debug_get_ui(void) {
-	return debug_ui;
-}
-
 void
 purple_debug_init(void) {
 	/* Read environment variables once per init */
diff --git a/pidgin/libpidgin.c b/pidgin/libpidgin.c
--- a/pidgin/libpidgin.c
+++ b/pidgin/libpidgin.c
@@ -183,13 +183,6 @@ purple_ui_protocol_registered_cb(PurpleP
 	purple_ui_add_protocol_theme_paths(protocol);
 }
 
-static void
-debug_init(void)
-{
-	PidginDebugUi *ui = pidgin_debug_ui_new();
-	purple_debug_set_ui(PURPLE_DEBUG_UI(ui));
-}
-
 static gboolean
 pidgin_history_init(GError **error) {
 	PurpleHistoryManager *manager = NULL;
@@ -289,7 +282,6 @@ static void
 pidgin_quit(void)
 {
 	/* Uninit */
-	PurpleDebugUi *ui;
 
 	/* Be sure to close all windows that are not attached to anything
 	 * (e.g., the debug window), or they may access things after they are
@@ -304,9 +296,6 @@ pidgin_quit(void)
 	pidgin_accounts_uninit();
 	pidgin_xfers_uninit();
 	pidgin_debug_window_hide();
-	ui = purple_debug_get_ui();
-	purple_debug_set_ui(NULL);
-	g_object_unref(ui);
 	pidgin_debug_uninit();
 
 	/* and end it all... */
@@ -322,7 +311,6 @@ pidgin_ui_get_info(void) {
 static PurpleCoreUiOps core_ops =
 {
 	pidgin_prefs_init,
-	debug_init,
 	pidgin_ui_init,
 	pidgin_quit,
 	pidgin_ui_get_info,
diff --git a/pidgin/pidgindebug.h b/pidgin/pidgindebug.h
--- a/pidgin/pidgindebug.h
+++ b/pidgin/pidgindebug.h
@@ -36,9 +36,7 @@
 
 G_BEGIN_DECLS
 
-#define PIDGIN_TYPE_DEBUG_UI (pidgin_debug_ui_get_type())
 #define PIDGIN_TYPE_DEBUG_WINDOW (pidgin_debug_window_get_type())
-G_DECLARE_FINAL_TYPE(PidginDebugUi, pidgin_debug_ui, PIDGIN, DEBUG_UI, GObject)
 G_DECLARE_FINAL_TYPE(PidginDebugWindow, pidgin_debug_window, PIDGIN, DEBUG_WINDOW, GtkWindow)
 
 /**
@@ -72,13 +70,6 @@ void pidgin_debug_init(void);
 void pidgin_debug_uninit(void);
 
 /**
- * pidgin_debug_ui_new:
- *
- * Initializes the GTK debug system.
- */
-PidginDebugUi *pidgin_debug_ui_new(void);
-
-/**
  * pidgin_debug_get_handle:
  *
  * Get the handle for the GTK debug system.
diff --git a/pidgin/pidgindebug.c b/pidgin/pidgindebug.c
--- a/pidgin/pidgindebug.c
+++ b/pidgin/pidgindebug.c
@@ -72,19 +72,6 @@ struct _PidginDebugWindow {
 static PidginDebugWindow *debug_win = NULL;
 static guint debug_enabled_timer = 0;
 
-struct _PidginDebugUi
-{
-	GObject parent;
-
-	/* Other members, including private data. */
-	guint debug_enabled_timer;
-};
-
-static void pidgin_debug_ui_interface_init(PurpleDebugUiInterface *iface);
-
-G_DEFINE_TYPE_WITH_CODE(PidginDebugUi, pidgin_debug_ui, G_TYPE_OBJECT,
-                        G_IMPLEMENT_INTERFACE(PURPLE_TYPE_DEBUG_UI,
-                                              pidgin_debug_ui_interface_init));
 G_DEFINE_TYPE(PidginDebugWindow, pidgin_debug_window, GTK_TYPE_WINDOW);
 
 static gint
@@ -811,11 +798,6 @@ pidgin_debug_g_log_handler(GLogLevelFlag
 	return G_LOG_WRITER_HANDLED;
 }
 
-static void
-pidgin_debug_ui_init(PidginDebugUi *self)
-{
-}
-
 void
 pidgin_debug_window_show(void)
 {
@@ -838,121 +820,6 @@ pidgin_debug_window_hide(void)
 	}
 }
 
-static void
-pidgin_debug_print(PurpleDebugUi *self,
-                   PurpleDebugLevel level, const char *category,
-                   const char *arg_s)
-{
-	GtkTextTag *level_tag;
-	const char *mdate;
-	time_t mtime;
-	GtkTextIter end;
-	gboolean scroll;
-
-	if (debug_win == NULL)
-		return;
-	if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled"))
-		return;
-
-	scroll = view_near_bottom(debug_win);
-	gtk_text_buffer_get_end_iter(debug_win->buffer, &end);
-	gtk_text_buffer_move_mark(debug_win->buffer, debug_win->start_mark,
-			&end);
-
-	level_tag = debug_win->tags.level[level];
-
-	mtime = time(NULL);
-	mdate = purple_utf8_strftime("(%H:%M:%S) ", localtime(&mtime));
-	gtk_text_buffer_insert_with_tags(
-			debug_win->buffer,
-			&end,
-			mdate,
-			-1,
-			level_tag,
-			debug_win->paused ? debug_win->tags.paused : NULL,
-			NULL);
-
-	if (category && *category) {
-		gtk_text_buffer_insert_with_tags(
-				debug_win->buffer,
-				&end,
-				category,
-				-1,
-				level_tag,
-				debug_win->tags.category,
-				debug_win->paused ? debug_win->tags.paused : NULL,
-				NULL);
-		gtk_text_buffer_insert_with_tags(
-				debug_win->buffer,
-				&end,
-				": ",
-				2,
-				level_tag,
-				debug_win->tags.category,
-				debug_win->paused ? debug_win->tags.paused : NULL,
-				NULL);
-	}
-
-	gtk_text_buffer_insert_with_tags(
-			debug_win->buffer,
-			&end,
-			arg_s,
-			-1,
-			level_tag,
-			debug_win->paused ? debug_win->tags.paused : NULL,
-			NULL);
-	gtk_text_buffer_insert_with_tags(
-			debug_win->buffer,
-			&end,
-			"\n",
-			1,
-			level_tag,
-			debug_win->paused ? debug_win->tags.paused : NULL,
-			NULL);
-
-	if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/filter") && debug_win->regex) {
-		/* Filter out any new messages. */
-		GtkTextIter start;
-
-		gtk_text_buffer_get_iter_at_mark(debug_win->buffer, &start,
-				debug_win->start_mark);
-		gtk_text_buffer_get_iter_at_mark(debug_win->buffer, &end,
-				debug_win->end_mark);
-
-		do_regex(debug_win, &start, &end);
-	}
-
-	if (scroll) {
-		gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(debug_win->textview),
-				debug_win->end_mark, 0, TRUE, 0, 1);
-	}
-}
-
-static gboolean
-pidgin_debug_is_enabled(PurpleDebugUi *self, PurpleDebugLevel level, const char *category)
-{
-	return (debug_win != NULL &&
-			purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled"));
-}
-
-static void
-pidgin_debug_ui_interface_init(PurpleDebugUiInterface *iface)
-{
-	iface->print = pidgin_debug_print;
-	iface->is_enabled = pidgin_debug_is_enabled;
-}
-
-static void
-pidgin_debug_ui_class_init(PidginDebugUiClass *klass)
-{
-}
-
-PidginDebugUi *
-pidgin_debug_ui_new(void)
-{
-	return g_object_new(PIDGIN_TYPE_DEBUG_UI, NULL);
-}
-
 void
 pidgin_debug_init_handler(void)
 {
