Show
Ignore:
Timestamp:
04/20/06 06:29:18 (3 years ago)
Author:
jordi
Message:

When the main window is resized or moved, the current position and size is saved to the configuration values.

The configuration now is saved by main.cxx when the application quits correctly.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/gtk/MainView.cxx

    r89 r94  
    3434// Forward declarations. 
    3535static void main_window_about_box_cb (GtkWidget *, gpointer); 
     36static gboolean main_window_moved_or_resized_cb (GtkWidget *,  
     37                                                 GdkEventConfigure *, gpointer); 
    3638static void main_window_go_to_first_page_cb (GtkWidget *, gpointer); 
    3739static void main_window_go_to_last_page_cb (GtkWidget *, gpointer); 
     
    143145    m_MainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); 
    144146    setMainWindowIcon (); 
    145     // Connect already the destroy signal. 
     147    // Connect already the destroy and delete signal. 
    146148    g_signal_connect (G_OBJECT (m_MainWindow), "destroy", 
    147149                      G_CALLBACK (main_window_quit_cb), NULL); 
     150    g_signal_connect (G_OBJECT (m_MainWindow), "configure-event", 
     151                      G_CALLBACK (main_window_moved_or_resized_cb), NULL); 
    148152    // Create the main vertical box. 
    149153    m_MainBox = gtk_vbox_new (FALSE, 0); 
     
    358362MainView::show (void) 
    359363{     
     364    Config &config = Config::getConfig (); 
     365    gtk_window_set_default_size (GTK_WINDOW (m_MainWindow), 
     366                                 config.getWindowWidth (), 
     367                                 config.getWindowHeight ()); 
    360368    gtk_widget_show (m_MainWindow); 
    361     gtk_window_maximize (GTK_WINDOW (m_MainWindow)); 
     369    gtk_window_move (GTK_WINDOW (m_MainWindow),  
     370                     config.getWindowX (), config.getWindowY ()); 
    362371} 
    363372 
     
    754763 
    755764/// 
     765/// @brief Called when the window is moved or resized. 
     766/// 
     767/// This is used to save the current window's position and size. 
     768/// 
     769gboolean 
     770main_window_moved_or_resized_cb (GtkWidget *widget, GdkEventConfigure *event,  
     771                                 gpointer data) 
     772{ 
     773    // First set the window's size and position to the configuration. 
     774    GtkWindow *m_MainWindow = GTK_WINDOW (widget); 
     775    Config &config = Config::getConfig (); 
     776    config.setWindowSize (event->width, event->height); 
     777    gint x; 
     778    gint y; 
     779    gtk_window_get_position (m_MainWindow, &x, &y); 
     780    config.setWindowPos (x, y); 
     781 
     782    return FALSE; 
     783} 
     784 
     785/// 
    756786/// @brief The user tries to go to the first page. 
    757787///