/soc/2013/bhaskar/plugins-window: da63c7bb7377: Fixed some bugs ...

Bhaskar Kandiyal bkandiyal at gmail.com
Sat Sep 14 16:56:11 EDT 2013


Changeset: da63c7bb7377230b7b17158541a939ee4a4356ba
Author:	 Bhaskar Kandiyal <bkandiyal at gmail.com>
Date:	 2013-09-15 02:25 +0530
Branch:	 soc.2013.plugins_window
URL: https://hg.pidgin.im/soc/2013/bhaskar/plugins-window/rev/da63c7bb7377

Description:

Fixed some bugs and made added some functionality to the plugin details pane

diffstat:

 pidgin/gtkplugin-updater.c    |  58 ++++++++++++++++++++++++++++++++++++-
 pidgin/gtkplugin.c            |  66 ++++++++++++++++++++++++++++++++++++++----
 pidgin/ui/plugin_details.html |  38 ++++++++++++++++++++++--
 3 files changed, 149 insertions(+), 13 deletions(-)

diffs (truncated from 350 to 300 lines):

diff --git a/pidgin/gtkplugin-updater.c b/pidgin/gtkplugin-updater.c
--- a/pidgin/gtkplugin-updater.c
+++ b/pidgin/gtkplugin-updater.c
@@ -38,6 +38,10 @@
 #include <json-glib/json-glib.h>
 
 static GtkTextView *changelog;
+static GtkWidget *progress;
+static GtkWidget *dlg_progress;
+
+static gboolean STOP_UPDATING = FALSE;
 static gboolean INTERACTIVE = FALSE;
 
 typedef enum
@@ -50,6 +54,42 @@ typedef enum
 	PLUGING_COL_CHANGELOG = 5,
 } PluginColumns;
 
+static GtkWidget*
+create_progress_dialog()
+{
+	GtkWidget *dialog;
+	GtkWidget *content;
+	GtkWidget *label;
+	GtkWidget *vbox;
+
+	dialog = gtk_dialog_new();
+
+	gtk_widget_set_size_request(dialog, 400, 100);
+	gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+	gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+
+	content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+	vbox = gtk_vbox_new(TRUE, 1);
+
+	label = gtk_label_new(_("Checking for updates...."));
+	progress = gtk_progress_bar_new();
+	gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress));
+
+	gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
+	gtk_box_pack_end(GTK_BOX(vbox), progress, TRUE, TRUE, 0);
+
+	gtk_container_add(GTK_CONTAINER(content), vbox);
+
+	return dialog;
+}
+
+static void
+update_progress_cb(PurpleHttpConnection *http_conn,
+		gboolean reading_state, int processed, int total, gpointer user_data)
+{
+	gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress));
+}
+
 static void
 download_plugin_cb(PurpleHttpConnection *con, PurpleHttpResponse *response, gpointer user_data)
 {
@@ -177,6 +217,8 @@ execute_update_queue(gpointer data)
 		g_free(url);
 	}
 
