40
40
#include <libempathy/empathy-contact-list.h>
41
41
#include <libempathy/empathy-log-manager.h>
42
42
#include <libempathy/empathy-tp-group.h>
43
#include <libempathy/empathy-contact-groups.h>
43
44
#include <libempathy/empathy-debug.h>
44
45
#include <libempathy/empathy-utils.h>
45
#include <libempathy/empathy-marshal.h>
47
47
#include "empathy-contact-list-view.h"
48
48
#include "empathy-contact-list-store.h"
49
49
#include "empathy-images.h"
50
#include "empathy-contact-groups.h"
51
50
#include "empathy-cell-renderer-expander.h"
52
51
#include "empathy-cell-renderer-text.h"
53
52
#include "empathy-cell-renderer-activatable.h"
321
322
G_SIGNAL_RUN_LAST,
324
empathy_marshal_VOID__OBJECT_STRING_STRING,
325
_empathy_gtk_marshal_VOID__OBJECT_STRING_STRING,
326
327
3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_STRING);
328
329
g_object_class_install_property (object_class,
330
g_param_spec_boolean ("interactive",
331
"View is interactive",
332
"Is the view interactive",
331
g_param_spec_flags ("features",
332
"Features of the view",
333
"Falgs for all enabled features",
334
EMPATHY_TYPE_CONTACT_LIST_FEATURES,
336
338
g_type_class_add_private (object_class, sizeof (EmpathyContactListViewPriv));
447
449
EmpathyContactListView *
448
empathy_contact_list_view_new (EmpathyContactListStore *store)
450
empathy_contact_list_view_new (EmpathyContactListStore *store,
451
EmpathyContactListFeatures features)
450
EmpathyContactListViewPriv *priv;
451
453
EmpathyContactListView *view;
454
EmpathyContactListViewPriv *priv;
456
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), NULL);
453
view = g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW, NULL);
458
view = g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW,
459
"features", features,
454
462
priv = GET_PRIV (view);
456
463
priv->store = g_object_ref (store);
457
contact_list_view_setup (view);
464
contact_list_view_setup (EMPATHY_CONTACT_LIST_VIEW (view));
463
empathy_contact_list_view_set_interactive (EmpathyContactListView *view,
464
gboolean interactive)
470
empathy_contact_list_view_set_features (EmpathyContactListView *view,
471
EmpathyContactListFeatures features)
466
473
EmpathyContactListViewPriv *priv = GET_PRIV (view);
468
475
g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view));
470
priv->interactive = interactive;
471
g_object_notify (G_OBJECT (view), "interactive");
477
priv->features = features;
479
/* Update DnD source/dest */
480
if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG) {
481
gtk_drag_source_set (GTK_WIDGET (view),
484
G_N_ELEMENTS (drag_types_source),
485
GDK_ACTION_MOVE | GDK_ACTION_COPY);
487
gtk_drag_source_unset (GTK_WIDGET (view));
491
if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP) {
492
gtk_drag_dest_set (GTK_WIDGET (view),
493
GTK_DEST_DEFAULT_ALL,
495
G_N_ELEMENTS (drag_types_dest),
496
GDK_ACTION_MOVE | GDK_ACTION_COPY);
498
/* FIXME: URI could still be droped depending on FT feature */
499
gtk_drag_dest_unset (GTK_WIDGET (view));
502
g_object_notify (G_OBJECT (view), "features");
475
empathy_contact_list_view_get_interactive (EmpathyContactListView *view)
505
EmpathyContactListFeatures
506
empathy_contact_list_view_get_features (EmpathyContactListView *view)
477
508
EmpathyContactListViewPriv *priv = GET_PRIV (view);
479
510
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), FALSE);
481
return priv->interactive;
512
return priv->features;
542
empathy_contact_list_view_get_group_menu (EmpathyContactListView *view)
544
EmpathyContactListViewPriv *priv;
547
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
549
priv = GET_PRIV (view);
551
widget = gtk_ui_manager_get_widget (priv->ui, "/Group");
557
empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view,
558
EmpathyContact *contact)
560
EmpathyLogManager *log_manager;
561
gboolean can_show_log;
562
gboolean can_send_file;
565
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
566
g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
568
log_manager = empathy_log_manager_new ();
569
can_show_log = empathy_log_manager_exists (log_manager,
570
empathy_contact_get_account (contact),
571
empathy_contact_get_id (contact),
573
g_object_unref (log_manager);
574
can_send_file = FALSE;
575
can_voip = empathy_contact_can_voip (contact);
577
return contact_list_view_get_contact_menu (view,
584
573
contact_list_view_setup (EmpathyContactListView *view)
1204
1179
gboolean can_show_log,
1205
1180
gboolean can_voip)
1207
EmpathyContactListViewPriv *priv;
1211
priv = GET_PRIV (view);
1213
/* Sort out sensitive items */
1182
EmpathyContactListViewPriv *priv = GET_PRIV (view);
1185
if (!(priv->features & (EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT |
1186
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL |
1187
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG |
1188
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT |
1189
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE |
1190
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT |
1191
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO |
1192
EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE))) {
1196
/* Sort out sensitive/visible items */
1197
action = gtk_ui_manager_get_action (priv->ui, "/Contact/Chat");
1198
gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT);
1201
action = gtk_ui_manager_get_action (priv->ui, "/Contact/Call");
1202
gtk_action_set_sensitive (action, can_voip);
1203
gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL);
1214
1206
action = gtk_ui_manager_get_action (priv->ui, "/Contact/Log");
1215
1207
gtk_action_set_sensitive (action, can_show_log);
1208
gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG);
1218
action = gtk_ui_manager_get_action (priv->ui, "/Contact/Call");
1219
gtk_action_set_sensitive (action, can_voip);
1222
1211
action = gtk_ui_manager_get_action (priv->ui, "/Contact/SendFile");
1223
gtk_action_set_visible (action, can_send_file);
1225
widget = gtk_ui_manager_get_widget (priv->ui, "/Contact");
1212
gtk_action_set_visible (action, can_send_file && (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT));
1214
action = gtk_ui_manager_get_action (priv->ui, "/Contact/Invite");
1215
gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE);
1217
action = gtk_ui_manager_get_action (priv->ui, "/Contact/Edit");
1218
gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT);
1220
action = gtk_ui_manager_get_action (priv->ui, "/Contact/Information");
1221
gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO);
1223
action = gtk_ui_manager_get_action (priv->ui, "/Contact/Remove");
1224
gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE);
1226
return gtk_ui_manager_get_widget (priv->ui, "/Contact");
1230
empathy_contact_list_view_get_group_menu (EmpathyContactListView *view)
1232
EmpathyContactListViewPriv *priv = GET_PRIV (view);
1235
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
1237
if (!(priv->features & (EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME |
1238
EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE))) {
1242
action = gtk_ui_manager_get_action (priv->ui, "/Group/Rename");
1243
gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME);
1245
action = gtk_ui_manager_get_action (priv->ui, "/Group/Remove");
1246
gtk_action_set_visible (action, priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE);
1248
return gtk_ui_manager_get_widget (priv->ui, "/Group");
1252
empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view,
1253
EmpathyContact *contact)
1255
EmpathyLogManager *log_manager;
1256
gboolean can_show_log;
1257
gboolean can_send_file;
1260
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
1261
g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
1263
log_manager = empathy_log_manager_new ();
1264
can_show_log = empathy_log_manager_exists (log_manager,
1265
empathy_contact_get_account (contact),
1266
empathy_contact_get_id (contact),
1268
g_object_unref (log_manager);
1269
can_send_file = FALSE;
1270
can_voip = empathy_contact_can_voip (contact);
1272
return contact_list_view_get_contact_menu (view,
1230
1278
static gboolean