Changeset 3399 for trunk/jons-gtk2-gui
- Timestamp:
- 03/22/03 12:28:27 (6 years ago)
- Files:
-
- 1 modified
-
trunk/jons-gtk2-gui/src/convo.cpp (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/jons-gtk2-gui/src/convo.cpp
r3384 r3399 28 28 29 29 #include <list> 30 #include <iostream> 30 31 using namespace std; // for std::list 31 32 … … 40 41 GtkWidget *send_urgent; 41 42 GtkWidget *send_list; 43 GtkWidget *charset; 42 44 GdkColor *clrFore; 43 45 GdkColor *clrBack; … … 79 81 c->window = 0; 80 82 c->user = user; 83 81 84 c->clrBack = new GdkColor; 82 85 c->clrFore = new GdkColor; … … 101 104 } 102 105 103 conversation *convo_find(unsigned long uin) 106 conversation * 107 convo_find(unsigned long uin) 104 108 { 105 109 for (list<conversation *>::iterator i = cnv.begin(); i != cnv.end(); ++i) … … 127 131 } 128 132 133 void 134 charset_select(GtkWidget *w, struct conversation *c) 135 { 136 char *p = (char *)g_object_get_data(G_OBJECT(w), "encoding"); 137 if (strcmp(p, c->user->UserEncoding()) == 0) 138 return; 139 140 unsigned long uin = c->user->Uin(); 141 ICQUser *u = gUserManager.FetchUser(uin, LOCK_W); 142 u->SetUserEncoding(p); 143 u->SaveLicqInfo(); 144 gUserManager.DropUser(u); 145 c->user = gUserManager.FetchUser(uin, LOCK_R); 146 } 147 148 void 149 charset_popup(GtkWidget *w, struct conversation *c) 150 { 151 /* Add the character set menu */ 152 GtkWidget *menu = gtk_menu_new(); 153 const char *user_enc = c->user->UserEncoding(); 154 if (user_enc == NULL || *user_enc == 0) 155 user_enc = "UTF-8"; 156 for (encoding *ep = encodings; ep->name != NULL; ++ep) { 157 char *lbl = g_strdup_printf("%s (%s)", ep->name, ep->enc); 158 GtkWidget *item = gtk_check_menu_item_new_with_label(lbl); 159 g_free(lbl); 160 if (strcmp(user_enc, ep->enc) == 0) 161 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); 162 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); 163 g_object_set_data(G_OBJECT(item), "encoding", ep->enc); 164 g_signal_connect(G_OBJECT(item), "activate", 165 G_CALLBACK(charset_select), c); 166 } 167 gtk_widget_show_all(menu); 168 gtk_menu_popup(GTK_MENU(menu), 0, 0, 0, 0, 0, gtk_get_current_event_time()); 169 } 170 129 171 void convo_show(conversation *c) 130 172 { … … 196 238 /* Send the message to contact list */ 197 239 c->send_list = gtk_check_button_new_with_mnemonic("M_ultiple recipients"); 198 gtk_box_pack_start(GTK_BOX(options_box), c->send_list, FALSE, FALSE, 0); 240 gtk_box_pack_start(GTK_BOX(options_box), c->send_list, FALSE, FALSE, 5); 241 242 /* Character set */ 243 GtkWidget *bbox = hbutton_box_new(); 244 c->charset = gtk_button_new(); 245 gtk_container_add(GTK_CONTAINER(c->charset), 246 gtk_image_new_from_pixbuf(charset_icon)); 247 gtk_container_add(GTK_CONTAINER(bbox), c->charset); 248 gtk_box_pack_end(GTK_BOX(options_box), bbox, FALSE, FALSE, 0); 249 g_signal_connect(G_OBJECT(c->charset), "clicked", 250 G_CALLBACK(charset_popup), c); 199 251 200 252 /* Now pack the options_box */ … … 236 288 237 289 /* Set the title of the window */ 238 gchar * temp = c->user->GetAlias();239 const gchar *win_title = g_strdup_printf("Conversation with %s", temp);290 gchar *win_title = g_strdup_printf("Conversation with %s", 291 s_convert_to_utf8(c->user->GetAlias(), c->user->UserEncoding()).c_str()); 240 292 gtk_window_set_title(GTK_WINDOW(c->window), win_title); 241 293 g_free(win_title); 294 242 295 /* Set the focus of the window */ 243 296 gtk_window_set_focus(GTK_WINDOW(c->window), c->entry); … … 278 331 279 332 // How about their alias and an optional timestamp? 280 if (show_convo_timestamp) 281 { 333 if (show_convo_timestamp) { 282 334 char szTime[26]; 283 335 struct tm *_tm = localtime(&message_time); … … 310 362 { 311 363 /* Set the 2 button widgets */ 312 if (GTK_WIDGET_IS_SENSITIVE(c->send))364 if (GTK_WIDGET_IS_SENSITIVE(c->send)) 313 365 gtk_widget_set_sensitive(c->send, false); 314 366 toggle_close_cancel(c, 2); … … 331 383 /* I don't like those popups to send urgent... so just send it ** 332 384 ** urgently unless the user says to send it to the contact list*/ 333 if ((c->user->Status() == ICQ_STATUS_DND ||385 if ((c->user->Status() == ICQ_STATUS_DND || 334 386 c->user->Status() == ICQ_STATUS_OCCUPIED) && 335 387 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_urgent))) … … 338 390 strcpy(c->etag->buf, "Sending message "); 339 391 340 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_server)))392 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_server))) 341 393 strcat(c->etag->buf, "directly ... "); 342 394 else … … 344 396 345 397 /* Send the message */ 346 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_urgent)) || 347 urgent) 348 { 349 c->etag->e_tag = icq_daemon->icqSendMessage(c->user->Uin(), message, 350 (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_server))), 351 ICQ_TCPxMSG_URGENT); 352 } 353 398 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_urgent)) || 399 urgent) 400 c->etag->e_tag = icq_daemon->icqSendMessage(c->user->Uin(), message, 401 (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_server))), 402 ICQ_TCPxMSG_URGENT); 354 403 /* Send to contact list */ 355 else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_list))) 356 { 404 else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_list))) 357 405 c->etag->e_tag = icq_daemon->icqSendMessage(c->user->Uin(), message, 358 (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_server))), 359 ICQ_TCPxMSG_LIST); 360 } 361 406 (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_server))), 407 ICQ_TCPxMSG_LIST); 362 408 else /* Just send it normally */ 363 {364 409 c->etag->e_tag = icq_daemon->icqSendMessage(c->user->Uin(), message, 365 (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_server))), 366 ICQ_TCPxMSG_NORMAL); 367 } 410 (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(c->send_server))), 411 ICQ_TCPxMSG_NORMAL); 368 412 369 413 /* Take care of the etd buffer and add it to the slist */ … … 407 451 408 452 /* If the window doesn't exist, don't show anything */ 409 if(c == 0) 410 { 453 if (c == 0) { 411 454 system_status_refresh(); 412 455 return; … … 416 459 417 460 /* Make sure we really have an event */ 418 if (u_event == 0)461 if (u_event == 0) 419 462 return; 420 463 … … 423 466 424 467 // Get the color that it was sent in if it's wanted 425 if (recv_colors) 426 { 468 if (recv_colors) { 427 469 if (!c->clrBack) 428 470 c->clrBack = new GdkColor; … … 435 477 pIcqColor->Background() == 0x00FFFFFF) 436 478 bIgnoreBW = true; 437 else 438 { 479 else { 439 480 c->clrFore->red = pIcqColor->ForeRed() * 257; 440 481 c->clrFore->green = pIcqColor->ForeGreen() * 257; … … 447 488 } 448 489 } 449 else 450 { 451 if (c->clrFore) 452 { 490 else { 491 if (c->clrFore) { 453 492 delete c->clrFore; 454 493 c->clrFore = 0; 455 494 } 456 457 if (c->clrBack) 458 { 495 if (c->clrBack) { 459 496 delete c->clrBack; 460 497 c->clrBack = 0; … … 464 501 // How about their alias and an optional timestamp? 465 502 GtkTextBuffer *tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(c->text)); 466 convo_nick_timestamp(c->text, c->user->GetAlias(), u_event->Time(), "remote"); 503 convo_nick_timestamp(c->text, 504 s_convert_to_utf8(c->user->GetAlias(), c->user->UserEncoding()).c_str(), 505 u_event->Time(), "remote"); 467 506 GtkTextIter iter; 468 507 gtk_text_buffer_get_end_iter(tb, &iter); 469 508 gchar *txt; 470 509 471 switch (u_event->SubCommand()) 472 { 510 switch (u_event->SubCommand()) { 473 511 case ICQ_CMDxSUB_MSG: 512 cerr << "encoding: " << c->user->UserEncoding() << endl 513 << "text: " << u_event->Text() << endl; 474 514 txt = convert_to_utf8(u_event->Text(), c->user->UserEncoding()); 475 if (!bIgnoreBW) 476 { 515 if (!bIgnoreBW) { 477 516 GtkTextTag *tag = gtk_text_buffer_create_tag(tb, NULL, 478 517 "foreground-gdk", c->clrFore,
