Skip to content

Commit

Permalink
Merge pull request #133 from lidaobing/issue_132
Browse files Browse the repository at this point in the history
Issue 132: fix file accepted when cancel the directory chooser dialog.
  • Loading branch information
lidaobing authored Feb 3, 2018
2 parents 20a7aee + 2fa7289 commit 775e14c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
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

0 comments on commit 775e14c

Please sign in to comment.