annotate src/gtklog.c @ 13075:4b7a8787432c

[gaim-migrate @ 15437] If the username in /etc/passwd is not utf8, don't write it to accounts.xml committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 30 Jan 2006 06:22:39 +0000
parents cb36bc2db7c5
children 0aa231ebbfd5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file gtklog.c GTK+ Log viewer
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * @ingroup gtkui
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 *
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * gaim
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7685
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7685
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7685
diff changeset
9 * source distribution.
7537
083427fd8ba8 [gaim-migrate @ 8150]
Christian Hammond <chipx86@chipx86.com>
parents: 7535
diff changeset
10 *
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * (at your option) any later version.
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * GNU General Public License for more details.
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 */
9791
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9624
diff changeset
25 #include "internal.h"
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9624
diff changeset
26 #include "gtkgaim.h"
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "account.h"
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "gtkblist.h"
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "gtkimhtml.h"
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "gtklog.h"
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "gtkutils.h"
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "log.h"
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
34 #include "notify.h"
10636
0f5c5e6fb27f [gaim-migrate @ 12118]
Sean Egan <seanegan@gmail.com>
parents: 10574
diff changeset
35 #include "util.h"
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 static GHashTable *log_viewers = NULL;
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
38 static void populate_log_tree(GaimGtkLogViewer *lv);
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
39 static GaimGtkLogViewer *syslog_viewer = NULL;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 struct log_viewer_hash_t {
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
42 GaimLogType type;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 char *screenname;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 GaimAccount *account;
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
45 GaimContact *contact;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 };
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
48 static guint log_viewer_hash(gconstpointer data)
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 {
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
50 const struct log_viewer_hash_t *viewer = data;
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
51
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
52 if (viewer->contact != NULL)
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
53 return g_direct_hash(viewer->contact);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
54
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
55 return g_str_hash(viewer->screenname) +
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
56 g_str_hash(gaim_account_get_username(viewer->account));
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 }
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
59 static gboolean log_viewer_equal(gconstpointer y, gconstpointer z)
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 {
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
61 const struct log_viewer_hash_t *a, *b;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 int ret;
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
63 char *normal;
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
64
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
65 a = y;
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
66 b = z;
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
67
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
68 if (a->contact != NULL) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
69 if (b->contact != NULL)
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
70 return (a->contact == b->contact);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
71 else
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
72 return FALSE;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
73 } else {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
74 if (b->contact != NULL)
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
75 return FALSE;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
76 }
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
77
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
78 normal = g_strdup(gaim_normalize(a->account, a->screenname));
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
79 ret = (a->account == b->account) &&
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
80 !strcmp(normal, gaim_normalize(b->account, b->screenname));
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 g_free(normal);
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
82
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 return ret;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 }
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
86 static void search_cb(GtkWidget *button, GaimGtkLogViewer *lv)
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
87 {
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
88 const char *search_term = gtk_entry_get_text(GTK_ENTRY(lv->entry));
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
89 GList *logs;
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
90 GdkCursor *cursor;
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
91
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
92 if (lv->search != NULL)
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
93 g_free(lv->search);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
94
11585
46265a317bd3 [gaim-migrate @ 13855]
Nathan Walp <nwalp@pidgin.im>
parents: 11402
diff changeset
95 gtk_tree_store_clear(lv->treestore);
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
96 if (!(*search_term)) {
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
97 /* reset the tree */
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
98 populate_log_tree(lv);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
99 lv->search = NULL;
7537
083427fd8ba8 [gaim-migrate @ 8150]
Christian Hammond <chipx86@chipx86.com>
parents: 7535
diff changeset
100 gtk_imhtml_search_clear(GTK_IMHTML(lv->imhtml));
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
101 return;
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
102 }
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
103
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
104 lv->search = g_strdup(search_term);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
105
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
106 cursor = gdk_cursor_new(GDK_WATCH);
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
107 gdk_window_set_cursor(lv->window->window, cursor);
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
108 gdk_cursor_unref(cursor);
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
109 while (gtk_events_pending())
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
110 gtk_main_iteration();
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
111
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
112 for (logs = lv->logs; logs != NULL; logs = logs->next) {
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
113 char *read = gaim_log_read((GaimLog*)logs->data, NULL);
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
114 if (read && *read && gaim_strcasestr(read, search_term)) {
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
115 GtkTreeIter iter;
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
116 GaimLog *log = logs->data;
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
117 char title[64];
7676
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
118 char *title_utf8; /* temporary variable for utf8 conversion */
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
119
10636
0f5c5e6fb27f [gaim-migrate @ 12118]
Sean Egan <seanegan@gmail.com>
parents: 10574
diff changeset
120 gaim_strftime(title, sizeof(title), "%c", localtime(&log->time));
7676
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
121 title_utf8 = gaim_utf8_try_convert(title);
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
122 strncpy(title, title_utf8, sizeof(title));
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
123 g_free(title_utf8);
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
124
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
125 gtk_tree_store_append (lv->treestore, &iter, NULL);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
126 gtk_tree_store_set(lv->treestore, &iter,
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
127 0, title,
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
128 1, log, -1);
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
129 }
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10181
diff changeset
130 g_free(read);
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
131 }
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
132
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
133 gdk_window_set_cursor(lv->window->window, NULL);
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
134 }
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
135
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
136 static gboolean destroy_cb(GtkWidget *w, gint resp, struct log_viewer_hash_t *ht) {
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
137 GaimGtkLogViewer *lv = syslog_viewer;
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
138
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
139 if (ht != NULL) {
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
140 lv = g_hash_table_lookup(log_viewers, ht);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
141 g_hash_table_remove(log_viewers, ht);
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
142
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
143 if (ht->screenname != NULL)
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
144 g_free(ht->screenname);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
145
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
146 g_free(ht);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
147 } else
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
148 syslog_viewer = NULL;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
149
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
150 while (lv->logs != NULL) {
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
151 GList *logs2;
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
152
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
153 gaim_log_free((GaimLog *)lv->logs->data);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
154
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
155 logs2 = lv->logs->next;
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
156 g_list_free_1(lv->logs);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
157 lv->logs = logs2;
7533
66d6f5c4a14a [gaim-migrate @ 8146]
Sean Egan <seanegan@gmail.com>
parents: 7485
diff changeset
158 }
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
159
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
160 if (lv->search != NULL)
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
161 g_free(lv->search);
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
162
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
163 g_free(lv);
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
164 gtk_widget_destroy(w);
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
165
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
166 return TRUE;
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
167 }
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
168
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
169 static void log_row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, GaimGtkLogViewer *viewer) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
170 if (gtk_tree_view_row_expanded(tv, path))
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
171 gtk_tree_view_collapse_row(tv, path);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
172 else
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
173 gtk_tree_view_expand_row(tv, path, FALSE);
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
174 }
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
175
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
176 static void log_select_cb(GtkTreeSelection *sel, GaimGtkLogViewer *viewer) {
12838
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
177 GtkTreeIter iter;
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12232
diff changeset
178 GValue val;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 GtkTreeModel *model = GTK_TREE_MODEL(viewer->treestore);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 GaimLog *log = NULL;
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
181 GdkCursor *cursor;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 GaimLogReadFlags flags;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 char *read = NULL;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 char time[64];
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
186 if (!gtk_tree_selection_get_selected(sel, &model, &iter))
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 return;
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12232
diff changeset
188
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12232
diff changeset
189 val.g_type = 0;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 gtk_tree_model_get_value (model, &iter, 1, &val);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 log = g_value_get_pointer(&val);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 g_value_unset(&val);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
194 if (log == NULL)
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 return;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
197 /* When we set the initial log, this gets called and the window is still NULL. */
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
198 if (viewer->window->window != NULL)
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
199 {
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
200 cursor = gdk_cursor_new(GDK_WATCH);
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
201 gdk_window_set_cursor(viewer->window->window, cursor);
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
202 gdk_cursor_unref(cursor);
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
203 while (gtk_events_pending())
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
204 gtk_main_iteration();
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
205 }
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
206
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
207 if (log->type != GAIM_LOG_SYSTEM) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
208 char *title;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
209 char *title_utf8; /* temporary variable for utf8 conversion */
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
210
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
211 gaim_strftime(time, sizeof(time), "%c", localtime(&log->time));
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
212
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
213 if (log->type == GAIM_LOG_CHAT)
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
214 title = g_strdup_printf(_("Conversation in %s on %s"), log->name, time);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
215 else
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
216 title = g_strdup_printf(_("Conversation with %s on %s"), log->name, time);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
217
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
218 title_utf8 = gaim_utf8_try_convert(title);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
219 g_free(title);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
220
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
221 title = g_strdup_printf("<span size='larger' weight='bold'>%s</span>", title_utf8);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
222 g_free(title_utf8);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
223
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
224 gtk_label_set_markup(GTK_LABEL(viewer->label), title);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
225 g_free(title);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
226 }
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
227
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 read = gaim_log_read(log, &flags);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 viewer->flags = flags;
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
230
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 gtk_imhtml_clear(GTK_IMHTML(viewer->imhtml));
10645
6480697e907b [gaim-migrate @ 12157]
Sean Egan <seanegan@gmail.com>
parents: 10636
diff changeset
232 gtk_imhtml_set_protocol_name(GTK_IMHTML(viewer->imhtml),
6480697e907b [gaim-migrate @ 12157]
Sean Egan <seanegan@gmail.com>
parents: 10636
diff changeset
233 gaim_account_get_protocol_name(log->account));
12838
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
234
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
235 gaim_signal_emit(gaim_gtk_log_get_handle(), "log-displaying", viewer, log);
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
236
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10181
diff changeset
237 gtk_imhtml_append_text(GTK_IMHTML(viewer->imhtml), read,
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
238 GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_SCROLL |
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 ((flags & GAIM_LOG_READ_NO_NEWLINE) ? GTK_IMHTML_NO_NEWLINE : 0));
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
240 g_free(read);
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
241
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
242 if (viewer->search != NULL) {
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10181
diff changeset
243 gtk_imhtml_search_clear(GTK_IMHTML(viewer->imhtml));
7537
083427fd8ba8 [gaim-migrate @ 8150]
Christian Hammond <chipx86@chipx86.com>
parents: 7535
diff changeset
244 gtk_imhtml_search_find(GTK_IMHTML(viewer->imhtml), viewer->search);
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10181
diff changeset
245 }
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
246
12232
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
247 /* When we set the initial log, this gets called and the window is still NULL. */
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
248 if (viewer->window->window != NULL)
375f1f3817a8 [gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents: 11869
diff changeset
249 gdk_window_set_cursor(viewer->window->window, NULL);
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 }
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 /* I want to make this smarter, but haven't come up with a cool algorithm to do so, yet.
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 * I want the tree to be divided into groups like "Today," "Yesterday," "Last week,"
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 * "August," "2002," etc. based on how many conversation took place in each subdivision.
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 *
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 * For now, I'll just make it a flat list.
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 */
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 static void populate_log_tree(GaimGtkLogViewer *lv)
11585
46265a317bd3 [gaim-migrate @ 13855]
Nathan Walp <nwalp@pidgin.im>
parents: 11402
diff changeset
259 /* Logs are made from trees in real life.
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 This is a tree made from logs */
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 {
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
262 char month[30];
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
263 char title[64];
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
264 char prev_top_month[30] = "";
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
265 char *utf8_tmp; /* temporary variable for utf8 conversion */
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
266 GtkTreeIter toplevel, child;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 GList *logs = lv->logs;
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
268
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
269 while (logs != NULL) {
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 GaimLog *log = logs->data;
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
271
10636
0f5c5e6fb27f [gaim-migrate @ 12118]
Sean Egan <seanegan@gmail.com>
parents: 10574
diff changeset
272 gaim_strftime(month, sizeof(month), "%B %Y", localtime(&log->time));
0f5c5e6fb27f [gaim-migrate @ 12118]
Sean Egan <seanegan@gmail.com>
parents: 10574
diff changeset
273 gaim_strftime(title, sizeof(title), "%c", localtime(&log->time));
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
274
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
275 /* do utf8 conversions */
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
276 utf8_tmp = gaim_utf8_try_convert(month);
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
277 strncpy(month, utf8_tmp, sizeof(month));
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10181
diff changeset
278 g_free(utf8_tmp);
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
279 utf8_tmp = gaim_utf8_try_convert(title);
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
280 strncpy(title, utf8_tmp, sizeof(title));
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
281 g_free(utf8_tmp);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
282
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
283 if (strncmp(month, prev_top_month, sizeof(month)) != 0) {
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
284 /* top level */
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
285 gtk_tree_store_append(lv->treestore, &toplevel, NULL);
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
286 gtk_tree_store_set(lv->treestore, &toplevel, 0, month, 1, NULL, -1);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
287
10680
dcbbad970e0d [gaim-migrate @ 12226]
Mark Doliner <mark@kingant.net>
parents: 10669
diff changeset
288 strncpy(prev_top_month, month, sizeof(prev_top_month));
dcbbad970e0d [gaim-migrate @ 12226]
Mark Doliner <mark@kingant.net>
parents: 10669
diff changeset
289 }
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
290
10680
dcbbad970e0d [gaim-migrate @ 12226]
Mark Doliner <mark@kingant.net>
parents: 10669
diff changeset
291 /* sub */
dcbbad970e0d [gaim-migrate @ 12226]
Mark Doliner <mark@kingant.net>
parents: 10669
diff changeset
292 gtk_tree_store_append(lv->treestore, &child, &toplevel);
dcbbad970e0d [gaim-migrate @ 12226]
Mark Doliner <mark@kingant.net>
parents: 10669
diff changeset
293 gtk_tree_store_set(lv->treestore, &child, 0, title, 1, log, -1);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
294
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 logs = logs->next;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 }
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 }
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
299 static GaimGtkLogViewer *display_log_viewer(struct log_viewer_hash_t *ht, GList *logs,
11585
46265a317bd3 [gaim-migrate @ 13855]
Nathan Walp <nwalp@pidgin.im>
parents: 11402
diff changeset
300 const char *title, GdkPixbuf *pixbuf, int log_size)
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
301 {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
302 GaimGtkLogViewer *lv;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
303 GtkWidget *title_box;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
304 char *text;
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
305 GtkWidget *pane;
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
306 GtkWidget *sw;
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
307 GtkCellRenderer *rend;
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
308 GtkTreeViewColumn *col;
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
309 GtkTreeSelection *sel;
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11769
diff changeset
310 #if GTK_CHECK_VERSION(2,2,0)
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
311 GtkTreePath *path_to_first_log;
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11769
diff changeset
312 #endif
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
313 GtkWidget *vbox;
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
314 GtkWidget *frame;
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
315 GtkWidget *hbox;
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
316 GtkWidget *button;
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
317 GtkWidget *size_label;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 lv = g_new0(GaimGtkLogViewer, 1);
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
320 lv->logs = logs;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
321
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
322 if (logs == NULL)
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
323 {
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
324 /* No logs were found. */
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
325 const char *log_preferences = NULL;
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
326
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
327 if (ht == NULL) {
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
328 if (!gaim_prefs_get_bool("/core/logging/log_system"))
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
329 log_preferences = _("System events will only be logged if the \"Log all status changes to system log\" preference is enabled.");
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
330 } else {
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
331 if (ht->type == GAIM_LOG_IM) {
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
332 if (!gaim_prefs_get_bool("/core/logging/log_ims"))
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
333 log_preferences = _("Instant messages will only be logged if the \"Log all instant messages\" preference is enabled.");
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
334 } else if (ht->type == GAIM_LOG_CHAT) {
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
335 if (!gaim_prefs_get_bool("/core/logging/log_chats"))
11869
3ba50c385299 [gaim-migrate @ 14160]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11780
diff changeset
336 log_preferences = _("Chats will only be logged if the \"Log all chats\" preference is enabled.");
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
337 }
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
338 }
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
339
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
340 gaim_notify_info(NULL, title, _("No logs were found"), log_preferences);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
341 return NULL;
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
342 }
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
343
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
344 if (ht != NULL)
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
345 g_hash_table_insert(log_viewers, ht, lv);
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 /* Window ***********/
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
348 lv->window = gtk_dialog_new_with_buttons(title, NULL, 0,
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 11004
diff changeset
350 gtk_container_set_border_width (GTK_CONTAINER(lv->window), GAIM_HIG_BOX_SPACE);
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 gtk_dialog_set_has_separator(GTK_DIALOG(lv->window), FALSE);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(lv->window)->vbox), 0);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
353 g_signal_connect(G_OBJECT(lv->window), "response",
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
354 G_CALLBACK(destroy_cb), ht);
11004
a3d3729a9130 [gaim-migrate @ 12859]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10884
diff changeset
355 gtk_window_set_role(GTK_WINDOW(lv->window), "log_viewer");
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
356
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
357 /* Icon *************/
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
358 if (pixbuf != NULL) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
359 GdkPixbuf *scale;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
360 GtkWidget *icon;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 11004
diff changeset
362 title_box = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 11004
diff changeset
363 gtk_container_set_border_width(GTK_CONTAINER(title_box), GAIM_HIG_BOX_SPACE);
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
364 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), title_box, FALSE, FALSE, 0);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
365
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
366 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
367 icon = gtk_image_new_from_pixbuf(scale);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
368 gtk_box_pack_start(GTK_BOX(title_box), icon, FALSE, FALSE, 0);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
369 g_object_unref(G_OBJECT(pixbuf));
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
370 g_object_unref(G_OBJECT(scale));
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
371 } else
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
372 title_box = GTK_DIALOG(lv->window)->vbox;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 /* Label ************/
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
375 lv->label = gtk_label_new(NULL);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
376
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
377 text = g_strdup_printf("<span size='larger' weight='bold'>%s</span>", title);
9624
abacf29577b2 [gaim-migrate @ 10468]
Sean Egan <seanegan@gmail.com>
parents: 9435
diff changeset
378
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
379 gtk_label_set_markup(GTK_LABEL(lv->label), text);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
380 gtk_misc_set_alignment(GTK_MISC(lv->label), 0, 0);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
381 gtk_box_pack_start(GTK_BOX(title_box), lv->label, FALSE, FALSE, 0);
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 g_free(text);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
384 /* Pane *************/
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
385 pane = gtk_hpaned_new();
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
386 gtk_container_set_border_width(GTK_CONTAINER(pane), GAIM_HIG_BOX_SPACE);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
387 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), pane, TRUE, TRUE, 0);
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
389 /* List *************/
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
390 sw = gtk_scrolled_window_new (NULL, NULL);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
391 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
392 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
393 gtk_paned_add1(GTK_PANED(pane), sw);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
394 lv->treestore = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
395 lv->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (lv->treestore));
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
396 rend = gtk_cell_renderer_text_new();
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
397 col = gtk_tree_view_column_new_with_attributes ("time", rend, "markup", 0, NULL);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
398 gtk_tree_view_append_column (GTK_TREE_VIEW(lv->treeview), col);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
399 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (lv->treeview), FALSE);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
400 gtk_container_add (GTK_CONTAINER (sw), lv->treeview);
11402
3b95804caea4 [gaim-migrate @ 13637]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
401
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
402 populate_log_tree(lv);
11402
3b95804caea4 [gaim-migrate @ 13637]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
403
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
404 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (lv->treeview));
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
405 g_signal_connect (G_OBJECT (sel), "changed",
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
406 G_CALLBACK (log_select_cb),
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
407 lv);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
408 g_signal_connect (G_OBJECT(lv->treeview), "row-activated",
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
409 G_CALLBACK(log_row_activated_cb),
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
410 lv);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
411 gaim_set_accessible_label(lv->treeview, lv->label);
11585
46265a317bd3 [gaim-migrate @ 13855]
Nathan Walp <nwalp@pidgin.im>
parents: 11402
diff changeset
412
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
413 /* Log size ************/
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
414 if(log_size) {
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
415 char *sz_txt = gaim_str_size_to_units(log_size);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
416 text = g_strdup_printf("<span weight='bold'>%s</span> %s", _("Total log size:"), sz_txt);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
417 size_label = gtk_label_new(NULL);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
418 gtk_label_set_markup(GTK_LABEL(size_label), text);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
419 /* gtk_paned_add1(GTK_PANED(pane), size_label); */
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
420 gtk_misc_set_alignment(GTK_MISC(size_label), 0, 0);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
421 gtk_box_pack_end(GTK_BOX(GTK_DIALOG(lv->window)->vbox), size_label, FALSE, FALSE, 0);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
422 g_free(sz_txt);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
423 g_free(text);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
424 }
11402
3b95804caea4 [gaim-migrate @ 13637]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
425
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
426 /* A fancy little box ************/
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
427 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
428 gtk_paned_add2(GTK_PANED(pane), vbox);
11402
3b95804caea4 [gaim-migrate @ 13637]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
429
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
430 /* Viewer ************/
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
431 frame = gaim_gtk_create_imhtml(FALSE, &lv->imhtml, NULL);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
432 gtk_widget_set_name(lv->imhtml, "gaim_gtklog_imhtml");
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
433 gtk_widget_set_size_request(lv->imhtml, 320, 200);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
434 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
435 gtk_widget_show(frame);
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
436
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
437 /* Search box **********/
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
438 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
439 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
440 lv->entry = gtk_entry_new();
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
441 gtk_box_pack_start(GTK_BOX(hbox), lv->entry, TRUE, TRUE, 0);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
442 button = gtk_button_new_from_stock(GTK_STOCK_FIND);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
443 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
444 g_signal_connect(GTK_ENTRY(lv->entry), "activate", G_CALLBACK(search_cb), lv);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
445 g_signal_connect(GTK_BUTTON(button), "activate", G_CALLBACK(search_cb), lv);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
446 g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(search_cb), lv);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
447
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11769
diff changeset
448 #if GTK_CHECK_VERSION(2,2,0)
11769
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
449 /* Show most recent log **********/
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
450 path_to_first_log = gtk_tree_path_new_from_string("0:0");
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
451 if (path_to_first_log)
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
452 {
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
453 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(lv->treeview), path_to_first_log);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
454 gtk_tree_selection_select_path(sel, path_to_first_log);
d56778d594d9 [gaim-migrate @ 14060]
Mark Doliner <mark@kingant.net>
parents: 11703
diff changeset
455 gtk_tree_path_free(path_to_first_log);
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
456 }
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11769
diff changeset
457 #endif
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 gtk_widget_show_all(lv->window);
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
460
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
461 return lv;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
462 }
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
463
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
464 void gaim_gtk_log_show(GaimLogType type, const char *screenname, GaimAccount *account) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
465 struct log_viewer_hash_t *ht = g_new0(struct log_viewer_hash_t, 1);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
466 GaimGtkLogViewer *lv = NULL;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
467 const char *name = screenname;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
468 char *title;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
469
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
470 g_return_if_fail(account != NULL);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
471 g_return_if_fail(screenname != NULL);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
472
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
473 ht->type = type;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
474 ht->screenname = g_strdup(screenname);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
475 ht->account = account;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
476
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
477 if (log_viewers == NULL) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
478 log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
479 } else if ((lv = g_hash_table_lookup(log_viewers, ht))) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
480 gtk_window_present(GTK_WINDOW(lv->window));
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
481 g_free(ht);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
482 return;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
483 }
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
484
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
485 if (type == GAIM_LOG_CHAT) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
486 GaimChat *chat;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
487
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
488 chat = gaim_blist_find_chat(account, screenname);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
489 if (chat != NULL)
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
490 name = gaim_chat_get_name(chat);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
491
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
492 title = g_strdup_printf(_("Conversations in %s"), name);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
493 } else {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
494 GaimBuddy *buddy;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
495
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
496 buddy = gaim_find_buddy(account, screenname);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
497 if (buddy != NULL)
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
498 name = gaim_buddy_get_contact_alias(buddy);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
499
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
500 title = g_strdup_printf(_("Conversations with %s"), name);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
501 }
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
502
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
503 display_log_viewer(ht, gaim_log_get_logs(type, screenname, account),
11585
46265a317bd3 [gaim-migrate @ 13855]
Nathan Walp <nwalp@pidgin.im>
parents: 11402
diff changeset
504 title, gaim_gtk_create_prpl_icon(account), gaim_log_get_total_size(type, screenname, account));
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
505 g_free(title);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
506 }
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
507
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
508 void gaim_gtk_log_show_contact(GaimContact *contact) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
509 struct log_viewer_hash_t *ht = g_new0(struct log_viewer_hash_t, 1);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
510 GaimBlistNode *child;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
511 GaimGtkLogViewer *lv = NULL;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
512 GList *logs = NULL;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
513 char *filename;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
514 GdkPixbuf *pixbuf;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
515 const char *name = NULL;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
516 char *title;
11585
46265a317bd3 [gaim-migrate @ 13855]
Nathan Walp <nwalp@pidgin.im>
parents: 11402
diff changeset
517 int total_log_size = 0;
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
518
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
519 g_return_if_fail(contact != NULL);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
520
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
521 ht->type = GAIM_LOG_IM;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
522 ht->contact = contact;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
523
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
524 if (log_viewers == NULL) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
525 log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
526 } else if ((lv = g_hash_table_lookup(log_viewers, ht))) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
527 gtk_window_present(GTK_WINDOW(lv->window));
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
528 g_free(ht);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
529 return;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
530 }
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
531
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
532 for (child = contact->node.child ; child ; child = child->next) {
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
533 if (!GAIM_BLIST_NODE_IS_BUDDY(child))
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
534 continue;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
535
11703
a53cef8bd22b [gaim-migrate @ 13994]
Richard Laager <rlaager@wiktel.com>
parents: 11700
diff changeset
536 logs = g_list_concat(gaim_log_get_logs(GAIM_LOG_IM, ((GaimBuddy *)child)->name,
a53cef8bd22b [gaim-migrate @ 13994]
Richard Laager <rlaager@wiktel.com>
parents: 11700
diff changeset
537 ((GaimBuddy *)child)->account), logs);
11585
46265a317bd3 [gaim-migrate @ 13855]
Nathan Walp <nwalp@pidgin.im>
parents: 11402
diff changeset
538 total_log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy *)child)->name, ((GaimBuddy *)child)->account);
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
539 }
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
540 logs = g_list_sort(logs, gaim_log_compare);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
541
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
542 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", "online.png", NULL);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
543 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
544 g_free(filename);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
545
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
546 if (contact->alias != NULL)
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
547 name = contact->alias;
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
548 else if (contact->priority != NULL)
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
549 name = gaim_buddy_get_contact_alias(contact->priority);
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
550
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
551 title = g_strdup_printf(_("Conversations with %s"), name);
11585
46265a317bd3 [gaim-migrate @ 13855]
Nathan Walp <nwalp@pidgin.im>
parents: 11402
diff changeset
552 display_log_viewer(ht, logs, title, pixbuf, total_log_size);
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
553 g_free(title);
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554 }
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
555
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
556 void gaim_gtk_syslog_show()
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
557 {
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
558 GList *accounts = NULL;
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
559 GList *logs = NULL;
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
560
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
561 if (syslog_viewer != NULL) {
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
562 gtk_window_present(GTK_WINDOW(syslog_viewer->window));
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
563 return;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
564 }
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
565
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
566 for(accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) {
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
567
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
568 GaimAccount *account = (GaimAccount *)accounts->data;
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
569 if(gaim_find_prpl(gaim_account_get_protocol_id(account)) == NULL)
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
570 continue;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
571
11703
a53cef8bd22b [gaim-migrate @ 13994]
Richard Laager <rlaager@wiktel.com>
parents: 11700
diff changeset
572 logs = g_list_concat(gaim_log_get_system_logs(account), logs);
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
573 }
10663
241d2e62bed2 [gaim-migrate @ 12202]
Sean Egan <seanegan@gmail.com>
parents: 10645
diff changeset
574 logs = g_list_sort(logs, gaim_log_compare);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
575
11585
46265a317bd3 [gaim-migrate @ 13855]
Nathan Walp <nwalp@pidgin.im>
parents: 11402
diff changeset
576 syslog_viewer = display_log_viewer(NULL, logs, _("System Log"), NULL, 0);
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
577 }
12838
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
578
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
579 /****************************************************************************
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
580 * GTK+ LOG SUBSYSTEM *******************************************************
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
581 ****************************************************************************/
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
582
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
583 void *
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
584 gaim_gtk_log_get_handle(void)
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
585 {
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
586 static int handle;
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
587
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
588 return &handle;
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
589 }
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
590
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
591 void gaim_gtk_log_init(void)
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
592 {
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
593 void *handle = gaim_gtk_log_get_handle();
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
594
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
595 gaim_signal_register(handle, "log-displaying",
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
596 gaim_marshal_VOID__POINTER_POINTER,
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
597 NULL, 2,
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
598 gaim_value_new(GAIM_TYPE_BOXED,
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
599 "GaimGtkLogViewer *"),
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
600 gaim_value_new(GAIM_TYPE_SUBTYPE,
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
601 GAIM_SUBTYPE_LOG));
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
602 }
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
603
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
604 void
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
605 gaim_gtk_log_uninit(void)
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
606 {
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
607 gaim_signals_unregister_by_instance(gaim_gtk_log_get_handle());
cb36bc2db7c5 [gaim-migrate @ 15186]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
608 }