Mercurial > pidgin
comparison src/gtklog.c @ 11769:d56778d594d9
[gaim-migrate @ 14060]
Use the notify API to show the "No logs found!" messages.
Why don't I get a "No logs found!" message when doing
Buddies->View Log, enter in random letters and click on
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 23 Oct 2005 22:44:04 +0000 |
parents | a53cef8bd22b |
children | 8cb75ba77f9d |
comparison
equal
deleted
inserted
replaced
11768:a9e9b76905b4 | 11769:d56778d594d9 |
---|---|
24 */ | 24 */ |
25 #include "internal.h" | 25 #include "internal.h" |
26 #include "gtkgaim.h" | 26 #include "gtkgaim.h" |
27 | 27 |
28 #include "account.h" | 28 #include "account.h" |
29 #include "util.h" | |
30 #include "gtkblist.h" | 29 #include "gtkblist.h" |
31 #include "gtkimhtml.h" | 30 #include "gtkimhtml.h" |
32 #include "gtklog.h" | 31 #include "gtklog.h" |
33 #include "gtkutils.h" | 32 #include "gtkutils.h" |
34 #include "log.h" | 33 #include "log.h" |
34 #include "notify.h" | |
35 #include "util.h" | 35 #include "util.h" |
36 | 36 |
37 static GHashTable *log_viewers = NULL; | 37 static GHashTable *log_viewers = NULL; |
38 static void populate_log_tree(GaimGtkLogViewer *lv); | 38 static void populate_log_tree(GaimGtkLogViewer *lv); |
39 static GaimGtkLogViewer *syslog_viewer = NULL; | 39 static GaimGtkLogViewer *syslog_viewer = NULL; |
280 const char *title, GdkPixbuf *pixbuf, int log_size) | 280 const char *title, GdkPixbuf *pixbuf, int log_size) |
281 { | 281 { |
282 GaimGtkLogViewer *lv; | 282 GaimGtkLogViewer *lv; |
283 GtkWidget *title_box; | 283 GtkWidget *title_box; |
284 char *text; | 284 char *text; |
285 GtkWidget *pane; | |
286 GtkWidget *sw; | |
287 GtkCellRenderer *rend; | |
288 GtkTreeViewColumn *col; | |
289 GtkTreeSelection *sel; | |
290 GtkTreePath *path_to_first_log; | |
291 GtkWidget *vbox; | |
292 GtkWidget *frame; | |
293 GtkWidget *hbox; | |
294 GtkWidget *button; | |
295 GtkWidget *size_label; | |
285 | 296 |
286 lv = g_new0(GaimGtkLogViewer, 1); | 297 lv = g_new0(GaimGtkLogViewer, 1); |
287 lv->logs = logs; | 298 lv->logs = logs; |
299 | |
300 if (logs == NULL) | |
301 { | |
302 /* No logs were found. */ | |
303 const char *log_preferences = NULL; | |
304 | |
305 if (ht == NULL) { | |
306 if (!gaim_prefs_get_bool("/core/logging/log_system")) | |
307 log_preferences = _("System events will only be logged if the \"Log all status changes to system log\" preference is enabled."); | |
308 } else { | |
309 if (ht->type == GAIM_LOG_IM) { | |
310 if (!gaim_prefs_get_bool("/core/logging/log_ims")) | |
311 log_preferences = _("Instant messages will only be logged if the \"Log all instant messages\" preference is enabled."); | |
312 } else if (ht->type == GAIM_LOG_CHAT) { | |
313 if (!gaim_prefs_get_bool("/core/logging/log_chats")) | |
314 log_preferences = _("Chats will only be logged if the \"Log all chats preference\" is enabled."); | |
315 } | |
316 } | |
317 | |
318 gaim_notify_info(NULL, title, _("No logs were found"), log_preferences); | |
319 return NULL; | |
320 } | |
288 | 321 |
289 if (ht != NULL) | 322 if (ht != NULL) |
290 g_hash_table_insert(log_viewers, ht, lv); | 323 g_hash_table_insert(log_viewers, ht, lv); |
291 | 324 |
292 /* Window ***********/ | 325 /* Window ***********/ |
324 gtk_label_set_markup(GTK_LABEL(lv->label), text); | 357 gtk_label_set_markup(GTK_LABEL(lv->label), text); |
325 gtk_misc_set_alignment(GTK_MISC(lv->label), 0, 0); | 358 gtk_misc_set_alignment(GTK_MISC(lv->label), 0, 0); |
326 gtk_box_pack_start(GTK_BOX(title_box), lv->label, FALSE, FALSE, 0); | 359 gtk_box_pack_start(GTK_BOX(title_box), lv->label, FALSE, FALSE, 0); |
327 g_free(text); | 360 g_free(text); |
328 | 361 |
329 if (logs != NULL) { | 362 /* Pane *************/ |
330 GtkWidget *pane; | 363 pane = gtk_hpaned_new(); |
331 GtkWidget *sw; | 364 gtk_container_set_border_width(GTK_CONTAINER(pane), GAIM_HIG_BOX_SPACE); |
332 GtkCellRenderer *rend; | 365 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), pane, TRUE, TRUE, 0); |
333 GtkTreeViewColumn *col; | 366 |
334 GtkTreeSelection *sel; | 367 /* List *************/ |
335 GtkTreePath *path_to_first_log; | 368 sw = gtk_scrolled_window_new (NULL, NULL); |
336 GtkWidget *vbox; | 369 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); |
337 GtkWidget *frame; | 370 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); |
338 GtkWidget *hbox; | 371 gtk_paned_add1(GTK_PANED(pane), sw); |
339 GtkWidget *button; | 372 lv->treestore = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); |
340 GtkWidget *size_label; | 373 lv->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (lv->treestore)); |
341 | 374 rend = gtk_cell_renderer_text_new(); |
342 /* Pane *************/ | 375 col = gtk_tree_view_column_new_with_attributes ("time", rend, "markup", 0, NULL); |
343 pane = gtk_hpaned_new(); | 376 gtk_tree_view_append_column (GTK_TREE_VIEW(lv->treeview), col); |
344 gtk_container_set_border_width(GTK_CONTAINER(pane), GAIM_HIG_BOX_SPACE); | 377 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (lv->treeview), FALSE); |
345 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), pane, TRUE, TRUE, 0); | 378 gtk_container_add (GTK_CONTAINER (sw), lv->treeview); |
346 | 379 |
347 /* List *************/ | 380 populate_log_tree(lv); |
348 sw = gtk_scrolled_window_new (NULL, NULL); | 381 |
349 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); | 382 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (lv->treeview)); |
350 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | 383 g_signal_connect (G_OBJECT (sel), "changed", |
351 gtk_paned_add1(GTK_PANED(pane), sw); | 384 G_CALLBACK (log_select_cb), |
352 lv->treestore = gtk_tree_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); | 385 lv); |
353 lv->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (lv->treestore)); | 386 g_signal_connect (G_OBJECT(lv->treeview), "row-activated", |
354 rend = gtk_cell_renderer_text_new(); | 387 G_CALLBACK(log_row_activated_cb), |
355 col = gtk_tree_view_column_new_with_attributes ("time", rend, "markup", 0, NULL); | 388 lv); |
356 gtk_tree_view_append_column (GTK_TREE_VIEW(lv->treeview), col); | 389 gaim_set_accessible_label(lv->treeview, lv->label); |
357 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (lv->treeview), FALSE); | 390 |
358 gtk_container_add (GTK_CONTAINER (sw), lv->treeview); | 391 /* Log size ************/ |
359 | 392 if(log_size) { |
360 populate_log_tree(lv); | 393 char *sz_txt = gaim_str_size_to_units(log_size); |
361 | 394 text = g_strdup_printf("<span weight='bold'>%s</span> %s", _("Total log size:"), sz_txt); |
362 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (lv->treeview)); | 395 size_label = gtk_label_new(NULL); |
363 g_signal_connect (G_OBJECT (sel), "changed", | 396 gtk_label_set_markup(GTK_LABEL(size_label), text); |
364 G_CALLBACK (log_select_cb), | 397 /* gtk_paned_add1(GTK_PANED(pane), size_label); */ |
365 lv); | 398 gtk_misc_set_alignment(GTK_MISC(size_label), 0, 0); |
366 g_signal_connect (G_OBJECT(lv->treeview), "row-activated", | 399 gtk_box_pack_end(GTK_BOX(GTK_DIALOG(lv->window)->vbox), size_label, FALSE, FALSE, 0); |
367 G_CALLBACK(log_row_activated_cb), | 400 g_free(sz_txt); |
368 lv); | |
369 gaim_set_accessible_label(lv->treeview, lv->label); | |
370 | |
371 /* Log size ************/ | |
372 if(log_size) { | |
373 char *sz_txt = gaim_str_size_to_units(log_size); | |
374 text = g_strdup_printf("<span weight='bold'>%s</span> %s", _("Total log size:"), sz_txt); | |
375 size_label = gtk_label_new(NULL); | |
376 gtk_label_set_markup(GTK_LABEL(size_label), text); | |
377 /* gtk_paned_add1(GTK_PANED(pane), size_label); */ | |
378 gtk_misc_set_alignment(GTK_MISC(size_label), 0, 0); | |
379 gtk_box_pack_end(GTK_BOX(GTK_DIALOG(lv->window)->vbox), size_label, FALSE, FALSE, 0); | |
380 g_free(sz_txt); | |
381 g_free(text); | |
382 } | |
383 | |
384 /* A fancy little box ************/ | |
385 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
386 gtk_paned_add2(GTK_PANED(pane), vbox); | |
387 | |
388 /* Viewer ************/ | |
389 frame = gaim_gtk_create_imhtml(FALSE, &lv->imhtml, NULL); | |
390 gtk_widget_set_name(lv->imhtml, "gaim_gtklog_imhtml"); | |
391 gtk_widget_set_size_request(lv->imhtml, 320, 200); | |
392 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | |
393 gtk_widget_show(frame); | |
394 | |
395 /* Search box **********/ | |
396 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
397 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
398 lv->entry = gtk_entry_new(); | |
399 gtk_box_pack_start(GTK_BOX(hbox), lv->entry, TRUE, TRUE, 0); | |
400 button = gtk_button_new_from_stock(GTK_STOCK_FIND); | |
401 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
402 g_signal_connect(GTK_ENTRY(lv->entry), "activate", G_CALLBACK(search_cb), lv); | |
403 g_signal_connect(GTK_BUTTON(button), "activate", G_CALLBACK(search_cb), lv); | |
404 g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(search_cb), lv); | |
405 | |
406 /* Show most recent log **********/ | |
407 path_to_first_log = gtk_tree_path_new_from_string("0:0"); | |
408 if (path_to_first_log) | |
409 { | |
410 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(lv->treeview), path_to_first_log); | |
411 gtk_tree_selection_select_path(sel, path_to_first_log); | |
412 gtk_tree_path_free(path_to_first_log); | |
413 } | |
414 | |
415 } else { | |
416 /* No logs were found. */ | |
417 const char *log_preferences = NULL; | |
418 GtkWidget *label; | |
419 | |
420 if (ht == NULL) { | |
421 if (!gaim_prefs_get_bool("/core/logging/log_system")) | |
422 log_preferences = _("System events will only be logged if the <span style=\"italic\">Log all status changes to system log</span> preference is enabled."); | |
423 } else { | |
424 if (ht->type == GAIM_LOG_IM) { | |
425 if (!gaim_prefs_get_bool("/core/logging/log_ims")) | |
426 log_preferences = _("Instant messages will only be logged if the <span style=\"italic\">Log all instant messages</span> preference is enabled."); | |
427 } else if (ht->type == GAIM_LOG_CHAT) { | |
428 if (!gaim_prefs_get_bool("/core/logging/log_chats")) | |
429 log_preferences = _("Chats will only be logged if the <span style=\"italic\">Log all chats preference</span> is enabled."); | |
430 } | |
431 } | |
432 | |
433 text = g_strdup_printf("\n<span weight=\"bold\">%s</span>%s%s\n", | |
434 _("No logs were found."), | |
435 log_preferences ? "\n" : "", | |
436 log_preferences ? log_preferences : ""); | |
437 | |
438 label = gtk_label_new(NULL); | |
439 | |
440 gtk_label_set_markup(GTK_LABEL(label), text); | |
441 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
442 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
443 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(lv->window)->vbox), label, FALSE, FALSE, 0); | |
444 g_free(text); | 401 g_free(text); |
402 } | |
403 | |
404 /* A fancy little box ************/ | |
405 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
406 gtk_paned_add2(GTK_PANED(pane), vbox); | |
407 | |
408 /* Viewer ************/ | |
409 frame = gaim_gtk_create_imhtml(FALSE, &lv->imhtml, NULL); | |
410 gtk_widget_set_name(lv->imhtml, "gaim_gtklog_imhtml"); | |
411 gtk_widget_set_size_request(lv->imhtml, 320, 200); | |
412 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | |
413 gtk_widget_show(frame); | |
414 | |
415 /* Search box **********/ | |
416 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
417 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
418 lv->entry = gtk_entry_new(); | |
419 gtk_box_pack_start(GTK_BOX(hbox), lv->entry, TRUE, TRUE, 0); | |
420 button = gtk_button_new_from_stock(GTK_STOCK_FIND); | |
421 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
422 g_signal_connect(GTK_ENTRY(lv->entry), "activate", G_CALLBACK(search_cb), lv); | |
423 g_signal_connect(GTK_BUTTON(button), "activate", G_CALLBACK(search_cb), lv); | |
424 g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(search_cb), lv); | |
425 | |
426 /* Show most recent log **********/ | |
427 path_to_first_log = gtk_tree_path_new_from_string("0:0"); | |
428 if (path_to_first_log) | |
429 { | |
430 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(lv->treeview), path_to_first_log); | |
431 gtk_tree_selection_select_path(sel, path_to_first_log); | |
432 gtk_tree_path_free(path_to_first_log); | |
445 } | 433 } |
446 | 434 |
447 gtk_widget_show_all(lv->window); | 435 gtk_widget_show_all(lv->window); |
448 | 436 |
449 return lv; | 437 return lv; |