static void presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser) { EmpathyPresenceChooserPriv *priv; McPresence state; McPresence flash_state; const gchar *status; priv = GET_PRIV (chooser); state = empathy_idle_get_state (priv->idle); status = empathy_idle_get_status (priv->idle); flash_state = empathy_idle_get_flash_state (priv->idle); presence_chooser_reset_scroll_timeout (chooser); gtk_label_set_text (GTK_LABEL (priv->label), status); if (flash_state != MC_PRESENCE_UNSET) { presence_chooser_flash_start (chooser, state, flash_state); } else { presence_chooser_flash_stop (chooser, state); } }
static void presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser) { EmpathyPresenceChooserPriv *priv; TpConnectionPresenceType state; TpConnectionPresenceType flash_state; const gchar *status; GtkTreeModel *model; GtkTreeIter iter; gboolean valid, match_state = FALSE, match = FALSE; priv = GET_PRIV (chooser); if (priv->editing_status) { return; } priv->state = state = empathy_idle_get_state (priv->idle); status = empathy_idle_get_status (priv->idle); flash_state = empathy_idle_get_flash_state (priv->idle); /* look through the model and attempt to find a matching state */ model = gtk_combo_box_get_model (GTK_COMBO_BOX (chooser)); for (valid = gtk_tree_model_get_iter_first (model, &iter); valid; valid = gtk_tree_model_iter_next (model, &iter)) { int m_type; TpConnectionPresenceType m_state; char *m_status; gtk_tree_model_get (model, &iter, COL_STATE, &m_state, COL_TYPE, &m_type, -1); if (m_type == ENTRY_TYPE_CUSTOM || m_type == ENTRY_TYPE_SEPARATOR || m_type == ENTRY_TYPE_EDIT_CUSTOM) { continue; } else if (!match_state && state == m_state) { /* we are now in the section that can contain our * match */ match_state = TRUE; } else if (match_state && state != m_state) { /* we have passed the section that can contain our * match */ break; } gtk_tree_model_get (model, &iter, COL_STATUS_TEXT, &m_status, -1); match = !tp_strdiff (status, m_status); g_free (m_status); if (match) break; } if (match) { priv->block_changed++; gtk_combo_box_set_active_iter (GTK_COMBO_BOX (chooser), &iter); presence_chooser_set_favorite_icon (chooser); priv->block_changed--; } else { ui_set_custom_state (chooser, state, status); } if (flash_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) { presence_chooser_flash_start (chooser, state, flash_state); } else { presence_chooser_flash_stop (chooser, state); } }