+	purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/updater/install_pending_updates", TRUE);
+
 	purple_debug_info("updater", "Plugins updated successfully\n");
 	if(INTERACTIVE)
 	{
@@ -405,6 +447,11 @@ check_updates_request_cb(PurpleHttpConne
 	}
 	json_reader_end_member(reader);
 
+	if(INTERACTIVE)
+	{
+		gtk_widget_destroy(dlg_progress);
+	}
+
 	g_idle_add((GSourceFunc) handle_updates, plugin_store);
 
 	g_strfreev(list);
@@ -422,10 +469,17 @@ pidgin_plugin_updater_check_for_updates(
 	JsonNode *root;
 	GList *plugin_list;
 	PurplePlugin *plug;
+	PurpleHttpConnection *con;
 	gsize len;
 
 	INTERACTIVE = interactive;
 
+	if(INTERACTIVE)
+	{
+		dlg_progress = create_progress_dialog();
+		gtk_widget_show_all(dlg_progress);
+	}
+
 	url = g_strdup_printf("%s/%s", PIDGIN_PLUGIN_WEBSITE_URI, "api/get_version");
 	purple_debug_info("updater", "Checking for plugin updates....\n");
 
@@ -456,8 +510,8 @@ pidgin_plugin_updater_check_for_updates(
 	purple_http_request_header_set(request, "Content-Type", "application/x-www-form-urlencoded");
 	purple_http_request_set_contents(request, data, g_utf8_strlen(data, -1));
 
-	purple_http_request(NULL, request, check_updates_request_cb, (gpointer)interactive);
-
+	con = purple_http_request(NULL, request, check_updates_request_cb, (gpointer)interactive);
+	purple_http_conn_set_progress_watcher(con, (PurpleHttpProgressWatcher) update_progress_cb, NULL, 0);
 	purple_http_request_unref(request);
 
 	json_node_free(root);
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c
--- a/pidgin/gtkplugin.c
+++ b/pidgin/gtkplugin.c
@@ -759,14 +759,52 @@ plugin_details_button_click_cb(WebKitDOM
 	}
 }
 
+static GtkWidget*
+create_progress_dialog()
+{
+	GtkWidget *dialog;
+	GtkWidget *content;
+	GtkWidget *label;
+	GtkWidget *vbox;
+	GtkWidget *progress;
+
+	dialog = gtk_dialog_new();
+
+	gtk_widget_set_size_request(dialog, 400, 100);
+	gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+	gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+
+	content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+	vbox = gtk_vbox_new(TRUE, 1);
+
+	label = gtk_label_new(_("Downloading plugins...."));
+	progress = gtk_progress_bar_new();
+
+	gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
+	gtk_box_pack_end(GTK_BOX(vbox), progress, TRUE, TRUE, 0);
+
+	gtk_container_add(GTK_CONTAINER(content), vbox);
+
+	gtk_widget_show_all(dialog);
+
+	return progress;
+}
+
+static void
+destroy_progress_dialog(GtkWidget *progress)
+{
+	purple_debug_info("plugins", "Destroying progress dialog\n");
+	gtk_widget_destroy(gtk_widget_get_toplevel(progress));
+	purple_debug_info("plugins", "Done\n");
+}
 
 static gboolean
 webview_download_status(gpointer data)
 {
 	GHashTable *hash_table = (GHashTable*) data;
-	GtkWidget *dialog;
+	GtkWidget *dialog, *progress;
 	WebKitDownload *download;
-	gchar *id, *path, *plugin_file, *msg;
+	gchar *path, *plugin_file, *msg;
 	gchar *filename, *type;
 	WebKitDownloadStatus status;
 	gboolean *update;
@@ -775,9 +813,14 @@ webview_download_status(gpointer data)
 	filename = (gchar*) g_hash_table_lookup(hash_table, "filename");
 	type = (gchar*) g_hash_table_lookup(hash_table, "type");
 	update = (gboolean*) g_hash_table_lookup(hash_table, "update");
+	progress = (GtkWidget*) g_hash_table_lookup(hash_table, "progress");
 
 	status = webkit_download_get_status(download);
 
+	purple_debug_info("plugins", "Settings progress to %2f", webkit_download_get_progress(download));
+	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress), webkit_download_get_progress(download));
+	purple_debug_info("plugins", "Done");
+
 	switch(status)
 	{
 	case WEBKIT_DOWNLOAD_STATUS_FINISHED:
@@ -813,15 +856,15 @@ webview_download_status(gpointer data)
 
 		if(g_strcmp0(type, "sounds") == 0)
 		{
-			msg = "Sound theme installed. You can enable the theme from Tools->Preferences->Themes in Pidgin";
+			msg = _("Sound theme installed. You can enable the theme from Tools->Preferences->Themes in Pidgin");
 		}
 		else if(g_strcmp0(type, "themes") == 0)
 		{
-			msg = "Buddy list theme installed. You can enable the theme from Tools->Preferences->Themes in Pidgin";
+			msg = _("Buddy list theme installed. You can enable the theme from Tools->Preferences->Themes in Pidgin");
 		}
 		else
 		{
-			msg = "Plugin installed. You can now enable the plugin from the \'Installed Plugins\' tab";
+			msg = _("Plugin installed. You can now enable the plugin from the \'Installed Plugins\' tab");
 		}
 
 		dialog = gtk_message_dialog_new(GTK_WINDOW(plugin_dialog), GTK_DIALOG_MODAL,
@@ -837,6 +880,7 @@ webview_download_status(gpointer data)
 
 		/* Refresh the plugins list */
 		refresh_plugin_model();
+		destroy_progress_dialog(progress);
 		g_hash_table_unref(hash_table);
 		return FALSE;
 	break;
@@ -848,17 +892,18 @@ webview_download_status(gpointer data)
 				_("An error occurred when trying to download the plugin. Please try again."));
 		gtk_dialog_run(GTK_DIALOG(dialog));
 		gtk_widget_destroy(dialog);
+		destroy_progress_dialog(progress);
 		g_hash_table_unref(hash_table);
 		return FALSE;
 	break;
 
 	case WEBKIT_DOWNLOAD_STATUS_CANCELLED:
+		destroy_progress_dialog(progress);
 		g_hash_table_unref(hash_table);
 		return FALSE;
 	break;
 
 	default:
-		g_hash_table_unref(hash_table);
 		return TRUE;
 	}
 }
