Skip to content

Decouple the app indicator from the Application class#711

Merged
lidaobing merged 1 commit into
mainfrom
bf_refactor_appindicator
Jan 29, 2026
Merged

Decouple the app indicator from the Application class#711
lidaobing merged 1 commit into
mainfrom
bf_refactor_appindicator

Conversation

@lidaobing

@lidaobing lidaobing commented Jan 29, 2026

Copy link
Copy Markdown
Member

Summary by Sourcery

Decouple the app indicator from the Application class by routing actions and signals through a generic GActionGroup and a new activation signal.

Enhancements:

  • Refactor IptuxAppIndicator to hold a reference to its owner and expose a sigActivateMainWindow signal instead of directly depending on Application and UiCoreThread.
  • Update Application startup logic to wire the app indicator to the application action group and unread message count via signal connections.
  • Adjust the dummy app indicator implementation to match the new constructor and method signatures.

@sourcery-ai

sourcery-ai Bot commented Jan 29, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors IptuxAppIndicator to decouple it from Application by passing a GActionGroup and exposing a signal for main-window activation, while moving unread-count wiring and activation logic into Application and updating the dummy implementation accordingly.

Sequence diagram for main window activation via app indicator scroll

sequenceDiagram
  actor User
  participant IptuxAppIndicatorPrivate
  participant IptuxAppIndicator
  participant Application
  participant GActionGroup

  User->>IptuxAppIndicatorPrivate: scroll_event
  IptuxAppIndicatorPrivate->>IptuxAppIndicator: onScrollEvent triggers sigActivateMainWindow.emit()
  IptuxAppIndicator->>Application: sigActivateMainWindow callback
  Application->>GActionGroup: g_action_group_activate_action open_main_window
Loading

Sequence diagram for startup wiring of app indicator and unread count

sequenceDiagram
  participant Application
  participant GActionGroup
  participant UiCoreThread
  participant IptuxAppIndicator

  Application->>GActionGroup: obtain from self.app
  Application->>IptuxAppIndicator: constructor(action_group)
  Application->>IptuxAppIndicator: connect sigActivateMainWindow handler
  Application->>UiCoreThread: connect sigUnreadMsgCountUpdated to IptuxAppIndicator.SetUnreadCount
Loading

Updated class diagram for IptuxAppIndicator decoupled from Application

classDiagram
  class Application {
    +onStartup(self)
    -bool enable_app_indicator_
    -shared_ptr~IptuxAppIndicator~ app_indicator
    -GApplication* app
    -UiCoreThread* cthrd
  }

  class IptuxAppIndicator {
    +IptuxAppIndicator(GActionGroup* action_group)
    +void SetUnreadCount(int count)
    +sigc::signal~void~ sigActivateMainWindow
    -shared_ptr~IptuxAppIndicatorPrivate~ priv
  }

  class IptuxAppIndicatorPrivate {
    +IptuxAppIndicatorPrivate(IptuxAppIndicator* owner)
    +~IptuxAppIndicatorPrivate()
    +static void onScrollEvent(IptuxAppIndicatorPrivate* self)
    -IptuxAppIndicator* owner
    -AppIndicator* indicator
    -GtkBuilder* menuBuilder
  }

  class IptuxAppIndicatorDummy {
    +IptuxAppIndicator(GActionGroup* action_group)
    +void SetUnreadCount(int count)
  }

  class UiCoreThread {
    +sigUnreadMsgCountUpdated
  }

  Application *-- IptuxAppIndicator : owns
  Application --> GActionGroup : uses
  Application --> UiCoreThread : uses
  IptuxAppIndicator *-- IptuxAppIndicatorPrivate : owns
  IptuxAppIndicator --> GActionGroup : uses
  UiCoreThread --> IptuxAppIndicator : updates_unread_count
  IptuxAppIndicatorDummy ..|> IptuxAppIndicator : dummy_implementation
Loading

File-Level Changes

Change Details Files
Decouple IptuxAppIndicator from Application and use a signal to request main-window activation.
  • Remove direct dependency on Application and UiCoreThread headers from the app indicator implementation.
  • Change IptuxAppIndicatorPrivate to hold an owning IptuxAppIndicator pointer instead of an Application pointer.
  • Replace onScrollEvent implementation to emit a new sigActivateMainWindow signal on the owner instead of activating the action directly.
  • Adjust the IptuxAppIndicator constructor to accept a GActionGroup*, store the owner, and use the passed action group when inserting the action group into the tray menu.
