mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-19 20:20:18 +00:00
Added Windows-side icon theme fallback logic in win32_configure_icon_theme that now checks (in addition to the existing <base>/share/icons) these paths:
ZOITECHAT_ICON_PATH (user override env var),
current working directory + share/icons,
argv[0] directory + share/icons.
Valid directories are appended to GTK’s icon search path.
Added diagnostic logging so startup clearly reports either the selected icon path source/path or that none of the expected locations were usable, to speed up Windows missing-icon triage.
Reused/stored the computed argv[0] directory in fe_args (via win32_argv0_dir) so it can be used both for chdir and for icon fallback resolution.
This commit is contained in:
@@ -117,6 +117,8 @@ create_msg_dialog (gchar *title, gchar *message)
|
|||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *win32_argv0_dir;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
win32_set_gsettings_schema_dir (void)
|
win32_set_gsettings_schema_dir (void)
|
||||||
{
|
{
|
||||||
@@ -225,24 +227,66 @@ static void
|
|||||||
win32_configure_icon_theme (void)
|
win32_configure_icon_theme (void)
|
||||||
{
|
{
|
||||||
GtkIconTheme *theme;
|
GtkIconTheme *theme;
|
||||||
|
const char *env_icons_path;
|
||||||
char *base_path;
|
char *base_path;
|
||||||
char *icons_path;
|
char *icons_path;
|
||||||
|
char *cwd_dir;
|
||||||
|
char *cwd_path;
|
||||||
|
char *argv0_icons_path;
|
||||||
|
const char *selected_source = NULL;
|
||||||
|
char *selected_path = NULL;
|
||||||
|
|
||||||
|
#define WIN32_SET_ICON_PATH(source_name, path_value) \
|
||||||
|
G_STMT_START { \
|
||||||
|
if ((path_value) != NULL && g_file_test ((path_value), G_FILE_TEST_IS_DIR)) \
|
||||||
|
{ \
|
||||||
|
gtk_icon_theme_append_search_path (theme, (path_value)); \
|
||||||
|
if (selected_path == NULL) \
|
||||||
|
{ \
|
||||||
|
selected_source = (source_name); \
|
||||||
|
selected_path = g_strdup (path_value); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
theme = gtk_icon_theme_get_default ();
|
theme = gtk_icon_theme_get_default ();
|
||||||
if (!theme)
|
if (!theme)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
env_icons_path = g_getenv ("ZOITECHAT_ICON_PATH");
|
||||||
|
if (env_icons_path && *env_icons_path)
|
||||||
|
WIN32_SET_ICON_PATH ("ZOITECHAT_ICON_PATH", env_icons_path);
|
||||||
|
|
||||||
base_path = g_win32_get_package_installation_directory_of_module (NULL);
|
base_path = g_win32_get_package_installation_directory_of_module (NULL);
|
||||||
if (!base_path)
|
if (base_path)
|
||||||
return;
|
{
|
||||||
|
icons_path = g_build_filename (base_path, "share", "icons", NULL);
|
||||||
|
WIN32_SET_ICON_PATH ("module base", icons_path);
|
||||||
|
g_free (icons_path);
|
||||||
|
}
|
||||||
|
|
||||||
icons_path = g_build_filename (base_path, "share", "icons", NULL);
|
cwd_dir = g_get_current_dir ();
|
||||||
|
cwd_path = g_build_filename (cwd_dir, "share", "icons", NULL);
|
||||||
|
WIN32_SET_ICON_PATH ("current working directory", cwd_path);
|
||||||
|
g_free (cwd_path);
|
||||||
|
g_free (cwd_dir);
|
||||||
|
|
||||||
if (g_file_test (icons_path, G_FILE_TEST_IS_DIR))
|
if (win32_argv0_dir)
|
||||||
gtk_icon_theme_append_search_path (theme, icons_path);
|
{
|
||||||
|
argv0_icons_path = g_build_filename (win32_argv0_dir, "share", "icons", NULL);
|
||||||
|
WIN32_SET_ICON_PATH ("argv[0] directory", argv0_icons_path);
|
||||||
|
g_free (argv0_icons_path);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (icons_path);
|
if (selected_path)
|
||||||
|
g_message ("win32_configure_icon_theme: selected icon path (%s): %s", selected_source, selected_path);
|
||||||
|
else
|
||||||
|
g_message ("win32_configure_icon_theme: no usable icon path found (checked ZOITECHAT_ICON_PATH, module base/share/icons, cwd/share/icons, argv[0]/share/icons)");
|
||||||
|
|
||||||
|
g_free (selected_path);
|
||||||
g_free (base_path);
|
g_free (base_path);
|
||||||
|
|
||||||
|
#undef WIN32_SET_ICON_PATH
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -361,16 +405,10 @@ fe_args (int argc, char *argv[])
|
|||||||
/* cuts can. So we have to set the current dir manually, to the path */
|
/* cuts can. So we have to set the current dir manually, to the path */
|
||||||
/* of the exe. */
|
/* of the exe. */
|
||||||
{
|
{
|
||||||
char *tmp = g_strdup (argv[0]);
|
g_free (win32_argv0_dir);
|
||||||
char *sl;
|
win32_argv0_dir = g_path_get_dirname (argv[0]);
|
||||||
|
if (win32_argv0_dir)
|
||||||
sl = strrchr (tmp, G_DIR_SEPARATOR);
|
chdir (win32_argv0_dir);
|
||||||
if (sl)
|
|
||||||
{
|
|
||||||
*sl = 0;
|
|
||||||
chdir (tmp);
|
|
||||||
}
|
|
||||||
g_free (tmp);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user