GdkPixbuf* hybrid_create_pixbuf_at_size(const guchar *pixbuf_data, gint pixbuf_len, gint scale_width, gint scale_height) { GdkPixbuf *pixbuf; GdkPixbuf *res; pixbuf = hybrid_create_pixbuf(pixbuf_data, pixbuf_len); res = gdk_pixbuf_scale_simple(pixbuf, scale_width, scale_height, GDK_INTERP_BILINEAR); g_object_unref(pixbuf); return res; }
static void switch_page_cb(GtkNotebook *notebook, gpointer newpage, guint newpage_nth, gpointer user_data) { GSList *pos; HybridChatWindow *chat; HybridBuddy *buddy; GdkPixbuf *pixbuf; HybridConversation *conv = (HybridConversation*)user_data; gint page_index; for (pos = conv->chat_buddies; pos; pos = pos->next) { chat = (HybridChatWindow*)pos->data; page_index = gtk_notebook_page_num(GTK_NOTEBOOK(conv->notebook), chat->vbox); if (page_index == newpage_nth) { goto page_found; } } hybrid_debug_error("conv", "FATAL, can not find an exist buddy\n"); return; page_found: if (IS_SYSTEM_CHAT(chat)) { buddy = chat->data; /* Set the conversation window's icon. */ pixbuf = hybrid_create_pixbuf(buddy->icon_data, buddy->icon_data_length); gtk_window_set_icon(GTK_WINDOW(conv->window), pixbuf); g_object_unref(pixbuf); /* Set the conversation window's title */ gtk_window_set_title(GTK_WINDOW(conv->window), (!buddy->name || *(buddy->name) == '\0') ? buddy->id : buddy->name); } }
void hybrid_confirm_window_create(HybridAccount *account, guchar *pic_data, gint pic_len, HybridConfirmOkFunc ok_func, HybridConfirmCancelFunc cancel_func, gpointer user_data) { HybridConfirmWindow *con; GtkWidget *vbox; GtkWidget *table; GtkWidget *action_area; GtkWidget *button; GtkWidget *label; GdkPixbuf *pixbuf; con = g_new0(HybridConfirmWindow, 1); con->account = account; con->ok_func = ok_func; con->cancel_func = cancel_func; con->user_data = user_data; con->window = hybrid_create_window(_("Confirm Code"), NULL, GTK_WIN_POS_CENTER, FALSE); gtk_widget_set_size_request(con->window, 300, 200); gtk_container_set_border_width(GTK_CONTAINER(con->window), 8); g_signal_connect(con->window, "destroy", G_CALLBACK(destroy_cb), con); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(con->window), vbox); table = gtk_table_new(3, 3, FALSE); gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 5); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), _("<i>Please input the following code in the picture:</i>")); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 2, 0, 1); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), _("<i>Code:</i>")); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); /* show code picture. */ pixbuf = hybrid_create_pixbuf(pic_data, pic_len); con->image = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(pixbuf); gtk_table_attach_defaults(GTK_TABLE(table), con->image, 1, 2, 1, 2); con->entry = gtk_entry_new(); g_signal_connect(con->entry, "activate", G_CALLBACK(ok_cb), con); gtk_table_attach_defaults(GTK_TABLE(table), con->entry, 0, 2, 2, 3); action_area = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), action_area, FALSE, FALSE, 5); button = gtk_button_new_with_label(_("OK")); gtk_widget_set_size_request(button, 100, 30); gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5); g_signal_connect(button, "clicked", G_CALLBACK(ok_cb), con); button = gtk_button_new_with_label(_("Cancel")); gtk_widget_set_size_request(button, 100, 30); gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5); g_signal_connect(button, "clicked", G_CALLBACK(cancel_cb), con); gtk_widget_show_all(con->window); }
/** * Callback function for the get_info transaction. */ static gint get_info_cb(fetion_account *ac, const gchar *sipmsg, fetion_transaction *trans) { HybridNotifyInfo *info; HybridBuddy *hybrid_buddy; fetion_buddy *buddy; gchar *province; gchar *city; GdkPixbuf *pixbuf = NULL; //info = (HybridInfo*)trans->data; if (!(buddy = fetion_buddy_parse_info(ac, trans->userid, sipmsg))) { /* TODO show an error msg in the get-info box. */ return HYBRID_ERROR; } province = buddy->province && *(buddy->province) != '\0' ? get_province_name(buddy->province) : g_strdup(_("Unknown")); city = buddy->city && *(buddy->city) != '\0' ? get_city_name(buddy->province, buddy->city) : g_strdup(_("Unknown")); info = hybrid_notify_info_create(); hybrid_info_add_pair(info, _("Nickname"), buddy->nickname); if (*buddy->localname) { hybrid_info_add_pair(info, _("Localname"), buddy->localname); } hybrid_info_add_pair(info, _("Fetion-no"), buddy->sid); if (buddy->mobileno && *buddy->mobileno) { hybrid_info_add_pair(info, _("Mobile-no"), buddy->mobileno); } hybrid_info_add_pair(info, _("Gender"), buddy->gender == 1 ? _("Male") : (buddy->gender == 2 ? _("Female") : _("Secrecy"))); if (*buddy->mood_phrase) { hybrid_info_add_pair(info, _("Mood"), buddy->mood_phrase); } hybrid_info_add_pair(info, _("Country"), !buddy->country || g_strcmp0(buddy->country, "CN") == 0 || !*buddy->country ? "China" : buddy->country); hybrid_info_add_pair(info, _("Province"), province); hybrid_info_add_pair(info, _("City"), city); if ((hybrid_buddy = hybrid_blist_find_buddy(ac->account, buddy->userid))) { if (hybrid_buddy->icon_data) { pixbuf = hybrid_create_pixbuf(hybrid_buddy->icon_data, hybrid_buddy->icon_data_length); hybrid_info_add_pixbuf_pair(info, _("Photo"), pixbuf); if (pixbuf) { g_object_unref(pixbuf); } } } g_free(province); g_free(city); hybrid_info_notify(ac->account, info, buddy->userid); hybrid_notify_info_destroy(info); return HYBRID_OK; }