soc.2010.logviewer: ed42eeca: First update, adding the global log view...

adam.fowler at soc.pidgin.im adam.fowler at soc.pidgin.im
Wed Jun 30 17:01:10 EDT 2010


----------------------------------------------------------------------
Revision: ed42eeca96298891445718e54a71240d601e6dca
Parent:   4d68ce907a18679ccc1656075efd5b7d114fdf92
Author:   adam.fowler at soc.pidgin.im
Date:     06/30/10 16:46:13
Branch:   im.pidgin.soc.2010.logviewer
URL: http://d.pidgin.im/viewmtn/revision/info/ed42eeca96298891445718e54a71240d601e6dca

Changelog: 


First update, adding the global log viewer to Tools>Chat Logs

Changes against parent 4d68ce907a18679ccc1656075efd5b7d114fdf92

  patched  libpurple/log.c
  patched  libpurple/log.h
  patched  pidgin/gtkblist.c
  patched  pidgin/gtklog.c
  patched  pidgin/gtklog.h

-------------- next part --------------
============================================================
--- libpurple/log.c	6eb41ef373632163452c5ce4ccee063891e0f560
+++ libpurple/log.c	cf70a8960aaed0f13632a5aa2ee9c1c61f428bab
@@ -516,12 +516,16 @@ GList *purple_log_get_logs(PurpleLogType
 	GList *logs = NULL;
 	GSList *n;
 	for (n = loggers; n; n = n->next) {
+		fprintf(stderr,"%s\n", loggers);
+		fprintf(stderr,"THIS IS RUNNIN\n"); 
 		PurpleLogLogger *logger = n->data;
+		fprintf(stderr,"%s\n", n->data);
+		fprintf(stderr,"%s\n", logger->list);
 		if (!logger->list)
 			continue;
 		logs = g_list_concat(logger->list(type, name, account), logs);
 	}
-
+	fprintf(stderr,"THIS IS NOT RUNNING\n");
 	return g_list_sort(logs, purple_log_compare);
 }
 
