qulogic/pidgin

The start of the libpurple option group

2017-10-05, Gary Kramlich
afb1c8302e49
Parents da7cb2e388ee
Children 60c745a9e06d
The start of the libpurple option group
--- a/finch/libfinch.c Thu Oct 05 21:51:59 2017 -0500
+++ b/finch/libfinch.c Thu Oct 05 22:23:56 2017 -0500
@@ -29,6 +29,7 @@
#include "glibcompat.h"
#include "log.h"
#include "notify.h"
+#include "options.h"
#include "plugins.h"
#include "protocol.h"
#include "pounce.h"
@@ -146,9 +147,6 @@
{"config", 'c', 0,
G_OPTION_ARG_FILENAME, &opt_config_dir_arg,
_("use DIR for config files"), _("DIR")},
- {"debug", 'd', 0,
- G_OPTION_ARG_NONE, &debug_enabled,
- _("print debugging messages to stderr"), NULL},
{"nologin", 'n', 0,
G_OPTION_ARG_NONE, &opt_nologin,
_("don't automatically login"), NULL},
@@ -170,6 +168,7 @@
g_option_context_set_summary(context, DISPLAY_VERSION);
g_option_context_add_main_entries(context, option_entries, PACKAGE);
+ g_option_context_add_group(context, purple_get_option_group());
g_option_context_add_group(context, gplugin_get_option_group());
#ifdef G_OS_WIN32
--- a/libpurple/meson.build Thu Oct 05 21:51:59 2017 -0500
+++ b/libpurple/meson.build Thu Oct 05 22:23:56 2017 -0500
@@ -39,6 +39,7 @@
'nat-pmp.c',
'network.c',
'notify.c',
+ 'options.c',
'plugins.c',
'pluginpref.c',
'pounce.c',
@@ -118,6 +119,7 @@
'nat-pmp.h',
'network.h',
'notify.h',
+ 'options.h',
'plugins.h',
'pluginpref.h',
'pounce.h',
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/options.c Thu Oct 05 22:23:56 2017 -0500
@@ -0,0 +1,68 @@
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#include "internal.h"
+
+#include "options.h"
+
+/******************************************************************************
+ * Callbacks
+ *****************************************************************************/
+static gboolean
+debug_opt_arg_func(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);
+ }
+
+ return TRUE;
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+GOptionGroup *
+purple_get_option_group(void) {
+ GOptionGroup *group = NULL;
+ GOptionEntry entries[] = {
+ {
+ "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
+ G_OPTION_ARG_CALLBACK, &debug_opt_arg_func,
+ _("print debugging messages to stdout"),
+ _("[colored]")
+ },
+ };
+
+ group = g_option_group_new(
+ "libpurple",
+ _("LibPurple options"),
+ _("Show LibPurple Options"),
+ NULL,
+ NULL
+ );
+
+ g_option_group_add_entries(group, entries);
+
+ return group;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/options.h Thu Oct 05 22:23:56 2017 -0500
@@ -0,0 +1,33 @@
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#ifndef PURPLE_OPTIONS_H
+#define PURPLE_OPTIONS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+GOptionGroup *purple_get_option_group(void);
+
+G_END_DECLS
+
+#endif /* PURPLE_OPTIONS_H */
--- a/pidgin/libpidgin.c Thu Oct 05 21:51:59 2017 -0500
+++ b/pidgin/libpidgin.c Thu Oct 05 22:23:56 2017 -0500
@@ -33,6 +33,7 @@
#include "log.h"
#include "network.h"
#include "notify.h"
+#include "options.h"
#include "prefs.h"
#include "protocol.h"
#include "pounce.h"
@@ -375,25 +376,10 @@
purple_blist_set_visible(TRUE);
}
-static gboolean debug_colored = FALSE;
-static gboolean debug_enabled = FALSE;
static gboolean opt_login = FALSE;
static gchar *opt_login_arg = NULL;
static gboolean
-debug_opt_arg_func(const gchar *option_name, const gchar *value,
- gpointer data, GError **error)
-{
- debug_enabled = TRUE;
-
- if (purple_strequal(value, "colored")) {
- debug_colored = TRUE;
- }
-
- return TRUE;
-}
-
-static gboolean
login_opt_arg_func(const gchar *option_name, const gchar *value,
gpointer data, GError **error)
{
@@ -441,10 +427,6 @@
{"config", 'c', 0,
G_OPTION_ARG_FILENAME, &opt_config_dir_arg,
_("use DIR for config files"), _("DIR")},
- {"debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
- G_OPTION_ARG_CALLBACK, &debug_opt_arg_func,
- _("print debugging messages to stdout"),
- _("[colored]")},
{"force-online", 'f', 0,
G_OPTION_ARG_NONE, &opt_force_online,
_("force online, regardless of network status"), NULL},
@@ -468,11 +450,8 @@
{NULL}
};
- debug_colored = FALSE;
#ifdef DEBUG
- debug_enabled = TRUE;
-#else
- debug_enabled = FALSE;
+ purple_debug_set_enabled(TRUE);
#endif
#ifdef ENABLE_NLS
@@ -594,8 +573,9 @@
g_free(summary);
g_option_context_add_main_entries(context, option_entries, PACKAGE);
+ g_option_context_add_group(context, purple_get_option_group());
+ g_option_context_add_group(context, gplugin_get_option_group());
g_option_context_add_group(context, gtk_get_option_group(TRUE));
- g_option_context_add_group(context, gplugin_get_option_group());
#ifdef G_OS_WIN32
/* Handle Unicode filenames on Windows. See GOptionContext docs. */
@@ -647,11 +627,6 @@
* Fire up this baby.
*/
- if (g_getenv("PIDGIN_DEBUG_COLORED") != NULL)
- debug_colored = TRUE;
- purple_debug_set_enabled(debug_enabled);
- purple_debug_set_colored(debug_colored);
-
app = G_APPLICATION(gtk_application_new("im.pidgin.Pidgin",
G_APPLICATION_NON_UNIQUE));