static void contact_widget_set_contact (EmpathyContactWidget *information, EmpathyContact *contact) { if (contact == information->contact) return; contact_widget_remove_contact (information); if (contact) { TpConnection *connection; connection = empathy_contact_get_connection (contact); information->contact = g_object_ref (contact); information->factory = empathy_tp_contact_factory_dup_singleton (connection); } /* set the selected account to be the account this contact came from */ if (contact && EMPATHY_IS_ACCOUNT_CHOOSER (information->widget_account)) { empathy_account_chooser_set_account ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account), empathy_contact_get_account (contact)); } /* Update information for widgets */ contact_widget_contact_update (information); contact_widget_groups_update (information); contact_widget_details_update (information); contact_widget_client_update (information); contact_widget_location_update (information); }
static gboolean select_account (EmpathyAccountChooser *self, TpAccount *account) { GtkComboBox *combobox; GtkTreeModel *model; GtkTreeIter iter; SetAccountData data; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self), FALSE); combobox = GTK_COMBO_BOX (self); model = gtk_combo_box_get_model (combobox); gtk_combo_box_get_active_iter (combobox, &iter); data.self = self; data.account = account; data.set = FALSE; gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) account_chooser_set_account_foreach, &data); self->priv->account_manually_set = data.set; return data.set; }
/** * empathy_account_chooser_get_has_all_option: * @self: an #EmpathyAccountChooser * * Returns whether @self has the #EmpathyAccountChooser:has-all-option * property set to true. * * Return value: whether @self has the #EmpathyAccountChooser:has-all-option * property enabled. */ gboolean empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *self) { g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self), FALSE); return self->priv->has_all_option; }
/** * empathy_account_chooser_set_account: * @chooser: an #EmpathyAccountChooser * @account: a #TpAccount * * Sets the currently selected account to @account, if it exists in the list. * * Return value: whether the chooser was set to @account. */ gboolean empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, TpAccount *account) { EmpathyAccountChooserPriv *priv; GtkComboBox *combobox; GtkTreeModel *model; GtkTreeIter iter; SetAccountData data; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), FALSE); priv = GET_PRIV (chooser); combobox = GTK_COMBO_BOX (chooser); model = gtk_combo_box_get_model (combobox); gtk_combo_box_get_active_iter (combobox, &iter); data.chooser = chooser; data.account = account; gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) account_chooser_set_account_foreach, &data); priv->account_manually_set = data.set; return data.set; }
/** * empathy_account_chooser_get_has_all_option: * @chooser: an #EmpathyAccountChooser * * Returns whether @chooser has the #EmpathyAccountChooser:has-all-option property * set to true. * * Return value: whether @chooser has the #EmpathyAccountChooser:has-all-option property * enabled. */ gboolean empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *chooser) { EmpathyAccountChooserPriv *priv; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), FALSE); priv = GET_PRIV (chooser); return priv->has_all_option; }
/** * empathy_account_chooser_set_filter: * @self: an #EmpathyAccountChooser * @filter: a filter * @user_data: data to pass to @filter, or %NULL * * Sets a filter on the @self so only accounts that are %TRUE in the eyes * of the filter are visible in the @self. */ void empathy_account_chooser_set_filter (EmpathyAccountChooser *self, EmpathyAccountChooserFilterFunc filter, gpointer user_data) { g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self)); self->priv->filter = filter; self->priv->filter_data = user_data; /* Refilter existing data */ empathy_account_chooser_refilter (self); }
/** * empathy_account_chooser_get_connection: * @chooser: an #EmpathyAccountChooser * * Returns a borrowed reference to the #TpConnection associated with the * account currently selected. The caller must reference the returned object with * g_object_ref() if it will be kept * * Return value: a borrowed reference to the #TpConnection associated with the * account curently selected. */ TpConnection * empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) { EmpathyAccountChooserPriv *priv; EmpathyAccount *account; TpConnection *connection; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), NULL); priv = GET_PRIV (chooser); account = empathy_account_chooser_dup_account (chooser); connection = empathy_account_get_connection (account); g_object_unref (account); return connection; }
/** * empathy_account_chooser_dup_account: * @self: an #EmpathyAccountChooser * * Returns the account which is currently selected in the chooser or %NULL * if there is no account selected. The #TpAccount returned should be * unrefed with g_object_unref() when finished with. * * Return value: a new ref to the #TpAccount currently selected, or %NULL. */ TpAccount * empathy_account_chooser_dup_account (EmpathyAccountChooser *self) { TpAccount *account; GtkTreeModel *model; GtkTreeIter iter; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self), NULL); model = gtk_combo_box_get_model (GTK_COMBO_BOX (self)); if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self), &iter)) return NULL; gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1); return account; }
McAccount * empathy_account_chooser_get_account (EmpathyAccountChooser *chooser) { EmpathyAccountChooserPriv *priv; McAccount *account; GtkTreeModel *model; GtkTreeIter iter; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), NULL); priv = GET_PRIV (chooser); model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser)); gtk_combo_box_get_active_iter (GTK_COMBO_BOX (chooser), &iter); gtk_tree_model_get (model, &iter, COL_ACCOUNT_POINTER, &account, -1); return account; }
gboolean empathy_account_chooser_has_all_selected (EmpathyAccountChooser *self) { GtkTreeModel *model; GtkTreeIter iter; RowType type; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self), FALSE); g_return_val_if_fail (self->priv->has_all_option == TRUE, FALSE); model = gtk_combo_box_get_model (GTK_COMBO_BOX (self)); if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self), &iter)) return FALSE; gtk_tree_model_get (model, &iter, COL_ACCOUNT_ROW_TYPE, &type, -1); return type == ROW_ALL; }
/** * empathy_account_chooser_set_filter: * @chooser: an #EmpathyAccountChooser * @filter: a filter * @user_data: data to pass to @filter, or %NULL * * Sets a filter on the @chooser so only accounts that are %TRUE in the eyes * of the filter are visible in the @chooser. */ void empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, EmpathyAccountChooserFilterFunc filter, gpointer user_data) { EmpathyAccountChooserPriv *priv; GtkTreeModel *model; g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser)); priv = GET_PRIV (chooser); priv->filter = filter; priv->filter_data = user_data; /* Refilter existing data */ priv->set_active_item = FALSE; model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser)); gtk_tree_model_foreach (model, account_chooser_filter_foreach, chooser); }
void empathy_account_chooser_set_all (EmpathyAccountChooser *self) { GtkComboBox *combobox; GtkTreeModel *model; GtkTreeIter iter; g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self)); g_return_if_fail (self->priv->has_all_option); combobox = GTK_COMBO_BOX (self); model = gtk_combo_box_get_model (combobox); if (gtk_tree_model_get_iter_first (model, &iter)) { /* 'All accounts' is the first row */ gtk_combo_box_set_active_iter (combobox, &iter); self->priv->account_manually_set = TRUE; } }
/** * empathy_account_chooser_get_connection: * @self: an #EmpathyAccountChooser * * Returns a borrowed reference to the #TpConnection associated with the * account currently selected. The caller must reference the returned object * with g_object_ref() if it will be kept * * Return value: a borrowed reference to the #TpConnection associated with the * account curently selected. */ TpConnection * empathy_account_chooser_get_connection (EmpathyAccountChooser *self) { TpAccount *account; TpConnection *connection; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (self), NULL); account = empathy_account_chooser_dup_account (self); /* if the returned account is NULL, then the account manager probably * hasn't been prepared yet. It should be safe to return NULL here * though. */ if (account == NULL) return NULL; connection = tp_account_get_connection (account); g_object_unref (account); return connection; }
/** * empathy_account_chooser_set_has_all_option: * @chooser: an #EmpathyAccountChooser * @has_all_option: a new value for the #EmpathyAccountChooser:has-all-option property * * Sets the #EmpathyAccountChooser:has-all-option property. */ void empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *chooser, gboolean has_all_option) { EmpathyAccountChooserPriv *priv; GtkComboBox *combobox; GtkListStore *store; GtkTreeModel *model; GtkTreeIter iter; g_return_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser)); priv = GET_PRIV (chooser); if (priv->has_all_option == has_all_option) { return; } combobox = GTK_COMBO_BOX (chooser); model = gtk_combo_box_get_model (combobox); store = GTK_LIST_STORE (model); priv->has_all_option = has_all_option; /* * The first 2 options are the ALL and separator */ if (has_all_option) { gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (chooser), (GtkTreeViewRowSeparatorFunc) account_chooser_separator_func, chooser, NULL); gtk_list_store_prepend (store, &iter); gtk_list_store_set (store, &iter, COL_ACCOUNT_TEXT, NULL, COL_ACCOUNT_ENABLED, TRUE, COL_ACCOUNT_POINTER, NULL, -1); gtk_list_store_prepend (store, &iter); gtk_list_store_set (store, &iter, COL_ACCOUNT_TEXT, _("All"), COL_ACCOUNT_ENABLED, TRUE, COL_ACCOUNT_POINTER, NULL, -1); } else { if (gtk_tree_model_get_iter_first (model, &iter)) { if (gtk_list_store_remove (GTK_LIST_STORE (model), &iter)) { gtk_list_store_remove (GTK_LIST_STORE (model), &iter); } } gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (chooser), (GtkTreeViewRowSeparatorFunc) NULL, NULL, NULL); } g_object_notify (G_OBJECT (chooser), "has-all-option"); }