Commit c75319eb authored by Travis Reitter's avatar Travis Reitter

Re-implement the context menu for Individuals

parent cdd2409d
......@@ -52,6 +52,7 @@ libempathy_gtk_handwritten_source = \
empathy-contact-selector-dialog.c \
empathy-contact-widget.c \
empathy-geometry.c \
empathy-individual-menu.c \
empathy-individual-store.c \
empathy-individual-view.c \
empathy-irc-network-dialog.c \
......
This diff is collapsed.
......@@ -38,6 +38,26 @@ typedef enum {
EMPATHY_INDIVIDUAL_FEATURE_ALL = (1 << 6) - 1,
} EmpathyIndividualFeatureFlags;
GtkWidget * empathy_individual_menu_new (FolksIndividual *individual,
EmpathyIndividualFeatureFlags features);
GtkWidget * empathy_individual_add_menu_item_new (FolksIndividual *individual);
GtkWidget * empathy_individual_chat_menu_item_new (FolksIndividual *individual);
GtkWidget * empathy_individual_audio_call_menu_item_new (
FolksIndividual *individual);
GtkWidget * empathy_individual_video_call_menu_item_new (
FolksIndividual *individual);
GtkWidget * empathy_individual_log_menu_item_new (FolksIndividual *individual);
GtkWidget * empathy_individual_info_menu_item_new (FolksIndividual *individual);
GtkWidget * empathy_individual_edit_menu_item_new (FolksIndividual *individual);
GtkWidget * empathy_individual_invite_menu_item_new (
FolksIndividual *individual);
GtkWidget * empathy_individual_file_transfer_menu_item_new (
FolksIndividual *individual);
GtkWidget * empathy_individual_share_my_desktop_menu_item_new (
FolksIndividual *individual);
GtkWidget * empathy_individual_favourite_menu_item_new (
FolksIndividual *individual);
G_END_DECLS
#endif /* __EMPATHY_INDIVIDUAL_MENU_H__ */
......
......@@ -117,10 +117,11 @@ G_DEFINE_TYPE (EmpathyIndividualStore, empathy_individual_store,
static void
add_individual_to_store (GtkTreeStore *self,
GtkTreeIter *iter,
GtkTreeIter *parent,
FolksIndividual *individual,
EmpathyIndividualManagerFlags flags)
{
gtk_tree_store_set (self, iter,
gtk_tree_store_insert_with_values (self, iter, parent, 0,
EMPATHY_INDIVIDUAL_STORE_COL_NAME,
folks_individual_get_alias (individual),
EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, individual,
......@@ -132,7 +133,8 @@ add_individual_to_store (GtkTreeStore *self,
EMPATHY_INDIVIDUAL_STORE_COL_CAN_VIDEO_CALL,
folks_individual_get_capabilities (individual) &
FOLKS_CAPABILITIES_FLAGS_VIDEO,
EMPATHY_INDIVIDUAL_STORE_COL_FLAGS, flags, -1);
EMPATHY_INDIVIDUAL_STORE_COL_FLAGS, flags,
-1);
}
static gboolean
......@@ -391,10 +393,7 @@ individual_store_add_individual (EmpathyIndividualStore *self,
&iter_group, NULL, NULL, TRUE);
}
gtk_tree_store_insert_after (GTK_TREE_STORE (self), &iter,
parent, NULL);
add_individual_to_store (GTK_TREE_STORE (self), &iter,
add_individual_to_store (GTK_TREE_STORE (self), &iter, parent,
individual, flags);
}
......@@ -406,10 +405,7 @@ individual_store_add_individual (EmpathyIndividualStore *self,
individual_store_get_group (self, l->data, &iter_group, NULL, NULL,
FALSE);
gtk_tree_store_insert_after (GTK_TREE_STORE (self), &iter,
&iter_group, NULL);
add_individual_to_store (GTK_TREE_STORE (self), &iter,
add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group,
individual, flags);
}
g_list_free (groups);
......@@ -426,10 +422,7 @@ individual_store_add_individual (EmpathyIndividualStore *self,
individual_store_get_group (self, EMPATHY_INDIVIDUAL_STORE_FAVORITE,
&iter_group, NULL, NULL, TRUE);
gtk_tree_store_insert_after (GTK_TREE_STORE (self), &iter,
&iter_group, NULL);
add_individual_to_store (GTK_TREE_STORE (self), &iter,
add_individual_to_store (GTK_TREE_STORE (self), &iter, &iter_group,
individual, flags);
}
#endif
......@@ -456,7 +449,8 @@ individual_store_contact_set_active (EmpathyIndividualStore *self,
GtkTreePath *path;
gtk_tree_store_set (GTK_TREE_STORE (self), l->data,
EMPATHY_INDIVIDUAL_STORE_COL_IS_ACTIVE, active, -1);
EMPATHY_INDIVIDUAL_STORE_COL_IS_ACTIVE, active,
-1);
DEBUG ("Set item %s", active ? "active" : "inactive");
......@@ -686,21 +680,22 @@ individual_store_contact_update (EmpathyIndividualStore *self,
EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, pixbuf_status,
EMPATHY_INDIVIDUAL_STORE_COL_PIXBUF_AVATAR_VISIBLE, show_avatar,
EMPATHY_INDIVIDUAL_STORE_COL_NAME,
folks_individual_get_alias (individual),
folks_individual_get_alias (individual),
EMPATHY_INDIVIDUAL_STORE_COL_PRESENCE_TYPE,
folks_individual_get_presence_type (individual),
folks_individual_get_presence_type (individual),
EMPATHY_INDIVIDUAL_STORE_COL_STATUS,
folks_individual_get_presence_message (individual),
folks_individual_get_presence_message (individual),
EMPATHY_INDIVIDUAL_STORE_COL_CAN_AUDIO_CALL,
folks_individual_get_capabilities (individual) &
FOLKS_CAPABILITIES_FLAGS_AUDIO,
folks_individual_get_capabilities (individual) &
FOLKS_CAPABILITIES_FLAGS_AUDIO,
EMPATHY_INDIVIDUAL_STORE_COL_CAN_VIDEO_CALL,
folks_individual_get_capabilities (individual) &
FOLKS_CAPABILITIES_FLAGS_VIDEO,
folks_individual_get_capabilities (individual) &
FOLKS_CAPABILITIES_FLAGS_VIDEO,
EMPATHY_INDIVIDUAL_STORE_COL_COMPACT, priv->is_compact,
EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, FALSE,
EMPATHY_INDIVIDUAL_STORE_COL_IS_ONLINE, now_online,
EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, FALSE, -1);
EMPATHY_INDIVIDUAL_STORE_COL_IS_SEPARATOR, FALSE,
-1);
}
if (priv->show_active && do_set_active)
......
......@@ -770,20 +770,17 @@ individual_view_popup_menu_idle_cb (gpointer user_data)
GtkWidget *menu;
menu = empathy_individual_view_get_individual_menu (data->view);
if (!menu)
{
menu = empathy_individual_view_get_group_menu (data->view);
}
if (menu == NULL)
menu = empathy_individual_view_get_group_menu (data->view);
if (menu)
if (menu != NULL)
{
g_signal_connect (menu, "deactivate",
G_CALLBACK (gtk_menu_detach), NULL);
gtk_menu_attach_to_widget (GTK_MENU (menu),
GTK_WIDGET (data->view), NULL);
g_signal_connect (menu, "deactivate", G_CALLBACK (gtk_menu_detach), NULL);
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (data->view),
NULL);
gtk_widget_show (menu);
gtk_menu_popup (GTK_MENU (menu),
NULL, NULL, NULL, NULL, data->button, data->time);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, data->button,
data->time);
g_object_ref_sink (menu);
g_object_unref (menu);
}
......@@ -2064,8 +2061,7 @@ empathy_individual_view_get_individual_menu (EmpathyIndividualView *view)
}
flags = empathy_individual_view_get_flags (view);
/* TODO: implement (create the menu here */
DEBUG ("individual menu not implemented");
menu = empathy_individual_menu_new (individual, priv->individual_features);
/* Remove contact */
if (priv->view_features &
......
......@@ -288,3 +288,33 @@ empathy_individual_manager_remove (EmpathyIndividualManager *self,
/* TODO: implement */
DEBUG (G_STRLOC ": individual removal not implemented");
}
EmpathyIndividualManagerFlags
empathy_individual_manager_get_flags_for_connection (
EmpathyIndividualManager *self,
TpConnection *connection)
{
EmpathyIndividualManagerPriv *priv;
EmpathyContactListFlags list_flags;
EmpathyIndividualManagerFlags flags;
g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self),
EMPATHY_INDIVIDUAL_MANAGER_NO_FLAGS);
priv = GET_PRIV (self);
list_flags = empathy_contact_manager_get_flags_for_connection (
priv->contact_manager, connection);
flags = EMPATHY_INDIVIDUAL_MANAGER_NO_FLAGS;
if (list_flags & EMPATHY_CONTACT_LIST_CAN_ADD)
flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_ADD;
if (list_flags & EMPATHY_CONTACT_LIST_CAN_REMOVE)
flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_REMOVE;
if (list_flags & EMPATHY_CONTACT_LIST_CAN_ALIAS)
flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_ALIAS;
if (list_flags & EMPATHY_CONTACT_LIST_CAN_GROUP)
flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_GROUP;
return flags;
}
......@@ -37,6 +37,7 @@ G_BEGIN_DECLS
#define EMPATHY_INDIVIDUAL_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_INDIVIDUAL_MANAGER, EmpathyIndividualManagerClass))
typedef enum
{
EMPATHY_INDIVIDUAL_MANAGER_NO_FLAGS = 0,
EMPATHY_INDIVIDUAL_MANAGER_CAN_ADD = 1 << 0,
EMPATHY_INDIVIDUAL_MANAGER_CAN_REMOVE = 1 << 1,
EMPATHY_INDIVIDUAL_MANAGER_CAN_ALIAS = 1 << 2,
......@@ -78,5 +79,10 @@ gboolean empathy_individual_manager_is_favourite (
EmpathyIndividualManager *manager,
FolksIndividual *individual);
EmpathyIndividualManagerFlags
empathy_individual_manager_get_flags_for_connection (
EmpathyIndividualManager *manager,
TpConnection *connection);
G_END_DECLS
#endif /* __EMPATHY_INDIVIDUAL_MANAGER_H__ */
......@@ -569,6 +569,30 @@ empathy_folks_presence_type_to_tp (FolksPresenceType type)
return (TpConnectionPresenceType) type;
}
gboolean
empathy_folks_individual_contains_contact (FolksIndividual *individual)
{
GList *personas, *l;
g_return_val_if_fail (FOLKS_IS_INDIVIDUAL (individual), FALSE);
personas = folks_individual_get_personas (individual);
for (l = personas; l != NULL; l = l->next)
{
TpfPersona *persona = l->data;
if (TPF_IS_PERSONA (persona))
{
TpContact *contact = tpf_persona_get_contact (persona);
if (TP_IS_CONTACT (contact))
return TRUE;
}
}
return FALSE;
}
EmpathyContact *
empathy_contact_from_folks_individual (FolksIndividual *individual)
{
......
......@@ -91,6 +91,7 @@ void empathy_connect_new_account (TpAccount *account,
TpAccountManager *account_manager);
TpConnectionPresenceType empathy_folks_presence_type_to_tp (FolksPresenceType type);
gboolean empathy_folks_individual_contains_contact (FolksIndividual *individual);
EmpathyContact * empathy_contact_from_folks_individual (FolksIndividual *individual);
G_END_DECLS
......
......@@ -182,6 +182,9 @@ main_window_flash_foreach (GtkTreeModel *model,
&individual,
-1);
if (individual == NULL)
return FALSE;
contact = empathy_contact_from_folks_individual (individual);
if (contact != data->event->contact) {
if (contact) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment