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

check exist preference dialog before open a new one (fix #644) #645

Merged
merged 1 commit into from
Dec 27, 2024
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
4 changes: 4 additions & 0 deletions src/iptux/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
PPalInfo getMe();
GMenuModel* menu() { return menu_; }

GtkWidget* getPreferenceDialog() { return preference_dialog_; }
void setPreferenceDialog(GtkWidget* dialog) { preference_dialog_ = dialog; }

Check warning on line 44 in src/iptux/Application.h

View check run for this annotation

Codecov / codecov/patch

src/iptux/Application.h#L43-L44

Added lines #L43 - L44 were not covered by tests

private:
std::shared_ptr<IptuxConfig> config;
std::shared_ptr<ProgramData> data;
Expand All @@ -58,6 +61,7 @@
LogSystem* logSystem = 0;
NotificationService* notificationService = 0;
GMenuModel* menu_ = 0;
GtkWidget* preference_dialog_ = 0;
bool use_header_bar_ = false;
bool started{false};

Expand Down
7 changes: 7 additions & 0 deletions src/iptux/DataSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@
* @param parent 父窗口指针
*/
void DataSettings::ResetDataEntry(Application* app, GtkWidget* parent) {
if (app->getPreferenceDialog()) {
gtk_window_present(GTK_WINDOW(app->getPreferenceDialog()));
return;

Check warning on line 73 in src/iptux/DataSettings.cpp

View check run for this annotation

Codecov / codecov/patch

src/iptux/DataSettings.cpp#L71-L73

Added lines #L71 - L73 were not covered by tests
}

DataSettings dset(app, parent);
GtkWidget* dialog = GTK_WIDGET(dset.dialog());
app->setPreferenceDialog(dialog);

Check warning on line 78 in src/iptux/DataSettings.cpp

View check run for this annotation

Codecov / codecov/patch

src/iptux/DataSettings.cpp#L78

Added line #L78 was not covered by tests

/* 运行对话框 */
gtk_widget_show_all(dialog);
Expand Down Expand Up @@ -98,6 +104,7 @@
break;
}
}
app->setPreferenceDialog(NULL);

Check warning on line 107 in src/iptux/DataSettings.cpp

View check run for this annotation

Codecov / codecov/patch

src/iptux/DataSettings.cpp#L107

Added line #L107 was not covered by tests
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider connecting to the dialog's 'destroy' signal to handle cases where the dialog is closed externally

This would ensure the preference_dialog_ pointer is properly nulled even if the dialog is destroyed by the window manager or through other means.

}

/**
Expand Down
Loading