static void status_icon_update_icon (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); const gchar *icon_name; if (priv->event && priv->showing_event_icon) { icon_name = priv->event->icon_name; } else { TpConnectionPresenceType state; state = tp_account_manager_get_most_available_presence ( priv->account_manager, NULL, NULL); /* An unset presence type here doesn't make sense. Force it * to be offline. */ if (state == TP_CONNECTION_PRESENCE_TYPE_UNSET) { state = TP_CONNECTION_PRESENCE_TYPE_OFFLINE; } icon_name = empathy_icon_name_for_presence (state); } if (icon_name != NULL) gtk_status_icon_set_from_icon_name (priv->icon, icon_name); }
static void presence_chooser_menu_add_item (GtkWidget *menu, const gchar *str, McPresence state) { GtkWidget *item; GtkWidget *image; const gchar *icon_name; item = gtk_image_menu_item_new_with_label (str); icon_name = empathy_icon_name_for_presence (state); g_signal_connect (item, "activate", G_CALLBACK (presence_chooser_noncustom_activate_cb), NULL); image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU); gtk_widget_show (image); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); gtk_widget_show (item); g_object_set_data_full (G_OBJECT (item), "status", g_strdup (str), (GDestroyNotify) g_free); g_object_set_data (G_OBJECT (item), "state", GINT_TO_POINTER (state)); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); }
static gboolean presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser) { EmpathyPresenceChooserPriv *priv; TpConnectionPresenceType state; static gboolean on = FALSE; GtkWidget *entry; priv = GET_PRIV (chooser); if (on) { state = priv->flash_state_1; } else { state = priv->flash_state_2; } entry = gtk_bin_get_child (GTK_BIN (chooser)); gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, empathy_icon_name_for_presence (state)); on = !on; return TRUE; }
const gchar * empathy_icon_name_for_contact (EmpathyContact *contact) { TpConnectionPresenceType presence; g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), EMPATHY_IMAGE_OFFLINE); presence = empathy_contact_get_presence (contact); return empathy_icon_name_for_presence (presence); }
const gchar * empathy_icon_name_for_individual (FolksIndividual *individual) { FolksPresenceType folks_presence; TpConnectionPresenceType presence; folks_presence = folks_presence_details_get_presence_type ( FOLKS_PRESENCE_DETAILS (individual)); presence = empathy_folks_presence_type_to_tp (folks_presence); return empathy_icon_name_for_presence (presence); }
static void status_icon_update_icon (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv = GET_PRIV (icon); const gchar *icon_name; if (priv->event && priv->showing_event_icon) { icon_name = priv->event->icon_name; } else { McPresence state; state = empathy_idle_get_state (priv->idle); icon_name = empathy_icon_name_for_presence (state); } gtk_status_icon_set_from_icon_name (priv->icon, icon_name); }
static void presence_chooser_flash_stop (EmpathyPresenceChooser *chooser, TpConnectionPresenceType state) { EmpathyPresenceChooserPriv *priv = GET_PRIV (chooser); GtkWidget *entry; if (priv->flash_timeout_id) { g_source_remove (priv->flash_timeout_id); priv->flash_timeout_id = 0; } entry = gtk_bin_get_child (GTK_BIN (chooser)); gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, empathy_icon_name_for_presence (state)); }
static void presence_chooser_dialog_setup (CustomMessageDialog *dialog) { GtkListStore *store; GtkCellRenderer *renderer; GtkTreeIter iter; guint i; store = gtk_list_store_new (COL_COUNT, G_TYPE_STRING, /* Icon name */ G_TYPE_STRING, /* Label */ MC_TYPE_PRESENCE); /* Presence */ gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->combobox_status), GTK_TREE_MODEL (store)); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, "icon-name", COL_ICON, NULL); g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (dialog->combobox_status), renderer, "text", COL_LABEL, NULL); for (i = 0; i < G_N_ELEMENTS (states); i += 2) { if (!states[i+1]) { continue; } gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COL_ICON, empathy_icon_name_for_presence (states[i]), COL_LABEL, empathy_presence_get_default_message (states[i]), COL_PRESENCE, states[i], -1); } gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_status), 0); }
static void presence_chooser_flash_stop (EmpathyPresenceChooser *chooser, McPresence state) { EmpathyPresenceChooserPriv *priv; g_return_if_fail (EMPATHY_IS_PRESENCE_CHOOSER (chooser)); priv = GET_PRIV (chooser); if (priv->flash_timeout_id) { g_source_remove (priv->flash_timeout_id); priv->flash_timeout_id = 0; } gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), empathy_icon_name_for_presence (state), GTK_ICON_SIZE_MENU); priv->last_state = state; }
static gboolean presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser) { EmpathyPresenceChooserPriv *priv; McPresence state; static gboolean on = FALSE; priv = GET_PRIV (chooser); if (on) { state = priv->flash_state_1; } else { state = priv->flash_state_2; } gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), empathy_icon_name_for_presence (state), GTK_ICON_SIZE_MENU); on = !on; return TRUE; }
static void ui_set_custom_state (EmpathyPresenceChooser *self, TpConnectionPresenceType state, const char *status) { EmpathyPresenceChooserPriv *priv = GET_PRIV (self); GtkWidget *entry; const char *icon_name; entry = gtk_bin_get_child (GTK_BIN (self)); priv->block_set_editing++; priv->block_changed++; icon_name = empathy_icon_name_for_presence (state); gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, icon_name); gtk_entry_set_text (GTK_ENTRY (entry), status == NULL ? "" : status); presence_chooser_set_favorite_icon (self); priv->block_changed--; priv->block_set_editing--; }
static void presence_chooser_create_model (EmpathyPresenceChooser *self) { GtkListStore *store; char *custom_message; int i; store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, /* COL_STATE_ICON_NAME */ G_TYPE_UINT, /* COL_STATE */ G_TYPE_STRING, /* COL_STATUS_TEXT */ G_TYPE_STRING, /* COL_DISPLAY_MARKUP */ G_TYPE_BOOLEAN, /* COL_STATUS_CUSTOMISABLE */ G_TYPE_INT); /* COL_TYPE */ custom_message = g_strdup_printf ("<i>%s</i>", _("Custom Message...")); for (i = 0; states[i].state != TP_CONNECTION_PRESENCE_TYPE_UNSET; i++) { GList *list, *l; const char *status, *icon_name; status = empathy_presence_get_default_message (states[i].state); icon_name = empathy_icon_name_for_presence (states[i].state); gtk_list_store_insert_with_values (store, NULL, -1, COL_STATE_ICON_NAME, icon_name, COL_STATE, states[i].state, COL_STATUS_TEXT, status, COL_DISPLAY_MARKUP, status, COL_STATUS_CUSTOMISABLE, states[i].customisable, COL_TYPE, ENTRY_TYPE_BUILTIN, -1); if (states[i].customisable) { /* Set custom messages if wanted */ list = empathy_status_presets_get (states[i].state, -1); list = g_list_sort (list, (GCompareFunc) g_utf8_collate); for (l = list; l; l = l->next) { gtk_list_store_insert_with_values (store, NULL, -1, COL_STATE_ICON_NAME, icon_name, COL_STATE, states[i].state, COL_STATUS_TEXT, l->data, COL_DISPLAY_MARKUP, l->data, COL_STATUS_CUSTOMISABLE, TRUE, COL_TYPE, ENTRY_TYPE_SAVED, -1); } g_list_free (list); gtk_list_store_insert_with_values (store, NULL, -1, COL_STATE_ICON_NAME, icon_name, COL_STATE, states[i].state, COL_STATUS_TEXT, "", COL_DISPLAY_MARKUP, custom_message, COL_STATUS_CUSTOMISABLE, TRUE, COL_TYPE, ENTRY_TYPE_CUSTOM, -1); } } /* add a separator */ gtk_list_store_insert_with_values (store, NULL, -1, COL_TYPE, ENTRY_TYPE_SEPARATOR, -1); gtk_list_store_insert_with_values (store, NULL, -1, COL_STATE_ICON_NAME, GTK_STOCK_EDIT, COL_STATUS_TEXT, "", COL_DISPLAY_MARKUP, _("Edit Custom Messages..."), COL_TYPE, ENTRY_TYPE_EDIT_CUSTOM, -1); g_free (custom_message); gtk_combo_box_set_model (GTK_COMBO_BOX (self), GTK_TREE_MODEL (store)); g_object_unref (store); }