fix: quiet GTK/GLib warn spam; fix include order; normalize imported CSS

This commit is contained in:
2026-03-09 14:21:20 -06:00
parent a11687e3eb
commit 0aa6c26490
27 changed files with 126 additions and 57 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -1,7 +1,7 @@
#ifndef ZOITECHAT_GTK3_THEME_SERVICE_H
#define ZOITECHAT_GTK3_THEME_SERVICE_H
#include <glib.h>
#include "zoitechat.h"
typedef enum
{

View File

@@ -16,7 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <glib.h>
#include "zoitechat.h"
#include <time.h>
#include <fcntl.h>
@@ -26,7 +27,6 @@
#include <unistd.h>
#endif
#include "zoitechat.h"
#include "cfgfiles.h"
#include "util.h"
#include "text.h"

View File

@@ -1,9 +1,9 @@
#include <glib.h>
#include <glib/gstdio.h>
#include "../zoitechat.h"
#include "../gtk3-theme-service.h"
#include "../cfgfiles.h"
#include <glib/gstdio.h>
char *xdir = NULL;
char *

View File

@@ -1,10 +1,11 @@
#include <errno.h>
#include "zoitechat.h"
#include <gio/gio.h>
#include <glib/gstdio.h>
#include "cfgfiles.h"
#include "zoitechat.h"
#include "theme-service.h"
static zoitechat_theme_post_apply_callback zoitechat_theme_post_apply_cb;

View File

@@ -1,7 +1,7 @@
#ifndef ZOITECHAT_THEME_SERVICE_H
#define ZOITECHAT_THEME_SERVICE_H
#include <glib.h>
#include "zoitechat.h"
char *zoitechat_theme_service_get_themes_dir (void);
GStrv zoitechat_theme_service_discover_themes (void);

View File

@@ -21,6 +21,8 @@
#include <stdio.h>
#include <ctype.h>
#include "fe-gtk.h"
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkcairo.h>
@@ -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"

View File

@@ -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 <http://www.gnu.org/licenses/>";
g_snprintf (comment, sizeof(comment), ""
#ifdef WIN32
"Portable Mode: %s\n"

View File

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

View File

@@ -22,10 +22,10 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "../common/zoitechat.h"
#include <gio/gio.h>
#include <glib/gstdio.h>
#include "../common/zoitechat.h"
#include "../common/cfgfiles.h"
#include "../common/fe.h"
#include "../common/text.h"

View File

@@ -1,5 +1,6 @@
#include "../../fe-gtk.h"
#include <math.h>
#include <gtk/gtk.h>
#include "../theme-access.h"
#include "../theme-manager.h"

View File

@@ -1,4 +1,4 @@
#include <gtk/gtk.h>
#include "../../fe-gtk.h"
#include "../theme-application.h"
#include "../../maingui.h"

View File

@@ -1,11 +1,12 @@
#include "../../../common/zoitechat.h"
#include "../../../common/zoitechatc.h"
#include <glib.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#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;

View File

@@ -1,8 +1,7 @@
#include <gtk/gtk.h>
#include "../../fe-gtk.h"
#include "../theme-manager.h"
#include "../theme-gtk3.h"
#include "../../fe-gtk.h"
#include "../../../common/zoitechat.h"
#include "../../../common/zoitechatc.h"

View File

@@ -1,8 +1,8 @@
#include <gtk/gtk.h>
#include "../../fe-gtk.h"
#include <string.h>
#include "../theme-manager.h"
#include "../../fe-gtk.h"
#include "../../../common/zoitechat.h"
#include "../../../common/zoitechatc.h"

View File

@@ -1,8 +1,7 @@
#include <gtk/gtk.h>
#include "../../fe-gtk.h"
#include "../theme-palette.h"
#include "../theme-manager.h"
#include "../../fe-gtk.h"
#include "../../../common/zoitechat.h"
#include "../../../common/zoitechatc.h"

View File

@@ -1,9 +1,8 @@
#include <gtk/gtk.h>
#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"

View File

@@ -1,3 +1,6 @@
#include "../../../common/zoitechat.h"
#include "../../../common/zoitechatc.h"
#include <errno.h>
#include <math.h>
#include <fcntl.h>
@@ -8,8 +11,6 @@
#include <unistd.h>
#include "../theme-runtime.h"
#include "../../../common/zoitechat.h"
#include "../../../common/zoitechatc.h"
struct session *current_sess;
struct session *current_tab;

View File

@@ -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;

View File

@@ -1,7 +1,6 @@
#ifndef ZOITECHAT_THEME_APPLICATION_H
#define ZOITECHAT_THEME_APPLICATION_H
#include <glib.h>
#include "../fe-gtk.h"
gboolean theme_application_apply_mode (unsigned int mode, gboolean *palette_changed);

View File

@@ -1,5 +1,8 @@
#include "theme-gtk3.h"
#include "../../common/zoitechat.h"
#include "../../common/zoitechatc.h"
#include <gtk/gtk.h>
#include <glib/gstdio.h>
#include <gio/gio.h>
@@ -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;

View File

@@ -1,7 +1,5 @@
#include "theme-policy.h"
#include <gtk/gtk.h>
#include "../fe-gtk.h"
#include "../../common/zoitechat.h"
#include "../../common/zoitechatc.h"

View File

@@ -1,7 +1,7 @@
#ifndef ZOITECHAT_THEME_POLICY_H
#define ZOITECHAT_THEME_POLICY_H
#include <glib.h>
#include "../fe-gtk.h"
gboolean theme_policy_system_prefers_dark (void);
gboolean theme_policy_is_dark_mode_active (unsigned int mode);

View File

@@ -1,6 +1,9 @@
#include <stdio.h>
#include <string.h>
#include "../../common/zoitechat.h"
#include "../../common/zoitechatc.h"
#include <gio/gio.h>
#include <glib/gstdio.h>
@@ -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"

View File

@@ -1,12 +1,11 @@
#ifndef ZOITECHAT_THEME_PREFERENCES_H
#define ZOITECHAT_THEME_PREFERENCES_H
#include <gtk/gtk.h>
#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);

View File

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