Skip to content

feat(gui): remove the global Connect/Disconnect toolbar button - #663

Merged
got3nks merged 5 commits into
amule-org:masterfrom
LSalami:remove-global-connect-button
Jul 28, 2026
Merged

feat(gui): remove the global Connect/Disconnect toolbar button#663
got3nks merged 5 commits into
amule-org:masterfrom
LSalami:remove-global-connect-button

Conversation

@LSalami

@LSalami LSalami commented Jul 28, 2026

Copy link
Copy Markdown

Closes #402.

Per-network controls already exist (Kad pane's Start/Stop, Servers pane's ED2K connect/disconnect), and the connection state is already shown in the status bar. Originally this PR just removed the global toolbar button; after review discussion with got3nks, it now relocates the button's functionality into the ED2K and Kad panes instead, as a better end state than a plain removal.

What changed

  • Removed the ID_BUTTONCONNECT toolbar tool, its three skin icons (Toolbar_Connect/Disconnect/Connecting) and their bitmap wiring, the button-update block in ShowConnectionState(), and the two EnableTool(ID_BUTTONCONNECT, ...) call sites. ShowConnectionState()'s now-unused skinChanged parameter (and the forceUpdate plumbing that reached it through GuiEvents.cpp's ShowConnState()) is gone too.
  • CServerWnd's IDC_ED2KDISCONNECT and CKadDlg's ID_KADDISCONNECT buttons are now 3-state Connect/Cancel/Disconnect toggles, mirroring the removed global button's ed2kState/kadState-driven logic and reusing the existing connButImg() bitmaps. CServerWnd::UpdateED2KConnectButton() / CKadDlg::UpdateConnectButton() are called from ShowConnectionState() alongside the existing UpdateED2KInfo()/UpdateKadInfo(), plus once from each pane's own ctor/Init() for the initial paint. This means ED2K and Kad can now be connected/disconnected independently, which the old OR-toggled global button never allowed, and the ED2K pane gains a Connect button it never had (previously Disconnect-only).
  • OnBnClickedED2KDisconnect gained the missing "connect when off" branch; OnBnClickedDisconnectKad branches the same way (StopKad() also covers "cancel while connecting" -- there's no separate abort path). CamuleDlg::OnBnConnect() and the tray icon's connect/disconnect action are untouched.
  • Left ID_BUTTONCONNECT and muuli_wdr.cpp's muleToolbar() (which still references it) alone -- that function predates Apply_Toolbar_Skin, is never called anywhere in the codebase, and touching pre-existing dead code felt out of scope for this fix.

Testing

Built and ran amule on Windows (MSYS2/MinGW-w64) interactively:

  • Both buttons show the correct label + icon for their live state (Connect/Cancel/Disconnect).
  • Clicking ED2K's button disconnects, then reconnects, correctly toggling label/icon each time; same full cycle re-verified after removing an initial state-cache (see review discussion below).
  • Disabling ED2K in Preferences while Kad stays connected: the ED2K tab disappears (pre-existing DoNetworkRearrange behavior) while Kad's button and connection are unaffected, confirming the two toggle independently.
  • Re-enabling ED2K (which prompts for an app restart, pre-existing behavior) and restarting: on the fresh post-restart paint, both buttons show the correct live state immediately.
  • amuleGUI (CLIENT_GUI) builds clean with these changes; full interactive remote-daemon testing not performed.

An earlier revision memoized each button's state to avoid redundant SetLabel/SetBitmap/Enable calls; got3nks's review caught two bugs in that (the early-return could skip Enable() and leave a button stuck disabled, and the function-scope static cache survived widget recreation and could leave a stale default label after Init()). Dropped the memoization entirely -- both bugs go away, and per-tick SetLabel/SetBitmap/Enable on a plain wxButton is cheap (master's own second call site already did an unconditional EnableTool every tick without issue).

@LSalami

LSalami commented Jul 28, 2026

Copy link
Copy Markdown
Author

Visually confirmed locally (macOS build): the toolbar now starts directly with Networks, no leftover gap or orphaned separator where the Connect/Disconnect button used to be.

@LSalami
LSalami force-pushed the remove-global-connect-button branch from cb71bed to f029c39 Compare July 28, 2026 08:27
@got3nks

got3nks commented Jul 28, 2026

Copy link
Copy Markdown

Thanks for this @LSalami — the removal is clean and the write-up in the description is spot on.

Before merging, a better end state came up that I'd like your take on: instead of dropping the three connect/connecting/disconnect icons, relocate the live status into each network's own pane by turning the existing per-network Disconnect buttons into live toggles.

Concretely, the ED2K pane (IDC_ED2KDISCONNECT) and Kad pane (ID_KADDISCONNECT) buttons become 3-state toggles that mirror what the global button did, scoped to one network: off → Connect (Toolbar_Connect), connecting → Cancel (Toolbar_Connecting), connected → Disconnect (Toolbar_Disconnect).

The nice part is the state is already computed for us: ShowConnectionState() derives per-network ed2kState/kadState every tick and already calls UpdateED2KInfo()/UpdateKadInfo(). So rather than deleting that block, we repurpose it to drive the two buttons via connButImg() + wxButton::SetBitmap(). Each handler then becomes the matching half of the old OnBnConnect — the ED2K one just needs the missing "connect when off" branch added.

Why it's worth the extra step over a plain removal:

  • Preserves the old functionality and improves on it — you can bring up ED2K or Kad independently, which the global OR-toggle never allowed.
  • Reuses the three icons instead of retiring them.
  • The ED2K pane gains a Connect button it never had (today it only offers Disconnect).
  • No new translatable strings — Connect/Cancel/Disconnect are already in the catalog.
  • Works over EC too, exactly as the global button did in amulegui.

OnBnConnect and the tray icon's connect/disconnect stay exactly as they are.

@LSalami

LSalami commented Jul 28, 2026

Copy link
Copy Markdown
Author

That's a better end state than a plain removal, agreed — independent ED2K/Kad toggling is a real usability win, and giving the ED2K pane a Connect button it never had is a nice side effect rather than scope creep.

I'll rework this PR along those lines: turn IDC_ED2KDISCONNECT / ID_KADDISCONNECT into 3-state toggles driven by the existing ed2kState/kadState computed in ShowConnectionState(), reusing connButImg() + wxButton::SetBitmap() as you outlined, and add the missing "connect when off" branch to the ED2K handler. OnBnConnect and the tray icon stay untouched.

Will push an update once it's working locally on macOS.

@LSalami
LSalami force-pushed the remove-global-connect-button branch from f029c39 to db0bb57 Compare July 28, 2026 16:52
LSalami added a commit to LSalami/amule that referenced this pull request Jul 28, 2026
…l/Disconnect toggles

Relocates the removed global toolbar button's functionality into the
ED2K (IDC_ED2KDISCONNECT) and Kad (ID_KADDISCONNECT) panes instead of
just dropping it, per got3nks's proposal on amule-org#663: each button now
mirrors ed2kState/kadState (off/connecting/connected) using the
existing connButImg() bitmaps, and can independently connect or
cancel/disconnect its own network -- something the old OR-toggled
global button never allowed. The ED2K pane also gains a Connect
button it never had (previously Disconnect-only).

CServerWnd::UpdateED2KConnectButton() / CKadDlg::UpdateConnectButton()
are called from CamuleDlg::ShowConnectionState() alongside the
existing UpdateED2KInfo()/UpdateKadInfo() calls, and once from each
pane's own ctor/Init() for the initial paint. OnBnClickedED2KDisconnect
and OnBnClickedDisconnectKad gained the missing "connect when off"
branch; OnBnConnect and the tray icon are untouched.

Verified interactively on Windows: both buttons show the correct
label/icon for their live state, ED2K disconnect/reconnect works from
its own button, and disabling ED2K in Preferences while Kad stays
connected confirms the two toggle independently.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@LSalami

LSalami commented Jul 28, 2026

Copy link
Copy Markdown
Author

Pushed the toggle implementation (db0bb57), rebased on current master.

  • CServerWnd::UpdateED2KConnectButton() / CKadDlg::UpdateConnectButton() drive IDC_ED2KDISCONNECT / ID_KADDISCONNECT from ed2kState/Kad-equivalent state, reusing connButImg() for the bitmap. Called from ShowConnectionState() alongside the existing UpdateED2KInfo()/UpdateKadInfo(), plus once from each pane's own ctor/Init() for the initial paint.
  • OnBnClickedED2KDisconnect gained the missing "connect when off" branch; OnBnClickedDisconnectKad now branches the same way (StopKad() also covers "cancel while connecting" — no separate abort path exists).
  • OnBnConnect and the tray icon's connect/disconnect are untouched.

Verified interactively on Windows (MSYS2/MinGW-w64 build):

  • Both buttons show the correct label + icon for their live state (Connect/Cancel/Disconnect).
  • Clicking ED2K's button disconnects, then reconnects, correctly toggling label/icon each time.
  • Disabling ED2K in Preferences while Kad stays connected: the ED2K tab disappears (pre-existing DoNetworkRearrange behavior) while Kad's button and connection are unaffected, confirming the two toggle independently.

Haven't run the full unit test suite here since none of this touches core/testable logic (pure GUI wiring) — let me know if you'd like that run anyway before merge.

LSalami added a commit to LSalami/amule that referenced this pull request Jul 28, 2026
…l/Disconnect toggles

Relocates the removed global toolbar button's functionality into the
ED2K (IDC_ED2KDISCONNECT) and Kad (ID_KADDISCONNECT) panes instead of
just dropping it, per got3nks's proposal on amule-org#663: each button now
mirrors ed2kState/kadState (off/connecting/connected) using the
existing connButImg() bitmaps, and can independently connect or
cancel/disconnect its own network -- something the old OR-toggled
global button never allowed. The ED2K pane also gains a Connect
button it never had (previously Disconnect-only).

CServerWnd::UpdateED2KConnectButton() / CKadDlg::UpdateConnectButton()
are called from CamuleDlg::ShowConnectionState() alongside the
existing UpdateED2KInfo()/UpdateKadInfo() calls, and once from each
pane's own ctor/Init() for the initial paint. OnBnClickedED2KDisconnect
and OnBnClickedDisconnectKad gained the missing "connect when off"
branch; OnBnConnect and the tray icon are untouched.

Verified interactively on Windows: both buttons show the correct
label/icon for their live state, ED2K disconnect/reconnect works from
its own button, and disabling ED2K in Preferences while Kad stays
connected confirms the two toggle independently.

po/ regenerated via scripts/update-po.sh to match the new button
labels ("Disconnect Kad" is now unused and moves to the obsolete
section; no new translatable strings).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@LSalami
LSalami force-pushed the remove-global-connect-button branch from db0bb57 to b34348b Compare July 28, 2026 16:58

@got3nks got3nks 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.

Toggle implementation matches what we discussed — 3-state, connButImg() reuse, ED2K gaining the Connect it never had, tray icon and OnBnConnect untouched. Two problems, both from the reintroduced memoization.

1. Enable() sits below the early return, and the escape hatches that used to cover it are gone.

static State s_oldState = Off;
static bool s_first = true;
if (!s_first && state == s_oldState) {
	return;                                                                    // skips everything below
}
...
button->Enable(thePrefs::GetNetworkED2K() && theApp->ipfilter->IsReady());     // only re-evaluated on state change

Master memoized too, but it had two ways out that this PR removes:

  • if ((true == skinChanged) || (currentState != s_oldState)) — and IPFilter.cpp calls ShowConnectionState(true) precisely to force that block once the filter finishes loading (its comment read // update connect button). The PR deletes the skinChanged/forceUpdate parameter as unused, so that path is gone.
  • A second, unconditional EnableTool(ID_BUTTONCONNECT, … && ipfilter->IsReady()) on the network-config-changed path, which covered the prefs case. Also removed.

Net effect: start with IP filtering on → state Off, IsReady() false → button disabled; filter becomes ready → state still Off → early return → button stays disabled, and with the global button gone the only ways out are the tray icon or double-clicking a server. Same shape for prefs: toggling ED2K/Kad while already disconnected leaves the enable state stale.

2. The cache is function-scope static — shared across instances and surviving widget recreation, so the Init()/ctor "initial paint" call early-returns whenever the remembered state matches and the fresh button keeps its wxDesigner default label ("Disconnect Kad").

Suggested fix: drop the memoization in both updaters. They run once per ShowConnectionState() tick, and SetLabel/SetBitmap/Enable are cheap — master's second call site did EnableTool unconditionally every time anyway. If you'd rather keep it, make the cache a member, and always run Enable() before the early return so only label/bitmap work is skipped.

3. Please verify the remote (amuleGUI → daemon) case explicitly. The accessors are all present remotely (CServerConnectRem::IsConnecting(), IsConnectedED2K(), IsConnectedKad(), IsKadRunning()), and CIPFilterRem::IsReady() is a stub returning true, so labels should track. But the enable gate still reads thePrefs::GetNetworkED2K()/Kademlia(), which on amuleGUI arrive over EC — and GuiEvents.cpp's ShowConnState(forceUpdate) is the remote force path being removed here. Worth checking that toggling ED2K/Kad in a remote session actually updates both buttons.

Minor: please update the PR description — it still describes only the removal, and it seeds the squash-merge message. Ignore the po/ conflict for now, we'll sort catalogs separately.

@LSalami

LSalami commented Jul 28, 2026

Copy link
Copy Markdown
Author

Fixed a po/ catalog drift the CI caught (forgot to re-run scripts/update-po.sh after the last label change) and squashed the fix into the implementation commit (b34348b). All 13 CI checks are green now.

LSalami added 3 commits July 28, 2026 19:42
Closes amule-org#402. Per-network controls already exist (Kad pane's Start/Stop,
Servers pane's ED2K connect/disconnect), the connection state is
already shown in the status bar, and after discussing relocating it
into the Networks view the agreed call (got3nks + ngosang) was simply
to remove it -- mirrors what amule-org#585 already did on the Web UI side.

Removed the toolbar tool, its three skin icons (Toolbar_Connect/
Disconnect/Connecting) and their bitmap wiring, the button-update block
in ShowConnectionState(), and the two EnableTool(ID_BUTTONCONNECT, ...)
call sites.

CamuleDlg::OnBnConnect() itself stays -- CMuleTrayIcon::DoConnectDisconnect()
still calls it for the tray icon's own connect/disconnect action, which
is unaffected by this change.

ShowConnectionState()'s skinChanged parameter was only ever read by the
now-removed block, so it's gone too, along with the one call site that
passed true and the forceUpdate plumbing that reached it through
GuiEvents.cpp's ShowConnState() free function.

Left ID_BUTTONCONNECT and muuli_wdr.cpp's muleToolbar() (which still
calls it) alone -- that function predates Apply_Toolbar_Skin, is never
called anywhere, and touching pre-existing dead code is out of scope
for this fix.

Verified: built and ran both amule and amulegui cleanly, full unit
test suite passing (26/26). Confirmed via the po/ diff that "Connect"/
"Disconnect"/"Cancel" remain in the catalog (still used by other
per-network buttons) -- only their now-orphaned toolbar-specific
tooltip strings were dropped. Could not get a real on-screen visual
confirmation of the toolbar layout -- same macOS Accessibility
automation limitations as amule-org#180 got in the way of screenshotting the
actual app window.
Mechanical rebase to resolve conflicts against master's amule-org#642/amule-org#643 --
no source changes here. Resolved a real conflict in amuleDlg.cpp's
event table: amule-org#642 added the Alt+<letter> EVT_MENU block right where
this branch removed the EVT_TOOL(ID_BUTTONCONNECT, ...) line; kept
amule-org#642's block, dropped the connect-button line as intended.

Regenerated again via scripts/update-po.sh after later rebasing onto
master's amule-org#671 (Preferences sidebar) and amule-org#665/amule-org#662 (amuleapi
credentials, sparse part-file setting), which had added strings this
branch's catalogs didn't have yet.
…l/Disconnect toggles

Relocates the removed global toolbar button's functionality into the
ED2K (IDC_ED2KDISCONNECT) and Kad (ID_KADDISCONNECT) panes instead of
just dropping it, per got3nks's proposal on amule-org#663: each button now
mirrors ed2kState/kadState (off/connecting/connected) using the
existing connButImg() bitmaps, and can independently connect or
cancel/disconnect its own network -- something the old OR-toggled
global button never allowed. The ED2K pane also gains a Connect
button it never had (previously Disconnect-only).

CServerWnd::UpdateED2KConnectButton() / CKadDlg::UpdateConnectButton()
are called from CamuleDlg::ShowConnectionState() alongside the
existing UpdateED2KInfo()/UpdateKadInfo() calls, and once from each
pane's own ctor/Init() for the initial paint. OnBnClickedED2KDisconnect
and OnBnClickedDisconnectKad gained the missing "connect when off"
branch; OnBnConnect and the tray icon are untouched.

Verified interactively on Windows: both buttons show the correct
label/icon for their live state, ED2K disconnect/reconnect works from
its own button, and disabling ED2K in Preferences while Kad stays
connected confirms the two toggle independently.

po/ regenerated via scripts/update-po.sh to match the new button
labels ("Disconnect Kad" is now unused and moves to the obsolete
section; no new translatable strings).
@LSalami
LSalami force-pushed the remove-global-connect-button branch from b34348b to d66888f Compare July 28, 2026 17:47
LSalami added a commit to LSalami/amule that referenced this pull request Jul 28, 2026
…l/Disconnect toggles

Relocates the removed global toolbar button's functionality into the
ED2K (IDC_ED2KDISCONNECT) and Kad (ID_KADDISCONNECT) panes instead of
just dropping it, per got3nks's proposal on amule-org#663: each button now
mirrors ed2kState/kadState (off/connecting/connected) using the
existing connButImg() bitmaps, and can independently connect or
cancel/disconnect its own network -- something the old OR-toggled
global button never allowed. The ED2K pane also gains a Connect
button it never had (previously Disconnect-only).

CServerWnd::UpdateED2KConnectButton() / CKadDlg::UpdateConnectButton()
are called from CamuleDlg::ShowConnectionState() alongside the
existing UpdateED2KInfo()/UpdateKadInfo() calls, and once from each
pane's own ctor/Init() for the initial paint. OnBnClickedED2KDisconnect
and OnBnClickedDisconnectKad gained the missing "connect when off"
branch; OnBnConnect and the tray icon are untouched.

Verified interactively on Windows: both buttons show the correct
label/icon for their live state, ED2K disconnect/reconnect works from
its own button, and disabling ED2K in Preferences while Kad stays
connected confirms the two toggle independently.

po/ regenerated via scripts/update-po.sh to match the new button
labels ("Disconnect Kad" is now unused and moves to the obsolete
section; no new translatable strings).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
LSalami added a commit to LSalami/amule that referenced this pull request Jul 28, 2026
got3nks flagged two bugs in review (PR amule-org#663): the static cache's
early return also skipped Enable(), so the button could get stuck
disabled once IsReady()/network-pref state changed without the
Connect/Cancel/Disconnect state itself changing (master had two now-
deleted escape hatches -- the skinChanged force-path and an
unconditional EnableTool call -- that used to paper over this). Worse,
the cache was function-scope static, surviving widget recreation, so
a fresh pane's Init() call could early-return and leave the wxDesigner
default label ("Disconnect Kad") on screen.

Dropping the cache removes both: SetLabel/SetBitmap/Enable are cheap
on a plain wxButton (unlike the old toolbar tool, which had real
native-image-list reasons to memoize, see amuleDlg.cpp:1054-ish), and
master's own second call site already did an unconditional EnableTool
every tick without issue.

Verified interactively on Windows: re-tested full disconnect/reconnect
cycle on both panes, plus toggling ED2K off and back on via
Preferences (which now requires an app restart to re-enable, existing
behavior) -- on the fresh post-restart paint, both buttons show the
correct live state immediately. Also confirmed amulegui (CLIENT_GUI)
builds clean with these changes; did not perform full interactive
remote-daemon testing.

@got3nks got3nks 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.

Built and tested this on macOS (wx 3.3.3) and Ubuntu ARM64 (wxGTK 3.2), monolithic and amuleGUI, both clean. Functionally it works: the per-network buttons cycle Connect → Cancel → Disconnect correctly for eD2k and Kad independently, over EC too. Moving the control into each network's pane is the right call.

Three things to fix before merge, all cosmetic but they leave the two buttons looking different from each other and different across platforms.

1. No gap between the icon and the label. Both handlers call SetBitmap(connButImg(n)) without any spacing, so the icon touches the text on both tabs, on both platforms.

Worth flagging the trap here: the obvious fix, SetBitmapMargins(), is not portable. wxOSX overrides DoSetBitmapMargins (osx/anybutton.h:33) but wxGTK does not — it inherits the base no-op (anybutton.h:172-173, empty body). Using it would fix macOS and silently do nothing on Linux, widening the divergence this PR should be closing.

Portable alternatives: prefix the label with a space outside the _() call (wxT(" ") + _("Connect")) so no new msgid is introduced; pad the bitmap at runtime via wxImage; or drop the icons on these two buttons. The label prefix is the smallest change that behaves identically everywhere.

2. The Kad button is stretched, and its content aligns differently per platform. This isn't in the handler, it's the sizer flags in muuli_wdr.cpp:

// ED2K — natural size in a horizontal row
item5->Add(item14, wxSizerFlags().Center().Border(wxLEFT|wxRIGHT, 5));
// Kad — stretched to the full column width in a vertical sizer
item20->Add(item38, wxSizerFlags().Expand().Border(wxALL, 5));

.Expand() makes the Kad button far wider than its content, and the platforms then distribute the slack differently — GTK centres icon+label, macOS pins the icon left. Dropping .Expand() so it sizes naturally like the ED2K one removes the excess width, and with it the divergence.

One trade-off to be aware of: it currently lines up with the full-width "Bootstrap from known clients" button above it, so this swaps intra-pane consistency for cross-tab consistency. Given the two connect buttons should read as the same control, I think cross-tab is the one that matters — but it's your call.

3. Factor the two update functions into one helper. CServerWnd::UpdateED2KConnectButton() and CKadDlg::UpdateConnectButton() are near-identical — same three-state enum, same switch, same three bitmaps — differing only in where the state comes from and the Enable() condition. A shared helper taking the button, the state and the enabled flag would collapse them, and it matters more after this review: the icon-spacing fix above otherwise has to be duplicated in both.

LSalami added a commit to LSalami/amule that referenced this pull request Jul 28, 2026
got3nks flagged two bugs in review (PR amule-org#663): the static cache's
early return also skipped Enable(), so the button could get stuck
disabled once IsReady()/network-pref state changed without the
Connect/Cancel/Disconnect state itself changing (master had two now-
deleted escape hatches -- the skinChanged force-path and an
unconditional EnableTool call -- that used to paper over this). Worse,
the cache was function-scope static, surviving widget recreation, so
a fresh pane's Init() call could early-return and leave the wxDesigner
default label ("Disconnect Kad") on screen.

Dropping the cache removes both: SetLabel/SetBitmap/Enable are cheap
on a plain wxButton (unlike the old toolbar tool, which had real
native-image-list reasons to memoize, see amuleDlg.cpp:1054-ish), and
master's own second call site already did an unconditional EnableTool
every tick without issue.

Verified interactively on Windows: re-tested full disconnect/reconnect
cycle on both panes, plus toggling ED2K off and back on via
Preferences (which now requires an app restart to re-enable, existing
behavior) -- on the fresh post-restart paint, both buttons show the
correct live state immediately. Also confirmed amulegui (CLIENT_GUI)
builds clean with these changes; did not perform full interactive
remote-daemon testing.
@LSalami
LSalami force-pushed the remove-global-connect-button branch from d66888f to c1067c4 Compare July 28, 2026 18:32
got3nks flagged two bugs in review (PR amule-org#663): the static cache's
early return also skipped Enable(), so the button could get stuck
disabled once IsReady()/network-pref state changed without the
Connect/Cancel/Disconnect state itself changing (master had two now-
deleted escape hatches -- the skinChanged force-path and an
unconditional EnableTool call -- that used to paper over this). Worse,
the cache was function-scope static, surviving widget recreation, so
a fresh pane's Init() call could early-return and leave the wxDesigner
default label ("Disconnect Kad") on screen.

Dropping the cache removes both: SetLabel/SetBitmap/Enable are cheap
on a plain wxButton (unlike the old toolbar tool, which had real
native-image-list reasons to memoize, see amuleDlg.cpp:1054-ish), and
master's own second call site already did an unconditional EnableTool
every tick without issue.

Second review round (macOS + Ubuntu ARM64, monolithic + amuleGUI)
confirmed the toggle works functionally but flagged three cosmetic
issues, all fixed here:

- No gap between the connect-button icon and its label. The obvious
  fix, wxButton::SetBitmapMargins(), is NOT portable (wxOSX overrides
  it, wxGTK inherits the base no-op) -- prefixing the label with a
  literal space outside the _() call behaves identically on both and
  introduces no new msgid.
- The Kad button was stretched full-width by its sizer's .Expand()
  flag, while the ED2K one sizes naturally; GTK and macOS then filled
  the slack differently (centered vs. icon-left). Dropped .Expand()
  so the two buttons size the same way -- trades away lining up with
  the "Bootstrap from known clients" button above it, but the two
  connect buttons reading as the same control matters more.
- CServerWnd::UpdateED2KConnectButton() and CKadDlg::UpdateConnectButton()
  were near-identical (same 3-state enum, same switch, same three
  bitmaps). Factored into a shared SetConnectButtonState(button, state,
  enabled) helper in muuli_wdr.cpp/.h, next to connButImg() which it
  reuses -- so the icon-spacing fix above lives in one place instead
  of two.

Verified interactively on Windows: re-tested full disconnect/reconnect
cycle on both panes, toggling ED2K off and back on via Preferences
(existing behavior: needs an app restart to re-enable) with correct
state on the fresh post-restart paint, and confirmed by screenshot
that both buttons now show a visible icon/label gap and size the same
way (Kad no longer stretched). Also confirmed amulegui (CLIENT_GUI)
builds clean with these changes; did not perform full interactive
remote-daemon testing.
@LSalami
LSalami force-pushed the remove-global-connect-button branch from c1067c4 to 9f0e5a4 Compare July 28, 2026 19:00
@LSalami

LSalami commented Jul 28, 2026

Copy link
Copy Markdown
Author

Pushed all three fixes from the latest review:

  1. Icon/label gap: prefixed the label with a literal space outside _() (no new msgid) — SetBitmapMargins() isn't portable (no-op on wxGTK).
  2. Dropped .Expand() on the Kad button so it sizes naturally like the ED2K one — trades away alignment with "Bootstrap from known clients" above it for cross-tab consistency.
  3. Factored both update functions into a shared SetConnectButtonState() helper in muuli_wdr.cpp/.h, next to connButImg().

Verified interactively on Windows (screenshots): both buttons now show a visible icon/label gap and size the same way. Re-confirmed the full disconnect/reconnect cycle and independent ED2K/Kad toggling still work after these changes. amuleGUI still builds clean.

@got3nks

got3nks commented Jul 28, 2026

Copy link
Copy Markdown

Thanks @LSalami — testing the toggles on Linux (GTK) turned up one rendering bug plus a small layout suggestion.

immagine

ED2K button paints with the icon overlapping the label on first show (Kad renders fine). It corrects itself the instant you resize the window, so it's a first-layout ordering issue rather than styling: in the CServerWnd constructor, UpdateED2KConnectButton() runs after sizer->Show(this, TRUE), so SetBitmap() grows the button's best size after the row was already measured for the text-only label, and nothing re-lays it out until a resize. The Kad tab dodges this only because it's a notebook page that's first laid out when shown — after Init() has set its bitmap — whereas the Servers pane is visible at startup and measured once before the bitmap lands. A Layout() after the initial state is set (either right after UpdateED2KConnectButton() in the ctor, or button->GetParent()->Layout() at the end of the updater) fixes it — worth doing on both panes so Kad isn't relying on lucky timing.

Layout suggestion for the Kad tab: could we move the ID_KADDISCONNECT toggle to the top of the tab, above the "Bootstrap" static box, instead of under the bootstrap actions? Leading with the network's primary connect/disconnect control, with the manual bootstrap form beneath it, reads more naturally — and mirrors having the main control up top.

Otherwise it's looking good — builds clean here on macOS and Ubuntu ARM64.

@got3nks

got3nks commented Jul 28, 2026

Copy link
Copy Markdown

One more Servers-pane tweak while you're in there, @LSalami: could we move the "Add server manually" form (name / IP:Port / Add) down below the server list, and keep the ED2K connect/disconnect toggle up top on its own row (right-aligned)? That puts the table directly under the primary control and mirrors the Kad tab's "primary control on top, manual form below" shape.

Concretely in serverListDlgUp (muuli_wdr.cpp): the toggle and the add-form currently share one row (item5) above the table. Split them — leave the toggle in the top row (an AddStretchSpacer(1) before it keeps it right-aligned where it sits today) and re-add the name/IP/port/Add widgets in a new row after the CServerListCtrl (item15). The old vertical separator between the form and the button can go.

Two more issues from got3nks's Linux/GTK pass on amule-org#663.

1. Bug: the ED2K connect button painted with the icon overlapping the
   label on first show (Kad was fine, only by luck of timing).
   CServerWnd::UpdateED2KConnectButton() runs after sizer->Show(this,
   TRUE) in the ctor, so SetBitmap() grows the button's best size
   after the row was already measured against the text-only label,
   and nothing re-lays it out until a window resize. Fixed by calling
   Layout() on the button's parent at the end of the shared
   SetConnectButtonState() helper -- covers both panes, and stops Kad
   from relying on being laid out late (its notebook page is only
   measured once shown, after Init() already set its bitmap).

2. Layout: moved both connect/disconnect toggles to lead their pane
   instead of sitting among secondary controls, per got3nks's request:
   - ED2K (serverListDlgUp): toggle now on its own top row, right-
     aligned via a stretch spacer, directly above the server list.
     The "Add server manually" form (name/IP/port/Add) moved below
     the table instead of sharing a row with the toggle; the vertical
     separator that used to sit between them is gone (no longer
     needed once they're not adjacent).
   - Kad (KadDlg): toggle moved out of the "Bootstrap" static box
     (where it sat under "Bootstrap from known clients") to its own
     top row above the box, right-aligned the same way as ED2K's.
     item0 changed from a 1x1 FlexGridSizer (which only ever held the
     two-column area) to a plain vertical wxBoxSizer so it can hold
     the new top row plus the existing two-column layout.

Both panes now read "primary control on top, secondary/manual
controls below" -- matching shape on both tabs.

Verified interactively on Windows: screenshotted both panes, confirmed
no icon/label overlap on first paint (no window resize needed), and
re-ran the disconnect/reconnect toggle cycle on both after the layout
change.
@LSalami

LSalami commented Jul 28, 2026

Copy link
Copy Markdown
Author

Pushed both fixes from the Linux/GTK pass:

  1. First-paint layout bug: added button->GetParent()->Layout() at the end of the shared SetConnectButtonState() helper — fixes the icon/label overlap on the Servers pane's first show, and stops the Kad pane from relying on lucky notebook-page layout timing.
  2. Both toggles moved to lead their pane: ED2K's is now on its own top row (right-aligned), server list directly below, "Add server manually" moved beneath the table. Kad's moved out of the Bootstrap box to its own top row above it, same alignment.

Verified interactively on Windows: screenshotted both panes, no icon/label overlap on first paint, toggle cycle still works on both after the layout change.

@got3nks
got3nks merged commit 2c130da into amule-org:master Jul 28, 2026
13 checks passed
@LSalami
LSalami deleted the remove-global-connect-button branch July 28, 2026 20:12
got3nks added a commit that referenced this pull request Jul 28, 2026
…RL (#677)

Follow-ups to #663:

- Give the Kad tab the same full-width first row as the ED2K pane: the
  nodes-list URL refresher (update button, label, URL entry) with the
  connect/disconnect toggle right-aligned, above the stats graph and the
  Bootstrap box. Previously the toggle sat inside the 2-column grid, so a
  right-aligned toggle landed mid-pane instead of at the pane edge.

- macOS rendered the server-list and nodes-list URL entries two lines
  tall: their rows carry an icon-bearing button (taller than a one-line
  field on macOS) and the entries used Expand(), which stretched them to
  match. Switch both to CenterVertical() (still proportion 1 horizontally)
  so they stay one line.
ngosang added a commit that referenced this pull request Jul 29, 2026
…age (#685)

The Networks tab strip carried a single ConnectButton that toggled ED2K and
Kad together, while each tab had its own state-blind Connect/Disconnect
buttons. That mirrored neither the REST API (already symmetric via
POST /networks/{connect,disconnect} with {network: "ed2k"|"kad"|"both"}) nor
amulegui after #663/#677, and it meant only the global button reflected the
actual connection state.

Each network tab now owns one state-aware toggle for its own network. Colour
and label follow the real state from the SSE status_changed event — a
red/amber/green plug reading "ED2K: Connected", "Kad: Connecting…" — while the
click performs the opposite action. "connecting" counts as up, so a Kad that is
running-but-not-routing (the backend collapses that into "connecting") stays
stoppable; this matches CKadDlg::OnBnClickedDisconnectKad. There is no
confirmation dialog, matching the buttons it replaces. Disconnecting both
networks at once is no longer offered.

Kad's "Connect from known clients" button is not lost: it issued the same
EC_OP_KAD_START the toggle does, exactly as amulegui's ID_KNOWNNODECONNECT
handler is a bare StartKad() call. "Bootstrap from node" is a genuinely
different operation (EC_OP_KAD_BOOTSTRAP_FROM_IP) and is untouched, as is the
per-row connect that dials one specific server.

The page is now a single view file. servers.js, kad.js, ed2k.js and logs.js
were imported by networks.js and nothing else, so splitting them only bought a
five-request, two-wave waterfall behind the lazy route import in app.js
RouteView — the browser had to parse networks.js before it could discover the
other four. At 410 lines the merged file sits alongside preferences.js (411)
and download-detail.js (429), which are single-file multi-tab views already;
Networks was the only page split up. split-detail.js stays separate, being
shared with Downloads and Shared files.

Merging also let some duplication and dead code go:

- stat() was defined identically in kad.js and ed2k.js; one copy remains, and
  the two log panels now share a logBox() helper.
- Three data.ensureStatus() calls in the panels were no-ops. Shell already
  calls it unconditionally for every route (app.js) and it is guarded by
  statusActive, so Ed2kInfoPanel no longer needs an effect at all.
- NetworkConnectButton lives in the view rather than components.js: it is
  Networks-only, and keeping it in components.js would have shipped it
  eagerly to every page.
- app.css: the button is now a .btn, so the tool-btn-derived sizing and the
  dead .tabs-extra .conn-btn overrides are gone. The state colours and
  .tabs-extra itself stay (still used by the Downloads category filters).
- i18n: no new keys — networks_tab_ed2k/_kad and app_connect* already cover
  the label. Eight keys left with no reference are removed, and the missing
  networks_kad_conn_disabled is added; without it the Kad info panel printed
  a raw key string whenever Kad was stopped.
LSalami added a commit to LSalami/amule that referenced this pull request Jul 29, 2026
…mule-org#402)

Follow-up review feedback on amule-org#663/amule-org#677's per-tab connect/disconnect
toggle: the button/icon were too large and sat flush against the tab
strip, and since the same button occupies the same spot on both the
ED2K and Kad tabs, its label ("Disconnect") didn't say which network
it affects. Icons are now a uniform 16x16 (down from an inconsistent
32x32/16x16 mix), each row gets a top border, and the label now reads
"Connect ED2K" / "Disconnect Kad" / etc.

Also drops the global Connect/Disconnect toolbar button
(ID_BUTTONCONNECT): it lost its click handler somewhere across
amule-org#663/amule-org#677 and had been dead ever since (no EVT_TOOL binding left) --
the combined both-networks action is still reachable from the tray
icon.
LSalami added a commit to LSalami/amule that referenced this pull request Jul 29, 2026
…mule-org#402)

Follow-up review feedback on amule-org#663/amule-org#677's per-tab connect/disconnect
toggle: the button/icon were too large and sat flush against the tab
strip, and since the same button occupies the same spot on both the
ED2K and Kad tabs, its label ("Disconnect") didn't say which network
it affects. Icons are now a uniform 16x16 (down from an inconsistent
32x32/16x16 mix), each row gets a top border, and the label now reads
"Connect ED2K" / "Disconnect Kad" / etc.

Also drops the global Connect/Disconnect toolbar button
(ID_BUTTONCONNECT): it lost its click handler somewhere across
the combined both-networks action is still reachable from the tray
icon.
LSalami added a commit to LSalami/amule that referenced this pull request Jul 29, 2026
…mule-org#402)

Follow-up review feedback on amule-org#663/amule-org#677's per-tab connect/disconnect
toggle: the button/icon were too large and sat flush against the tab
strip, and since the same button occupies the same spot on both the
ED2K and Kad tabs, its label ("Disconnect") didn't say which network
it affects. Icons are now a uniform 16x16 (down from an inconsistent
32x32/16x16 mix), each row gets a top border, and the label now reads
"Connect ED2K" / "Disconnect Kad" / etc.

Also drops the global Connect/Disconnect toolbar button
(ID_BUTTONCONNECT): it lost its click handler somewhere across
the combined both-networks action is still reachable from the tray
icon.
got3nks pushed a commit that referenced this pull request Jul 29, 2026
Shrinks the per-tab connect button and names its network (Connect/Disconnect/Cancel ED2K|Kad), adds top padding to both network tabs' first row, and scales the button icon to a uniform DPI-aware size with a per-(state, size) cache.

Bitmap margins are wxOSX-only: wxMSW keeps its native font-derived default, wxGTK keeps the leading-space fallback since it has no margin support.

Kad tab redesigned to mirror the ED2K tab: the graph spans the full width with the bootstrap-from-node row beneath it, and the four-octet IP entry collapses to a single trimmed x.x.x.x field.

Drops two redundant controls: the inert global Connect toolbar button (no event binding since #663/#677) and the "Bootstrap from known clients" button, which called the same StartKad() as the Kad tab's own Connect toggle.
got3nks pushed a commit that referenced this pull request Jul 31, 2026
This is a deliberate UI change, not a behaviour-preserving refactor --
worth being explicit about per review discussion on #675. None of the
74 sites touched here have ever rendered their border: the legacy
`Add(window, proportion, flag, border)` form only applies `border`
when `flag` carries a direction bit (wxALL/wxLEFT/wxRIGHT/wxTOP/
wxBOTTOM), and all 74 omitted it. Converting to wxSizerFlags() and
supplying a real direction bit means these borders render for the
first time, which will reflow the affected dialogs to some degree.

Per #663 (the case that originally surfaced this pattern): the
recorded border values were never validated by anything, since they
never rendered. Each site was judged against its structural siblings
rather than ported verbatim -- where siblings already carried a
working border, matched to it; where a site was the outlier in an
otherwise-consistent row/grid, adjusted to match rather than
introducing a new, never-tested value. A few sites lost their border
entirely where every sibling in the same row already had none (the
stray value read as leftover noise, not an intended margin).

Three additional non-legacy-syntax inconsistencies folded into the
same pass (found while scoping #675, confirmed still present):
- PreferencesRemoteControlsTab: "Low rights password" carried
  Border(wxLEFT|wxRIGHT, 20) while every other same-column label in
  the grid ("Web template", "Full rights password") uses
  Border(wxRIGHT, 5) -- the 20px left indent looked like it was
  copy-pasted from the unrelated UPnP-port row's indent, not a
  deliberate choice for this row.
- PreferencesOnlineSigTab: the "Save online signature file in" path
  field had no Expand()/proportion despite sitting in a column its
  parent FlexGridSizer marks growable -- it couldn't actually grow to
  fill the space reserved for it.
- PreferencesGeneralTab: the "Browser Selection" row (text field +
  Browse button) still used the legacy 3-arg Add() form while the
  structurally identical "Video Player" row already used
  wxSizerFlags() -- modernized for consistency, no behaviour change
  (both used border 0).

Scope: src/muuli_wdr.cpp only, matching where #663/#473 originally
established (and didn't fully carry through) the wxSizerFlags()
convention.

Testing: full build verified (macOS). Visually walked every dialog
these 20 functions produce that's reachable without live server/
download/client data in a fresh test config: main status bar,
search, transfer panes, shared-files header, servers/Kad tabs,
Friends/Messages panels, and all 15 Preferences tabs -- no clipped or
overlapping controls, and the two directly-testable fixes (the
OnlineSig path field now expanding, the RemoteControls password grid
column now aligned) confirmed visually.

NOT independently verified: fileDetails, clientDetails, commentLstDlg,
and CategoriesEditWindow all require live downloads/shared files/
clients/categories to reach via the UI, which a from-scratch test
config doesn't have -- these got the same siblings-based border
review as everything else, but I have not seen them rendered.
Sizer-border rendering is exactly where wxGTK/wxMSW/wxOSX diverge, so
this needs eyes on Linux and Windows too, per the #675 review
discussion.
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.

[GUI] Remove the global Connect/Disconnect button from the amulegui toolbar and move it into the Networks view

2 participants