static void log_manager_searched_new_cb (GObject *manager, GAsyncResult *result, gpointer user_data) { GList *hits; GList *l; GtkTreeIter iter; GtkListStore *store = user_data; GError *error = NULL; hits = tpl_log_manager_search_new_async_finish (result, &error); if (error != NULL) { DEBUG ("%s. Aborting", error->message); g_error_free (error); return; } for (l = hits; l; l = l->next) { TplLogSearchHit *hit; const gchar *account_name; const gchar *account_icon; gchar *date_readable; hit = l->data; /* Protect against invalid data (corrupt or old log files. */ if (!hit->account || !hit->chat_id) { continue; } date_readable = tpl_log_manager_get_date_readable (hit->date); account_name = tp_account_get_display_name (hit->account); account_icon = tp_account_get_icon_name (hit->account); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COL_FIND_ACCOUNT_ICON, account_icon, COL_FIND_ACCOUNT_NAME, account_name, COL_FIND_ACCOUNT, hit->account, COL_FIND_CHAT_NAME, hit->chat_id, /* FIXME */ COL_FIND_CHAT_ID, hit->chat_id, COL_FIND_IS_CHATROOM, hit->is_chatroom, COL_FIND_DATE, hit->date, COL_FIND_DATE_READABLE, date_readable, -1); g_free (date_readable); /* FIXME: Update COL_FIND_CHAT_NAME */ if (hit->is_chatroom) { } else { } } if (hits) { tpl_log_manager_search_free (hits); } }
const gchar * empathy_protocol_name_for_contact (EmpathyContact *contact) { TpAccount *account; g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); account = empathy_contact_get_account (contact); if (account == NULL) return NULL; return tp_account_get_icon_name (account); }
static void account_chooser_filter_ready_cb (gboolean is_enabled, gpointer data) { FilterResultCallbackData *fr_data = data; EmpathyAccountChooser *chooser; EmpathyAccountChooserPriv *priv; TpAccount *account; GtkTreeIter *iter; GtkListStore *store; GtkComboBox *combobox; const gchar *icon_name; GdkPixbuf *pixbuf; chooser = fr_data->chooser; priv = GET_PRIV (chooser); account = fr_data->account; iter = fr_data->iter; combobox = GTK_COMBO_BOX (chooser); store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox)); icon_name = tp_account_get_icon_name (account); pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON); gtk_list_store_set (store, iter, COL_ACCOUNT_IMAGE, pixbuf, COL_ACCOUNT_TEXT, tp_account_get_display_name (account), COL_ACCOUNT_ENABLED, is_enabled, -1); if (pixbuf != NULL) g_object_unref (pixbuf); /* set first connected account as active account */ if (priv->account_manually_set == FALSE && priv->set_active_item == FALSE && is_enabled) { priv->set_active_item = TRUE; gtk_combo_box_set_active_iter (combobox, iter); } filter_result_callback_data_free (fr_data); }
static GdkPixbuf * empathy_pixbuf_protocol_from_contact_scaled (EmpathyContact *contact, gint width, gint height) { TpAccount *account; gchar *filename; GdkPixbuf *pixbuf = NULL; g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); account = empathy_contact_get_account (contact); filename = tpaw_filename_from_icon_name ( tp_account_get_icon_name (account), GTK_ICON_SIZE_MENU); if (filename != NULL) { pixbuf = gdk_pixbuf_new_from_file_at_size (filename, width, height, NULL); g_free (filename); } return pixbuf; }
static void empathy_password_dialog_constructed (GObject *object) { EmpathyPasswordDialog *dialog; EmpathyPasswordDialogPriv *priv; TpAccount *account; GtkWidget *icon; GtkBox *box; gchar *text; dialog = EMPATHY_PASSWORD_DIALOG (object); priv = dialog->priv; g_assert (priv->handler != NULL); priv->grabbing = FALSE; account = empathy_server_sasl_handler_get_account (priv->handler); tp_g_signal_connect_object (priv->handler, "invalidated", G_CALLBACK (password_dialog_handler_invalidated_cb), object, 0); /* dialog */ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); priv->ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK); gtk_widget_set_sensitive (priv->ok_button, FALSE); text = g_strdup_printf (_("Enter your password for account\n<b>%s</b>"), tp_account_get_display_name (account)); gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), text); g_free (text); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DIALOG_AUTHENTICATION); box = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))); /* dialog icon */ icon = gtk_image_new_from_icon_name (tp_account_get_icon_name (account), GTK_ICON_SIZE_DIALOG); gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), icon); gtk_widget_show (icon); /* entry */ priv->entry = gtk_entry_new (); gtk_entry_set_visibility (GTK_ENTRY (priv->entry), FALSE); /* entry clear icon */ gtk_entry_set_icon_from_stock (GTK_ENTRY (priv->entry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR); gtk_entry_set_icon_sensitive (GTK_ENTRY (priv->entry), GTK_ENTRY_ICON_SECONDARY, FALSE); g_signal_connect (priv->entry, "icon-release", G_CALLBACK (clear_icon_released_cb), NULL); g_signal_connect (priv->entry, "changed", G_CALLBACK (password_entry_changed_cb), dialog); g_signal_connect (priv->entry, "activate", G_CALLBACK (password_entry_activate_cb), dialog); gtk_box_pack_start (box, priv->entry, FALSE, FALSE, 0); gtk_widget_show (priv->entry); /* remember password ticky box */ priv->ticky = gtk_check_button_new_with_label (_("Remember password")); gtk_box_pack_start (box, priv->ticky, FALSE, FALSE, 0); /* only show it if we actually support it */ if (empathy_server_sasl_handler_can_save_response_somewhere (priv->handler)) gtk_widget_show (priv->ticky); g_signal_connect (dialog, "response", G_CALLBACK (password_dialog_response_cb), dialog); g_signal_connect (dialog, "window-state-event", G_CALLBACK (password_dialog_window_state_changed), dialog); g_signal_connect (dialog, "map-event", G_CALLBACK (password_dialog_grab_keyboard), dialog); g_signal_connect (dialog, "unmap-event", G_CALLBACK (password_dialog_ungrab_keyboard), dialog); gtk_widget_grab_focus (priv->entry); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS); }
static void log_manager_searched_new_cb (GObject *manager, GAsyncResult *result, gpointer user_data) { GList *hits; GList *l; GtkTreeIter iter; GtkListStore *store = user_data; GError *error = NULL; if (log_window == NULL) return; if (!tpl_log_manager_search_finish (TPL_LOG_MANAGER (manager), result, &hits, &error)) { DEBUG ("%s. Aborting", error->message); g_error_free (error); return; } for (l = hits; l; l = l->next) { TplLogSearchHit *hit; const gchar *account_name; const gchar *account_icon; gchar date_readable[255]; gchar tmp[255]; hit = l->data; /* Protect against invalid data (corrupt or old log files. */ if (hit->account == NULL || hit->chat_id == NULL) { continue; } g_date_strftime (date_readable, sizeof (date_readable), EMPATHY_DATE_FORMAT_DISPLAY_SHORT, hit->date); g_date_strftime (tmp, sizeof (tmp), "%Y%m%d", hit->date); account_name = tp_account_get_display_name (hit->account); account_icon = tp_account_get_icon_name (hit->account); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COL_FIND_ACCOUNT_ICON, account_icon, COL_FIND_ACCOUNT_NAME, account_name, COL_FIND_ACCOUNT, hit->account, COL_FIND_CHAT_NAME, hit->chat_id, /* FIXME */ COL_FIND_CHAT_ID, hit->chat_id, COL_FIND_IS_CHATROOM, hit->is_chatroom, COL_FIND_DATE, tmp, COL_FIND_DATE_READABLE, date_readable, -1); /* FIXME: Update COL_FIND_CHAT_NAME */ if (hit->is_chatroom) { } else { } } if (hits != NULL) { tpl_log_manager_search_free (hits); } }
static void contact_widget_contact_update (EmpathyContactWidget *information) { TpAccount *account = NULL; const gchar *id = NULL; /* Connect and get info from new contact */ if (information->contact) { g_signal_connect_swapped (information->contact, "notify::name", G_CALLBACK (contact_widget_name_notify_cb), information); g_signal_connect_swapped (information->contact, "notify::presence", G_CALLBACK (contact_widget_presence_notify_cb), information); g_signal_connect_swapped (information->contact, "notify::presence-message", G_CALLBACK (contact_widget_presence_notify_cb), information); g_signal_connect_swapped (information->contact, "notify::avatar", G_CALLBACK (contact_widget_avatar_notify_cb), information); account = empathy_contact_get_account (information->contact); id = empathy_contact_get_id (information->contact); } /* Update account widget */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { if (account) { g_signal_handlers_block_by_func (information->widget_account, contact_widget_change_contact, information); empathy_account_chooser_set_account ( EMPATHY_ACCOUNT_CHOOSER (information->widget_account), account); g_signal_handlers_unblock_by_func (information->widget_account, contact_widget_change_contact, information); } } else { if (account) { const gchar *name; name = tp_account_get_display_name (account); gtk_label_set_label (GTK_LABEL (information->label_account), name); name = tp_account_get_icon_name (account); gtk_image_set_from_icon_name (GTK_IMAGE (information->image_account), name, GTK_ICON_SIZE_MENU); } } /* Update id widget */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID) gtk_entry_set_text (GTK_ENTRY (information->widget_id), id ? id : ""); else gtk_label_set_label (GTK_LABEL (information->widget_id), id ? id : ""); /* Update other widgets */ if (information->contact) { contact_widget_name_notify_cb (information); contact_widget_presence_notify_cb (information); contact_widget_avatar_notify_cb (information); #if HAVE_FAVOURITE_CONTACTS if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_FAVOURITE) { gboolean is_favourite; is_favourite = empathy_contact_list_is_favourite ( EMPATHY_CONTACT_LIST (information->manager), information->contact); contact_widget_favourites_changed_cb (information->manager, information->contact, is_favourite, information); } #endif gtk_widget_show (information->label_alias); gtk_widget_show (information->widget_alias); gtk_widget_show (information->hbox_presence); gtk_widget_show (information->widget_avatar); } else { gtk_widget_hide (information->label_alias); gtk_widget_hide (information->widget_alias); gtk_widget_hide (information->hbox_presence); gtk_widget_hide (information->widget_avatar); } }
static void log_window_find_populate (EmpathyLogWindow *window, const gchar *search_criteria) { #ifndef ENABLE_TPL GList *hits, *l; #endif /* ENABLE_TPL */ GtkTreeView *view; GtkTreeModel *model; GtkTreeSelection *selection; GtkListStore *store; #ifndef ENABLE_TPL GtkTreeIter iter; #endif /* ENABLE_TPL */ view = GTK_TREE_VIEW (window->treeview_find); model = gtk_tree_view_get_model (view); selection = gtk_tree_view_get_selection (view); store = GTK_LIST_STORE (model); empathy_chat_view_clear (window->chatview_find); gtk_list_store_clear (store); if (EMP_STR_EMPTY (search_criteria)) { /* Just clear the search. */ return; } #ifdef ENABLE_TPL tpl_log_manager_search_new_async (window->log_manager, search_criteria, log_manager_searched_new_cb, (gpointer) store); #else hits = empathy_log_manager_search_new (window->log_manager, search_criteria); for (l = hits; l; l = l->next) { EmpathyLogSearchHit *hit; const gchar *account_name; const gchar *account_icon; gchar *date_readable; hit = l->data; /* Protect against invalid data (corrupt or old log files. */ if (!hit->account || !hit->chat_id) { continue; } date_readable = empathy_log_manager_get_date_readable (hit->date); account_name = tp_account_get_display_name (hit->account); account_icon = tp_account_get_icon_name (hit->account); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COL_FIND_ACCOUNT_ICON, account_icon, COL_FIND_ACCOUNT_NAME, account_name, COL_FIND_ACCOUNT, hit->account, COL_FIND_CHAT_NAME, hit->chat_id, /* FIXME */ COL_FIND_CHAT_ID, hit->chat_id, COL_FIND_IS_CHATROOM, hit->is_chatroom, COL_FIND_DATE, hit->date, COL_FIND_DATE_READABLE, date_readable, -1); g_free (date_readable); /* FIXME: Update COL_FIND_CHAT_NAME */ if (hit->is_chatroom) { } else { } } if (hits) { empathy_log_manager_search_free (hits); } #endif /* ENABLE_TPL */ }
static void main_window_error_display (EmpathyMainWindow *window, TpAccount *account, const gchar *message) { GtkWidget *info_bar; GtkWidget *content_area; GtkWidget *label; GtkWidget *image; GtkWidget *retry_button; GtkWidget *edit_button; GtkWidget *close_button; GtkWidget *action_area; GtkWidget *action_table; gchar *str; const gchar *icon_name; str = g_markup_printf_escaped ("<b>%s</b>\n%s", tp_account_get_display_name (account), message); info_bar = g_hash_table_lookup (window->errors, account); if (info_bar) { label = g_object_get_data (G_OBJECT (info_bar), "label"); /* Just set the latest error and return */ gtk_label_set_markup (GTK_LABEL (label), str); g_free (str); return; } info_bar = gtk_info_bar_new (); gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_ERROR); gtk_widget_set_no_show_all (info_bar, TRUE); gtk_box_pack_start (GTK_BOX (window->errors_vbox), info_bar, FALSE, TRUE, 0); gtk_widget_show (info_bar); icon_name = tp_account_get_icon_name (account); image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_widget_show (image); label = gtk_label_new (str); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_widget_show (label); g_free (str); content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)); gtk_box_pack_start (GTK_BOX (content_area), image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (content_area), label, TRUE, TRUE, 0); image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON); retry_button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (retry_button), image); gtk_widget_set_tooltip_text (retry_button, _("Reconnect")); gtk_widget_show (retry_button); image = gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_BUTTON); edit_button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (edit_button), image); gtk_widget_set_tooltip_text (edit_button, _("Edit Account")); gtk_widget_show (edit_button); image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON); close_button = gtk_button_new (); gtk_button_set_image (GTK_BUTTON (close_button), image); gtk_widget_set_tooltip_text (close_button, _("Close")); gtk_widget_show (close_button); action_table = gtk_table_new (1, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (action_table), 2); gtk_widget_show (action_table); action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (info_bar)); gtk_box_pack_start (GTK_BOX (action_area), action_table, FALSE, FALSE, 0); gtk_table_attach (GTK_TABLE (action_table), retry_button, 0, 1, 0, 1, (GtkAttachOptions) (GTK_SHRINK), (GtkAttachOptions) (GTK_SHRINK), 0, 0); gtk_table_attach (GTK_TABLE (action_table), edit_button, 1, 2, 0, 1, (GtkAttachOptions) (GTK_SHRINK), (GtkAttachOptions) (GTK_SHRINK), 0, 0); gtk_table_attach (GTK_TABLE (action_table), close_button, 2, 3, 0, 1, (GtkAttachOptions) (GTK_SHRINK), (GtkAttachOptions) (GTK_SHRINK), 0, 0); g_object_set_data (G_OBJECT (info_bar), "label", label); g_object_set_data_full (G_OBJECT (info_bar), "account", g_object_ref (account), g_object_unref); g_object_set_data_full (G_OBJECT (edit_button), "account", g_object_ref (account), g_object_unref); g_object_set_data_full (G_OBJECT (close_button), "account", g_object_ref (account), g_object_unref); g_object_set_data_full (G_OBJECT (retry_button), "account", g_object_ref (account), g_object_unref); g_signal_connect (edit_button, "clicked", G_CALLBACK (main_window_error_edit_clicked_cb), window); g_signal_connect (close_button, "clicked", G_CALLBACK (main_window_error_close_clicked_cb), window); g_signal_connect (retry_button, "clicked", G_CALLBACK (main_window_error_retry_clicked_cb), window); gtk_widget_show (window->errors_vbox); g_hash_table_insert (window->errors, g_object_ref (account), info_bar); }