@@ -875,6 +920,7 @@ webview_download_requested_cb(WebKitWebV
 	GRegex *re;
 	PurplePlugin *plug;
 	GFile *file;
+	GtkWidget *progress;
 
 	msgd = gtk_message_dialog_new(GTK_WINDOW(plugin_dialog), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
 				_("Are you sure you wish to install this plugin?"));
@@ -908,12 +954,15 @@ webview_download_requested_cb(WebKitWebV
 
 	g_regex_unref(re);
 
+	progress = create_progress_dialog();
+
 	hash = g_hash_table_new(NULL, NULL);
 
 	g_hash_table_insert(hash, "webkit-download", download);
 	g_hash_table_insert(hash, "filename", filename);
 	g_hash_table_insert(hash, "type", type);
 	g_hash_table_insert(hash, "update", FALSE);
+	g_hash_table_insert(hash, "progress", progress);
 
 	if(g_str_equal("plugins", type))
 	{
@@ -957,6 +1006,7 @@ webview_download_requested_cb(WebKitWebV
 	if(g_mkdir_with_parents(g_path_get_dirname(path), 0755) == -1)
 	{
 		purple_debug_info("plugins", "Error creating directory: %s\n", path);
+		g_hash_table_unref(hash);
 		return FALSE;
 	}
 
@@ -1025,6 +1075,8 @@ plugin_category_changed_cb(GtkTreeView *
 		gtk_tree_view_set_cursor(view, path, NULL, FALSE);
 		gtk_tree_model_filter_refilter(filter);
 		gtk_tree_path_free(path);
+
+		gtk_webview_safe_execute_script(GTK_WEBVIEW(plugin_details), "reset()");
 	}
 }
 
@@ -1265,7 +1317,7 @@ void pidgin_plugin_dialog_show()
 	g_signal_connect(G_OBJECT(plugin_dialog), "response", G_CALLBACK(plugin_dialog_response_cb), sel);
 	g_signal_connect(G_OBJECT(notebook), "switch-page", G_CALLBACK(plugin_tab_change_cb), NULL);
 
-	gtk_window_set_default_size(GTK_WINDOW(plugin_dialog), 800, 600);
+	gtk_window_set_default_size(GTK_WINDOW(plugin_dialog), 780, 600);
 
 	pidgin_auto_parent_window(plugin_dialog);
 
diff --git a/pidgin/ui/plugin_details.html b/pidgin/ui/plugin_details.html
--- a/pidgin/ui/plugin_details.html
+++ b/pidgin/ui/plugin_details.html
@@ -20,13 +20,14 @@
 			font-weight: bold;
 		}
 		
-		a {
+		a, #file {
 			color: #8C5099;
 			text-decoration: none;
 		}
 		
-		a:hover {
+		a:hover, #file:hover {
 			color: #9A38B2;
+			cursor: pointer;
 			//text-decoration: underline;
 		}
 		
@@ -151,13 +152,39 @@
 			
 			showIntro(false);



More information about the Commits mailing list