Changeset 2558 for trunk/jons-gtk-gui

Show
Ignore:
Timestamp:
06/15/01 14:27:17 (7 years ago)
Author:
emojon
Message:

Save window size and position option.

It works on KDE. I'm gonna play around with it and see if it works on other WM's as well, so if anyone sees this, I'd appreciate any feedback.

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

Legend:

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

    r2532 r2558  
    164164        { 
    165165            wizard_message(5); 
    166             main_window = main_window_new(title, 445, 200); 
     166            main_window = main_window_new(title); 
    167167            main_window_show(); 
    168168            system_status_refresh(); 
  • trunk/jons-gtk-gui/src/licq_gtk.h

    r2495 r2558  
    307307    GtkWidget *flash_events; 
    308308    GtkWidget *chkRecvColors; 
     309    GtkWidget *chkRememberWindowPos; 
    309310 
    310311    // Network section 
     
    506507extern bool flash_events; 
    507508extern unsigned long auto_logon; 
     509extern bool remember_window_pos; 
     510 
     511/* Globals for window dimensions / location */ 
     512extern short int windowX; 
     513extern short int windowY; 
     514extern short int windowH; 
     515extern short int windowW; 
    508516 
    509517/* Globals in random_chat.cpp */ 
     
    673681 
    674682/* Functions in main_window.cpp */ 
    675 extern GtkWidget *main_window_new(const gchar *, gint, gint); 
     683extern GtkWidget *main_window_new(const gchar *); 
    676684extern void main_window_show(); 
    677685 
     
    704712extern void color_dlg_cancel(GtkWidget *, gpointer); 
    705713extern void SOCKSClicked(GtkWidget *, gpointer); 
     714extern void save_window_pos (void); 
    706715 
    707716 
  • trunk/jons-gtk-gui/src/main.cpp

    r2532 r2558  
    9999    else 
    100100    { 
    101         main_window = main_window_new(title, 245, 160);  
     101        main_window = main_window_new(title);    
    102102        main_window_show(); 
    103103        contact_list_refresh(); 
  • trunk/jons-gtk-gui/src/main_window.cpp

    r2532 r2558  
    3131void main_window_delete_event(GtkWidget *mainwindow, gpointer data) 
    3232{ 
     33    save_window_pos(); 
    3334    gtk_main_quit(); 
    3435} 
    3536 
    36 GtkWidget* main_window_new(const gchar* window_title, 
    37                gint height, 
    38                gint width) 
     37GtkWidget* main_window_new(const gchar* window_title) 
    3938{ 
    4039    gtk_timeout_add(1000, flash_icons, 0); 
     
    6463    /* Create the main window */ 
    6564    main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 
     65 
     66    /* set the position if that option is enabled */ 
     67    if (remember_window_pos) 
     68        gtk_widget_set_uposition (main_window, windowX, windowY); 
    6669 
    6770    /* Set the title */ 
     
    9598                       GTK_POLICY_NEVER, 
    9699                       GTK_POLICY_AUTOMATIC); 
    97     gtk_widget_set_usize(scroll_bar, width - 77, height - 61); 
     100    gtk_widget_set_usize(scroll_bar, windowW - 77, windowH - 87); 
    98101 
    99102    /* Add in the contact list */ 
    100     contact_list = contact_list_new(height - 30, width - 37); 
     103    contact_list = contact_list_new(windowH - 56, windowW - 37); 
    101104     
    102105    gtk_container_add(GTK_CONTAINER(scroll_bar), contact_list); 
     
    109112 
    110113    /* Add in the status bar menu */ 
    111     status_bar = status_bar_new(25, width, 2); 
     114    status_bar = status_bar_new(25, windowW, 2); 
    112115 
    113116    /* Add the status bar to the event box */ 
     
    123126 
    124127    /* Add the system status bar */ 
    125     system_status = system_status_new(25, width, 2); 
     128    system_status = system_status_new(25, windowW, 2); 
    126129 
    127130    /* Add the system status bar into the event box */ 
  • trunk/jons-gtk-gui/src/menu.cpp

    r2532 r2558  
    185185void menu_system_quit(GtkWidget *blah, gpointer data) 
    186186{ 
     187    save_window_pos(); 
    187188    gtk_main_quit(); 
    188189}  
  • trunk/jons-gtk-gui/src/option_window.cpp

    r2532 r2558  
    3434char timestamp_format[50]; 
    3535unsigned long auto_logon; 
     36bool remember_window_pos; 
     37 
     38// Global variables for window position and size 
     39short int windowX; 
     40short int windowY; 
     41short int windowH; 
     42short int windowW; 
    3643 
    3744// The "Options" selection under the menu in the main window 
     
    106113    ow->chkRecvColors = gtk_check_button_new_with_label("Receive Colors"); 
    107114    gtk_table_attach(GTK_TABLE(table), ow->chkRecvColors, 0, 1, 3, 4, 
     115        GtkAttachOptions(GTK_FILL | GTK_EXPAND), 
     116        GTK_FILL, 3, 3); 
     117 
     118    // Remember window position 
     119    ow->chkRememberWindowPos = gtk_check_button_new_with_label("Save Window Size and Position"); 
     120    gtk_table_attach(GTK_TABLE(table), ow->chkRememberWindowPos, 1, 2, 3, 4, 
    108121        GtkAttachOptions(GTK_FILL | GTK_EXPAND), 
    109122        GTK_FILL, 3, 3); 
     
    354367    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ow->chkRecvColors), 
    355368        recv_colors); 
     369    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ow->chkRememberWindowPos), 
     370        remember_window_pos); 
    356371 
    357372    // Clist of servers 
     
    428443    recv_colors = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( 
    429444        ow->chkRecvColors)); 
     445    remember_window_pos = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( 
     446        ow->chkRememberWindowPos)); 
    430447     
    431448    // Save the daemon options 
     
    496513    licqConf.WriteBool("RecvColors", recv_colors); 
    497514    licqConf.WriteBool("ShowTimestamp", show_convo_timestamp); 
     515    licqConf.WriteBool("RememberWindowPos", remember_window_pos); 
    498516    licqConf.WriteStr("TimestampFormat", timestamp_format); 
    499517 
     
    506524    // Refresh contact list 
    507525    contact_list_refresh(); 
     526} 
     527 
     528void save_window_pos (void) 
     529{ 
     530    char filename[MAX_FILENAME_LEN]; 
     531    sprintf (filename, "%s/licq_jons-gtk-gui.conf", BASE_DIR); 
     532    CIniFile licqConf(INI_FxERROR | INI_FxALLOWxCREATE); 
     533    if(!licqConf.LoadFile(filename)) 
     534        return; 
     535    gint x, y, w, h; 
     536 
     537    gdk_window_get_root_origin(main_window->window, &x, &y); 
     538    gdk_window_get_size(main_window->window, &w, &h); 
     539 
     540    licqConf.SetSection("appearance"); 
     541 
     542    licqConf.WriteNum("windowX", (short int)x); 
     543    licqConf.WriteNum("windowY", (short int)y); 
     544    licqConf.WriteNum("windowW", (short int)w); 
     545    licqConf.WriteNum("windowH", (short int)h); 
     546     
     547    licqConf.FlushFile(); 
     548    licqConf.CloseFile(); 
    508549} 
    509550 
     
    548589    licqConf.ReadBool("ShowTimestamp", show_convo_timestamp, true); 
    549590    licqConf.ReadStr("TimestampFormat", timestamp_format, "%H:%M:%S"); 
     591    licqConf.ReadBool("RememberWindowPos", remember_window_pos, true); 
     592 
     593    // Window size & position 
     594    licqConf.ReadNum("windowX", windowX, 0); 
     595    licqConf.ReadNum("windowY", windowY, 0); 
     596    licqConf.ReadNum("windowH", windowH, 245); 
     597    licqConf.ReadNum("windowW", windowW, 160); 
    550598     
    551599    // Auto logon 
  • trunk/jons-gtk-gui/src/register_user.cpp

    r2532 r2558  
    136136        wizard_message(6); 
    137137 
    138         main_window = main_window_new(g_strdup_printf("%ld", _uin), 
    139             445, 200); 
     138        main_window = main_window_new(g_strdup_printf("%ld", _uin)); 
    140139        main_window_show(); 
    141140        system_status_refresh();