@@ -1401,7 +1405,7 @@ static gsize html_logger_write(PurpleLog
 			header = g_strdup_printf("System log for account %s (%s) connected at %s",
 					purple_account_get_username(log->account), prpl, date);
 		else
-			header = g_strdup_printf("Conversation with %s at %s on %s (%s)",
+			header = g_strdup_printf("Conversation withTEST %s at %s on %s (%s)",
 					log->name, date, purple_account_get_username(log->account), prpl);
 
 		written += fprintf(data->file, "%s", header);
@@ -1557,7 +1561,7 @@ static gsize txt_logger_write(PurpleLog 
 				purple_account_get_username(log->account), prpl,
 				purple_date_format_full(localtime(&log->time)));
 		else
-			written += fprintf(data->file, "Conversation with %s at %s on %s (%s)\n",
+			written += fprintf(data->file, "Conversation withTEST2 %s at %s on %s (%s)\n",
 				log->name, purple_date_format_full(localtime(&log->time)),
 				purple_account_get_username(log->account), prpl);
 	}
============================================================
--- pidgin/gtkblist.c	13c1e422e251a301e1e938bcdcc4baa3f3f94fd5
+++ pidgin/gtkblist.c	20d396d4a4be98abb2e65965368c4cc1ab811be0
@@ -742,6 +742,7 @@ static void gtk_blist_menu_bp_cb(GtkWidg
 	                          purple_buddy_get_name(b), NULL);
 }
 
+
 static void gtk_blist_menu_showlog_cb(GtkWidget *w, PurpleBlistNode *node)
 {
 	PurpleLogType type;
@@ -755,11 +756,13 @@ static void gtk_blist_menu_showlog_cb(Gt
 		type = PURPLE_LOG_IM;
 		name = g_strdup(purple_buddy_get_name(b));
 		account = purple_buddy_get_account(b);
+		g_print("Hokay\n");
 	} else if (PURPLE_BLIST_NODE_IS_CHAT(node)) {
 		PurpleChat *c = PURPLE_CHAT(node);
 		PurplePluginProtocolInfo *prpl_info = NULL;
 		type = PURPLE_LOG_CHAT;
 		account = purple_chat_get_account(c);
+		g_print("Hokay1\n");
 		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_find_prpl(purple_account_get_protocol_id(account)));
 		if (prpl_info && prpl_info->get_chat_name) {
 			name = prpl_info->get_chat_name(purple_chat_get_components(c));
@@ -767,10 +770,11 @@ static void gtk_blist_menu_showlog_cb(Gt
 	} else if (PURPLE_BLIST_NODE_IS_CONTACT(node)) {
 		pidgin_log_show_contact(PURPLE_CONTACT(node));
 		pidgin_clear_cursor(gtkblist->window);
+		g_print("Hokay2\n");
 		return;
 	} else {
 		pidgin_clear_cursor(gtkblist->window);
-
+		g_print("Hokay3\n");
 		/* This callback should not have been registered for a node
 		 * that doesn't match the type of one of the blocks above. */
 		g_return_if_reached();
@@ -779,6 +783,7 @@ static void gtk_blist_menu_showlog_cb(Gt
 	if (name && account) {
 		pidgin_log_show(type, name, account);
 		pidgin_clear_cursor(gtkblist->window);
+		g_print("PASSED\n");
 	}
 
 	g_free(name);
@@ -1550,17 +1555,17 @@ pidgin_blist_make_buddy_menu(GtkWidget *
 
 	if (node->parent && node->parent->child->next &&
 	      !sub && !contact_expanded) {
-		pidgin_new_item_from_stock(menu, _("View _Log"), NULL,
+		pidgin_new_item_from_stock(menu, _("View _Log1"), NULL,
 				G_CALLBACK(gtk_blist_menu_showlog_cb),
 				contact, 0, 0, NULL);
 	} else if (!sub) {
-		pidgin_new_item_from_stock(menu, _("View _Log"), NULL,
+		pidgin_new_item_from_stock(menu, _("View _Log2"), NULL,
 				G_CALLBACK(gtk_blist_menu_showlog_cb), buddy, 0, 0, NULL);
 	}
 
 	if (!PURPLE_BLIST_NODE_HAS_FLAG(node, PURPLE_BLIST_NODE_FLAG_NO_SAVE)) {
 		gboolean show_offline = purple_blist_node_get_bool(node, "show_offline");
-		pidgin_new_item_from_stock(menu, show_offline ? _("Hide When Offline") : _("Show When Offline"),
+		pidgin_new_item_from_stock(menu, show_offline ? _("Hide When Offline") : _("Show When OfflineONE"),
 				NULL, G_CALLBACK(gtk_blist_menu_showoffline_cb), node, 0, 0, NULL);
 	}
 
@@ -1744,7 +1749,7 @@ create_group_menu (PurpleBlistNode *node
 				 G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL);
 	if (!(purple_blist_node_get_flags(node) & PURPLE_BLIST_NODE_FLAG_NO_SAVE)) {
 		gboolean show_offline = purple_blist_node_get_bool(node, "show_offline");
-		pidgin_new_item_from_stock(menu, show_offline ? _("Hide When Offline") : _("Show When Offline"),
+		pidgin_new_item_from_stock(menu, show_offline ? _("Hide When Offline") : _("Show When OfflineTWO"),
 				NULL, G_CALLBACK(gtk_blist_menu_showoffline_cb), node, 0, 0, NULL);
 	}
 
@@ -1772,7 +1777,7 @@ create_chat_menu(PurpleBlistNode *node, 
 			G_CALLBACK(gtk_blist_menu_autojoin_cb), node, autojoin);
 	pidgin_new_check_item(menu, _("Persistent"),
 			G_CALLBACK(gtk_blist_menu_persistent_cb), node, persistent);
-	pidgin_new_item_from_stock(menu, _("View _Log"), NULL,
+	pidgin_new_item_from_stock(menu, _("View _Log3"), NULL,
 			G_CALLBACK(gtk_blist_menu_showlog_cb), node, 0, 0, NULL);
 
 	pidgin_append_blist_node_proto_menu(menu, c->account->gc, node);
@@ -1799,7 +1804,7 @@ create_contact_menu (PurpleBlistNode *no
 
 	menu = gtk_menu_new();
 
-	pidgin_new_item_from_stock(menu, _("View _Log"), NULL,
+	pidgin_new_item_from_stock(menu, _("View _Log4"), NULL,
 				 G_CALLBACK(gtk_blist_menu_showlog_cb),
 				 node, 0, 0, NULL);
 
@@ -3690,6 +3695,7 @@ static GtkItemFactoryEntry blist_menu[] 
 	{ "/Tools/sep2", NULL, NULL, 0, "<Separator>", NULL },
 	{ N_("/Tools/_File Transfers"), "<CTL>T", pidgin_xfer_dialog_show, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_TRANSFER },
 	{ N_("/Tools/R_oom List"), NULL, pidgin_roomlist_dialog_show, 0, "<Item>", NULL },
+	{ N_("/Tools/Chat Lo_gs"), NULL, pidgin_log_show_global, 0, "<Item>", NULL},
 	{ N_("/Tools/System _Log"), NULL, gtk_blist_show_systemlog_cb, 3, "<Item>", NULL },
 	{ "/Tools/sep3", NULL, NULL, 0, "<Separator>", NULL },
 	{ N_("/Tools/Mute _Sounds"), NULL, pidgin_blist_mute_sounds_cb, 0, "<CheckItem>", NULL },
============================================================
--- libpurple/log.h	fdae3f0adc203739096c27e7d4bb6fc140b28591
+++ libpurple/log.h	97f81bee8dd3fc7055dfdd1475548f2b5d7fac17
@@ -42,7 +42,8 @@ typedef enum {
 typedef enum {
 	PURPLE_LOG_IM,
 	PURPLE_LOG_CHAT,
-	PURPLE_LOG_SYSTEM
+	PURPLE_LOG_SYSTEM,
+	PURPLE_LOG_GLOBAL
 } PurpleLogType;
 
 typedef enum {
============================================================
--- pidgin/gtklog.c	f9d82fe3e8fab18648c330dbfffb92f146b5062f
+++ pidgin/gtklog.c	3a0084d7547470c925665d04b204a396672601d5
@@ -1,3 +1,4 @@
+
 /**
  * @file gtklog.c GTK+ Log viewer
  * @ingroup pidgin
@@ -50,19 +51,20 @@ struct log_viewer_hash_t {
 	PurpleContact *contact;
 };
 
-static guint log_viewer_hash(gconstpointer data)
-{
+static guint log_viewer_hash(gconstpointer data){
 	const struct log_viewer_hash_t *viewer = data;
 
 	if (viewer->contact != NULL)
 		return g_direct_hash(viewer->contact);
+	else if (viewer->type == PURPLE_LOG_GLOBAL){
+		return g_direct_hash(viewer);
+	}
 
 	return g_str_hash(viewer->buddyname) +
 		g_str_hash(purple_account_get_username(viewer->account));
 }
 
-static gboolean log_viewer_equal(gconstpointer y, gconstpointer z)
-{
+static gboolean log_viewer_equal(gconstpointer y, gconstpointer z){
 	const struct log_viewer_hash_t *a, *b;
 	int ret;
 	char *normal;
@@ -88,8 +90,7 @@ static gboolean log_viewer_equal(gconstp
 	return ret;
 }
 
-static void select_first_log(PidginLogViewer *lv)
-{
+static void select_first_log(PidginLogViewer *lv){
 	GtkTreeModel *model;
 	GtkTreeIter iter, it;
 	GtkTreePath *path;
@@ -111,16 +112,14 @@ static void select_first_log(PidginLogVi
 	gtk_tree_path_free(path);
 }
 
-static const char *log_get_date(PurpleLog *log)
-{
+static const char *log_get_date(PurpleLog *log){
 	if (log->tm)
 		return purple_date_format_full(log->tm);
 	else
 		return purple_date_format_full(localtime(&log->time));
 }
 
-static void search_cb(GtkWidget *button, PidginLogViewer *lv)
-{
+static void search_cb(GtkWidget *button, PidginLogViewer *lv){
 	const char *search_term = gtk_entry_get_text(GTK_ENTRY(lv->entry));
 	GList *logs;
 
@@ -170,7 +169,7 @@ static void destroy_cb(GtkWidget *w, gin
 
 static void destroy_cb(GtkWidget *w, gint resp, struct log_viewer_hash_t *ht) {
 	PidginLogViewer *lv = syslog_viewer;
-
+	/*gboolean skip = FALSE;*/
 #ifdef _WIN32
 	if (resp == GTK_RESPONSE_HELP) {
 		GtkTreeSelection *sel;
@@ -204,24 +203,36 @@ static void destroy_cb(GtkWidget *w, gin
 		return;
 	}
 #endif
+	/*if(ht->type == PURPLE_LOG_GLOBAL)
+			skip = TRUE;*/
 
 	if (ht != NULL) {
 		lv = g_hash_table_lookup(log_viewers, ht);
+								fprintf(stderr,"stepif1 called\n");
 		g_hash_table_remove(log_viewers, ht);
-
+						fprintf(stderr,"stepif2 called\n");
 		g_free(ht->buddyname);
+								fprintf(stderr,"stepif3 called\n");
 		g_free(ht);
-	} else
+								fprintf(stderr,"stepif4 called\n");
+
+	} else{
 		syslog_viewer = NULL;
+				fprintf(stderr,"else called\n");
+	}
 
 	purple_request_close_with_handle(lv);
+	/*if(!skip){*/
+		g_list_foreach(lv->logs, (GFunc)purple_log_free, NULL);
+						fprintf(stderr,"step1 called\n");
+		g_list_free(lv->logs);
+						fprintf(stderr,"step2 called\n");
+		g_free(lv->search);
+						fprintf(stderr,"step3 called\n");
+		g_free(lv);
+						fprintf(stderr,"step4 called\n");
+	/*}*/
 
-	g_list_foreach(lv->logs, (GFunc)purple_log_free, NULL);
-	g_list_free(lv->logs);
-
-	g_free(lv->search);
-	g_free(lv);
-
 	gtk_widget_destroy(w);
 }
 
@@ -232,14 +243,12 @@ static void log_row_activated_cb(GtkTree
 		gtk_tree_view_expand_row(tv, path, FALSE);
 }
 
-static void delete_log_cleanup_cb(gpointer *data)
-{
+static void delete_log_cleanup_cb(gpointer *data){
 	g_free(data[1]); /* iter */
 	g_free(data);
 }
 
-static void delete_log_cb(gpointer *data)
-{
+static void delete_log_cb(gpointer *data){
 	if (!purple_log_delete((PurpleLog *)data[2]))
 	{
 		purple_notify_error(NULL, NULL, _("Log Deletion Failed"),
@@ -269,8 +278,7 @@ static void delete_log_cb(gpointer *data
 	delete_log_cleanup_cb(data);
 }
 
-static void log_delete_log_cb(GtkWidget *menuitem, gpointer *data)
-{
+static void log_delete_log_cb(GtkWidget *menuitem, gpointer *data){
 	PidginLogViewer *lv = data[0];
 	PurpleLog *log = data[1];
 	const char *time = log_get_date(log);
@@ -325,8 +333,7 @@ static void log_delete_log_cb(GtkWidget 
 	g_free(tmp);
 }
 
-static void log_show_popup_menu(GtkWidget *treeview, GdkEventButton *event, gpointer *data)
-{
+static void log_show_popup_menu(GtkWidget *treeview, GdkEventButton *event, gpointer *data){
 	GtkWidget *menu = gtk_menu_new();
 	GtkWidget *menuitem = gtk_menu_item_new_with_label(_("Delete Log..."));
 
@@ -343,10 +350,8 @@ static void log_show_popup_menu(GtkWidge
 	               gdk_event_get_time((GdkEvent *)event));
 }
 
-static gboolean log_button_press_cb(GtkWidget *treeview, GdkEventButton *event, PidginLogViewer *lv)
-{
-	if (event->type == GDK_BUTTON_PRESS && event->button == 3)
-	{
+static gboolean log_button_press_cb(GtkWidget *treeview, GdkEventButton *event, PidginLogViewer *lv){
+	if (event->type == GDK_BUTTON_PRESS && event->button == 3){ /*Just a note, left = 1, middle = 2, right = 3...Threw me at first*/
 		GtkTreePath *path;
 		GtkTreeIter *iter;
 		GValue val;
@@ -382,8 +387,7 @@ static gboolean log_button_press_cb(GtkW
 	return FALSE;
 }
 
-static gboolean log_popup_menu_cb(GtkWidget *treeview, PidginLogViewer *lv)
-{
+static gboolean log_popup_menu_cb(GtkWidget *treeview, PidginLogViewer *lv){
 	GtkTreeSelection *sel;
 	GtkTreeIter *iter;
 	GValue val;
@@ -416,8 +420,7 @@ static gboolean log_popup_menu_cb(GtkWid
 	return TRUE;
 }
 
-static gboolean search_find_cb(gpointer data)
-{
+static gboolean search_find_cb(gpointer data){
 	PidginLogViewer *viewer = data;
 	gtk_imhtml_search_find(GTK_IMHTML(viewer->imhtml), viewer->search);
 	g_object_steal_data(G_OBJECT(viewer->entry), "search-find-cb");
@@ -439,7 +442,6 @@ static void log_select_cb(GtkTreeSelecti
 	gtk_tree_model_get_value (model, &iter, 1, &val);
 	log = g_value_get_pointer(&val);
 	g_value_unset(&val);
-
 	if (log == NULL)
 		return;
 
@@ -451,7 +453,7 @@ static void log_select_cb(GtkTreeSelecti
 			title = g_strdup_printf(_("<span size='larger' weight='bold'>Conversation in %s on %s</span>"),
 									log->name, log_get_date(log));
 		else
-			title = g_strdup_printf(_("<span size='larger' weight='bold'>Conversation with %s on %s</span>"),
+			title = g_strdup_printf(_("<span size='larger' weight='bold'>Conversation withTEST %s on %s</span>"),
 									log->name, log_get_date(log));
 
 		gtk_label_set_markup(GTK_LABEL(viewer->label), title);
@@ -524,9 +526,11 @@ static void populate_log_tree(PidginLogV
 	}
 }
 
-static PidginLogViewer *display_log_viewer(struct log_viewer_hash_t *ht, GList *logs,
-						const char *title, GtkWidget *icon, int log_size)
-{
+static PidginLogViewer *display_log_viewer(struct log_viewer_hash_t *ht,
+															GList *logs,
+													  const char *title, 
+														GtkWidget *icon, 	
+														   int log_size){
 	PidginLogViewer *lv;
 	GtkWidget *title_box;
 	char *text;
@@ -539,8 +543,9 @@ static PidginLogViewer *display_log_view
 	GtkWidget *frame;
 	GtkWidget *hbox;
 	GtkWidget *find_button;
-	GtkWidget *size_label;
+	GtkWidget *size_label; 
 
+	fprintf(stderr,"\n\n##### START *display_log_viewer #####\n\n");
 	if (logs == NULL)
 	{
 		/* No logs were found. */
@@ -560,19 +565,19 @@ static PidginLogViewer *display_log_view
 			g_free(ht->buddyname);
 			g_free(ht);
 		}
-
 		if(icon != NULL)
 			gtk_widget_destroy(icon);
 
 		purple_notify_info(NULL, title, _("No logs were found"), log_preferences);
 		return NULL;
 	}
-
 	lv = g_new0(PidginLogViewer, 1);
 	lv->logs = logs;
 
-	if (ht != NULL)
+
+	if (ht != NULL){
 		g_hash_table_insert(log_viewers, ht, lv);
+	}
 
 	/* Window ***********/
 	lv->window = gtk_dialog_new_with_buttons(title, NULL, 0,
@@ -583,17 +588,16 @@ static PidginLogViewer *display_log_view
 #endif
 	gtk_container_set_border_width (GTK_CONTAINER(lv->window), PIDGIN_HIG_BOX_SPACE);
 	gtk_dialog_set_has_separator(GTK_DIALOG(lv->window), FALSE);
-	gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(lv->window)->vbox), 0);
-	g_signal_connect(G_OBJECT(lv->window), "response",
-					 G_CALLBACK(destroy_cb), ht);
-	gtk_window_set_role(GTK_WINDOW(lv->window), "log_viewer");
+	gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(lv->window)->vbox),0);
+		g_signal_connect(G_OBJECT(lv->window), "response",
+						 G_CALLBACK(destroy_cb), ht);
+		gtk_window_set_role(GTK_WINDOW(lv->window), "log_viewer");
 
 	/* Icon *************/
 	if (icon != NULL) {
 		title_box = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
 		gtk_container_set_border_width(GTK_CONTAINER(title_box), PIDGIN_HIG_BOX_SPACE);
 		gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), title_box, FALSE, FALSE, 0);
-
 		gtk_box_pack_start(GTK_BOX(title_box), icon, FALSE, FALSE, 0);
 	} else
 		title_box = GTK_DIALOG(lv->window)->vbox;
@@ -623,6 +627,7 @@ static PidginLogViewer *display_log_view
 	g_object_unref(G_OBJECT(lv->treestore));
 	rend = gtk_cell_renderer_text_new();
 	col = gtk_tree_view_column_new_with_attributes ("time", rend, "markup", 0, NULL);
+	
 	gtk_tree_view_append_column (GTK_TREE_VIEW(lv->treeview), col);
 	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (lv->treeview), FALSE);
 	gtk_container_add (GTK_CONTAINER (sw), lv->treeview);
@@ -631,11 +636,10 @@ static PidginLogViewer *display_log_view
 
 	sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (lv->treeview));
 	g_signal_connect (G_OBJECT (sel), "changed",
-			G_CALLBACK (log_select_cb),
-			lv);
+			G_CALLBACK (log_select_cb),	lv);			
 	g_signal_connect (G_OBJECT(lv->treeview), "row-activated",
-			G_CALLBACK(log_row_activated_cb),
-			lv);
+			G_CALLBACK(log_row_activated_cb), lv);
+			
 	pidgin_set_accessible_label(lv->treeview, lv->label);
 
 	g_signal_connect(lv->treeview, "button-press-event", G_CALLBACK(log_button_press_cb), lv);
@@ -644,6 +648,7 @@ static PidginLogViewer *display_log_view
 	/* Log size ************/
 	if(log_size) {
 		char *sz_txt = purple_str_size_to_units(log_size);
+		fprintf(stderr, "%s", sz_txt);
 		text = g_strdup_printf("<span weight='bold'>%s</span> %s", _("Total log size:"), sz_txt);
 		size_label = gtk_label_new(NULL);
 		gtk_label_set_markup(GTK_LABEL(size_label), text);
@@ -675,29 +680,93 @@ static PidginLogViewer *display_log_view
 	g_signal_connect(GTK_ENTRY(lv->entry), "activate", G_CALLBACK(search_cb), lv);
 	g_signal_connect(GTK_BUTTON(find_button), "clicked", G_CALLBACK(search_cb), lv);
 
+
 	select_first_log(lv);
-
 	gtk_widget_show_all(lv->window);
+	
+	fprintf(stderr,"\n\n##### END *display_log_viewer #####\n\n");
+	return lv;
+}
+void pidgin_log_show_global() {
+        PurpleBuddy *buddy;
+        PurpleContact *contact;
+        GSList *list, *tmplist;
+        struct log_viewer_hash_t *ht;
+	PidginLogViewer *lv;
+	GtkWidget *title_box;
+	char *text;
+	GtkWidget *pane;
+	GtkWidget *sw;
+	GtkCellRenderer *rend;
+	GtkTreeViewColumn *col;
+	GtkTreeSelection *sel;
+	GtkWidget *vbox;
+	GtkWidget *frame;
+	GtkWidget *hbox;
+	GtkWidget *find_button;
+	GtkWidget *size_label; 
+        
+ 
+        list = purple_blist_get_buddies();
+       
+        for (tmplist = list; tmplist != NULL; tmplist = tmplist->next) {
+                buddy = tmplist->data;
+                contact = purple_buddy_get_contact_alias(buddy);
+                fprintf(stderr, "%s\n", contact);
+                tmplist->data = contact;
+        }
+        ht = g_new0(struct log_viewer_hash_t, 1);
+        ht->type = PURPLE_LOG_GLOBAL;
+        g_slist_free(list);
+	
+	if (log_viewers == NULL) {
+		log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal);
+		fprintf(stderr, "log_viewers created.\n");
+	} else if ((lv = g_hash_table_lookup(log_viewers, ht))) {
+		gtk_window_present(GTK_WINDOW(lv->window));
+		g_free(ht->buddyname);
+		g_free(ht);
+	}
+	if (ht != NULL){
 
-	return lv;
+		g_hash_table_insert(log_viewers, ht, lv);
+		fprintf(stderr, "lv inserted into ht\n");
+	}
+	/* Window ***********/
+	lv->window = gtk_dialog_new_with_buttons("Log Viewer", NULL, 0,
+					     GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+#ifdef _WIN32
+	/* Steal the "HELP" response and use it to trigger browsing to the logs folder */
+	gtk_dialog_add_button(GTK_DIALOG(lv->window), _("_Browse logs folder"), GTK_RESPONSE_HELP);
+#endif
+	gtk_container_set_border_width (GTK_CONTAINER(lv->window), PIDGIN_HIG_BOX_SPACE);
+	gtk_dialog_set_has_separator(GTK_DIALOG(lv->window), FALSE);
+	gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(lv->window)->vbox),0);
+		g_signal_connect(G_OBJECT(lv->window), "response",
+						 G_CALLBACK(destroy_cb), ht);
+		gtk_window_set_role(GTK_WINDOW(lv->window), "log_viewer");
+	gtk_widget_show_all(lv->window);
+	
 }
+void pidgin_log_show(PurpleLogType type,
+				  const char *buddyname,
+				 PurpleAccount *account) {
 
-void pidgin_log_show(PurpleLogType type, const char *buddyname, PurpleAccount *account) {
 	struct log_viewer_hash_t *ht;
 	PidginLogViewer *lv = NULL;
 	const char *name = buddyname;
 	char *title;
-	GdkPixbuf *prpl_icon;
+	GdkPixbuf *prpl_icon;	
 
-	g_return_if_fail(account != NULL);
+	fprintf(stderr,"\n#####\n pidgin_log_show #####\n\n");
+	g_return_if_fail(account != NULL);/*Here we check a few things to see if we can continue*/
 	g_return_if_fail(buddyname != NULL);
 
-	ht = g_new0(struct log_viewer_hash_t, 1);
+	ht = g_new0(struct log_viewer_hash_t, 1);/*Here we clear all the fields in ht with 0*/
 
 	ht->type = type;
 	ht->buddyname = g_strdup(buddyname);
 	ht->account = account;
-
 	if (log_viewers == NULL) {
 		log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal);
 	} else if ((lv = g_hash_table_lookup(log_viewers, ht))) {
@@ -709,18 +778,16 @@ void pidgin_log_show(PurpleLogType type,
 
 	if (type == PURPLE_LOG_CHAT) {
 		PurpleChat *chat;
-
 		chat = purple_blist_find_chat(account, buddyname);
 		if (chat != NULL)
 			name = purple_chat_get_name(chat);
-
 		title = g_strdup_printf(_("Conversations in %s"), name);
 	} else {
 		PurpleBuddy *buddy;
-
 		buddy = purple_find_buddy(account, buddyname);
-		if (buddy != NULL)
+		if (buddy != NULL){
 			name = purple_buddy_get_contact_alias(buddy);
+		}
 
 		title = g_strdup_printf(_("Conversations with %s"), name);
 	}
@@ -730,10 +797,10 @@ void pidgin_log_show(PurpleLogType type,
 	display_log_viewer(ht, purple_log_get_logs(type, buddyname, account),
 			title, gtk_image_new_from_pixbuf(prpl_icon),
 			purple_log_get_total_size(type, buddyname, account));
-
-	if (prpl_icon)
+	if (prpl_icon){
 		g_object_unref(prpl_icon);
-	g_free(title);
+	}
+	fprintf(stderr,"\n##### END pidgin_log_show #####\n\n");
 }
 
 void pidgin_log_show_contact(PurpleContact *contact) {
@@ -808,8 +875,7 @@ void pidgin_log_show_contact(PurpleConta
 	g_free(title);
 }
 
-void pidgin_syslog_show()
-{
+void pidgin_syslog_show(){
 	GList *accounts = NULL;
 	GList *logs = NULL;
 
@@ -836,15 +902,13 @@ void *
  ****************************************************************************/
 
 void *
-pidgin_log_get_handle(void)
-{
+pidgin_log_get_handle(void){
 	static int handle;
 
 	return &handle;
 }
 
-void pidgin_log_init(void)
-{
+void pidgin_log_init(void){
 	void *handle = pidgin_log_get_handle();
 
 	purple_signal_register(handle, "log-displaying",
@@ -857,7 +921,6 @@ void
 }
 
 void
-pidgin_log_uninit(void)
-{
+pidgin_log_uninit(void){
 	purple_signals_unregister_by_instance(pidgin_log_get_handle());
 }
============================================================
--- pidgin/gtklog.h	beebb1eb384edcdea9fb0073e342b726f7dd685b
+++ pidgin/gtklog.h	e8c4987a0a34800dc5890af15e85eb90087712df
@@ -55,6 +55,7 @@ void pidgin_log_show_contact(PurpleConta
 
 void pidgin_log_show(PurpleLogType type, const char *buddyname, PurpleAccount *account);
 void pidgin_log_show_contact(PurpleContact *contact);
+void pidgin_log_show_global();
 
 void pidgin_syslog_show(void);
 


More information about the Commits mailing list