src/iptux/AppIndicator.cpp
src/iptux/AppIndicator.h
Expose a public activation signal and unread-count API on IptuxAppIndicator, and wire it from Application.
  • Add sigc::signal sigActivateMainWindow and include necessary headers in AppIndicator.h.
  • In Application::onStartup, construct IptuxAppIndicator with the application GActionGroup instead of Application*, connect sigActivateMainWindow to the existing open_main_window action, and connect the core thread unread-message-count signal to IptuxAppIndicator::SetUnreadCount.
src/iptux/AppIndicator.h
src/iptux/Application.cpp
Update dummy app indicator implementation to match the new interface.
  • Change the dummy IptuxAppIndicator constructor signature to take a GActionGroup* instead of Application*.
  • Provide a no-op implementation for SetUnreadCount in the dummy source.
src/iptux/AppIndicatorDummy.cpp

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

@github-actions

Copy link
Copy Markdown

Test Results

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

Results for commit a2633cf. ± Comparison against base commit e5ebeed.

@codecov

codecov Bot commented Jan 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.99%. Comparing base (e5ebeed) to head (a2633cf).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/iptux/Application.cpp 0.00% 6 Missing ⚠️
src/iptux/AppIndicator.cpp 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #711      +/-   ##
==========================================
- Coverage   52.01%   51.99%   -0.03%     
==========================================
  Files          64       64              
  Lines        8599     8601       +2     
==========================================
- Hits         4473     4472       -1     
- Misses       4126     4129       +3     

☔ View full report in Codecov by Sentry.
📢 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.

@lidaobing lidaobing changed the title 1 Decouple the app indicator from the Application class Jan 29, 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 left some high level feedback:

  • In Application::onStartup, consider avoiding capturing self by reference in the lambda connected to sigActivateMainWindow and instead capture only the needed GActionGroup* (or self.app) by value to make the signal connection more robust against future changes in Application’s lifetime management.
  • The IptuxAppIndicatorPrivate stores a raw IptuxAppIndicator* owner; if the ownership model ever changes, this could become a dangling pointer, so it may be safer to clarify or enforce the lifetime relationship (e.g., with comments or by using a safer pattern like having the outer class explicitly disconnect signals before destruction).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `Application::onStartup`, consider avoiding capturing `self` by reference in the lambda connected to `sigActivateMainWindow` and instead capture only the needed `GActionGroup*` (or `self.app`) by value to make the signal connection more robust against future changes in `Application`’s lifetime management.
- The `IptuxAppIndicatorPrivate` stores a raw `IptuxAppIndicator* owner`; if the ownership model ever changes, this could become a dangling pointer, so it may be safer to clarify or enforce the lifetime relationship (e.g., with comments or by using a safer pattern like having the outer class explicitly disconnect signals before destruction).

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.

@lidaobing lidaobing requested a review from Copilot January 29, 2026 05:08
@lidaobing lidaobing merged commit 8dbae1a into main Jan 29, 2026
20 of 24 checks passed
@lidaobing lidaobing deleted the bf_refactor_appindicator branch January 29, 2026 05:08

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

This PR refactors the IptuxAppIndicator class to remove its direct dependency on the Application class, improving modularity and separation of concerns. The app indicator now accepts a generic GActionGroup* instead of an Application* pointer and communicates back to the application through a signal rather than direct method calls.

Changes:

  • Modified IptuxAppIndicator to accept a GActionGroup* in its constructor instead of an Application* pointer
  • Added a sigActivateMainWindow signal to IptuxAppIndicator for communicating activation events back to the application
  • Updated Application::onStartup to wire up the app indicator to the application's action group and connect the unread message count signal externally

Reviewed changes

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

File Description
src/iptux/Application.cpp Updated to instantiate app indicator with GActionGroup, connect activation signal to action, and wire up unread count updates
src/iptux/AppIndicator.h Changed constructor to accept GActionGroup* instead of Application*, added sigActivateMainWindow signal, removed Application dependency
src/iptux/AppIndicator.cpp Modified constructor and event handler to use owner pointer and emit signal instead of directly calling application methods
src/iptux/AppIndicatorDummy.cpp Updated dummy implementation to match new constructor signature and added SetUnreadCount stub

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