linuxmint / linuxmint/nemo

Replace hardcoded 500ms loading-spinner timeout with a named constant

Open Beginner friendly
#3,824 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.6k
Forks
368
Avg merge
4d 4h
Merged PRs (30d)
2

Description

Summary

The "Loading…"/"Searching…" spinner that sometimes appears in Nemo's floating bar is gated by a hardcoded 500 ms delay, and the spinner's size/margins are also hardcoded magic numbers. This is exactly why the indicator only sometimes appears: if a folder finishes loading within 500 ms the timer is cancelled and the spinner is never shown; only slower loads make it appear.

Where the hardcoding is

src/nemo-window-manage-views.c, function setup_loading_floating_bar():

slot->loading_timeout_id =
    g_timeout_add (500, setup_loading_floating_bar_timeout_cb, slot);

The timeout is later cancelled in remove_loading_floating_bar() (called from end_location_change() on nemo_window_report_load_complete()), so the spinner only appears when loading takes longer than this value. The literal 500 is the debounce that decides whether the indicator shows at all.

In src/nemo-floating-bar.c, the spinner geometry is also hardcoded:

gtk_widget_set_size_request (w, 16, 16);      /* line 232 — 16x16 px */
gtk_widget_set_margin_left (w, 8);            /* line 233 — 8 px */
"spacing", 8,                                 /* line 337 — 8 px */

Why it matters

The rest of the codebase consistently names such delays as #define constants, e.g. LOADING_TO_EMPTY_DELAY 100 (nemo-list-model.c), DRAG_EXPAND_CATEGORY_DELAY 500 (nemo-places-sidebar.c), UPDATE_INTERVAL_TIMEOUT_INTERVAL 500 (nemo-view.c), SCROLL_TIMEOUT 150 / INITIAL_SCROLL_TIMEOUT 300 (nemo-pathbar.c), and CHOWN_CHGRP_TIMEOUT 300 /* milliseconds */ (nemo-properties-window.c). The bare 500 / 16 / 8 literals are inconsistent with this convention, making the loading-indicator behavior harder to locate, tune and unit-test.

Suggested fix

Introduce a named constant, e.g. #define LOADING_FLOATING_BAR_TIMEOUT 500 /* milliseconds */ in src/nemo-window-manage-views.c, and use it in the g_timeout_add call. Likewise expose the spinner size/margins as named constants or via CSS. No behavior change is required — just naming the existing magic numbers so the "sometimes appears" debounce is explicit and consistent.

Environment

  • Nemo source: 6.0.2 (linuxmint/nemo)
  • Files: src/nemo-window-manage-views.c (line 1269), src/nemo-floating-bar.c (lines 232, 233, 337)

This is a code-quality/hardcoding issue; runtime behavior is otherwise correct.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/nemo-window-manage-views.c at setup_loading_floating_bar() and its timeout cancellation path, then inspect the spinner literals in src/nemo-floating-bar.c. Name the existing timeout and geometry values consistently with the project conventions, preserving behavior; done means the specified magic numbers are no longer bare literals.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
desktop
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
86/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.