Commit Graph

2320 Commits

Author SHA1 Message Date
607faa80ca Fixed the GTK3 dropdown regression by switching from combo-box ID/path behavior to an explicit internal index→full-path mapping (gtk3_theme_paths) while keeping user-facing theme names in the dropdown text. This preserves internal full path mapping without relying on active-id lookups.
Kept GTK3 discovery restricted to the app-local install directory (get_xdir()/gtk3-themes) and only included directories containing gtk-3.0/gtk.css.

Ensured theme selection is restored/saved correctly by matching saved pref name against discovered entries and applying via the selected internal path, then persisting prefs.hex_gui_gtk3_theme_name with save_config().

Preserved/updated empty-invalid status behavior to show “No valid GTK3 themes found.” when no usable themes exist (or saved selection is invalid).

Added proper cleanup for the new internal mapping via setup_theme_ui_free and wired it into g_object_set_data_full.
2026-02-26 00:56:17 -07:00
1c1110847c Fixed the GTK3 theme dropdown population to include all expected sources again (ZoiteChat local store, user local themes, and system theme dirs), which resolves the “messed up selector” behavior from the previous change.
Restored proper initial selection logic so the dropdown now prefers saved gui_gtk3_theme_name when present, and otherwise falls back to the current GTK gtk-theme-name.

    Fixed selection UX by not forcing index 0; it starts unselected and selects only if a real match is found. Also made Apply button sensitivity follow actual selection state.

    Updated the status text to reflect mixed-source theme discovery and added cleanup for allocated selection strings/path entries in this code path.
2026-02-26 00:47:04 -07:00
a796f78884 Fixed the GTK3 theme import crash by replacing the dark-variant notification call from the signal macro path to fe_message(..., FE_MSG_INFO), avoiding the segfaulting path during import completion while preserving user feedback. 2026-02-26 00:35:42 -07:00
4354aaa57a Added a new backend API, zoitechat_import_gtk3_theme_archive(const char *archive_path, GError **error), and exposed it in the common header so GTK setup code can call a shared import path instead of inlining extraction logic.
Updated the GTK3 import callback in setup.c to:

    open a file chooser titled Import GTK3 Theme ZIP,

    enforce a ZIP-focused chooser filter (*.zip, *.ZIP),

    call the new backend function,

    show success/failure dialogs through setup_theme_show_message,

    refresh the GTK3 theme list immediately after successful import.

Updated the GTK3 section button label to Import GTK3 Theme ZIP and added/used new translatable strings for the new button text and import messages.
2026-02-26 00:16:05 -07:00
4aeb5b5697 Split the theme setup page into two explicit framed sections: “ZoiteChat Theme” (legacy colors.conf / pevents.conf flow) and “GTK3 Theme” (GTK theme import/select/apply flow), with distinct button labels like “Apply ZoiteChat Theme” and “Apply GTK3 Theme.”
Expanded setup_theme_ui to track separate widget state for ZoiteChat controls and GTK3 controls (zoitechat_* and gtk3_* fields), so the two flows are no longer sharing ambiguous UI pointers.

    Kept the existing ZoiteChat apply path using zoitechat_apply_theme, but updated selection/status/apply messaging so it clearly indicates palette/event updates rather than GTK theme activation.

    Added GTK3 theme management behavior:

        discovery/population from standard theme directories,

        import from archive via file chooser into ~/.themes/<basename>,

        apply via GtkSettings (gtk-theme-name),

        status/info messages that explicitly say GTK3 activation does not change ZoiteChat palette settings.
