3 * Pidgin is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
27 #include "pidgindebugplugininfo.h"
29 struct _PidginDebugPluginInfo
{
35 struct _PidginDebugPluginInfoClass
{
36 GtkDialogClass parent
;
42 * SECTION:pidgindebugplugininfo
43 * @Title: Debug Plugin Info
44 * @Short_description: A widget that lists verbose plugin info
46 * When helping users troubleshoot issues with Pidgin we often need to know
47 * what plugins that have installed/running. This widget gives them an easy
48 * way to get that info to us.
52 GtkTextBuffer
*buffer
;
54 } PidginDebugPluginInfoPrivate
;
56 G_DEFINE_TYPE_WITH_PRIVATE(PidginDebugPluginInfo
, pidgin_debug_plugin_info
, GTK_TYPE_DIALOG
)
58 /******************************************************************************
60 *****************************************************************************/
62 purple_debug_plugin_compare_plugin_id(gconstpointer a
, gconstpointer b
) {
64 gplugin_plugin_info_get_id(GPLUGIN_PLUGIN_INFO(
65 purple_plugin_get_info(PURPLE_PLUGIN((gpointer
)a
)))),
66 gplugin_plugin_info_get_id(GPLUGIN_PLUGIN_INFO(
67 purple_plugin_get_info(PURPLE_PLUGIN((gpointer
)b
)))));
71 pidgin_debug_plugin_info_build_html(void) {
72 GString
*str
= g_string_new(NULL
);
73 GList
*plugins
= NULL
, *l
= NULL
;
75 g_string_append_printf(str
, "<h2>%s</h2><dl>", _("Plugin Information"));
77 plugins
= g_list_sort(
78 purple_plugins_find_all(),
79 purple_debug_plugin_compare_plugin_id
82 for(l
= plugins
; l
!= NULL
; l
= l
->next
) {
83 PurplePlugin
*plugin
= PURPLE_PLUGIN(l
->data
);
84 PurplePluginInfo
*info
= purple_plugin_get_info(plugin
);
85 PurplePluginExtraCb extra_cb
;
86 gchar
*name
= g_markup_escape_text(
87 gplugin_plugin_info_get_name(GPLUGIN_PLUGIN_INFO(info
)),
89 gchar
*version
, *license
, *website
, *id
;
90 gchar
*authors
= NULL
, *extra
= NULL
;
91 const gchar
*error_message
= NULL
;
99 "license-id", &license
,
102 "extra-cb", &extra_cb
,
106 if(authorsv
!= NULL
) {
107 gchar
*authorstmp
= g_strjoinv(", ", (gchar
**)authorsv
);
108 g_strfreev(authorsv
);
110 authors
= g_markup_escape_text(authorstmp
, -1);
114 if(extra_cb
!= NULL
) {
115 extra
= extra_cb(plugin
);
118 error_message
= purple_plugin_info_get_error(info
);
120 loaded
= purple_plugin_is_loaded(plugin
);
122 g_string_append_printf(str
, "<dt>%s</dt><dd>", name
);
125 /* this is not translated as it's meant for debugging */
126 g_string_append_printf(
128 "<b>Authors:</b> %s<br/>"
129 "<b>Version:</b> %s<br/>"
130 "<b>License:</b> %s<br/>"
131 "<b>Website:</b> %s<br/>"
133 "<b>Extra:</b> %s<br/>"
134 "<b>Errors:</b> %s</br>"
136 authors
? authors
: "",
137 version
? version
: "",
138 license
? license
: "",
139 website
? website
: "",
142 error_message
? error_message
: "",
143 loaded
? "Yes" : "No"
146 g_clear_pointer(&authors
, g_free
);
151 g_clear_pointer(&extra
, g_free
);
153 g_string_append(str
, "</dd>");
156 g_list_free(plugins
);
158 g_string_append(str
, "</dl>");
160 return g_string_free(str
, FALSE
);
163 /******************************************************************************
165 *****************************************************************************/
167 pidgin_debug_plugin_info_init(PidginDebugPluginInfo
*debug_plugin_info
) {
168 gtk_widget_init_template(GTK_WIDGET(debug_plugin_info
));
172 pidgin_debug_plugin_info_class_init(PidginDebugPluginInfoClass
*klass
) {
173 GtkWidgetClass
*widget_class
= GTK_WIDGET_CLASS(klass
);
175 gtk_widget_class_set_template_from_resource(
177 "/im/pidgin/Pidgin/Debug/plugininfo.ui"
180 gtk_widget_class_bind_template_child_private(widget_class
, PidginDebugPluginInfo
, buffer
);
181 gtk_widget_class_bind_template_child_private(widget_class
, PidginDebugPluginInfo
, view
);
184 /******************************************************************************
186 *****************************************************************************/
189 * pidgin_debug_plugin_info_new:
191 * Creates a new #PidginDebugPluginInfo that provides the user with an easy way
192 * to share information about their plugin state for debugging purposes.
194 * Returns: (transfer full): The new #PidginDebugPluginInfo instance.
196 GtkWidget
*pidgin_debug_plugin_info_new(void) {
197 return GTK_WIDGET(g_object_new(
198 PIDGIN_TYPE_DEBUG_PLUGIN_INFO
,
204 pidgin_debug_plugin_info_show(void) {
205 PidginDebugPluginInfoPrivate
*priv
= NULL
;
206 GtkWidget
*win
= NULL
;
209 win
= pidgin_debug_plugin_info_new();
210 priv
= pidgin_debug_plugin_info_get_instance_private(PIDGIN_DEBUG_PLUGIN_INFO(win
));
212 text
= pidgin_debug_plugin_info_build_html();
213 talkatu_markup_set_html(TALKATU_BUFFER(priv
->buffer
), text
, -1);
216 gtk_widget_show_all(win
);
217 gtk_window_present(GTK_WINDOW(win
));