summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Kramlich <grim@reaperworld.com>2019-02-21 22:27:53 -0600
committerGary Kramlich <grim@reaperworld.com>2019-02-21 22:27:53 -0600
commite173df1375ce261f170f853f2ae5d41153dc6fe7 (patch)
tree749d77abce7e79b77d8c75bea7515690f5e90598
parent14a00ed172f773dc4b7aeaf95664a3e28a4f8a65 (diff)
downloadpidgin-e173df1375ce261f170f853f2ae5d41153dc6fe7.tar.gz
Start of moving the plugin info dialog to talkatu. Still need to handle error messages and their formatting
-rw-r--r--pidgin/gtkblist.c3
-rw-r--r--pidgin/gtkdialogs.c20
-rw-r--r--pidgin/meson.build2
-rw-r--r--pidgin/pidgindebugplugininfo.c192
-rw-r--r--pidgin/pidgindebugplugininfo.h64
-rw-r--r--pidgin/resources/Debug/plugininfo.ui84
-rw-r--r--pidgin/resources/pidgin.gresource.xml1
7 files changed, 354 insertions, 12 deletions
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 859ed5ecf7..9c135b979f 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -60,6 +60,7 @@
#include "pidgin/minidialog.h"
#include "pidgin/pidginabout.h"
#include "pidgin/pidgindebug.h"
+#include "pidgin/pidgindebugplugininfo.h"
#include "pidgin/pidgintooltip.h"
#include <gdk/gdkkeysyms.h>
@@ -3641,7 +3642,7 @@ static const GtkActionEntry blist_menu_entries[] = {
{ "HelpMenu", NULL, N_("_Help"), NULL, NULL, NULL },
{ "OnlineHelp", GTK_STOCK_HELP, N_("Online _Help"), "F1", NULL, gtk_blist_show_onlinehelp_cb },
{ "DebugWindow", NULL, N_("_Debug Window"), NULL, NULL, toggle_debug },
- { "PluginInformation", NULL, N_("_Plugin Information"), NULL, NULL, pidgin_dialogs_plugins_info },
+ { "PluginInformation", NULL, N_("_Plugin Information"), NULL, NULL, pidgin_debug_plugin_info_show },
{ "About", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL, G_CALLBACK(_pidgin_about_cb) },
};
diff --git a/pidgin/gtkdialogs.c b/pidgin/gtkdialogs.c
index 296be4aadc..9102feb9c4 100644
--- a/pidgin/gtkdialogs.c
+++ b/pidgin/gtkdialogs.c
@@ -20,6 +20,8 @@
*/
#define _PIDGIN_GTKDIALOGS_C_
+#include <talkatu.h>
+
#include "internal.h"
#include "pidgin.h"
#include "package_revision.h"
@@ -39,7 +41,6 @@
#include "gtkdialogs.h"
#include "gtklog.h"
#include "gtkutils.h"
-#include "gtkwebview.h"
#include "pidginstock.h"
#ifdef USE_GSTREAMER
@@ -113,8 +114,9 @@ pidgin_logo_versionize(GdkPixbuf **original, GtkWidget *widget) {
static GtkWidget *
pidgin_build_help_dialog(const char *title, const char *role, GString *string)
{
- GtkWidget *win, *vbox, *frame, *logo, *webview, *button;
+ GtkWidget *win, *vbox, *logo, *view, *button;
GdkPixbuf *pixbuf;
+ GtkTextBuffer *buffer;
AtkObject *obj;
char *filename, *tmp;
@@ -128,10 +130,6 @@ pidgin_build_help_dialog(const char *title, const char *role, GString *string)
pixbuf = pidgin_pixbuf_new_from_file(filename);
g_free(filename);
-#if 0 /* Don't versionize the logo when the logo has the version in it */
- pidgin_logo_versionize(&pixbuf, logo);
-#endif
-
/* Insert the logo */
logo = gtk_image_new_from_pixbuf(pixbuf);
if (pixbuf)
@@ -142,11 +140,11 @@ pidgin_build_help_dialog(const char *title, const char *role, GString *string)
g_free(tmp);
gtk_box_pack_start(GTK_BOX(vbox), logo, FALSE, FALSE, 0);
- frame = pidgin_create_webview(FALSE, &webview, NULL);
- pidgin_webview_set_format_functions(PIDGIN_WEBVIEW(webview), PIDGIN_WEBVIEW_ALL ^ PIDGIN_WEBVIEW_SMILEY);
- gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
+ buffer = talkatu_html_buffer_new();
+ talkatu_markup_append_html(TALKATU_BUFFER(buffer), string->str, -1);
- pidgin_webview_append_html(PIDGIN_WEBVIEW(webview), string->str);
+ view = talkatu_view_new_with_buffer(buffer);
+ gtk_box_pack_start(GTK_BOX(vbox), view, TRUE, TRUE, 0);
button = pidgin_dialog_add_button(GTK_DIALOG(win), _("_Close"),
G_CALLBACK(destroy_win), win);
@@ -244,7 +242,7 @@ void pidgin_dialogs_plugins_info(void)
}
g_list_free(plugins);
- g_string_append(str, "</dl>");
+ g_string_append(str, "</dl><br/>");
plugins_info = pidgin_build_help_dialog(title, "plugins_info", str);
g_signal_connect(G_OBJECT(plugins_info), "destroy",
diff --git a/pidgin/meson.build b/pidgin/meson.build
index 83780486f6..72fd599f04 100644
--- a/pidgin/meson.build
+++ b/pidgin/meson.build
@@ -43,6 +43,7 @@ libpidgin_SOURCES = [
'minidialog.c',
'pidginabout.c',
'pidgindebug.c',
+ 'pidgindebugplugininfo.c',
'pidgintalkatu.c',
'pidgintooltip.c',
]
@@ -93,6 +94,7 @@ libpidgin_headers = [
'minidialog.h',
'pidginabout.h',
'pidgindebug.h',
+ 'pidgindebugplugininfo.h',
'pidgintalkatu.h',
'pidgintooltip.h',
'pidgin.h',
diff --git a/pidgin/pidgindebugplugininfo.c b/pidgin/pidgindebugplugininfo.c
new file mode 100644
index 0000000000..8762010467
--- /dev/null
+++ b/pidgin/pidgindebugplugininfo.c
@@ -0,0 +1,192 @@
+/* pidgin
+ *
+ * Pidgin 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 <talkatu.h>
+
+#include "internal.h"
+#include "plugins.h"
+
+#include "pidgindebugplugininfo.h"
+
+/**
+ * SECTION:pidgindebugplugininfo
+ * @Title: Debug Plugin Info
+ * @Short_description: A widget that lists verbose plugin info
+ *
+ * When helping users troubleshoot issues with Pidgin we often need to know
+ * what plugins that have installed/running. This widget gives them an easy
+ * way to get that info to us.
+ */
+
+typedef struct {
+ GtkTextBuffer *buffer;
+ GtkWidget *view;
+} PidginDebugPluginInfoPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE(PidginDebugPluginInfo, pidgin_debug_plugin_info, GTK_TYPE_DIALOG)
+
+/******************************************************************************
+ * Helpers
+ *****************************************************************************/
+static gchar *
+pidgin_debug_plugin_info_build_html(void) {
+ GString *str = g_string_new(NULL);
+ GList *plugins = NULL, *l = NULL;
+ GError *error = NULL;
+ gchar *ret = NULL;
+
+ g_string_append_printf(str, "<h2>%s</h2><dl>", _("Plugin Information"));
+
+ plugins = purple_plugins_find_all();
+ for(l = plugins; l != NULL; l = l->next) {
+ PurplePlugin *plugin = PURPLE_PLUGIN(l->data);
+ PurplePluginInfo *info = purple_plugin_get_info(plugin);
+ PurplePluginExtraCb extra_cb;
+ gchar *name = g_markup_escape_text(purple_plugin_info_get_name(info), -1);
+ gchar *version, *license, *website, *id;
+ gchar *authors = NULL, *extra = NULL;
+ const gchar *error_message = NULL;
+ const gchar * const *authorsv;
+ gboolean loaded;
+
+ g_object_get(
+ G_OBJECT(info),
+ "authors", &authorsv,
+ "version", &version,
+ "license-id", &license,
+ "website", &website,
+ "id", &id,
+ "extra-cb", &extra_cb,
+ NULL
+ );
+
+ if(authorsv != NULL) {
+ gchar *authorstmp = g_strjoinv(", ", (gchar **)authorsv);
+ g_strfreev(authorsv);
+
+ authors = g_markup_escape_text(authorstmp, -1);
+ g_free(authorstmp);
+ }
+
+ if(extra_cb != NULL) {
+ extra = extra_cb(plugin);
+ }
+
+ error_message = purple_plugin_info_get_error(info);
+
+ loaded = purple_plugin_is_loaded(plugin);
+
+ g_string_append_printf(str, "<dt>%s</dt><dd>", name);
+ g_free(name);
+
+ /* this is not translated as it's meant for debugging */
+ g_string_append_printf(
+ str,
+ "<b>Authors:</b> %s<br/>"
+ "<b>Version:</b> %s<br/>"
+ "<b>License:</b> %s<br/>"
+ "<b>Website:</b> %s<br/>"
+ "<b>ID:</b> %s<br/>"
+ "<b>Extra:</b> %s<br/>"
+ "<b>Errors:</b> %s</br>"
+ "<b>Loaded:</b> %s",
+ authors ? authors : "",
+ version ? version : "",
+ license ? license : "",
+ website ? website : "",
+ id ? id : "",
+ extra ? extra : "",
+ error_message ? error_message : "",
+ loaded ? "Yes" : "No"
+ );
+
+ g_free(authors);
+ g_free(version);
+ g_free(license);
+ g_free(website);
+ g_free(id);
+ g_free(extra);
+
+ g_string_append(str, "</dd>");
+ }
+
+ g_list_free(plugins);
+
+ g_string_append(str, "</dl>");
+
+ return g_string_free(str, FALSE);
+}
+
+/******************************************************************************
+ * GObject Stuff
+ *****************************************************************************/
+static void
+pidgin_debug_plugin_info_init(PidginDebugPluginInfo *debug_plugin_info) {
+ gtk_widget_init_template(GTK_WIDGET(debug_plugin_info));
+}
+
+static void
+pidgin_debug_plugin_info_class_init(PidginDebugPluginInfoClass *klass) {
+ gtk_widget_class_set_template_from_resource(
+ GTK_WIDGET_CLASS(klass),
+ "/im/pidgin/Pidgin/Debug/plugininfo.ui"
+ );
+
+ gtk_widget_class_bind_template_child_private(klass, PidginDebugPluginInfo, buffer);
+ gtk_widget_class_bind_template_child_private(klass, PidginDebugPluginInfo, view);
+}
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+
+/**
+ * pidgin_debug_plugin_info_new:
+ *
+ * Creates a new #PidginDebugPluginInfo that provides the user with an easy way
+ * to share information about their plugin state for debugging purposes.
+ *
+ * Returns: (transfer full): The new #PidginDebugPluginInfo instance.
+ */
+GtkWidget *pidgin_debug_plugin_info_new(void) {
+ return GTK_WIDGET(g_object_new(
+ PIDGIN_TYPE_DEBUG_PLUGIN_INFO,
+ NULL
+ ));
+}
+
+void
+pidgin_debug_plugin_info_show(void) {
+ PidginDebugPluginInfoPrivate *priv = NULL;
+ GtkWidget *win = NULL;
+ gchar *text = NULL;
+
+ win = pidgin_debug_plugin_info_new();
+ priv = pidgin_debug_plugin_info_get_instance_private(PIDGIN_DEBUG_PLUGIN_INFO(win));
+
+ text = pidgin_debug_plugin_info_build_html();
+ g_warning("text: '%s'", text);
+ talkatu_markup_set_html(TALKATU_BUFFER(priv->buffer), text, -1);
+ g_free(text);
+
+ gtk_widget_show_all(win);
+ gtk_window_present(GTK_WINDOW(win));
+}
diff --git a/pidgin/pidgindebugplugininfo.h b/pidgin/pidgindebugplugininfo.h
new file mode 100644
index 0000000000..507dddcffd
--- /dev/null
+++ b/pidgin/pidgindebugplugininfo.h
@@ -0,0 +1,64 @@
+/* pidgin
+ *
+ * Pidgin 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 PIDGIN_DEBUG_PLUGIN_INFO_H
+#define PIDGIN_DEBUG_PLUGIN_INFO_H
+
+#include <gtk/gtk.h>
+
+#define PIDGIN_TYPE_DEBUG_PLUGIN_INFO (pidgin_debug_plugin_info_get_type())
+#define PIDGIN_DEBUG_PLUGIN_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PIDGIN_TYPE_DEBUG_PLUGIN_INFO, PidginDebugPluginInfo))
+#define PIDGIN_DEBUG_PLUGIN_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PIDGIN_TYPE_DEBUG_PLUGIN_INFO, PidginDebugPluginInfoClass))
+#define PIDGIN_IS_DEBUG_PLUGIN_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PIDGIN_TYPE_DEBUG_PLUGIN_INFO))
+#define PIDGIN_IS_DEBUG_PLUGIN_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PIDGIN_TYPE_DEBUG_PLUGIN_INFO))
+#define PIDGIN_DEBUG_PLUGIN_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PIDGIN_TYPE_DEBUG_PLUGIN_INFO, PidginDebugPluginInfoClass))
+
+typedef struct _PidginDebugPluginInfo PidginDebugPluginInfo;
+typedef struct _PidginDebugPluginInfoClass PidginDebugPluginInfoClass;
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+struct _PidginDebugPluginInfo {
+ GtkDialog parent;
+
+ gpointer reserved[4];
+};
+
+struct _PidginDebugPluginInfoClass {
+ GtkDialogClass parent;
+
+ gpointer reserved[4];
+};
+
+G_BEGIN_DECLS
+
+GType pidgin_debug_plugin_info_get_type(void);
+
+GtkWidget *pidgin_debug_plugin_info_new(void);
+
+void pidgin_debug_plugin_info_show(void);
+
+G_END_DECLS
+
+#endif /* PIDGIN_DEBUG_PLUGIN_INFO_H */
diff --git a/pidgin/resources/Debug/plugininfo.ui b/pidgin/resources/Debug/plugininfo.ui
new file mode 100644
index 0000000000..d8deb3e616
--- /dev/null
+++ b/pidgin/resources/Debug/plugininfo.ui
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="Talkatu" version="0.0"/>
+ <requires lib="gtk+" version="3.10"/>
+ <!-- interface-local-resource-path ../ -->
+ <object class="TalkatuHtmlBuffer" id="buffer"/>
+ <template class="PidginDebugPluginInfo" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Pidgin Plugin Information</property>
+ <property name="role">plugins_info</property>
+ <property name="default_width">475</property>
+ <property name="default_height">450</property>
+ <property name="type_hint">dialog</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton">
+ <property name="label" translatable="yes">Close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="gtk_widget_destroy" object="PidginDebugPluginInfo" swapped="yes"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="logo">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="resource">/im/pidgin/Pidgin/logo.png</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="TalkatuView" id="view">
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="editable">False</property>
+ <property name="buffer">buffer</property>
+ <property name="send_binding"/>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/pidgin/resources/pidgin.gresource.xml b/pidgin/resources/pidgin.gresource.xml
index 95aa999877..0ec0090f89 100644
--- a/pidgin/resources/pidgin.gresource.xml
+++ b/pidgin/resources/pidgin.gresource.xml
@@ -7,6 +7,7 @@
<file compressed="true">About/credits.json</file>
<file compressed="true">Debug/debug.ui</file>
<file compressed="true">Debug/filter-popover.ui</file>
+ <file compressed="true">Debug/plugininfo.ui</file>
<file compressed="true">Prefs/prefs.ui</file>
</gresource>
</gresources>