*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
* Authors: Martyn Russell <martyn@imendio.com>
* Xavier Claessens <xclaesse@gmail.com>
*/
#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-log-manager.h>
+#include <libempathy/empathy-account-manager.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;
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,
+ EmpathyAccount *account,
const gchar *chat_id,
gboolean is_chatroom);
static gboolean log_window_chats_get_selected (EmpathyLogWindow *window,
- McAccount **account,
+ EmpathyAccount **account,
gchar **chat_id,
gboolean *is_chatroom);
static void log_window_chats_get_messages (EmpathyLogWindow *window,
};
GtkWidget *
-empathy_log_window_show (McAccount *account,
+empathy_log_window_show (EmpathyAccount *account,
const gchar *chat_id,
gboolean is_chatroom,
GtkWindow *parent)
{
static EmpathyLogWindow *window = NULL;
EmpathyAccountChooser *account_chooser;
- GList *accounts;
+ EmpathyAccountManager *account_manager;
gint account_num;
- GladeXML *glade;
+ GtkBuilder *gui;
+ gchar *filename;
if (window) {
gtk_window_present (GTK_WINDOW (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",
- "log_window",
- NULL,
+ filename = empathy_file_lookup ("empathy-log-window.ui",
+ "libempathy-gtk");
+ gui = empathy_builder_get_file (filename,
"log_window", &window->window,
"notebook", &window->notebook,
"entry_find", &window->entry_find,
"treeview_chats", &window->treeview_chats,
"scrolledwindow_chats", &window->scrolledwindow_chats,
NULL);
- empathy_glade_connect (glade,
- window,
+ g_free (filename);
+
+ empathy_builder_connect (gui, window,
"log_window", "destroy", log_window_destroy_cb,
"entry_find", "changed", log_window_entry_find_changed_cb,
"button_previous", "clicked", log_window_button_previous_clicked_cb,
"entry_chats", "activate", log_window_entry_chats_activate_cb,
NULL);
- g_object_unref (glade);
+ g_object_unref (gui);
g_object_add_weak_pointer (G_OBJECT (window->window),
(gpointer) &window);
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));
window);
/* Populate */
- accounts = mc_accounts_list ();
- account_num = g_list_length (accounts);
- mc_accounts_list_free (accounts);
+ account_manager = empathy_account_manager_dup_singleton ();
+ account_num = empathy_account_manager_get_count (account_manager);
+ g_object_unref (account_manager);
if (account_num > 1) {
gtk_widget_show (window->vbox_chats);
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);
str = gtk_entry_get_text (GTK_ENTRY (window->entry_find));
- is_sensitive &= !G_STR_EMPTY (str);
- is_sensitive &=
- !window->last_find ||
+ is_sensitive &= !EMP_STR_EMPTY (str);
+ is_sensitive &=
+ !window->last_find ||
(window->last_find && strcmp (window->last_find, str) != 0);
gtk_widget_set_sensitive (window->button_find, is_sensitive);
GtkTreeView *view;
GtkTreeModel *model;
GtkTreeIter iter;
- McAccount *account;
+ EmpathyAccount *account;
gchar *chat_id;
gboolean is_chatroom;
gchar *date;
gtk_widget_set_sensitive (window->button_next, FALSE);
empathy_chat_view_clear (window->chatview_find);
-
+
return;
}
gtk_list_store_clear (store);
- if (G_STR_EMPTY (search_criteria)) {
+ if (EMP_STR_EMPTY (search_criteria)) {
/* Just clear the search. */
return;
}
}
date_readable = empathy_log_manager_get_date_readable (hit->date);
- account_name = mc_account_get_display_name (hit->account);
- account_icon = empathy_icon_name_from_account (hit->account);
+ account_name = empathy_account_get_display_name (hit->account);
+ account_icon = empathy_account_get_icon_name (hit->account);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
store = gtk_list_store_new (COL_FIND_COUNT,
G_TYPE_STRING, /* account icon name */
G_TYPE_STRING, /* account name */
- MC_TYPE_ACCOUNT, /* account */
+ EMPATHY_TYPE_ACCOUNT, /* account */
G_TYPE_STRING, /* chat name */
G_TYPE_STRING, /* chat id */
G_TYPE_BOOLEAN, /* is chatroom */
log_window_chats_populate (EmpathyLogWindow *window)
{
EmpathyAccountChooser *account_chooser;
- McAccount *account;
+ EmpathyAccount *account;
GList *chats, *l;
GtkTreeView *view;
GtkTreeIter iter;
account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats);
- account = empathy_account_chooser_get_account (account_chooser);
+ account = empathy_account_chooser_dup_account (account_chooser);
view = GTK_TREE_VIEW (window->treeview_chats);
model = gtk_tree_view_get_model (view);
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,
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
COL_CHAT_ICON, "empathy-available", /* FIXME */
- COL_CHAT_NAME, hit->chat_id,
+ COL_CHAT_NAME, hit->chat_id,
COL_CHAT_ACCOUNT, account,
COL_CHAT_ID, hit->chat_id,
COL_CHAT_IS_CHATROOM, hit->is_chatroom,
/* new store */
store = gtk_list_store_new (COL_CHAT_COUNT,
- G_TYPE_STRING, /* icon */
- G_TYPE_STRING, /* name */
- MC_TYPE_ACCOUNT, /* account */
- G_TYPE_STRING, /* id */
- G_TYPE_BOOLEAN); /* is chatroom */
+ G_TYPE_STRING, /* icon */
+ G_TYPE_STRING, /* name */
+ EMPATHY_TYPE_ACCOUNT, /* account */
+ G_TYPE_STRING, /* id */
+ G_TYPE_BOOLEAN); /* is chatroom */
model = GTK_TREE_MODEL (store);
sortable = GTK_TREE_SORTABLE (store);
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,
+ EmpathyAccount *account,
const gchar *chat_id,
gboolean is_chatroom)
{
}
for (ok = TRUE; ok; ok = gtk_tree_model_iter_next (model, &iter)) {
- McAccount *this_account;
+ EmpathyAccount *this_account;
gchar *this_chat_id;
gboolean this_is_chatroom;
COL_CHAT_IS_CHATROOM, &this_is_chatroom,
-1);
- if (empathy_account_equal (this_account, account) &&
+ if (this_account == account &&
strcmp (this_chat_id, chat_id) == 0 &&
this_is_chatroom == is_chatroom) {
gtk_tree_selection_select_iter (selection, &iter);
static gboolean
log_window_chats_get_selected (EmpathyLogWindow *window,
- McAccount **account,
+ EmpathyAccount **account,
gchar **chat_id,
gboolean *is_chatroom)
{
GtkTreeSelection *selection;
GtkTreeIter iter;
gchar *id = NULL;
- McAccount *acc = NULL;
+ EmpathyAccount *acc = NULL;
gboolean room = FALSE;
view = GTK_TREE_VIEW (window->treeview_chats);
log_window_chats_get_messages (EmpathyLogWindow *window,
const gchar *date_to_show)
{
- McAccount *account;
+ EmpathyAccount *account;
gchar *chat_id;
gboolean is_chatroom;
EmpathyMessage *message;
}
- 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) {
/* 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);
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);
log_window_calendar_chats_month_changed_cb (GtkWidget *calendar,
EmpathyLogWindow *window)
{
- McAccount *account;
+ EmpathyAccount *account;
gchar *chat_id;
gboolean is_chatroom;
guint year_selected;
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;
}
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);
}
}
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