# HG changeset patch # User Sadrul Habib Chowdhury # Date 1183305462 0 # Node ID 719f73b9a593e6f82fb2251544b9f29c09bd7296 # Parent 29e48078a899801698fe543d48662d6c61d83d0c Remember the open/save file locations. diff -r 29e48078a899 -r 719f73b9a593 finch/gntprefs.c --- a/finch/gntprefs.c Sun Jul 01 15:26:50 2007 +0000 +++ b/finch/gntprefs.c Sun Jul 01 15:57:42 2007 +0000 @@ -52,6 +52,10 @@ purple_prefs_add_none("/finch/conversations"); purple_prefs_add_bool("/finch/conversations/timestamps", TRUE); purple_prefs_add_bool("/finch/conversations/notify_typing", FALSE); + + purple_prefs_add_none("/finch/filelocations"); + purple_prefs_add_path("/finch/filelocations/last_save_folder", ""); + purple_prefs_add_path("/finch/filelocations/last_save_folder", ""); } void finch_prefs_update_old() diff -r 29e48078a899 -r 719f73b9a593 finch/gntrequest.c --- a/finch/gntrequest.c Sun Jul 01 15:26:50 2007 +0000 +++ b/finch/gntrequest.c Sun Jul 01 15:57:42 2007 +0000 @@ -42,6 +42,7 @@ void *user_data; GntWidget *dialog; GCallback *cbs; + gboolean save; } PurpleGntFileRequest; static GntWidget * @@ -595,9 +596,13 @@ { PurpleGntFileRequest *data = fq; char *file = gnt_file_sel_get_selected_file(GNT_FILE_SEL(data->dialog)); + char *dir = g_path_get_dirname(file); if (data->cbs[0] != NULL) ((PurpleRequestFileCb)data->cbs[0])(data->user_data, file); g_free(file); + purple_prefs_set_path(data->save ? "/finch/filelocations/last_save_folder" : + "/finch/filelocations/last_open_folder", dir); + g_free(dir); purple_request_close(PURPLE_REQUEST_FILE, data->dialog); } @@ -619,14 +624,19 @@ GntWidget *window = gnt_file_sel_new(); GntFileSel *sel = GNT_FILE_SEL(window); PurpleGntFileRequest *data = g_new0(PurpleGntFileRequest, 1); + const char *path; data->user_data = user_data; data->cbs = g_new0(GCallback, 2); data->cbs[0] = ok_cb; data->cbs[1] = cancel_cb; data->dialog = window; + data->save = savedialog; gnt_box_set_title(GNT_BOX(window), title ? title : (savedialog ? _("Save File...") : _("Open File..."))); - gnt_file_sel_set_current_location(sel, purple_home_dir()); /* XXX: */ + + path = purple_prefs_get_path(savedialog ? "/finch/filelocations/last_save_folder" : "/finch/filelocations/last_open_folder"); + gnt_file_sel_set_current_location(sel, (path && *path) ? path : purple_home_dir()); + if (savedialog) gnt_file_sel_set_suggested_filename(sel, filename); g_signal_connect(G_OBJECT(sel->cancel), "activate",