Mon, 19 Mar 2007 06:01:29 +0000
More Gaim to Pidgin stuff
| 7432 | 1 | /** |
| 2 | * @file gtklog.c GTK+ Log viewer | |
| 3 | * @ingroup gtkui | |
| 4 | * | |
| 5 | * gaim | |
| 6 | * | |
| 8046 | 7 | * Gaim is the legal property of its developers, whose names are too numerous |
| 8 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 9 | * source distribution. | |
|
7537
4c3be2f554b1
[gaim-migrate @ 8150]
Christian Hammond <chipx86@chipx86.com>
parents:
7535
diff
changeset
|
10 | * |
| 7432 | 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 | */ | |
| 9791 | 25 | #include "internal.h" |
| 15577 | 26 | #include "pidgin.h" |
| 7432 | 27 | |
| 28 | #include "account.h" | |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
29 | #include "debug.h" |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
30 | #include "log.h" |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
31 | #include "notify.h" |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
32 | #include "request.h" |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
33 | #include "util.h" |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
34 | |
|
15639
4d29fa62453d
Use person icon for Person log viewer
Sean Egan <seanegan@pidgin.im>
parents:
15613
diff
changeset
|
35 | #include "gaimstock.h" |
| 7432 | 36 | #include "gtkblist.h" |
| 37 | #include "gtkimhtml.h" | |
| 38 | #include "gtklog.h" | |
| 39 | #include "gtkutils.h" | |
| 40 | ||
| 41 | static GHashTable *log_viewers = NULL; | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
42 | static void populate_log_tree(PidginLogViewer *lv); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
43 | static PidginLogViewer *syslog_viewer = NULL; |
| 7432 | 44 | |
| 45 | struct log_viewer_hash_t { | |
| 10663 | 46 | GaimLogType type; |
| 7432 | 47 | char *screenname; |
| 48 | GaimAccount *account; | |
| 10663 | 49 | GaimContact *contact; |
| 7432 | 50 | }; |
| 51 | ||
| 7440 | 52 | static guint log_viewer_hash(gconstpointer data) |
| 7432 | 53 | { |
| 7440 | 54 | const struct log_viewer_hash_t *viewer = data; |
| 55 | ||
| 10663 | 56 | if (viewer->contact != NULL) |
| 57 | return g_direct_hash(viewer->contact); | |
| 58 | ||
| 59 | return g_str_hash(viewer->screenname) + | |
| 60 | g_str_hash(gaim_account_get_username(viewer->account)); | |
| 7432 | 61 | } |
| 62 | ||
| 10663 | 63 | static gboolean log_viewer_equal(gconstpointer y, gconstpointer z) |
| 7432 | 64 | { |
| 7440 | 65 | const struct log_viewer_hash_t *a, *b; |
| 7432 | 66 | int ret; |
| 7440 | 67 | char *normal; |
| 68 | ||
| 69 | a = y; | |
| 70 | b = z; | |
| 71 | ||
| 10663 | 72 | if (a->contact != NULL) { |
| 73 | if (b->contact != NULL) | |
| 74 | return (a->contact == b->contact); | |
| 75 | else | |
| 76 | return FALSE; | |
| 77 | } else { | |
| 78 | if (b->contact != NULL) | |
| 79 | return FALSE; | |
| 80 | } | |
| 81 | ||
| 7440 | 82 | normal = g_strdup(gaim_normalize(a->account, a->screenname)); |
| 83 | ret = (a->account == b->account) && | |
| 84 | !strcmp(normal, gaim_normalize(b->account, b->screenname)); | |
| 7432 | 85 | g_free(normal); |
| 10663 | 86 | |
| 7432 | 87 | return ret; |
| 88 | } | |
| 89 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
90 | static void select_first_log(PidginLogViewer *lv) |
|
13569
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
91 | { |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
92 | GtkTreeModel *model; |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
93 | GtkTreeIter iter, it; |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
94 | GtkTreePath *path; |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
95 | |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
96 | model = GTK_TREE_MODEL(lv->treestore); |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
97 | |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
98 | if (!gtk_tree_model_get_iter_first(model, &iter)) |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
99 | return; |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
100 | |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
101 | path = gtk_tree_model_get_path(model, &iter); |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
102 | if (gtk_tree_model_iter_children(model, &it, &iter)) |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
103 | { |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
104 | gtk_tree_view_expand_row(GTK_TREE_VIEW(lv->treeview), path, TRUE); |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
105 | path = gtk_tree_model_get_path(model, &it); |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
106 | } |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
107 | |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
108 | gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(lv->treeview)), path); |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
109 | |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
110 | gtk_tree_path_free(path); |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
111 | } |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
112 | |
|
15060
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
113 | static const char *log_get_date(GaimLog *log) |
|
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
114 | { |
|
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
115 | if (log->tm) |
|
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
116 | return gaim_date_format_full(log->tm); |
|
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
117 | else |
|
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
118 | return gaim_date_format_full(localtime(&log->time)); |
|
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
119 | } |
|
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
120 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
121 | static void search_cb(GtkWidget *button, PidginLogViewer *lv) |
| 7535 | 122 | { |
| 123 | const char *search_term = gtk_entry_get_text(GTK_ENTRY(lv->entry)); | |
| 124 | GList *logs; | |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
125 | |
|
12232
857f087ec86b
[gaim-migrate @ 14534]
Richard Laager <rlaager@pidgin.im>
parents:
11869
diff
changeset
|
126 | if (!(*search_term)) { |
|
857f087ec86b
[gaim-migrate @ 14534]
Richard Laager <rlaager@pidgin.im>
parents:
11869
diff
changeset
|
127 | /* reset the tree */ |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
128 | gtk_tree_store_clear(lv->treestore); |
| 7535 | 129 | populate_log_tree(lv); |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
130 | g_free(lv->search); |
| 7535 | 131 | lv->search = NULL; |
|
7537
4c3be2f554b1
[gaim-migrate @ 8150]
Christian Hammond <chipx86@chipx86.com>
parents:
7535
diff
changeset
|
132 | gtk_imhtml_search_clear(GTK_IMHTML(lv->imhtml)); |
|
13569
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
133 | select_first_log(lv); |
| 7535 | 134 | return; |
| 135 | } | |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
136 | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
137 | if (lv->search != NULL && !strcmp(lv->search, search_term)) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
138 | { |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
139 | /* Searching for the same term acts as "Find Next" */ |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
140 | gtk_imhtml_search_find(GTK_IMHTML(lv->imhtml), lv->search); |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
141 | return; |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
142 | } |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
143 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
144 | pidgin_set_cursor(lv->window, GDK_WATCH); |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
145 | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
146 | g_free(lv->search); |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
147 | lv->search = g_strdup(search_term); |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
148 | |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
149 | gtk_tree_store_clear(lv->treestore); |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
150 | gtk_imhtml_clear(GTK_IMHTML(lv->imhtml)); |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
151 | |
| 7535 | 152 | for (logs = lv->logs; logs != NULL; logs = logs->next) { |
| 153 | char *read = gaim_log_read((GaimLog*)logs->data, NULL); | |
|
12232
857f087ec86b
[gaim-migrate @ 14534]
Richard Laager <rlaager@pidgin.im>
parents:
11869
diff
changeset
|
154 | if (read && *read && gaim_strcasestr(read, search_term)) { |
| 7535 | 155 | GtkTreeIter iter; |
| 156 | GaimLog *log = logs->data; | |
|
12232
857f087ec86b
[gaim-migrate @ 14534]
Richard Laager <rlaager@pidgin.im>
parents:
11869
diff
changeset
|
157 | |
| 7535 | 158 | gtk_tree_store_append (lv->treestore, &iter, NULL); |
| 159 | gtk_tree_store_set(lv->treestore, &iter, | |
|
15060
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
160 | 0, log_get_date(log), |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
161 | 1, log, -1); |
| 7535 | 162 | } |
|
10574
5abb2931b6ff
[gaim-migrate @ 11966]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10181
diff
changeset
|
163 | g_free(read); |
| 7535 | 164 | } |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
165 | |
|
13569
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
166 | select_first_log(lv); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
167 | pidgin_clear_cursor(lv->window); |
| 7535 | 168 | } |
| 169 | ||
|
15298
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
170 | static void destroy_cb(GtkWidget *w, gint resp, struct log_viewer_hash_t *ht) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
171 | PidginLogViewer *lv = syslog_viewer; |
|
7454
c99a2070471e
[gaim-migrate @ 8067]
Mark Doliner <markdoliner@pidgin.im>
parents:
7440
diff
changeset
|
172 | |
|
15298
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
173 | #ifdef _WIN32 |
|
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
174 | if (resp == GTK_RESPONSE_HELP) { |
|
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
175 | char *logdir = g_build_filename(gaim_user_dir(), "logs", NULL); |
|
15574
18d9d1c05994
Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents:
15568
diff
changeset
|
176 | winpidgin_shell_execute(logdir, "explore", NULL); |
|
15298
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
177 | g_free(logdir); |
|
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
178 | return; |
|
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
179 | } |
|
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
180 | #endif |
|
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
181 | |
| 10663 | 182 | if (ht != NULL) { |
| 8573 | 183 | lv = g_hash_table_lookup(log_viewers, ht); |
| 184 | g_hash_table_remove(log_viewers, ht); | |
| 10663 | 185 | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13569
diff
changeset
|
186 | g_free(ht->screenname); |
| 8573 | 187 | g_free(ht); |
| 188 | } else | |
| 189 | syslog_viewer = NULL; | |
| 190 | ||
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
191 | gaim_request_close_with_handle(lv); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
192 | |
|
13569
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
193 | g_list_foreach(lv->logs, (GFunc)gaim_log_free, NULL); |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
194 | g_list_free(lv->logs); |
| 10663 | 195 | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13569
diff
changeset
|
196 | g_free(lv->search); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13569
diff
changeset
|
197 | g_free(lv); |
| 10663 | 198 | |
|
7454
c99a2070471e
[gaim-migrate @ 8067]
Mark Doliner <markdoliner@pidgin.im>
parents:
7440
diff
changeset
|
199 | gtk_widget_destroy(w); |
|
c99a2070471e
[gaim-migrate @ 8067]
Mark Doliner <markdoliner@pidgin.im>
parents:
7440
diff
changeset
|
200 | } |
|
c99a2070471e
[gaim-migrate @ 8067]
Mark Doliner <markdoliner@pidgin.im>
parents:
7440
diff
changeset
|
201 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
202 | static void log_row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, PidginLogViewer *viewer) { |
| 10663 | 203 | if (gtk_tree_view_row_expanded(tv, path)) |
| 204 | gtk_tree_view_collapse_row(tv, path); | |
| 205 | else | |
| 206 | gtk_tree_view_expand_row(tv, path, FALSE); | |
| 8573 | 207 | } |
| 10663 | 208 | |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
209 | static void delete_log_cleanup_cb(gpointer *data) |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
210 | { |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
211 | g_free(data[1]); /* iter */ |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
212 | g_free(data); |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
213 | } |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
214 | |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
215 | static void delete_log_cb(gpointer *data) |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
216 | { |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
217 | if (!gaim_log_delete((GaimLog *)data[2])) |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
218 | { |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
219 | gaim_notify_error(NULL, NULL, "Log Deletion Failed", |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
220 | "Check permissions and try again."); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
221 | } |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
222 | else |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
223 | { |
|
15613
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
224 | GtkTreeStore *treestore = data[0]; |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
225 | GtkTreeIter *iter = (GtkTreeIter *)data[1]; |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
226 | GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore), iter); |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
227 | gboolean first = !gtk_tree_path_prev(path); |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
228 | |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
229 | if (!gtk_tree_store_remove(treestore, iter) && first) |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
230 | { |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
231 | /* iter was the last child at its level */ |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
232 | |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
233 | if (gtk_tree_path_up(path)) |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
234 | { |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
235 | gtk_tree_model_get_iter(GTK_TREE_MODEL(treestore), iter, path); |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
236 | gtk_tree_store_remove(treestore, iter); |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
237 | } |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
238 | } |
|
9a6ec23fe078
If you delete the last log for a month, delete the month header as well.
Richard Laager <rlaager@pidgin.im>
parents:
15612
diff
changeset
|
239 | gtk_tree_path_free(path); |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
240 | } |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
241 | |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
242 | delete_log_cleanup_cb(data); |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
243 | } |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
244 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
245 | static void log_delete_log_cb(GtkWidget *menuitem, gpointer *data) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
246 | { |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
247 | PidginLogViewer *lv = data[0]; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
248 | GaimLog *log = data[1]; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
249 | const char *time = log_get_date(log); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
250 | const char *name; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
251 | char *tmp; |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
252 | gpointer *data2; |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
253 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
254 | if (log->type == GAIM_LOG_IM) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
255 | { |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
256 | GaimBuddy *buddy = gaim_find_buddy(log->account, log->name); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
257 | if (buddy != NULL) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
258 | name = gaim_buddy_get_contact_alias(buddy); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
259 | else |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
260 | name = log->name; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
261 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
262 | tmp = g_strdup_printf(_("Are you sure you want to permanently delete the log of the " |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
263 | "conversation with %s which started at %s?"), name, time); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
264 | } |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
265 | else if (log->type == GAIM_LOG_CHAT) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
266 | { |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
267 | GaimChat *chat = gaim_blist_find_chat(log->account, log->name); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
268 | if (chat != NULL) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
269 | name = gaim_chat_get_name(chat); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
270 | else |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
271 | name = log->name; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
272 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
273 | tmp = g_strdup_printf(_("Are you sure you want to permanently delete the log of the " |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
274 | "conversation in %s which started at %s?"), name, time); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
275 | } |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
276 | else if (log->type == GAIM_LOG_SYSTEM) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
277 | { |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
278 | tmp = g_strdup_printf(_("Are you sure you want to permanently delete the system log " |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
279 | "which started at %s?"), time); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
280 | } |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
281 | else |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
282 | g_return_if_reached(); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
283 | |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
284 | /* The only way to free data in all cases is to tie it to the menuitem with |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
285 | * g_object_set_data_full(). But, since we need to get some data down to |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
286 | * delete_log_cb() to delete the log from the log viewer after the file is |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
287 | * deleted, we have to allocate a new data array and make sure it gets freed |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
288 | * either way. */ |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
289 | data2 = g_new(gpointer, 3); |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
290 | data2[0] = lv->treestore; |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
291 | data2[1] = data[3]; /* iter */ |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
292 | data2[2] = log; |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
293 | gaim_request_action(lv, NULL, "Delete Log?", tmp, |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
294 | 0, data2, 2, _("Delete"), delete_log_cb, _("Cancel"), delete_log_cleanup_cb); |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
295 | g_free(tmp); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
296 | } |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
297 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
298 | static void log_show_popup_menu(GtkWidget *treeview, GdkEventButton *event, gpointer *data) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
299 | { |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
300 | GtkWidget *menu = gtk_menu_new(); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
301 | GtkWidget *menuitem = gtk_menu_item_new_with_label("Delete Log..."); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
302 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
303 | if (!gaim_log_is_deletable((GaimLog *)data[1])) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
304 | gtk_widget_set_sensitive(menuitem, FALSE); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
305 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
306 | g_signal_connect(menuitem, "activate", G_CALLBACK(log_delete_log_cb), data); |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
307 | g_object_set_data_full(G_OBJECT(menuitem), "log-viewer-data", data, g_free); |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
308 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
309 | gtk_widget_show_all(menu); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
310 | |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
311 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, (GtkMenuPositionFunc)data[2], NULL, |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
312 | (event != NULL) ? event->button : 0, |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
313 | gdk_event_get_time((GdkEvent *)event)); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
314 | } |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
315 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
316 | static gboolean log_button_press_cb(GtkWidget *treeview, GdkEventButton *event, PidginLogViewer *lv) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
317 | { |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
318 | if (event->type == GDK_BUTTON_PRESS && event->button == 3) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
319 | { |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
320 | GtkTreePath *path; |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
321 | GtkTreeIter *iter; |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
322 | GValue val; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
323 | GaimLog *log; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
324 | gpointer *data; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
325 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
326 | if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), event->x, event->y, &path, NULL, NULL, NULL)) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
327 | return FALSE; |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
328 | iter = g_new(GtkTreeIter, 1); |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
329 | gtk_tree_model_get_iter(GTK_TREE_MODEL(lv->treestore), iter, path); |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
330 | val.g_type = 0; |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
331 | gtk_tree_model_get_value(GTK_TREE_MODEL(lv->treestore), iter, 1, &val); |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
332 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
333 | log = g_value_get_pointer(&val); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
334 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
335 | if (log == NULL) |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
336 | { |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
337 | g_free(iter); |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
338 | return FALSE; |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
339 | } |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
340 | |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
341 | data = g_new(gpointer, 4); |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
342 | data[0] = lv; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
343 | data[1] = log; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
344 | data[2] = NULL; |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
345 | data[3] = iter; |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
346 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
347 | log_show_popup_menu(treeview, event, data); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
348 | return TRUE; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
349 | } |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
350 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
351 | return FALSE; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
352 | } |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
353 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
354 | static gboolean log_popup_menu_cb(GtkWidget *treeview, PidginLogViewer *lv) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
355 | { |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
356 | GtkTreeSelection *sel; |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
357 | GtkTreeIter *iter; |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
358 | GValue val; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
359 | GaimLog *log; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
360 | gpointer *data; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
361 | |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
362 | iter = g_new(GtkTreeIter, 1); |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
363 | sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(lv)); |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
364 | if (!gtk_tree_selection_get_selected(sel, NULL, iter)) |
|
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
365 | { |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
366 | return FALSE; |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
367 | } |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
368 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
369 | val.g_type = 0; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
370 | gtk_tree_model_get_value(GTK_TREE_MODEL(lv->treestore), |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
371 | iter, NODE_COLUMN, &val); |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
372 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
373 | log = g_value_get_pointer(&val); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
374 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
375 | if (log == NULL) |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
376 | return FALSE; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
377 | |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
378 | data = g_new(gpointer, 4); |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
379 | data[0] = lv; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
380 | data[1] = log; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
381 | data[2] = pidgin_treeview_popup_menu_position_func; |
|
15612
5de26d19e4e5
After the log is deleted, remove the entry from the log viewer.
Richard Laager <rlaager@pidgin.im>
parents:
15586
diff
changeset
|
382 | data[3] = iter; |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
383 | |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
384 | log_show_popup_menu(treeview, NULL, data); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
385 | return TRUE; |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
386 | } |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
387 | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
388 | static gboolean search_find_cb(gpointer data) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
389 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
390 | PidginLogViewer *viewer = data; |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
391 | gtk_imhtml_search_find(GTK_IMHTML(viewer->imhtml), viewer->search); |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
392 | return FALSE; |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
393 | } |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
394 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
395 | static void log_select_cb(GtkTreeSelection *sel, PidginLogViewer *viewer) { |
|
12838
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
396 | GtkTreeIter iter; |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12232
diff
changeset
|
397 | GValue val; |
| 7432 | 398 | GtkTreeModel *model = GTK_TREE_MODEL(viewer->treestore); |
| 399 | GaimLog *log = NULL; | |
| 400 | GaimLogReadFlags flags; | |
| 401 | char *read = NULL; | |
| 402 | ||
| 10663 | 403 | if (!gtk_tree_selection_get_selected(sel, &model, &iter)) |
| 7432 | 404 | return; |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12232
diff
changeset
|
405 | |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12232
diff
changeset
|
406 | val.g_type = 0; |
| 7432 | 407 | gtk_tree_model_get_value (model, &iter, 1, &val); |
| 408 | log = g_value_get_pointer(&val); | |
| 409 | g_value_unset(&val); | |
| 410 | ||
| 10663 | 411 | if (log == NULL) |
| 7432 | 412 | return; |
| 413 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
414 | pidgin_set_cursor(viewer->window, GDK_WATCH); |
|
12232
857f087ec86b
[gaim-migrate @ 14534]
Richard Laager <rlaager@pidgin.im>
parents:
11869
diff
changeset
|
415 | |
| 10663 | 416 | if (log->type != GAIM_LOG_SYSTEM) { |
| 417 | char *title; | |
| 418 | if (log->type == GAIM_LOG_CHAT) | |
|
13105
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
13091
diff
changeset
|
419 | title = g_strdup_printf(_("<span size='larger' weight='bold'>Conversation in %s on %s</span>"), |
|
15060
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
420 | log->name, log_get_date(log)); |
| 10663 | 421 | else |
|
13105
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
13091
diff
changeset
|
422 | title = g_strdup_printf(_("<span size='larger' weight='bold'>Conversation with %s on %s</span>"), |
|
15060
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
423 | log->name, log_get_date(log)); |
| 10663 | 424 | |
| 425 | gtk_label_set_markup(GTK_LABEL(viewer->label), title); | |
| 426 | g_free(title); | |
| 427 | } | |
| 428 | ||
| 7432 | 429 | read = gaim_log_read(log, &flags); |
| 430 | viewer->flags = flags; | |
| 10663 | 431 | |
| 7432 | 432 | gtk_imhtml_clear(GTK_IMHTML(viewer->imhtml)); |
|
10645
f00e65bebc8b
[gaim-migrate @ 12157]
Richard Laager <rlaager@pidgin.im>
parents:
10636
diff
changeset
|
433 | gtk_imhtml_set_protocol_name(GTK_IMHTML(viewer->imhtml), |
|
f00e65bebc8b
[gaim-migrate @ 12157]
Richard Laager <rlaager@pidgin.im>
parents:
10636
diff
changeset
|
434 | gaim_account_get_protocol_name(log->account)); |
|
12838
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
435 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
436 | gaim_signal_emit(pidgin_log_get_handle(), "log-displaying", viewer, log); |
|
12838
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
437 | |
|
10574
5abb2931b6ff
[gaim-migrate @ 11966]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10181
diff
changeset
|
438 | gtk_imhtml_append_text(GTK_IMHTML(viewer->imhtml), read, |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
439 | GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_SCROLL | |
| 7432 | 440 | ((flags & GAIM_LOG_READ_NO_NEWLINE) ? GTK_IMHTML_NO_NEWLINE : 0)); |
|
12232
857f087ec86b
[gaim-migrate @ 14534]
Richard Laager <rlaager@pidgin.im>
parents:
11869
diff
changeset
|
441 | g_free(read); |
| 7535 | 442 | |
| 10663 | 443 | if (viewer->search != NULL) { |
|
10574
5abb2931b6ff
[gaim-migrate @ 11966]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10181
diff
changeset
|
444 | gtk_imhtml_search_clear(GTK_IMHTML(viewer->imhtml)); |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
445 | g_idle_add(search_find_cb, viewer); |
|
10574
5abb2931b6ff
[gaim-migrate @ 11966]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10181
diff
changeset
|
446 | } |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
447 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
448 | pidgin_clear_cursor(viewer->window); |
| 7432 | 449 | } |
| 450 | ||
| 451 | /* I want to make this smarter, but haven't come up with a cool algorithm to do so, yet. | |
| 452 | * I want the tree to be divided into groups like "Today," "Yesterday," "Last week," | |
| 453 | * "August," "2002," etc. based on how many conversation took place in each subdivision. | |
| 454 | * | |
| 455 | * For now, I'll just make it a flat list. | |
| 456 | */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
457 | static void populate_log_tree(PidginLogViewer *lv) |
| 11585 | 458 | /* Logs are made from trees in real life. |
| 7432 | 459 | This is a tree made from logs */ |
| 460 | { | |
|
13105
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
13091
diff
changeset
|
461 | const char *month; |
| 10663 | 462 | char prev_top_month[30] = ""; |
| 9435 | 463 | GtkTreeIter toplevel, child; |
| 7432 | 464 | GList *logs = lv->logs; |
| 10663 | 465 | |
| 466 | while (logs != NULL) { | |
| 7432 | 467 | GaimLog *log = logs->data; |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
468 | |
|
13120
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13105
diff
changeset
|
469 | month = gaim_utf8_strftime(_("%B %Y"), |
|
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13105
diff
changeset
|
470 | log->tm ? log->tm : localtime(&log->time)); |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
471 | |
|
13105
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
13091
diff
changeset
|
472 | if (strcmp(month, prev_top_month) != 0) |
|
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
13091
diff
changeset
|
473 | { |
| 9435 | 474 | /* top level */ |
| 475 | gtk_tree_store_append(lv->treestore, &toplevel, NULL); | |
| 476 | gtk_tree_store_set(lv->treestore, &toplevel, 0, month, 1, NULL, -1); | |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
477 | |
|
10680
e4a00ce2fc35
[gaim-migrate @ 12226]
Richard Laager <rlaager@pidgin.im>
parents:
10669
diff
changeset
|
478 | strncpy(prev_top_month, month, sizeof(prev_top_month)); |
|
e4a00ce2fc35
[gaim-migrate @ 12226]
Richard Laager <rlaager@pidgin.im>
parents:
10669
diff
changeset
|
479 | } |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
480 | |
|
10680
e4a00ce2fc35
[gaim-migrate @ 12226]
Richard Laager <rlaager@pidgin.im>
parents:
10669
diff
changeset
|
481 | /* sub */ |
|
e4a00ce2fc35
[gaim-migrate @ 12226]
Richard Laager <rlaager@pidgin.im>
parents:
10669
diff
changeset
|
482 | gtk_tree_store_append(lv->treestore, &child, &toplevel); |
|
13105
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
13091
diff
changeset
|
483 | gtk_tree_store_set(lv->treestore, &child, |
|
15060
a5d9fafd2b8c
[gaim-migrate @ 17777]
Richard Laager <rlaager@pidgin.im>
parents:
14861
diff
changeset
|
484 | 0, log_get_date(log), |
|
13105
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
13091
diff
changeset
|
485 | 1, log, |
|
8f9c66e4af87
[gaim-migrate @ 15466]
Richard Laager <rlaager@pidgin.im>
parents:
13091
diff
changeset
|
486 | -1); |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
487 | |
| 7432 | 488 | logs = logs->next; |
| 489 | } | |
| 490 | } | |
| 491 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
492 | static PidginLogViewer *display_log_viewer(struct log_viewer_hash_t *ht, GList *logs, |
|
15639
4d29fa62453d
Use person icon for Person log viewer
Sean Egan <seanegan@pidgin.im>
parents:
15613
diff
changeset
|
493 | const char *title, GtkWidget *icon, int log_size) |
| 10663 | 494 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
495 | PidginLogViewer *lv; |
| 10663 | 496 | GtkWidget *title_box; |
| 497 | char *text; | |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
498 | GtkWidget *pane; |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
499 | GtkWidget *sw; |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
500 | GtkCellRenderer *rend; |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
501 | GtkTreeViewColumn *col; |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
502 | GtkTreeSelection *sel; |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
503 | GtkWidget *vbox; |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
504 | GtkWidget *frame; |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
505 | GtkWidget *hbox; |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
506 | GtkWidget *find_button; |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
507 | GtkWidget *size_label; |
| 7432 | 508 | |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
509 | if (logs == NULL) |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
510 | { |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
511 | /* No logs were found. */ |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
512 | const char *log_preferences = NULL; |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
513 | |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
514 | if (ht == NULL) { |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
515 | if (!gaim_prefs_get_bool("/core/logging/log_system")) |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
516 | log_preferences = _("System events will only be logged if the \"Log all status changes to system log\" preference is enabled."); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
517 | } else { |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
518 | if (ht->type == GAIM_LOG_IM) { |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
519 | if (!gaim_prefs_get_bool("/core/logging/log_ims")) |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
520 | log_preferences = _("Instant messages will only be logged if the \"Log all instant messages\" preference is enabled."); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
521 | } else if (ht->type == GAIM_LOG_CHAT) { |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
522 | if (!gaim_prefs_get_bool("/core/logging/log_chats")) |
|
11869
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11780
diff
changeset
|
523 | log_preferences = _("Chats will only be logged if the \"Log all chats\" preference is enabled."); |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
524 | } |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
525 | } |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
526 | |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
527 | gaim_notify_info(NULL, title, _("No logs were found"), log_preferences); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
528 | return NULL; |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
529 | } |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
530 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
531 | lv = g_new0(PidginLogViewer, 1); |
|
13569
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
532 | lv->logs = logs; |
|
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
533 | |
| 10663 | 534 | if (ht != NULL) |
| 535 | g_hash_table_insert(log_viewers, ht, lv); | |
| 7432 | 536 | |
| 537 | /* Window ***********/ | |
| 10663 | 538 | lv->window = gtk_dialog_new_with_buttons(title, NULL, 0, |
| 7432 | 539 | GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); |
|
15298
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
540 | #ifdef _WIN32 |
|
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
541 | /* Steal the "HELP" response and use it to trigger browsing to the logs folder */ |
|
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
542 | gtk_dialog_add_button(GTK_DIALOG(lv->window), _("_Browse logs folder"), GTK_RESPONSE_HELP); |
|
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
543 | #endif |
| 15882 | 544 | gtk_container_set_border_width (GTK_CONTAINER(lv->window), PIDGIN_HIG_BOX_SPACE); |
| 7432 | 545 | gtk_dialog_set_has_separator(GTK_DIALOG(lv->window), FALSE); |
| 546 | gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(lv->window)->vbox), 0); | |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
547 | g_signal_connect(G_OBJECT(lv->window), "response", |
|
7454
c99a2070471e
[gaim-migrate @ 8067]
Mark Doliner <markdoliner@pidgin.im>
parents:
7440
diff
changeset
|
548 | G_CALLBACK(destroy_cb), ht); |
|
11004
2323998d6cb9
[gaim-migrate @ 12859]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
10884
diff
changeset
|
549 | gtk_window_set_role(GTK_WINDOW(lv->window), "log_viewer"); |
|
7454
c99a2070471e
[gaim-migrate @ 8067]
Mark Doliner <markdoliner@pidgin.im>
parents:
7440
diff
changeset
|
550 | |
| 10663 | 551 | /* Icon *************/ |
|
15639
4d29fa62453d
Use person icon for Person log viewer
Sean Egan <seanegan@pidgin.im>
parents:
15613
diff
changeset
|
552 | if (icon != NULL) { |
| 15882 | 553 | title_box = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
| 554 | gtk_container_set_border_width(GTK_CONTAINER(title_box), PIDGIN_HIG_BOX_SPACE); | |
| 10663 | 555 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), title_box, FALSE, FALSE, 0); |
| 556 | ||
| 557 | gtk_box_pack_start(GTK_BOX(title_box), icon, FALSE, FALSE, 0); | |
| 558 | } else | |
| 559 | title_box = GTK_DIALOG(lv->window)->vbox; | |
| 7432 | 560 | |
| 561 | /* Label ************/ | |
| 10663 | 562 | lv->label = gtk_label_new(NULL); |
| 563 | ||
| 564 | text = g_strdup_printf("<span size='larger' weight='bold'>%s</span>", title); | |
| 9624 | 565 | |
| 10663 | 566 | gtk_label_set_markup(GTK_LABEL(lv->label), text); |
| 567 | gtk_misc_set_alignment(GTK_MISC(lv->label), 0, 0); | |
| 568 | gtk_box_pack_start(GTK_BOX(title_box), lv->label, FALSE, FALSE, 0); | |
| 7432 | 569 | g_free(text); |
| 570 | ||
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
571 | /* Pane *************/ |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
572 | pane = gtk_hpaned_new(); |
| 15882 | 573 | gtk_container_set_border_width(GTK_CONTAINER(pane), PIDGIN_HIG_BOX_SPACE); |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
574 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), pane, TRUE, TRUE, 0); |
| 7432 | 575 | |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
576 | /* List *************/ |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
577 | sw = gtk_scrolled_window_new (NULL, NULL); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
578 | gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
579 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
580 | gtk_paned_add1(GTK_PANED(pane), sw); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
581 | lv->treestore = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
582 | lv->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (lv->treestore)); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
583 | rend = gtk_cell_renderer_text_new(); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
584 | col = gtk_tree_view_column_new_with_attributes ("time", rend, "markup", 0, NULL); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
585 | gtk_tree_view_append_column (GTK_TREE_VIEW(lv->treeview), col); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
586 | gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (lv->treeview), FALSE); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
587 | gtk_container_add (GTK_CONTAINER (sw), lv->treeview); |
|
11402
1be90c47f022
[gaim-migrate @ 13637]
Peter McCurdy <cpirate@users.sourceforge.net>
parents:
11243
diff
changeset
|
588 | |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
589 | populate_log_tree(lv); |
|
11402
1be90c47f022
[gaim-migrate @ 13637]
Peter McCurdy <cpirate@users.sourceforge.net>
parents:
11243
diff
changeset
|
590 | |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
591 | sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (lv->treeview)); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
592 | g_signal_connect (G_OBJECT (sel), "changed", |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
593 | G_CALLBACK (log_select_cb), |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
594 | lv); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
595 | g_signal_connect (G_OBJECT(lv->treeview), "row-activated", |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
596 | G_CALLBACK(log_row_activated_cb), |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
597 | lv); |
| 15568 | 598 | pidgin_set_accessible_label(lv->treeview, lv->label); |
| 11585 | 599 | |
|
15586
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
600 | g_signal_connect(lv->treeview, "button-press-event", G_CALLBACK(log_button_press_cb), lv); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
601 | g_signal_connect(lv->treeview, "popup-menu", G_CALLBACK(log_popup_menu_cb), lv); |
|
b03db9cb6cac
Implement the UI for deleting logs. This allows users to right-click on
Richard Laager <rlaager@pidgin.im>
parents:
15578
diff
changeset
|
602 | |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
603 | /* Log size ************/ |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
604 | if(log_size) { |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
605 | char *sz_txt = gaim_str_size_to_units(log_size); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
606 | text = g_strdup_printf("<span weight='bold'>%s</span> %s", _("Total log size:"), sz_txt); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
607 | size_label = gtk_label_new(NULL); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
608 | gtk_label_set_markup(GTK_LABEL(size_label), text); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
609 | /* gtk_paned_add1(GTK_PANED(pane), size_label); */ |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
610 | gtk_misc_set_alignment(GTK_MISC(size_label), 0, 0); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
611 | gtk_box_pack_end(GTK_BOX(GTK_DIALOG(lv->window)->vbox), size_label, FALSE, FALSE, 0); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
612 | g_free(sz_txt); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
613 | g_free(text); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
614 | } |
|
11402
1be90c47f022
[gaim-migrate @ 13637]
Peter McCurdy <cpirate@users.sourceforge.net>
parents:
11243
diff
changeset
|
615 | |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
616 | /* A fancy little box ************/ |
| 15882 | 617 | vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
618 | gtk_paned_add2(GTK_PANED(pane), vbox); |
|
11402
1be90c47f022
[gaim-migrate @ 13637]
Peter McCurdy <cpirate@users.sourceforge.net>
parents:
11243
diff
changeset
|
619 | |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
620 | /* Viewer ************/ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
621 | frame = pidgin_create_imhtml(FALSE, &lv->imhtml, NULL, NULL); |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
622 | gtk_widget_set_name(lv->imhtml, "pidginlog_imhtml"); |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
623 | gtk_widget_set_size_request(lv->imhtml, 320, 200); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
624 | gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
625 | gtk_widget_show(frame); |
|
10181
2425c3773266
[gaim-migrate @ 11296]
Mark Doliner <markdoliner@pidgin.im>
parents:
10175
diff
changeset
|
626 | |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
627 | /* Search box **********/ |
| 15882 | 628 | hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
629 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
630 | lv->entry = gtk_entry_new(); |
|
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
631 | gtk_box_pack_start(GTK_BOX(hbox), lv->entry, TRUE, TRUE, 0); |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
632 | find_button = gtk_button_new_from_stock(GTK_STOCK_FIND); |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
633 | gtk_box_pack_start(GTK_BOX(hbox), find_button, FALSE, FALSE, 0); |
|
11769
66e922bf0ebd
[gaim-migrate @ 14060]
Mark Doliner <markdoliner@pidgin.im>
parents:
11703
diff
changeset
|
634 | g_signal_connect(GTK_ENTRY(lv->entry), "activate", G_CALLBACK(search_cb), lv); |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14253
diff
changeset
|
635 | g_signal_connect(GTK_BUTTON(find_button), "clicked", G_CALLBACK(search_cb), lv); |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
636 | |
|
13569
4f0396bc59fc
[gaim-migrate @ 15947]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13435
diff
changeset
|
637 | select_first_log(lv); |
| 7432 | 638 | |
| 639 | gtk_widget_show_all(lv->window); | |
| 10663 | 640 | |
| 641 | return lv; | |
| 642 | } | |
| 643 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
644 | void pidgin_log_show(GaimLogType type, const char *screenname, GaimAccount *account) { |
|
15298
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
645 | struct log_viewer_hash_t *ht; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
646 | PidginLogViewer *lv = NULL; |
| 10663 | 647 | const char *name = screenname; |
| 648 | char *title; | |
| 649 | ||
| 650 | g_return_if_fail(account != NULL); | |
| 651 | g_return_if_fail(screenname != NULL); | |
| 652 | ||
|
15298
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
653 | ht = g_new0(struct log_viewer_hash_t, 1); |
|
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
654 | |
| 10663 | 655 | ht->type = type; |
| 656 | ht->screenname = g_strdup(screenname); | |
| 657 | ht->account = account; | |
| 658 | ||
| 659 | if (log_viewers == NULL) { | |
| 660 | log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal); | |
| 661 | } else if ((lv = g_hash_table_lookup(log_viewers, ht))) { | |
| 662 | gtk_window_present(GTK_WINDOW(lv->window)); | |
|
15298
e192226f7804
[gaim-migrate @ 18026]
Daniel Atallah <datallah@pidgin.im>
parents:
15060
diff
changeset
|
663 | g_free(ht->screenname); |
| 10663 | 664 | g_free(ht); |
| 665 | return; | |
| 666 | } | |
| 667 | ||
| 668 | if (type == GAIM_LOG_CHAT) { | |
| 669 | GaimChat *chat; | |
| 670 | ||
| 671 | chat = gaim_blist_find_chat(account, screenname); | |
| 672 | if (chat != NULL) | |
| 673 | name = gaim_chat_get_name(chat); | |
| 674 | ||
| 675 | title = g_strdup_printf(_("Conversations in %s"), name); | |
| 676 | } else { | |
| 677 | GaimBuddy *buddy; | |
| 678 | ||
| 679 | buddy = gaim_find_buddy(account, screenname); | |
| 680 | if (buddy != NULL) | |
| 681 | name = gaim_buddy_get_contact_alias(buddy); | |
| 682 | ||
| 683 | title = g_strdup_printf(_("Conversations with %s"), name); | |
| 684 | } | |
| 685 | ||
| 686 | display_log_viewer(ht, gaim_log_get_logs(type, screenname, account), | |
|
15639
4d29fa62453d
Use person icon for Person log viewer
Sean Egan <seanegan@pidgin.im>
parents:
15613
diff
changeset
|
687 | title, gtk_image_new_from_pixbuf(pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_MEDIUM)), |
|
15496
76b5ca00a36c
I think this takes care of protocol icons. Note there are still places
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
688 | gaim_log_get_total_size(type, screenname, account)); |
| 10663 | 689 | g_free(title); |
| 690 | } | |
| 691 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
692 | void pidgin_log_show_contact(GaimContact *contact) { |
| 10663 | 693 | struct log_viewer_hash_t *ht = g_new0(struct log_viewer_hash_t, 1); |
| 694 | GaimBlistNode *child; | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
695 | PidginLogViewer *lv = NULL; |
| 10663 | 696 | GList *logs = NULL; |
| 697 | GdkPixbuf *pixbuf; | |
|
15656
c1f66538f8c6
Fix a few small compile warnings:
Mark Doliner <markdoliner@pidgin.im>
parents:
15639
diff
changeset
|
698 | GtkWidget *image = gtk_image_new(); |
| 10663 | 699 | const char *name = NULL; |
| 700 | char *title; | |
| 11585 | 701 | int total_log_size = 0; |
| 10663 | 702 | |
| 703 | g_return_if_fail(contact != NULL); | |
| 704 | ||
| 705 | ht->type = GAIM_LOG_IM; | |
| 706 | ht->contact = contact; | |
| 707 | ||
| 708 | if (log_viewers == NULL) { | |
| 709 | log_viewers = g_hash_table_new(log_viewer_hash, log_viewer_equal); | |
| 710 | } else if ((lv = g_hash_table_lookup(log_viewers, ht))) { | |
| 711 | gtk_window_present(GTK_WINDOW(lv->window)); | |
| 712 | g_free(ht); | |
| 713 | return; | |
| 714 | } | |
| 715 | ||
| 716 | for (child = contact->node.child ; child ; child = child->next) { | |
| 717 | if (!GAIM_BLIST_NODE_IS_BUDDY(child)) | |
| 718 | continue; | |
| 719 | ||
|
11703
6b22ef099870
[gaim-migrate @ 13994]
Richard Laager <rlaager@pidgin.im>
parents:
11700
diff
changeset
|
720 | logs = g_list_concat(gaim_log_get_logs(GAIM_LOG_IM, ((GaimBuddy *)child)->name, |
|
6b22ef099870
[gaim-migrate @ 13994]
Richard Laager <rlaager@pidgin.im>
parents:
11700
diff
changeset
|
721 | ((GaimBuddy *)child)->account), logs); |
| 11585 | 722 | total_log_size += gaim_log_get_total_size(GAIM_LOG_IM, ((GaimBuddy *)child)->name, ((GaimBuddy *)child)->account); |
| 10663 | 723 | } |
| 724 | logs = g_list_sort(logs, gaim_log_compare); | |
| 725 | ||
|
15639
4d29fa62453d
Use person icon for Person log viewer
Sean Egan <seanegan@pidgin.im>
parents:
15613
diff
changeset
|
726 | pixbuf = gtk_widget_render_icon (image, PIDGIN_STOCK_STATUS_PERSON, |
|
4d29fa62453d
Use person icon for Person log viewer
Sean Egan <seanegan@pidgin.im>
parents:
15613
diff
changeset
|
727 | gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL), "GtkWindow"); |
|
4d29fa62453d
Use person icon for Person log viewer
Sean Egan <seanegan@pidgin.im>
parents:
15613
diff
changeset
|
728 | gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf); |
|
4d29fa62453d
Use person icon for Person log viewer
Sean Egan <seanegan@pidgin.im>
parents:
15613
diff
changeset
|
729 | |
| 10663 | 730 | if (contact->alias != NULL) |
| 731 | name = contact->alias; | |
| 732 | else if (contact->priority != NULL) | |
| 733 | name = gaim_buddy_get_contact_alias(contact->priority); | |
| 734 | ||
| 735 | title = g_strdup_printf(_("Conversations with %s"), name); | |
|
15639
4d29fa62453d
Use person icon for Person log viewer
Sean Egan <seanegan@pidgin.im>
parents:
15613
diff
changeset
|
736 | display_log_viewer(ht, logs, title, image, total_log_size); |
| 10663 | 737 | g_free(title); |
| 7432 | 738 | } |
| 8573 | 739 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
740 | void pidgin_syslog_show() |
| 8573 | 741 | { |
| 742 | GList *accounts = NULL; | |
| 10663 | 743 | GList *logs = NULL; |
| 8573 | 744 | |
|
10181
2425c3773266
[gaim-migrate @ 11296]
Mark Doliner <markdoliner@pidgin.im>
parents:
10175
diff
changeset
|
745 | if (syslog_viewer != NULL) { |
| 8573 | 746 | gtk_window_present(GTK_WINDOW(syslog_viewer->window)); |
| 747 | return; | |
| 748 | } | |
| 749 | ||
| 10663 | 750 | for(accounts = gaim_accounts_get_all(); accounts != NULL; accounts = accounts->next) { |
| 8573 | 751 | |
| 752 | GaimAccount *account = (GaimAccount *)accounts->data; | |
| 10663 | 753 | if(gaim_find_prpl(gaim_account_get_protocol_id(account)) == NULL) |
| 8573 | 754 | continue; |
| 755 | ||
|
11703
6b22ef099870
[gaim-migrate @ 13994]
Richard Laager <rlaager@pidgin.im>
parents:
11700
diff
changeset
|
756 | logs = g_list_concat(gaim_log_get_system_logs(account), logs); |
| 8573 | 757 | } |
| 10663 | 758 | logs = g_list_sort(logs, gaim_log_compare); |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
9917
diff
changeset
|
759 | |
| 11585 | 760 | syslog_viewer = display_log_viewer(NULL, logs, _("System Log"), NULL, 0); |
| 8573 | 761 | } |
|
12838
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
762 | |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
763 | /**************************************************************************** |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
764 | * GTK+ LOG SUBSYSTEM ******************************************************* |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
765 | ****************************************************************************/ |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
766 | |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
767 | void * |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
768 | pidgin_log_get_handle(void) |
|
12838
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
769 | { |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
770 | static int handle; |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
771 | |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
772 | return &handle; |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
773 | } |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
774 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
775 | void pidgin_log_init(void) |
|
12838
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
776 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
777 | void *handle = pidgin_log_get_handle(); |
|
12838
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
778 | |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
779 | gaim_signal_register(handle, "log-displaying", |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
780 | gaim_marshal_VOID__POINTER_POINTER, |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
781 | NULL, 2, |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
782 | gaim_value_new(GAIM_TYPE_BOXED, |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
783 | "PidginLogViewer *"), |
|
12838
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
784 | gaim_value_new(GAIM_TYPE_SUBTYPE, |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
785 | GAIM_SUBTYPE_LOG)); |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
786 | } |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
787 | |
|
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
788 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
789 | pidgin_log_uninit(void) |
|
12838
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
790 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
791 | gaim_signals_unregister_by_instance(pidgin_log_get_handle()); |
|
12838
5c6f36abeee8
[gaim-migrate @ 15186]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
792 | } |