From 0aa6c26490f34d15689b93e14f64026bfed5c0c1 Mon Sep 17 00:00:00 2001 From: Mike Buchholz Date: Mon, 9 Mar 2026 14:21:20 -0600 Subject: [PATCH] fix: quiet GTK/GLib warn spam; fix include order; normalize imported CSS --- src/common/dcc.h | 2 + src/common/gtk3-theme-service.c | 76 ++++++++++++++++--- src/common/gtk3-theme-service.h | 2 +- src/common/sts.c | 4 +- src/common/tests/test-gtk3-theme-service.c | 6 +- src/common/theme-service.c | 3 +- src/common/theme-service.h | 2 +- src/fe-gtk/maingui.c | 3 +- src/fe-gtk/menu.c | 10 --- src/fe-gtk/plugin-tray.c | 9 +++ src/fe-gtk/setup.c | 4 +- .../theme/tests/test-theme-access-routing.c | 3 +- .../test-theme-application-input-style.c | 2 +- .../theme/tests/test-theme-gtk3-settings.c | 5 +- .../tests/test-theme-manager-auto-refresh.c | 3 +- .../test-theme-manager-dispatch-routing.c | 4 +- .../theme/tests/test-theme-manager-policy.c | 3 +- .../test-theme-preferences-gtk3-populate.c | 3 +- .../tests/test-theme-runtime-persistence.c | 5 +- src/fe-gtk/theme/theme-access.c | 2 + src/fe-gtk/theme/theme-application.h | 1 - src/fe-gtk/theme/theme-gtk3.c | 5 +- src/fe-gtk/theme/theme-policy.c | 2 - src/fe-gtk/theme/theme-policy.h | 2 +- src/fe-gtk/theme/theme-preferences.c | 5 +- src/fe-gtk/theme/theme-preferences.h | 5 +- src/fe-gtk/xtext.c | 12 ++- 27 files changed, 126 insertions(+), 57 deletions(-) diff --git a/src/common/dcc.h b/src/common/dcc.h index 8c0ded6a..c28f04d3 100644 --- a/src/common/dcc.h +++ b/src/common/dcc.h @@ -59,7 +59,9 @@ struct DCC int resume_error; int resume_errno; + G_GNUC_BEGIN_IGNORE_DEPRECATIONS GTimeVal lastcpstv, firstcpstv; + G_GNUC_END_IGNORE_DEPRECATIONS goffset lastcpspos; gint64 maxcps; diff --git a/src/common/gtk3-theme-service.c b/src/common/gtk3-theme-service.c index d15824e3..4f48723c 100644 --- a/src/common/gtk3-theme-service.c +++ b/src/common/gtk3-theme-service.c @@ -739,6 +739,51 @@ select_theme_root (GPtrArray *roots, const char *input_root) return selected; } +static gboolean +copy_css_file (const char *src, const char *dest, GError **error) +{ + char *contents = NULL; + char *normalized; + gsize len = 0; + GRegex *regex; + + if (!g_file_get_contents (src, &contents, &len, error)) + return FALSE; + + if (!g_strstr_len (contents, len, ":insensitive")) + { + gboolean ok = g_file_set_contents (dest, contents, len, error); + g_free (contents); + return ok; + } + + regex = g_regex_new (":insensitive", 0, 0, error); + if (!regex) + { + g_free (contents); + return FALSE; + } + + normalized = g_regex_replace_literal (regex, contents, -1, 0, ":disabled", 0, error); + g_regex_unref (regex); + if (!normalized) + { + g_free (contents); + return FALSE; + } + + if (!g_file_set_contents (dest, normalized, -1, error)) + { + g_free (normalized); + g_free (contents); + return FALSE; + } + + g_free (normalized); + g_free (contents); + return TRUE; +} + static gboolean copy_tree (const char *src, const char *dest, GError **error) { @@ -768,19 +813,32 @@ copy_tree (const char *src, const char *dest, GError **error) } else { - GFile *sf = g_file_new_for_path (s); - GFile *df = g_file_new_for_path (d); - if (!g_file_copy (sf, df, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, error)) + if (g_str_has_suffix (name, ".css")) { + if (!copy_css_file (s, d, error)) + { + g_free (s); + g_free (d); + g_dir_close (dir); + return FALSE; + } + } + else + { + GFile *sf = g_file_new_for_path (s); + GFile *df = g_file_new_for_path (d); + if (!g_file_copy (sf, df, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, error)) + { + g_object_unref (sf); + g_object_unref (df); + g_free (s); + g_free (d); + g_dir_close (dir); + return FALSE; + } g_object_unref (sf); g_object_unref (df); - g_free (s); - g_free (d); - g_dir_close (dir); - return FALSE; } - g_object_unref (sf); - g_object_unref (df); } g_free (s); g_free (d); diff --git a/src/common/gtk3-theme-service.h b/src/common/gtk3-theme-service.h index 82b0172f..bbf98b0b 100644 --- a/src/common/gtk3-theme-service.h +++ b/src/common/gtk3-theme-service.h @@ -1,7 +1,7 @@ #ifndef ZOITECHAT_GTK3_THEME_SERVICE_H #define ZOITECHAT_GTK3_THEME_SERVICE_H -#include +#include "zoitechat.h" typedef enum { diff --git a/src/common/sts.c b/src/common/sts.c index eef2a71b..4047f229 100644 --- a/src/common/sts.c +++ b/src/common/sts.c @@ -16,7 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include "zoitechat.h" + #include #include @@ -26,7 +27,6 @@ #include #endif -#include "zoitechat.h" #include "cfgfiles.h" #include "util.h" #include "text.h" diff --git a/src/common/tests/test-gtk3-theme-service.c b/src/common/tests/test-gtk3-theme-service.c index ac332a55..9a414375 100644 --- a/src/common/tests/test-gtk3-theme-service.c +++ b/src/common/tests/test-gtk3-theme-service.c @@ -1,9 +1,9 @@ -#include -#include - +#include "../zoitechat.h" #include "../gtk3-theme-service.h" #include "../cfgfiles.h" +#include + char *xdir = NULL; char * diff --git a/src/common/theme-service.c b/src/common/theme-service.c index f0e5aa5f..2e8f6d33 100644 --- a/src/common/theme-service.c +++ b/src/common/theme-service.c @@ -1,10 +1,11 @@ #include +#include "zoitechat.h" + #include #include #include "cfgfiles.h" -#include "zoitechat.h" #include "theme-service.h" static zoitechat_theme_post_apply_callback zoitechat_theme_post_apply_cb; diff --git a/src/common/theme-service.h b/src/common/theme-service.h index 21208cf2..7b3b3a4a 100644 --- a/src/common/theme-service.h +++ b/src/common/theme-service.h @@ -1,7 +1,7 @@ #ifndef ZOITECHAT_THEME_SERVICE_H #define ZOITECHAT_THEME_SERVICE_H -#include +#include "zoitechat.h" char *zoitechat_theme_service_get_themes_dir (void); GStrv zoitechat_theme_service_discover_themes (void); diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 7d37ac21..3d0d8f5c 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -21,6 +21,8 @@ #include #include +#include "fe-gtk.h" + #include #include #include @@ -40,7 +42,6 @@ #include "../common/chanopt.h" #include "../common/cfgfiles.h" -#include "fe-gtk.h" #include "theme/theme-manager.h" #include "theme/theme-css.h" #include "banlist.h" diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 7faddc3e..2671ea4b 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -1860,16 +1860,6 @@ menu_about (GtkWidget *wid, gpointer sess) GtkAboutDialog *dialog = GTK_ABOUT_DIALOG(gtk_about_dialog_new()); theme_manager_attach_window (GTK_WIDGET (dialog)); char comment[512]; - char *license = "This program is free software; you can redistribute it and/or modify\n" \ - "it under the terms of the GNU General Public License as published by\n" \ - "the Free Software Foundation; version 2.\n\n" \ - "This program is distributed in the hope that it will be useful,\n" \ - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" \ - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" \ - "GNU General Public License for more details.\n\n" \ - "You should have received a copy of the GNU General Public License\n" \ - "along with this program. If not, see "; - g_snprintf (comment, sizeof(comment), "" #ifdef WIN32 "Portable Mode: %s\n" diff --git a/src/fe-gtk/plugin-tray.c b/src/fe-gtk/plugin-tray.c index 112c8983..5715231f 100644 --- a/src/fe-gtk/plugin-tray.c +++ b/src/fe-gtk/plugin-tray.c @@ -414,8 +414,10 @@ tray_app_indicator_init (void) { GObjectClass *klass; + G_GNUC_BEGIN_IGNORE_DEPRECATIONS tray_indicator = app_indicator_new ("zoitechat", ICON_NORMAL_NAME, APP_INDICATOR_CATEGORY_COMMUNICATIONS); + G_GNUC_END_IGNORE_DEPRECATIONS if (!tray_indicator) return FALSE; @@ -578,8 +580,13 @@ tray_backend_cleanup (void) static WinStatus tray_get_window_status (void) { + GtkWindow *win; const char *st; + win = GTK_WINDOW (zoitechat_get_info (ph, "gtkwin_ptr")); + if (win && !gtk_widget_get_visible (GTK_WIDGET (win))) + return WS_HIDDEN; + st = zoitechat_get_info (ph, "win_status"); if (!st) @@ -998,6 +1005,7 @@ blink_item (unsigned int *setting, GtkWidget *menu, char *label) } #endif +#if !HAVE_APPINDICATOR_BACKEND static void tray_menu_destroy (GtkWidget *menu, gpointer userdata) { @@ -1009,6 +1017,7 @@ tray_menu_destroy (GtkWidget *menu, gpointer userdata) g_source_remove (tray_menu_timer); #endif } +#endif #ifdef WIN32 static gboolean diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 9d015e80..65f1234f 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -22,10 +22,10 @@ #include #include +#include "../common/zoitechat.h" + #include #include - -#include "../common/zoitechat.h" #include "../common/cfgfiles.h" #include "../common/fe.h" #include "../common/text.h" diff --git a/src/fe-gtk/theme/tests/test-theme-access-routing.c b/src/fe-gtk/theme/tests/test-theme-access-routing.c index 9f87d150..bdc0227b 100644 --- a/src/fe-gtk/theme/tests/test-theme-access-routing.c +++ b/src/fe-gtk/theme/tests/test-theme-access-routing.c @@ -1,5 +1,6 @@ +#include "../../fe-gtk.h" + #include -#include #include "../theme-access.h" #include "../theme-manager.h" diff --git a/src/fe-gtk/theme/tests/test-theme-application-input-style.c b/src/fe-gtk/theme/tests/test-theme-application-input-style.c index ccfe7255..1dd750ed 100644 --- a/src/fe-gtk/theme/tests/test-theme-application-input-style.c +++ b/src/fe-gtk/theme/tests/test-theme-application-input-style.c @@ -1,4 +1,4 @@ -#include +#include "../../fe-gtk.h" #include "../theme-application.h" #include "../../maingui.h" diff --git a/src/fe-gtk/theme/tests/test-theme-gtk3-settings.c b/src/fe-gtk/theme/tests/test-theme-gtk3-settings.c index 69694950..37ccab84 100644 --- a/src/fe-gtk/theme/tests/test-theme-gtk3-settings.c +++ b/src/fe-gtk/theme/tests/test-theme-gtk3-settings.c @@ -1,11 +1,12 @@ +#include "../../../common/zoitechat.h" +#include "../../../common/zoitechatc.h" + #include #include #include #include "../theme-gtk3.h" #include "../../../common/gtk3-theme-service.h" -#include "../../../common/zoitechat.h" -#include "../../../common/zoitechatc.h" struct session *current_sess; struct session *current_tab; diff --git a/src/fe-gtk/theme/tests/test-theme-manager-auto-refresh.c b/src/fe-gtk/theme/tests/test-theme-manager-auto-refresh.c index b49acd76..8331b311 100644 --- a/src/fe-gtk/theme/tests/test-theme-manager-auto-refresh.c +++ b/src/fe-gtk/theme/tests/test-theme-manager-auto-refresh.c @@ -1,8 +1,7 @@ -#include +#include "../../fe-gtk.h" #include "../theme-manager.h" #include "../theme-gtk3.h" -#include "../../fe-gtk.h" #include "../../../common/zoitechat.h" #include "../../../common/zoitechatc.h" diff --git a/src/fe-gtk/theme/tests/test-theme-manager-dispatch-routing.c b/src/fe-gtk/theme/tests/test-theme-manager-dispatch-routing.c index 6e6b492e..a3c34bc0 100644 --- a/src/fe-gtk/theme/tests/test-theme-manager-dispatch-routing.c +++ b/src/fe-gtk/theme/tests/test-theme-manager-dispatch-routing.c @@ -1,8 +1,8 @@ -#include +#include "../../fe-gtk.h" + #include #include "../theme-manager.h" -#include "../../fe-gtk.h" #include "../../../common/zoitechat.h" #include "../../../common/zoitechatc.h" diff --git a/src/fe-gtk/theme/tests/test-theme-manager-policy.c b/src/fe-gtk/theme/tests/test-theme-manager-policy.c index 717736c6..d5d2b60d 100644 --- a/src/fe-gtk/theme/tests/test-theme-manager-policy.c +++ b/src/fe-gtk/theme/tests/test-theme-manager-policy.c @@ -1,8 +1,7 @@ -#include +#include "../../fe-gtk.h" #include "../theme-palette.h" #include "../theme-manager.h" -#include "../../fe-gtk.h" #include "../../../common/zoitechat.h" #include "../../../common/zoitechatc.h" diff --git a/src/fe-gtk/theme/tests/test-theme-preferences-gtk3-populate.c b/src/fe-gtk/theme/tests/test-theme-preferences-gtk3-populate.c index 71540bc2..117f1bdd 100644 --- a/src/fe-gtk/theme/tests/test-theme-preferences-gtk3-populate.c +++ b/src/fe-gtk/theme/tests/test-theme-preferences-gtk3-populate.c @@ -1,9 +1,8 @@ -#include +#include "../../fe-gtk.h" #include "../../../common/zoitechat.h" #include "../../../common/zoitechatc.h" #include "../../../common/gtk3-theme-service.h" -#include "../../fe-gtk.h" #include "../theme-gtk3.h" #include "../theme-manager.h" diff --git a/src/fe-gtk/theme/tests/test-theme-runtime-persistence.c b/src/fe-gtk/theme/tests/test-theme-runtime-persistence.c index bfb8dff7..8b211125 100644 --- a/src/fe-gtk/theme/tests/test-theme-runtime-persistence.c +++ b/src/fe-gtk/theme/tests/test-theme-runtime-persistence.c @@ -1,3 +1,6 @@ +#include "../../../common/zoitechat.h" +#include "../../../common/zoitechatc.h" + #include #include #include @@ -8,8 +11,6 @@ #include #include "../theme-runtime.h" -#include "../../../common/zoitechat.h" -#include "../../../common/zoitechatc.h" struct session *current_sess; struct session *current_tab; diff --git a/src/fe-gtk/theme/theme-access.c b/src/fe-gtk/theme/theme-access.c index 517936a7..c093df58 100644 --- a/src/fe-gtk/theme/theme-access.c +++ b/src/fe-gtk/theme/theme-access.c @@ -40,9 +40,11 @@ theme_access_get_gtk_palette_map (GtkWidget *widget, ThemeGtkPaletteMap *out_map return FALSE; gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_foreground); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_background); gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_foreground); gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_background); + G_GNUC_END_IGNORE_DEPRECATIONS gtk_style_context_get_color (context, GTK_STATE_FLAG_LINK, &accent); if (accent.alpha <= 0.0) accent = out_map->selection_background; diff --git a/src/fe-gtk/theme/theme-application.h b/src/fe-gtk/theme/theme-application.h index 99f770c9..46c7761d 100644 --- a/src/fe-gtk/theme/theme-application.h +++ b/src/fe-gtk/theme/theme-application.h @@ -1,7 +1,6 @@ #ifndef ZOITECHAT_THEME_APPLICATION_H #define ZOITECHAT_THEME_APPLICATION_H -#include #include "../fe-gtk.h" gboolean theme_application_apply_mode (unsigned int mode, gboolean *palette_changed); diff --git a/src/fe-gtk/theme/theme-gtk3.c b/src/fe-gtk/theme/theme-gtk3.c index 847e7ded..1a40030e 100644 --- a/src/fe-gtk/theme/theme-gtk3.c +++ b/src/fe-gtk/theme/theme-gtk3.c @@ -1,5 +1,8 @@ #include "theme-gtk3.h" +#include "../../common/zoitechat.h" +#include "../../common/zoitechatc.h" + #include #include #include @@ -7,8 +10,6 @@ #include "theme-policy.h" #include "../../common/gtk3-theme-service.h" -#include "../../common/zoitechat.h" -#include "../../common/zoitechatc.h" static GPtrArray *theme_gtk3_providers_base; static GPtrArray *theme_gtk3_providers_variant; diff --git a/src/fe-gtk/theme/theme-policy.c b/src/fe-gtk/theme/theme-policy.c index 14df8bf9..05271be7 100644 --- a/src/fe-gtk/theme/theme-policy.c +++ b/src/fe-gtk/theme/theme-policy.c @@ -1,7 +1,5 @@ #include "theme-policy.h" -#include - #include "../fe-gtk.h" #include "../../common/zoitechat.h" #include "../../common/zoitechatc.h" diff --git a/src/fe-gtk/theme/theme-policy.h b/src/fe-gtk/theme/theme-policy.h index 8e40653e..5ce1d5f4 100644 --- a/src/fe-gtk/theme/theme-policy.h +++ b/src/fe-gtk/theme/theme-policy.h @@ -1,7 +1,7 @@ #ifndef ZOITECHAT_THEME_POLICY_H #define ZOITECHAT_THEME_POLICY_H -#include +#include "../fe-gtk.h" gboolean theme_policy_system_prefers_dark (void); gboolean theme_policy_is_dark_mode_active (unsigned int mode); diff --git a/src/fe-gtk/theme/theme-preferences.c b/src/fe-gtk/theme/theme-preferences.c index 8270404a..8051e33a 100644 --- a/src/fe-gtk/theme/theme-preferences.c +++ b/src/fe-gtk/theme/theme-preferences.c @@ -1,6 +1,9 @@ #include #include +#include "../../common/zoitechat.h" +#include "../../common/zoitechatc.h" + #include #include @@ -8,9 +11,7 @@ #include "../../common/fe.h" #include "../../common/util.h" #include "../../common/cfgfiles.h" -#include "../../common/zoitechat.h" #include "../../common/gtk3-theme-service.h" -#include "../../common/zoitechatc.h" #include "theme-gtk3.h" #include "theme-manager.h" #include "theme-preferences.h" diff --git a/src/fe-gtk/theme/theme-preferences.h b/src/fe-gtk/theme/theme-preferences.h index 2ca3c3a8..d2d15a07 100644 --- a/src/fe-gtk/theme/theme-preferences.h +++ b/src/fe-gtk/theme/theme-preferences.h @@ -1,12 +1,11 @@ #ifndef ZOITECHAT_THEME_PREFERENCES_H #define ZOITECHAT_THEME_PREFERENCES_H -#include - -#include "theme-access.h" #include "../fe-gtk.h" #include "../../common/zoitechat.h" +#include "theme-access.h" + GtkWidget *theme_preferences_create_page (GtkWindow *parent, struct zoitechatprefs *setup_prefs, gboolean *color_change_flag); diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c index 448e3ace..27f19452 100644 --- a/src/fe-gtk/xtext.c +++ b/src/fe-gtk/xtext.c @@ -318,12 +318,18 @@ xtext_surface_from_window (GdkWindow *window) static cairo_t * xtext_create_context (GtkXText *xtext) { + cairo_t *cr; + if (xtext->draw_surface) return cairo_create (xtext->draw_surface); if (xtext->draw_cr) return cairo_reference (xtext->draw_cr); - return gdk_cairo_create (xtext->draw_window); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS + cr = gdk_cairo_create (xtext->draw_window); + G_GNUC_END_IGNORE_DEPRECATIONS + + return cr; } static inline void @@ -357,7 +363,7 @@ xtext_draw_line (GtkXText *xtext, cairo_t *cr, const XTextColor *color, int x1, cairo_restore (cr); } -static inline void +static void xtext_draw_bg_offset (GtkXText *xtext, int x, int y, int width, int height, int tile_x, int tile_y) { cairo_t *cr = xtext_create_context (xtext); @@ -1065,8 +1071,10 @@ static inline void gtk_xtext_clear_background (GtkWidget *widget) { GdkWindow *window = gtk_widget_get_window (widget); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (window) gdk_window_set_background_pattern (window, NULL); + G_GNUC_END_IGNORE_DEPRECATIONS } static void