Revision: 4975 http://geany.svn.sourceforge.net/geany/?rev=4975&view=rev Author: statc Date: 2010-05-31 09:26:07 +0000 (Mon, 31 May 2010)
Log Message: ----------- Use a separate queue to store recently closed files
Modified Paths: -------------- branches/sm/ChangeLog.sm branches/sm/src/document.c branches/sm/src/keybindings.c branches/sm/src/main.c branches/sm/src/ui_utils.c branches/sm/src/ui_utils.h
Modified: branches/sm/ChangeLog.sm =================================================================== --- branches/sm/ChangeLog.sm 2010-05-31 09:25:37 UTC (rev 4974) +++ branches/sm/ChangeLog.sm 2010-05-31 09:26:07 UTC (rev 4975) @@ -4,6 +4,9 @@ src/keyfile.h, src/main.c, src/ui_utils.c, src/ui_utils.h: Update lists of recent files and projects in geany.conf immediately instead of writing them on exit. + * src/document.c, src/keybindings.c, src/main.c, src/ui_utils.c, + src/ui_utils.h: + Use a separate queue to store recently closed files
2010-05-30 Eugene Arshinov <earshinov(at)gmail(dot)com>
Modified: branches/sm/src/document.c =================================================================== --- branches/sm/src/document.c 2010-05-31 09:25:37 UTC (rev 4974) +++ branches/sm/src/document.c 2010-05-31 09:26:07 UTC (rev 4975) @@ -636,7 +636,7 @@
/* Checking real_path makes it likely the file exists on disk */ if (! main_status.closing_all && doc->real_path != NULL) - ui_add_recent_file(doc->file_name, TRUE); + ui_add_closed_file(doc->file_name);
doc->is_valid = FALSE;
Modified: branches/sm/src/keybindings.c =================================================================== --- branches/sm/src/keybindings.c 2010-05-31 09:25:37 UTC (rev 4974) +++ branches/sm/src/keybindings.c 2010-05-31 09:26:07 UTC (rev 4975) @@ -1349,10 +1349,18 @@ break; case GEANY_KEYS_FILE_OPENLASTTAB: { - gchar *utf8_filename = g_queue_peek_head(ui_prefs.recent_queue); - gchar *locale_filename = utils_get_locale_from_utf8(utf8_filename); - document_open_file(locale_filename, FALSE, NULL, NULL); - g_free(locale_filename); + gchar *utf8_filename = g_queue_pop_head(ui_prefs.closed_queue); + if (utf8_filename == NULL) + { + utils_beep(); + } + else + { + gchar *locale_filename = utils_get_locale_from_utf8(utf8_filename); + document_open_file(locale_filename, FALSE, NULL, NULL); + g_free(utf8_filename); + g_free(locale_filename); + } break; } case GEANY_KEYS_FILE_SAVE:
Modified: branches/sm/src/main.c =================================================================== --- branches/sm/src/main.c 2010-05-31 09:25:37 UTC (rev 4974) +++ branches/sm/src/main.c 2010-05-31 09:26:07 UTC (rev 4975) @@ -276,6 +276,7 @@ app->tm_workspace = tm_get_workspace(); ui_prefs.recent_queue = g_queue_new(); ui_prefs.recent_projects_queue = g_queue_new(); + ui_prefs.closed_queue = g_queue_new(); main_status.opening_session_files = FALSE;
ui_init_stock_items(); @@ -1279,6 +1280,7 @@ if (ui_prefs.recent_projects_queue->length > 0) g_warning("Unsaved recent projects (%d)", ui_prefs.recent_projects_queue->length); queue_free(ui_prefs.recent_projects_queue); + queue_free(ui_prefs.closed_queue);
if (ui_widgets.prefs_dialog && GTK_IS_WIDGET(ui_widgets.prefs_dialog)) gtk_widget_destroy(ui_widgets.prefs_dialog); if (ui_widgets.save_filesel && GTK_IS_WIDGET(ui_widgets.save_filesel)) gtk_widget_destroy(ui_widgets.save_filesel);
Modified: branches/sm/src/ui_utils.c =================================================================== --- branches/sm/src/ui_utils.c 2010-05-31 09:25:37 UTC (rev 4974) +++ branches/sm/src/ui_utils.c 2010-05-31 09:26:07 UTC (rev 4975) @@ -1106,6 +1106,14 @@ }
+void ui_add_closed_file(const gchar *utf8_filename) +{ + g_queue_push_head(ui_prefs.closed_queue, g_strdup(utf8_filename)); + if (g_queue_get_length(ui_prefs.closed_queue) > file_prefs.mru_length) + g_free(g_queue_pop_tail(ui_prefs.closed_queue)); +} + + /* Returns: newly allocated string with the UTF-8 menu text. */ gchar *ui_menu_item_get_text(GtkMenuItem *menu_item) {
Modified: branches/sm/src/ui_utils.h =================================================================== --- branches/sm/src/ui_utils.h 2010-05-31 09:25:37 UTC (rev 4974) +++ branches/sm/src/ui_utils.h 2010-05-31 09:26:07 UTC (rev 4975) @@ -100,6 +100,10 @@ GQueue *recent_queue; GQueue *recent_projects_queue;
+ /* Stores recently closed files. Should contain file_prefs.mru_length + * elements max. Element type: gchar *. */ + GQueue *closed_queue; + /* Other menu-item related data */ gchar *custom_date_format; gchar **custom_commands; @@ -287,7 +291,9 @@
void ui_add_recent_project_file(const gchar *utf8_filename);
+void ui_add_closed_file(const gchar *utf8_filename);
+ void ui_update_tab_status(GeanyDocument *doc);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.