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