]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-log-window.c
Add en_GB in gitignore
[empathy.git] / libempathy-gtk / empathy-log-window.c
index da553075f45b5946ef419d3f6fb4b77a22a7987b..24633e5653e17ca25c97c7e7b3697c676d9b686a 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * Copyright (C) 2006-2007 Imendio AB
- * Copyright (C) 2007 Collabora Ltd.
+ * Copyright (C) 2007-2008 Collabora Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -27,7 +27,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include <glade/glade.h>
 
 #include <libempathy/empathy-chatroom-manager.h>
 #include <libempathy/empathy-chatroom.h>
 #include <libempathy/empathy-message.h>
-#include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-time.h>
 
 #include "empathy-log-window.h"
 #include "empathy-account-chooser.h"
 #include "empathy-chat-view.h"
+#include "empathy-theme-manager.h"
 #include "empathy-ui-utils.h"
 
-#define DEBUG_DOMAIN "LogWindow"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 typedef struct {
        GtkWidget         *window;
@@ -93,9 +94,6 @@ static void     log_window_chats_populate                  (EmpathyLogWindow *wi
 static void     log_window_chats_setup                     (EmpathyLogWindow *window);
 static void     log_window_chats_accounts_changed_cb       (GtkWidget        *combobox,
                                                            EmpathyLogWindow *window);
-static void     log_window_chats_new_message_cb            (EmpathyContact   *own_contact,
-                                                           EmpathyMessage   *message,
-                                                           EmpathyLogWindow *window);
 static void     log_window_chats_set_selected              (EmpathyLogWindow *window,
                                                            McAccount        *account,
                                                            const gchar      *chat_id,
@@ -136,7 +134,7 @@ enum {
        COL_CHAT_COUNT
 };
 
-void
+GtkWidget *
 empathy_log_window_show (McAccount   *account,
                        const gchar *chat_id,
                        gboolean     is_chatroom,
@@ -147,6 +145,7 @@ empathy_log_window_show (McAccount   *account,
        GList                  *accounts;
        gint                    account_num;
        GladeXML               *glade;
+       gchar                  *filename;
 
        if (window) {
                gtk_window_present (GTK_WINDOW (window->window));
@@ -157,13 +156,15 @@ empathy_log_window_show (McAccount   *account,
                                                       chat_id, is_chatroom);
                }
 
-               return;
+               return window->window;
        }
 
        window = g_new0 (EmpathyLogWindow, 1);
-       window->log_manager = empathy_log_manager_new ();
+       window->log_manager = empathy_log_manager_dup_singleton ();
 
-       glade = empathy_glade_get_file ("empathy-log-window.glade",
+       filename = empathy_file_lookup ("empathy-log-window.glade",
+                                       "libempathy-gtk");
+       glade = empathy_glade_get_file (filename,
                                       "log_window",
                                       NULL,
                                       "log_window", &window->window,
@@ -180,6 +181,8 @@ empathy_log_window_show (McAccount   *account,
                                       "treeview_chats", &window->treeview_chats,
                                       "scrolledwindow_chats", &window->scrolledwindow_chats,
                                       NULL);
+       g_free (filename);
+
        empathy_glade_connect (glade,
                              window,
                              "log_window", "destroy", log_window_destroy_cb,
@@ -205,13 +208,13 @@ empathy_log_window_show (McAccount   *account,
                          window);
 
        /* Configure Search EmpathyChatView */
-       window->chatview_find = empathy_chat_view_new ();
+       window->chatview_find = empathy_theme_manager_create_view (empathy_theme_manager_get ());
        gtk_container_add (GTK_CONTAINER (window->scrolledwindow_find),
                           GTK_WIDGET (window->chatview_find));
        gtk_widget_show (GTK_WIDGET (window->chatview_find));
 
        /* Configure Contacts EmpathyChatView */
-       window->chatview_chats = empathy_chat_view_new ();
+       window->chatview_chats = empathy_theme_manager_create_view (empathy_theme_manager_get ());
        gtk_container_add (GTK_CONTAINER (window->scrolledwindow_chats),
                           GTK_WIDGET (window->chatview_chats));
        gtk_widget_show (GTK_WIDGET (window->chatview_chats));
@@ -261,16 +264,14 @@ empathy_log_window_show (McAccount   *account,
        }
 
        gtk_widget_show (window->window);
+
+       return window->window;
 }
 
 static void
 log_window_destroy_cb (GtkWidget       *widget,
                       EmpathyLogWindow *window)
 {
-       g_signal_handlers_disconnect_by_func (window->log_manager,
-                                             log_window_chats_new_message_cb,
-                                             window);
-
        g_free (window->last_find);
        g_object_unref (window->log_manager);
 
@@ -289,7 +290,7 @@ log_window_entry_find_changed_cb (GtkWidget       *entry,
 
        str = gtk_entry_get_text (GTK_ENTRY (window->entry_find));
 
-       is_sensitive &= !G_STR_EMPTY (str);
+       is_sensitive &= !EMP_STR_EMPTY (str);
        is_sensitive &= 
                !window->last_find || 
                (window->last_find && strcmp (window->last_find, str) != 0);
@@ -399,7 +400,7 @@ log_window_find_populate (EmpathyLogWindow *window,
 
        gtk_list_store_clear (store);
 
-       if (G_STR_EMPTY (search_criteria)) {
+       if (EMP_STR_EMPTY (search_criteria)) {
                /* Just clear the search. */
                return;
        }
@@ -628,6 +629,11 @@ log_window_chats_populate (EmpathyLogWindow *window)
        selection = gtk_tree_view_get_selection (view);
        store = GTK_LIST_STORE (model);
 
+       if (account == NULL) {
+               gtk_list_store_clear (store);
+               return;
+       }
+
        /* Block signals to stop the logs being retrieved prematurely */
        g_signal_handlers_block_by_func (selection,
                                         log_window_chats_changed_cb,
@@ -735,17 +741,6 @@ log_window_chats_accounts_changed_cb (GtkWidget       *combobox,
        log_window_chats_populate (window);
 }
 
-static void
-log_window_chats_new_message_cb (EmpathyContact   *own_contact,
-                                EmpathyMessage   *message,
-                                EmpathyLogWindow *window)
-{
-       empathy_chat_view_append_message (window->chatview_chats, message);
-
-       /* Scroll to the most recent messages */
-       empathy_chat_view_scroll_down (window->chatview_chats);
-}
-
 static void
 log_window_chats_set_selected  (EmpathyLogWindow *window,
                                McAccount       *account,
@@ -906,7 +901,7 @@ log_window_chats_get_messages (EmpathyLogWindow *window,
                        }
 
 
-                       empathy_debug (DEBUG_DOMAIN, "Marking date:'%s'", str);
+                       DEBUG ("Marking date:'%s'", str);
                        gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), day);
 
                        if (l->next) {
@@ -970,9 +965,6 @@ log_window_chats_get_messages (EmpathyLogWindow *window,
        /* Turn back on scrolling */
        empathy_chat_view_scroll (window->chatview_find, TRUE);
 
-       /* Scroll to the most recent messages */
-       empathy_chat_view_scroll_down (window->chatview_chats);
-
        /* Give the search entry main focus */
        gtk_widget_grab_focus (window->entry_chats);
 
@@ -1000,7 +992,7 @@ log_window_calendar_chats_day_selected_cb (GtkWidget       *calendar,
 
        date = g_strdup_printf ("%4.4d%2.2d%2.2d", year, month, day);
 
-       empathy_debug (DEBUG_DOMAIN, "Currently selected date is:'%s'", date);
+       DEBUG ("Currently selected date is:'%s'", date);
 
        log_window_chats_get_messages (window, date);
 
@@ -1024,7 +1016,7 @@ log_window_calendar_chats_month_changed_cb (GtkWidget       *calendar,
 
        if (!log_window_chats_get_selected (window, &account,
                                            &chat_id, &is_chatroom)) {
-               empathy_debug (DEBUG_DOMAIN, "No chat selected to get dates for...");
+               DEBUG ("No chat selected to get dates for...");
                return;
        }
 
@@ -1056,7 +1048,7 @@ log_window_calendar_chats_month_changed_cb (GtkWidget       *calendar,
                sscanf (str, "%4d%2d%2d", &year, &month, &day);
 
                if (year == year_selected && month == month_selected) {
-                       empathy_debug (DEBUG_DOMAIN, "Marking date:'%s'", str);
+                       DEBUG ("Marking date:'%s'", str);
                        gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), day);
                }
        }
@@ -1064,9 +1056,8 @@ log_window_calendar_chats_month_changed_cb (GtkWidget       *calendar,
        g_list_foreach (dates, (GFunc) g_free, NULL);
        g_list_free (dates);
 
-       empathy_debug (DEBUG_DOMAIN,
-                     "Currently showing month %d and year %d",
-                     month_selected, year_selected);
+       DEBUG ("Currently showing month %d and year %d", month_selected,
+               year_selected);
 }
 
 static void