~ubuntu-branches/ubuntu/precise/empathy/precise-proposed-201205180810

« back to all changes in this revision

Viewing changes to libempathy-gtk/empathy-account-chooser.c

  • Committer: Bazaar Package Importer
  • Author(s): Brian Curtis, Brian Curtis, Ken VanDine
  • Date: 2011-06-01 10:35:24 UTC
  • mfrom: (1.1.70 upstream) (6.3.44 experimental)
  • Revision ID: james.westby@ubuntu.com-20110601103524-wx3wgp71394730jt
Tags: 3.1.1-1ubuntu1
[ Brian Curtis ]
* Merge with Debian experimental, remaining Ubuntu changes:
* debian/control:
  - Drop geoclue/mapping build-depends (they are in Universe)
  - Add Vcz-Bzr link
  - Add Suggests on telepathy-idle
  - Bump telepathy-butterfly, telepathy-haze to recommends
  - Don't recommend the freedesktop sound theme we have an ubuntu one
  - Add build depend for libunity-dev
* debian/rules:
  - Use autoreconf.mk
  - Disable map and location
* debian/empathy.install:
  - Install message indicator configuration
* debian/indicators/empathy:
  - Message indicator configuration
* debian/patches/01_lpi.patch:
  - Add Launchpad integration
* debian/patches/10_use_notify_osd_icons.patch:
  - Use the notify-osd image for new messages
* debian/patches/34_start_raised_execpt_in_session.patch
  - If not started with the session, we should always raise
* debian/patches/36_chat_window_default_size.patch:
  - Make the default chat window size larger
* debian/patches/37_facebook_default.patch:
  - Make facebook the default chat account type
* debian/patches/38_lp_569289.patch
  - Set freenode as default IRC network for new IRC accounts 
* debian/patches/41_unity_launcher_progress.patch
  - Display file transfer progress in the unity launcher

[ Ken VanDine ]
* debian/control
  - build depend on libgcr-3-dev instead of libgcr-dev
  - dropped build depends for libindicate, we will use telepathy-indicator
  - Depend on dconf-gsettings-backend | gsettings-backend
  - Added a Recommends for telepathy-indicator
* +debian/empathy.gsettings-override
  - Added an override for notifications-focus
* debian/patches/series
  - commented out 23_idomessagedialog_for_voip_and_ft.patch, until ido has 
    been ported to gtk3

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
        GtkTreeIter           *iter;
81
81
} FilterResultCallbackData;
82
82
 
 
83
static FilterResultCallbackData *
 
84
filter_result_callback_data_new (EmpathyAccountChooser *chooser,
 
85
                                 TpAccount             *account,
 
86
                                 GtkTreeIter           *iter)
 
87
{
 
88
        FilterResultCallbackData *data;
 
89
 
 
90
        data = g_slice_new0 (FilterResultCallbackData);
 
91
        data->chooser = g_object_ref (chooser);
 
92
        data->account = g_object_ref (account);
 
93
        data->iter = gtk_tree_iter_copy (iter);
 
94
 
 
95
        return data;
 
96
}
 
97
 
 
98
static void
 
99
filter_result_callback_data_free (FilterResultCallbackData *data)
 
100
{
 
101
        g_object_unref (data->chooser);
 
102
        g_object_unref (data->account);
 
103
        gtk_tree_iter_free (data->iter);
 
104
        g_slice_free (FilterResultCallbackData, data);
 
105
}
 
106
 