2026-02-26 00:11:05 -07:00
30609ba6db Updated Win32 theme CSS generation in fe_apply_windows_theme to build .zoitechat-dark and .zoitechat-light styles dynamically from palette values (COL_FG/COL_BG) instead of fixed hex literals, via a new helper that serializes PaletteColor with gdk_rgba_to_string.
Kept native titlebar dark-mode behavior intact by leaving the existing Win32 titlebar flow untouched and continuing to call theme preference updates in fe_apply_windows_theme.
Ensured theme/palette apply paths refresh CSS by routing both FE_GUI_APPLY and setup theme apply through fe_apply_theme_for_mode(...), which re-runs Win32 CSS application and re-applies classes to toplevel windows.
2026-02-25 23:53:31 -07:00
6b8e41b4c6 Updated mg_create_tabmenu to remove the hardcoded inline foreground="#3344cc" color from the top menu title and keep only bold emphasis (<b>…</b>), so GTK theme colors are used naturally. 2026-02-25 23:47:42 -07:00
0edab77fac Removed the local menu_icon_exists_in_resource probe from menu.c, so this file no longer carries a hardcoded /icons/menu/light resource check path. menu_icon_widget_new now calls gtkutil_menu_icon_exists for the zc-menu-* candidate check. This keeps the same fallback flow for custom icons: direct readable path first, then config-dir path, then stock/themed lookup.
Added gtkutil_menu_icon_exists to gtkutil.c and declared it in gtkutil.h. The implementation uses a shared helper that resolves menu icon resources with theme-variant-aware lookup (variant first, then light fallback) for both png and svg, so probing behavior now lives in the same subsystem as gtkutil_image_new_from_stock.
2026-02-25 23:40:38 -07:00
c8ae4f3b18 Removed the unused gtkutil_menu_icon_pixbuf_new helper from src/fe-gtk/gtkutil.c (it no longer appears between the surrounding menu icon helper and stock-icon mapping functions).
Kept gtkutil_menu_icon_image_new as the single menu-icon loading path, which already contains the requested theme variant selection and light-variant fallback behavior for both PNG and SVG assets.
2026-02-25 23:36:01 -07:00
578a417804 Added theming to menu_about() immediately after gtk_about_dialog_new() by calling fe_apply_theme_to_toplevel (GTK_WIDGET (dialog));, with the requested short CSS-selector comment style.
Added theming to setup_browsefont_cb() immediately after gtk_font_chooser_dialog_new(...) by calling fe_apply_theme_to_toplevel (dialog);, plus the same short comment for consistency/discoverability.
Added theming to setup_color_cb() immediately after gtk_color_chooser_dialog_new(...) by calling fe_apply_theme_to_toplevel (dialog);, again with the matching comment.
2026-02-25 23:30:35 -07:00
440e9ecf5a Updated fe_ctrl_gui()’s FE_GUI_APPLY branch to match the Preferences → Theme apply sequence by loading palette data first, then re-applying current dark-mode state, and only then calling setup_apply_real(TRUE, TRUE, TRUE, FALSE);.
Added an inline regression-prevention comment noting this path should stay in parity with setup_theme_apply_cb.

    Verified palette.h is already included in src/fe-gtk/fe-gtk.c (no include changes required).
2026-02-25 23:27:21 -07:00
ac2ab1443c Added fe_apply_theme_to_toplevel() for:
Standard GTK file chooser fallback dialog in src/fe-gtk/gtkutil.c

        Font chooser dialog in src/fe-gtk/setup.c

        Color chooser dialog in src/fe-gtk/setup.c

        About dialog in src/fe-gtk/menu.c
