void empathy_new_individual_dialog_show_with_individual (GtkWindow *parent, FolksIndividual *individual) { GtkWidget *dialog; GtkWidget *button; EmpathyContact *contact = NULL; GtkWidget *contact_widget; g_return_if_fail (individual == NULL || FOLKS_IS_INDIVIDUAL (individual)); if (new_individual_dialog) { gtk_window_present (GTK_WINDOW (new_individual_dialog)); return; } /* Create dialog */ dialog = gtk_dialog_new (); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_title (GTK_WINDOW (dialog), _("New Contact")); /* Cancel button */ button = gtk_button_new_with_label (GTK_STOCK_CANCEL); gtk_button_set_use_stock (GTK_BUTTON (button), TRUE); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CANCEL); gtk_widget_show (button); /* Add button */ button = gtk_button_new_with_label (GTK_STOCK_ADD); gtk_button_set_use_stock (GTK_BUTTON (button), TRUE); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_OK); gtk_widget_show (button); /* Contact info widget */ if (individual != NULL) contact = empathy_contact_dup_from_folks_individual (individual); contact_widget = empathy_contact_widget_new (contact); gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8); gtk_box_pack_start ( GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), contact_widget, TRUE, TRUE, 0); empathy_contact_widget_set_account_filter (contact_widget, can_add_contact_to_account, NULL); gtk_widget_show (contact_widget); new_individual_dialog = dialog; g_signal_connect (dialog, "response", G_CALLBACK (new_individual_response_cb), contact_widget); if (parent != NULL) gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); gtk_widget_show (dialog); tp_clear_object (&contact); }
/* Returns TRUE if the given Individual contains a TpContact */ gboolean empathy_folks_individual_contains_contact (FolksIndividual *individual) { GeeSet *personas; GeeIterator *iter; gboolean retval = FALSE; g_return_val_if_fail (FOLKS_IS_INDIVIDUAL (individual), FALSE); personas = folks_individual_get_personas (individual); iter = gee_iterable_iterator (GEE_ITERABLE (personas)); while (!retval && gee_iterator_next (iter)) { FolksPersona *persona = gee_iterator_get (iter); TpContact *contact = NULL; if (empathy_folks_persona_is_interesting (persona)) contact = tpf_persona_get_contact (TPF_PERSONA (persona)); g_clear_object (&persona); if (contact != NULL) retval = TRUE; } g_clear_object (&iter); return retval; }
static void individual_edit_dialog_set_individual ( EmpathyIndividualEditDialog *dialog, FolksIndividual *individual) { EmpathyIndividualEditDialogPriv *priv; g_return_if_fail (EMPATHY_INDIVIDUAL_EDIT_DIALOG (dialog)); g_return_if_fail (individual == NULL || FOLKS_IS_INDIVIDUAL (individual)); priv = GET_PRIV (dialog); /* Remove the old Individual */ if (priv->individual != NULL) { g_signal_handlers_disconnect_by_func (priv->individual, (GCallback) individual_removed_cb, dialog); } tp_clear_object (&priv->individual); /* Add the new Individual */ priv->individual = individual; if (individual != NULL) { g_object_ref (individual); g_signal_connect (individual, "removed", (GCallback) individual_removed_cb, dialog); /* Update the UI */ empathy_individual_widget_set_individual ( EMPATHY_INDIVIDUAL_WIDGET (priv->individual_widget), individual); } }
void empathy_individual_edit_dialog_show (FolksIndividual *individual, GtkWindow *parent) { GtkWidget *dialog; GList *l; g_return_if_fail (FOLKS_IS_INDIVIDUAL (individual)); g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent)); l = g_list_find_custom (edit_dialogs, individual, (GCompareFunc) individual_dialogs_find); if (l != NULL) { gtk_window_present (GTK_WINDOW (l->data)); return; } /* Create dialog */ dialog = g_object_new (EMPATHY_TYPE_INDIVIDUAL_EDIT_DIALOG, "individual", individual, NULL); edit_dialogs = g_list_prepend (edit_dialogs, dialog); gtk_widget_show (dialog); }
/* Return a ref on the GdkPixbuf */ GdkPixbuf * empathy_pixbuf_avatar_from_individual_scaled_finish ( FolksIndividual *individual, GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); gboolean result_valid; GdkPixbuf *pixbuf; g_return_val_if_fail (FOLKS_IS_INDIVIDUAL (individual), NULL); g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (simple), NULL); if (g_simple_async_result_propagate_error (simple, error)) return NULL; result_valid = g_simple_async_result_is_valid (result, G_OBJECT (individual), empathy_pixbuf_avatar_from_individual_scaled_async); g_return_val_if_fail (result_valid, NULL); pixbuf = g_simple_async_result_get_op_res_gpointer (simple); return pixbuf != NULL ? g_object_ref (pixbuf) : NULL; }
/** * empathy_persona_store_new: * @individual: the #FolksIndividual whose personas should be used in the store, * or %NULL * * Create a new #EmpathyPersonaStore with the personas from the given * @individual. * * Return value: a new #EmpathyPersonaStore */ EmpathyPersonaStore * empathy_persona_store_new (FolksIndividual *individual) { g_return_val_if_fail (individual == NULL || FOLKS_IS_INDIVIDUAL (individual), NULL); return g_object_new (EMPATHY_TYPE_PERSONA_STORE, "individual", individual, NULL); }
/** * empathy_individual_linker_new: * @start_individual: (allow-none): the #FolksIndividual to link to, or %NULL * * Creates a new #EmpathyIndividualLinker. * * Return value: a new #EmpathyIndividualLinker */ GtkWidget * empathy_individual_linker_new (FolksIndividual *start_individual) { g_return_val_if_fail (start_individual == NULL || FOLKS_IS_INDIVIDUAL (start_individual), NULL); return g_object_new (EMPATHY_TYPE_INDIVIDUAL_LINKER, "start-individual", start_individual, NULL); }
static void individual_activated_cb (EmpathyRosterView *self, FolksIndividual *individual, gpointer user_data) { g_assert (FOLKS_IS_INDIVIDUAL (individual)); g_print ("'%s' activated\n", folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual))); }
void empathy_individual_manager_unlink_individual (EmpathyIndividualManager *self, FolksIndividual *individual) { EmpathyIndividualManagerPriv *priv; g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self)); g_return_if_fail (FOLKS_IS_INDIVIDUAL (individual)); priv = GET_PRIV (self); DEBUG ("Unlinking individual '%s'", folks_individual_get_id (individual)); folks_individual_aggregator_unlink_individual (priv->aggregator, individual, (GAsyncReadyCallback) unlink_individual_cb, NULL); }
/** * empathy_persona_store_set_individual: * @self: an #EmpathyPersonaStore * @individual: the new individual to display in the store, or %NULL * * Set #EmpathyPersonaStore:individual to @individual, replacing the personas * which were in the store with the personas belonging to @individual, or with * nothing if @individual is %NULL. */ void empathy_persona_store_set_individual (EmpathyPersonaStore *self, FolksIndividual *individual) { EmpathyPersonaStorePriv *priv; g_return_if_fail (EMPATHY_IS_PERSONA_STORE (self)); g_return_if_fail (individual == NULL || FOLKS_IS_INDIVIDUAL (individual)); priv = GET_PRIV (self); /* Remove the old individual */ if (priv->individual != NULL) { GList *personas, *l; g_signal_handlers_disconnect_by_func (priv->individual, (GCallback) individual_personas_changed_cb, self); /* Disconnect from and remove all personas belonging to this individual */ personas = folks_individual_get_personas (priv->individual); for (l = personas; l != NULL; l = l->next) remove_persona_and_disconnect (self, FOLKS_PERSONA (l->data)); g_object_unref (priv->individual); } priv->individual = individual; /* Add the new individual */ if (individual != NULL) { GList *personas, *l; g_object_ref (individual); g_signal_connect (individual, "personas-changed", (GCallback) individual_personas_changed_cb, self); /* Add pre-existing Personas */ personas = folks_individual_get_personas (individual); for (l = personas; l != NULL; l = l->next) add_persona_and_connect (self, FOLKS_PERSONA (l->data)); } g_object_notify (G_OBJECT (self), "individual"); }
/** * empathy_individual_linker_set_start_individual: * @self: an #EmpathyIndividualLinker * @individual: (allow-none): the start individual, or %NULL * * Set the value of #EmpathyIndividualLinker:start-individual to @individual. */ void empathy_individual_linker_set_start_individual (EmpathyIndividualLinker *self, FolksIndividual *individual) { EmpathyIndividualLinkerPriv *priv; g_return_if_fail (EMPATHY_IS_INDIVIDUAL_LINKER (self)); g_return_if_fail (individual == NULL || FOLKS_IS_INDIVIDUAL (individual)); priv = GET_PRIV (self); tp_clear_object (&priv->start_individual); tp_clear_object (&priv->new_individual); g_hash_table_remove_all (priv->changed_individuals); if (individual != NULL) { priv->start_individual = g_object_ref (individual); priv->new_individual = folks_individual_new ( folks_individual_get_personas (individual)); empathy_individual_view_set_store (priv->individual_view, priv->individual_store); } else { priv->start_individual = NULL; priv->new_individual = NULL; /* We only display Individuals in the individual view if we have a * new_individual to link them into */ empathy_individual_view_set_store (priv->individual_view, NULL); } empathy_individual_widget_set_individual ( EMPATHY_INDIVIDUAL_WIDGET (priv->preview_widget), priv->new_individual); empathy_persona_store_set_individual (priv->persona_store, priv->new_individual); g_object_freeze_notify (G_OBJECT (self)); g_object_notify (G_OBJECT (self), "start-individual"); g_object_notify (G_OBJECT (self), "has-changed"); g_object_thaw_notify (G_OBJECT (self)); }
/** * Removes the inner contact from the server (and thus the Individual). Not * meant for de-shelling inner personas from an Individual. */ void empathy_individual_manager_remove (EmpathyIndividualManager *self, FolksIndividual *individual, const gchar *message) { EmpathyIndividualManagerPriv *priv; g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self)); g_return_if_fail (FOLKS_IS_INDIVIDUAL (individual)); priv = GET_PRIV (self); DEBUG ("removing individual %s (%s)", folks_individual_get_id (individual), folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual))); folks_individual_aggregator_remove_individual (priv->aggregator, individual, aggregator_remove_individual_cb, self); }
static PixbufAvatarFromIndividualClosure * pixbuf_avatar_from_individual_closure_new (FolksIndividual *individual, GSimpleAsyncResult *result, gint width, gint height, GCancellable *cancellable) { PixbufAvatarFromIndividualClosure *closure; g_return_val_if_fail (FOLKS_IS_INDIVIDUAL (individual), NULL); g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL); closure = g_slice_new0 (PixbufAvatarFromIndividualClosure); closure->result = g_object_ref (result); closure->width = width; closure->height = height; if (cancellable != NULL) closure->cancellable = g_object_ref (cancellable); return closure; }
/* Retrieve the EmpathyContact corresponding to the first TpContact contained * within the given Individual. Note that this is a temporary convenience. See * the TODO above. */ EmpathyContact * empathy_contact_dup_from_folks_individual (FolksIndividual *individual) { GeeSet *personas; GeeIterator *iter; EmpathyContact *contact = NULL; g_return_val_if_fail (FOLKS_IS_INDIVIDUAL (individual), NULL); personas = folks_individual_get_personas (individual); iter = gee_iterable_iterator (GEE_ITERABLE (personas)); while (gee_iterator_next (iter) && (contact == NULL)) { TpfPersona *persona = gee_iterator_get (iter); if (empathy_folks_persona_is_interesting (FOLKS_PERSONA (persona))) { TpContact *tp_contact; tp_contact = tpf_persona_get_contact (persona); if (tp_contact != NULL) { contact = empathy_contact_dup_from_tp_contact (tp_contact); empathy_contact_set_persona (contact, FOLKS_PERSONA (persona)); } } g_clear_object (&persona); } g_clear_object (&iter); if (contact == NULL) { DEBUG ("Can't create an EmpathyContact for Individual %s", folks_individual_get_id (individual)); } return contact; }