83
107
/* Distinguishes between store entries which are actually accounts, and special
84
108
 * items like the "All" entry and the separator below it, so they can be sorted
85
109
 * correctly. Higher-numbered entries will sort earlier.
99
123
        COL_ACCOUNT_COUNT
100
124
};
101
125
 
 
126
static void     account_chooser_constructed            (GObject                  *object);
102
127
static void     account_chooser_finalize               (GObject                  *object);
103
128
static void     account_chooser_get_property           (GObject                  *object,
104
129
                                                        guint                     param_id,
156
181
{
157
182
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
158
183
 
 
184
        object_class->constructed = account_chooser_constructed;
159
185
        object_class->finalize = account_chooser_finalize;
160
186
        object_class->get_property = account_chooser_get_property;
161
187
        object_class->set_property = account_chooser_set_property;
206
232
        g_signal_connect (priv->manager, "account-removed",
207
233
                          G_CALLBACK (account_chooser_account_removed_cb),
208
234
                          chooser);
209
 
 
210
 
        account_chooser_setup (EMPATHY_ACCOUNT_CHOOSER (chooser));
 
235
}
 
236
 
 
237
static void
 
238
account_chooser_constructed (GObject *object)
 
239
{
 
240
        EmpathyAccountChooser *self = (EmpathyAccountChooser *) object;
 
241
 
 
242
        account_chooser_setup (self);
211
243
}
212
244
 
213
245
static void
252
284
                              const GValue *value,
253
285
                              GParamSpec   *pspec)
254
286
{
255
 
        EmpathyAccountChooserPriv *priv;
256
 
 
257
 
        priv = GET_PRIV (object);
258
 
 
259
287
        switch (param_id) {
260
288
        case PROP_HAS_ALL_OPTION:
261
289
                empathy_account_chooser_set_has_all_option (EMPATHY_ACCOUNT_CHOOSER (object),
284
312
        return chooser;
285
313
}
286
314
 
287
 
gboolean
288
 
empathy_account_chooser_has_all_selected (EmpathyAccountChooser *chooser)
289
 
{
290
 
        EmpathyAccountChooserPriv *priv;
291
 
        GtkTreeModel              *model;
292
 
        GtkTreeIter                iter;
293
 
        RowType                    type;
294
 
 
295
 
        g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), FALSE);
296
 
 
297
 
        priv = GET_PRIV (chooser);
298
 
 
299
 
        g_return_val_if_fail (priv->has_all_option == TRUE, FALSE);
300
 
 
301
 
        model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser));
302
 
        if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (chooser), &iter)) {
303
 
                return FALSE;
304
 
        }
305
 
 
306
 
        gtk_tree_model_get (model, &iter, COL_ACCOUNT_ROW_TYPE, &type, -1);
307
 
 
308
 
        return type == ROW_ALL;
309
 
}
310
 
 
311
315
/**
312
316
 * empathy_account_chooser_dup_account:
313
317
 * @chooser: an #EmpathyAccountChooser
321
325
TpAccount *
322
326
empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser)
323
327
{
324
 
        EmpathyAccountChooserPriv *priv;
325
328
        TpAccount                 *account;
326
329
        GtkTreeModel             *model;
327
330
        GtkTreeIter               iter;
328
331
 
329
332
        g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), NULL);
330
333
 
331
 
        priv = GET_PRIV (chooser);
332
 
 
333
334
        model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser));
334
335
        if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (chooser), &iter)) {
335
336
                return NULL;
354
355
TpConnection *
355
356
empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser)
356
357
{
357
 
        EmpathyAccountChooserPriv *priv;
358
358
        TpAccount                 *account;
359
359
        TpConnection              *connection;
360
360
 
361
361
        g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), NULL);
362
362
 
363
 
        priv = GET_PRIV (chooser);
364
 
 
365
363
        account = empathy_account_chooser_dup_account (chooser);
366
364
 
367
365
        /* if the returned account is NULL, then the account manager probably
490
488
 
491
489
                gtk_list_store_prepend (store, &iter);
492
490
                gtk_list_store_set (store, &iter,
493
 
                                    COL_ACCOUNT_TEXT, _("All accounts"),
 
491
                                    COL_ACCOUNT_TEXT, _("All"),
494
492
                                    COL_ACCOUNT_ENABLED, TRUE,
495
493
                                    COL_ACCOUNT_POINTER, NULL,
496
494
                                    COL_ACCOUNT_ROW_TYPE, ROW_ALL,
788
786
                gtk_combo_box_set_active_iter (combobox, iter);
789
787
        }
790
788
 
791
 
        g_object_unref (account);
792
 
        g_free (iter);
793
 
        g_slice_free (FilterResultCallbackData, fr_data);
 
789
        filter_result_callback_data_free (fr_data);
794
790
}
795
791
 
796
792
static void
816
812
        if (account == NULL)
817
813
                return;
818
814
 
819
 
        data = g_slice_new0 (FilterResultCallbackData);
820
 
        data->chooser = chooser;
821
 
        data->account = g_object_ref (account);
822
 
        data->iter = g_memdup (iter, sizeof (GtkTreeIter));
 
815
        data = filter_result_callback_data_new (chooser, account, iter);
823
816
 
824
817
        if (priv->filter)
825
818
                priv->filter (account, account_chooser_filter_ready_cb,
963
956
        callback (is_connected, callback_data);
964
957
}
965
958
 
 
959
typedef struct {
 
960
        EmpathyAccountChooserFilterResultCallback callback;
 
961
        gpointer                                  user_data;
 
962
} FilterCallbackData;
 
963
 
 
964
static void
 
965
conn_prepared_cb (GObject *conn,
 
966
                GAsyncResult *result,
 
967
                gpointer user_data)
 
968
{
 
969
        FilterCallbackData *data = user_data;
 
970
        GError             *myerr = NULL;
 
971
        TpCapabilities     *caps;
 
972
 
 
973
        if (!tp_proxy_prepare_finish (conn, result, &myerr)) {
 
974
                data->callback (FALSE, data->user_data);
 
975
                g_slice_free (FilterCallbackData, data);
 
976
                return;
 
977
        }
 
978
 
 
979
        caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
 
980
        data->callback (tp_capabilities_supports_text_chatrooms (caps),
 
981
                        data->user_data);
 
982
 
 
983
        g_slice_free (FilterCallbackData, data);
 
984
}
 
985
 
 
986
/**
 
987
 * empathy_account_chooser_filter_supports_multichat:
 
988
 * @account: a #TpAccount
 
989
 * @callback: an #EmpathyAccountChooserFilterResultCallback accepting the result
 
990
 * @callback_data: data passed to the @callback
 
991
 * @user_data: user data or %NULL
 
992
 *
 
993
 * An #EmpathyAccountChooserFilterFunc that returns accounts that both
 
994
 * support multiuser text chat and are connected.
 
995
 *
 
996
 * Returns (via the callback) TRUE if @account both supports muc and is connected
 
997
 */
 
