Changeset 94
- Timestamp:
- 04/20/06 06:29:18 (3 years ago)
- Location:
- trunk/src
- Files:
-
- 4 modified
-
Config.cxx (modified) (3 diffs)
-
Config.h (modified) (1 diff)
-
gtk/MainView.cxx (modified) (4 diffs)
-
main.cxx (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Config.cxx
r93 r94 197 197 198 198 /// 199 /// @brief Save the current configuration to a file. 200 /// 201 void 202 Config::save () 203 { 204 gchar *contents = g_key_file_to_data (m_Values, NULL, NULL); 205 gchar *configFile = getConfigFileName (); 206 GError *error = NULL; 207 if ( !g_file_set_contents (configFile, contents, -1, &error) ) 208 { 209 g_warning ("Couldn't write configuration file: %s\n", error->message); 210 g_error_free (error); 211 } 212 g_free (contents); 213 g_free (configFile); 214 } 215 216 /// 199 217 /// @brief Saves the current window's size. 200 218 /// … … 255 273 GList *dirs = NULL; 256 274 gchar *dirName = g_strdup (path); 257 while ( !g_file_test (dirName, G_FILE_TEST_EXISTS) ) ;275 while ( !g_file_test (dirName, G_FILE_TEST_EXISTS) ) 258 276 { 259 277 dirs = g_list_prepend (dirs, dirName); … … 263 281 // Now create all of them. 264 282 GList *dir = g_list_first (dirs); 265 while ( NULL != dir ) ;283 while ( NULL != dir ) 266 284 { 267 285 if ( -1 == g_mkdir ((gchar *)dir->data, 0700) ) -
trunk/src/Config.h
r93 r94 43 43 gint getWindowX (void); 44 44 gint getWindowY (void); 45 void save(void); 45 46 void setWindowSize (gint width, gint height); 46 47 void setWindowPos (gint x, gint y); -
trunk/src/gtk/MainView.cxx
r89 r94 34 34 // Forward declarations. 35 35 static void main_window_about_box_cb (GtkWidget *, gpointer); 36 static gboolean main_window_moved_or_resized_cb (GtkWidget *, 37 GdkEventConfigure *, gpointer); 36 38 static void main_window_go_to_first_page_cb (GtkWidget *, gpointer); 37 39 static void main_window_go_to_last_page_cb (GtkWidget *, gpointer); … … 143 145 m_MainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); 144 146 setMainWindowIcon (); 145 // Connect already the destroy signal.147 // Connect already the destroy and delete signal. 146 148 g_signal_connect (G_OBJECT (m_MainWindow), "destroy", 147 149 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); 148 152 // Create the main vertical box. 149 153 m_MainBox = gtk_vbox_new (FALSE, 0); … … 358 362 MainView::show (void) 359 363 { 364 Config &config = Config::getConfig (); 365 gtk_window_set_default_size (GTK_WINDOW (m_MainWindow), 366 config.getWindowWidth (), 367 config.getWindowHeight ()); 360 368 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 ()); 362 371 } 363 372 … … 754 763 755 764 /// 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 /// 769 gboolean 770 main_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 /// 756 786 /// @brief The user tries to go to the first page. 757 787 /// -
trunk/src/main.cxx
r73 r94 24 24 #include <MainView.h> 25 25 #include "MainPter.h" 26 #include "Config.h" 26 27 27 28 … … 92 93 // the presenter's responsibility. 93 94 delete mainPter; 95 96 // Save the configuration. 97 Config::getConfig().save (); 98 94 99 // All done!. 95 100 return EXIT_SUCCESS;
