Skip to content

Replace gtk_dialog_run with async signal handlers (13/20 instances)#719

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/remove-gtk-dialog-run
Draft

Replace gtk_dialog_run with async signal handlers (13/20 instances)#719
Copilot wants to merge 6 commits intomainfrom
copilot/remove-gtk-dialog-run

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

gtk_dialog_run blocks the UI thread and is removed in GTK4. This PR converts dialog handling to async patterns using GTK signal handlers.

Changes

Converted to async (13/20 instances):

  • Simple notifications (pop_info, pop_warning, AboutDialog, error dialogs): Connect response signal to gtk_widget_destroy, show dialog non-blocking
  • File choosers (choose_file_with_preview, PickEnclosure, OnSaveImage, ShareFile pickers): New *_async() variants accept std::function<void(T*)> callbacks
  • Modal dialogs (ShareFile, DataSettings): Response handlers check action (OK/APPLY/CANCEL), destroy or keep open as needed

Pattern:

// Before
gchar* filename = choose_file_with_preview(title, parent);
if (filename) { process(filename); }

// After  
choose_file_with_preview_async(title, parent, [](gchar* filename) {
  if (filename) { process(filename); }
});

Remaining (7/20 instances):

Functions returning values synchronously (pop_request_quit, pop_obtain_shared_passwd, pop_password_settings, pop_save_path, validation loops in RevisePal, DetectPal). These require API changes at call sites.

Technical Details

  • Use g_signal_connect_data with custom data structs for memory management
  • Lambda captures with [this] or [=] for context preservation
  • Added <functional> header to files using std::function
Original prompt

This section details on the original issue you should resolve

<issue_title>gtk_dialog_run should be removed</issue_title>
<issue_description>1. Gtk4 removed it
2. it will block the UI thread, which cause other events unresponsible.
3. hard to use in unittest</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits February 2, 2026 07:07
…logs

Co-authored-by: lidaobing <27529+lidaobing@users.noreply.github.com>
Co-authored-by: lidaobing <27529+lidaobing@users.noreply.github.com>
Co-authored-by: lidaobing <27529+lidaobing@users.noreply.github.com>
Co-authored-by: lidaobing <27529+lidaobing@users.noreply.github.com>
Co-authored-by: lidaobing <27529+lidaobing@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove gtk_dialog_run to prevent UI blocking Replace gtk_dialog_run with async signal handlers (13/20 instances) Feb 2, 2026
Copilot AI requested a review from lidaobing February 2, 2026 07:18
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Test Results

0 tests   - 69   0 ✅  - 69   0s ⏱️ -3s
0 suites  - 32   0 💤 ± 0 
0 files    -  1   0 ❌ ± 0 

Results for commit bbd167a. ± Comparison against base commit 04a6534.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gtk_dialog_run should be removed

2 participants

Comments