aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-main-window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/empathy-main-window.c')
-rw-r--r--src/empathy-main-window.c130
1 files changed, 97 insertions, 33 deletions
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 28198b037..c5f13dfaf 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -76,7 +76,6 @@
#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>
@@ -98,6 +97,11 @@ enum {
PAGE_NO_MATCH
};
+enum {
+ PROP_0,
+ PROP_SHELL_RUNNING
+};
+
G_DEFINE_TYPE (EmpathyMainWindow, empathy_main_window, GTK_TYPE_WINDOW);
#define GET_PRIV(self) ((EmpathyMainWindowPriv *)((EmpathyMainWindow *) self)->priv)
@@ -164,8 +168,7 @@ struct _EmpathyMainWindowPriv {
/* 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_members_changed_id;
+ gboolean shell_running;
};
static void
@@ -552,6 +555,23 @@ main_window_event_removed_cb (EmpathyEventManager *manager,
&data);
}
+static gboolean
+main_window_load_events_idle_cb (gpointer user_data)
+{
+ EmpathyMainWindow *window = user_data;
+ EmpathyMainWindowPriv *priv = GET_PRIV (window);
+ GSList *l;
+
+ l = empathy_event_manager_get_events (priv->event_manager);
+ while (l) {
+ main_window_event_added_cb (priv->event_manager, l->data,
+ window);
+ l = l->next;
+ }
+
+ return FALSE;
+}
+
static void
main_window_row_activated_cb (EmpathyContactListView *view,
GtkTreePath *path,
@@ -646,6 +666,12 @@ main_window_row_inserted_cb (GtkTreeModel *model,
gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
PAGE_CONTACT_LIST);
gtk_widget_grab_focus (GTK_WIDGET (priv->individual_view));
+
+ /* The store is being filled, it will be done after an idle cb.
+ * So we can then get events. If we do that too soon, event's
+ * contact is not yet in the store and it won't get marked as
+ * having events. */
+ g_idle_add (main_window_load_events_idle_cb, window);
}
}
@@ -1988,7 +2014,8 @@ empathy_main_window_show_preferences (EmpathyMainWindow *window,
EmpathyMainWindowPriv *priv = GET_PRIV (window);
if (priv->preferences == NULL) {
- priv->preferences = empathy_preferences_new (GTK_WINDOW (window));
+ priv->preferences = empathy_preferences_new (GTK_WINDOW (window),
+ priv->shell_running);
g_object_add_weak_pointer (G_OBJECT (priv->preferences),
(gpointer) &priv->preferences);
@@ -2118,9 +2145,11 @@ main_window_connection_items_setup (EmpathyMainWindow *window,
"room_join_favorites",
"chat_new_message",
"chat_new_call",
+ "chat_search_contacts",
"chat_add_contact",
"edit_personal_information",
- "edit_blocked_contacts"
+ "edit_blocked_contacts",
+ "edit_search_contacts"
};
for (i = 0, list = NULL; i < G_N_ELEMENTS (actions_connected); i++) {
@@ -2142,7 +2171,7 @@ account_manager_prepared_cb (GObject *source_object,
EmpathyMainWindowPriv *priv = GET_PRIV (window);
GError *error = NULL;
- if (!tp_account_manager_prepare_finish (manager, result, &error)) {
+ if (!tp_proxy_prepare_finish (manager, result, &error)) {
DEBUG ("Failed to prepare account manager: %s", error->message);
g_error_free (error);
return;
@@ -2175,25 +2204,17 @@ account_manager_prepared_cb (GObject *source_object,
g_list_free (accounts);
}
-static void
-main_window_members_changed_cb (EmpathyContactList *list,
- EmpathyContact *contact,
- EmpathyContact *actor,
- guint reason,
- gchar *message,
- gboolean is_member,
- EmpathyMainWindow *window)
+void
+empathy_main_window_set_shell_running (EmpathyMainWindow *window,
+ gboolean shell_running)
{
EmpathyMainWindowPriv *priv = GET_PRIV (window);
- if (!is_member)
+ if (priv->shell_running == shell_running)
return;
- if (!empathy_migrate_butterfly_logs (contact)) {
- g_signal_handler_disconnect (list,
- priv->butterfly_log_migration_members_changed_id);
- priv->butterfly_log_migration_members_changed_id = 0;
- }
+ priv->shell_running = shell_running;
+ g_object_notify (G_OBJECT (window), "shell-running");
}
static GObject *
@@ -2215,13 +2236,64 @@ empathy_main_window_constructor (GType type,
}
static void
+empathy_main_window_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EmpathyMainWindow *self = EMPATHY_MAIN_WINDOW (object);
+ EmpathyMainWindowPriv *priv = GET_PRIV (self);
+
+ switch (property_id)
+ {
+ case PROP_SHELL_RUNNING:
+ priv->shell_running = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+empathy_main_window_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EmpathyMainWindow *self = EMPATHY_MAIN_WINDOW (object);
+ EmpathyMainWindowPriv *priv = GET_PRIV (self);
+
+ switch (property_id)
+ {
+ case PROP_SHELL_RUNNING:
+ g_value_set_boolean (value, priv->shell_running);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
empathy_main_window_class_init (EmpathyMainWindowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GParamSpec *pspec;
object_class->finalize = empathy_main_window_finalize;
object_class->constructor = empathy_main_window_constructor;
+ object_class->set_property = empathy_main_window_set_property;
+ object_class->get_property = empathy_main_window_get_property;
+
+ pspec = g_param_spec_boolean ("shell-running",
+ "Shell running",
+ "Whether the Shell is running or not",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_SHELL_RUNNING, pspec);
+
g_type_class_add_private (object_class, sizeof (EmpathyMainWindowPriv));
}
@@ -2237,7 +2309,6 @@ empathy_main_window_init (EmpathyMainWindow *window)
GtkToolItem *item;
gboolean show_offline;
gchar *filename;
- GSList *l;
GtkTreeModel *model;
GtkWidget *search_vbox;
GtkWidget *menubar;
@@ -2254,6 +2325,10 @@ empathy_main_window_init (EmpathyMainWindow *window)
gtk_window_set_role (GTK_WINDOW (window), "contact_list");
gtk_window_set_default_size (GTK_WINDOW (window), 225, 325);
+ /* don't finalize the widget on delete-event, just hide it */
+ g_signal_connect (window, "delete-event",
+ G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+
/* Set up interface */
filename = empathy_file_lookup ("empathy-main-window.ui", "src");
gui = empathy_builder_get_file (filename,
@@ -2340,7 +2415,7 @@ empathy_main_window_init (EmpathyMainWindow *window)
priv->account_manager = tp_account_manager_dup ();
- tp_account_manager_prepare_async (priv->account_manager, NULL,
+ tp_proxy_prepare_async (priv->account_manager, NULL,
account_manager_prepared_cb, window);
priv->errors = g_hash_table_new_full (g_direct_hash,
@@ -2414,10 +2489,6 @@ empathy_main_window_init (EmpathyMainWindow *window)
EMPATHY_INDIVIDUAL_VIEW_FEATURE_ALL ^ EMPATHY_INDIVIDUAL_VIEW_FEATURE_PERSONA_DROP,
EMPATHY_INDIVIDUAL_FEATURE_ALL);
- priv->butterfly_log_migration_members_changed_id = g_signal_connect (
- priv->contact_manager, "members-changed",
- G_CALLBACK (main_window_members_changed_cb), window);
-
gtk_widget_show (GTK_WIDGET (priv->individual_view));
gtk_container_add (GTK_CONTAINER (sw),
GTK_WIDGET (priv->individual_view));
@@ -2478,13 +2549,6 @@ empathy_main_window_init (EmpathyMainWindow *window)
G_CALLBACK (main_window_account_disabled_cb),
window);
- l = empathy_event_manager_get_events (priv->event_manager);
- while (l) {
- main_window_event_added_cb (priv->event_manager, l->data,
- window);
- l = l->next;
- }
-
/* Show offline ? */
show_offline = g_settings_get_boolean (priv->gsettings_ui,
EMPATHY_PREFS_UI_SHOW_OFFLINE);