Mercurial > pidgin.yaz
changeset 18410:719f73b9a593
Remember the open/save file locations.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 01 Jul 2007 15:57:42 +0000 |
parents | 29e48078a899 |
children | 3849776d0f71 |
files | finch/gntprefs.c finch/gntrequest.c |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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()
--- 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",