EmpathyIndividualViewPriv *priv = GET_PRIV (self);
EmpathyLiveSearch *live = EMPATHY_LIVE_SEARCH (priv->search_widget);
const gchar *str;
- const gchar *p;
- gchar *dup_str = NULL;
- gboolean visible;
GList *personas, *l;
g_assert (live != NULL);
personas = folks_individual_get_personas (individual);
for (l = personas; l; l = l->next)
{
+ const gchar *p;
+ gchar *dup_str = NULL;
+ gboolean visible;
+
str = folks_persona_get_uid (l->data);
p = strstr (str, "@");
if (p != NULL)
if (priv->tooltip_widget != NULL)
{
DEBUG ("Tooltip destroyed");
- g_object_unref (priv->tooltip_widget);
- priv->tooltip_widget = NULL;
+ tp_clear_object (&priv->tooltip_widget);
}
}
/* Avoid an infinite loop. See GNOME bug #574377 */
if (running > 0)
- {
- return FALSE;
- }
+ return FALSE;
+
running++;
/* Don't show the tooltip if there's already a popup menu */
if (gtk_menu_get_for_attach_widget (GTK_WIDGET (view)) != NULL)
- {
- goto OUT;
- }
+ goto OUT;
if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (view), &x, &y,
keyboard_mode, &model, &path, &iter))
- {
- goto OUT;
- }
+ goto OUT;
gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (view), tooltip, path);
gtk_tree_path_free (path);
EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual,
-1);
if (individual == NULL)
- {
- goto OUT;
- }
- else
- {
- contact = empathy_contact_from_folks_individual (individual);
- if (contact == NULL)
- goto OUT;
- }
+ goto OUT;
+
+ contact = empathy_contact_dup_from_folks_individual (individual);
+ g_object_unref (individual);
+
+ if (contact == NULL)
+ goto OUT;
- if (!priv->tooltip_widget)
+ if (priv->tooltip_widget == NULL)
{
priv->tooltip_widget = empathy_contact_widget_new (contact,
EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP |
gtk_widget_show (priv->tooltip_widget);
}
else
- {
- empathy_contact_widget_set_contact (priv->tooltip_widget, contact);
- }
+ empathy_contact_widget_set_contact (priv->tooltip_widget, contact);
gtk_tooltip_set_custom (tooltip, priv->tooltip_widget);
ret = TRUE;
g_object_unref (contact);
- g_object_unref (individual);
OUT:
running--;
return ret;
}
+static void
+groups_change_group_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ FolksGroups *groups = FOLKS_GROUPS (source);
+ GError *error = NULL;
+
+ folks_groups_change_group_finish (groups, result, &error);
+ if (error != NULL)
+ {
+ g_warning ("failed to change group: %s", error->message);
+ g_clear_error (&error);
+ }
+}
+
static void
individual_view_handle_drag (EmpathyIndividualView *self,
FolksIndividual *individual,
}
if (new_group != NULL)
- folks_groups_change_group (FOLKS_GROUPS (individual), new_group, TRUE);
+ folks_groups_change_group (FOLKS_GROUPS (individual), new_group, TRUE,
+ groups_change_group_cb, NULL);
if (old_group != NULL && action == GDK_ACTION_MOVE)
- folks_groups_change_group (FOLKS_GROUPS (individual), old_group, FALSE);
+ folks_groups_change_group (FOLKS_GROUPS (individual), old_group, FALSE,
+ groups_change_group_cb, NULL);
}
static gboolean
GtkTreeIter iter;
const gchar *sel_data;
FolksIndividual *individual;
+ EmpathyContact *contact;
sel_data = (const gchar *) gtk_selection_data_get_data (selection);
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter,
EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual, -1);
- if (!individual)
- {
- return FALSE;
- }
+ if (individual == NULL)
+ return FALSE;
- /* TODO: implement this */
- DEBUG ("file transfer not implemented");
+ contact = empathy_contact_dup_from_folks_individual (individual);
+ empathy_send_file_from_uri_list (contact, sel_data);
g_object_unref (individual);
+ tp_clear_object (&contact);
return TRUE;
}
is_row = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
x, y, &path, NULL, NULL, NULL);
- cleanup &= (!dm);
+ cleanup &= (dm == NULL);
if (is_row)
{
cleanup &= (dm && gtk_tree_path_compare (dm->path, path) != 0);
- is_different = (!dm || (dm
+ is_different = ((dm == NULL) || ((dm != NULL)
&& gtk_tree_path_compare (dm->path, path) != 0));
}
else
- {
- cleanup &= FALSE;
- }
+ cleanup &= FALSE;
if (path == NULL)
{
not groups.
*/
FolksIndividual *individual;
+ EmpathyCapabilities caps = EMPATHY_CAPABILITIES_NONE;
+
gtk_tree_model_get (model, &iter,
EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual, -1);
+ if (individual != NULL)
+ {
+ EmpathyContact *contact = NULL;
+
+ contact = empathy_contact_dup_from_folks_individual (individual);
+ caps = empathy_contact_get_capabilities (contact);
+
+ tp_clear_object (&contact);
+ }
+
if (individual != NULL &&
folks_individual_is_online (individual) &&
- (folks_individual_get_capabilities (individual) &
- FOLKS_CAPABILITIES_FLAGS_FILE_TRANSFER))
+ (caps & EMPATHY_CAPABILITIES_FT))
{
gdk_drag_status (context, GDK_ACTION_COPY, time_);
gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (widget),
path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
- g_object_unref (individual);
}
else
{
gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (widget), NULL, 0);
retval = FALSE;
}
+
+ if (individual != NULL)
+ g_object_unref (individual);
}
if (!is_different && !cleanup)
- {
- return retval;
- }
+ return retval;
if (dm)
{
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- return;
- }
+ return;
path = gtk_tree_model_get_path (model, &iter);
priv->drag_row = gtk_tree_row_reference_new (model, path);
priv = GET_PRIV (widget);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
- if (!priv->drag_row)
- {
- return;
- }
+ if (priv->drag_row == NULL)
+ return;
src_path = gtk_tree_row_reference_get_path (priv->drag_row);
- if (!src_path)
- {
- return;
- }
+ if (src_path == NULL)
+ return;
if (!gtk_tree_model_get_iter (model, &iter, src_path))
{
individual =
empathy_individual_view_dup_selected (EMPATHY_INDIVIDUAL_VIEW (widget));
- if (!individual)
- {
- return;
- }
+ if (individual == NULL)
+ return;
individual_id = folks_individual_get_id (individual);
(guchar *) individual_id, strlen (individual_id) + 1);
break;
}
+
+ g_object_unref (individual);
}
static void
GtkTreeIter iter;
if (!(priv->individual_features & EMPATHY_CONTACT_FEATURE_CHAT))
- {
- return;
- }
+ return;
- model = GTK_TREE_MODEL (priv->store);
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter,
EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual, -1);
- if (!individual)
+ if (individual == NULL)
return;
- contact = empathy_contact_from_folks_individual (individual);
-
- if (contact)
+ contact = empathy_contact_dup_from_folks_individual (individual);
+ if (contact != NULL)
{
DEBUG ("Starting a chat");
}
g_object_unref (individual);
+ tp_clear_object (&contact);
}
static void
g_object_set (cell, "cell-background-gdk", &color, NULL);
}
else
- {
- g_object_set (cell, "cell-background-gdk", NULL, NULL);
- }
+ g_object_set (cell, "cell-background-gdk", NULL, NULL);
}
static void
"pixbuf", pixbuf,
NULL);
- if (pixbuf != NULL)
- {
- g_object_unref (pixbuf);
- }
+ tp_clear_object (&pixbuf);
individual_view_cell_set_background (view, cell, is_group, is_active);
}
"pixbuf", pixbuf,
NULL);
- if (pixbuf != NULL)
- g_object_unref (pixbuf);
+ tp_clear_object (&pixbuf);
g_free (name);
}
"pixbuf", pixbuf,
NULL);
- if (pixbuf)
- {
- g_object_unref (pixbuf);
- }
+ tp_clear_object (&pixbuf);
individual_view_cell_set_background (view, cell, is_group, is_active);
}
NULL);
}
else
- {
- g_object_set (cell, "visible", FALSE, NULL);
- }
+ g_object_set (cell, "visible", FALSE, NULL);
individual_view_cell_set_background (view, cell, is_group, is_active);
}
{
EmpathyIndividualView *view = EMPATHY_INDIVIDUAL_VIEW (object);
EmpathyIndividualViewPriv *priv = GET_PRIV (view);
-
GtkCellRenderer *cell;
GtkTreeViewColumn *col;
guint i;
tp_g_signal_connect_object (priv->store, "row-deleted",
G_CALLBACK (individual_view_store_row_deleted_cb), view, 0);
+ tp_g_signal_connect_object (priv->store, "row-changed",
+ G_CALLBACK (individual_view_store_row_changed_cb), view, 0);
+ tp_g_signal_connect_object (priv->store, "row-inserted",
+ G_CALLBACK (individual_view_store_row_changed_cb), view, 0);
+ tp_g_signal_connect_object (priv->store, "row-deleted",
+ G_CALLBACK (individual_view_store_row_deleted_cb), view, 0);
+
/* Setup view */
/* Setting reorderable is a hack that gets us row previews as drag icons
for free. We override all the drag handlers. It's tricky to get the
EmpathyIndividualView *view = EMPATHY_INDIVIDUAL_VIEW (object);
EmpathyIndividualViewPriv *priv = GET_PRIV (view);
- if (priv->store != NULL)
- {
- g_object_unref (priv->store);
- priv->store = NULL;
- }
- if (priv->filter != NULL)
- {
- g_object_unref (priv->filter);
- priv->filter = NULL;
- }
- if (priv->tooltip_widget != NULL)
- {
- gtk_widget_destroy (priv->tooltip_widget);
- priv->tooltip_widget = NULL;
- }
- if (priv->file_targets != NULL)
- {
- gtk_target_list_unref (priv->file_targets);
- priv->file_targets = NULL;
- }
+ tp_clear_object (&priv->store);
+ tp_clear_object (&priv->filter);
+ tp_clear_pointer (&priv->tooltip_widget, gtk_widget_destroy);
+ tp_clear_pointer (&priv->file_targets, gtk_target_list_unref);
empathy_individual_view_set_live_search (view, NULL);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- return NULL;
- }
+ return NULL;
gtk_tree_model_get (model, &iter,
EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual, -1);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- return 0;
- }
+ return 0;
gtk_tree_model_get (model, &iter,
EMPATHY_INDIVIDUAL_STORE_COL_FLAGS, &flags, -1);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
- {
- return NULL;
- }
+ return NULL;
gtk_tree_model_get (model, &iter,
EMPATHY_INDIVIDUAL_STORE_COL_IS_GROUP, &is_group,
gchar *group;
group = empathy_individual_view_get_selected_group (view, NULL);
- if (group)
+ if (group != NULL)
{
gchar *text;
GtkWindow *parent;
if (individual_view_remove_dialog_show (parent, _("Removing group"),
text))
{
- /* TODO: implement */
- DEBUG ("removing group unimplemented");
+ EmpathyIndividualManager *manager =
+ empathy_individual_manager_dup_singleton ();
+ empathy_individual_manager_remove_group (manager, group);
+ g_object_unref (G_OBJECT (manager));
}
g_free (text);
if (!(priv->view_features & (EMPATHY_INDIVIDUAL_VIEW_FEATURE_GROUPS_RENAME |
EMPATHY_INDIVIDUAL_VIEW_FEATURE_GROUPS_REMOVE)))
- {
- return NULL;
- }
+ return NULL;
group = empathy_individual_view_get_selected_group (view, &is_fake_group);
if (!group || is_fake_group)
individual = empathy_individual_view_dup_selected (view);
- if (individual)
+ if (individual != NULL)
{
gchar *text;
GtkWindow *parent;
g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_VIEW (view), NULL);
individual = empathy_individual_view_dup_selected (view);
- if (!individual)
- {
- return NULL;
- }
+ if (individual == NULL)
+ return NULL;
+
flags = empathy_individual_view_get_flags (view);
menu = empathy_individual_menu_new (individual, priv->individual_features);
{
/* create the menu if required, or just add a separator */
- if (!menu)
- {
- menu = gtk_menu_new ();
- }
+ if (menu == NULL)
+ menu = gtk_menu_new ();
else
{
item = gtk_separator_menu_item_new ();