Move debug command-line option to the UIs
This is not really a core option, and even has a different meaning in Finch.
Testing Done:
Run `finch3 -d` and see debug window open by default; run `pidgin3` and see debug output printed.
Reviewed at https://reviews.imfreedom.org/r/1080/
--- a/ChangeLog.API Tue Oct 19 02:57:01 2021 -0500
+++ b/ChangeLog.API Tue Oct 19 03:00:48 2021 -0500
@@ -390,6 +390,9 @@
* purple_date_format_long, use g_date_time_format instead.
* purple_date_format_short, use g_date_time_format instead.
+ * purple_debug_is_enabled + * purple_debug_set_colored + * purple_debug_set_enabled * purple_dnsquery_a_account
* purple_event_loop_{get|set}_ui_ops. Manually drive the GLib
event loop yourself. See GLib Main Event Loop docs.
--- a/finch/gntdebug.c Tue Oct 19 02:57:01 2021 -0500
+++ b/finch/gntdebug.c Tue Oct 19 03:00:48 2021 -0500
@@ -317,13 +317,6 @@
gnt_widget_show(debug.window);
-start_with_debugwin(gpointer null)
- finch_debug_window_show();
finch_debug_init_handler(void)
@@ -334,19 +327,13 @@
g_set_print_handler(print_stderr); /* Redirect the debug messages to stderr */
- if (!purple_debug_is_enabled()) {
- handle_fprintf_stderr(FALSE);
+ handle_fprintf_stderr(FALSE); purple_prefs_add_none(PREF_ROOT);
purple_prefs_add_string(PREF_ROOT "/filter", "");
purple_prefs_add_none(PREF_ROOT "/size");
purple_prefs_add_int(PREF_ROOT "/size/width", 60);
purple_prefs_add_int(PREF_ROOT "/size/height", 15);
- if (purple_debug_is_enabled()) {
- g_timeout_add(0, start_with_debugwin, NULL);
--- a/finch/libfinch.c Tue Oct 19 02:57:01 2021 -0500
+++ b/finch/libfinch.c Tue Oct 19 03:00:48 2021 -0500
@@ -65,14 +65,21 @@
+start_with_debugwin(gpointer null) + finch_debug_window_show(); init_libpurple(int argc, char **argv)
gboolean opt_nologin = FALSE;
gboolean opt_version = FALSE;
+ gboolean opt_debug = FALSE; char *opt_config_dir_arg = NULL;
- gboolean debug_enabled = FALSE;
const gchar *plugin_path = NULL;
@@ -82,6 +89,9 @@
G_OPTION_ARG_FILENAME, &opt_config_dir_arg,
_("use DIR for config files"), _("DIR")},
+ G_OPTION_ARG_NONE, &opt_debug, + _("open debug window on startup"), NULL}, G_OPTION_ARG_NONE, &opt_nologin,
_("don't automatically login"), NULL},
@@ -152,7 +162,9 @@
/* We don't want debug-messages to show up and corrupt the display */
finch_debug_init_handler();
- purple_debug_set_enabled(debug_enabled);
+ g_timeout_add(0, start_with_debugwin, NULL); purple_core_set_ui_ops(gnt_core_get_ui_ops());
purple_idle_set_ui_ops(finch_idle_get_ui_ops());
--- a/libpurple/debug.c Tue Oct 19 02:57:01 2021 -0500
+++ b/libpurple/debug.c Tue Oct 19 03:00:48 2021 -0500
@@ -24,18 +24,6 @@
- * This determines whether debug info should be written to the
- * It doesn't make sense to make this a normal Purple preference
- * because it's a command line option. This will always be FALSE,
- * unless the user explicitly started the UI with the -d flag.
- * It doesn't matter what this value was the last time Purple was
- * started, so it doesn't make sense to save it in prefs.
-static gboolean debug_enabled = FALSE;
* These determine whether verbose or unsafe debugging are desired. I
* don't want to make these purple preferences because their values should
* not be remembered across instances of the UI.
@@ -43,8 +31,6 @@
static gboolean debug_verbose = FALSE;
static gboolean debug_unsafe = FALSE;
-static gboolean debug_colored = FALSE;
purple_debug_vargs(PurpleDebugLevel level, const gchar *category,
const gchar *format, va_list args)
@@ -153,16 +139,6 @@
-purple_debug_set_enabled(gboolean enabled) {
- debug_enabled = enabled;
-purple_debug_is_enabled() {
purple_debug_is_verbose() {
@@ -184,11 +160,6 @@
-purple_debug_set_colored(gboolean colored) {
- debug_colored = colored;
purple_debug_init(void) {
/* Read environment variables once per init */
if(g_getenv("PURPLE_UNSAFE_DEBUG")) {
--- a/libpurple/debug.h Tue Oct 19 02:57:01 2021 -0500
+++ b/libpurple/debug.h Tue Oct 19 03:00:48 2021 -0500
@@ -151,23 +151,6 @@
void purple_debug_fatal(const gchar *category, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
- * purple_debug_set_enabled:
- * @enabled: %TRUE to enable debug output or %FALSE to disable it.
- * Enable or disable printing debug output to the console.
-void purple_debug_set_enabled(gboolean enabled);
- * purple_debug_is_enabled:
- * Check if console debug output is enabled.
- * Returns: %TRUE if debugging is enabled, %FALSE if it is not.
-gboolean purple_debug_is_enabled(void);
* purple_debug_set_verbose:
* @verbose: %TRUE to enable verbose debugging or %FALSE to disable it.
@@ -209,14 +192,6 @@
gboolean purple_debug_is_unsafe(void);
- * purple_debug_set_colored:
- * @colored: %TRUE to enable colored output, %FALSE to disable it.
- * Enable or disable colored output for bash console.
-void purple_debug_set_colored(gboolean colored);
/******************************************************************************
*****************************************************************************/
--- a/libpurple/purpleoptions.c Tue Oct 19 02:57:01 2021 -0500
+++ b/libpurple/purpleoptions.c Tue Oct 19 03:00:48 2021 -0500
@@ -32,19 +32,6 @@
*****************************************************************************/
-purple_options_debug_cb(const gchar *option_name, const gchar *value,
- gpointer data, GError **error)
- purple_debug_set_enabled(TRUE);
- if (purple_strequal(value, "colored")) {
- purple_debug_set_colored(TRUE);
purple_options_force_online_cb(const gchar *option_name, const gchar *value,
gpointer data, GError **error)
@@ -61,11 +48,6 @@
GOptionGroup *group = NULL;
GOptionEntry entries[] = {
- "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
- G_OPTION_ARG_CALLBACK, &purple_options_debug_cb,
- _("print debugging messages to stdout"),
"force-online", 'f', G_OPTION_FLAG_NO_ARG,
G_OPTION_ARG_CALLBACK, &purple_options_force_online_cb,
_("force online, regardless of network status"),
--- a/libpurple/tests/test_ui.c Tue Oct 19 02:57:01 2021 -0500
+++ b/libpurple/tests/test_ui.c Tue Oct 19 03:00:48 2021 -0500
@@ -106,9 +106,6 @@
/* set the magic PURPLE_PLUGINS_SKIP environment variable */
g_setenv("PURPLE_PLUGINS_SKIP", "1", TRUE);
- /* We do not want any debugging for now to keep the noise to a minimum. */
- purple_debug_set_enabled(FALSE);
/* Set the core-uiops, which is used to
* - initialize the ui specific preferences.
* - initialize the debug ui.
--- a/pidgin/libpidgin.c Tue Oct 19 02:57:01 2021 -0500
+++ b/pidgin/libpidgin.c Tue Oct 19 03:00:48 2021 -0500
@@ -432,10 +432,6 @@
- purple_debug_set_enabled(TRUE);
bindtextdomain(PACKAGE, PURPLE_LOCALEDIR);
bind_textdomain_codeset(PACKAGE, "UTF-8");
--- a/pidgin/pidginapplication.c Tue Oct 19 02:57:01 2021 -0500
+++ b/pidgin/pidginapplication.c Tue Oct 19 03:00:48 2021 -0500
@@ -55,6 +55,20 @@
/******************************************************************************
*****************************************************************************/
+pidgin_options_debug_cb(G_GNUC_UNUSED const gchar *option_name, + G_GNUC_UNUSED const gchar *value, + G_GNUC_UNUSED gpointer data, + G_GNUC_UNUSED GError **error) + pidgin_debug_set_print_enabled(TRUE); +/****************************************************************************** + *****************************************************************************/ static gchar *opt_config_dir_arg = NULL;
static gboolean opt_nologin = FALSE;
@@ -63,6 +77,10 @@
"config", 'c', 0, G_OPTION_ARG_FILENAME, &opt_config_dir_arg,
N_("use DIR for config files"), N_("DIR")
+ "debug", 'd', 0, G_OPTION_ARG_CALLBACK, + &pidgin_options_debug_cb, + N_("print debugging messages to stdout"), NULL "nologin", 'n', 0, G_OPTION_ARG_NONE, &opt_nologin,
N_("don't automatically login"), NULL
@@ -482,6 +500,9 @@
pidgin_debug_init_handler();
+ pidgin_debug_set_print_enabled(TRUE); provider = gtk_css_provider_new();
--- a/pidgin/pidgindebug.c Tue Oct 19 02:57:01 2021 -0500
+++ b/pidgin/pidgindebug.c Tue Oct 19 03:00:48 2021 -0500
@@ -69,6 +69,7 @@
+static gboolean debug_print_enabled = FALSE; static PidginDebugWindow *debug_win = NULL;
static guint debug_enabled_timer = 0;
@@ -696,7 +697,11 @@
!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled")) {
- return G_LOG_WRITER_UNHANDLED;
+ if (debug_print_enabled) { + return g_log_writer_default(log_level, fields, n_fields, user_data); + return G_LOG_WRITER_UNHANDLED; for (i = 0; i < n_fields; i++) {
@@ -795,7 +800,11 @@
debug_win->end_mark, 0, TRUE, 0, 1);
- return G_LOG_WRITER_HANDLED;
+ if (debug_print_enabled) { + return g_log_writer_default(log_level, fields, n_fields, user_data); + return G_LOG_WRITER_HANDLED; @@ -827,6 +836,12 @@
+pidgin_debug_set_print_enabled(gboolean enable) + debug_print_enabled = enable; /* Debug window preferences. */
--- a/pidgin/pidgindebug.h Tue Oct 19 02:57:01 2021 -0500
+++ b/pidgin/pidgindebug.h Tue Oct 19 03:00:48 2021 -0500
@@ -46,6 +46,17 @@
void pidgin_debug_init_handler(void);
+ * pidgin_debug_set_print_enabled: + * Set whether the debug logging messages are sent the default GLib logging handler. + * This will print to the console, if Pidgin is run from there. +void pidgin_debug_set_print_enabled(gboolean enable); * Perform necessary initializations.