#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy-gtk/empathy-notify-manager.h>
+ #include "empathy-chat-manager.h"
#include "empathy-chat-window.h"
#include "empathy-about-dialog.h"
#include "empathy-invite-participant-dialog.h"
GtkTargetList *contact_targets;
GtkTargetList *file_targets;
+ EmpathyChatManager *chat_manager;
+ gulong chat_manager_chats_changed_id;
+
/* Menu items. */
GtkUIManager *ui_manager;
GtkAction *menu_conv_insert_smiley;
GtkAction *menu_tabs_next;
GtkAction *menu_tabs_prev;
+ GtkAction *menu_tabs_undo_close_tab;
GtkAction *menu_tabs_left;
GtkAction *menu_tabs_right;
GtkAction *menu_tabs_detach;
{ "text/contact-id", 0, DND_DRAG_TYPE_CONTACT_ID },
{ "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, DND_DRAG_TYPE_TAB },
{ "text/uri-list", 0, DND_DRAG_TYPE_URI_LIST },
+ { "text/path-list", 0, DND_DRAG_TYPE_URI_LIST },
};
static const GtkTargetEntry drag_types_dest_contact[] = {
};
static const GtkTargetEntry drag_types_dest_file[] = {
+ /* must be first to be prioritized, in order to receive the
+ * note's file path from Tomboy instead of an URI */
+ { "text/path-list", 0, DND_DRAG_TYPE_URI_LIST },
{ "text/uri-list", 0, DND_DRAG_TYPE_URI_LIST },
};
{
gboolean first_page;
gboolean last_page;
+ gboolean wrap_around;
gboolean is_connected;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
first_page = (page_num == 0);
last_page = (page_num == (num_pages - 1));
+ g_object_get (gtk_settings_get_default (), "gtk-keynav-wrap-around",
+ &wrap_around, NULL);
is_connected = empathy_chat_get_tp_chat (priv->current_chat) != NULL;
- DEBUG ("Update window : Menu Contexts (Tabs & Conv)");
-
- gtk_action_set_sensitive (priv->menu_tabs_next, TRUE);
- gtk_action_set_sensitive (priv->menu_tabs_prev, TRUE);
+ gtk_action_set_sensitive (priv->menu_tabs_next, (!last_page ||
+ wrap_around));
+ gtk_action_set_sensitive (priv->menu_tabs_prev, (!first_page ||
+ wrap_around));
gtk_action_set_sensitive (priv->menu_tabs_detach, num_pages > 1);
gtk_action_set_sensitive (priv->menu_tabs_left, !first_page);
gtk_action_set_sensitive (priv->menu_tabs_right, !last_page);
"/chats_menubar/menu_contact");
orig_submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu));
- DEBUG ("Update window : Contact Menu");
-
if (orig_submenu == NULL || !GTK_WIDGET_VISIBLE (orig_submenu)) {
submenu = empathy_chat_get_contact_menu (priv->current_chat);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), submenu);
{
gchar *name;
- DEBUG ("Update window : Title");
-
name = get_window_title_name (priv);
gtk_window_set_title (GTK_WINDOW (priv->dialog), name);
g_free (name);
n_chats = g_list_length (priv->chats);
- DEBUG ("Update window : Icon");
-
/* Update window icon */
if (priv->chats_new_msg) {
gtk_window_set_icon_name (GTK_WINDOW (priv->dialog),
GtkWidget *chat_close_button;
gint i;
- DEBUG ("Update window : Close Button");
-
if (num_pages == 1) {
chat = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 0);
chat_close_button = g_object_get_data (G_OBJECT (chat),
num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
- DEBUG ("Update window");
-
/* Update Tab menu */
chat_window_menu_context_update (priv,
num_pages);
EmpathyTpChat *tp_chat;
TpChannel *channel;
int response;
+ TpAccount *account;
priv = GET_PRIV (window);
tp_chat = empathy_chat_get_tp_chat (priv->current_chat);
channel = empathy_tp_chat_get_channel (tp_chat);
+ account = empathy_chat_get_account (priv->current_chat);
dialog = empathy_invite_participant_dialog_new (
- GTK_WINDOW (priv->dialog));
+ GTK_WINDOW (priv->dialog), account);
gtk_widget_show (dialog);
response = gtk_dialog_run (GTK_DIALOG (dialog));
EmpathyChatWindowPriv *priv;
EmpathyChat *chat;
gint index_, numPages;
+ gboolean wrap_around;
priv = GET_PRIV (window);
+ g_object_get (gtk_settings_get_default (), "gtk-keynav-wrap-around",
+ &wrap_around, NULL);
+
chat = priv->current_chat;
index_ = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
numPages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
- if (index_ == (numPages - 1)) {
+ if (index_ == (numPages - 1) && wrap_around) {
gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 0);
return;
}
EmpathyChatWindowPriv *priv;
EmpathyChat *chat;
gint index_, numPages;
+ gboolean wrap_around;
priv = GET_PRIV (window);
+ g_object_get (gtk_settings_get_default (), "gtk-keynav-wrap-around",
+ &wrap_around, NULL);
+
chat = priv->current_chat;
index_ = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
numPages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
- if (index_ <= 0) {
+ if (index_ <= 0 && wrap_around) {
gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), numPages - 1);
return;
}
gtk_notebook_prev_page (GTK_NOTEBOOK (priv->notebook));
}
+ static void
+ chat_window_tabs_undo_close_tab_activate_cb (GtkAction *action,
+ EmpathyChatWindow *window)
+ {
+ EmpathyChatWindowPriv *priv = GET_PRIV (window);
+ empathy_chat_manager_undo_closed_chat (priv->chat_manager);
+ }
+
static void
chat_window_tabs_left_activate_cb (GtkAction *action,
EmpathyChatWindow *window)
priv = GET_PRIV (window);
- DEBUG ("Turning %s urgency hint", urgent ? "on" : "off");
gtk_window_set_urgency_hint (GTK_WINDOW (priv->dialog), urgent);
}
{
EmpathyChatWindowPriv *priv;
- DEBUG ("Focus in event, updating title");
-
priv = GET_PRIV (window);
priv->chats_new_msg = g_list_remove (priv->chats_new_msg, priv->current_chat);
int x,
int y,
guint time_,
- gpointer user_data)
+ EmpathyChatWindow *window)
{
- GdkAtom target, uri_target, contact_target;
+ GdkAtom target;
+ EmpathyChatWindowPriv *priv;
+
+ priv = GET_PRIV (window);
- target = gtk_drag_dest_find_target (widget, context, NULL);
- uri_target = gdk_atom_intern_static_string ("text/uri-list");
- contact_target = gdk_atom_intern_static_string ("text/contact-id");
+ target = gtk_drag_dest_find_target (widget, context, priv->file_targets);
+ if (target == GDK_NONE)
+ target = gtk_drag_dest_find_target (widget, context, priv->contact_targets);
- if (target == uri_target || target == contact_target) {
+ if (target != GDK_NONE) {
gtk_drag_get_data (widget, context, target, time_);
return TRUE;
}
{
GdkAtom target;
EmpathyChatWindowPriv *priv;
- GdkAtom dest_target;
priv = GET_PRIV (window);
- target = gtk_drag_dest_find_target (widget, context, NULL);
-
- dest_target = gdk_atom_intern_static_string ("text/uri-list");
- if (target == dest_target) {
+ target = gtk_drag_dest_find_target (widget, context, priv->file_targets);
+ if (target != GDK_NONE) {
/* This is a file drag. Ensure the contact is online and set the
drag type to COPY. Note that it's possible that the tab will
be switched by GTK+ after a timeout from drag_motion without
return TRUE;
}
- dest_target = gdk_atom_intern_static_string ("text/contact-id");
- if (target == dest_target) {
+ target = gtk_drag_dest_find_target (widget, context, priv->contact_targets);
+ if (target != GDK_NONE) {
/* This is a drag of a contact from a contact list. Set to COPY.
FIXME: If this drag is to a MUC window, it invites the user.
Otherwise, it opens a chat. Should we use a different drag
}
}
+ static void
+ chat_window_chat_manager_chats_changed_cb (EmpathyChatManager *chat_manager,
+ guint num_chats_in_manager,
+ EmpathyChatWindow *window)
+ {
+ EmpathyChatWindowPriv *priv = GET_PRIV (window);
+
+ gtk_action_set_sensitive (priv->menu_tabs_undo_close_tab,
+ num_chats_in_manager > 0);
+ }
+
static void
chat_window_finalize (GObject *object)
{
gtk_target_list_unref (priv->file_targets);
}
+ if (priv->chat_manager) {
+ g_signal_handler_disconnect (priv->chat_manager,
+ priv->chat_manager_chats_changed_id);
+ g_object_unref (priv->chat_manager);
+ priv->chat_manager = NULL;
+ }
+
chat_windows = g_list_remove (chat_windows, window);
gtk_widget_destroy (priv->dialog);
"menu_edit_find", &priv->menu_edit_find,
"menu_tabs_next", &priv->menu_tabs_next,
"menu_tabs_prev", &priv->menu_tabs_prev,
+ "menu_tabs_undo_close_tab", &priv->menu_tabs_undo_close_tab,
"menu_tabs_left", &priv->menu_tabs_left,
"menu_tabs_right", &priv->menu_tabs_right,
"menu_tabs_detach", &priv->menu_tabs_detach,
"menu_edit_find", "activate", chat_window_find_activate_cb,
"menu_tabs_next", "activate", chat_window_tabs_next_activate_cb,
"menu_tabs_prev", "activate", chat_window_tabs_previous_activate_cb,
+ "menu_tabs_undo_close_tab", "activate", chat_window_tabs_undo_close_tab_activate_cb,
"menu_tabs_left", "activate", chat_window_tabs_left_activate_cb,
"menu_tabs_right", "activate", chat_window_tabs_right_activate_cb,
"menu_tabs_detach", "activate", chat_window_detach_activate_cb,
priv->current_chat = NULL;
priv->notify_mgr = empathy_notify_manager_dup_singleton ();
+
+ priv->chat_manager = empathy_chat_manager_dup_singleton ();
+ priv->chat_manager_chats_changed_id =
+ g_signal_connect (priv->chat_manager, "chats-changed",
+ G_CALLBACK (chat_window_chat_manager_chats_changed_cb),
+ window);
+
+ chat_window_chat_manager_chats_changed_cb (priv->chat_manager,
+ empathy_chat_manager_get_num_chats (priv->chat_manager),
+ window);
}
EmpathyChatWindow *
EmpathyChatWindowPriv *priv;
gint position;
EmpathyContact *remote_contact;
+ EmpathyChatManager *chat_manager;
g_return_if_fail (window != NULL);
g_return_if_fail (EMPATHY_IS_CHAT (chat));
chat);
}
+ chat_manager = empathy_chat_manager_dup_singleton ();
+ empathy_chat_manager_closed_chat (chat_manager, chat);
+ g_object_unref (chat_manager);
+
position = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook),
GTK_WIDGET (chat));
gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), position);
priv = GET_PRIV (window);
empathy_chat_window_switch_to_chat (window, chat);
- empathy_window_present (GTK_WINDOW (priv->dialog), TRUE);
+ empathy_window_present (GTK_WINDOW (priv->dialog));
gtk_widget_grab_focus (chat->input_text_view);
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2002-2007 Imendio AB
- * Copyright (C) 2007-2008 Collabora Ltd.
+ * Copyright (C) 2007-2010 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
#include <sys/stat.h>
#include <gtk/gtk.h>
+ #include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
#include <telepathy-glib/account-manager.h>
#include <libempathy-gtk/empathy-ui-utils.h>
#include "empathy-accounts-dialog.h"
+ #include "empathy-chat-manager.h"
#include "empathy-main-window.h"
#include "ephy-spinner.h"
#include "empathy-preferences.h"
#include "empathy-chatrooms-window.h"
#include "empathy-event-manager.h"
#include "empathy-ft-manager.h"
+#include "empathy-migrate-butterfly-logs.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
/* Actions that are enabled when there are connected accounts */
GList *actions_connected;
+
+ /* The idle event source to migrate butterfly's logs */
+ guint butterfly_log_migration_contact_added_id;
} EmpathyMainWindow;
static EmpathyMainWindow *main_window = NULL;
account = g_object_get_data (G_OBJECT (button), "account");
empathy_accounts_dialog_show_application (
- gtk_widget_get_screen (GTK_WIDGET (button)), NULL, NULL,
+ gtk_widget_get_screen (GTK_WIDGET (button)),
account, FALSE, FALSE);
main_window_remove_error (window, account);
label = gtk_label_new (str);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_widget_show (label);
g_free (str);
window);
g_object_unref (window->event_manager);
g_object_unref (window->ui_manager);
+ g_object_unref (window->chatroom_manager);
g_free (window);
}
+ static gboolean
+ main_window_key_press_event_cb (GtkWidget *window,
+ GdkEventKey *event,
+ gpointer user_data)
+ {
+ EmpathyChatManager *chat_manager;
+
+ if (event->keyval == GDK_T
+ && event->state & GDK_SHIFT_MASK
+ && event->state & GDK_CONTROL_MASK) {
+ chat_manager = empathy_chat_manager_dup_singleton ();
+ empathy_chat_manager_undo_closed_chat (chat_manager);
+ g_object_unref (chat_manager);
+ }
+ return FALSE;
+ }
+
static void
main_window_chat_quit_cb (GtkAction *action,
EmpathyMainWindow *window)
EmpathyMainWindow *window)
{
empathy_accounts_dialog_show_application (gdk_screen_get_default (),
- NULL, NULL, NULL, FALSE, FALSE);
+ NULL, FALSE, FALSE);
}
static void
main_window_help_debug_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- empathy_debug_window_new (NULL);
+ GdkScreen *screen = gdk_screen_get_default ();
+ GError *error = NULL;
+ gchar *argv[2] = { NULL, };
+ gint i = 0;
+ gchar *path;
+
+ g_return_if_fail (GDK_IS_SCREEN (screen));
+
+ /* Try to run from source directory if possible */
+ path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "src",
+ "empathy-debugger", NULL);
+
+ if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
+ g_free (path);
+ path = g_build_filename (BIN_DIR, "empathy-debugger", NULL);
+ }
+
+ argv[i++] = path;
+
+ gdk_spawn_on_screen (screen, NULL, argv, NULL,
+ G_SPAWN_SEARCH_PATH,
+ NULL, NULL, NULL, &error);
+
+ if (error) {
+ g_warning ("Failed to open debug window: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_free (path);
}
static void
empathy_accounts_dialog_show_application (
gtk_widget_get_screen (GTK_WIDGET (throbber_ebox)),
- NULL, NULL, NULL, FALSE, FALSE);
+ NULL, FALSE, FALSE);
return FALSE;
}
g_list_free (accounts);
}
+static void
+main_window_contact_added_cb (EmpathyContactMonitor *monitor,
+ EmpathyContact *contact,
+ EmpathyMainWindow *window)
+{
+ if (!empathy_migrate_butterfly_logs (contact)) {
+ g_signal_handler_disconnect (monitor,
+ window->butterfly_log_migration_contact_added_id);
+ window->butterfly_log_migration_contact_added_id = 0;
+ }
+}
+
GtkWidget *
empathy_main_window_show (void)
{
GSList *l;
if (main_window) {
- empathy_window_present (GTK_WINDOW (main_window->window), TRUE);
+ empathy_window_present (GTK_WINDOW (main_window->window));
return main_window->window;
}
empathy_builder_connect (gui, window,
"main_window", "destroy", main_window_destroy_cb,
+ "main_window", "key-press-event", main_window_key_press_event_cb,
"chat_quit", "activate", main_window_chat_quit_cb,
"chat_new_message", "activate", main_window_chat_new_message_cb,
"chat_new_call", "activate", main_window_chat_new_call_cb,
EMPATHY_CONTACT_FEATURE_ALL);
g_signal_connect (monitor, "contact-presence-changed",
G_CALLBACK (main_window_contact_presence_changed_cb), window);
+ window->butterfly_log_migration_contact_added_id = g_signal_connect (monitor, "contact-added",
+ G_CALLBACK (main_window_contact_added_cb), window);
g_object_unref (list_iface);
gtk_widget_show (GTK_WIDGET (window->list_view));
#include "empathy-import-mc4-accounts.h"
#include "empathy-accounts-common.h"
#include "empathy-accounts-dialog.h"
+ #include "empathy-chat-manager.h"
#include "empathy-status-icon.h"
#include "empathy-call-window.h"
#include "empathy-chat-window.h"
g_free (old_dir);
}
-static void
-accounts_application_exited_cb (GPid pid,
- gint status,
- gpointer data)
-{
- if (status)
- {
- g_warning ("accounts application exited with status %d: '%s'",
- status, g_strerror (status));
- }
-}
-
static void
show_accounts_ui (GdkScreen *screen,
gboolean if_needed)
{
empathy_accounts_dialog_show_application (screen,
- accounts_application_exited_cb, NULL, NULL, if_needed, start_hidden);
+ NULL, if_needed, start_hidden);
}
static UniqueResponse
account_manager_chatroom_ready_cb, chatroom_manager);
}
+static void
+empathy_idle_set_auto_away_cb (EmpathyConf *conf,
+ const gchar *key,
+ gpointer user_data)
+{
+ gboolean autoaway;
+ EmpathyIdle *idle = user_data;
+
+ empathy_conf_get_bool (conf, key, &autoaway);
+ empathy_idle_set_auto_away (idle, autoaway);
+}
+
int
main (int argc, char *argv[])
{
GtkWidget *window;
EmpathyIdle *idle;
EmpathyConnectivity *connectivity;
+ EmpathyChatManager *chat_manager;
GError *error = NULL;
UniqueApp *unique_app;
gboolean chatroom_manager_ready;
-
+ gboolean autoaway = TRUE;
#ifdef ENABLE_DEBUG
TpDebugSender *debug_sender;
-#endif /* ENABLE_TPL */
+#endif
GOptionContext *optcontext;
GOptionEntry options[] = {
/* Setting up Idle */
idle = empathy_idle_dup_singleton ();
- empathy_idle_set_auto_away (idle, TRUE);
+
+ empathy_conf_get_bool (empathy_conf_get (),
+ EMPATHY_PREFS_AUTOAWAY, &autoaway);
+
+ empathy_conf_notify_add (empathy_conf_get (),
+ EMPATHY_PREFS_AUTOAWAY,
+ empathy_idle_set_auto_away_cb,
+ idle);
+
+ empathy_idle_set_auto_away (idle, autoaway);
/* Setting up Connectivity */
connectivity = empathy_connectivity_dup_singleton ();
window = empathy_main_window_show ();
icon = empathy_status_icon_new (GTK_WINDOW (window), start_hidden);
+ /* Chat manager */
+ chat_manager = empathy_chat_manager_dup_singleton ();
+
g_signal_connect (unique_app, "message-received",
G_CALLBACK (unique_app_message_cb), window);
g_object_unref (debug_sender);
#endif
+ g_object_unref (chat_manager);
g_object_unref (idle);
g_object_unref (connectivity);
g_object_unref (icon);