Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 132: fix file accepted when cancel the directory chooser dialog. #133

Merged
merged 1 commit into from
Feb 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [#119] check the return code of `setsockopt`.
* [#?] switch to GTK+3, and use `GtkApplication`.
* [#125] fix crash on UdpData::SomeoneSendmsg.
* [#132] fix file accepted when cancel the directory chooser dialog.

### refactor

Expand Down
3 changes: 3 additions & 0 deletions src/iptux/DialogPeer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,9 @@ void DialogPeer::onAcceptButtonClicked(DialogPeer *self) {
pthread_t pid;

const gchar *filepath = pop_save_path(GTK_WIDGET(self->grpinf->dialog));
if(filepath == nullptr) {
return;
}
self->progdt.path = filepath;
/* 考察数据集中是否存在项 */
widget = GTK_WIDGET(
Expand Down
9 changes: 2 additions & 7 deletions src/iptux/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,9 @@ char *pop_password_settings(GtkWidget *parent) {
}
return NULL;
}
/**
* 弹出接收文件存放位置的对话框.
* @param parent parent window
* @return path string
*/

const char *pop_save_path(GtkWidget *parent) {
const char *path;
const char *path = nullptr;
GtkWidget *dialog;

dialog = gtk_file_chooser_dialog_new(
Expand All @@ -228,7 +224,6 @@ const char *pop_save_path(GtkWidget *parent) {
GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
g_progdt->path.c_str());
path = g_progdt->path.c_str();
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
path = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog));
}
Expand Down
6 changes: 6 additions & 0 deletions src/iptux/dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ bool pop_request_quit();
bool pop_request_shared_file(PalInfo *pal);
char *pop_obtain_shared_passwd(PalInfo *pal);
char *pop_password_settings(GtkWidget *parent);

/**
* 弹出接收文件存放位置的对话框.
* @param parent parent window
* @return path const char*, if user does not accept, return nullptr
*/
const char *pop_save_path(GtkWidget *parent);

} // namespace iptux
Expand Down