Skip to content

add "Accept All" to Peer Dialog Receive File context menu#725

Merged
lidaobing merged 2 commits into
mainfrom
bf_dialog_accept_ctx_menu
Jul 15, 2026
Merged

add "Accept All" to Peer Dialog Receive File context menu#725
lidaobing merged 2 commits into
mainfrom
bf_dialog_accept_ctx_menu

Conversation

@lidaobing

@lidaobing lidaobing commented Jul 14, 2026

Copy link
Copy Markdown
Member
image

Summary by Sourcery

Enhancements:

  • Add a window-level "accept_all" action and connect the receive-file button and context menu to it for file reception control.

@lidaobing
lidaobing marked this pull request as draft July 14, 2026 05:30
@sourcery-ai

sourcery-ai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Expose a new window-level "accept_all" GAction for receiving files, wire the receive-file button and peer dialog context menu to this action, and rename the button from "Accept" to "Accept All" while reusing the existing bulk-accept logic for both automatic and user-invoked acceptance flows.

Sequence diagram for the new accept_all file reception action

sequenceDiagram
  actor User
  participant AcceptAllButton
  participant GAction_accept_all
  participant DialogPeer

  User->>AcceptAllButton: click
  AcceptAllButton->>GAction_accept_all: activate
  GAction_accept_all->>DialogPeer: onAcceptAll
Loading

Flow diagram for entry points into DialogPeer.onAcceptAll

flowchart TD
  A[ShowInfoEnclosure] -->|receiving > 0| B[onAcceptAll]
  C[Accept All button] --> D[win.accept_all]
  D --> B
  E[RecvTreePopup context menu] --> F[win.accept_all]
  F --> B
Loading

File-Level Changes

Change Details Files
Introduce a window-scoped GAction for accepting all pending received files and hook the main receive button to it.
  • Register a new GActionEntry named "accept_all" in DialogPeer::init and bind it to the new DialogPeer::onAcceptAll handler.
  • Replace the old "Accept" button click signal with a GTK actionable wired to the "win.accept_all" action while renaming the button label to "Accept All".
  • Reuse the existing multi-file acceptance code path by moving it from onAcceptButtonClicked into onAcceptAll with a GAction-style signature.
src/iptux/DialogPeer.cpp
src/iptux/DialogPeer.h
Align automatic-accept and context-menu flows with the new accept_all action and prepare menu resources to invoke it.
  • Update ShowInfoEnclosure to call onAcceptAll with GAction-style arguments when there are pending receiving files.
  • Declare the new onAcceptAll static callback in DialogPeer.h alongside other action handlers for consistency.
  • Adjust menus.ui (peer dialog receive-file context menu) to expose an "Accept" item that triggers the win.accept_all action instead of the old button-specific handler.
src/iptux/DialogPeer.cpp
src/iptux/DialogPeer.h
src/iptux/resources/gtk/menus.ui

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Consider updating the onAccept callback signature to use the specific GAction/GVariant pointer types (e.g., GSimpleAction* and GVariant*) instead of void* to improve type safety and readability when used as a GActionCallback.
  • In ShowInfoEnclosure, call the static handler as DialogPeer::onAccept(nullptr, nullptr, dlgpr); instead of dlgpr->onAccept(...) to make it clearer this is a static action callback rather than an instance method.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider updating the `onAccept` callback signature to use the specific GAction/GVariant pointer types (e.g., `GSimpleAction*` and `GVariant*`) instead of `void*` to improve type safety and readability when used as a `GActionCallback`.
- In `ShowInfoEnclosure`, call the static handler as `DialogPeer::onAccept(nullptr, nullptr, dlgpr);` instead of `dlgpr->onAccept(...)` to make it clearer this is a static action callback rather than an instance method.

## Individual Comments

### Comment 1
<location path="src/iptux/DialogPeer.cpp" line_range="849" />
<code_context>

   if (receiving > 0)
