/soc/2013/bhaskar/plugins-window: 0eeb7ed2712d: Category pane ad...

Bhaskar Kandiyal bkandiyal at gmail.com
Mon Aug 12 16:29:33 EDT 2013


Changeset: 0eeb7ed2712dcb5f517fbf9419a7e23bdb214377
Author:	 Bhaskar Kandiyal <bkandiyal at gmail.com>
Date:	 2013-08-13 01:54 +0530
Branch:	 default
URL: https://hg.pidgin.im/soc/2013/bhaskar/plugins-window/rev/0eeb7ed2712d

Description:

Category pane added to the plugins window

diffstat:

 configure.ac                  |    1 +
 libpurple/plugin.c            |   53 ++
 libpurple/plugin.h            |   22 +
 pidgin/Makefile.am            |    2 +-
 pidgin/gtkplugin.c            |  748 ++++++++++++++++++++++++++++-------------
 pidgin/ui/Makefile.am         |    7 +
 pidgin/ui/plugin_details.html |  181 ++++++++++
 7 files changed, 770 insertions(+), 244 deletions(-)

diffs (truncated from 1277 to 300 lines):

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -2868,6 +2868,7 @@ AC_CONFIG_FILES([Makefile
 		   pidgin/plugins/perl/common/Makefile.PL
 		   pidgin/plugins/ticker/Makefile
 		   pidgin/themes/Makefile
+       pidgin/ui/Makefile
 		   libpurple/ciphers/Makefile
 		   libpurple/example/Makefile
 		   libpurple/gconf/Makefile
diff --git a/libpurple/plugin.c b/libpurple/plugin.c
--- a/libpurple/plugin.c
+++ b/libpurple/plugin.c
@@ -36,6 +36,8 @@
 #include "valgrind.h"
 #include "version.h"
 
+#include <gio/gio.h>
+
 typedef struct
 {
 	GHashTable *commands;
@@ -199,6 +201,8 @@ purple_plugin_probe(const char *filename
 	gpointer unpunned;
 	gchar *basename = NULL;
 	gboolean (*purple_init_plugin)(PurplePlugin *);
+	GFile *gfile;
+	GFileInfo *gfile_info;
 
 	purple_debug_misc("plugins", "probing %s\n", filename);
 	g_return_val_if_fail(filename != NULL, NULL);
@@ -477,6 +481,21 @@ purple_plugin_probe(const char *filename
 		}
 	}
 
+	gfile = g_file_new_for_path(filename);
+	gfile_info = g_file_query_info(gfile, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
+
+	if (gfile_info != NULL)
+	{
+		plugin->removeable = g_file_info_get_attribute_boolean(gfile_info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE);
+		g_object_unref(gfile_info);
+		purple_debug_info("plugins", "Removeable: %s\n", (plugin->removeable)?"TRUE":"FALSE");
+	}
+	else {
+		plugin->removeable = FALSE;
+		purple_debug_info("plugins", "Cannot read file info of %s", filename);
+	}
+
+	g_object_unref(gfile);
 	return plugin;
 #else
 	return NULL;
@@ -884,6 +903,32 @@ purple_plugin_destroy(PurplePlugin *plug
 }
 
 gboolean
+purple_plugin_remove(PurplePlugin *plugin)
+{
+#ifdef PURPLE_PLUGINS
+	gboolean ret;
+	GFile *file;
+
+	g_return_val_if_fail(plugin != NULL, FALSE);
+
+	if (!plugin->removeable)
+		return FALSE;
+
+	file = g_file_new_for_path(plugin->path);
+
+	purple_plugin_destroy(plugin);
+
+	ret = g_file_delete(file, NULL, NULL);
+
+	g_object_unref(file);
+
+	return ret;
+#else
+	return TRUE;
+#endif /* PURPLE_PLUGINS */
+}
+
+gboolean
 purple_plugin_is_loaded(const PurplePlugin *plugin)
 {
 	g_return_val_if_fail(plugin != NULL, FALSE);
@@ -899,6 +944,14 @@ purple_plugin_is_unloadable(const Purple
 	return plugin->unloadable;
 }
 
+gboolean
+purple_plugin_is_removeable(const PurplePlugin *plugin)
+{
+	g_return_val_if_fail(plugin != NULL, FALSE);
+	
+	return plugin->removeable;
+}
+
 const gchar *
 purple_plugin_get_id(const PurplePlugin *plugin) {
 	g_return_val_if_fail(plugin, NULL);
diff --git a/libpurple/plugin.h b/libpurple/plugin.h
--- a/libpurple/plugin.h
+++ b/libpurple/plugin.h
@@ -159,6 +159,7 @@ struct _PurplePlugin
 	void *ipc_data;                        /**< IPC data.                 */
 	void *extra;                           /**< Plugin-specific data.     */
 	gboolean unloadable;                   /**< Unloadable                */
+	gboolean removeable;				   /**< Removeable				  */	
 	GList *dependent_plugins;              /**< Plugins depending on this */
 
 	void (*_purple_reserved1)(void);
@@ -338,6 +339,13 @@ gboolean purple_plugin_reload(PurplePlug
 void purple_plugin_destroy(PurplePlugin *plugin);
 
 /**
+ * Completely removes the plugin file from the filesystem.
+ *
+ * @param plugin The plugin hangle
+ */
+gboolean purple_plugin_remove(PurplePlugin *plugin);
+
+/**
  * Returns whether or not a plugin is currently loaded.
  *
  * @param plugin The plugin.
@@ -361,6 +369,20 @@ gboolean purple_plugin_is_loaded(const P
 gboolean purple_plugin_is_unloadable(const PurplePlugin *plugin);
 
 /**
+ * Returns whether or not a plugin is removeable.
+ * 
+ * If this returns @c TRUE, the plugin can be removed that is,
+ * it's file can be deleted. If the plugin file is writeable then
+ * the plugin can be removed.
+ * 
+ * @param plugin The plugin.
+ * 
+ * @return @c TRUE if the plugin can be removed
+ * 			@c FALSE otherwise
+ */
+ gboolean purple_plugin_is_removeable(const PurplePlugin *plugin);
+ 
+/**
  * Returns a plugin's id.
  *
  * @param plugin The plugin.
diff --git a/pidgin/Makefile.am b/pidgin/Makefile.am
--- a/pidgin/Makefile.am
+++ b/pidgin/Makefile.am
@@ -36,7 +36,7 @@ if ENABLE_GTK
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = pidgin-3.pc
 
-SUBDIRS = pixmaps plugins themes
+SUBDIRS = pixmaps plugins themes ui
 
 bin_PROGRAMS = pidgin
 
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c
--- a/pidgin/gtkplugin.c
+++ b/pidgin/gtkplugin.c
@@ -32,6 +32,7 @@
 #include "prefs.h"
 #include "request.h"
 #include "pidgintooltip.h"
+#include "gtkwebview.h"
 
 #include <string.h>
 
@@ -39,21 +40,30 @@
 
 #define PIDGIN_RESPONSE_CONFIGURE 98121
 
+typedef enum {
+	PLUGINS_TAB_INSTALLED_PLUGINS = 0,
+	PLUGINS_TAB_DOWNLOAD_PLUGINS = 1,
+} PluginTabs;
+
+typedef enum {
+	PLUGIN_FILTER_ENABLED_PLUGINS = 0,
+	PLUGIN_FILTER_DISABLED_PLUGINS = 1,
+	PLUGIN_FILTER_ALL_PLUGINS = 3,
+} PluginFilter;
+
+static const gchar* DEFAULT_URI = "http://bhaskar-kandiyal.rhcloud.com/";
+static gint FIRST_LOAD = TRUE;
+
 static void plugin_toggled_stage_two(PurplePlugin *plug, GtkTreeModel *model,
                                   GtkTreeIter *iter, gboolean unload);
+static gchar* convert_to_html_para(const gchar *input);
 
-static GtkWidget *expander = NULL;
+static GtkWidget *event_view = NULL;
 static GtkWidget *plugin_dialog = NULL;
+static GtkWidget *plugin_details = NULL;
+static GtkWidget *download_plugins = NULL;
+static GtkWidget *category_tree = NULL;
 
-static GtkLabel *plugin_name = NULL;
-static GtkTextBuffer *plugin_desc = NULL;
-static GtkLabel *plugin_error = NULL;
-static GtkLabel *plugin_author = NULL;
-static GtkLabel *plugin_website = NULL;
-static gchar *plugin_website_uri = NULL;
-static GtkLabel *plugin_filename = NULL;
-
-static GtkWidget *pref_button = NULL;
 static GHashTable *plugin_pref_dialogs = NULL;
 
 GtkWidget *
@@ -168,6 +178,7 @@ static void plugin_loading_common(Purple
 {
 	GtkTreeIter iter;
 	GtkTreeModel *model = gtk_tree_view_get_model(view);
+	gchar *buf;
 
 	if (gtk_tree_model_get_iter_first(model, &iter)) {
 		do {
@@ -189,12 +200,14 @@ static void plugin_loading_common(Purple
 				gtk_tree_model_get(model, &iter, 2, &plug, -1);
 				if (plug == plugin)
 				{
-					gtk_widget_set_sensitive(pref_button,
-						loaded
-						&& ((PIDGIN_IS_PIDGIN_PLUGIN(plug) && plug->info->ui_info
-							&& PIDGIN_PLUGIN_UI_INFO(plug)->get_config_frame)
-						 || (plug->info->prefs_info
-							&& plug->info->prefs_info->get_plugin_pref_frame)));
+					buf = g_strdup_printf("enableConfigure(%d)", purple_plugin_is_loaded(plug)
+								&& ((PIDGIN_IS_PIDGIN_PLUGIN(plug) && plug->info->ui_info
+									&& PIDGIN_PLUGIN_UI_INFO(plug)->get_config_frame)
+								 || (plug->info->prefs_info
+									&& plug->info->prefs_info->get_plugin_pref_frame)));
+
+					gtk_webview_safe_execute_script(GTK_WEBVIEW(plugin_details), buf);
+					g_free(buf);
 				}
 			}
 
@@ -317,6 +330,8 @@ static void plugin_toggled(GtkCellRender
 
 static void plugin_toggled_stage_two(PurplePlugin *plug, GtkTreeModel *model, GtkTreeIter *iter, gboolean unload)
 {
+	gchar *buf, *error;
+
 	if (unload)
 	{
 		pidgin_set_cursor(plugin_dialog, GDK_WATCH);
@@ -343,36 +358,22 @@ static void plugin_toggled_stage_two(Pur
 		pidgin_clear_cursor(plugin_dialog);
 	}
 
-	gtk_widget_set_sensitive(pref_button,
-		purple_plugin_is_loaded(plug)
-		&& ((PIDGIN_IS_PIDGIN_PLUGIN(plug) && plug->info->ui_info
-			&& PIDGIN_PLUGIN_UI_INFO(plug)->get_config_frame)
-		 || (plug->info->prefs_info
-			&& plug->info->prefs_info->get_plugin_pref_frame)));
+	buf = g_strdup_printf("enableConfigure(%d)", purple_plugin_is_loaded(plug)
+			&& ((PIDGIN_IS_PIDGIN_PLUGIN(plug) && plug->info->ui_info
+				&& PIDGIN_PLUGIN_UI_INFO(plug)->get_config_frame)
+			 || (plug->info->prefs_info
+				&& plug->info->prefs_info->get_plugin_pref_frame)));
+
+	gtk_webview_safe_execute_script(GTK_WEBVIEW(plugin_details), buf);
+	g_free(buf);
 
 	if (plug->error != NULL)
 	{
-		gchar *name = g_markup_escape_text(purple_plugin_get_name(plug), -1);
-
-		gchar *error = g_markup_escape_text(plug->error, -1);
-		gchar *text;
-
-		text = g_strdup_printf(
-			"<b>%s</b> %s\n<span weight=\"bold\" color=\"red\"%s</span>",
-			purple_plugin_get_name(plug), purple_plugin_get_version(plug), error);
-		gtk_list_store_set(GTK_LIST_STORE (model), iter,
-				   1, text,
-				   -1);
-		g_free(text);
-
-		text = g_strdup_printf(
-			"<span weight=\"bold\" color=\"red\">%s</span>",
-			error);
-		gtk_label_set_markup(plugin_error, text);
-		g_free(text);
-
+		error = convert_to_html_para(plug->error);
+		buf = g_strdup_printf("showError('%s')", "Error: Kaboom!");
+		gtk_webview_safe_execute_script(GTK_WEBVIEW(plugin_details), buf);
 		g_free(error);
-		g_free(name);
+		g_free(buf);
 	}
 
 	gtk_list_store_set(GTK_LIST_STORE (model), iter,
@@ -398,85 +399,106 @@ static gboolean ensure_plugin_visible(vo



More information about the Commits mailing list