aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/empathy-accounts-common.c30
-rw-r--r--src/empathy-accounts-common.h2
-rw-r--r--src/empathy-accounts.c106
-rw-r--r--src/empathy-debugger.c5
-rw-r--r--src/empathy-main-window.c2
-rw-r--r--src/empathy-status-icon.c4
-rw-r--r--src/empathy.c7
7 files changed, 76 insertions, 80 deletions
diff --git a/src/empathy-accounts-common.c b/src/empathy-accounts-common.c
index a08a1ef77..88d14c321 100644
--- a/src/empathy-accounts-common.c
+++ b/src/empathy-accounts-common.c
@@ -85,28 +85,30 @@ empathy_accounts_has_accounts (TpAccountManager *manager)
static void
do_show_accounts_ui (TpAccountManager *manager,
TpAccount *account,
- GCallback window_destroyed_cb)
+ GApplication *app)
{
static GtkWidget *accounts_window = NULL;
if (accounts_window == NULL)
- accounts_window = empathy_accounts_dialog_show (NULL, account);
+ {
+ accounts_window = empathy_accounts_dialog_show (NULL, account);
- if (window_destroyed_cb)
- g_signal_connect (accounts_window, "destroy", window_destroyed_cb, NULL);
+ gtk_application_add_window (GTK_APPLICATION (app),
+ GTK_WINDOW (accounts_window));
+ }
gtk_window_present (GTK_WINDOW (accounts_window));
}
static GtkWidget *
show_account_assistant (EmpathyConnectionManagers *connection_mgrs,
- GCallback assistant_destroy_cb)
+ GApplication *app)
{
GtkWidget *assistant;
assistant = empathy_account_assistant_show (NULL, connection_mgrs);
- if (assistant_destroy_cb)
- g_signal_connect (assistant, "destroy", assistant_destroy_cb, NULL);
+
+ gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (assistant));
return assistant;
}
@@ -117,23 +119,24 @@ connection_managers_prepare_for_accounts (GObject *source,
gpointer user_data)
{
EmpathyConnectionManagers *cm_mgr = EMPATHY_CONNECTION_MANAGERS (source);
- GCallback assistant_destroy_cb = G_CALLBACK (user_data);
+ GApplication *app = user_data;
if (!empathy_connection_managers_prepare_finish (cm_mgr, result, NULL))
goto out;
- show_account_assistant (cm_mgr, assistant_destroy_cb);
+ show_account_assistant (cm_mgr, app);
DEBUG ("would show the account assistant");
out:
g_object_unref (cm_mgr);
+ g_application_release (app);
}
void
empathy_accounts_show_accounts_ui (TpAccountManager *manager,
TpAccount *account,
gboolean assistant,
- GCallback window_destroyed_cb)
+ GApplication *app)
{
g_return_if_fail (TP_IS_ACCOUNT_MANAGER (manager));
g_return_if_fail (!account || TP_IS_ACCOUNT (account));
@@ -141,7 +144,7 @@ empathy_accounts_show_accounts_ui (TpAccountManager *manager,
if ((empathy_accounts_has_non_salut_accounts (manager) && !assistant) ||
account != NULL)
{
- do_show_accounts_ui (manager, account, window_destroyed_cb);
+ do_show_accounts_ui (manager, account, app);
}
else
{
@@ -149,7 +152,10 @@ empathy_accounts_show_accounts_ui (TpAccountManager *manager,
cm_mgr = empathy_connection_managers_dup_singleton ();
+ /* Hold the application while preparing cm_mgr */
+ g_application_hold (app);
+
empathy_connection_managers_prepare_async (cm_mgr,
- connection_managers_prepare_for_accounts, window_destroyed_cb);
+ connection_managers_prepare_for_accounts, app);
}
}
diff --git a/src/empathy-accounts-common.h b/src/empathy-accounts-common.h
index 002d78323..f9294fbd2 100644
--- a/src/empathy-accounts-common.h
+++ b/src/empathy-accounts-common.h
@@ -29,6 +29,6 @@ gboolean empathy_accounts_has_accounts (TpAccountManager *manager);
void empathy_accounts_show_accounts_ui (TpAccountManager *manager,
TpAccount *account,
gboolean assistant,
- GCallback window_destroyed_cb);
+ GApplication *app);
#endif /* __EMPATHY_ACCOUNTS_COMMON_H__ */
diff --git a/src/empathy-accounts.c b/src/empathy-accounts.c
index 3cad96744..3b25201c5 100644
--- a/src/empathy-accounts.c
+++ b/src/empathy-accounts.c
@@ -54,38 +54,40 @@
static gboolean only_if_needed = FALSE;
static gboolean hidden = FALSE;
static gchar *selected_account_name = NULL;
-static gboolean account_manager_prepared = FALSE;
static gboolean assistant = FALSE;
static void
-account_prepare_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+maybe_show_accounts_ui (TpAccountManager *manager,
+ GApplication *app)
{
- TpAccountManager *manager = TP_ACCOUNT_MANAGER (user_data);
- TpAccount *account = TP_ACCOUNT (source_object);
- GError *error = NULL;
+ if (hidden)
+ return;
- if (!tp_proxy_prepare_finish (account, result, &error))
- {
- DEBUG ("Failed to prepare account: %s", error->message);
- g_error_free (error);
+ if (only_if_needed && empathy_accounts_has_non_salut_accounts (manager))
+ return;
- account = NULL;
- }
-
- empathy_accounts_show_accounts_ui (manager, account, assistant,
- G_CALLBACK (gtk_main_quit));
+ empathy_accounts_show_accounts_ui (manager, NULL, assistant, app);
}
-static void
-maybe_show_accounts_ui (TpAccountManager *manager)
+static TpAccount *
+find_account (TpAccountManager *mgr,
+ const gchar *path)
{
- if (hidden ||
- (only_if_needed && empathy_accounts_has_non_salut_accounts (manager)))
- gtk_main_quit ();
- else
- empathy_accounts_show_accounts_ui (manager, NULL, assistant, gtk_main_quit);
+ GList *accounts, *l;
+ TpAccount *found = NULL;
+
+ accounts = tp_account_manager_get_valid_accounts (mgr);
+ for (l = accounts; l != NULL; l = g_list_next (l))
+ {
+ if (!tp_strdiff (tp_proxy_get_object_path (l->data), path))
+ {
+ found = l->data;
+ break;
+ }
+ }
+
+ g_list_free (accounts);
+ return found;
}
static void
@@ -95,21 +97,19 @@ account_manager_ready_for_accounts_cb (GObject *source_object,
{
TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object);
GError *error = NULL;
+ GApplication *app = G_APPLICATION (user_data);
if (!tp_proxy_prepare_finish (manager, result, &error))
{
DEBUG ("Failed to prepare account manager: %s", error->message);
g_clear_error (&error);
- return;
+ goto out;
}
- account_manager_prepared = TRUE;
-
if (selected_account_name != NULL)
{
gchar *account_path;
- TpAccount *account = NULL;
- TpDBusDaemon *bus;
+ TpAccount *account;
/* create and prep the corresponding TpAccount so it's fully ready by the
* time we try to select it in the accounts dialog */
@@ -119,49 +119,48 @@ account_manager_ready_for_accounts_cb (GObject *source_object,
account_path = g_strdup_printf ("%s%s", TP_ACCOUNT_OBJECT_PATH_BASE,
selected_account_name);
- bus = tp_dbus_daemon_dup (NULL);
- if ((account = tp_account_new (bus, account_path, &error)))
+ account = find_account (manager, account_path);
+
+ if (account != NULL)
{
- tp_proxy_prepare_async (account, NULL, account_prepare_cb, manager);
- g_object_unref (bus);
- return;
+ empathy_accounts_show_accounts_ui (manager, account, assistant, app);
+ goto out;
}
else
{
- DEBUG ("Failed to find account with path %s: %s", account_path,
- error->message);
+ DEBUG ("Failed to find account with path %s", account_path);
+
g_clear_error (&error);
- maybe_show_accounts_ui (manager);
+ maybe_show_accounts_ui (manager, app);
}
- g_object_unref (bus);
g_free (account_path);
}
else
{
- maybe_show_accounts_ui (manager);
+ maybe_show_accounts_ui (manager, app);
}
+
+out:
+ g_application_release (app);
}
static int
app_command_line_cb (GApplication *app,
GApplicationCommandLine *cmdline)
{
- g_application_hold (app);
+ TpAccountManager *account_manager;
- /* if the window is ready, present it; otherwise, it will be presented when
- * the accounts manager is prepared */
- if (account_manager_prepared)
- {
- TpAccountManager *account_manager;
+ account_manager = tp_account_manager_dup ();
- account_manager = tp_account_manager_dup ();
- empathy_accounts_show_accounts_ui (account_manager, NULL, assistant,
- G_CALLBACK (gtk_main_quit));
+ /* Hold the application while preparing the AM */
+ g_application_hold (app);
- g_object_unref (account_manager);
- }
+ tp_proxy_prepare_async (account_manager, NULL,
+ account_manager_ready_for_accounts_cb, app);
+
+ g_object_unref (account_manager);
return 0;
}
@@ -223,12 +222,9 @@ local_cmdline (GApplication *app,
return retval;
}
-#define COMMAND_ACCOUNTS_DIALOG 1
-
int
main (int argc, char *argv[])
{
- TpAccountManager *account_manager;
GtkApplication *app;
GObjectClass *app_class;
gint retval;
@@ -251,17 +247,11 @@ main (int argc, char *argv[])
app_class = G_OBJECT_GET_CLASS (app);
G_APPLICATION_CLASS (app_class)->local_command_line = local_cmdline;
- account_manager = tp_account_manager_dup ();
-
- tp_proxy_prepare_async (account_manager, NULL,
- account_manager_ready_for_accounts_cb, NULL);
-
g_signal_connect (app, "command-line", G_CALLBACK (app_command_line_cb),
NULL);
retval = g_application_run (G_APPLICATION (app), argc, argv);
- g_object_unref (account_manager);
g_object_unref (app);
return retval;
diff --git a/src/empathy-debugger.c b/src/empathy-debugger.c
index 664dc211a..0bf34e015 100644
--- a/src/empathy-debugger.c
+++ b/src/empathy-debugger.c
@@ -38,10 +38,9 @@ activate_cb (GApplication *app)
if (window == NULL)
{
window = empathy_debug_window_new (NULL);
- g_signal_connect (window, "destroy", gtk_main_quit, NULL);
- /* don't let this application exit automatically */
- g_application_hold (G_APPLICATION (app));
+ gtk_application_add_window (GTK_APPLICATION (app),
+ GTK_WINDOW (window));
}
else
{
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index c5f13dfaf..da8acf153 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -1433,7 +1433,7 @@ static void
main_window_chat_quit_cb (GtkAction *action,
EmpathyMainWindow *window)
{
- gtk_main_quit ();
+ gtk_widget_destroy (GTK_WIDGET (window));
}
static void
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index d6f5b2e46..3aa27a467 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -320,7 +320,9 @@ static void
status_icon_quit_cb (GtkAction *action,
EmpathyStatusIcon *icon)
{
- gtk_main_quit ();
+ EmpathyStatusIconPriv *priv = GET_PRIV (icon);
+
+ gtk_widget_destroy (priv->window);
}
static void
diff --git a/src/empathy.c b/src/empathy.c
index e1dab1f18..b73bf1b03 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -181,9 +181,6 @@ empathy_app_finalize (GObject *object)
g_free (self->preferences_tab);
- if (self->window != NULL)
- gtk_widget_destroy (self->window);
-
if (finalize != NULL)
finalize (object);
}
@@ -351,12 +348,14 @@ empathy_app_command_line (GApplication *app,
g_error_free (error);
}
- g_application_hold (G_APPLICATION (app));
self->activated = TRUE;
/* Setting up UI */
self->window = empathy_main_window_dup ();
+ gtk_application_add_window (GTK_APPLICATION (app),
+ GTK_WINDOW (self->window));
+
/* check if Shell is running */
dbus = tp_dbus_daemon_dup (&error);
g_assert_no_error (error);