-    dlgpr->onAcceptButtonClicked(dlgpr);
+    dlgpr->onAccept(nullptr, nullptr, dlgpr);
 }
 /**
</code_context>
<issue_to_address>
**suggestion:** Avoid calling the GAction callback directly with synthetic nullptr arguments.

This ties `ShowInfoEnclosure` to the exact `onAccept` callback signature and assumes the `GSimpleAction` and `GVariant` parameters are never needed, which is brittle and may break if `onAccept` starts using them. Prefer either triggering the action via the action group (e.g. `g_action_group_activate_action` for "accept") or factoring the core accept logic into a separate helper that both `onAccept` and `ShowInfoEnclosure` call, with `onAccept` just adapting the GAction callback signature.

Suggested implementation:

```cpp
  }

  if (receiving > 0)
    g_action_group_activate_action(G_ACTION_GROUP(dlgpr->window), "accept", nullptr);
}

```

This change assumes that:
1. `dlgpr->window` is the same object used earlier with `g_action_map_disable_actions(G_ACTION_MAP(self.window), ...)` and implements `GActionGroup`.
2. The "accept" action is already registered on that window/action group and wired to `onAccept`.

If `DialogPeer` exposes the action group via another member or accessor (rather than `window`), adjust `G_ACTION_GROUP(dlgpr->window)` accordingly. If the accept action expects a parameter, replace the final `nullptr` with an appropriate `GVariant` value.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/iptux/DialogPeer.cpp Outdated

if (receiving > 0)
dlgpr->onAcceptButtonClicked(dlgpr);
dlgpr->onAccept(nullptr, nullptr, dlgpr);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Avoid calling the GAction callback directly with synthetic nullptr arguments.

This ties ShowInfoEnclosure to the exact onAccept callback signature and assumes the GSimpleAction and GVariant parameters are never needed, which is brittle and may break if onAccept starts using them. Prefer either triggering the action via the action group (e.g. g_action_group_activate_action for "accept") or factoring the core accept logic into a separate helper that both onAccept and ShowInfoEnclosure call, with onAccept just adapting the GAction callback signature.

Suggested implementation:

  }

  if (receiving > 0)
    g_action_group_activate_action(G_ACTION_GROUP(dlgpr->window), "accept", nullptr);
}

This change assumes that:

  1. dlgpr->window is the same object used earlier with g_action_map_disable_actions(G_ACTION_MAP(self.window), ...) and implements GActionGroup.
  2. The "accept" action is already registered on that window/action group and wired to onAccept.

If DialogPeer exposes the action group via another member or accessor (rather than window), adjust G_ACTION_GROUP(dlgpr->window) accordingly. If the accept action expects a parameter, replace the final nullptr with an appropriate GVariant value.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Test Results

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

Results for commit a6f80cf. ± Comparison against base commit 520742e.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.59%. Comparing base (520742e) to head (a6f80cf).

Files with missing lines Patch % Lines
src/iptux/DialogPeer.cpp 60.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #725   +/-   ##
=======================================
  Coverage   51.58%   51.59%           
=======================================
  Files          64       64           
  Lines        8865     8866    +1     
=======================================
+ Hits         4573     4574    +1     
  Misses       4292     4292           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an “Accept” action to the peer dialog’s receive-file context menu and wires the existing “Accept” receive button to a new win.accept GAction, so file reception control is accessible via both button and popup menu.

Changes:

  • Add Accept item to the peer-recv-popup menu (win.accept).
  • Register a new window action accept and route the Accept button through GtkActionable.
  • Update receive-tree selection logic to toggle action sensitivity for accept/refuse.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/iptux/resources/gtk/menus.ui Adds “Accept” to the receive-file popup menu via win.accept.
src/iptux/DialogPeer.h Replaces the old accept-click handler declaration with the new action callback signature.
src/iptux/DialogPeer.cpp Registers win.accept, hooks the Accept button to it, and updates action sensitivity toggling.

Comment thread src/iptux/DialogPeer.cpp Outdated
@sonarqubecloud

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@lidaobing
lidaobing requested a review from Copilot July 15, 2026 04:08
@lidaobing
lidaobing marked this pull request as ready for review July 15, 2026 04:09
@lidaobing lidaobing changed the title add "Accept" to Peer Dialog Receive File context menu add "Accept All" to Peer Dialog Receive File context menu Jul 15, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Consider adding a thin wrapper (e.g. acceptAll() method on DialogPeer) and having both the action callback and ShowInfoEnclosure call that, rather than calling the onAcceptAll action callback directly with nullptr arguments.
  • The new onAcceptAll signature using void*, void* parameters is hard to follow; it would be clearer and safer to use the actual GTK types (e.g. GSimpleAction*, GVariant*) or explicitly document why generic pointers are needed for makeActionEntry.
  • Now that the button is wired to accept_all, double-check whether the button label should explicitly say Accept All or just Accept based on what the handler actually does (accepting all files vs. only selected ones) to avoid user confusion.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider adding a thin wrapper (e.g. `acceptAll()` method on `DialogPeer`) and having both the action callback and `ShowInfoEnclosure` call that, rather than calling the `onAcceptAll` action callback directly with `nullptr` arguments.
- The new `onAcceptAll` signature using `void*, void*` parameters is hard to follow; it would be clearer and safer to use the actual GTK types (e.g. `GSimpleAction*`, `GVariant*`) or explicitly document why generic pointers are needed for `makeActionEntry`.
- Now that the button is wired to `accept_all`, double-check whether the button label should explicitly say `Accept All` or just `Accept` based on what the handler actually does (accepting all files vs. only selected ones) to avoid user confusion.

## Individual Comments

### Comment 1
<location path="src/iptux/DialogPeer.cpp" line_range="933" />
<code_context>
- */
-void DialogPeer::onAcceptButtonClicked(DialogPeer* self) {
+
+void DialogPeer::onAcceptAll(void*, void*, DialogPeer* self) {
   GtkWidget* widget;
   GtkTreeModel* model;
</code_context>
<issue_to_address>
**suggestion:** Align the callback signature and unused parameters with the patterns used by `onRefuse`/`onRefuseAll` for consistency and clarity.

`onAcceptAll` currently takes two anonymous `void*` parameters and a `DialogPeer*`, whereas other action callbacks (e.g., `onRefuse`/`onRefuseAll`) use `DialogPeer& self` and name the first two parameters as `GSimpleAction*` / `GVariant*`. Please update this to use a `DialogPeer&` if possible, use the concrete GTK/GIO types for the first two parameters, or explicitly mark them unused (casts or `[[maybe_unused]]`) to match the existing pattern and avoid warnings.

Suggested implementation:

```cpp
void DialogPeer::onAcceptAll(GSimpleAction* action, GVariant* parameter, DialogPeer& self) {
  (void)action;
  (void)parameter;

```

To fully align with the existing pattern, you will also need to:
1. Update the corresponding declaration in `DialogPeer.hpp` (or the relevant header) to match the new signature:
   - From: `static void onAcceptAll(void*, void*, DialogPeer* self);`
   - To:   `static void onAcceptAll(GSimpleAction* action, GVariant* parameter, DialogPeer& self);`
2. Adjust any places where `onAcceptAll` is connected as a callback (e.g., `g_signal_connect` or `g_simple_action_new_stateful` callbacks) to pass a `DialogPeer&` (or ensure the callback trampoline matches the new signature), following the same pattern as `onRefuse`/`onRefuseAll`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/iptux/DialogPeer.cpp
*/
void DialogPeer::onAcceptButtonClicked(DialogPeer* self) {

void DialogPeer::onAcceptAll(void*, void*, DialogPeer* self) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Align the callback signature and unused parameters with the patterns used by onRefuse/onRefuseAll for consistency and clarity.

onAcceptAll currently takes two anonymous void* parameters and a DialogPeer*, whereas other action callbacks (e.g., onRefuse/onRefuseAll) use DialogPeer& self and name the first two parameters as GSimpleAction* / GVariant*. Please update this to use a DialogPeer& if possible, use the concrete GTK/GIO types for the first two parameters, or explicitly mark them unused (casts or [[maybe_unused]]) to match the existing pattern and avoid warnings.

Suggested implementation:

void DialogPeer::onAcceptAll(GSimpleAction* action, GVariant* parameter, DialogPeer& self) {
  (void)action;
  (void)parameter;

To fully align with the existing pattern, you will also need to:

  1. Update the corresponding declaration in DialogPeer.hpp (or the relevant header) to match the new signature:
    • From: static void onAcceptAll(void*, void*, DialogPeer* self);
    • To: static void onAcceptAll(GSimpleAction* action, GVariant* parameter, DialogPeer& self);
  2. Adjust any places where onAcceptAll is connected as a callback (e.g., g_signal_connect or g_simple_action_new_stateful callbacks) to pass a DialogPeer& (or ensure the callback trampoline matches the new signature), following the same pattern as onRefuse/onRefuseAll.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread src/iptux/DialogPeer.cpp
Comment on lines +933 to 936
void DialogPeer::onAcceptAll(void*, void*, DialogPeer* self) {
GtkWidget* widget;
GtkTreeModel* model;
GtkTreeIter iter;
Comment thread src/iptux/DialogPeer.h
Comment on lines 75 to 81
static void onRecvTreeSelectionChanged(DialogPeer& self, GtkTreeSelection*);
static void onAcceptButtonClicked(DialogPeer* self);
static void ShowInfoEnclosure(DialogPeer* dlgpr);
static bool UpdataEnclosureRcvUI(DialogPeer* dlgpr);
static gint RcvTreePopup(GtkWidget*, GdkEvent* event, DialogPeer* self);
static void onAcceptAll(void*, void*, DialogPeer* self);
static void onRefuse(void*, void*, DialogPeer& self);
static void onRefuseAll(void*, void*, DialogPeer& self);
Comment on lines +341 to +344
<item>
<attribute name="label" translatable="yes">Accept All</attribute>
<attribute name="action">win.accept_all</attribute>
</item>
@lidaobing
lidaobing merged commit 080485e into main Jul 15, 2026
20 of 22 checks passed
@lidaobing
lidaobing deleted the bf_dialog_accept_ctx_menu branch July 15, 2026 04:13
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.

2 participants