2026-02-25 23:18:19 -07:00
ce5128e4fb Added a theme_name null guard in the Adwaita/Yaru workaround condition inside create_input_style() so g_str_has_prefix() is only called when theme_name is non-null, while preserving existing behavior for non-null theme names.
Left allocation/free flow unchanged; theme_name is still freed exactly once at the existing cleanup point after the reload block.
2026-02-25 22:52:40 -07:00
c37faa1492 Refactored the Preferences color-page edit-source model to use an explicit snapshot pointer (setup_color_edit_source_colors) and a helper that selects light vs dark snapshot palettes, so the page preview is decoupled from the runtime colors[] palette. This affects selector refresh, page initialization, and cleanup lifecycle.
Updated edit-target and dark-mode combo callbacks on the color page to stop applying global palette mode directly; they now only switch/refresh the Preferences page source palette.
Changed color-chooser behavior so setup_color_response_cb() writes edits to the selected target snapshot via palette_user_set_color / palette_dark_set_color, then refreshes only page widgets (no runtime palette apply). Also updated dialog initialization to read from the current edit-source snapshot.
Added palette snapshot accessors (palette_user_colors, palette_dark_colors) in the palette API and implementation so Preferences can render from light/dark snapshots safely without mutating runtime palette state.
Runtime palette changes remain on the real apply paths (theme/dark-mode application), not edit-target toggles.
2026-02-25 22:48:55 -07:00
685989fa25 Updated fe_system_prefers_dark() to remove the old !has_theme_name gate and always read gtk-application-prefer-dark-theme whenever that property exists. Theme-name matching is still kept as an additional signal.
Added deterministic dark-mode precedence by combining explicit signals (theme_name_prefers_dark || property_prefers_dark), while preserving Windows system preference as another dark-enabling signal when available. This ensures “dark if any explicit dark signal is true.”
Re-checked the relevant callers (fe_auto_dark_mode_changed() and fe_apply_theme_for_mode()): they consume fe_system_prefers_dark() output and do not depend on the removed !has_theme_name conditional behavior.
2026-02-25 22:42:43 -07:00
cbc474477b Updated gtkutil_menu_icon_theme_variant() to select the menu icon theme variant from the app’s effective dark-mode state first (fe_dark_mode_state_is_initialized() + fe_dark_mode_is_enabled()), and only use GTK/theme-name heuristics as fallback before app state is initialized. This preserves the existing light-asset fallback behavior in menu icon loading logic.
Added a new frontend helper declaration fe_dark_mode_state_is_initialized() in the GTK frontend header so callers can check whether dark-mode state is ready.
Implemented dark-mode initialization tracking in fe-gtk.c via a new static flag, set when auto mode state is externally set and during fe_init(), and exposed it through fe_dark_mode_state_is_initialized().
2026-02-25 22:31:52 -07:00
51f8795d1a Updated create_input_style() so input selection CSS now prefers palette-derived COL_MARK_FG / COL_MARK_BG colors directly (as #RRGGBB from sel_* values), instead of defaulting to @theme_selected_*.
Added a guarded fallback path that only uses theme lookup/string conversion when palette selection components are invalid (isfinite checks fail), with palette values as secondary fallback there too. This keeps theme colors out of the primary path while preserving robustness for malformed data.
Kept needs_reload dependent on last_sel_* tracking, so changing selection colors in Preferences still triggers immediate CSS regeneration (including across light/dark mode).
2026-02-25 22:25:35 -07:00
faacd95dfc Added setup-local state for palette editing target (setup_color_edit_dark_palette) plus Light/Dark option strings, so palette editing is no longer coupled to runtime AUTO dark-mode detection. This keeps the choice in Preferences state only.
Added a new Editing: combo control near the dark-mode selector in setup_create_color_page, with a callback that switches between Light/Dark palette targets and refreshes swatches immediately using the same refresh path as dark-mode UI updates.
    Updated the dark-mode combo callback to refresh color swatches based on the explicit editing target (not runtime dark-mode detection), preserving existing runtime theme behavior while editing persisted overrides.
    Updated setup_color_response_cb to write color changes to palette_dark_set_color vs palette_user_set_color based on the new edit-target state.
    Initialized the editing target in setup_create_color_page from explicit Dark mode selection only (hex_gui_dark_mode == ZOITECHAT_DARK_MODE_DARK), avoiding AUTO runtime detection for editing context.
2026-02-25 21:28:08 -07:00
ed02b21228 Extended setup_dark_mode_menu_cb so after setup_menu_cb it now computes the selected dark-mode state via fe_dark_mode_is_enabled_for(setup_prefs.hex_gui_dark_mode), swaps the in-memory editor palette with palette_apply_dark_mode(...), and immediately refreshes color swatches. This keeps the editor model synchronized with the dark-mode combo selection.
Added setup_refresh_color_selector_widgets() to iterate color_selector_widgets, resolve each button’s stored color index, and re-run setup_color_button_apply against colors[] so all selectors repaint to the active palette.
    Updated setup_create_color_button to register each widget’s palette index (zoitechat-color-index), enabling correct per-button repaint during mode switches.
    Preserved existing persistence behavior in setup_color_response_cb (palette_dark_set_color vs palette_user_set_color) so changes remain non-destructive until existing OK/Save flow persists them.
2026-02-25 21:22:56 -07:00
d321717da8 Hardened create_input_style() so selection-color CSS no longer hard-depends on @theme_selected_*: it now first tries symbolic theme colors via gtk_style_context_lookup_color(), and only falls back when unavailable.
Added a fallback path that derives selection colors from palette values (COL_MARK_FG/COL_MARK_BG) and then samples selected-state colors from a GTK style context when possible, emitting explicit color strings for CSS.
Ensured fallback regeneration is tied to the same reload flow by extending needs_reload tracking with selection palette channels and persisting those last-seen values.
Kept Preferences > Colors foreground/background behavior intact for normal input rendering; only selection-specific CSS is conditionally overridden. Base text/background/caret rules remain unchanged while only text selection uses the new selection logic.
2026-02-25 20:59:07 -07:00
6310ab245c Updated fe_apply_theme_for_mode() to immediately reapply fe_apply_theme_to_toplevel() across all currently-open GTK toplevel windows (gtk_window_list_toplevels()), so mode switches update existing windows without reopening them.
Added/kept lifecycle call sites for main and detached/channel windows, with comments explaining that .zoitechat-dark / .zoitechat-light classes are required for GTK CSS selectors. This includes top/tab windows and server list/edit windows.
Wired dialog/toplevel creation paths in src/fe-gtk/ to call fe_apply_theme_to_toplevel() (without duplicating platform logic), including common prompt/message dialogs and feature-specific dialogs (join, notify, setup, ignore/ban, etc.), each with the requested brief comment near the new call site.
2026-02-25 20:39:48 -07:00
5952006662 Refactored fe_system_prefers_dark() to always allow gtk-application-prefer-dark-theme to be read as a fallback (when no explicit theme name is set), removing the previous suppression tied to app-written state. This preserves priority for explicit dark theme names and platform-native preference checks before the GTK property fallback.
Added a short in-code comment explaining why app-written GTK property state must not permanently block future reads in AUTO mode.
Removed the now-unneeded app_set_prefer_dark tracking behavior from fe_set_gtk_prefer_dark_theme(), so writes no longer disable later fallback reads.
Confirmed fe_auto_dark_mode_changed() still prevents reapply loops by early-returning when enabled == auto_dark_mode_enabled before calling theme/apply logic.
2026-02-25 20:32:44 -07:00
e4cb453915 Added a centralized theme-class application in gtkutil_window_new() so any toplevel created through this helper gets fe_apply_theme_to_toplevel() during construction. This covers most non-session windows consistently at creation time.
Updated Preferences window creation to explicitly apply the toplevel theme after gtk_widget_show_all() in setup_window_open(), matching your requested timing there.
Added explicit theme application for non-session windows that bypass gtkutil_window_new() and use direct gtk_window_new() in server list UI (editserv and servlist).
Extended mg_apply_setup() to iterate all current GTK toplevels (gtk_window_list_toplevels()) and reapply fe_apply_theme_to_toplevel() during setup/theme reapply flows, ensuring existing windows stay consistent after theme changes. Palette override widgets were not touched.
2026-02-25 20:27:15 -07:00
361e35de7f Updated chanview_apply_theme() in src/fe-gtk/chanview.c to apply the palette colors unconditionally (for tree view chanview), instead of branching on raw dark-mode enum checks. This keys behavior off the already-resolved palette output, which matches how setup_apply_to_sess() / palette_apply_dark_mode() flows are intended to work.
Preserved font handling exactly as before (input_style->font_desc when available).
Added inline rationale comment clarifying that AUTO/light should continue using palette-managed colors and should not revert to GTK theme defaults in a way that clears custom colors.
2026-02-25 20:23:01 -07:00
bbde2e5578 Added a new internal state flag, app_set_prefer_dark, and now set it whenever fe_set_gtk_prefer_dark_theme() writes gtk-application-prefer-dark-theme, so AUTO detection can distinguish app-authored writes from system/user signals.
Reworked fe_system_prefers_dark() to prioritize non-app-written sources in AUTO flow:

        first: gtk-theme-name dark-variant heuristic,

        then (Windows): native platform detection via fe_win32_try_get_system_dark,

        only then fallback to gtk-application-prefer-dark-theme when no theme-name signal was available and the app has not written that property.

    Kept manual LIGHT/DARK behavior unchanged by preserving the existing mode application path (fe_apply_theme_for_mode() still drives fe_set_gtk_prefer_dark_theme() directly).

    Verified fe_auto_dark_mode_changed() and fe_init() signal wiring still trigger AUTO palette/theme refreshes on system theme changes (notify::gtk-theme-name and existing notify callback flow remain in place).
2026-02-25 20:03:20 -07:00
97c6f36b20 Adjusted create_input_style so it no longer globally forces color on #zoitechat-inputbox, reducing over-constraining while still applying the user-selected background and caret color where intended. This keeps non-text-node state rendering more theme-driven.
Kept user override support for baseline text color and caret color on the input’s text node (#zoitechat-inputbox text).
Added targeted state-aware text rules for :focus and :backdrop (to preserve readability when theme state styling changes), plus a softened :disabled text rule instead of broad global color forcing.
Added explicit selection-node handling (#zoitechat-inputbox text selection) using theme selection tokens so selected text remains readable and aligned with Adwaita/Yaru-style theme behavior.
Preserved the existing Adwaita/Yaru background-image workaround logic, so fallback behavior remains compatible with those themes.
2026-02-25 19:43:19 -07:00
deepend-tildeclub
2bf32fc770 Merge pull request #90 from ZoiteChat/code-cleanup
Code cleanup
2026-02-25 18:16:54 -07:00
3e095c3c33 Removed two redundant inline comments in the file dialog response/done handlers, leaving the behavior unchanged and the control flow cleaner.
Removed an old commented-out helper function block (gtkutil_treeview_get_selected_iter) that was dead/commented code.
2026-02-25 18:07:26 -07:00
3445d946bc Removed a redundant inline comment in icon loading/scaling logic, leaving behavior unchanged.
Removed a redundant inline comment in the Windows sysinfo volume-name guard path, with no functional impact.
Removed a redundant inline comment in WinRT toast setup while keeping the same notification/audio attribute behavior.
2026-02-25 18:05:21 -07:00
7578928199 Cleaned up redundant/outdated inline comments in the text frontend argument/config and GUI control paths while leaving behavior unchanged (comment-only cleanup). 2026-02-25 16:22:46 -07:00
e3f932aa6b Updated the Win32 window-state handling to include shellapi.h and query taskbar auto-hide/taskbar edge state via SHAppBarMessage, so maximized windows can leave a 1px reveal edge for the auto-hidden taskbar.
Added monitor-aware work-area adjustment when maximized (MonitorFromWindow + GetMonitorInfo) and shrink by 1px on the detected taskbar edge (including bottom edge), then apply that rectangle with SetWindowPos. This addresses the “mouse at bottom edge should unhide taskbar” behavior.
Kept the existing HWND_NOTOPMOST safeguard in place after the adjustment, preserving prior not-topmost behavior.
2026-02-25 14:48:18 -07:00
7cfa3b3513 Added a Windows-only helper (mg_win32_allow_autohide_taskbar) that gets the native HWND and calls SetWindowPos(..., HWND_NOTOPMOST, ...) for non-fullscreen window-state transitions, so a maximized ZoiteChat window no longer blocks the taskbar auto-hide reveal edge.
Hooked that helper into mg_windowstate_cb so it runs whenever the main window state changes (while preserving existing maximize/fullscreen preference handling).
2026-02-25 14:18:23 -07:00
81c691491c Removed three redundant inline comments in joind_ok_cb that duplicated obvious control flow, leaving behavior unchanged and improving readability. 2026-02-25 13:55:44 -07:00
c361602b1a Removed four unneeded section comments in src/common/notify.h (WATCH/MONITOR/general/old ISON labels), leaving only the function declarations for a cleaner header interface. 2026-02-25 13:51:22 -07:00
3cff6742f5 Removed unneeded inline comments around the Win32 error-formatting fallback in errorstring() and simplified matching block-closing lines, without changing behavior. 2026-02-25 02:37:08 -07:00
6a02f578b6 Removed obsolete commented-out lines from fe_cleanup() so the function no longer contains dead commented code.
Removed an unnecessary explanatory comment above the unconditional early return in log_handler(), leaving only the active behavior.

Removed an unneeded section marker comment before fe_idle() to keep surrounding code cleaner.
2026-02-25 02:34:50 -07:00
e62769b361 Cleaned up unneeded comments in DCC receive/connect code by removing:
a stale commented-out ACK block in the DCC receive error path,

    an unnecessary speculative note before the quoted filename handling,

    and an editorial inline comment on a static variable declaration.
2026-02-25 02:30:46 -07:00
9df9776238 Removed a stale multi-line # TODO note block from the common Meson build file to clean up unneeded comments without changing build logic.
Removed an old commented-out /* FIXME ... */ prototype block from servlist.h, leaving only active declarations.
2026-02-25 02:28:10 -07:00
4beabb6bf5 Removed a stale commented-out debug function block from the fishlim plugin source to reduce dead/commented code.
Removed the corresponding commented-out RAW LINE hook entry so only active handlers remain in plugin initialization.
2026-02-25 02:24:11 -07:00
fd48c97209 Removed four redundant inline comments in src/fe-gtk/urlgrab.c to clean up readability without changing behavior (treeview enum declaration area, right-click selection block, headers visibility call, and URL list overflow trimming block). 2026-02-25 02:09:35 -07:00
e58bf2be22 Cleaned up redundant comments in dcc_listen_init by removing obvious/explanatory noise and an obsolete commented-out debug printf, while leaving logic unchanged. 2026-02-25 02:07:38 -07:00
dc6453e230 Removed redundant inline comments in lastact_update and lastact_getfirst where the code was already self-explanatory, without changing behavior.
Simplified away_check by removing comment clutter and keeping only the logic flow, including the WHO batching behavior.
Removed unneeded commentary around lag-check helpers and timer reinitialization to keep the core timer code cleaner and easier to scan.
2026-02-25 02:04:31 -07:00
b3a0288fd9 Cleaned up stale inline comments in the tab scrolling handlers by removing outdated explanatory text while keeping behavior unchanged (tab_left_is_moving / tab_right_is_moving reset paths).
Removed an old commented-out gtk_container_set_border_width(...) line that was dead/commented code in cv_tabs_init.
Simplified the tab-switch condition by removing a legacy commented expression from if (is_switching).
2026-02-25 02:01:11 -07:00
1bf0140652 Cleaned up redundant inline comments in the SCRAM implementation so the file is less noisy while preserving behavior exactly as-is (no logic changes). 2026-02-25 01:54:34 -07:00
bb72f8afab Removed redundant inline comments from the common header includes/platform guards in src/common/zoitechat.h (e.g., comments like “need time_t”, “for win32”, “for unix”), while preserving meaningful explanatory comments. 2026-02-25 01:50:00 -07:00
bb11c4676b Cleaned up src/fe-gtk/meson.build by removing an outdated commented-out WinRT build block in the Windows section, leaving only active build logic.
Removed an inline TODO comment from the gnome.compile_resources call to keep the Meson configuration concise and focused on current settings.
2026-02-25 01:47:32 -07:00
32fe3e54f1 Removed redundant section-divider comments in the Windows spellcheck provider to reduce clutter without changing behavior.
Removed non-essential inline comments that restated obvious return values and assignment intent (return -1/1/0, add_to_exclude alias), keeping logic identical.
2026-02-25 01:45:20 -07:00
9d2187ca4d Cleaned up unneeded inline comments in src/fe-text/fe-text.c where control-character switch cases were already self-explanatory, while keeping behavior unchanged.
Removed a redundant comment from the done global flag declaration for a cleaner declaration section.
2026-02-25 01:43:01 -07:00
ef2befa698 Cleaned up redundant comments in src/fe-gtk/fkeys.c by removing section-divider noise and a stale XXX line near key-action helpers, while keeping useful function-level documentation.
Removed repetitive inline comments from return 2; statements in tab-move/history key actions, since behavior is already clear from the surrounding code.
Removed an unnecessary separator comment before replace_handle() for a cleaner transition between functions.
2026-02-25 01:35:30 -07:00
5f9ce549f8 Removed redundant inline comments in the timer plugin that did not add useful context (plugin handle declaration and return value comment), keeping behavior unchanged.
Removed an obsolete visual alignment guide comment above the timer list header print call to clean up the function body.
2026-02-25 01:32:27 -07:00