#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>
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)
/* 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
&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,
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);
}
}
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);
"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++) {
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;
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 *
return window;
}
+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));
}
GtkToolItem *item;
gboolean show_offline;
gchar *filename;
- GSList *l;
GtkTreeModel *model;
GtkWidget *search_vbox;
GtkWidget *menubar;
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,
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,
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));
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);