998
void
 
999
empathy_account_chooser_filter_supports_chatrooms (
 
1000
        TpAccount                                 *account,
 
1001
        EmpathyAccountChooserFilterResultCallback  callback,
 
1002
        gpointer                                   callback_data,
 
1003
        gpointer                                   user_data)
 
1004
{
 
1005
        TpConnection       *connection;
 
1006
        FilterCallbackData *cb_data;
 
1007
        GQuark              features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 };
 
1008
 
 
1009
        if (tp_account_get_connection_status (account, NULL) !=
 
1010
                TP_CONNECTION_STATUS_CONNECTED) {
 
1011
                callback (FALSE, callback_data);
 
1012
                return;
 
1013
        }
 
1014
 
 
1015
        /* check if CM supports multiuser text chat */
 
1016
        connection = tp_account_get_connection (account);
 
1017
        if (connection == NULL) {
 
1018
                callback (FALSE, callback_data);
 
1019
                return;
 
1020
        }
 
1021
 
 
1022
        cb_data = g_slice_new0 (FilterCallbackData);
 
1023
        cb_data->callback = callback;
 
1024
        cb_data->user_data = callback_data;
 
1025
 
 
1026
        tp_proxy_prepare_async (connection, features, conn_prepared_cb,
 
1027
                cb_data);
 
1028
}
 
1029
 
966
1030
gboolean
967
1031
empathy_account_chooser_is_ready (EmpathyAccountChooser *self)
968
1032
{