Changeset 2361 for trunk/jons-gtk-gui

Show
Ignore:
Timestamp:
11/24/00 16:54:04 (8 years ago)
Author:
emojon
Message:

New option!

Show timestamp in convo window, and you can change the format if you don't like
it. The different options for the format can be found in 'man strftime'

Location:
trunk/jons-gtk-gui/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/jons-gtk-gui/src/convo.cpp

    r2321 r2361  
    2525 
    2626#include <string.h> 
     27#include <time.h> 
    2728#include <gtk/gtk.h> 
    2829#include <gdk/gdkkeysyms.h> 
     
    410411                g_strdup_printf(":  %s\n", message); 
    411412 
     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        } 
     420 
    412421        gtk_text_freeze(GTK_TEXT(c->text)); 
    413422        gtk_text_insert(GTK_TEXT(c->text), 0, red, 0, 
    414423                c->user->GetAlias(), -1); 
     424         
     425        if (show_convo_timestamp) 
     426        { 
     427            char *temp_stamp = g_strdup_printf(" (%s)", szTime); 
     428            gtk_text_insert(GTK_TEXT(c->text), 0, red, 0, 
     429                temp_stamp, -1); 
     430            g_free(temp_stamp); 
     431        } 
     432         
    415433        gtk_text_insert(GTK_TEXT(c->text), 0, 0, 0, for_user_m, -1); 
    416434        gtk_text_thaw(GTK_TEXT(c->text)); 
  • trunk/jons-gtk-gui/src/licq_gtk.h

    r2358 r2361  
    299299    GtkWidget *show_ignored; 
    300300    GtkWidget *show_offline; 
     301    GtkWidget *show_timestamp; 
     302    GtkWidget *txtTimestampFormat; 
    301303    GtkWidget *enter_sends; 
    302304    GtkWidget *flash_events; 
     
    494496extern bool show_offline_users; 
    495497extern bool show_ignored_users; 
     498extern bool show_convo_timestamp; 
     499extern char timestamp_format[50]; 
    496500extern bool enter_sends; 
    497501extern bool flash_events; 
  • trunk/jons-gtk-gui/src/option_window.cpp

    r2332 r2361  
    2828bool show_offline_users; 
    2929bool show_ignored_users; 
     30bool show_convo_timestamp; 
    3031bool enter_sends; 
    3132bool flash_events; 
    32  
    33 /* The "Options" selection under the menu in the main window */ 
     33char timestamp_format[50]; 
     34 
     35// The "Options" selection under the menu in the main window 
    3436void menu_options_create() 
    3537{ 
     
    3941    GtkWidget *label; 
    4042    GtkWidget *close; 
     43    GtkWidget *hbox; 
    4144    struct options_window *ow = g_new0(struct options_window, 1); 
    4245 
    43     /* Make the window */ 
     46    // Make the window 
    4447    ow->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 
    4548    gtk_widget_show(ow->window); 
    4649    gtk_window_set_title(GTK_WINDOW(ow->window), "Licq - Options"); 
    4750 
    48     /* The vertical box, the main window will contain this */ 
     51    // The vertical box, the main window will contain this 
    4952    v_box = gtk_vbox_new(FALSE, 5); 
    5053    gtk_container_add(GTK_CONTAINER(ow->window), v_box); 
    5154 
    52     /* The notebook that will contain all the options */ 
     55    // The notebook that will contain all the options 
    5356    notebook = gtk_notebook_new(); 
    5457 
    55     /* The table that will be used in all the notebook pages */ 
     58    // The table that will be used in all the notebook pages 
    5659    table = gtk_table_new(5, 2, FALSE); 
    5760 
    5861/*********************** FIRST TAB *********************/  
    5962     
    60     /* Show ignored users in the contact list? */ 
     63    // Show ignored users in the contact list? 
    6164    ow->show_ignored = gtk_check_button_new_with_label("Show ignored users"); 
    6265    gtk_table_attach(GTK_TABLE(table), ow->show_ignored, 0, 1, 0, 1, 
     
    6467             GTK_FILL, 3, 3); 
    6568 
    66     /* Show offline users in the contact list? */ 
     69    // Show offline users in the contact list? 
    6770    ow->show_offline = gtk_check_button_new_with_label("Show offline users"); 
    6871    gtk_table_attach(GTK_TABLE(table), ow->show_offline, 1, 2, 0, 1, 
     
    7073             GTK_FILL, 3, 3); 
    7174  
    72     /* Enter key pressed in the convo window send it? */ 
     75    // Enter key pressed in the convo window send it? 
    7376    ow->enter_sends = gtk_check_button_new_with_label("Enter sends messages"); 
    7477    gtk_table_attach(GTK_TABLE(table), ow->enter_sends, 0, 1, 1, 2, 
     
    8184        GtkAttachOptions(GTK_FILL | GTK_EXPAND), GTK_FILL, 3, 3); 
    8285 
    83     /* Set the check buttons */ 
    84     //set_options(ow); 
    85  
    86     /* Put the table in the notebook */ 
     86    // Timestamp 
     87    ow->show_timestamp = gtk_check_button_new_with_label("Show timestamp in messages"); 
     88    gtk_table_attach(GTK_TABLE(table), ow->show_timestamp, 0, 1, 2, 3, 
     89        GtkAttachOptions(GTK_FILL | GTK_EXPAND), 
     90        GTK_FILL, 3, 3); 
     91 
     92    // Timestamp format 
     93    hbox = gtk_hbox_new(false, 5); 
     94    label = gtk_label_new("Timestamp Format:"); 
     95    ow->txtTimestampFormat = gtk_entry_new_with_max_length(50); 
     96    gtk_widget_set_usize(ow->txtTimestampFormat, 80, 20); 
     97    gtk_box_pack_start(GTK_BOX(hbox), label, false, 0, 0); 
     98    gtk_box_pack_start(GTK_BOX(hbox), ow->txtTimestampFormat, false, 0, 0); 
     99    gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 2, 3, 
     100        GtkAttachOptions(GTK_FILL | GTK_EXPAND), 
     101        GTK_FILL, 3,3 ); 
     102     
     103 
     104    // Put the table in the notebook 
    87105    label = gtk_label_new("General"); 
    88106    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label); 
     
    90108/**************** Second tab: Contact List Colors ****************/ 
    91109     
    92     /* Recreate the table */ 
     110    // Recreate the table 
    93111    table = gtk_table_new(5, 2, FALSE); 
    94112 
    95     /* The table for the color selection in the "Contact List Colors" frame */ 
     113    // The table for the color selection in the "Contact List Colors" frame 
    96114    GtkWidget *clr_table = gtk_table_new(3, 3, FALSE); 
    97115     
    98     /* Colors frame and attach it to the table and also a table for inside ** 
    99      * the frame */ 
     116    // Colors frame and attach it to the table and also a table for inside 
     117    // the frame 
    100118    GtkWidget *color_frame = gtk_frame_new("Contact List Colors"); 
    101119    gtk_table_attach(GTK_TABLE(table), color_frame, 0, 1, 0, 1, 
     
    103121    gtk_container_add(GTK_CONTAINER(color_frame), clr_table); 
    104122 
    105     /* Online color label */ 
     123    // Online color label 
    106124    label = gtk_label_new("Online Color"); 
    107125    gtk_table_attach(GTK_TABLE(clr_table), label, 0, 1, 0, 1, 
    108126             GTK_FILL, GTK_FILL, 3, 3); 
    109127     
    110     /* Online color browse button */ 
     128    // Online color browse button 
    111129    int *chg_on_color = new int; 
    112130    *chg_on_color = 1; 
     
    119137             GTK_FILL, GTK_FILL, 3, 3); 
    120138 
    121     /* Offline color label */ 
     139    // Offline color labe 
    122140    label = gtk_label_new("Offline Color"); 
    123141    gtk_table_attach(GTK_TABLE(clr_table), label, 0, 1, 1, 2, 
    124142             GTK_FILL, GTK_FILL, 3, 3); 
    125143 
    126     /* Offline color browse button */ 
     144    // Offline color browse button 
    127145    int *chg_off_color = new int; 
    128146    *chg_off_color = 2; 
     
    322340    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ow->flash_events), 
    323341        flash_events); 
     342    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ow->show_timestamp), 
     343        show_convo_timestamp); 
     344    gtk_entry_set_text(GTK_ENTRY(ow->txtTimestampFormat), 
     345        timestamp_format); 
    324346 
    325347    // Clist of servers 
     
    348370    show_ignored_users = gtk_toggle_button_get_active( 
    349371        GTK_TOGGLE_BUTTON(ow->show_ignored)); 
     372    show_convo_timestamp = gtk_toggle_button_get_active( 
     373        GTK_TOGGLE_BUTTON(ow->show_timestamp)); 
    350374    enter_sends = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ow->enter_sends)); 
    351375    flash_events = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( 
    352376        ow->flash_events)); 
    353      
     377    gchar *temp = gtk_editable_get_chars(GTK_EDITABLE(ow->txtTimestampFormat), 0, -1); 
     378    strcpy(timestamp_format, temp); 
     379    g_free(temp); 
     380     
     381    // Save the daemon options 
     382    icq_daemon->setDefaultRemotePort( 
     383        gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ow->spnDefPort))); 
     384 
     385    icq_daemon->SetTCPPorts( 
     386        gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ow->spnPortLow)), 
     387        gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ow->spnPortHigh))); 
     388     
     389    icq_daemon->SetTCPEnabled( 
     390       !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ow->chkTCPEnabled))); 
     391 
    354392    gtk_widget_destroy(ow->window); 
    355  
    356     // Save the daemon options 
    357     icq_daemon->setDefaultRemotePort(gtk_spin_button_get_value_as_int( 
    358         GTK_SPIN_BUTTON(ow->spnDefPort))); 
    359     icq_daemon->SetTCPPorts(gtk_spin_button_get_value_as_int( 
    360         GTK_SPIN_BUTTON(ow->spnPortLow)), 
    361         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ow->spnPortHigh))); 
    362     icq_daemon->SetTCPEnabled(!gtk_toggle_button_get_active( 
    363         GTK_TOGGLE_BUTTON(ow->chkTCPEnabled))); 
    364393 
    365394    icq_daemon->SaveConf(); 
     
    389418    licqConf.WriteBool("EnterSends", enter_sends); 
    390419    licqConf.WriteBool("FlashEvents", flash_events); 
     420    licqConf.WriteBool("ShowTimestamp", show_convo_timestamp); 
     421    licqConf.WriteStr("TimestampFormat", timestamp_format); 
    391422 
    392423    licqConf.FlushFile(); 
     
    434465    licqConf.ReadBool("EnterSends", enter_sends, true); 
    435466    licqConf.ReadBool("FlashEvents", flash_events, true); 
     467    licqConf.ReadBool("ShowTimestamp", show_convo_timestamp, true); 
     468    licqConf.ReadStr("TimestampFormat", timestamp_format, "%H:%M:%S"); 
    436469} 
    437470