Changeset 2445 for trunk/jons-gtk-gui
- Timestamp:
- 01/09/01 15:26:56 (8 years ago)
- Location:
- trunk/jons-gtk-gui/src
- Files:
-
- 6 modified
-
convo.cpp (modified) (8 diffs)
-
history_window.cpp (modified) (7 diffs)
-
licq_gtk.h (modified) (6 diffs)
-
main.cpp (modified) (1 diff)
-
main_window.cpp (modified) (2 diffs)
-
option_window.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/jons-gtk-gui/src/convo.cpp
r2362 r2445 21 21 #include "licq_gtk.h" 22 22 23 #include "licq_color.h" 23 24 #include "licq_icqd.h" 24 25 #include "licq_user.h" … … 51 52 52 53 c->user = u; 54 c->clrBack = new GdkColor; 55 c->clrFore = new GdkColor; 53 56 54 57 cnv = g_slist_append(cnv, c); … … 100 103 101 104 /* Handle the etag stuff */ 102 struct e_tag_data *etd = g_new0(struct e_tag_data, 1); 103 104 c->etag = etd; 105 c->etag = g_new0(struct e_tag_data, 1); 105 106 106 107 /* Make the convo window */ … … 218 219 gtk_window_set_focus(GTK_WINDOW(c->window), c->entry); 219 220 220 /* Don't forget the delete signal */221 gtk_signal_connect(GTK_OBJECT(c->window), "de stroy",222 GTK_SIGNAL_FUNC(convo_ close), c);221 /* Don't forget the delete_event signal */ 222 gtk_signal_connect(GTK_OBJECT(c->window), "delete_event", 223 GTK_SIGNAL_FUNC(convo_delete), c); 223 224 224 225 /* More e_tag_data stuff */ … … 404 405 } 405 406 406 if(u_event->SubCommand() == ICQ_CMDxSUB_MSG) 407 { 408 const gchar *message = u_event->Text(); 407 // Get the color that it was sent in if it's wanted 408 if (recv_colors) 409 { 410 if (!c->clrBack) 411 { 412 c->clrBack = new GdkColor; 413 } 414 415 if (!c->clrFore) 416 { 417 c->clrFore = new GdkColor; 418 } 419 420 CICQColor *pIcqColor = u_event->Color(); 421 c->clrFore->red = pIcqColor->ForeRed() * 257; 422 c->clrFore->green = pIcqColor->ForeGreen() * 257; 423 c->clrFore->blue = pIcqColor->ForeBlue() * 257; 424 c->clrFore->pixel = 255; 425 c->clrBack->red = pIcqColor->BackRed() * 257; 426 c->clrBack->green = pIcqColor->BackGreen() * 257; 427 c->clrBack->blue = pIcqColor->BackBlue() * 257; 428 c->clrBack->pixel = 255; 429 } 430 else 431 { 432 if (c->clrFore) 433 { 434 delete c->clrFore; 435 c->clrFore = 0; 436 } 437 438 if (c->clrBack) 439 { 440 delete c->clrBack; 441 c->clrBack = 0; 442 } 443 } 444 445 // How about their alias and an optional timestamp? 446 gtk_text_freeze(GTK_TEXT(c->text)); 447 gtk_text_insert(GTK_TEXT(c->text), 0, red, 0, c->user->GetAlias(), -1); 448 449 if (show_convo_timestamp) 450 { 451 char szTime[26]; 452 time_t message_time = u_event->Time(); 453 struct tm *_tm = localtime(&message_time); 454 strftime(szTime, 26, timestamp_format, _tm); 455 szTime[25] = '\0'; 409 456 410 const gchar *for_user_m = 411 g_strdup_printf(": %s\n", message); 412 413 char szTime[26]; 414 if (show_convo_timestamp) 415 { 416 time_t message_time = u_event->Time(); 417 struct tm *_tm = localtime(&message_time); 418 strftime(szTime, 26, timestamp_format, _tm); 419 szTime[25] = '\0'; 420 } 421 422 gtk_text_freeze(GTK_TEXT(c->text)); 423 gtk_text_insert(GTK_TEXT(c->text), 0, red, 0, 424 c->user->GetAlias(), -1); 425 426 if (show_convo_timestamp) 427 { 428 char *temp_stamp = g_strdup_printf(" (%s)", szTime); 429 gtk_text_insert(GTK_TEXT(c->text), 0, red, 0, 430 temp_stamp, -1); 431 g_free(temp_stamp); 432 } 433 434 gtk_text_insert(GTK_TEXT(c->text), 0, 0, 0, for_user_m, -1); 457 char *szTempStamp = g_strdup_printf(" (%s): ", szTime); 458 gtk_text_insert(GTK_TEXT(c->text), 0, red, 0, szTempStamp, -1); 459 g_free(szTempStamp); 460 } 461 462 switch (u_event->SubCommand()) 463 { 464 case ICQ_CMDxSUB_MSG: 465 { 466 gtk_text_insert(GTK_TEXT(c->text), 0, c->clrFore, c->clrBack, 467 u_event->Text(), -1); 468 gtk_text_insert(GTK_TEXT(c->text), 0, 0, 0, "\n", -1); 435 469 gtk_text_thaw(GTK_TEXT(c->text)); 436 } 437 438 else if(u_event->SubCommand() == ICQ_CMDxSUB_URL) 439 { 470 break; 471 } 472 473 case ICQ_CMDxSUB_URL: 474 { 440 475 const char *url = u_event->Text(); 441 476 … … 447 482 gtk_text_insert(GTK_TEXT(c->text), 0, 0, 0, for_user_u, -1); 448 483 gtk_text_thaw(GTK_TEXT(c->text)); 449 450 }451 452 else if(u_event->SubCommand() == ICQ_CMDxSUB_CHAT)453 {484 break; 485 } 486 487 case ICQ_CMDxSUB_CHAT: 488 { 454 489 const gchar *chat_d = u_event->Text(); 455 490 … … 474 509 chat_accept_window(c_event, uin); 475 510 } 476 } 477 478 else if(u_event->SubCommand() == ICQ_CMDxSUB_FILE) 479 { 511 break; 512 } 513 514 case ICQ_CMDxSUB_FILE: 515 { 480 516 const gchar *file_d = u_event->Text(); 481 517 … … 498 534 file_accept_window(c->user, u_event); 499 535 } 500 } 501 } 502 503 gboolean convo_close(GtkWidget *widget, struct conversation *c) 504 { 505 gtk_widget_destroy(c->window); 536 break; 537 } 538 539 default: // Not good 540 break; 541 } // switch 542 } 543 544 gboolean convo_delete(GtkWidget *widget, GdkEvent *event, struct conversation *c) 545 { 546 convo_close(0, c); 547 return false; 548 } 549 550 void convo_close(GtkWidget *widget, struct conversation *c) 551 { 552 if (c->clrBack) 553 { 554 delete (c->clrBack); 555 } 556 if (c->clrFore) 557 { 558 delete (c->clrFore); 559 } 560 506 561 cnv = g_slist_remove(cnv, c); 507 562 catcher = g_slist_remove(catcher, c->etag); 508 return TRUE; 509 } 563 564 gtk_widget_destroy(c->window); 565 566 g_free(c->etag); 567 g_free(c); 568 } -
trunk/jons-gtk-gui/src/history_window.cpp
r2057 r2445 20 20 21 21 #include "licq_gtk.h" 22 #include "event_description.h" 22 23 23 24 #include "licq_events.h" … … 27 28 28 29 #include <gtk/gtk.h> 30 #include <time.h> 29 31 30 32 const gchar *line = "\n----------------------------\n"; … … 39 41 struct history *hist; 40 42 const gchar *title = g_strdup_printf("History with %s", user->GetAlias()); 41 gchar sz _date[30];43 gchar szHdr[256]; 42 44 time_t _time; 43 45 HistoryList hist_list; … … 47 49 hist->user = user; 48 50 49 / * Make the window */51 // Make the window 50 52 window = gtk_window_new(GTK_WINDOW_DIALOG); 51 53 gtk_window_set_title(GTK_WINDOW(window), title); 52 54 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); 53 55 54 / * Make the boxes */56 // Make the boxes 55 57 v_box = gtk_vbox_new(FALSE, 5); 56 58 h_box = gtk_hbox_new(FALSE, 5); 57 59 58 / * Make the scrolled window */60 // Make the scrolled window 59 61 scroll = gtk_scrolled_window_new(NULL, NULL); 60 62 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), … … 63 65 gtk_widget_set_usize(scroll, 300, 225); 64 66 65 / * Make the text box */67 // Make the text box 66 68 hist->text = gtk_text_new(NULL, NULL); 67 69 gtk_text_set_word_wrap(GTK_TEXT(hist->text), TRUE); … … 69 71 gtk_container_add(GTK_CONTAINER(scroll), hist->text); 70 72 71 / * Pack the scrolled window */73 // Pack the scrolled window 72 74 gtk_box_pack_start(GTK_BOX(v_box), scroll, TRUE, TRUE, 0); 73 75 74 / * The close button */76 // The close button 75 77 button = gtk_button_new_with_label("Close"); 76 78 gtk_signal_connect(GTK_OBJECT(button), "clicked", 77 79 GTK_SIGNAL_FUNC(dialog_close), window); 78 80 79 / * The reverse check button */81 // The reverse check button 80 82 hist->check = gtk_check_button_new_with_label("Reverse"); 81 83 gtk_signal_connect(GTK_OBJECT(hist->check), "toggled", 82 84 GTK_SIGNAL_FUNC(reverse_history), hist); 83 85 84 / * Pack them */86 // Pack them 85 87 gtk_box_pack_start(GTK_BOX(h_box), hist->check, TRUE, TRUE, 5); 86 88 gtk_box_pack_start(GTK_BOX(h_box), button, TRUE, TRUE, 5); 87 89 gtk_box_pack_start(GTK_BOX(v_box), h_box, FALSE, FALSE, 0); 88 90 89 /* Add in the history */ 90 gtk_text_freeze(GTK_TEXT(hist->text)); 91 // Add in the history 91 92 if(!user->GetHistory(hist_list)) 92 93 return; 93 94 95 // The three colors, blue, red, and white 96 GdkColor clrBlue, clrRed, clrWhite; 97 98 clrBlue.red = 0; 99 clrBlue.green = 0; 100 clrBlue.blue = 0xFFFF; 101 clrBlue.pixel = gulong(255 * 256); 102 103 clrRed.red = 0xFFFF; 104 clrRed.green = 0; 105 clrRed.blue = 0; 106 clrRed.pixel = 255; 107 108 clrWhite.red = 0xFFFF; 109 clrWhite.green = 0xFFFF; 110 clrWhite.blue = 0xFFFF; 111 clrWhite.pixel = 255; 112 94 113 history_iter = hist_list.begin(); 114 gtk_text_freeze(GTK_TEXT(hist->text)); 115 116 // Easy way, small memory 117 GdkColor *clrColor; 118 char *szDesc, szDate[30]; 119 tm *tmStupid; 95 120 96 while( 1)121 while(history_iter != hist_list.end()) 97 122 { 98 if(history_iter == hist_list.end())99 break;100 101 123 _time = (*history_iter)->Time(); 102 sprintf(sz_date, "%s\n", ctime(&_time)); 103 124 tmStupid = localtime(&_time); 125 strftime(szDate, 29, "%c", tmStupid); 126 szDesc = event_description(*history_iter); 127 128 if ((*history_iter)->Direction() == D_RECEIVER) 129 { 130 clrColor = &clrRed; 131 snprintf(szHdr, 255, 132 "%s from %s\n%s [%c%c%c%c]\n\n", 133 szDesc, 134 user->GetAlias(), 135 szDate, 136 (*history_iter)->IsDirect() ? 'D' : '-', 137 (*history_iter)->IsMultiRec() ? 'M' : '-', 138 (*history_iter)->IsUrgent() ? 'U' : '-', 139 (*history_iter)->IsEncrypted() ? 'E' : '-'); 140 } 141 else 142 { 143 clrColor = &clrBlue; 144 snprintf(szHdr, 255, 145 "%s to %s\n%s [%c%c%c%c]\n\n", 146 szDesc, 147 user->GetAlias(), 148 szDate, 149 (*history_iter)->IsDirect() ? 'D' : '-', 150 (*history_iter)->IsMultiRec() ? 'M' : '-', 151 (*history_iter)->IsUrgent() ? 'U' : '-', 152 (*history_iter)->IsEncrypted() ? 'E' : '-'); 153 } 154 155 szHdr[255] = '\0'; 104 156 gtk_text_insert(GTK_TEXT(hist->text), 0, 105 (*history_iter)->Direction() == D_RECEIVER ? red: blue, 106 0, 107 sz_date, -1); 157 clrColor, &clrWhite, szHdr, -1); 108 158 gtk_text_insert(GTK_TEXT(hist->text), 109 159 0, 110 (*history_iter)->Direction() == D_RECEIVER ? red : blue, 111 0, 112 (*history_iter)->Text(), -1); 113 gtk_text_insert(GTK_TEXT(hist->text), 0, 0, 0, line, -1); 114 160 clrColor, &clrWhite, (*history_iter)->Text(), -1); 161 gtk_text_insert(GTK_TEXT(hist->text), 0, 0, 0, "\n\n", -1); 162 163 delete [] szDesc; 115 164 history_iter++; 116 165 } … … 147 196 break; 148 197 } 149 150 198 else 151 199 { -
trunk/jons-gtk-gui/src/licq_gtk.h
r2361 r2445 27 27 #include "licq_log.h" 28 28 #include "licq_chat.h" 29 #include "licq_color.h" 29 30 #include "licq_user.h" 30 31 … … 33 34 #include <fstream.h> 34 35 35 /* Program used definitions */36 #define MAX_LENGTH_UIN 8 36 /* Program used constants */ 37 const int MAX_LENGTH_UIN = 8; 37 38 38 39 /********** Structures ******************/ … … 50 51 GtkWidget *send_list; 51 52 GtkWidget *progress; 53 GdkColor *clrFore; 54 GdkColor *clrBack; 52 55 gchar prog_buf[60]; 53 56 gchar *for_user; … … 303 306 GtkWidget *enter_sends; 304 307 GtkWidget *flash_events; 308 GtkWidget *chkRecvColors; 305 309 306 310 // Network section … … 497 501 extern bool show_ignored_users; 498 502 extern bool show_convo_timestamp; 503 extern bool recv_colors; 499 504 extern char timestamp_format[50]; 500 505 extern bool enter_sends; 501 506 extern bool flash_events; 507 extern unsigned long auto_logon; 502 508 503 509 /* Globals in random_chat.cpp */ … … 599 605 extern void convo_cancel(GtkWidget *, struct conversation *); 600 606 extern void convo_recv(unsigned long); 601 extern gboolean convo_close(GtkWidget *, struct conversation *); 607 extern gint convo_delete(GtkWidget *, GdkEvent *, struct conversation *); 608 extern void convo_close(GtkWidget *, struct conversation *); 602 609 603 610 -
trunk/jons-gtk-gui/src/main.cpp
r2176 r2445 125 125 gtk_main(); 126 126 127 icq_daemon->icqLogoff(); 128 icq_daemon->UnregisterPlugin(); 129 gLog.ModifyService(S_PLUGIN, 0); 130 127 131 gtk_widget_destroy(main_window); 128 129 icq_daemon->icqLogoff();130 131 icq_daemon->UnregisterPlugin();132 132 133 133 return 0; -
trunk/jons-gtk-gui/src/main_window.cpp
r2176 r2445 31 31 void main_window_delete_event(GtkWidget *mainwindow, gpointer data) 32 32 { 33 icq_daemon->UnregisterPlugin();34 33 gtk_main_quit(); 35 34 } … … 151 150 gtk_widget_show(system_status); 152 151 152 // Auto logon here 153 if (auto_logon != ICQ_STATUS_OFFLINE) 154 icq_daemon->icqLogon(auto_logon); 155 153 156 return main_window; 154 157 } -
trunk/jons-gtk-gui/src/option_window.cpp
r2361 r2445 29 29 bool show_ignored_users; 30 30 bool show_convo_timestamp; 31 bool recv_colors; 31 32 bool enter_sends; 32 33 bool flash_events; 33 34 char timestamp_format[50]; 35 unsigned long auto_logon; 34 36 35 37 // The "Options" selection under the menu in the main window … … 100 102 GtkAttachOptions(GTK_FILL | GTK_EXPAND), 101 103 GTK_FILL, 3,3 ); 102 104 105 // Receive colors 106 ow->chkRecvColors = gtk_check_button_new_with_label("Receive Colors"); 107 gtk_table_attach(GTK_TABLE(table), ow->chkRecvColors, 0, 1, 3, 4, 108 GtkAttachOptions(GTK_FILL | GTK_EXPAND), 109 GTK_FILL, 3, 3); 103 110 104 111 // Put the table in the notebook … … 293 300 lItems = g_list_append(lItems, const_cast<char *>("(None)")); 294 301 lItems = g_list_append(lItems, const_cast<char *>("Online")); 302 lItems = g_list_append(lItems, const_cast<char *>("Free For Chat")); 295 303 lItems = g_list_append(lItems, const_cast<char *>("Away")); 296 304 lItems = g_list_append(lItems, const_cast<char *>("Not Available")); … … 344 352 gtk_entry_set_text(GTK_ENTRY(ow->txtTimestampFormat), 345 353 timestamp_format); 354 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ow->chkRecvColors), 355 recv_colors); 346 356 347 357 // Clist of servers … … 358 368 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ow->spnPortHigh), 359 369 icq_daemon->TCPPortsHigh()); 370 371 // Auto Logon 372 char szStatus[15]; 373 if (auto_logon == ICQ_STATUS_OFFLINE) 374 { 375 strcpy(szStatus, "(None)"); 376 } 377 else if (auto_logon & ICQ_STATUS_DND) 378 { 379 strcpy(szStatus, "Do Not Disturb"); 380 } 381 else if (auto_logon & ICQ_STATUS_OCCUPIED) 382 { 383 strcpy(szStatus, "Occupied"); 384 } 385 else if (auto_logon & ICQ_STATUS_NA) 386 { 387 strcpy(szStatus, "Not Available"); 388 } 389 else if (auto_logon & ICQ_STATUS_AWAY) 390 { 391 strcpy(szStatus, "Away"); 392 } 393 else if (auto_logon & ICQ_STATUS_FREEFORCHAT) 394 { 395 strcpy(szStatus, "Free For Chat"); 396 } 397 else if (auto_logon & ICQ_STATUS_ONLINE) 398 { 399 strcpy(szStatus, "Online"); 400 } 401 else 402 { 403 strcpy(szStatus, "(None)"); 404 } 405 406 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(ow->cmbAutoLogon)->entry), 407 szStatus); 408 409 if (auto_logon != ICQ_STATUS_OFFLINE && auto_logon & ICQ_STATUS_FxPRIVATE) 410 { 411 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ow->chkInvisible), 412 true); 413 } 414 360 415 } 361 416 362 417 void done_options(GtkWidget *widget, gpointer data) 363 418 { 364 // Refresh the contact list365 contact_list_refresh();366 367 419 struct options_window *ow = (struct options_window *)data; 368 420 show_offline_users = gtk_toggle_button_get_active( … … 378 430 strcpy(timestamp_format, temp); 379 431 g_free(temp); 432 recv_colors = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( 433 ow->chkRecvColors)); 380 434 381 435 // Save the daemon options … … 389 443 icq_daemon->SetTCPEnabled( 390 444 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ow->chkTCPEnabled))); 445 446 // Auto logon 447 const char *szAutoLogon = 448 gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(ow->cmbAutoLogon)->entry), 449 0, -1); 450 451 if (strcmp("Online", szAutoLogon) == 0) 452 auto_logon = ICQ_STATUS_ONLINE; 453 else if (strcmp("Away", szAutoLogon) == 0) 454 auto_logon = ICQ_STATUS_AWAY; 455 else if (strcmp("Not Available", szAutoLogon) == 0) 456 auto_logon = ICQ_STATUS_NA; 457 else if (strcmp("Occupied", szAutoLogon) == 0) 458 auto_logon = ICQ_STATUS_OCCUPIED; 459 else if (strcmp("Do Not Disturb", szAutoLogon) == 0) 460 auto_logon = ICQ_STATUS_DND; 461 else if (strcmp("Free For Chat", szAutoLogon) == 0) 462 auto_logon = ICQ_STATUS_FREEFORCHAT; 463 else 464 auto_logon = ICQ_STATUS_OFFLINE; 465 466 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ow->chkInvisible))) 467 { 468 auto_logon |= ICQ_STATUS_FxPRIVATE; 469 } 391 470 392 471 gtk_widget_destroy(ow->window); … … 414 493 licqConf.WriteNum("ColorAway_Blue", away_color->blue); 415 494 licqConf.WriteNum("ColorAway_Pixel", away_color->pixel); 495 licqConf.WriteNum("AutoLogon", auto_logon); 416 496 licqConf.WriteBool("ShowOfflineUsers", show_offline_users); 417 497 licqConf.WriteBool("ShowIgnoredUsres", show_ignored_users); 418 498 licqConf.WriteBool("EnterSends", enter_sends); 419 499 licqConf.WriteBool("FlashEvents", flash_events); 500 licqConf.WriteBool("RecvColors", recv_colors); 420 501 licqConf.WriteBool("ShowTimestamp", show_convo_timestamp); 421 502 licqConf.WriteStr("TimestampFormat", timestamp_format); … … 426 507 // Refresh the colors 427 508 do_colors(); 509 510 // Refresh contact list 511 contact_list_refresh(); 428 512 } 429 513 … … 465 549 licqConf.ReadBool("EnterSends", enter_sends, true); 466 550 licqConf.ReadBool("FlashEvents", flash_events, true); 551 licqConf.ReadBool("RecvColors", recv_colors, true); 467 552 licqConf.ReadBool("ShowTimestamp", show_convo_timestamp, true); 468 553 licqConf.ReadStr("TimestampFormat", timestamp_format, "%H:%M:%S"); 554 555 // Auto logon 556 licqConf.ReadNum("AutoLogon", auto_logon, 0); 469 557 } 470 558
