annotate src/gtklog.c @ 10636:0f5c5e6fb27f

[gaim-migrate @ 12118] The strftime warnings fiunally got to me, so I made gaim_strftime to work around it. Turns out KingAnt had already discovered this solution for oscar.c but left it #iffed out. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 24 Feb 2005 01:11:17 +0000
parents 77ef3f2f0df8
children 6480697e907b
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 "util.h"
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "gtkblist.h"
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "gtkimhtml.h"
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "gtklog.h"
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "gtkutils.h"
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "log.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 {
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 char *screenname;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 GaimAccount *account;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 };
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
46 static guint log_viewer_hash(gconstpointer data)
7432
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 const struct log_viewer_hash_t *viewer = data;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 return g_str_hash(viewer->screenname) + g_str_hash(gaim_account_get_username(viewer->account));
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
50
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 }
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
53 static gint log_viewer_equal(gconstpointer y, gconstpointer z)
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 {
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
55 const struct log_viewer_hash_t *a, *b;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 int ret;
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
57 char *normal;
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
58
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
59 a = y;
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
60 b = z;
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
61
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
62 normal = g_strdup(gaim_normalize(a->account, a->screenname));
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
63 ret = (a->account == b->account) &&
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
64 !strcmp(normal, gaim_normalize(b->account, b->screenname));
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 g_free(normal);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 return ret;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 }
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
69 static void search_cb(GtkWidget *button, GaimGtkLogViewer *lv)
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
70 {
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
71 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
72 GList *logs;
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
73 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
74
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
75 if (lv->search)
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
76 g_free(lv->search);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
77
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
78 gtk_tree_store_clear(lv->treestore);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
79 if (strlen(search_term) == 0) {/* reset the tree */
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
80 populate_log_tree(lv);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
81 lv->search = NULL;
7537
083427fd8ba8 [gaim-migrate @ 8150]
Christian Hammond <chipx86@chipx86.com>
parents: 7535
diff changeset
82 gtk_imhtml_search_clear(GTK_IMHTML(lv->imhtml));
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
83 return;
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
84 }
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
85
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
86 lv->search = g_strdup(search_term);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
87
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
88 gdk_window_set_cursor(lv->window->window, cursor);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
89 while (gtk_events_pending())
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
90 gtk_main_iteration();
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
91 gdk_cursor_unref(cursor);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
92
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
93 for (logs = lv->logs; logs != NULL; logs = logs->next) {
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
94 char *read = gaim_log_read((GaimLog*)logs->data, NULL);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
95 if (gaim_strcasestr(read, search_term)) {
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
96 GtkTreeIter iter;
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
97 GaimLog *log = logs->data;
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
98 char title[64];
7676
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
99 char *title_utf8; /* temporary variable for utf8 conversion */
10636
0f5c5e6fb27f [gaim-migrate @ 12118]
Sean Egan <seanegan@gmail.com>
parents: 10574
diff changeset
100 gaim_strftime(title, sizeof(title), "%c", localtime(&log->time));
7676
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
101 title_utf8 = gaim_utf8_try_convert(title);
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
102 strncpy(title, title_utf8, sizeof(title));
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
103 g_free(title_utf8);
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
104 gtk_tree_store_append (lv->treestore, &iter, NULL);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
105 gtk_tree_store_set(lv->treestore, &iter,
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
106 0, title,
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
107 1, log, -1);
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
108 }
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10181
diff changeset
109 g_free(read);
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
110 }
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
111
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
112
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
113 cursor = gdk_cursor_new(GDK_LEFT_PTR);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
114 gdk_window_set_cursor(lv->window->window, cursor);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
115 gdk_cursor_unref(cursor);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
116 }
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
117
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
118 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
119 GaimGtkLogViewer *lv = syslog_viewer;
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
120
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
121 if(ht != NULL){
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
122 lv = g_hash_table_lookup(log_viewers, ht);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
123 g_hash_table_remove(log_viewers, ht);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
124 g_free(ht->screenname);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
125 g_free(ht);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
126 } else
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
127 syslog_viewer = NULL;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
128
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
129 while (lv->logs) {
7533
66d6f5c4a14a [gaim-migrate @ 8146]
Sean Egan <seanegan@gmail.com>
parents: 7485
diff changeset
130 GaimLog *log = lv->logs->data;
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
131 GList *logs2;
7685
9e122b8f564f [gaim-migrate @ 8329]
Ethan Blanton <elb@pidgin.im>
parents: 7676
diff changeset
132 gaim_log_free(log);
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
133 logs2 = lv->logs->next;
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
134 g_list_free_1(lv->logs);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
135 lv->logs = logs2;
7533
66d6f5c4a14a [gaim-migrate @ 8146]
Sean Egan <seanegan@gmail.com>
parents: 7485
diff changeset
136 }
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
137 if (lv->search)
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
138 g_free(lv->search);
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
139 g_free(lv);
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
140 gtk_widget_destroy(w);
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
141
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
142 return TRUE;
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
143 }
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
144 #if 0
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
145 static gboolean destroy_syslog_cb(GtkWidget *w, gint resp, void *cb)
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
146 {
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
147 while (syslog_viewer->logs) {
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
148 GaimLog *log = syslog_viewer->logs->data;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
149 GList *logs2;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
150 gaim_log_free(log);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
151 logs2 = syslog_viewer->logs->next;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
152 g_list_free_1(syslog_viewer->logs);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
153 syslog_viewer->logs = logs2;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
154 }
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
155 if (syslog_viewer->search)
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
156 g_free(syslog_viewer->search);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
157 g_free(syslog_viewer);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
158 syslog_viewer = NULL;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
159 gtk_widget_destroy(w);
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
160
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
161 return TRUE;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
162 }
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
163 #endif
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
164 static void log_select_cb(GtkTreeSelection *sel, GaimGtkLogViewer *viewer) {
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 GtkTreeIter iter;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 GValue val = { 0, };
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 GtkTreeModel *model = GTK_TREE_MODEL(viewer->treestore);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 GaimLog *log = NULL;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 GaimLogReadFlags flags;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 char *read = NULL;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 char time[64];
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 char *title;
7676
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
174 char *title_utf8; /* temporary variable for utf8 conversion */
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 if (! gtk_tree_selection_get_selected (sel, &model, &iter))
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 return;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 gtk_tree_model_get_value (model, &iter, 1, &val);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 log = g_value_get_pointer(&val);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 g_value_unset(&val);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 if (!log)
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 return;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 read = gaim_log_read(log, &flags);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 viewer->flags = flags;
10636
0f5c5e6fb27f [gaim-migrate @ 12118]
Sean Egan <seanegan@gmail.com>
parents: 10574
diff changeset
187 gaim_strftime(time, sizeof(time), "%c", localtime(&log->time));
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 title = g_strdup_printf("%s - %s", log->name, time);
7676
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
189 title_utf8 = gaim_utf8_try_convert(title);
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
190 g_free(title);
5c5acdf8b982 [gaim-migrate @ 8320]
Sean Egan <seanegan@gmail.com>
parents: 7537
diff changeset
191 title = title_utf8;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 gtk_window_set_title(GTK_WINDOW(viewer->window), title);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 gtk_imhtml_clear(GTK_IMHTML(viewer->imhtml));
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10181
diff changeset
194 gtk_imhtml_append_text(GTK_IMHTML(viewer->imhtml), read,
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
195 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
196 ((flags & GAIM_LOG_READ_NO_NEWLINE) ? GTK_IMHTML_NO_NEWLINE : 0));
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
197
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
198 if (viewer->search)
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10181
diff changeset
199 {
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10181
diff changeset
200 gtk_imhtml_search_clear(GTK_IMHTML(viewer->imhtml));
7537
083427fd8ba8 [gaim-migrate @ 8150]
Christian Hammond <chipx86@chipx86.com>
parents: 7535
diff changeset
201 gtk_imhtml_search_find(GTK_IMHTML(viewer->imhtml), viewer->search);
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10181
diff changeset
202 }
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
203
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 g_free(read);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 g_free(title);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 }
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 /* 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
209 * 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
210 * "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
211 *
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 * For now, I'll just make it a flat list.
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 */
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 static void populate_log_tree(GaimGtkLogViewer *lv)
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 /* Logs are made from trees in real life.
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 This is a tree made from logs */
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 {
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
218 char month[30];
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7436
diff changeset
219 char title[64];
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
220 char prev_top_month[30];
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
221 char *utf8_tmp; /* temporary variable for utf8 conversion */
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
222 GtkTreeIter toplevel, child;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 GList *logs = lv->logs;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 while (logs) {
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 GaimLog *log = logs->data;
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
226
10636
0f5c5e6fb27f [gaim-migrate @ 12118]
Sean Egan <seanegan@gmail.com>
parents: 10574
diff changeset
227 gaim_strftime(month, sizeof(month), "%B %Y", localtime(&log->time));
0f5c5e6fb27f [gaim-migrate @ 12118]
Sean Egan <seanegan@gmail.com>
parents: 10574
diff changeset
228 gaim_strftime(title, sizeof(title), "%c", localtime(&log->time));
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
229
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
230 /* do utf8 conversions */
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
231 utf8_tmp = gaim_utf8_try_convert(month);
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
232 strncpy(month, utf8_tmp, sizeof(month));
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10181
diff changeset
233 g_free(utf8_tmp);
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
234 utf8_tmp = gaim_utf8_try_convert(title);
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
235 strncpy(title, utf8_tmp, sizeof(title));
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
236 g_free(utf8_tmp);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
237
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
238 if (strncmp(month, prev_top_month, sizeof(month)) != 0) {
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
239 /* top level */
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
240 gtk_tree_store_append(lv->treestore, &toplevel, NULL);
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
241 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
242
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
243 /* sub */
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
244 gtk_tree_store_append(lv->treestore, &child, &toplevel);
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
245 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
246
9435
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
247 strncpy(prev_top_month, month, sizeof(prev_top_month));
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
248 } else {
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
249 gtk_tree_store_append(lv->treestore, &child, &toplevel);
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
250 gtk_tree_store_set(lv->treestore, &child, 0, title, 1, log, -1);
5635f71aa5db [gaim-migrate @ 10256]
Luke Schierer <lschiere@pidgin.im>
parents: 9192
diff changeset
251 }
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
252
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 logs = logs->next;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 }
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
9917
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9791
diff changeset
257 void gaim_gtk_log_show(GaimLogType type, const char *screenname, GaimAccount *account) {
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 /* if (log_viewers && g_hash_table */
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 GtkWidget *hbox, *vbox;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 GdkPixbuf *pixbuf, *scale;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 GtkCellRenderer *rend;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 GtkTreeViewColumn *col;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 GaimGtkLogViewer *lv = NULL;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 GtkTreeSelection *sel;
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
265 GtkWidget *icon, *label, *pane, *sw, *button, *frame;
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 GList *logs;
9624
abacf29577b2 [gaim-migrate @ 10468]
Sean Egan <seanegan@gmail.com>
parents: 9435
diff changeset
267 char *text ,*ttext;
7436
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7432
diff changeset
268 struct log_viewer_hash_t *ht = g_new0(struct log_viewer_hash_t, 1);
7cdbd2eb7546 [gaim-migrate @ 8041]
Nathan Walp <nwalp@pidgin.im>
parents: 7432
diff changeset
269
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 ht->screenname = g_strdup(screenname);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 ht->account = account;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 if (!log_viewers) {
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 } else if ((lv = g_hash_table_lookup(log_viewers, ht))) {
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 gtk_window_present(GTK_WINDOW(lv->window));
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
277 g_free(ht);
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 return;
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 }
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 lv = g_new0(GaimGtkLogViewer, 1);
9917
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9791
diff changeset
282 lv->logs = logs = gaim_log_get_logs(type, screenname, account);
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 g_hash_table_insert(log_viewers, ht, lv);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 /* Window ***********/
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
286 lv->window = gtk_dialog_new_with_buttons(screenname, NULL, 0,
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 gtk_container_set_border_width (GTK_CONTAINER(lv->window), 6);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 gtk_dialog_set_has_separator(GTK_DIALOG(lv->window), FALSE);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 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
291 g_signal_connect(G_OBJECT(lv->window), "response",
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
292 G_CALLBACK(destroy_cb), ht);
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
293
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 hbox = gtk_hbox_new(FALSE, 6);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), hbox, FALSE, FALSE, 0);
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 /* Icon *************/
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 pixbuf = create_prpl_icon(account);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 icon = gtk_image_new_from_pixbuf(scale);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 g_object_unref(G_OBJECT(pixbuf));
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 g_object_unref(G_OBJECT(scale));
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 /* Label ************/
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 label = gtk_label_new(NULL);
9624
abacf29577b2 [gaim-migrate @ 10468]
Sean Egan <seanegan@gmail.com>
parents: 9435
diff changeset
308
abacf29577b2 [gaim-migrate @ 10468]
Sean Egan <seanegan@gmail.com>
parents: 9435
diff changeset
309 ttext = g_strdup_printf(_("Conversations with %s"), screenname);
abacf29577b2 [gaim-migrate @ 10468]
Sean Egan <seanegan@gmail.com>
parents: 9435
diff changeset
310 text = g_strdup_printf("<span size='larger' weight='bold'>%s</span>",ttext);
abacf29577b2 [gaim-migrate @ 10468]
Sean Egan <seanegan@gmail.com>
parents: 9435
diff changeset
311 g_free(ttext);
abacf29577b2 [gaim-migrate @ 10468]
Sean Egan <seanegan@gmail.com>
parents: 9435
diff changeset
312
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 gtk_label_set_markup(GTK_LABEL(label), text);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 g_free(text);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 /* Pane *************/
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 pane = gtk_hpaned_new();
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 gtk_container_set_border_width(GTK_CONTAINER(pane), 6);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), pane, TRUE, TRUE, 0);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
321
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 /* List *************/
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 sw = gtk_scrolled_window_new (NULL, NULL);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 gtk_paned_add1(GTK_PANED(pane), sw);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 lv->treestore = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 lv->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (lv->treestore));
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 rend = gtk_cell_renderer_text_new();
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 col = gtk_tree_view_column_new_with_attributes ("time", rend, "markup", 0, NULL);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 gtk_tree_view_append_column (GTK_TREE_VIEW(lv->treeview), col);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (lv->treeview), FALSE);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 gtk_container_add (GTK_CONTAINER (sw), lv->treeview);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 populate_log_tree(lv);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (lv->treeview));
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 g_signal_connect (G_OBJECT (sel), "changed",
7454
50f4386a8262 [gaim-migrate @ 8067]
Mark Doliner <mark@kingant.net>
parents: 7440
diff changeset
338 G_CALLBACK (log_select_cb),
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 lv);
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
340 gaim_set_accessible_label(lv->treeview, label);
8577
599d6ac9bbfe [gaim-migrate @ 9326]
Nathan Walp <nwalp@pidgin.im>
parents: 8573
diff changeset
341
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
342 /* A fancy little box ************/
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 vbox = gtk_vbox_new(FALSE, 6);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 gtk_paned_add2(GTK_PANED(pane), vbox);
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
345
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
346 /* Viewer ************/
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
347 frame = gaim_gtk_create_imhtml(FALSE, &lv->imhtml, NULL);
9005
230cf4032e3d [gaim-migrate @ 9780]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
348 gtk_widget_set_name(lv->imhtml, "gaim_gtklog_imhtml");
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 gtk_widget_set_size_request(lv->imhtml, 320, 200);
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
350 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
351 gtk_widget_show(frame);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
352
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 /* Search box **********/
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 hbox = gtk_hbox_new(FALSE, 6);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 lv->entry = gtk_entry_new();
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 gtk_box_pack_start(GTK_BOX(hbox), lv->entry, TRUE, TRUE, 0);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 button = gtk_button_new_from_stock(GTK_STOCK_FIND);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
360 g_signal_connect(GTK_ENTRY(lv->entry), "activate", G_CALLBACK(search_cb), lv);
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
361 g_signal_connect(GTK_BUTTON(button), "activate", G_CALLBACK(search_cb), lv);
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
362 g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(search_cb), lv);
7432
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 gtk_widget_show_all(lv->window);
31faec55ef8e [gaim-migrate @ 8037]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 }
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
366
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
367 void gaim_gtk_syslog_show()
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
368 {
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
369 GtkWidget *hbox, *vbox;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
370 GtkCellRenderer *rend;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
371 GtkTreeViewColumn *col;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
372 GtkTreeSelection *sel;
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
373 GtkWidget *label, *pane, *sw, *button, *frame;
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
374 char *text;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
375 GList *accounts = NULL;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
376
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
377 if (syslog_viewer != NULL) {
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
378 gtk_window_present(GTK_WINDOW(syslog_viewer->window));
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
379 return;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
380 }
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
381
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
382 syslog_viewer = g_new0(GaimGtkLogViewer, 1);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
383
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
384 for(accounts = gaim_accounts_get_all(); accounts != NULL;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
385 accounts = accounts->next) {
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
386 GList *logs;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
387 GaimAccount *account = (GaimAccount *)accounts->data;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
388 if(!gaim_find_prpl(gaim_account_get_protocol_id(account)))
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
389 continue;
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
390
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
391 logs = gaim_log_get_system_logs(account);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
392 syslog_viewer->logs = g_list_concat(syslog_viewer->logs, logs);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
393 }
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
394 syslog_viewer->logs = g_list_sort(syslog_viewer->logs, gaim_log_compare);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
395
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
396 /* Window ***********/
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
397 syslog_viewer->window = gtk_dialog_new_with_buttons(_("System Log"), NULL, 0,
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
398 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
399 gtk_container_set_border_width (GTK_CONTAINER(syslog_viewer->window), 6);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
400 gtk_dialog_set_has_separator(GTK_DIALOG(syslog_viewer->window), FALSE);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
401 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(syslog_viewer->window)->vbox), 0);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
402 g_signal_connect(G_OBJECT(syslog_viewer->window), "response",
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
403 G_CALLBACK(destroy_cb), NULL);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
404
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
405 hbox = gtk_hbox_new(FALSE, 6);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
406 gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
407 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(syslog_viewer->window)->vbox), hbox,
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
408 FALSE, FALSE, 0);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
409
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
410 /* Label ************/
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
411 label = gtk_label_new(NULL);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
412 text = g_strdup_printf("<span size='larger' weight='bold'>%s</span>",
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
413 _("System Log"));
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
414 gtk_label_set_markup(GTK_LABEL(label), text);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
415 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
416 g_free(text);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
417
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
418 /* Pane *************/
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
419 pane = gtk_hpaned_new();
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
420 gtk_container_set_border_width(GTK_CONTAINER(pane), 6);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
421 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(syslog_viewer->window)->vbox), pane,
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
422 TRUE, TRUE, 0);
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
423
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
424 /* List *************/
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
425 sw = gtk_scrolled_window_new (NULL, NULL);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
426 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
427 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
428 gtk_paned_add1(GTK_PANED(pane), sw);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
429 syslog_viewer->treestore = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
430 syslog_viewer->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (syslog_viewer->treestore));
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
431 rend = gtk_cell_renderer_text_new();
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
432 col = gtk_tree_view_column_new_with_attributes ("time", rend, "markup", 0, NULL);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
433 gtk_tree_view_append_column (GTK_TREE_VIEW(syslog_viewer->treeview), col);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
434 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (syslog_viewer->treeview), FALSE);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
435 gtk_container_add (GTK_CONTAINER (sw), syslog_viewer->treeview);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
436
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
437 gtk_widget_set_size_request(syslog_viewer->treeview, 170, 200);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
438 populate_log_tree(syslog_viewer);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
439
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
440 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (syslog_viewer->treeview));
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
441 g_signal_connect (G_OBJECT (sel), "changed",
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
442 G_CALLBACK (log_select_cb),
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
443 syslog_viewer);
9005
230cf4032e3d [gaim-migrate @ 9780]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
444
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
445 /* A fancy little box ************/
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
446 vbox = gtk_vbox_new(FALSE, 6);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
447 gtk_paned_add2(GTK_PANED(pane), vbox);
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
448
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
449 /* Viewer ************/
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
450 frame = gaim_gtk_create_imhtml(FALSE, &syslog_viewer->imhtml, NULL);
9005
230cf4032e3d [gaim-migrate @ 9780]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
451 gtk_widget_set_name(syslog_viewer->imhtml, "gaim_gtklog_imhtml");
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
452 gtk_widget_set_size_request(syslog_viewer->imhtml, 400, 200);
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
453 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
454 gtk_widget_show(frame);
9005
230cf4032e3d [gaim-migrate @ 9780]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
455
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
456 /* Search box **********/
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
457 hbox = gtk_hbox_new(FALSE, 6);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
458 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
459 syslog_viewer->entry = gtk_entry_new();
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
460 gtk_box_pack_start(GTK_BOX(hbox), syslog_viewer->entry, TRUE, TRUE, 0);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
461 button = gtk_button_new_from_stock(GTK_STOCK_FIND);
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
462 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
463 g_signal_connect(GTK_ENTRY(syslog_viewer->entry), "activate",
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
464 G_CALLBACK(search_cb), syslog_viewer);
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
465 g_signal_connect(GTK_BUTTON(button), "activate",
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
466 G_CALLBACK(search_cb), syslog_viewer);
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
467 g_signal_connect(GTK_BUTTON(button), "clicked",
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10175
diff changeset
468 G_CALLBACK(search_cb), syslog_viewer);
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
469
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 9917
diff changeset
470 gtk_widget_show_all(syslog_viewer->window);
8573
7dcd6f26e4a7 [gaim-migrate @ 9321]
Luke Schierer <lschiere@pidgin.im>
parents: 8137
diff changeset
471 }