Mercurial > pidgin
changeset 15936:0f1ab43db297
fix file saving
author | Richard Nelson <wabz@pidgin.im> |
---|---|
date | Tue, 27 Mar 2007 00:46:18 +0000 |
parents | cc3c50816cc9 |
children | fd9482f9f604 |
files | finch/gntrequest.c finch/libgnt/gntfilesel.c finch/libgnt/gntfilesel.h |
diffstat | 3 files changed, 20 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntrequest.c Mon Mar 26 05:42:33 2007 +0000 +++ b/finch/gntrequest.c Tue Mar 27 00:46:18 2007 +0000 @@ -582,6 +582,8 @@ data->dialog = window; 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: */ + if (savedialog) + gnt_file_sel_set_suggested_filename(sel, filename); g_signal_connect(G_OBJECT(sel->cancel), "activate", G_CALLBACK(file_cancel_cb), data); g_signal_connect(G_OBJECT(sel->select), "activate",
--- a/finch/libgnt/gntfilesel.c Mon Mar 26 05:42:33 2007 +0000 +++ b/finch/libgnt/gntfilesel.c Tue Mar 27 00:46:18 2007 +0000 @@ -28,6 +28,7 @@ { GntFileSel *sel = GNT_FILE_SEL(widget); g_free(sel->current); + g_free(sel->suggest); if (sel->tags) { g_list_foreach(sel->tags, (GFunc)g_free, NULL); g_list_free(sel->tags); @@ -70,7 +71,8 @@ { char *old; const char *tmp; - tmp = (const char*)gnt_tree_get_selection_data(sel->dirsonly ? GNT_TREE(sel->dirs) : GNT_TREE(sel->files)); + tmp = sel->suggest ? sel->suggest : + (const char*)gnt_tree_get_selection_data(sel->dirsonly ? GNT_TREE(sel->dirs) : GNT_TREE(sel->files)); old = g_strdup_printf("%s%s%s", sel->current, sel->current[1] ? G_DIR_SEPARATOR_S : "", tmp ? tmp : ""); gnt_entry_set_text(GNT_ENTRY(sel->location), old); g_free(old); @@ -230,6 +232,8 @@ static void file_sel_changed(GntWidget *widget, gpointer old, gpointer current, GntFileSel *sel) { + g_free(sel->suggest); + sel->suggest = NULL; update_location(sel); } @@ -449,12 +453,19 @@ return sel->dirsonly; } +void gnt_file_sel_set_suggested_filename(GntFileSel *sel, const char *suggest) +{ + sel->suggest = g_strdup(suggest); +} + char *gnt_file_sel_get_selected_file(GntFileSel *sel) { char *ret; - const char *tmp; - tmp = (const char*)gnt_tree_get_selection_data(sel->dirsonly ? GNT_TREE(sel->dirs) : GNT_TREE(sel->files)); - ret = g_strdup_printf("%s%s%s", sel->current, sel->current[1] ? G_DIR_SEPARATOR_S : "", tmp ? tmp : ""); + if (sel->dirsonly) { + ret = g_strdup(g_path_get_dirname(gnt_entry_get_text(GNT_ENTRY(sel->location)))); + } else { + ret = g_strdup(gnt_entry_get_text(GNT_ENTRY(sel->location))); + } return ret; }
--- a/finch/libgnt/gntfilesel.h Mon Mar 26 05:42:33 2007 +0000 +++ b/finch/libgnt/gntfilesel.h Tue Mar 27 00:46:18 2007 +0000 @@ -33,6 +33,7 @@ GntWidget *cancel; /* cancel button */ char *current; /* Full path of the current location */ + char *suggest; /* Suggested filename */ /* XXX: someone should make these useful */ gboolean must_exist; /* Make sure the selected file (the name entered in 'location') exists */ gboolean dirsonly; /* Show only directories */ @@ -73,6 +74,8 @@ void gnt_file_sel_set_multi_select(GntFileSel *sel, gboolean set); +void gnt_file_sel_set_suggested_filename(GntFileSel *sel, const char *suggest); + G_END_DECLS #endif /* GNT_FILE_SEL_H */