Mercurial > pidgin.yaz
comparison src/gtklog.c @ 12232:375f1f3817a8
[gaim-migrate @ 14534]
Displaying large logs is slow. Let's show the busy cursor whenever possible. This currently doesn't show the busy cursor over the IMHTMLs in a conversation window even though I set a busy cursor for the conversation window. I looked into fixing that, but I'm not sure exactly what the best way to deal with it is.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 27 Nov 2005 03:20:35 +0000 |
parents | 3ba50c385299 |
children | e856f985a0b9 |
comparison
equal
deleted
inserted
replaced
12231:c342eb6e8cd3 | 12232:375f1f3817a8 |
---|---|
85 | 85 |
86 static void search_cb(GtkWidget *button, GaimGtkLogViewer *lv) | 86 static void search_cb(GtkWidget *button, GaimGtkLogViewer *lv) |
87 { | 87 { |
88 const char *search_term = gtk_entry_get_text(GTK_ENTRY(lv->entry)); | 88 const char *search_term = gtk_entry_get_text(GTK_ENTRY(lv->entry)); |
89 GList *logs; | 89 GList *logs; |
90 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH); | 90 GdkCursor *cursor; |
91 | 91 |
92 if (lv->search != NULL) | 92 if (lv->search != NULL) |
93 g_free(lv->search); | 93 g_free(lv->search); |
94 | 94 |
95 gtk_tree_store_clear(lv->treestore); | 95 gtk_tree_store_clear(lv->treestore); |
96 if (strlen(search_term) == 0) {/* reset the tree */ | 96 if (!(*search_term)) { |
97 /* reset the tree */ | |
97 populate_log_tree(lv); | 98 populate_log_tree(lv); |
98 lv->search = NULL; | 99 lv->search = NULL; |
99 gtk_imhtml_search_clear(GTK_IMHTML(lv->imhtml)); | 100 gtk_imhtml_search_clear(GTK_IMHTML(lv->imhtml)); |
100 return; | 101 return; |
101 } | 102 } |
102 | 103 |
103 lv->search = g_strdup(search_term); | 104 lv->search = g_strdup(search_term); |
104 | 105 |
106 cursor = gdk_cursor_new(GDK_WATCH); | |
105 gdk_window_set_cursor(lv->window->window, cursor); | 107 gdk_window_set_cursor(lv->window->window, cursor); |
108 gdk_cursor_unref(cursor); | |
106 while (gtk_events_pending()) | 109 while (gtk_events_pending()) |
107 gtk_main_iteration(); | 110 gtk_main_iteration(); |
108 gdk_cursor_unref(cursor); | |
109 | 111 |
110 for (logs = lv->logs; logs != NULL; logs = logs->next) { | 112 for (logs = lv->logs; logs != NULL; logs = logs->next) { |
111 char *read = gaim_log_read((GaimLog*)logs->data, NULL); | 113 char *read = gaim_log_read((GaimLog*)logs->data, NULL); |
112 if (gaim_strcasestr(read, search_term)) { | 114 if (read && *read && gaim_strcasestr(read, search_term)) { |
113 GtkTreeIter iter; | 115 GtkTreeIter iter; |
114 GaimLog *log = logs->data; | 116 GaimLog *log = logs->data; |
115 char title[64]; | 117 char title[64]; |
116 char *title_utf8; /* temporary variable for utf8 conversion */ | 118 char *title_utf8; /* temporary variable for utf8 conversion */ |
119 | |
117 gaim_strftime(title, sizeof(title), "%c", localtime(&log->time)); | 120 gaim_strftime(title, sizeof(title), "%c", localtime(&log->time)); |
118 title_utf8 = gaim_utf8_try_convert(title); | 121 title_utf8 = gaim_utf8_try_convert(title); |
119 strncpy(title, title_utf8, sizeof(title)); | 122 strncpy(title, title_utf8, sizeof(title)); |
120 g_free(title_utf8); | 123 g_free(title_utf8); |
124 | |
121 gtk_tree_store_append (lv->treestore, &iter, NULL); | 125 gtk_tree_store_append (lv->treestore, &iter, NULL); |
122 gtk_tree_store_set(lv->treestore, &iter, | 126 gtk_tree_store_set(lv->treestore, &iter, |
123 0, title, | 127 0, title, |
124 1, log, -1); | 128 1, log, -1); |
125 } | 129 } |
126 g_free(read); | 130 g_free(read); |
127 } | 131 } |
128 | 132 |
129 | 133 gdk_window_set_cursor(lv->window->window, NULL); |
130 cursor = gdk_cursor_new(GDK_LEFT_PTR); | |
131 gdk_window_set_cursor(lv->window->window, cursor); | |
132 gdk_cursor_unref(cursor); | |
133 } | 134 } |
134 | 135 |
135 static gboolean destroy_cb(GtkWidget *w, gint resp, struct log_viewer_hash_t *ht) { | 136 static gboolean destroy_cb(GtkWidget *w, gint resp, struct log_viewer_hash_t *ht) { |
136 GaimGtkLogViewer *lv = syslog_viewer; | 137 GaimGtkLogViewer *lv = syslog_viewer; |
137 | 138 |
175 static void log_select_cb(GtkTreeSelection *sel, GaimGtkLogViewer *viewer) { | 176 static void log_select_cb(GtkTreeSelection *sel, GaimGtkLogViewer *viewer) { |
176 GtkTreeIter iter; | 177 GtkTreeIter iter; |
177 GValue val = { 0, }; | 178 GValue val = { 0, }; |
178 GtkTreeModel *model = GTK_TREE_MODEL(viewer->treestore); | 179 GtkTreeModel *model = GTK_TREE_MODEL(viewer->treestore); |
179 GaimLog *log = NULL; | 180 GaimLog *log = NULL; |
181 GdkCursor *cursor; | |
180 GaimLogReadFlags flags; | 182 GaimLogReadFlags flags; |
181 char *read = NULL; | 183 char *read = NULL; |
182 char time[64]; | 184 char time[64]; |
183 | 185 |
184 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) | 186 if (!gtk_tree_selection_get_selected(sel, &model, &iter)) |
187 log = g_value_get_pointer(&val); | 189 log = g_value_get_pointer(&val); |
188 g_value_unset(&val); | 190 g_value_unset(&val); |
189 | 191 |
190 if (log == NULL) | 192 if (log == NULL) |
191 return; | 193 return; |
194 | |
195 /* When we set the initial log, this gets called and the window is still NULL. */ | |
196 if (viewer->window->window != NULL) | |
197 { | |
198 cursor = gdk_cursor_new(GDK_WATCH); | |
199 gdk_window_set_cursor(viewer->window->window, cursor); | |
200 gdk_cursor_unref(cursor); | |
201 while (gtk_events_pending()) | |
202 gtk_main_iteration(); | |
203 } | |
192 | 204 |
193 if (log->type != GAIM_LOG_SYSTEM) { | 205 if (log->type != GAIM_LOG_SYSTEM) { |
194 char *title; | 206 char *title; |
195 char *title_utf8; /* temporary variable for utf8 conversion */ | 207 char *title_utf8; /* temporary variable for utf8 conversion */ |
196 | 208 |
218 gtk_imhtml_set_protocol_name(GTK_IMHTML(viewer->imhtml), | 230 gtk_imhtml_set_protocol_name(GTK_IMHTML(viewer->imhtml), |
219 gaim_account_get_protocol_name(log->account)); | 231 gaim_account_get_protocol_name(log->account)); |
220 gtk_imhtml_append_text(GTK_IMHTML(viewer->imhtml), read, | 232 gtk_imhtml_append_text(GTK_IMHTML(viewer->imhtml), read, |
221 GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_SCROLL | | 233 GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_TITLE | GTK_IMHTML_NO_SCROLL | |
222 ((flags & GAIM_LOG_READ_NO_NEWLINE) ? GTK_IMHTML_NO_NEWLINE : 0)); | 234 ((flags & GAIM_LOG_READ_NO_NEWLINE) ? GTK_IMHTML_NO_NEWLINE : 0)); |
235 g_free(read); | |
223 | 236 |
224 if (viewer->search != NULL) { | 237 if (viewer->search != NULL) { |
225 gtk_imhtml_search_clear(GTK_IMHTML(viewer->imhtml)); | 238 gtk_imhtml_search_clear(GTK_IMHTML(viewer->imhtml)); |
226 gtk_imhtml_search_find(GTK_IMHTML(viewer->imhtml), viewer->search); | 239 gtk_imhtml_search_find(GTK_IMHTML(viewer->imhtml), viewer->search); |
227 } | 240 } |
228 | 241 |
229 g_free(read); | 242 /* When we set the initial log, this gets called and the window is still NULL. */ |
243 if (viewer->window->window != NULL) | |
244 gdk_window_set_cursor(viewer->window->window, NULL); | |
230 } | 245 } |
231 | 246 |
232 /* I want to make this smarter, but haven't come up with a cool algorithm to do so, yet. | 247 /* I want to make this smarter, but haven't come up with a cool algorithm to do so, yet. |
233 * I want the tree to be divided into groups like "Today," "Yesterday," "Last week," | 248 * I want the tree to be divided into groups like "Today," "Yesterday," "Last week," |
234 * "August," "2002," etc. based on how many conversation took place in each subdivision. | 249 * "August," "2002," etc. based on how many conversation took place in each subdivision. |