pidgin: ae9d7912: Added "View All Logs" menu in the buddyl...
sadrul at pidgin.im
sadrul at pidgin.im
Thu Jun 5 06:25:43 EDT 2008
-----------------------------------------------------------------
Revision: ae9d7912dfb7c1627441484bfe471dd4d370d346
Ancestor: a4b1dc8ffb42dbdc2fed7229698a957e9529ed33
Author: sadrul at pidgin.im
Date: 2008-06-05T10:23:58
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ae9d7912dfb7c1627441484bfe471dd4d370d346
Modified files:
ChangeLog finch/gntblist.c finch/gntlog.c
ChangeLog:
Added "View All Logs" menu in the buddylist to display a list of all IM
logs.
-------------- next part --------------
============================================================
--- ChangeLog 1faf84786e1e74373d3e2b4229a1d2adc6ce8a19
+++ ChangeLog e5d7d1895de54297c3f54f89134fbfbe7dd5828f
@@ -20,6 +20,8 @@ version 2.5.0 (??/??/2008):
Finch:
* Added "Invite..." menu to chats.
+ * Added "View All Logs" menu in the buddylist to display a list of all IM
+ logs.
version 2.4.2 (05/17/2008):
libpurple:
============================================================
--- finch/gntblist.c 9c3de6e5483669e3038686979d484d1ea6602574
+++ finch/gntblist.c dc22e98b1be133fcce7af208888d9434faec6fb1
@@ -2851,6 +2851,12 @@ static void
}
static void
+view_all_logs_cb(GntMenuItem *item, gpointer n)
+{
+ finch_log_show(PURPLE_LOG_IM, NULL, NULL);
+}
+
+static void
menu_add_buddy_cb(GntMenuItem *item, gpointer null)
{
purple_blist_request_add_buddy(NULL, NULL, NULL, NULL);
@@ -2915,6 +2921,11 @@ create_menu(void)
gnt_menu_add_item(GNT_MENU(sub), item);
gnt_menuitem_set_callback(GNT_MENU_ITEM(item), view_log_cb, NULL);
+ item = gnt_menuitem_new(_("View All Logs"));
+ gnt_menuitem_set_id(GNT_MENU_ITEM(item), "view-all-logs");
+ gnt_menu_add_item(GNT_MENU(sub), item);
+ gnt_menuitem_set_callback(GNT_MENU_ITEM(item), view_all_logs_cb, NULL);
+
item = gnt_menuitem_new(_("Show"));
gnt_menu_add_item(GNT_MENU(sub), item);
subsub = gnt_menu_new(GNT_MENU_POPUP);
============================================================
--- finch/gntlog.c 033d31355f54f52de6c2263f58b8550ed1cd01a0
+++ finch/gntlog.c 42ac4af19deac2a04722299f5e6c82e10cfed445
@@ -61,8 +61,12 @@ static guint log_viewer_hash(gconstpoint
if (viewer->contact != NULL)
return g_direct_hash(viewer->contact);
- return g_str_hash(viewer->screenname) +
- g_str_hash(purple_account_get_username(viewer->account));
+ if (viewer->account) {
+ return g_str_hash(viewer->screenname) +
+ g_str_hash(purple_account_get_username(viewer->account));
+ }
+
+ return (guint)viewer;
}
static gboolean log_viewer_equal(gconstpointer y, gconstpointer z)
@@ -84,10 +88,14 @@ static gboolean log_viewer_equal(gconstp
return FALSE;
}
- normal = g_strdup(purple_normalize(a->account, a->screenname));
- ret = (a->account == b->account) &&
- !strcmp(normal, purple_normalize(b->account, b->screenname));
- g_free(normal);
+ if (a->screenname && b->screenname) {
+ normal = g_strdup(purple_normalize(a->account, a->screenname));
+ ret = (a->account == b->account) &&
+ !strcmp(normal, purple_normalize(b->account, b->screenname));
+ g_free(normal);
+ } else {
+ ret = (a == b);
+ }
return ret;
}
@@ -348,14 +356,28 @@ static FinchLogViewer *display_log_viewe
return lv;
}
-void finch_log_show(PurpleLogType type, const char *screenname, PurpleAccount *account) {
+static void
+our_logging_blows(PurpleLogSet *set, PurpleLogSet *setagain, GList **list)
+{
+ /* The iteration happens on the first list. So we use the shorter list in front */
+ if (set->type != PURPLE_LOG_IM)
+ return;
+ *list = g_list_concat(purple_log_get_logs(PURPLE_LOG_IM, set->name, set->account), *list);
+}
+
+void finch_log_show(PurpleLogType type, const char *screenname, PurpleAccount *account)
+{
struct log_viewer_hash_t *ht;
FinchLogViewer *lv = NULL;
const char *name = screenname;
char *title;
+ GList *logs = NULL;
+ int size = 0;
- g_return_if_fail(account != NULL);
- g_return_if_fail(screenname != NULL);
+ if (type != PURPLE_LOG_IM) {
+ g_return_if_fail(account != NULL);
+ g_return_if_fail(screenname != NULL);
+ }
ht = g_new0(struct log_viewer_hash_t, 1);
@@ -383,20 +405,35 @@ void finch_log_show(PurpleLogType type,
} else {
PurpleBuddy *buddy;
- buddy = purple_find_buddy(account, screenname);
- if (buddy != NULL)
- name = purple_buddy_get_contact_alias(buddy);
+ if (screenname) {
+ buddy = purple_find_buddy(account, screenname);
+ if (buddy != NULL)
+ name = purple_buddy_get_contact_alias(buddy);
+ title = g_strdup_printf(_("Conversations with %s"), name);
+ } else {
+ title = g_strdup(_("All Conversations"));
+ }
+ }
- title = g_strdup_printf(_("Conversations with %s"), name);
+ if (screenname) {
+ logs = purple_log_get_logs(type, screenname, account);
+ size = purple_log_get_total_size(type, screenname, account);
+ } else {
+ /* This will happen only for IMs */
+ GHashTable *table = purple_log_get_log_sets();
+ g_hash_table_foreach(table, (GHFunc)our_logging_blows, &logs);
+ g_hash_table_destroy(table);
+ logs = g_list_sort(logs, purple_log_compare);
+ size = 0;
}
- display_log_viewer(ht, purple_log_get_logs(type, screenname, account),
- title, purple_log_get_total_size(type, screenname, account));
+ display_log_viewer(ht, logs, title, size);
g_free(title);
}
-void finch_log_show_contact(PurpleContact *contact) {
+void finch_log_show_contact(PurpleContact *contact)
+{
struct log_viewer_hash_t *ht;
PurpleBlistNode *child;
FinchLogViewer *lv = NULL;
More information about the Commits
mailing list