mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-17 19:20:20 +00:00
Compare commits
21 Commits
zoitechat-
...
save-fixes
| Author | SHA1 | Date | |
|---|---|---|---|
| b32f6522ac | |||
| b7e4548d2a | |||
| 0cfb63f301 | |||
| e90b68967c | |||
| 0155b07c9d | |||
| 592d74e788 | |||
| 854a913911 | |||
| 48b551b188 | |||
| 9e808c57b4 | |||
| 896a761e24 | |||
| 96af9bdde6 | |||
| e90f0188c1 | |||
| 0ab7eb7207 | |||
| 81dcdbe648 | |||
| f4090cb0e5 | |||
| 0f5dfb147e | |||
| 0bcd369426 | |||
|
|
b316d4a281 | ||
| 86ab0135ce | |||
| 2d42d4e181 | |||
| 23e6313e2f |
21
.github/workflows/windows-build.yml
vendored
21
.github/workflows/windows-build.yml
vendored
@@ -29,7 +29,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-python@v6
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.14.2'
|
python-version: '3.14.3'
|
||||||
architecture: ${{ matrix.arch }}
|
architecture: ${{ matrix.arch }}
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
@@ -62,19 +62,16 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Download-WithRetry -Url https://files.jrsoftware.org/is/6/innosetup-6.7.0.exe -OutFile deps\innosetup-unicode.exe
|
Download-WithRetry -Url https://github.com/jrsoftware/issrc/releases/download/is-6_7_1/innosetup-6.7.1.exe -OutFile deps\innosetup-unicode.exe
|
||||||
& deps\innosetup-unicode.exe /VERYSILENT | Out-Null
|
& deps\innosetup-unicode.exe /VERYSILENT | Out-Null
|
||||||
|
|
||||||
Download-WithRetry -Url https://github.com/zoitechat/gvsbuild/releases/download/zoitechat-2.17.0/idpsetup-1.5.1.exe -OutFile deps\idpsetup.exe
|
|
||||||
& deps\idpsetup.exe /VERYSILENT
|
|
||||||
|
|
||||||
Download-WithRetry -Url https://github.com/ZoiteChat/gvsbuild/releases/download/zoitechat-2.18.0-pre1/GTK3_Gvsbuild_zoitechat-2.18.0-pre1_${{ matrix.platform }}.7z -OutFile deps\gtk-${{ matrix.arch }}.7z
|
Download-WithRetry -Url https://github.com/ZoiteChat/gvsbuild/releases/download/zoitechat-2.18.0-pre1/GTK3_Gvsbuild_zoitechat-2.18.0-pre1_${{ matrix.platform }}.7z -OutFile deps\gtk-${{ matrix.arch }}.7z
|
||||||
& 7z.exe x deps\gtk-${{ matrix.arch }}.7z -oC:\gtk-build\gtk\x64\release
|
& 7z.exe x deps\gtk-${{ matrix.arch }}.7z -oC:\gtk-build\gtk\x64\release
|
||||||
|
|
||||||
Download-WithRetry -Url https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-hicolor-icon-theme-0.18-1-any.pkg.tar.zst -OutFile deps\hicolor-icon-theme.pkg.tar.zst
|
Download-WithRetry -Url https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-hicolor-icon-theme-0.18-1-any.pkg.tar.zst -OutFile deps\hicolor-icon-theme.pkg.tar.zst
|
||||||
python -c "import tarfile,zstandard,pathlib;archive=pathlib.Path(r'deps\\hicolor-icon-theme.pkg.tar.zst');target=pathlib.Path(r'C:\\gtk-build\\gtk\\x64\\release');dctx=zstandard.ZstdDecompressor();f=archive.open('rb');reader=dctx.stream_reader(f);tf=tarfile.open(fileobj=reader,mode='r|');[tf.extract(m,path=target) for m in tf if m.name.startswith('mingw64/share/icons/hicolor/')];tf.close();reader.close();f.close()"
|
python -c "import tarfile,zstandard,pathlib;archive=pathlib.Path(r'deps\\hicolor-icon-theme.pkg.tar.zst');target=pathlib.Path(r'C:\\gtk-build\\gtk\\x64\\release');dctx=zstandard.ZstdDecompressor();f=archive.open('rb');reader=dctx.stream_reader(f);tf=tarfile.open(fileobj=reader,mode='r|');[tf.extract(m,path=target) for m in tf if m.name.startswith('mingw64/share/icons/hicolor/')];tf.close();reader.close();f.close()"
|
||||||
|
|
||||||
Download-WithRetry -Url https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-libarchive-3.8.1-1-any.pkg.tar.zst -OutFile deps\libarchive.pkg.tar.zst
|
Download-WithRetry -Url https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-libarchive-3.8.6-1-any.pkg.tar.zst -OutFile deps\libarchive.pkg.tar.zst
|
||||||
python -c "import tarfile,zstandard,pathlib;archive=pathlib.Path(r'deps\\libarchive.pkg.tar.zst');target=pathlib.Path(r'C:\\gtk-build\\gtk\\x64\\release');dctx=zstandard.ZstdDecompressor();f=archive.open('rb');reader=dctx.stream_reader(f);tf=tarfile.open(fileobj=reader,mode='r|');[tf.extract(m,path=target) for m in tf if m.name.startswith(('mingw64/include/archive','mingw64/lib/libarchive','mingw64/bin/libarchive'))];tf.close();reader.close();f.close()"
|
python -c "import tarfile,zstandard,pathlib;archive=pathlib.Path(r'deps\\libarchive.pkg.tar.zst');target=pathlib.Path(r'C:\\gtk-build\\gtk\\x64\\release');dctx=zstandard.ZstdDecompressor();f=archive.open('rb');reader=dctx.stream_reader(f);tf=tarfile.open(fileobj=reader,mode='r|');[tf.extract(m,path=target) for m in tf if m.name.startswith(('mingw64/include/archive','mingw64/lib/libarchive','mingw64/bin/libarchive'))];tf.close();reader.close();f.close()"
|
||||||
|
|
||||||
if (Test-Path C:\gtk-build\gtk\x64\release\mingw64\share\icons\hicolor) {
|
if (Test-Path C:\gtk-build\gtk\x64\release\mingw64\share\icons\hicolor) {
|
||||||
@@ -97,19 +94,19 @@ jobs:
|
|||||||
Remove-Item -Path C:\gtk-build\gtk\x64\release\mingw64 -Recurse -Force
|
Remove-Item -Path C:\gtk-build\gtk\x64\release\mingw64 -Recurse -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
Download-WithRetry -Url https://github.com/zoitechat/gvsbuild/releases/download/zoitechat-2.17.0/gendef-20111031.7z -OutFile deps\gendef.7z
|
Download-WithRetry -Url https://github.com/ZoiteChat/gvsbuild/releases/download/zoitechat-2.18.0-pre4/gendef20260315.7z -OutFile deps\gendef.7z
|
||||||
& 7z.exe x deps\gendef.7z -oC:\gtk-build
|
& 7z.exe x deps\gendef.7z -oC:\gtk-build
|
||||||
|
|
||||||
Download-WithRetry -Url https://github.com/zoitechat/gvsbuild/releases/download/zoitechat-2.17.0/WinSparkle-20151011.7z -OutFile deps\WinSparkle.7z
|
Download-WithRetry -Url https://github.com/ZoiteChat/gvsbuild/releases/download/zoitechat-2.18.0-pre4/WinSparkle-20260315.7z -OutFile deps\WinSparkle.7z
|
||||||
& 7z.exe x deps\WinSparkle.7z -oC:\gtk-build\WinSparkle
|
& 7z.exe x deps\WinSparkle.7z -oC:\gtk-build\WinSparkle
|
||||||
|
|
||||||
Download-WithRetry -Url https://github.com/zoitechat/gvsbuild/releases/download/zoitechat-2.17.0/perl-5.20.0-${{ matrix.arch }}.7z -OutFile deps\perl-${{ matrix.arch }}.7z
|
Download-WithRetry -Url https://github.com/ZoiteChat/gvsbuild/releases/download/zoitechat-2.18.0-pre4/perl-5.42.0.1-${{ matrix.arch }}.7z -OutFile deps\perl-${{ matrix.arch }}.7z
|
||||||
& 7z.exe x deps\perl-${{ matrix.arch }}.7z -oC:\gtk-build\perl-5.20\${{ matrix.platform }}
|
& 7z.exe x deps\perl-${{ matrix.arch }}.7z -oC:\gtk-build\perl-5.42.0.1\${{ matrix.platform }}
|
||||||
|
|
||||||
$pyRoot = $env:pythonLocation
|
$pyRoot = $env:pythonLocation
|
||||||
if (-not $pyRoot) { $pyRoot = & python -c "import sys; print(sys.prefix)" }
|
if (-not $pyRoot) { $pyRoot = & python -c "import sys; print(sys.prefix)" }
|
||||||
|
|
||||||
foreach ($pyDir in @("C:\gtk-build\python-3.14.2", "C:\gtk-build\python-3.14")) {
|
foreach ($pyDir in @("C:\gtk-build\python-3.14.3", "C:\gtk-build\python-3.14")) {
|
||||||
New-Item -Path $pyDir -ItemType Directory -Force | Out-Null
|
New-Item -Path $pyDir -ItemType Directory -Force | Out-Null
|
||||||
$target = Join-Path $pyDir "${{ matrix.platform }}"
|
$target = Join-Path $pyDir "${{ matrix.platform }}"
|
||||||
if (Test-Path $target) { Remove-Item $target -Recurse -Force }
|
if (Test-Path $target) { Remove-Item $target -Recurse -Force }
|
||||||
@@ -120,7 +117,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
|
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
|
||||||
|
|
||||||
set "PYTHON_DIR=C:\gtk-build\python-3.14.2\${{ matrix.platform }}"
|
set "PYTHON_DIR=C:\gtk-build\python-3.14.3\${{ matrix.platform }}"
|
||||||
if not exist "%PYTHON_DIR%\libs\python314.lib" (
|
if not exist "%PYTHON_DIR%\libs\python314.lib" (
|
||||||
echo Missing %PYTHON_DIR%\libs\python314.lib
|
echo Missing %PYTHON_DIR%\libs\python314.lib
|
||||||
dir "%PYTHON_DIR%\libs"
|
dir "%PYTHON_DIR%\libs"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ depends=(
|
|||||||
'glib2'
|
'glib2'
|
||||||
'gtk3'
|
'gtk3'
|
||||||
'iso-codes'
|
'iso-codes'
|
||||||
|
'libayatana-appindicator'
|
||||||
'libcanberra'
|
'libcanberra'
|
||||||
'lua'
|
'lua'
|
||||||
'openssl'
|
'openssl'
|
||||||
@@ -26,7 +27,6 @@ makedepends=(
|
|||||||
'python'
|
'python'
|
||||||
)
|
)
|
||||||
optdepends=(
|
optdepends=(
|
||||||
'libayatana-appindicator: Ayatana/AppIndicator tray backend'
|
|
||||||
'pciutils: sysinfo plugin hardware detection details'
|
'pciutils: sysinfo plugin hardware detection details'
|
||||||
)
|
)
|
||||||
provides=('zoitechat')
|
provides=('zoitechat')
|
||||||
|
|||||||
@@ -45,6 +45,22 @@ endif
|
|||||||
perl_ldflags = []
|
perl_ldflags = []
|
||||||
perl_rpath = ''
|
perl_rpath = ''
|
||||||
foreach flag : ret.stdout().strip().split(' ')
|
foreach flag : ret.stdout().strip().split(' ')
|
||||||
|
if flag.startswith('/') and '/libperl.' in flag
|
||||||
|
split = flag.split('/')
|
||||||
|
libperl_dir = ''
|
||||||
|
foreach part : split
|
||||||
|
if part != '' and not part.startswith('libperl.')
|
||||||
|
if libperl_dir == ''
|
||||||
|
libperl_dir = '/' + part
|
||||||
|
else
|
||||||
|
libperl_dir += '/' + part
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endforeach
|
||||||
|
perl_ldflags += '-L' + libperl_dir
|
||||||
|
perl_ldflags += '-lperl'
|
||||||
|
continue
|
||||||
|
endif
|
||||||
if flag.startswith('-L') or flag.startswith('-l')
|
if flag.startswith('-L') or flag.startswith('-l')
|
||||||
perl_ldflags += flag
|
perl_ldflags += flag
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -407,6 +407,9 @@ const struct prefs vars[] =
|
|||||||
{"gui_autoopen_send", P_OFFINT (hex_gui_autoopen_send), TYPE_BOOL},
|
{"gui_autoopen_send", P_OFFINT (hex_gui_autoopen_send), TYPE_BOOL},
|
||||||
{"gui_chanlist_maxusers", P_OFFINT (hex_gui_chanlist_maxusers), TYPE_INT},
|
{"gui_chanlist_maxusers", P_OFFINT (hex_gui_chanlist_maxusers), TYPE_INT},
|
||||||
{"gui_chanlist_minusers", P_OFFINT (hex_gui_chanlist_minusers), TYPE_INT},
|
{"gui_chanlist_minusers", P_OFFINT (hex_gui_chanlist_minusers), TYPE_INT},
|
||||||
|
{"gui_chanlist_width_channel", P_OFFINT (hex_gui_chanlist_width_channel), TYPE_INT},
|
||||||
|
{"gui_chanlist_width_topic", P_OFFINT (hex_gui_chanlist_width_topic), TYPE_INT},
|
||||||
|
{"gui_chanlist_width_users", P_OFFINT (hex_gui_chanlist_width_users), TYPE_INT},
|
||||||
{"gui_compact", P_OFFINT (hex_gui_compact), TYPE_BOOL},
|
{"gui_compact", P_OFFINT (hex_gui_compact), TYPE_BOOL},
|
||||||
{"gui_dialog_height", P_OFFINT (hex_gui_dialog_height), TYPE_INT},
|
{"gui_dialog_height", P_OFFINT (hex_gui_dialog_height), TYPE_INT},
|
||||||
{"gui_dialog_left", P_OFFINT (hex_gui_dialog_left), TYPE_INT},
|
{"gui_dialog_left", P_OFFINT (hex_gui_dialog_left), TYPE_INT},
|
||||||
@@ -466,6 +469,8 @@ const struct prefs vars[] =
|
|||||||
{"gui_ulist_hide", P_OFFINT (hex_gui_ulist_hide), TYPE_BOOL},
|
{"gui_ulist_hide", P_OFFINT (hex_gui_ulist_hide), TYPE_BOOL},
|
||||||
{"gui_ulist_icons", P_OFFINT (hex_gui_ulist_icons), TYPE_BOOL},
|
{"gui_ulist_icons", P_OFFINT (hex_gui_ulist_icons), TYPE_BOOL},
|
||||||
{"gui_ulist_pos", P_OFFINT (hex_gui_ulist_pos), TYPE_INT},
|
{"gui_ulist_pos", P_OFFINT (hex_gui_ulist_pos), TYPE_INT},
|
||||||
|
{"gui_ulist_nick_width", P_OFFINT (hex_gui_ulist_nick_width), TYPE_INT},
|
||||||
|
{"gui_ulist_host_width", P_OFFINT (hex_gui_ulist_host_width), TYPE_INT},
|
||||||
{"gui_ulist_show_hosts", P_OFFINT(hex_gui_ulist_show_hosts), TYPE_BOOL},
|
{"gui_ulist_show_hosts", P_OFFINT(hex_gui_ulist_show_hosts), TYPE_BOOL},
|
||||||
{"gui_ulist_sort", P_OFFINT (hex_gui_ulist_sort), TYPE_INT},
|
{"gui_ulist_sort", P_OFFINT (hex_gui_ulist_sort), TYPE_INT},
|
||||||
{"gui_ulist_style", P_OFFINT (hex_gui_ulist_style), TYPE_BOOL},
|
{"gui_ulist_style", P_OFFINT (hex_gui_ulist_style), TYPE_BOOL},
|
||||||
@@ -824,6 +829,9 @@ load_default_config(void)
|
|||||||
prefs.hex_flood_msg_time = 30;
|
prefs.hex_flood_msg_time = 30;
|
||||||
prefs.hex_gui_chanlist_maxusers = 9999;
|
prefs.hex_gui_chanlist_maxusers = 9999;
|
||||||
prefs.hex_gui_chanlist_minusers = 5;
|
prefs.hex_gui_chanlist_minusers = 5;
|
||||||
|
prefs.hex_gui_chanlist_width_channel = 0;
|
||||||
|
prefs.hex_gui_chanlist_width_topic = 0;
|
||||||
|
prefs.hex_gui_chanlist_width_users = 0;
|
||||||
prefs.hex_gui_dialog_height = 256;
|
prefs.hex_gui_dialog_height = 256;
|
||||||
prefs.hex_gui_dialog_width = 500;
|
prefs.hex_gui_dialog_width = 500;
|
||||||
prefs.hex_gui_lagometer = 1;
|
prefs.hex_gui_lagometer = 1;
|
||||||
@@ -837,6 +845,8 @@ load_default_config(void)
|
|||||||
prefs.hex_gui_tab_trunc = 20;
|
prefs.hex_gui_tab_trunc = 20;
|
||||||
prefs.hex_gui_throttlemeter = 1;
|
prefs.hex_gui_throttlemeter = 1;
|
||||||
prefs.hex_gui_ulist_pos = 3;
|
prefs.hex_gui_ulist_pos = 3;
|
||||||
|
prefs.hex_gui_ulist_nick_width = 0;
|
||||||
|
prefs.hex_gui_ulist_host_width = 0;
|
||||||
prefs.hex_gui_win_height = 400;
|
prefs.hex_gui_win_height = 400;
|
||||||
prefs.hex_gui_win_width = 640;
|
prefs.hex_gui_win_width = 640;
|
||||||
prefs.hex_irc_ban_type = 1;
|
prefs.hex_irc_ban_type = 1;
|
||||||
@@ -1009,15 +1019,51 @@ load_config (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
save_config (void)
|
save_config_write_to_fd (int fh)
|
||||||
{
|
{
|
||||||
int fh, i;
|
int i;
|
||||||
char *config, *new_config;
|
|
||||||
|
if (!cfg_put_str (fh, "version", PACKAGE_VERSION))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
switch (vars[i].type)
|
||||||
|
{
|
||||||
|
case TYPE_STR:
|
||||||
|
if (!cfg_put_str (fh, vars[i].name, (char *) &prefs + vars[i].offset))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case TYPE_INT:
|
||||||
|
case TYPE_BOOL:
|
||||||
|
if (!cfg_put_int (fh, *((int *) &prefs + vars[i].offset), vars[i].name))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vars[i].after_update != NULL)
|
||||||
|
vars[i].after_update();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while (vars[i].name);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
save_config_prepare (char **temp_path)
|
||||||
|
{
|
||||||
|
int fh;
|
||||||
|
char *config;
|
||||||
|
char *new_config;
|
||||||
|
|
||||||
if (check_config_dir () != 0)
|
if (check_config_dir () != 0)
|
||||||
make_config_dirs ();
|
make_config_dirs ();
|
||||||
|
|
||||||
|
if (!temp_path)
|
||||||
|
return 0;
|
||||||
|
|
||||||
config = default_file ();
|
config = default_file ();
|
||||||
new_config = g_strconcat (config, ".new", NULL);
|
new_config = g_strconcat (config, ".new", NULL);
|
||||||
|
|
||||||
@@ -1028,63 +1074,67 @@ save_config (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cfg_put_str (fh, "version", PACKAGE_VERSION))
|
if (!save_config_write_to_fd (fh))
|
||||||
{
|
{
|
||||||
close (fh);
|
close (fh);
|
||||||
g_free (new_config);
|
g_free (new_config);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
switch (vars[i].type)
|
|
||||||
{
|
|
||||||
case TYPE_STR:
|
|
||||||
if (!cfg_put_str (fh, vars[i].name, (char *) &prefs + vars[i].offset))
|
|
||||||
{
|
|
||||||
close (fh);
|
|
||||||
g_free (new_config);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TYPE_INT:
|
|
||||||
case TYPE_BOOL:
|
|
||||||
if (!cfg_put_int (fh, *((int *) &prefs + vars[i].offset), vars[i].name))
|
|
||||||
{
|
|
||||||
close (fh);
|
|
||||||
g_free (new_config);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vars[i].after_update != NULL)
|
|
||||||
{
|
|
||||||
vars[i].after_update();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
while (vars[i].name);
|
|
||||||
|
|
||||||
if (close (fh) == -1)
|
if (close (fh) == -1)
|
||||||
{
|
{
|
||||||
g_free (new_config);
|
g_free (new_config);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
*temp_path = new_config;
|
||||||
g_unlink (config); /* win32 can't rename to an existing file */
|
return 1;
|
||||||
#endif
|
}
|
||||||
if (g_rename (new_config, config) == -1)
|
|
||||||
{
|
int
|
||||||
g_free (new_config);
|
save_config_finalize (const char *temp_path)
|
||||||
|
{
|
||||||
|
char *config;
|
||||||
|
|
||||||
|
if (!temp_path)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
config = default_file ();
|
||||||
|
#ifdef WIN32
|
||||||
|
g_unlink (config);
|
||||||
|
#endif
|
||||||
|
if (g_rename (temp_path, config) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
g_free (new_config);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
save_config_discard (const char *temp_path)
|
||||||
|
{
|
||||||
|
if (!temp_path)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_unlink (temp_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
save_config (void)
|
||||||
|
{
|
||||||
|
char *temp_path = NULL;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
if (!save_config_prepare (&temp_path))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
result = save_config_finalize (temp_path);
|
||||||
|
if (!result)
|
||||||
|
save_config_discard (temp_path);
|
||||||
|
g_free (temp_path);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_showval (session *sess, const struct prefs *var, char *tbuf)
|
set_showval (session *sess, const struct prefs *var, char *tbuf)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ int make_config_dirs (void);
|
|||||||
int make_dcc_dirs (void);
|
int make_dcc_dirs (void);
|
||||||
int load_config (void);
|
int load_config (void);
|
||||||
int save_config (void);
|
int save_config (void);
|
||||||
|
int save_config_prepare (char **temp_path);
|
||||||
|
int save_config_finalize (const char *temp_path);
|
||||||
|
void save_config_discard (const char *temp_path);
|
||||||
void list_free (GSList ** list);
|
void list_free (GSList ** list);
|
||||||
void list_loadconf (char *file, GSList ** list, char *defaultconf);
|
void list_loadconf (char *file, GSList ** list, char *defaultconf);
|
||||||
int list_delentry (GSList ** list, char *name);
|
int list_delentry (GSList ** list, char *name);
|
||||||
|
|||||||
@@ -44,11 +44,20 @@ typedef struct
|
|||||||
char *icon; /* filename */
|
char *icon; /* filename */
|
||||||
} menu_entry;
|
} menu_entry;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gboolean success;
|
||||||
|
gboolean partial_failure;
|
||||||
|
gboolean config_failed;
|
||||||
|
gboolean theme_failed;
|
||||||
|
} fe_preferences_save_result;
|
||||||
|
|
||||||
int fe_args (int argc, char *argv[]);
|
int fe_args (int argc, char *argv[]);
|
||||||
void fe_init (void);
|
void fe_init (void);
|
||||||
void fe_main (void);
|
void fe_main (void);
|
||||||
void fe_cleanup (void);
|
void fe_cleanup (void);
|
||||||
void fe_exit (void);
|
void fe_exit (void);
|
||||||
|
fe_preferences_save_result fe_preferences_persistence_save_all (void);
|
||||||
int fe_timeout_add (int interval, void *callback, void *userdata);
|
int fe_timeout_add (int interval, void *callback, void *userdata);
|
||||||
int fe_timeout_add_seconds (int interval, void *callback, void *userdata);
|
int fe_timeout_add_seconds (int interval, void *callback, void *userdata);
|
||||||
void fe_timeout_remove (int tag);
|
void fe_timeout_remove (int tag);
|
||||||
|
|||||||
@@ -292,7 +292,13 @@ match_host (const char *word, int *start, int *end)
|
|||||||
static gboolean
|
static gboolean
|
||||||
match_host6 (const char *word, int *start, int *end)
|
match_host6 (const char *word, int *start, int *end)
|
||||||
{
|
{
|
||||||
return regex_match (re_host6 (), word, start, end);
|
if (!regex_match (re_host6 (), word, start, end))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (word[*start] != '[')
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -373,40 +379,64 @@ url_last (int *lstart, int *lend)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
regex_match (const GRegex *re, const char *word, int *start, int *end)
|
match_has_valid_context (const char *word, int start, int end)
|
||||||
{
|
{
|
||||||
GMatchInfo *gmi;
|
if (start > 0)
|
||||||
|
{
|
||||||
|
char prev = word[start - 1];
|
||||||
|
if (g_ascii_isalnum ((guchar)prev) || prev == '_' || prev == '-')
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
g_regex_match (re, word, 0, &gmi);
|
if (word[end] != '\0')
|
||||||
|
|
||||||
if (!g_match_info_matches (gmi))
|
|
||||||
{
|
{
|
||||||
g_match_info_free (gmi);
|
char next = word[end];
|
||||||
return FALSE;
|
if (g_ascii_isalnum ((guchar)next) || next == '_')
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (g_match_info_matches (gmi))
|
|
||||||
{
|
|
||||||
g_match_info_fetch_pos (gmi, 0, start, end);
|
|
||||||
g_match_info_next (gmi, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_match_info_free (gmi);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
regex_match (const GRegex *re, const char *word, int *start, int *end)
|
||||||
|
{
|
||||||
|
GMatchInfo *gmi;
|
||||||
|
gboolean found = FALSE;
|
||||||
|
int mstart;
|
||||||
|
int mend;
|
||||||
|
|
||||||
|
g_regex_match (re, word, 0, &gmi);
|
||||||
|
|
||||||
|
while (g_match_info_matches (gmi))
|
||||||
|
{
|
||||||
|
g_match_info_fetch_pos (gmi, 0, &mstart, &mend);
|
||||||
|
if (match_has_valid_context (word, mstart, mend))
|
||||||
|
{
|
||||||
|
*start = mstart;
|
||||||
|
*end = mend;
|
||||||
|
found = TRUE;
|
||||||
|
}
|
||||||
|
g_match_info_next (gmi, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_match_info_free (gmi);
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
/* Miscellaneous description --- */
|
/* Miscellaneous description --- */
|
||||||
#define DOMAIN "[_\\pL\\pN\\pS][-_\\pL\\pN\\pS]*(\\.[-_\\pL\\pN\\pS]+)*"
|
#define DOMAIN_LABEL "[\\pL\\pN](?:[-\\pL\\pN]{0,61}[\\pL\\pN])?"
|
||||||
#define TLD "\\.[\\pL][-\\pL\\pN]*[\\pL]"
|
#define DOMAIN DOMAIN_LABEL "(\\." DOMAIN_LABEL ")*"
|
||||||
#define IPADDR "[0-9]{1,3}(\\.[0-9]{1,3}){3}"
|
#define TLD "\\.[\\pL](?:[-\\pL\\pN]*[\\pL\\pN])?"
|
||||||
|
#define IPADDR "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}"
|
||||||
#define IPV6GROUP "([0-9a-f]{0,4})"
|
#define IPV6GROUP "([0-9a-f]{0,4})"
|
||||||
#define IPV6ADDR "((" IPV6GROUP "(:" IPV6GROUP "){7})" \
|
#define IPV6ADDR "((" IPV6GROUP "(:" IPV6GROUP "){7})" \
|
||||||
"|(" IPV6GROUP "(:" IPV6GROUP ")*:(:" IPV6GROUP ")+))" /* with :: compression */
|
"|(" IPV6GROUP "(:" IPV6GROUP ")*:(:" IPV6GROUP ")+))" /* with :: compression */
|
||||||
#define HOST "(" DOMAIN TLD "|" IPADDR "|" IPV6ADDR ")"
|
#define HOST "(" DOMAIN TLD "|" IPADDR "|" IPV6ADDR ")"
|
||||||
/* In urls the IPv6 must be enclosed in square brackets */
|
/* In urls the IPv6 must be enclosed in square brackets */
|
||||||
#define HOST_URL "(" DOMAIN TLD "|" IPADDR "|" "\\[" IPV6ADDR "\\]" ")"
|
#define HOST_URL "(" DOMAIN TLD "|" IPADDR "|" "\\[" IPV6ADDR "\\]" ")"
|
||||||
#define HOST_URL_OPT_TLD "(" DOMAIN "|" HOST_URL ")"
|
#define HOST_URL_OPT_TLD HOST_URL
|
||||||
#define PORT "(:[1-9][0-9]{0,4})"
|
#define PORT "(:[1-9][0-9]{0,4})"
|
||||||
#define OPT_PORT "(" PORT ")?"
|
#define OPT_PORT "(" PORT ")?"
|
||||||
|
|
||||||
|
|||||||
@@ -1104,7 +1104,18 @@ zoitechat_exit (void)
|
|||||||
plugin_kill_all ();
|
plugin_kill_all ();
|
||||||
fe_cleanup ();
|
fe_cleanup ();
|
||||||
|
|
||||||
save_config ();
|
{
|
||||||
|
fe_preferences_save_result save_result;
|
||||||
|
|
||||||
|
save_result = fe_preferences_persistence_save_all ();
|
||||||
|
if (!save_result.success)
|
||||||
|
{
|
||||||
|
if (save_result.partial_failure || (!save_result.config_failed && save_result.theme_failed))
|
||||||
|
g_printerr ("Could not fully save preferences. zoitechat.conf was written, but colors.conf failed.\n");
|
||||||
|
else
|
||||||
|
g_printerr ("Could not save zoitechat.conf.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (prefs.save_pevents)
|
if (prefs.save_pevents)
|
||||||
{
|
{
|
||||||
pevent_save (NULL);
|
pevent_save (NULL);
|
||||||
|
|||||||
@@ -248,6 +248,9 @@ struct zoitechatprefs
|
|||||||
int hex_flood_msg_time;
|
int hex_flood_msg_time;
|
||||||
int hex_gui_chanlist_maxusers;
|
int hex_gui_chanlist_maxusers;
|
||||||
int hex_gui_chanlist_minusers;
|
int hex_gui_chanlist_minusers;
|
||||||
|
int hex_gui_chanlist_width_channel;
|
||||||
|
int hex_gui_chanlist_width_topic;
|
||||||
|
int hex_gui_chanlist_width_users;
|
||||||
int hex_gui_dialog_height;
|
int hex_gui_dialog_height;
|
||||||
int hex_gui_dialog_left;
|
int hex_gui_dialog_left;
|
||||||
int hex_gui_dialog_top;
|
int hex_gui_dialog_top;
|
||||||
@@ -269,6 +272,8 @@ struct zoitechatprefs
|
|||||||
int hex_gui_transparency;
|
int hex_gui_transparency;
|
||||||
int hex_gui_throttlemeter;
|
int hex_gui_throttlemeter;
|
||||||
int hex_gui_ulist_pos;
|
int hex_gui_ulist_pos;
|
||||||
|
int hex_gui_ulist_nick_width;
|
||||||
|
int hex_gui_ulist_host_width;
|
||||||
int hex_gui_ulist_sort;
|
int hex_gui_ulist_sort;
|
||||||
int hex_gui_url_mod;
|
int hex_gui_url_mod;
|
||||||
int hex_gui_win_height;
|
int hex_gui_win_height;
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ ascii_open (void)
|
|||||||
gtk_widget_set_size_request (but, 28, -1);
|
gtk_widget_set_size_request (but, 28, -1);
|
||||||
g_signal_connect (G_OBJECT (but), "clicked",
|
g_signal_connect (G_OBJECT (but), "clicked",
|
||||||
G_CALLBACK (ascii_click), NULL);
|
G_CALLBACK (ascii_click), NULL);
|
||||||
g_signal_connect (G_OBJECT (but), "enter_notify_event",
|
g_signal_connect (G_OBJECT (but), "enter-notify-event",
|
||||||
G_CALLBACK (ascii_enter), label);
|
G_CALLBACK (ascii_enter), label);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), but, 0, 0, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), but, 0, 0, 0);
|
||||||
gtk_widget_show (but);
|
gtk_widget_show (but);
|
||||||
|
|||||||
@@ -74,6 +74,19 @@ chanlistrow;
|
|||||||
|
|
||||||
#define GET_MODEL(xserv) (gtk_tree_view_get_model(GTK_TREE_VIEW(xserv->gui->chanlist_list)))
|
#define GET_MODEL(xserv) (gtk_tree_view_get_model(GTK_TREE_VIEW(xserv->gui->chanlist_list)))
|
||||||
|
|
||||||
|
#define CHANLIST_COL_WIDTH_MIN_CHANNEL 60
|
||||||
|
#define CHANLIST_COL_WIDTH_MIN_USERS 40
|
||||||
|
#define CHANLIST_COL_WIDTH_MIN_TOPIC 60
|
||||||
|
|
||||||
|
static int
|
||||||
|
chanlist_clamp_width (int width, int min_width)
|
||||||
|
{
|
||||||
|
if (width < min_width)
|
||||||
|
return min_width;
|
||||||
|
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chanlist_set_label_alignment (GtkWidget *widget)
|
chanlist_set_label_alignment (GtkWidget *widget)
|
||||||
{
|
{
|
||||||
@@ -508,36 +521,72 @@ chanlist_match_topic_button_toggled (GtkWidget * wid, server *serv)
|
|||||||
serv->gui->chanlist_match_wants_topic = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (wid));
|
serv->gui->chanlist_match_wants_topic = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (wid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GSList *
|
||||||
|
chanlist_get_selection (server *serv, int column)
|
||||||
|
{
|
||||||
|
GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (serv->gui->chanlist_list));
|
||||||
|
GtkTreeModel *model = GET_MODEL (serv);
|
||||||
|
GList *rows;
|
||||||
|
GList *cur;
|
||||||
|
GSList *result = NULL;
|
||||||
|
|
||||||
|
rows = gtk_tree_selection_get_selected_rows (sel, &model);
|
||||||
|
for (cur = rows; cur != NULL; cur = cur->next)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
char *value;
|
||||||
|
|
||||||
|
if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *)cur->data))
|
||||||
|
{
|
||||||
|
gtk_tree_model_get (model, &iter, column, &value, -1);
|
||||||
|
result = g_slist_prepend (result, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free_full (rows, (GDestroyNotify) gtk_tree_path_free);
|
||||||
|
return g_slist_reverse (result);
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
chanlist_get_selected (server *serv, gboolean get_topic)
|
chanlist_get_selected (server *serv, gboolean get_topic)
|
||||||
{
|
{
|
||||||
char *chan;
|
GSList *selection = chanlist_get_selection (serv, get_topic ? COL_TOPIC : COL_CHANNEL);
|
||||||
GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (serv->gui->chanlist_list));
|
char *value;
|
||||||
GtkTreeModel *model;
|
|
||||||
GtkTreeIter iter;
|
|
||||||
|
|
||||||
if (!gtk_tree_selection_get_selected (sel, &model, &iter))
|
if (!selection)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
gtk_tree_model_get (model, &iter, get_topic ? COL_TOPIC : COL_CHANNEL, &chan, -1);
|
value = selection->data;
|
||||||
return chan;
|
selection->data = NULL;
|
||||||
|
g_slist_free_full (selection, g_free);
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chanlist_join (GtkWidget * wid, server *serv)
|
chanlist_join (GtkWidget * wid, server *serv)
|
||||||
{
|
{
|
||||||
char tbuf[CHANLEN + 6];
|
char tbuf[CHANLEN + 6];
|
||||||
char *chan = chanlist_get_selected (serv, FALSE);
|
GSList *selection;
|
||||||
if (chan)
|
GSList *item;
|
||||||
|
gboolean joined = FALSE;
|
||||||
|
|
||||||
|
selection = chanlist_get_selection (serv, COL_CHANNEL);
|
||||||
|
for (item = selection; item != NULL; item = item->next)
|
||||||
{
|
{
|
||||||
if (serv->connected && (strcmp (chan, "*") != 0))
|
char *chan = item->data;
|
||||||
|
|
||||||
|
if (serv->connected && strcmp (chan, "*") != 0)
|
||||||
{
|
{
|
||||||
g_snprintf (tbuf, sizeof (tbuf), "join %s", chan);
|
g_snprintf (tbuf, sizeof (tbuf), "join %s", chan);
|
||||||
handle_command (serv->server_session, tbuf, FALSE);
|
handle_command (serv->server_session, tbuf, FALSE);
|
||||||
} else
|
joined = TRUE;
|
||||||
gdk_display_beep (gdk_display_get_default ());
|
}
|
||||||
g_free (chan);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!joined && selection)
|
||||||
|
gdk_display_beep (gdk_display_get_default ());
|
||||||
|
|
||||||
|
g_slist_free_full (selection, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -614,7 +663,8 @@ chanlist_minusers (GtkSpinButton *wid, server *serv)
|
|||||||
{
|
{
|
||||||
serv->gui->chanlist_minusers = gtk_spin_button_get_value_as_int (wid);
|
serv->gui->chanlist_minusers = gtk_spin_button_get_value_as_int (wid);
|
||||||
prefs.hex_gui_chanlist_minusers = serv->gui->chanlist_minusers;
|
prefs.hex_gui_chanlist_minusers = serv->gui->chanlist_minusers;
|
||||||
save_config();
|
if (!save_config ())
|
||||||
|
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||||
|
|
||||||
if (serv->gui->chanlist_minusers < serv->gui->chanlist_minusers_downloaded)
|
if (serv->gui->chanlist_minusers < serv->gui->chanlist_minusers_downloaded)
|
||||||
{
|
{
|
||||||
@@ -636,7 +686,8 @@ chanlist_maxusers (GtkSpinButton *wid, server *serv)
|
|||||||
{
|
{
|
||||||
serv->gui->chanlist_maxusers = gtk_spin_button_get_value_as_int (wid);
|
serv->gui->chanlist_maxusers = gtk_spin_button_get_value_as_int (wid);
|
||||||
prefs.hex_gui_chanlist_maxusers = serv->gui->chanlist_maxusers;
|
prefs.hex_gui_chanlist_maxusers = serv->gui->chanlist_maxusers;
|
||||||
save_config();
|
if (!save_config ())
|
||||||
|
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -656,23 +707,47 @@ chanlist_menu_destroy (GtkWidget *menu, gpointer userdata)
|
|||||||
static void
|
static void
|
||||||
chanlist_copychannel (GtkWidget *item, server *serv)
|
chanlist_copychannel (GtkWidget *item, server *serv)
|
||||||
{
|
{
|
||||||
char *chan = chanlist_get_selected (serv, FALSE);
|
GSList *selection = chanlist_get_selection (serv, COL_CHANNEL);
|
||||||
if (chan)
|
GSList *cur;
|
||||||
|
GString *text;
|
||||||
|
|
||||||
|
if (!selection)
|
||||||
|
return;
|
||||||
|
|
||||||
|
text = g_string_new ("");
|
||||||
|
for (cur = selection; cur != NULL; cur = cur->next)
|
||||||
{
|
{
|
||||||
gtkutil_copy_to_clipboard (item, NULL, chan);
|
if (text->len)
|
||||||
g_free (chan);
|
g_string_append_c (text, '\n');
|
||||||
|
g_string_append (text, (char *)cur->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtkutil_copy_to_clipboard (item, NULL, text->str);
|
||||||
|
g_string_free (text, TRUE);
|
||||||
|
g_slist_free_full (selection, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chanlist_copytopic (GtkWidget *item, server *serv)
|
chanlist_copytopic (GtkWidget *item, server *serv)
|
||||||
{
|
{
|
||||||
char *topic = chanlist_get_selected (serv, TRUE);
|
GSList *selection = chanlist_get_selection (serv, COL_TOPIC);
|
||||||
if (topic)
|
GSList *cur;
|
||||||
|
GString *text;
|
||||||
|
|
||||||
|
if (!selection)
|
||||||
|
return;
|
||||||
|
|
||||||
|
text = g_string_new ("");
|
||||||
|
for (cur = selection; cur != NULL; cur = cur->next)
|
||||||
{
|
{
|
||||||
gtkutil_copy_to_clipboard (item, NULL, topic);
|
if (text->len)
|
||||||
g_free (topic);
|
g_string_append_c (text, '\n');
|
||||||
|
g_string_append (text, (char *)cur->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtkutil_copy_to_clipboard (item, NULL, text->str);
|
||||||
|
g_string_free (text, TRUE);
|
||||||
|
g_slist_free_full (selection, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -689,10 +764,12 @@ chanlist_button_cb (GtkTreeView *tree, GdkEventButton *event, server *serv)
|
|||||||
if (!gtk_tree_view_get_path_at_pos (tree, event->x, event->y, &path, 0, 0, 0))
|
if (!gtk_tree_view_get_path_at_pos (tree, event->x, event->y, &path, 0, 0, 0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* select what they right-clicked on */
|
|
||||||
sel = gtk_tree_view_get_selection (tree);
|
sel = gtk_tree_view_get_selection (tree);
|
||||||
gtk_tree_selection_unselect_all (sel);
|
if (!gtk_tree_selection_path_is_selected (sel, path))
|
||||||
gtk_tree_selection_select_path (sel, path);
|
{
|
||||||
|
gtk_tree_selection_unselect_all (sel);
|
||||||
|
gtk_tree_selection_select_path (sel, path);
|
||||||
|
}
|
||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
|
|
||||||
menu = gtk_menu_new ();
|
menu = gtk_menu_new ();
|
||||||
@@ -741,6 +818,26 @@ chanlist_button_cb (GtkTreeView *tree, GdkEventButton *event, server *serv)
|
|||||||
static void
|
static void
|
||||||
chanlist_destroy_widget (GtkWidget *wid, server *serv)
|
chanlist_destroy_widget (GtkWidget *wid, server *serv)
|
||||||
{
|
{
|
||||||
|
GtkTreeViewColumn *column;
|
||||||
|
|
||||||
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (serv->gui->chanlist_list), COL_CHANNEL);
|
||||||
|
if (column)
|
||||||
|
prefs.hex_gui_chanlist_width_channel =
|
||||||
|
chanlist_clamp_width (gtk_tree_view_column_get_width (column), CHANLIST_COL_WIDTH_MIN_CHANNEL);
|
||||||
|
|
||||||
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (serv->gui->chanlist_list), COL_USERS);
|
||||||
|
if (column)
|
||||||
|
prefs.hex_gui_chanlist_width_users =
|
||||||
|
chanlist_clamp_width (gtk_tree_view_column_get_width (column), CHANLIST_COL_WIDTH_MIN_USERS);
|
||||||
|
|
||||||
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (serv->gui->chanlist_list), COL_TOPIC);
|
||||||
|
if (column)
|
||||||
|
prefs.hex_gui_chanlist_width_topic =
|
||||||
|
chanlist_clamp_width (gtk_tree_view_column_get_width (column), CHANLIST_COL_WIDTH_MIN_TOPIC);
|
||||||
|
|
||||||
|
if (!save_config ())
|
||||||
|
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||||
|
|
||||||
custom_list_clear ((CustomList *)GET_MODEL (serv));
|
custom_list_clear ((CustomList *)GET_MODEL (serv));
|
||||||
chanlist_data_free (serv);
|
chanlist_data_free (serv);
|
||||||
|
|
||||||
@@ -831,7 +928,8 @@ chanlist_opengui (server *serv, int do_refresh)
|
|||||||
if (prefs.hex_gui_chanlist_minusers < 1 || prefs.hex_gui_chanlist_minusers > 999999)
|
if (prefs.hex_gui_chanlist_minusers < 1 || prefs.hex_gui_chanlist_minusers > 999999)
|
||||||
{
|
{
|
||||||
prefs.hex_gui_chanlist_minusers = 5;
|
prefs.hex_gui_chanlist_minusers = 5;
|
||||||
save_config();
|
if (!save_config ())
|
||||||
|
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
serv->gui->chanlist_minusers = prefs.hex_gui_chanlist_minusers;
|
serv->gui->chanlist_minusers = prefs.hex_gui_chanlist_minusers;
|
||||||
@@ -842,7 +940,8 @@ chanlist_opengui (server *serv, int do_refresh)
|
|||||||
if (prefs.hex_gui_chanlist_maxusers < 1 || prefs.hex_gui_chanlist_maxusers > 999999)
|
if (prefs.hex_gui_chanlist_maxusers < 1 || prefs.hex_gui_chanlist_maxusers > 999999)
|
||||||
{
|
{
|
||||||
prefs.hex_gui_chanlist_maxusers = 9999;
|
prefs.hex_gui_chanlist_maxusers = 9999;
|
||||||
save_config();
|
if (!save_config ())
|
||||||
|
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
serv->gui->chanlist_maxusers = prefs.hex_gui_chanlist_maxusers;
|
serv->gui->chanlist_maxusers = prefs.hex_gui_chanlist_maxusers;
|
||||||
@@ -870,7 +969,7 @@ chanlist_opengui (server *serv, int do_refresh)
|
|||||||
GTK_SHADOW_IN);
|
GTK_SHADOW_IN);
|
||||||
serv->gui->chanlist_list = view;
|
serv->gui->chanlist_list = view;
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (view), "row_activated",
|
g_signal_connect (G_OBJECT (view), "row-activated",
|
||||||
G_CALLBACK (chanlist_dclick_cb), serv);
|
G_CALLBACK (chanlist_dclick_cb), serv);
|
||||||
g_signal_connect (G_OBJECT (view), "button-press-event",
|
g_signal_connect (G_OBJECT (view), "button-press-event",
|
||||||
G_CALLBACK (chanlist_button_cb), serv);
|
G_CALLBACK (chanlist_button_cb), serv);
|
||||||
@@ -878,7 +977,39 @@ chanlist_opengui (server *serv, int do_refresh)
|
|||||||
chanlist_add_column (view, COL_CHANNEL, 96, _("Channel"), FALSE);
|
chanlist_add_column (view, COL_CHANNEL, 96, _("Channel"), FALSE);
|
||||||
chanlist_add_column (view, COL_USERS, 50, _("Users"), TRUE);
|
chanlist_add_column (view, COL_USERS, 50, _("Users"), TRUE);
|
||||||
chanlist_add_column (view, COL_TOPIC, 50, _("Topic"), FALSE);
|
chanlist_add_column (view, COL_TOPIC, 50, _("Topic"), FALSE);
|
||||||
|
|
||||||
|
if (prefs.hex_gui_chanlist_width_channel > 0)
|
||||||
|
{
|
||||||
|
GtkTreeViewColumn *column = gtk_tree_view_get_column (GTK_TREE_VIEW (view), COL_CHANNEL);
|
||||||
|
if (column)
|
||||||
|
gtk_tree_view_column_set_fixed_width (column,
|
||||||
|
chanlist_clamp_width (prefs.hex_gui_chanlist_width_channel, CHANLIST_COL_WIDTH_MIN_CHANNEL));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefs.hex_gui_chanlist_width_users > 0)
|
||||||
|
{
|
||||||
|
GtkTreeViewColumn *column = gtk_tree_view_get_column (GTK_TREE_VIEW (view), COL_USERS);
|
||||||
|
if (column)
|
||||||
|
{
|
||||||
|
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||||
|
gtk_tree_view_column_set_fixed_width (column,
|
||||||
|
chanlist_clamp_width (prefs.hex_gui_chanlist_width_users, CHANLIST_COL_WIDTH_MIN_USERS));
|
||||||
|
gtk_tree_view_column_set_resizable (column, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefs.hex_gui_chanlist_width_topic > 0)
|
||||||
|
{
|
||||||
|
GtkTreeViewColumn *column = gtk_tree_view_get_column (GTK_TREE_VIEW (view), COL_TOPIC);
|
||||||
|
if (column)
|
||||||
|
{
|
||||||
|
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||||
|
gtk_tree_view_column_set_fixed_width (column,
|
||||||
|
chanlist_clamp_width (prefs.hex_gui_chanlist_width_topic, CHANLIST_COL_WIDTH_MIN_TOPIC));
|
||||||
|
}
|
||||||
|
}
|
||||||
gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (view), GTK_TREE_VIEW_GRID_LINES_HORIZONTAL);
|
gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (view), GTK_TREE_VIEW_GRID_LINES_HORIZONTAL);
|
||||||
|
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), GTK_SELECTION_MULTIPLE);
|
||||||
/* this is a speed up, but no horizontal scrollbar :( */
|
/* this is a speed up, but no horizontal scrollbar :( */
|
||||||
/*gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW (view), TRUE);*/
|
/*gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW (view), TRUE);*/
|
||||||
gtk_widget_show (view);
|
gtk_widget_show (view);
|
||||||
@@ -936,7 +1067,7 @@ chanlist_opengui (server *serv, int do_refresh)
|
|||||||
wid = gtk_spin_button_new_with_range (1, 999999, 1);
|
wid = gtk_spin_button_new_with_range (1, 999999, 1);
|
||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (wid),
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (wid),
|
||||||
serv->gui->chanlist_minusers);
|
serv->gui->chanlist_minusers);
|
||||||
g_signal_connect (G_OBJECT (wid), "value_changed",
|
g_signal_connect (G_OBJECT (wid), "value-changed",
|
||||||
G_CALLBACK (chanlist_minusers), serv);
|
G_CALLBACK (chanlist_minusers), serv);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
|
||||||
gtk_widget_show (wid);
|
gtk_widget_show (wid);
|
||||||
@@ -949,7 +1080,7 @@ chanlist_opengui (server *serv, int do_refresh)
|
|||||||
wid = gtk_spin_button_new_with_range (1, 999999, 1);
|
wid = gtk_spin_button_new_with_range (1, 999999, 1);
|
||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (wid),
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (wid),
|
||||||
serv->gui->chanlist_maxusers);
|
serv->gui->chanlist_maxusers);
|
||||||
g_signal_connect (G_OBJECT (wid), "value_changed",
|
g_signal_connect (G_OBJECT (wid), "value-changed",
|
||||||
G_CALLBACK (chanlist_maxusers), serv);
|
G_CALLBACK (chanlist_maxusers), serv);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), wid, 0, 0, 0);
|
||||||
gtk_widget_show (wid);
|
gtk_widget_show (wid);
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ make_sbutton (GtkArrowType type, void *click_cb, void *userdata)
|
|||||||
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||||
g_signal_connect (G_OBJECT (button), "clicked",
|
g_signal_connect (G_OBJECT (button), "clicked",
|
||||||
G_CALLBACK (click_cb), userdata);
|
G_CALLBACK (click_cb), userdata);
|
||||||
g_signal_connect (G_OBJECT (button), "scroll_event",
|
g_signal_connect (G_OBJECT (button), "scroll-event",
|
||||||
G_CALLBACK (tab_scroll_cb), userdata);
|
G_CALLBACK (tab_scroll_cb), userdata);
|
||||||
gtk_widget_show (arrow);
|
gtk_widget_show (arrow);
|
||||||
|
|
||||||
@@ -395,7 +395,7 @@ cv_tabs_init (chanview *cv)
|
|||||||
outer = gtkutil_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);
|
outer = gtkutil_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);
|
||||||
}
|
}
|
||||||
((tabview *)cv)->outer = outer;
|
((tabview *)cv)->outer = outer;
|
||||||
g_signal_connect (G_OBJECT (outer), "size_allocate",
|
g_signal_connect (G_OBJECT (outer), "size-allocate",
|
||||||
G_CALLBACK (cv_tabs_sizealloc), cv);
|
G_CALLBACK (cv_tabs_sizealloc), cv);
|
||||||
gtk_widget_show (outer);
|
gtk_widget_show (outer);
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ cv_tabs_init (chanview *cv)
|
|||||||
gtk_widget_set_size_request (viewport, -1, 1);
|
gtk_widget_set_size_request (viewport, -1, 1);
|
||||||
else
|
else
|
||||||
gtk_widget_set_size_request (viewport, 1, -1);
|
gtk_widget_set_size_request (viewport, 1, -1);
|
||||||
g_signal_connect (G_OBJECT (viewport), "scroll_event",
|
g_signal_connect (G_OBJECT (viewport), "scroll-event",
|
||||||
G_CALLBACK (tab_scroll_cb), cv);
|
G_CALLBACK (tab_scroll_cb), cv);
|
||||||
gtk_box_pack_start (GTK_BOX (outer), viewport, 1, 1, 0);
|
gtk_box_pack_start (GTK_BOX (outer), viewport, 1, 1, 0);
|
||||||
gtk_widget_show (viewport);
|
gtk_widget_show (viewport);
|
||||||
@@ -671,12 +671,12 @@ cv_tabs_add (chanview *cv, chan *ch, char *name, GtkTreeIter *parent)
|
|||||||
gtk_widget_set_name (but, "zoitechat-tab");
|
gtk_widget_set_name (but, "zoitechat-tab");
|
||||||
g_object_set_data (G_OBJECT (but), "c", ch);
|
g_object_set_data (G_OBJECT (but), "c", ch);
|
||||||
/* used to trap right-clicks */
|
/* used to trap right-clicks */
|
||||||
g_signal_connect (G_OBJECT (but), "button_press_event",
|
g_signal_connect (G_OBJECT (but), "button-press-event",
|
||||||
G_CALLBACK (tab_click_cb), ch);
|
G_CALLBACK (tab_click_cb), ch);
|
||||||
/* avoid prelights */
|
/* avoid prelights */
|
||||||
g_signal_connect (G_OBJECT (but), "enter_notify_event",
|
g_signal_connect (G_OBJECT (but), "enter-notify-event",
|
||||||
G_CALLBACK (tab_ignore_cb), NULL);
|
G_CALLBACK (tab_ignore_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (but), "leave_notify_event",
|
g_signal_connect (G_OBJECT (but), "leave-notify-event",
|
||||||
G_CALLBACK (tab_ignore_cb), NULL);
|
G_CALLBACK (tab_ignore_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (but), "pressed",
|
g_signal_connect (G_OBJECT (but), "pressed",
|
||||||
G_CALLBACK (tab_pressed_cb), ch);
|
G_CALLBACK (tab_pressed_cb), ch);
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ cv_tree_init (chanview *cv)
|
|||||||
GTK_SHADOW_IN);
|
GTK_SHADOW_IN);
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (win),
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (win),
|
||||||
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||||
|
gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (win), 1);
|
||||||
gtk_container_add (GTK_CONTAINER (cv->box), win);
|
gtk_container_add (GTK_CONTAINER (cv->box), win);
|
||||||
gtk_widget_show (win);
|
gtk_widget_show (win);
|
||||||
|
|
||||||
@@ -165,30 +166,32 @@ cv_tree_init (chanview *cv)
|
|||||||
gtk_container_add (GTK_CONTAINER (win), view);
|
gtk_container_add (GTK_CONTAINER (win), view);
|
||||||
col = gtk_tree_view_column_new();
|
col = gtk_tree_view_column_new();
|
||||||
|
|
||||||
/* icon column */
|
|
||||||
if (cv->use_icons)
|
if (cv->use_icons)
|
||||||
{
|
{
|
||||||
renderer = gtk_cell_renderer_pixbuf_new ();
|
renderer = gtk_cell_renderer_pixbuf_new ();
|
||||||
if (prefs.hex_gui_compact)
|
if (prefs.hex_gui_compact)
|
||||||
g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);
|
g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);
|
||||||
|
|
||||||
gtk_tree_view_column_pack_start(col, renderer, FALSE);
|
gtk_tree_view_column_pack_start (col, renderer, FALSE);
|
||||||
gtk_tree_view_column_set_attributes (col, renderer, "pixbuf", COL_PIXBUF, NULL);
|
gtk_tree_view_column_set_attributes (col, renderer, "pixbuf", COL_PIXBUF, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* main column */
|
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
if (prefs.hex_gui_compact)
|
if (prefs.hex_gui_compact)
|
||||||
g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);
|
g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);
|
||||||
|
g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
||||||
gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1);
|
gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1);
|
||||||
gtk_tree_view_column_pack_start(col, renderer, TRUE);
|
gtk_tree_view_column_pack_start (col, renderer, TRUE);
|
||||||
gtk_tree_view_column_set_attributes (col, renderer,
|
gtk_tree_view_column_set_attributes (col, renderer,
|
||||||
"text", COL_NAME,
|
"text", COL_NAME,
|
||||||
"attributes", COL_ATTR,
|
"attributes", COL_ATTR,
|
||||||
"underline", COL_UNDERLINE,
|
"underline", COL_UNDERLINE,
|
||||||
NULL);
|
NULL);
|
||||||
gtk_tree_view_column_set_expand (col, TRUE);
|
gtk_tree_view_column_set_expand (col, TRUE);
|
||||||
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
|
gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
|
||||||
|
gtk_tree_view_column_set_min_width (col, 1);
|
||||||
|
gtk_tree_view_append_column (GTK_TREE_VIEW (view), col);
|
||||||
|
gtk_tree_view_set_expander_column (GTK_TREE_VIEW (view), col);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (view))),
|
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (view))),
|
||||||
"changed", G_CALLBACK (cv_tree_sel_cb), cv);
|
"changed", G_CALLBACK (cv_tree_sel_cb), cv);
|
||||||
@@ -196,20 +199,20 @@ cv_tree_init (chanview *cv)
|
|||||||
G_CALLBACK (cv_tree_click_cb), cv);
|
G_CALLBACK (cv_tree_click_cb), cv);
|
||||||
g_signal_connect (G_OBJECT (view), "row-activated",
|
g_signal_connect (G_OBJECT (view), "row-activated",
|
||||||
G_CALLBACK (cv_tree_activated_cb), NULL);
|
G_CALLBACK (cv_tree_activated_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (view), "scroll_event",
|
g_signal_connect (G_OBJECT (view), "scroll-event",
|
||||||
G_CALLBACK (cv_tree_scroll_event_cb), NULL);
|
G_CALLBACK (cv_tree_scroll_event_cb), NULL);
|
||||||
|
|
||||||
gtk_drag_dest_set (view, GTK_DEST_DEFAULT_ALL, dnd_dest_target, 1,
|
gtk_drag_dest_set (view, GTK_DEST_DEFAULT_ALL, dnd_dest_target, 1,
|
||||||
GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
|
GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
|
||||||
gtk_drag_source_set (view, GDK_BUTTON1_MASK, dnd_src_target, 1, GDK_ACTION_COPY);
|
gtk_drag_source_set (view, GDK_BUTTON1_MASK, dnd_src_target, 1, GDK_ACTION_COPY);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (view), "drag_begin",
|
g_signal_connect (G_OBJECT (view), "drag-begin",
|
||||||
G_CALLBACK (mg_drag_begin_cb), NULL);
|
G_CALLBACK (mg_drag_begin_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (view), "drag_drop",
|
g_signal_connect (G_OBJECT (view), "drag-drop",
|
||||||
G_CALLBACK (mg_drag_drop_cb), NULL);
|
G_CALLBACK (mg_drag_drop_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (view), "drag_motion",
|
g_signal_connect (G_OBJECT (view), "drag-motion",
|
||||||
G_CALLBACK (mg_drag_motion_cb), NULL);
|
G_CALLBACK (mg_drag_motion_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (view), "drag_end",
|
g_signal_connect (G_OBJECT (view), "drag-end",
|
||||||
G_CALLBACK (mg_drag_end_cb), NULL);
|
G_CALLBACK (mg_drag_end_cb), NULL);
|
||||||
|
|
||||||
((treeview *)cv)->tree = GTK_TREE_VIEW (view);
|
((treeview *)cv)->tree = GTK_TREE_VIEW (view);
|
||||||
|
|||||||
@@ -863,7 +863,7 @@ fe_dcc_open_recv_win (int passive)
|
|||||||
gtk_tree_selection_set_mode (dccfwin.sel, GTK_SELECTION_MULTIPLE);
|
gtk_tree_selection_set_mode (dccfwin.sel, GTK_SELECTION_MULTIPLE);
|
||||||
|
|
||||||
if (!prefs.hex_gui_tab_utils)
|
if (!prefs.hex_gui_tab_utils)
|
||||||
g_signal_connect (G_OBJECT (dccfwin.window), "configure_event",
|
g_signal_connect (G_OBJECT (dccfwin.window), "configure-event",
|
||||||
G_CALLBACK (dcc_configure_cb), 0);
|
G_CALLBACK (dcc_configure_cb), 0);
|
||||||
g_signal_connect (G_OBJECT (dccfwin.sel), "changed",
|
g_signal_connect (G_OBJECT (dccfwin.sel), "changed",
|
||||||
G_CALLBACK (dcc_row_cb), NULL);
|
G_CALLBACK (dcc_row_cb), NULL);
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ editlist_treeview_new (GtkWidget *box, char *title1, char *title2)
|
|||||||
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), FALSE);
|
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (view), FALSE);
|
||||||
gtk_tree_view_set_reorderable (GTK_TREE_VIEW (view), TRUE);
|
gtk_tree_view_set_reorderable (GTK_TREE_VIEW (view), TRUE);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (view), "key_press_event",
|
g_signal_connect (G_OBJECT (view), "key-press-event",
|
||||||
G_CALLBACK (editlist_keypress), NULL);
|
G_CALLBACK (editlist_keypress), NULL);
|
||||||
|
|
||||||
gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (view), GTK_TREE_VIEW_GRID_LINES_HORIZONTAL);
|
gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (view), GTK_TREE_VIEW_GRID_LINES_HORIZONTAL);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@
|
|||||||
#include "plugin-notification.h"
|
#include "plugin-notification.h"
|
||||||
#include "theme/theme-manager.h"
|
#include "theme/theme-manager.h"
|
||||||
#include "theme/theme-application.h"
|
#include "theme/theme-application.h"
|
||||||
|
#include "preferences-persistence.h"
|
||||||
|
|
||||||
#ifdef USE_LIBCANBERRA
|
#ifdef USE_LIBCANBERRA
|
||||||
#include <canberra.h>
|
#include <canberra.h>
|
||||||
@@ -585,6 +586,21 @@ fe_cleanup (void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fe_preferences_save_result
|
||||||
|
fe_preferences_persistence_save_all (void)
|
||||||
|
{
|
||||||
|
PreferencesPersistenceResult save_result;
|
||||||
|
fe_preferences_save_result result;
|
||||||
|
|
||||||
|
save_result = preferences_persistence_save_all ();
|
||||||
|
result.success = save_result.success;
|
||||||
|
result.partial_failure = save_result.partial_failure;
|
||||||
|
result.config_failed = save_result.config_failed;
|
||||||
|
result.theme_failed = save_result.theme_failed;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fe_exit (void)
|
fe_exit (void)
|
||||||
{
|
{
|
||||||
@@ -1339,22 +1355,79 @@ fe_open_url_inner (const char *url)
|
|||||||
g_free (escaped_url);
|
g_free (escaped_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fe_open_url_is_local_path (const char *url)
|
||||||
|
{
|
||||||
|
if (g_path_is_absolute (url) || g_file_test (url, G_FILE_TEST_EXISTS))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
if (g_ascii_isalpha (url[0]) && url[1] == ':' &&
|
||||||
|
(url[2] == '\\' || url[2] == '/'))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
if (url[0] == '\\' && url[1] == '\\')
|
||||||
|
return TRUE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
fe_open_url_canonicalize_path (const char *path)
|
||||||
|
{
|
||||||
|
char *absolute_path;
|
||||||
|
char *cwd;
|
||||||
|
|
||||||
|
if (!path || path[0] == '\0')
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (g_path_is_absolute (path))
|
||||||
|
return g_strdup (path);
|
||||||
|
|
||||||
|
cwd = g_get_current_dir ();
|
||||||
|
absolute_path = g_build_filename (cwd, path, NULL);
|
||||||
|
g_free (cwd);
|
||||||
|
return absolute_path;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fe_open_url (const char *url)
|
fe_open_url (const char *url)
|
||||||
{
|
{
|
||||||
int url_type = url_check_word (url);
|
int url_type = url_check_word (url);
|
||||||
char *uri;
|
char *uri;
|
||||||
|
char *path;
|
||||||
|
char *path_uri;
|
||||||
|
|
||||||
|
if (fe_open_url_is_local_path (url))
|
||||||
|
{
|
||||||
|
path = fe_open_url_canonicalize_path (url);
|
||||||
|
path_uri = g_filename_to_uri (path, NULL, NULL);
|
||||||
|
g_free (path);
|
||||||
|
|
||||||
|
if (path_uri)
|
||||||
|
{
|
||||||
|
fe_open_url_inner (path_uri);
|
||||||
|
g_free (path_uri);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* gvfs likes file:// */
|
/* gvfs likes file:// */
|
||||||
if (url_type == WORD_PATH)
|
if (url_type == WORD_PATH)
|
||||||
{
|
{
|
||||||
#ifndef WIN32
|
path = fe_open_url_canonicalize_path (url);
|
||||||
uri = g_strconcat ("file://", url, NULL);
|
path_uri = g_filename_to_uri (path, NULL, NULL);
|
||||||
fe_open_url_inner (uri);
|
g_free (path);
|
||||||
g_free (uri);
|
if (path_uri)
|
||||||
#else
|
{
|
||||||
fe_open_url_inner (url);
|
fe_open_url_inner (path_uri);
|
||||||
#endif
|
g_free (path_uri);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fe_open_url_inner (url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* IPv6 addr. Add http:// */
|
/* IPv6 addr. Add http:// */
|
||||||
else if (url_type == WORD_HOST6)
|
else if (url_type == WORD_HOST6)
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ powershell "Get-Content -Encoding UTF8 '$(ZoiteChatLib)zoitechat.rc.utf8' | Out-
|
|||||||
<ClInclude Include="icon-resolver.h" />
|
<ClInclude Include="icon-resolver.h" />
|
||||||
<ClInclude Include="joind.h" />
|
<ClInclude Include="joind.h" />
|
||||||
<ClInclude Include="maingui.h" />
|
<ClInclude Include="maingui.h" />
|
||||||
|
<ClInclude Include="preferences-persistence.h" />
|
||||||
<ClInclude Include="menu.h" />
|
<ClInclude Include="menu.h" />
|
||||||
<ClInclude Include="notifications\notification-backend.h" />
|
<ClInclude Include="notifications\notification-backend.h" />
|
||||||
<ClInclude Include="notifygui.h" />
|
<ClInclude Include="notifygui.h" />
|
||||||
@@ -107,6 +108,7 @@ powershell "Get-Content -Encoding UTF8 '$(ZoiteChatLib)zoitechat.rc.utf8' | Out-
|
|||||||
<ClCompile Include="notifications\notification-windows.c" />
|
<ClCompile Include="notifications\notification-windows.c" />
|
||||||
<ClCompile Include="notifygui.c" />
|
<ClCompile Include="notifygui.c" />
|
||||||
<ClCompile Include="pixmaps.c" />
|
<ClCompile Include="pixmaps.c" />
|
||||||
|
<ClCompile Include="preferences-persistence.c" />
|
||||||
<ClCompile Include="plugin-notification.c" />
|
<ClCompile Include="plugin-notification.c" />
|
||||||
<ClCompile Include="plugin-tray.c" />
|
<ClCompile Include="plugin-tray.c" />
|
||||||
<ClCompile Include="plugingui.c" />
|
<ClCompile Include="plugingui.c" />
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Source Files">
|
<Filter Include="Source Files">
|
||||||
@@ -51,6 +51,9 @@
|
|||||||
<ClInclude Include="maingui.h">
|
<ClInclude Include="maingui.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="preferences-persistence.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="menu.h">
|
<ClInclude Include="menu.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -182,6 +185,9 @@
|
|||||||
<ClCompile Include="pixmaps.c">
|
<ClCompile Include="pixmaps.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="preferences-persistence.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="plugingui.c">
|
<ClCompile Include="plugingui.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ key_handle_key_press (GtkWidget *wid, GdkEventKey *evt, session *sess)
|
|||||||
return 1;
|
return 1;
|
||||||
case 2:
|
case 2:
|
||||||
g_signal_stop_emission_by_name (G_OBJECT (wid),
|
g_signal_stop_emission_by_name (G_OBJECT (wid),
|
||||||
"key_press_event");
|
"key-press-event");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -662,7 +662,7 @@ gtkutil_esc_destroy (GtkWidget * win, GdkEventKey * key, gpointer userdata)
|
|||||||
void
|
void
|
||||||
gtkutil_destroy_on_esc (GtkWidget *win)
|
gtkutil_destroy_on_esc (GtkWidget *win)
|
||||||
{
|
{
|
||||||
g_signal_connect (G_OBJECT (win), "key_press_event", G_CALLBACK (gtkutil_esc_destroy), win);
|
g_signal_connect (G_OBJECT (win), "key-press-event", G_CALLBACK (gtkutil_esc_destroy), win);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ joind_show_dialog (server *serv)
|
|||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog1), "destroy",
|
g_signal_connect (G_OBJECT (dialog1), "destroy",
|
||||||
G_CALLBACK (joind_destroy_cb), serv);
|
G_CALLBACK (joind_destroy_cb), serv);
|
||||||
g_signal_connect (G_OBJECT (entry1), "focus_in_event",
|
g_signal_connect (G_OBJECT (entry1), "focus-in-event",
|
||||||
G_CALLBACK (joind_entryfocus_cb), serv);
|
G_CALLBACK (joind_entryfocus_cb), serv);
|
||||||
g_signal_connect (G_OBJECT (entry1), "activate",
|
g_signal_connect (G_OBJECT (entry1), "activate",
|
||||||
G_CALLBACK (joind_entryenter_cb), okbutton1);
|
G_CALLBACK (joind_entryenter_cb), okbutton1);
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
#include "theme/theme-palette.h"
|
#include "theme/theme-palette.h"
|
||||||
#include "maingui.h"
|
#include "maingui.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
#include "preferences-persistence.h"
|
||||||
#include "fkeys.h"
|
#include "fkeys.h"
|
||||||
#include "userlistgui.h"
|
#include "userlistgui.h"
|
||||||
#include "chanview.h"
|
#include "chanview.h"
|
||||||
@@ -173,6 +174,81 @@ enum
|
|||||||
|
|
||||||
static void mg_apply_emoji_fallback_widget (GtkWidget *widget);
|
static void mg_apply_emoji_fallback_widget (GtkWidget *widget);
|
||||||
|
|
||||||
|
#define MG_CONFIG_SAVE_DEBOUNCE_MS 250
|
||||||
|
|
||||||
|
static guint mg_config_save_source_id = 0;
|
||||||
|
static gboolean mg_config_prefs_dirty = FALSE;
|
||||||
|
|
||||||
|
static void
|
||||||
|
mg_show_save_failure (const PreferencesPersistenceResult *save_result)
|
||||||
|
{
|
||||||
|
char buffer[192];
|
||||||
|
|
||||||
|
if (!save_result || save_result->success)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (save_result->partial_failure)
|
||||||
|
{
|
||||||
|
fe_message (_("Could not fully save preferences. zoitechat.conf was written, but colors.conf failed. Retry is possible."), FE_MSG_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_snprintf (buffer, sizeof (buffer), _("Could not save preferences (%s). Retry is possible."), save_result->failed_file ? save_result->failed_file : _("unknown file"));
|
||||||
|
fe_message (buffer, FE_MSG_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
mg_config_save_timeout_cb (gpointer userdata)
|
||||||
|
{
|
||||||
|
PreferencesPersistenceResult save_result;
|
||||||
|
|
||||||
|
mg_config_save_source_id = 0;
|
||||||
|
|
||||||
|
if (!mg_config_prefs_dirty)
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
|
||||||
|
save_result = preferences_persistence_save_all ();
|
||||||
|
if (!save_result.success)
|
||||||
|
mg_show_save_failure (&save_result);
|
||||||
|
mg_config_prefs_dirty = FALSE;
|
||||||
|
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mg_schedule_config_save (void)
|
||||||
|
{
|
||||||
|
if (!mg_config_prefs_dirty)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (mg_config_save_source_id != 0)
|
||||||
|
g_source_remove (mg_config_save_source_id);
|
||||||
|
|
||||||
|
mg_config_save_source_id = g_timeout_add (MG_CONFIG_SAVE_DEBOUNCE_MS,
|
||||||
|
mg_config_save_timeout_cb,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mg_flush_config_save (void)
|
||||||
|
{
|
||||||
|
PreferencesPersistenceResult save_result;
|
||||||
|
|
||||||
|
if (mg_config_save_source_id != 0)
|
||||||
|
{
|
||||||
|
g_source_remove (mg_config_save_source_id);
|
||||||
|
mg_config_save_source_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mg_config_prefs_dirty)
|
||||||
|
{
|
||||||
|
save_result = preferences_persistence_save_all ();
|
||||||
|
if (!save_result.success)
|
||||||
|
mg_show_save_failure (&save_result);
|
||||||
|
mg_config_prefs_dirty = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
mg_set_source_color (cairo_t *cr, const XTextColor *color)
|
mg_set_source_color (cairo_t *cr, const XTextColor *color)
|
||||||
{
|
{
|
||||||
@@ -670,7 +746,7 @@ mg_spellcheck_cb (SexySpellEntry *entry, gchar *word, gpointer data)
|
|||||||
{
|
{
|
||||||
/* This can cause freezes on long words, nicks arn't very long anyway. */
|
/* This can cause freezes on long words, nicks arn't very long anyway. */
|
||||||
if (strlen (word) > 20)
|
if (strlen (word) > 20)
|
||||||
return TRUE;
|
return FALSE;
|
||||||
|
|
||||||
/* Ignore anything we think is a valid url */
|
/* Ignore anything we think is a valid url */
|
||||||
if (url_check_word (word) != 0)
|
if (url_check_word (word) != 0)
|
||||||
@@ -761,6 +837,10 @@ fe_set_title (session *sess)
|
|||||||
static gboolean
|
static gboolean
|
||||||
mg_windowstate_cb (GtkWindow *wid, GdkEventWindowState *event, gpointer userdata)
|
mg_windowstate_cb (GtkWindow *wid, GdkEventWindowState *event, gpointer userdata)
|
||||||
{
|
{
|
||||||
|
guint win_state;
|
||||||
|
guint win_fullscreen;
|
||||||
|
gboolean changed = FALSE;
|
||||||
|
|
||||||
if ((event->changed_mask & GDK_WINDOW_STATE_ICONIFIED) &&
|
if ((event->changed_mask & GDK_WINDOW_STATE_ICONIFIED) &&
|
||||||
(event->new_window_state & GDK_WINDOW_STATE_ICONIFIED) &&
|
(event->new_window_state & GDK_WINDOW_STATE_ICONIFIED) &&
|
||||||
prefs.hex_gui_tray_minimize && prefs.hex_gui_tray &&
|
prefs.hex_gui_tray_minimize && prefs.hex_gui_tray &&
|
||||||
@@ -769,13 +849,31 @@ mg_windowstate_cb (GtkWindow *wid, GdkEventWindowState *event, gpointer userdata
|
|||||||
tray_toggle_visibility (TRUE);
|
tray_toggle_visibility (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
prefs.hex_gui_win_state = 0;
|
win_state = 0;
|
||||||
if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)
|
if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)
|
||||||
prefs.hex_gui_win_state = 1;
|
win_state = 1;
|
||||||
|
|
||||||
prefs.hex_gui_win_fullscreen = 0;
|
win_fullscreen = 0;
|
||||||
if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
|
if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
|
||||||
prefs.hex_gui_win_fullscreen = 1;
|
win_fullscreen = 1;
|
||||||
|
|
||||||
|
if (prefs.hex_gui_win_state != win_state)
|
||||||
|
{
|
||||||
|
prefs.hex_gui_win_state = win_state;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefs.hex_gui_win_fullscreen != win_fullscreen)
|
||||||
|
{
|
||||||
|
prefs.hex_gui_win_fullscreen = win_fullscreen;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
mg_config_prefs_dirty = TRUE;
|
||||||
|
mg_schedule_config_save ();
|
||||||
|
}
|
||||||
|
|
||||||
menu_set_fullscreen (current_sess->gui, prefs.hex_gui_win_fullscreen);
|
menu_set_fullscreen (current_sess->gui, prefs.hex_gui_win_fullscreen);
|
||||||
|
|
||||||
@@ -789,30 +887,87 @@ mg_windowstate_cb (GtkWindow *wid, GdkEventWindowState *event, gpointer userdata
|
|||||||
static gboolean
|
static gboolean
|
||||||
mg_configure_cb (GtkWidget *wid, GdkEventConfigure *event, session *sess)
|
mg_configure_cb (GtkWidget *wid, GdkEventConfigure *event, session *sess)
|
||||||
{
|
{
|
||||||
if (sess == NULL) /* for the main_window */
|
gboolean changed = FALSE;
|
||||||
|
|
||||||
|
if (sess == NULL)
|
||||||
{
|
{
|
||||||
if (mg_gui)
|
if (mg_gui)
|
||||||
{
|
{
|
||||||
if (prefs.hex_gui_win_save && !prefs.hex_gui_win_state && !prefs.hex_gui_win_fullscreen)
|
if (prefs.hex_gui_win_save && !prefs.hex_gui_win_state && !prefs.hex_gui_win_fullscreen)
|
||||||
{
|
{
|
||||||
sess = current_sess;
|
int win_left;
|
||||||
gtk_window_get_position (GTK_WINDOW (wid), &prefs.hex_gui_win_left,
|
int win_top;
|
||||||
&prefs.hex_gui_win_top);
|
int win_width;
|
||||||
gtk_window_get_size (GTK_WINDOW (wid), &prefs.hex_gui_win_width,
|
int win_height;
|
||||||
&prefs.hex_gui_win_height);
|
|
||||||
|
gtk_window_get_position (GTK_WINDOW (wid), &win_left, &win_top);
|
||||||
|
gtk_window_get_size (GTK_WINDOW (wid), &win_width, &win_height);
|
||||||
|
|
||||||
|
if (prefs.hex_gui_win_left != win_left)
|
||||||
|
{
|
||||||
|
prefs.hex_gui_win_left = win_left;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefs.hex_gui_win_top != win_top)
|
||||||
|
{
|
||||||
|
prefs.hex_gui_win_top = win_top;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefs.hex_gui_win_width != win_width)
|
||||||
|
{
|
||||||
|
prefs.hex_gui_win_width = win_width;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefs.hex_gui_win_height != win_height)
|
||||||
|
{
|
||||||
|
prefs.hex_gui_win_height = win_height;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (sess->type == SESS_DIALOG && prefs.hex_gui_win_save)
|
||||||
if (sess)
|
|
||||||
{
|
{
|
||||||
if (sess->type == SESS_DIALOG && prefs.hex_gui_win_save)
|
int dialog_left;
|
||||||
|
int dialog_top;
|
||||||
|
int dialog_width;
|
||||||
|
int dialog_height;
|
||||||
|
|
||||||
|
gtk_window_get_position (GTK_WINDOW (wid), &dialog_left, &dialog_top);
|
||||||
|
gtk_window_get_size (GTK_WINDOW (wid), &dialog_width, &dialog_height);
|
||||||
|
|
||||||
|
if (prefs.hex_gui_dialog_left != dialog_left)
|
||||||
{
|
{
|
||||||
gtk_window_get_position (GTK_WINDOW (wid), &prefs.hex_gui_dialog_left,
|
prefs.hex_gui_dialog_left = dialog_left;
|
||||||
&prefs.hex_gui_dialog_top);
|
changed = TRUE;
|
||||||
gtk_window_get_size (GTK_WINDOW (wid), &prefs.hex_gui_dialog_width,
|
|
||||||
&prefs.hex_gui_dialog_height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prefs.hex_gui_dialog_top != dialog_top)
|
||||||
|
{
|
||||||
|
prefs.hex_gui_dialog_top = dialog_top;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefs.hex_gui_dialog_width != dialog_width)
|
||||||
|
{
|
||||||
|
prefs.hex_gui_dialog_width = dialog_width;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefs.hex_gui_dialog_height != dialog_height)
|
||||||
|
{
|
||||||
|
prefs.hex_gui_dialog_height = dialog_height;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
{
|
||||||
|
mg_config_prefs_dirty = TRUE;
|
||||||
|
mg_schedule_config_save ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -1063,9 +1218,14 @@ mg_userlist_showhide (session *sess, int show)
|
|||||||
session_gui *gui = sess->gui;
|
session_gui *gui = sess->gui;
|
||||||
int handle_size;
|
int handle_size;
|
||||||
int right_size;
|
int right_size;
|
||||||
|
int min_right_size;
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
|
|
||||||
right_size = MAX (prefs.hex_gui_pane_right_size, prefs.hex_gui_pane_right_size_min);
|
gtk_widget_get_size_request (gui->user_box, &min_right_size, NULL);
|
||||||
|
if (min_right_size < 1)
|
||||||
|
min_right_size = 1;
|
||||||
|
|
||||||
|
right_size = MAX (prefs.hex_gui_pane_right_size, min_right_size);
|
||||||
|
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
@@ -2179,12 +2339,13 @@ mg_topic_key_press_cb (GtkWidget *entry, GdkEventKey *event, gpointer userdata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
mg_topic_get_word_at_pos (GtkWidget *entry, gdouble event_x, gdouble event_y)
|
mg_topic_get_word_at_pos (GtkWidget *entry, gdouble event_x, gdouble event_y, int *word_pos)
|
||||||
{
|
{
|
||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
GtkTextIter iter;
|
GtkTextIter iter;
|
||||||
GtkTextIter start;
|
GtkTextIter start;
|
||||||
GtkTextIter end;
|
GtkTextIter end;
|
||||||
|
GtkTextIter cursor;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
@@ -2194,6 +2355,7 @@ mg_topic_get_word_at_pos (GtkWidget *entry, gdouble event_x, gdouble event_y)
|
|||||||
x, y, &x, &y);
|
x, y, &x, &y);
|
||||||
gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (entry), &iter, x, y);
|
gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (entry), &iter, x, y);
|
||||||
|
|
||||||
|
cursor = iter;
|
||||||
start = iter;
|
start = iter;
|
||||||
while (!gtk_text_iter_starts_line (&start))
|
while (!gtk_text_iter_starts_line (&start))
|
||||||
{
|
{
|
||||||
@@ -2221,6 +2383,16 @@ mg_topic_get_word_at_pos (GtkWidget *entry, gdouble event_x, gdouble event_y)
|
|||||||
if (gtk_text_iter_equal (&start, &end))
|
if (gtk_text_iter_equal (&start, &end))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (word_pos)
|
||||||
|
{
|
||||||
|
char *prefix;
|
||||||
|
|
||||||
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (entry));
|
||||||
|
prefix = gtk_text_buffer_get_text (buffer, &start, &cursor, FALSE);
|
||||||
|
*word_pos = (int)strlen (prefix);
|
||||||
|
g_free (prefix);
|
||||||
|
}
|
||||||
|
|
||||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (entry));
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (entry));
|
||||||
return gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
return gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||||
}
|
}
|
||||||
@@ -2243,25 +2415,34 @@ mg_topic_set_cursor (GtkWidget *entry, GdkCursorType cursor_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
mg_topic_word_is_clickable (const char *word)
|
mg_topic_word_is_clickable (const char *word, int word_pos)
|
||||||
{
|
{
|
||||||
|
int start;
|
||||||
|
int end;
|
||||||
|
|
||||||
if (!word || word[0] == 0)
|
if (!word || word[0] == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (strcmp (word, "/") == 0)
|
if (strcmp (word, "/") == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return url_check_word (word) != 0;
|
if (url_check_word (word) == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
url_last (&start, &end);
|
||||||
|
return word_pos >= start && word_pos < end;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
mg_topic_motion_cb (GtkWidget *entry, GdkEventMotion *event, gpointer userdata)
|
mg_topic_motion_cb (GtkWidget *entry, GdkEventMotion *event, gpointer userdata)
|
||||||
{
|
{
|
||||||
char *word;
|
char *word;
|
||||||
|
int word_pos;
|
||||||
gboolean word_is_clickable;
|
gboolean word_is_clickable;
|
||||||
|
|
||||||
word = mg_topic_get_word_at_pos (entry, event->x, event->y);
|
word_pos = 0;
|
||||||
word_is_clickable = mg_topic_word_is_clickable (word);
|
word = mg_topic_get_word_at_pos (entry, event->x, event->y, &word_pos);
|
||||||
|
word_is_clickable = mg_topic_word_is_clickable (word, word_pos);
|
||||||
if (word_is_clickable)
|
if (word_is_clickable)
|
||||||
mg_topic_set_cursor (entry, GDK_HAND2);
|
mg_topic_set_cursor (entry, GDK_HAND2);
|
||||||
else
|
else
|
||||||
@@ -2282,17 +2463,19 @@ static gboolean
|
|||||||
mg_topic_button_release_cb (GtkWidget *entry, GdkEventButton *event, gpointer userdata)
|
mg_topic_button_release_cb (GtkWidget *entry, GdkEventButton *event, gpointer userdata)
|
||||||
{
|
{
|
||||||
char *word;
|
char *word;
|
||||||
|
int word_pos;
|
||||||
int start;
|
int start;
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
if (event->button != 1)
|
if (event->button != 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
word = mg_topic_get_word_at_pos (entry, event->x, event->y);
|
word_pos = 0;
|
||||||
|
word = mg_topic_get_word_at_pos (entry, event->x, event->y, &word_pos);
|
||||||
if (!word)
|
if (!word)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (mg_topic_word_is_clickable (word))
|
if (mg_topic_word_is_clickable (word, word_pos))
|
||||||
{
|
{
|
||||||
url_last (&start, &end);
|
url_last (&start, &end);
|
||||||
word[end] = 0;
|
word[end] = 0;
|
||||||
@@ -2311,6 +2494,8 @@ mg_tabwindow_kill_cb (GtkWidget *win, gpointer userdata)
|
|||||||
GSList *list, *next;
|
GSList *list, *next;
|
||||||
session *sess;
|
session *sess;
|
||||||
|
|
||||||
|
mg_flush_config_save ();
|
||||||
|
|
||||||
zoitechat_is_quitting = TRUE;
|
zoitechat_is_quitting = TRUE;
|
||||||
|
|
||||||
/* see if there's any non-tab windows left */
|
/* see if there's any non-tab windows left */
|
||||||
@@ -2621,7 +2806,7 @@ mg_create_chanmodebuttons (session_gui *gui, GtkWidget *box)
|
|||||||
mg_apply_emoji_fallback_widget (gui->key_entry);
|
mg_apply_emoji_fallback_widget (gui->key_entry);
|
||||||
g_signal_connect (G_OBJECT (gui->key_entry), "activate",
|
g_signal_connect (G_OBJECT (gui->key_entry), "activate",
|
||||||
G_CALLBACK (mg_key_entry_cb), NULL);
|
G_CALLBACK (mg_key_entry_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (gui->key_entry), "key_press_event",
|
g_signal_connect (G_OBJECT (gui->key_entry), "key-press-event",
|
||||||
G_CALLBACK (mg_entry_select_all), NULL);
|
G_CALLBACK (mg_entry_select_all), NULL);
|
||||||
|
|
||||||
if (prefs.hex_gui_input_style)
|
if (prefs.hex_gui_input_style)
|
||||||
@@ -2636,7 +2821,7 @@ mg_create_chanmodebuttons (session_gui *gui, GtkWidget *box)
|
|||||||
mg_apply_emoji_fallback_widget (gui->limit_entry);
|
mg_apply_emoji_fallback_widget (gui->limit_entry);
|
||||||
g_signal_connect (G_OBJECT (gui->limit_entry), "activate",
|
g_signal_connect (G_OBJECT (gui->limit_entry), "activate",
|
||||||
G_CALLBACK (mg_limit_entry_cb), NULL);
|
G_CALLBACK (mg_limit_entry_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (gui->limit_entry), "key_press_event",
|
g_signal_connect (G_OBJECT (gui->limit_entry), "key-press-event",
|
||||||
G_CALLBACK (mg_entry_select_all), NULL);
|
G_CALLBACK (mg_entry_select_all), NULL);
|
||||||
|
|
||||||
if (prefs.hex_gui_input_style)
|
if (prefs.hex_gui_input_style)
|
||||||
@@ -2928,18 +3113,18 @@ mg_create_textarea (session *sess, GtkWidget *box)
|
|||||||
|
|
||||||
gtk_drag_dest_set (gui->vscrollbar, 5, dnd_dest_targets, 2,
|
gtk_drag_dest_set (gui->vscrollbar, 5, dnd_dest_targets, 2,
|
||||||
GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
|
GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
|
||||||
g_signal_connect (G_OBJECT (gui->vscrollbar), "drag_begin",
|
g_signal_connect (G_OBJECT (gui->vscrollbar), "drag-begin",
|
||||||
G_CALLBACK (mg_drag_begin_cb), NULL);
|
G_CALLBACK (mg_drag_begin_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (gui->vscrollbar), "drag_drop",
|
g_signal_connect (G_OBJECT (gui->vscrollbar), "drag-drop",
|
||||||
G_CALLBACK (mg_drag_drop_cb), NULL);
|
G_CALLBACK (mg_drag_drop_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (gui->vscrollbar), "drag_motion",
|
g_signal_connect (G_OBJECT (gui->vscrollbar), "drag-motion",
|
||||||
G_CALLBACK (mg_drag_motion_cb), gui->vscrollbar);
|
G_CALLBACK (mg_drag_motion_cb), gui->vscrollbar);
|
||||||
g_signal_connect (G_OBJECT (gui->vscrollbar), "drag_end",
|
g_signal_connect (G_OBJECT (gui->vscrollbar), "drag-end",
|
||||||
G_CALLBACK (mg_drag_end_cb), NULL);
|
G_CALLBACK (mg_drag_end_cb), NULL);
|
||||||
|
|
||||||
gtk_drag_dest_set (gui->xtext, GTK_DEST_DEFAULT_ALL, dnd_targets, 1,
|
gtk_drag_dest_set (gui->xtext, GTK_DEST_DEFAULT_ALL, dnd_targets, 1,
|
||||||
GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
|
GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
|
||||||
g_signal_connect (G_OBJECT (gui->xtext), "drag_data_received",
|
g_signal_connect (G_OBJECT (gui->xtext), "drag-data-received",
|
||||||
G_CALLBACK (mg_dialog_dnd_drop), NULL);
|
G_CALLBACK (mg_dialog_dnd_drop), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3115,6 +3300,8 @@ mg_create_userlist (session_gui *gui, GtkWidget *box)
|
|||||||
gtk_box_pack_start (GTK_BOX (vbox), frame, 0, 0, GUI_SPACING);
|
gtk_box_pack_start (GTK_BOX (vbox), frame, 0, 0, GUI_SPACING);
|
||||||
|
|
||||||
gui->namelistinfo = gtk_label_new (NULL);
|
gui->namelistinfo = gtk_label_new (NULL);
|
||||||
|
gtk_label_set_xalign (GTK_LABEL (gui->namelistinfo), 0.0f);
|
||||||
|
gtk_widget_set_halign (gui->namelistinfo, GTK_ALIGN_START);
|
||||||
gtk_container_add (GTK_CONTAINER (frame), gui->namelistinfo);
|
gtk_container_add (GTK_CONTAINER (frame), gui->namelistinfo);
|
||||||
|
|
||||||
gui->user_tree = ulist = userlist_create (vbox);
|
gui->user_tree = ulist = userlist_create (vbox);
|
||||||
@@ -3197,7 +3384,7 @@ mg_create_center (session *sess, session_gui *gui, GtkWidget *box)
|
|||||||
gtk_paned_pack1 (GTK_PANED (gui->hpane_left), gui->vpane_left, FALSE, FALSE);
|
gtk_paned_pack1 (GTK_PANED (gui->hpane_left), gui->vpane_left, FALSE, FALSE);
|
||||||
gtk_paned_pack2 (GTK_PANED (gui->hpane_left), gui->hpane_right, TRUE, TRUE);
|
gtk_paned_pack2 (GTK_PANED (gui->hpane_left), gui->hpane_right, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
gtk_paned_pack2 (GTK_PANED (gui->hpane_right), gui->vpane_right, FALSE, FALSE);
|
gtk_paned_pack2 (GTK_PANED (gui->hpane_right), gui->vpane_right, FALSE, TRUE);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (box), gui->hpane_left, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (box), gui->hpane_left, TRUE, TRUE, 0);
|
||||||
|
|
||||||
@@ -3653,7 +3840,8 @@ static void
|
|||||||
search_set_option (GtkToggleButton *but, guint *pref)
|
search_set_option (GtkToggleButton *but, guint *pref)
|
||||||
{
|
{
|
||||||
*pref = gtk_toggle_button_get_active(but);
|
*pref = gtk_toggle_button_get_active(but);
|
||||||
save_config();
|
if (!save_config ())
|
||||||
|
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -3709,7 +3897,7 @@ mg_create_search(session *sess, GtkWidget *box)
|
|||||||
gtk_widget_set_size_request (gui->shentry, 180, -1);
|
gtk_widget_set_size_request (gui->shentry, 180, -1);
|
||||||
mg_apply_emoji_fallback_widget (entry);
|
mg_apply_emoji_fallback_widget (entry);
|
||||||
gui->search_changed_signal = g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(search_handle_change), sess);
|
gui->search_changed_signal = g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(search_handle_change), sess);
|
||||||
g_signal_connect (G_OBJECT (entry), "key_press_event", G_CALLBACK (search_handle_esc), sess);
|
g_signal_connect (G_OBJECT (entry), "key-press-event", G_CALLBACK (search_handle_esc), sess);
|
||||||
g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(mg_search_handle_next), sess);
|
g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(mg_search_handle_next), sess);
|
||||||
gtk_entry_set_icon_activatable (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, FALSE);
|
gtk_entry_set_icon_activatable (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, FALSE);
|
||||||
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (sess->gui->shentry), GTK_ENTRY_ICON_SECONDARY, _("Search hit end or not found."));
|
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (sess->gui->shentry), GTK_ENTRY_ICON_SECONDARY, _("Search hit end or not found."));
|
||||||
@@ -3791,11 +3979,11 @@ mg_create_entry (session *sess, GtkWidget *box)
|
|||||||
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
|
||||||
|
|
||||||
gtk_widget_set_name (entry, "zoitechat-inputbox");
|
gtk_widget_set_name (entry, "zoitechat-inputbox");
|
||||||
g_signal_connect (G_OBJECT (entry), "key_press_event",
|
g_signal_connect (G_OBJECT (entry), "key-press-event",
|
||||||
G_CALLBACK (key_handle_key_press), NULL);
|
G_CALLBACK (key_handle_key_press), NULL);
|
||||||
g_signal_connect (G_OBJECT (entry), "focus_in_event",
|
g_signal_connect (G_OBJECT (entry), "focus-in-event",
|
||||||
G_CALLBACK (mg_inputbox_focus), gui);
|
G_CALLBACK (mg_inputbox_focus), gui);
|
||||||
g_signal_connect (G_OBJECT (entry), "populate_popup",
|
g_signal_connect (G_OBJECT (entry), "populate-popup",
|
||||||
G_CALLBACK (mg_inputbox_rightclick), NULL);
|
G_CALLBACK (mg_inputbox_rightclick), NULL);
|
||||||
g_signal_connect (G_OBJECT (entry), "word-check",
|
g_signal_connect (G_OBJECT (entry), "word-check",
|
||||||
G_CALLBACK (mg_spellcheck_cb), NULL);
|
G_CALLBACK (mg_spellcheck_cb), NULL);
|
||||||
@@ -3958,11 +4146,11 @@ mg_create_topwindow (session *sess)
|
|||||||
gtk_container_set_border_width (GTK_CONTAINER (win), GUI_BORDER);
|
gtk_container_set_border_width (GTK_CONTAINER (win), GUI_BORDER);
|
||||||
gtk_widget_set_opacity (win, (prefs.hex_gui_transparency / 255.));
|
gtk_widget_set_opacity (win, (prefs.hex_gui_transparency / 255.));
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (win), "focus_in_event",
|
g_signal_connect (G_OBJECT (win), "focus-in-event",
|
||||||
G_CALLBACK (mg_topwin_focus_cb), sess);
|
G_CALLBACK (mg_topwin_focus_cb), sess);
|
||||||
g_signal_connect (G_OBJECT (win), "destroy",
|
g_signal_connect (G_OBJECT (win), "destroy",
|
||||||
G_CALLBACK (mg_topdestroy_cb), sess);
|
G_CALLBACK (mg_topdestroy_cb), sess);
|
||||||
g_signal_connect (G_OBJECT (win), "configure_event",
|
g_signal_connect (G_OBJECT (win), "configure-event",
|
||||||
G_CALLBACK (mg_configure_cb), sess);
|
G_CALLBACK (mg_configure_cb), sess);
|
||||||
|
|
||||||
|
|
||||||
@@ -4148,15 +4336,15 @@ mg_create_tabwindow (session *sess)
|
|||||||
gtk_widget_set_opacity (win, (prefs.hex_gui_transparency / 255.));
|
gtk_widget_set_opacity (win, (prefs.hex_gui_transparency / 255.));
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (win), GUI_BORDER);
|
gtk_container_set_border_width (GTK_CONTAINER (win), GUI_BORDER);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (win), "delete_event",
|
g_signal_connect (G_OBJECT (win), "delete-event",
|
||||||
G_CALLBACK (mg_tabwindow_de_cb), 0);
|
G_CALLBACK (mg_tabwindow_de_cb), 0);
|
||||||
g_signal_connect (G_OBJECT (win), "destroy",
|
g_signal_connect (G_OBJECT (win), "destroy",
|
||||||
G_CALLBACK (mg_tabwindow_kill_cb), 0);
|
G_CALLBACK (mg_tabwindow_kill_cb), 0);
|
||||||
g_signal_connect (G_OBJECT (win), "focus_in_event",
|
g_signal_connect (G_OBJECT (win), "focus-in-event",
|
||||||
G_CALLBACK (mg_tabwin_focus_cb), NULL);
|
G_CALLBACK (mg_tabwin_focus_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (win), "configure_event",
|
g_signal_connect (G_OBJECT (win), "configure-event",
|
||||||
G_CALLBACK (mg_configure_cb), NULL);
|
G_CALLBACK (mg_configure_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (win), "window_state_event",
|
g_signal_connect (G_OBJECT (win), "window-state-event",
|
||||||
G_CALLBACK (mg_windowstate_cb), NULL);
|
G_CALLBACK (mg_windowstate_cb), NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ zoitechat_gtk_sources = [
|
|||||||
'maingui.c',
|
'maingui.c',
|
||||||
'notifygui.c',
|
'notifygui.c',
|
||||||
'pixmaps.c',
|
'pixmaps.c',
|
||||||
|
'preferences-persistence.c',
|
||||||
'plugin-tray.c',
|
'plugin-tray.c',
|
||||||
'plugin-notification.c',
|
'plugin-notification.c',
|
||||||
'rawlog.c',
|
'rawlog.c',
|
||||||
|
|||||||
66
src/fe-gtk/preferences-persistence.c
Normal file
66
src/fe-gtk/preferences-persistence.c
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#include "preferences-persistence.h"
|
||||||
|
|
||||||
|
#include "../common/cfgfiles.h"
|
||||||
|
#include "theme/theme-runtime.h"
|
||||||
|
|
||||||
|
PreferencesPersistenceResult
|
||||||
|
preferences_persistence_save_all (void)
|
||||||
|
{
|
||||||
|
PreferencesPersistenceResult result;
|
||||||
|
char *config_temp;
|
||||||
|
char *theme_temp;
|
||||||
|
|
||||||
|
result.success = FALSE;
|
||||||
|
result.retry_possible = TRUE;
|
||||||
|
result.partial_failure = FALSE;
|
||||||
|
result.config_failed = FALSE;
|
||||||
|
result.theme_failed = FALSE;
|
||||||
|
result.failed_file = NULL;
|
||||||
|
config_temp = NULL;
|
||||||
|
theme_temp = NULL;
|
||||||
|
|
||||||
|
if (!save_config_prepare (&config_temp))
|
||||||
|
{
|
||||||
|
result.config_failed = TRUE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!theme_runtime_save_prepare (&theme_temp))
|
||||||
|
{
|
||||||
|
result.theme_failed = TRUE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!save_config_finalize (config_temp))
|
||||||
|
{
|
||||||
|
result.config_failed = TRUE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!theme_runtime_save_finalize (theme_temp))
|
||||||
|
{
|
||||||
|
result.theme_failed = TRUE;
|
||||||
|
result.partial_failure = TRUE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.success = TRUE;
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (!result.success)
|
||||||
|
{
|
||||||
|
if (result.config_failed && result.theme_failed)
|
||||||
|
result.failed_file = "zoitechat.conf and colors.conf";
|
||||||
|
else if (result.config_failed)
|
||||||
|
result.failed_file = "zoitechat.conf";
|
||||||
|
else if (result.theme_failed)
|
||||||
|
result.failed_file = "colors.conf";
|
||||||
|
}
|
||||||
|
|
||||||
|
save_config_discard (config_temp);
|
||||||
|
theme_runtime_save_discard (theme_temp);
|
||||||
|
g_free (config_temp);
|
||||||
|
g_free (theme_temp);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
18
src/fe-gtk/preferences-persistence.h
Normal file
18
src/fe-gtk/preferences-persistence.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef ZOITECHAT_PREFERENCES_PERSISTENCE_H
|
||||||
|
#define ZOITECHAT_PREFERENCES_PERSISTENCE_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gboolean success;
|
||||||
|
gboolean retry_possible;
|
||||||
|
gboolean partial_failure;
|
||||||
|
gboolean config_failed;
|
||||||
|
gboolean theme_failed;
|
||||||
|
const char *failed_file;
|
||||||
|
} PreferencesPersistenceResult;
|
||||||
|
|
||||||
|
PreferencesPersistenceResult preferences_persistence_save_all (void);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -192,7 +192,7 @@ open_rawlog (struct server *serv)
|
|||||||
serv, _("Save As..."));
|
serv, _("Save As..."));
|
||||||
|
|
||||||
/* Copy selection to clipboard when Ctrl+Shift+C is pressed AND text auto-copy is disabled */
|
/* Copy selection to clipboard when Ctrl+Shift+C is pressed AND text auto-copy is disabled */
|
||||||
g_signal_connect (G_OBJECT (serv->gui->rawlog_window), "key_press_event", G_CALLBACK (rawlog_key_cb), serv->gui->rawlog_textlist);
|
g_signal_connect (G_OBJECT (serv->gui->rawlog_window), "key-press-event", G_CALLBACK (rawlog_key_cb), serv->gui->rawlog_textlist);
|
||||||
g_object_set_data (G_OBJECT (serv->gui->rawlog_window), RAWLOG_THEME_LISTENER_ID_KEY,
|
g_object_set_data (G_OBJECT (serv->gui->rawlog_window), RAWLOG_THEME_LISTENER_ID_KEY,
|
||||||
GUINT_TO_POINTER (theme_listener_register ("rawlog.window", rawlog_theme_changed, serv->gui->rawlog_window)));
|
GUINT_TO_POINTER (theme_listener_register ("rawlog.window", rawlog_theme_changed, serv->gui->rawlog_window)));
|
||||||
g_signal_connect (G_OBJECT (serv->gui->rawlog_window), "destroy", G_CALLBACK (rawlog_theme_destroy_cb), NULL);
|
g_signal_connect (G_OBJECT (serv->gui->rawlog_window), "destroy", G_CALLBACK (rawlog_theme_destroy_cb), NULL);
|
||||||
|
|||||||
@@ -763,9 +763,9 @@ servlist_edit_cb (GtkWidget *but, gpointer none)
|
|||||||
servlist_servers_populate (selected_net, edit_trees[SERVER_TREE]);
|
servlist_servers_populate (selected_net, edit_trees[SERVER_TREE]);
|
||||||
servlist_channels_populate (selected_net, edit_trees[CHANNEL_TREE]);
|
servlist_channels_populate (selected_net, edit_trees[CHANNEL_TREE]);
|
||||||
servlist_commands_populate (selected_net, edit_trees[CMD_TREE]);
|
servlist_commands_populate (selected_net, edit_trees[CMD_TREE]);
|
||||||
g_signal_connect (G_OBJECT (edit_win), "delete_event",
|
g_signal_connect (G_OBJECT (edit_win), "delete-event",
|
||||||
G_CALLBACK (servlist_editwin_delete_cb), 0);
|
G_CALLBACK (servlist_editwin_delete_cb), 0);
|
||||||
g_signal_connect (G_OBJECT (edit_win), "configure_event",
|
g_signal_connect (G_OBJECT (edit_win), "configure-event",
|
||||||
G_CALLBACK (servlist_edit_configure_cb), 0);
|
G_CALLBACK (servlist_edit_configure_cb), 0);
|
||||||
gtk_widget_show (edit_win);
|
gtk_widget_show (edit_win);
|
||||||
}
|
}
|
||||||
@@ -1002,7 +1002,8 @@ servlist_savegui (void)
|
|||||||
sp[0] = 0; /* spaces will break the login */
|
sp[0] = 0; /* spaces will break the login */
|
||||||
/* strcpy (prefs.hex_irc_real_name, gtk_entry_get_text (GTK_ENTRY (entry_greal))); */
|
/* strcpy (prefs.hex_irc_real_name, gtk_entry_get_text (GTK_ENTRY (entry_greal))); */
|
||||||
servlist_save ();
|
servlist_save ();
|
||||||
save_config (); /* For nicks stored in zoitechat.conf */
|
if (!save_config ())
|
||||||
|
fe_message (_("Could not save zoitechat.conf."), FE_MSG_WARN);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1838,7 +1839,7 @@ servlist_open_edit (GtkWidget *parent, ircnet *net)
|
|||||||
model = GTK_TREE_MODEL (store);
|
model = GTK_TREE_MODEL (store);
|
||||||
|
|
||||||
edit_trees[SERVER_TREE] = treeview_servers = gtk_tree_view_new_with_model (model);
|
edit_trees[SERVER_TREE] = treeview_servers = gtk_tree_view_new_with_model (model);
|
||||||
g_signal_connect (G_OBJECT (treeview_servers), "key_press_event",
|
g_signal_connect (G_OBJECT (treeview_servers), "key-press-event",
|
||||||
G_CALLBACK (servlist_keypress_cb), notebook);
|
G_CALLBACK (servlist_keypress_cb), notebook);
|
||||||
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview_servers))),
|
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview_servers))),
|
||||||
"changed", G_CALLBACK (servlist_server_row_cb), NULL);
|
"changed", G_CALLBACK (servlist_server_row_cb), NULL);
|
||||||
@@ -1863,7 +1864,7 @@ servlist_open_edit (GtkWidget *parent, ircnet *net)
|
|||||||
model = GTK_TREE_MODEL (store);
|
model = GTK_TREE_MODEL (store);
|
||||||
|
|
||||||
edit_trees[CHANNEL_TREE] = treeview_channels = gtk_tree_view_new_with_model (model);
|
edit_trees[CHANNEL_TREE] = treeview_channels = gtk_tree_view_new_with_model (model);
|
||||||
g_signal_connect (G_OBJECT (treeview_channels), "key_press_event",
|
g_signal_connect (G_OBJECT (treeview_channels), "key-press-event",
|
||||||
G_CALLBACK (servlist_keypress_cb), notebook);
|
G_CALLBACK (servlist_keypress_cb), notebook);
|
||||||
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview_channels))),
|
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview_channels))),
|
||||||
"changed", G_CALLBACK (servlist_channel_row_cb), NULL);
|
"changed", G_CALLBACK (servlist_channel_row_cb), NULL);
|
||||||
@@ -1900,7 +1901,7 @@ servlist_open_edit (GtkWidget *parent, ircnet *net)
|
|||||||
model = GTK_TREE_MODEL (store);
|
model = GTK_TREE_MODEL (store);
|
||||||
|
|
||||||
edit_trees[CMD_TREE] = treeview_commands = gtk_tree_view_new_with_model (model);
|
edit_trees[CMD_TREE] = treeview_commands = gtk_tree_view_new_with_model (model);
|
||||||
g_signal_connect (G_OBJECT (treeview_commands), "key_press_event",
|
g_signal_connect (G_OBJECT (treeview_commands), "key-press-event",
|
||||||
G_CALLBACK (servlist_keypress_cb), notebook);
|
G_CALLBACK (servlist_keypress_cb), notebook);
|
||||||
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview_commands))),
|
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview_commands))),
|
||||||
"changed", G_CALLBACK (servlist_command_row_cb), NULL);
|
"changed", G_CALLBACK (servlist_command_row_cb), NULL);
|
||||||
@@ -2356,13 +2357,13 @@ fe_serverlist_open (session *sess)
|
|||||||
|
|
||||||
servlist_networks_populate (networks_tree, network_list);
|
servlist_networks_populate (networks_tree, network_list);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (serverlist_win), "delete_event",
|
g_signal_connect (G_OBJECT (serverlist_win), "delete-event",
|
||||||
G_CALLBACK (servlist_delete_cb), 0);
|
G_CALLBACK (servlist_delete_cb), 0);
|
||||||
g_signal_connect (G_OBJECT (serverlist_win), "configure_event",
|
g_signal_connect (G_OBJECT (serverlist_win), "configure-event",
|
||||||
G_CALLBACK (servlist_configure_cb), 0);
|
G_CALLBACK (servlist_configure_cb), 0);
|
||||||
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (networks_tree))),
|
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (networks_tree))),
|
||||||
"changed", G_CALLBACK (servlist_network_row_cb), NULL);
|
"changed", G_CALLBACK (servlist_network_row_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (networks_tree), "key_press_event",
|
g_signal_connect (G_OBJECT (networks_tree), "key-press-event",
|
||||||
G_CALLBACK (servlist_net_keypress_cb), networks_tree);
|
G_CALLBACK (servlist_net_keypress_cb), networks_tree);
|
||||||
|
|
||||||
gtk_widget_show (serverlist_win);
|
gtk_widget_show (serverlist_win);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "maingui.h"
|
#include "maingui.h"
|
||||||
#include "pixmaps.h"
|
#include "pixmaps.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
#include "preferences-persistence.h"
|
||||||
#include "plugin-tray.h"
|
#include "plugin-tray.h"
|
||||||
#include "notifications/notification-backend.h"
|
#include "notifications/notification-backend.h"
|
||||||
|
|
||||||
@@ -893,7 +894,7 @@ setup_create_spin (GtkWidget *table, int row, const setting *set)
|
|||||||
gtk_widget_set_tooltip_text (wid, _(set->tooltip));
|
gtk_widget_set_tooltip_text (wid, _(set->tooltip));
|
||||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (wid),
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (wid),
|
||||||
setup_get_int (&setup_prefs, set));
|
setup_get_int (&setup_prefs, set));
|
||||||
g_signal_connect (G_OBJECT (wid), "value_changed",
|
g_signal_connect (G_OBJECT (wid), "value-changed",
|
||||||
G_CALLBACK (setup_spin_cb), (gpointer)set);
|
G_CALLBACK (setup_spin_cb), (gpointer)set);
|
||||||
gtk_box_pack_start (GTK_BOX (rbox), wid, 0, 0, 0);
|
gtk_box_pack_start (GTK_BOX (rbox), wid, 0, 0, 0);
|
||||||
|
|
||||||
@@ -949,7 +950,7 @@ setup_create_hscale (GtkWidget *table, int row, const setting *set)
|
|||||||
wid = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0., 255., 1.);
|
wid = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0., 255., 1.);
|
||||||
gtk_scale_set_value_pos (GTK_SCALE (wid), GTK_POS_RIGHT);
|
gtk_scale_set_value_pos (GTK_SCALE (wid), GTK_POS_RIGHT);
|
||||||
gtk_range_set_value (GTK_RANGE (wid), setup_get_int (&setup_prefs, set));
|
gtk_range_set_value (GTK_RANGE (wid), setup_get_int (&setup_prefs, set));
|
||||||
g_signal_connect (G_OBJECT(wid), "value_changed",
|
g_signal_connect (G_OBJECT(wid), "value-changed",
|
||||||
G_CALLBACK (setup_hscale_cb), (gpointer)set);
|
G_CALLBACK (setup_hscale_cb), (gpointer)set);
|
||||||
setup_table_attach (table, wid, 3, 6, row, row + 1, TRUE, FALSE,
|
setup_table_attach (table, wid, 3, 6, row, row + 1, TRUE, FALSE,
|
||||||
SETUP_ALIGN_FILL, SETUP_ALIGN_FILL, 0, 0);
|
SETUP_ALIGN_FILL, SETUP_ALIGN_FILL, 0, 0);
|
||||||
@@ -1965,7 +1966,7 @@ setup_create_tree (GtkWidget *box, GtkWidget *book)
|
|||||||
gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
|
gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
|
||||||
gtk_tree_selection_set_select_function (sel, setup_tree_select_filter,
|
gtk_tree_selection_set_select_function (sel, setup_tree_select_filter,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
g_signal_connect (G_OBJECT (tree), "cursor_changed",
|
g_signal_connect (G_OBJECT (tree), "cursor-changed",
|
||||||
G_CALLBACK (setup_tree_cb), book);
|
G_CALLBACK (setup_tree_cb), book);
|
||||||
|
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
@@ -2191,10 +2192,32 @@ setup_apply (struct zoitechatprefs *pr)
|
|||||||
static void
|
static void
|
||||||
setup_ok_cb (GtkWidget *but, GtkWidget *win)
|
setup_ok_cb (GtkWidget *but, GtkWidget *win)
|
||||||
{
|
{
|
||||||
gtk_widget_destroy (win);
|
PreferencesPersistenceResult save_result;
|
||||||
|
struct zoitechatprefs old_prefs;
|
||||||
|
char buffer[192];
|
||||||
|
|
||||||
|
memcpy (&old_prefs, &prefs, sizeof (prefs));
|
||||||
|
theme_preferences_stage_apply ();
|
||||||
setup_apply (&setup_prefs);
|
setup_apply (&setup_prefs);
|
||||||
save_config ();
|
save_result = preferences_persistence_save_all ();
|
||||||
theme_manager_save_preferences ();
|
if (save_result.success)
|
||||||
|
{
|
||||||
|
theme_preferences_stage_commit ();
|
||||||
|
gtk_widget_destroy (win);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy (&prefs, &old_prefs, sizeof (prefs));
|
||||||
|
theme_preferences_stage_discard ();
|
||||||
|
|
||||||
|
if (save_result.partial_failure)
|
||||||
|
{
|
||||||
|
fe_message (_("Preferences were partially saved. zoitechat.conf succeeded, colors.conf failed. Retry is possible."), FE_MSG_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_snprintf (buffer, sizeof (buffer), _("Could not save preferences (%s). Retry is possible."), save_result.failed_file ? save_result.failed_file : _("unknown file"));
|
||||||
|
fe_message (buffer, FE_MSG_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
@@ -2242,6 +2265,7 @@ setup_close_cb (GtkWidget *win, GtkWidget **swin)
|
|||||||
{
|
{
|
||||||
*swin = NULL;
|
*swin = NULL;
|
||||||
|
|
||||||
|
theme_preferences_stage_discard ();
|
||||||
|
|
||||||
if (font_dialog)
|
if (font_dialog)
|
||||||
{
|
{
|
||||||
@@ -2262,6 +2286,7 @@ setup_open (void)
|
|||||||
memcpy (&setup_prefs, &prefs, sizeof (prefs));
|
memcpy (&setup_prefs, &prefs, sizeof (prefs));
|
||||||
|
|
||||||
color_change = FALSE;
|
color_change = FALSE;
|
||||||
|
theme_preferences_stage_begin ();
|
||||||
setup_window = setup_window_open ();
|
setup_window = setup_window_open ();
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (setup_window), "destroy",
|
g_signal_connect (G_OBJECT (setup_window), "destroy",
|
||||||
|
|||||||
@@ -964,6 +964,9 @@ default_word_check(SexySpellEntry *entry, const gchar *word)
|
|||||||
/* We only want to check words */
|
/* We only want to check words */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_utf8_strlen (word, -1) > 20)
|
||||||
|
return FALSE;
|
||||||
for (li = entry->priv->dict_list; li; li = g_slist_next (li)) {
|
for (li = entry->priv->dict_list; li; li = g_slist_next (li)) {
|
||||||
struct EnchantDict *dict = (struct EnchantDict *) li->data;
|
struct EnchantDict *dict = (struct EnchantDict *) li->data;
|
||||||
if (enchant_dict_check(dict, word, strlen(word)) == 0) {
|
if (enchant_dict_check(dict, word, strlen(word)) == 0) {
|
||||||
@@ -1161,13 +1164,34 @@ check_color:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
attr_list_has_attrs (PangoAttrList *attrs)
|
||||||
|
{
|
||||||
|
PangoAttrIterator *it;
|
||||||
|
GSList *list;
|
||||||
|
gboolean has = FALSE;
|
||||||
|
|
||||||
|
if (!attrs)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
it = pango_attr_list_get_iterator (attrs);
|
||||||
|
if (!it)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
list = pango_attr_iterator_get_attrs (it);
|
||||||
|
has = (list != NULL);
|
||||||
|
g_slist_free_full (list, (GDestroyNotify) pango_attribute_destroy);
|
||||||
|
pango_attr_iterator_destroy (it);
|
||||||
|
|
||||||
|
return has;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sexy_spell_entry_recheck_all(SexySpellEntry *entry)
|
sexy_spell_entry_recheck_all(SexySpellEntry *entry)
|
||||||
{
|
{
|
||||||
GdkRectangle rect;
|
GdkRectangle rect;
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
GtkWidget *widget = GTK_WIDGET(entry);
|
GtkWidget *widget = GTK_WIDGET(entry);
|
||||||
PangoLayout *layout;
|
|
||||||
int length, i, text_len;
|
int length, i, text_len;
|
||||||
const char *text;
|
const char *text;
|
||||||
|
|
||||||
@@ -1196,8 +1220,7 @@ sexy_spell_entry_recheck_all(SexySpellEntry *entry)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layout = gtk_entry_get_layout(GTK_ENTRY(entry));
|
gtk_entry_set_attributes (GTK_ENTRY (entry), attr_list_has_attrs (entry->priv->attr_list) ? entry->priv->attr_list : NULL);
|
||||||
pango_layout_set_attributes(layout, entry->priv->attr_list);
|
|
||||||
|
|
||||||
if (gtk_widget_get_realized (GTK_WIDGET(entry)))
|
if (gtk_widget_get_realized (GTK_WIDGET(entry)))
|
||||||
{
|
{
|
||||||
@@ -1213,13 +1236,6 @@ sexy_spell_entry_recheck_all(SexySpellEntry *entry)
|
|||||||
static gboolean
|
static gboolean
|
||||||
sexy_spell_entry_draw(GtkWidget *widget, cairo_t *cr)
|
sexy_spell_entry_draw(GtkWidget *widget, cairo_t *cr)
|
||||||
{
|
{
|
||||||
SexySpellEntry *entry = SEXY_SPELL_ENTRY(widget);
|
|
||||||
GtkEntry *gtk_entry = GTK_ENTRY(widget);
|
|
||||||
PangoLayout *layout;
|
|
||||||
|
|
||||||
layout = gtk_entry_get_layout(gtk_entry);
|
|
||||||
pango_layout_set_attributes(layout, entry->priv->attr_list);
|
|
||||||
|
|
||||||
return GTK_WIDGET_CLASS(parent_class)->draw (widget, cr);
|
return GTK_WIDGET_CLASS(parent_class)->draw (widget, cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,9 +57,10 @@ theme_runtime_load (void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
gboolean
|
||||||
theme_runtime_save (void)
|
theme_runtime_save (void)
|
||||||
{
|
{
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -119,8 +119,9 @@ void theme_runtime_load (void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void theme_runtime_save (void)
|
gboolean theme_runtime_save (void)
|
||||||
{
|
{
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean theme_runtime_is_dark_active (void)
|
gboolean theme_runtime_is_dark_active (void)
|
||||||
|
|||||||
@@ -112,8 +112,9 @@ void theme_runtime_load (void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void theme_runtime_save (void)
|
gboolean theme_runtime_save (void)
|
||||||
{
|
{
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean theme_runtime_is_dark_active (void)
|
gboolean theme_runtime_is_dark_active (void)
|
||||||
|
|||||||
@@ -122,8 +122,9 @@ void theme_runtime_load (void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void theme_runtime_save (void)
|
gboolean theme_runtime_save (void)
|
||||||
{
|
{
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean theme_runtime_is_dark_active (void)
|
gboolean theme_runtime_is_dark_active (void)
|
||||||
|
|||||||
@@ -66,9 +66,10 @@ theme_manager_reset_mode_colors (unsigned int mode, gboolean *palette_changed)
|
|||||||
*palette_changed = FALSE;
|
*palette_changed = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
gboolean
|
||||||
theme_manager_save_preferences (void)
|
theme_manager_save_preferences (void)
|
||||||
{
|
{
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemePaletteBehavior
|
ThemePaletteBehavior
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ struct zoitechatprefs prefs;
|
|||||||
|
|
||||||
static char *test_home_dir;
|
static char *test_home_dir;
|
||||||
|
|
||||||
|
static char *
|
||||||
|
test_home_path (const char *file)
|
||||||
|
{
|
||||||
|
return g_build_filename (test_home_dir, file, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
read_line_value (const char *cfg, const char *key, char *out, gsize out_len)
|
read_line_value (const char *cfg, const char *key, char *out, gsize out_len)
|
||||||
{
|
{
|
||||||
@@ -97,6 +103,12 @@ cfg_put_int (int fh, int value, char *var)
|
|||||||
return write (fh, line, (size_t) len) == len;
|
return write (fh, line, (size_t) len) == len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
get_xdir (void)
|
||||||
|
{
|
||||||
|
return test_home_dir;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
zoitechat_open_file (const char *file, int flags, int mode, int xof_flags)
|
zoitechat_open_file (const char *file, int flags, int mode, int xof_flags)
|
||||||
{
|
{
|
||||||
@@ -145,7 +157,7 @@ read_colors_conf (void)
|
|||||||
gsize length = 0;
|
gsize length = 0;
|
||||||
gboolean ok;
|
gboolean ok;
|
||||||
|
|
||||||
path = g_build_filename (test_home_dir, "colors.conf", NULL);
|
path = test_home_path ("colors.conf");
|
||||||
ok = g_file_get_contents (path, &content, &length, NULL);
|
ok = g_file_get_contents (path, &content, &length, NULL);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
g_assert_true (ok);
|
g_assert_true (ok);
|
||||||
@@ -222,7 +234,7 @@ test_loads_legacy_color_keys_via_migration_loader (void)
|
|||||||
gboolean ok;
|
gboolean ok;
|
||||||
|
|
||||||
setup_temp_home ();
|
setup_temp_home ();
|
||||||
path = g_build_filename (test_home_dir, "colors.conf", NULL);
|
path = test_home_path ("colors.conf");
|
||||||
ok = g_file_set_contents (path, legacy_cfg, -1, NULL);
|
ok = g_file_set_contents (path, legacy_cfg, -1, NULL);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
g_assert_true (ok);
|
g_assert_true (ok);
|
||||||
@@ -336,6 +348,50 @@ test_gtk_map_uses_theme_defaults_until_custom_token_is_set (void)
|
|||||||
g_assert_true (colors_equal (&values.foreground, &custom));
|
g_assert_true (colors_equal (&values.foreground, &custom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_save_finalize_replaces_colors_conf_atomically (void)
|
||||||
|
{
|
||||||
|
char *path;
|
||||||
|
char *temp_path = NULL;
|
||||||
|
char *cfg = NULL;
|
||||||
|
gboolean ok;
|
||||||
|
|
||||||
|
setup_temp_home ();
|
||||||
|
path = test_home_path ("colors.conf");
|
||||||
|
ok = g_file_set_contents (path, "theme.mode.light.token.mirc_0 = 0000 0000 0000\n", -1, NULL);
|
||||||
|
g_assert_true (ok);
|
||||||
|
|
||||||
|
theme_runtime_load ();
|
||||||
|
g_assert_true (theme_runtime_save_prepare (&temp_path));
|
||||||
|
g_assert_nonnull (temp_path);
|
||||||
|
g_assert_nonnull (g_strrstr (temp_path, "colors.conf.new."));
|
||||||
|
g_assert_true (g_file_test (temp_path, G_FILE_TEST_EXISTS));
|
||||||
|
g_assert_true (theme_runtime_save_finalize (temp_path));
|
||||||
|
g_assert_false (g_file_test (temp_path, G_FILE_TEST_EXISTS));
|
||||||
|
ok = g_file_get_contents (path, &cfg, NULL, NULL);
|
||||||
|
g_assert_true (ok);
|
||||||
|
g_assert_nonnull (g_strstr_len (cfg, -1, "theme.palette.semantic_migrated = 1"));
|
||||||
|
g_free (cfg);
|
||||||
|
g_free (temp_path);
|
||||||
|
g_free (path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_save_discard_unlinks_temp_file (void)
|
||||||
|
{
|
||||||
|
char *temp_path = NULL;
|
||||||
|
|
||||||
|
setup_temp_home ();
|
||||||
|
theme_runtime_load ();
|
||||||
|
g_assert_true (theme_runtime_save_prepare (&temp_path));
|
||||||
|
g_assert_nonnull (temp_path);
|
||||||
|
g_assert_true (g_file_test (temp_path, G_FILE_TEST_EXISTS));
|
||||||
|
theme_runtime_save_discard (temp_path);
|
||||||
|
g_assert_false (g_file_test (temp_path, G_FILE_TEST_EXISTS));
|
||||||
|
g_free (temp_path);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_save_writes_only_custom_token_keys (void)
|
test_save_writes_only_custom_token_keys (void)
|
||||||
{
|
{
|
||||||
@@ -368,6 +424,10 @@ main (int argc, char **argv)
|
|||||||
test_gtk_map_colors_blend_with_palette_without_transparency);
|
test_gtk_map_colors_blend_with_palette_without_transparency);
|
||||||
g_test_add_func ("/theme/runtime/gtk_map_uses_theme_defaults_until_custom_token_is_set",
|
g_test_add_func ("/theme/runtime/gtk_map_uses_theme_defaults_until_custom_token_is_set",
|
||||||
test_gtk_map_uses_theme_defaults_until_custom_token_is_set);
|
test_gtk_map_uses_theme_defaults_until_custom_token_is_set);
|
||||||
|
g_test_add_func ("/theme/runtime/save_finalize_replaces_colors_conf_atomically",
|
||||||
|
test_save_finalize_replaces_colors_conf_atomically);
|
||||||
|
g_test_add_func ("/theme/runtime/save_discard_unlinks_temp_file",
|
||||||
|
test_save_discard_unlinks_temp_file);
|
||||||
g_test_add_func ("/theme/runtime/save_writes_only_custom_token_keys",
|
g_test_add_func ("/theme/runtime/save_writes_only_custom_token_keys",
|
||||||
test_save_writes_only_custom_token_keys);
|
test_save_writes_only_custom_token_keys);
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
|
|||||||
@@ -284,10 +284,10 @@ theme_manager_commit_preferences (unsigned int old_mode, gboolean *color_change)
|
|||||||
fe_set_auto_dark_mode_state (theme_policy_is_dark_mode_active (ZOITECHAT_DARK_MODE_AUTO));
|
fe_set_auto_dark_mode_state (theme_policy_is_dark_mode_active (ZOITECHAT_DARK_MODE_AUTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
gboolean
|
||||||
theme_manager_save_preferences (void)
|
theme_manager_save_preferences (void)
|
||||||
{
|
{
|
||||||
theme_runtime_save ();
|
return theme_runtime_save ();
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void theme_manager_set_mode (unsigned int mode, gboolean *palette_changed);
|
|||||||
void theme_manager_set_token_color (unsigned int mode, ThemeSemanticToken token, const GdkRGBA *color, gboolean *palette_changed);
|
void theme_manager_set_token_color (unsigned int mode, ThemeSemanticToken token, const GdkRGBA *color, gboolean *palette_changed);
|
||||||
void theme_manager_reset_mode_colors (unsigned int mode, gboolean *palette_changed);
|
void theme_manager_reset_mode_colors (unsigned int mode, gboolean *palette_changed);
|
||||||
void theme_manager_commit_preferences (unsigned int old_mode, gboolean *color_change);
|
void theme_manager_commit_preferences (unsigned int old_mode, gboolean *color_change);
|
||||||
void theme_manager_save_preferences (void);
|
gboolean theme_manager_save_preferences (void);
|
||||||
gboolean theme_changed_event_has_reason (const ThemeChangedEvent *event, ThemeChangedReason reason);
|
gboolean theme_changed_event_has_reason (const ThemeChangedEvent *event, ThemeChangedReason reason);
|
||||||
void theme_manager_apply_and_dispatch (unsigned int mode, ThemeChangedReason reasons, gboolean *palette_changed);
|
void theme_manager_apply_and_dispatch (unsigned int mode, ThemeChangedReason reasons, gboolean *palette_changed);
|
||||||
void theme_manager_dispatch_changed (ThemeChangedReason reasons);
|
void theme_manager_dispatch_changed (ThemeChangedReason reasons);
|
||||||
|
|||||||
@@ -70,6 +70,155 @@ typedef struct
|
|||||||
|
|
||||||
#define COLOR_MANAGER_RESPONSE_RESET 1
|
#define COLOR_MANAGER_RESPONSE_RESET 1
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gboolean active;
|
||||||
|
gboolean changed;
|
||||||
|
gboolean snapshot_valid[THEME_TOKEN_COUNT];
|
||||||
|
gboolean staged_valid[THEME_TOKEN_COUNT];
|
||||||
|
GdkRGBA snapshot[THEME_TOKEN_COUNT];
|
||||||
|
GdkRGBA staged[THEME_TOKEN_COUNT];
|
||||||
|
} theme_preferences_stage_state;
|
||||||
|
|
||||||
|
static theme_preferences_stage_state theme_preferences_stage;
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
theme_preferences_staged_get_color (ThemeSemanticToken token, GdkRGBA *rgba)
|
||||||
|
{
|
||||||
|
if (token < 0 || token >= THEME_TOKEN_COUNT || !rgba)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (theme_preferences_stage.active && theme_preferences_stage.staged_valid[token])
|
||||||
|
{
|
||||||
|
*rgba = theme_preferences_stage.staged[token];
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return theme_get_color (token, rgba);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
theme_preferences_stage_recompute_changed (void)
|
||||||
|
{
|
||||||
|
ThemeSemanticToken token;
|
||||||
|
|
||||||
|
theme_preferences_stage.changed = FALSE;
|
||||||
|
for (token = THEME_TOKEN_MIRC_0; token < THEME_TOKEN_COUNT; token++)
|
||||||
|
{
|
||||||
|
if (!theme_preferences_stage.snapshot_valid[token] || !theme_preferences_stage.staged_valid[token])
|
||||||
|
continue;
|
||||||
|
if (!gdk_rgba_equal (&theme_preferences_stage.snapshot[token], &theme_preferences_stage.staged[token]))
|
||||||
|
{
|
||||||
|
theme_preferences_stage.changed = TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
theme_preferences_stage_sync_runtime_to_snapshot (void)
|
||||||
|
{
|
||||||
|
ThemeSemanticToken token;
|
||||||
|
|
||||||
|
for (token = THEME_TOKEN_MIRC_0; token < THEME_TOKEN_COUNT; token++)
|
||||||
|
{
|
||||||
|
if (theme_preferences_stage.snapshot_valid[token])
|
||||||
|
theme_manager_set_token_color (ZOITECHAT_DARK_MODE_LIGHT, token,
|
||||||
|
&theme_preferences_stage.snapshot[token], NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
theme_preferences_stage_sync_runtime_to_staged (void)
|
||||||
|
{
|
||||||
|
ThemeSemanticToken token;
|
||||||
|
|
||||||
|
for (token = THEME_TOKEN_MIRC_0; token < THEME_TOKEN_COUNT; token++)
|
||||||
|
{
|
||||||
|
if (theme_preferences_stage.staged_valid[token])
|
||||||
|
theme_manager_set_token_color (ZOITECHAT_DARK_MODE_LIGHT, token,
|
||||||
|
&theme_preferences_stage.staged[token], NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
theme_preferences_staged_set_color (ThemeSemanticToken token, const GdkRGBA *rgba,
|
||||||
|
gboolean *color_change_flag, gboolean live_preview)
|
||||||
|
{
|
||||||
|
const GdkRGBA *preview_color = rgba;
|
||||||
|
|
||||||
|
if (token < 0 || token >= THEME_TOKEN_COUNT || !rgba)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (theme_preferences_stage.active)
|
||||||
|
{
|
||||||
|
theme_preferences_stage.staged[token] = *rgba;
|
||||||
|
theme_preferences_stage.staged_valid[token] = TRUE;
|
||||||
|
theme_preferences_stage_recompute_changed ();
|
||||||
|
if (color_change_flag)
|
||||||
|
*color_change_flag = theme_preferences_stage.changed;
|
||||||
|
|
||||||
|
preview_color = &theme_preferences_stage.staged[token];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (live_preview)
|
||||||
|
theme_manager_set_token_color (ZOITECHAT_DARK_MODE_LIGHT, token, preview_color, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
theme_preferences_stage_begin (void)
|
||||||
|
{
|
||||||
|
ThemeSemanticToken token;
|
||||||
|
|
||||||
|
memset (&theme_preferences_stage, 0, sizeof (theme_preferences_stage));
|
||||||
|
theme_preferences_stage.active = TRUE;
|
||||||
|
|
||||||
|
for (token = THEME_TOKEN_MIRC_0; token < THEME_TOKEN_COUNT; token++)
|
||||||
|
{
|
||||||
|
GdkRGBA rgba;
|
||||||
|
|
||||||
|
if (!theme_preferences_staged_get_color (token, &rgba))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
theme_preferences_stage.snapshot[token] = rgba;
|
||||||
|
theme_preferences_stage.staged[token] = rgba;
|
||||||
|
theme_preferences_stage.snapshot_valid[token] = TRUE;
|
||||||
|
theme_preferences_stage.staged_valid[token] = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
theme_preferences_stage_apply (void)
|
||||||
|
{
|
||||||
|
if (!theme_preferences_stage.active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
theme_preferences_stage_sync_runtime_to_staged ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
theme_preferences_stage_commit (void)
|
||||||
|
{
|
||||||
|
if (!theme_preferences_stage.active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
theme_preferences_stage_apply ();
|
||||||
|
memset (&theme_preferences_stage, 0, sizeof (theme_preferences_stage));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
theme_preferences_stage_discard (void)
|
||||||
|
{
|
||||||
|
if (!theme_preferences_stage.active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
theme_preferences_stage_sync_runtime_to_snapshot ();
|
||||||
|
memset (&theme_preferences_stage, 0, sizeof (theme_preferences_stage));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
theme_preferences_show_import_error (GtkWidget *button, const char *message);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
theme_preferences_manager_row_free (gpointer data)
|
theme_preferences_manager_row_free (gpointer data)
|
||||||
{
|
{
|
||||||
@@ -113,16 +262,16 @@ theme_preferences_manager_update_preview (theme_color_manager_ui *ui)
|
|||||||
if (!ui)
|
if (!ui)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!theme_get_color (THEME_TOKEN_TEXT_FOREGROUND, &text_fg)
|
if (!theme_preferences_staged_get_color (THEME_TOKEN_TEXT_FOREGROUND, &text_fg)
|
||||||
|| !theme_get_color (THEME_TOKEN_TEXT_BACKGROUND, &text_bg)
|
|| !theme_preferences_staged_get_color (THEME_TOKEN_TEXT_BACKGROUND, &text_bg)
|
||||||
|| !theme_get_color (THEME_TOKEN_SELECTION_FOREGROUND, &sel_fg)
|
|| !theme_preferences_staged_get_color (THEME_TOKEN_SELECTION_FOREGROUND, &sel_fg)
|
||||||
|| !theme_get_color (THEME_TOKEN_SELECTION_BACKGROUND, &sel_bg)
|
|| !theme_preferences_staged_get_color (THEME_TOKEN_SELECTION_BACKGROUND, &sel_bg)
|
||||||
|| !theme_get_color (THEME_TOKEN_MARKER, &marker)
|
|| !theme_preferences_staged_get_color (THEME_TOKEN_MARKER, &marker)
|
||||||
|| !theme_get_color (THEME_TOKEN_TAB_NEW_DATA, &tab_new_data)
|
|| !theme_preferences_staged_get_color (THEME_TOKEN_TAB_NEW_DATA, &tab_new_data)
|
||||||
|| !theme_get_color (THEME_TOKEN_TAB_NEW_MESSAGE, &tab_new_message)
|
|| !theme_preferences_staged_get_color (THEME_TOKEN_TAB_NEW_MESSAGE, &tab_new_message)
|
||||||
|| !theme_get_color (THEME_TOKEN_TAB_HIGHLIGHT, &tab_highlight)
|
|| !theme_preferences_staged_get_color (THEME_TOKEN_TAB_HIGHLIGHT, &tab_highlight)
|
||||||
|| !theme_get_color (THEME_TOKEN_TAB_AWAY, &tab_away)
|
|| !theme_preferences_staged_get_color (THEME_TOKEN_TAB_AWAY, &tab_away)
|
||||||
|| !theme_get_color (THEME_TOKEN_SPELL, &spell))
|
|| !theme_preferences_staged_get_color (THEME_TOKEN_SPELL, &spell))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gtkutil_apply_palette (ui->preview_window, &text_bg, &text_fg, NULL);
|
gtkutil_apply_palette (ui->preview_window, &text_bg, &text_fg, NULL);
|
||||||
@@ -302,15 +451,12 @@ theme_preferences_color_response_cb (GtkDialog *dialog, gint response_id, gpoint
|
|||||||
if (response_id == GTK_RESPONSE_OK)
|
if (response_id == GTK_RESPONSE_OK)
|
||||||
{
|
{
|
||||||
GdkRGBA rgba;
|
GdkRGBA rgba;
|
||||||
gboolean changed = FALSE;
|
|
||||||
|
|
||||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &rgba);
|
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &rgba);
|
||||||
theme_manager_set_token_color (ZOITECHAT_DARK_MODE_LIGHT,
|
theme_preferences_staged_set_color (data->token,
|
||||||
data->token,
|
&rgba,
|
||||||
&rgba,
|
data->color_change_flag,
|
||||||
&changed);
|
TRUE);
|
||||||
if (data->color_change_flag)
|
|
||||||
*data->color_change_flag = *data->color_change_flag || changed;
|
|
||||||
theme_preferences_color_button_apply (data->button, &rgba);
|
theme_preferences_color_button_apply (data->button, &rgba);
|
||||||
theme_preferences_manager_update_preview ((theme_color_manager_ui *) data->manager_ui);
|
theme_preferences_manager_update_preview ((theme_color_manager_ui *) data->manager_ui);
|
||||||
}
|
}
|
||||||
@@ -329,7 +475,7 @@ theme_preferences_color_cb (GtkWidget *button, gpointer userdata)
|
|||||||
|
|
||||||
token = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "zoitechat-theme-token"));
|
token = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "zoitechat-theme-token"));
|
||||||
|
|
||||||
if (!theme_get_color (token, &rgba))
|
if (!theme_preferences_staged_get_color (token, &rgba))
|
||||||
return;
|
return;
|
||||||
dialog = gtk_color_chooser_dialog_new (_("Select color"), GTK_WINDOW (userdata));
|
dialog = gtk_color_chooser_dialog_new (_("Select color"), GTK_WINDOW (userdata));
|
||||||
theme_manager_attach_window (dialog);
|
theme_manager_attach_window (dialog);
|
||||||
@@ -405,14 +551,7 @@ theme_preferences_manager_row_apply (theme_color_manager_row *row, const GdkRGBA
|
|||||||
static void
|
static void
|
||||||
theme_preferences_manager_row_commit (theme_color_manager_row *row, const GdkRGBA *rgba)
|
theme_preferences_manager_row_commit (theme_color_manager_row *row, const GdkRGBA *rgba)
|
||||||
{
|
{
|
||||||
gboolean changed = FALSE;
|
theme_preferences_staged_set_color (row->token, rgba, row->color_change_flag, TRUE);
|
||||||
|
|
||||||
theme_manager_set_token_color (ZOITECHAT_DARK_MODE_LIGHT,
|
|
||||||
row->token,
|
|
||||||
rgba,
|
|
||||||
&changed);
|
|
||||||
if (row->color_change_flag)
|
|
||||||
*row->color_change_flag = *row->color_change_flag || changed;
|
|
||||||
theme_preferences_manager_row_apply (row, rgba);
|
theme_preferences_manager_row_apply (row, rgba);
|
||||||
theme_preferences_manager_update_preview ((theme_color_manager_ui *) row->manager_ui);
|
theme_preferences_manager_update_preview ((theme_color_manager_ui *) row->manager_ui);
|
||||||
}
|
}
|
||||||
@@ -425,7 +564,7 @@ theme_preferences_manager_entry_commit (theme_color_manager_row *row)
|
|||||||
|
|
||||||
if (!gdk_rgba_parse (&rgba, text))
|
if (!gdk_rgba_parse (&rgba, text))
|
||||||
{
|
{
|
||||||
if (theme_get_color (row->token, &rgba))
|
if (theme_preferences_staged_get_color (row->token, &rgba))
|
||||||
theme_preferences_manager_row_apply (row, &rgba);
|
theme_preferences_manager_row_apply (row, &rgba);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -483,7 +622,7 @@ theme_preferences_manager_pick_cb (GtkWidget *button, gpointer user_data)
|
|||||||
GdkRGBA rgba;
|
GdkRGBA rgba;
|
||||||
theme_manager_live_picker_data *data;
|
theme_manager_live_picker_data *data;
|
||||||
|
|
||||||
if (!theme_get_color (row->token, &rgba))
|
if (!theme_preferences_staged_get_color (row->token, &rgba))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dialog = gtk_color_chooser_dialog_new (_("Select color"), row->parent);
|
dialog = gtk_color_chooser_dialog_new (_("Select color"), row->parent);
|
||||||
@@ -542,7 +681,7 @@ theme_preferences_manager_refresh_rows (theme_color_manager_ui *ui)
|
|||||||
theme_color_manager_row *row = g_ptr_array_index (ui->rows, i);
|
theme_color_manager_row *row = g_ptr_array_index (ui->rows, i);
|
||||||
GdkRGBA rgba;
|
GdkRGBA rgba;
|
||||||
|
|
||||||
if (theme_get_color (row->token, &rgba))
|
if (theme_preferences_staged_get_color (row->token, &rgba))
|
||||||
theme_preferences_manager_row_apply (row, &rgba);
|
theme_preferences_manager_row_apply (row, &rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,7 +700,24 @@ theme_preferences_manager_dialog_response_cb (GtkDialog *dialog, gint response_i
|
|||||||
gboolean changed = FALSE;
|
gboolean changed = FALSE;
|
||||||
|
|
||||||
theme_manager_reset_mode_colors (ZOITECHAT_DARK_MODE_LIGHT, &changed);
|
theme_manager_reset_mode_colors (ZOITECHAT_DARK_MODE_LIGHT, &changed);
|
||||||
if (ui->color_change_flag)
|
if (theme_preferences_stage.active)
|
||||||
|
{
|
||||||
|
ThemeSemanticToken token;
|
||||||
|
|
||||||
|
for (token = THEME_TOKEN_MIRC_0; token < THEME_TOKEN_COUNT; token++)
|
||||||
|
{
|
||||||
|
GdkRGBA rgba;
|
||||||
|
|
||||||
|
if (!theme_get_color (token, &rgba))
|
||||||
|
continue;
|
||||||
|
theme_preferences_stage.staged[token] = rgba;
|
||||||
|
theme_preferences_stage.staged_valid[token] = TRUE;
|
||||||
|
}
|
||||||
|
theme_preferences_stage_recompute_changed ();
|
||||||
|
if (ui->color_change_flag)
|
||||||
|
*ui->color_change_flag = theme_preferences_stage.changed;
|
||||||
|
}
|
||||||
|
else if (ui->color_change_flag)
|
||||||
*ui->color_change_flag = *ui->color_change_flag || changed;
|
*ui->color_change_flag = *ui->color_change_flag || changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,7 +851,7 @@ theme_preferences_create_color_manager_dialog (GtkWindow *parent, gboolean *colo
|
|||||||
g_free (token_code);
|
g_free (token_code);
|
||||||
g_free (search_text);
|
g_free (search_text);
|
||||||
|
|
||||||
if (theme_get_color (token, &rgba))
|
if (theme_preferences_staged_get_color (token, &rgba))
|
||||||
theme_preferences_manager_row_apply (row, &rgba);
|
theme_preferences_manager_row_apply (row, &rgba);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (button), "clicked",
|
g_signal_connect (G_OBJECT (button), "clicked",
|
||||||
@@ -724,19 +880,15 @@ static void
|
|||||||
theme_preferences_manage_colors_cb (GtkWidget *button, gpointer user_data)
|
theme_preferences_manage_colors_cb (GtkWidget *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
gboolean *color_change_flag = user_data;
|
gboolean *color_change_flag = user_data;
|
||||||
gboolean old_changed = FALSE;
|
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
|
|
||||||
if (color_change_flag)
|
|
||||||
old_changed = *color_change_flag;
|
|
||||||
|
|
||||||
dialog = theme_preferences_create_color_manager_dialog (GTK_WINDOW (gtk_widget_get_toplevel (button)),
|
dialog = theme_preferences_create_color_manager_dialog (GTK_WINDOW (gtk_widget_get_toplevel (button)),
|
||||||
color_change_flag);
|
color_change_flag);
|
||||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
|
|
||||||
if (color_change_flag && *color_change_flag != old_changed)
|
if (color_change_flag)
|
||||||
theme_manager_save_preferences ();
|
*color_change_flag = theme_preferences_stage.active ? theme_preferences_stage.changed : *color_change_flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -865,12 +1017,8 @@ theme_preferences_import_colors_conf_cb (GtkWidget *button, gpointer user_data)
|
|||||||
char *cfg;
|
char *cfg;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gboolean any_imported = FALSE;
|
gboolean any_imported = FALSE;
|
||||||
gboolean old_changed = FALSE;
|
|
||||||
ThemeSemanticToken token;
|
ThemeSemanticToken token;
|
||||||
|
|
||||||
if (color_change_flag)
|
|
||||||
old_changed = *color_change_flag;
|
|
||||||
|
|
||||||
dialog = gtk_file_chooser_dialog_new (_("Import colors.conf colors"),
|
dialog = gtk_file_chooser_dialog_new (_("Import colors.conf colors"),
|
||||||
GTK_WINDOW (gtk_widget_get_toplevel (button)),
|
GTK_WINDOW (gtk_widget_get_toplevel (button)),
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||||
@@ -906,14 +1054,14 @@ theme_preferences_import_colors_conf_cb (GtkWidget *button, gpointer user_data)
|
|||||||
if (!theme_preferences_read_import_color (cfg, token, &rgba))
|
if (!theme_preferences_read_import_color (cfg, token, &rgba))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
theme_manager_set_token_color (ZOITECHAT_DARK_MODE_LIGHT, token, &rgba, color_change_flag);
|
theme_preferences_staged_set_color (token, &rgba, color_change_flag, TRUE);
|
||||||
any_imported = TRUE;
|
any_imported = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!any_imported)
|
if (!any_imported)
|
||||||
theme_preferences_show_import_error (button, _("No importable colors were found in that colors.conf file."));
|
theme_preferences_show_import_error (button, _("No importable colors were found in that colors.conf file."));
|
||||||
else if (color_change_flag && *color_change_flag != old_changed)
|
else if (color_change_flag)
|
||||||
theme_manager_save_preferences ();
|
*color_change_flag = theme_preferences_stage.active ? theme_preferences_stage.changed : *color_change_flag;
|
||||||
|
|
||||||
g_free (cfg);
|
g_free (cfg);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
@@ -957,7 +1105,7 @@ theme_preferences_create_color_button (GtkWidget *table,
|
|||||||
g_object_set_data (G_OBJECT (but), "zoitechat-theme-color-change", color_change_flag);
|
g_object_set_data (G_OBJECT (but), "zoitechat-theme-color-change", color_change_flag);
|
||||||
gtk_grid_attach (GTK_GRID (table), but, col, row, 1, 1);
|
gtk_grid_attach (GTK_GRID (table), but, col, row, 1, 1);
|
||||||
g_signal_connect (G_OBJECT (but), "clicked", G_CALLBACK (theme_preferences_color_cb), parent);
|
g_signal_connect (G_OBJECT (but), "clicked", G_CALLBACK (theme_preferences_color_cb), parent);
|
||||||
if (theme_get_color (token, &color))
|
if (theme_preferences_staged_get_color (token, &color))
|
||||||
theme_preferences_color_button_apply (but, &color);
|
theme_preferences_color_button_apply (but, &color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1392,26 +1540,34 @@ theme_preferences_populate_gtk3 (theme_preferences_ui *ui)
|
|||||||
g_ptr_array_unref (themes);
|
g_ptr_array_unref (themes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
theme_preferences_gtk3_import_path (theme_preferences_ui *ui, char *path)
|
||||||
|
{
|
||||||
|
char *id = NULL;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!zoitechat_gtk3_theme_service_import (path, &id, &error))
|
||||||
|
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
|
||||||
|
error ? error->message : _("Failed to import GTK3 theme."));
|
||||||
|
g_clear_error (&error);
|
||||||
|
g_free (id);
|
||||||
|
g_free (path);
|
||||||
|
theme_preferences_populate_gtk3 (ui);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
theme_preferences_gtk3_import_cb (GtkWidget *button, gpointer user_data)
|
theme_preferences_gtk3_import_cb (GtkWidget *button, gpointer user_data)
|
||||||
{
|
{
|
||||||
theme_preferences_ui *ui = user_data;
|
theme_preferences_ui *ui = user_data;
|
||||||
GtkWidget *dialog;
|
GtkFileChooserNative *dialog;
|
||||||
GtkFileFilter *filter;
|
GtkFileFilter *filter;
|
||||||
GtkWidget *folder_dialog;
|
|
||||||
char *path;
|
char *path;
|
||||||
char *id = NULL;
|
|
||||||
GError *error = NULL;
|
|
||||||
gint response;
|
|
||||||
|
|
||||||
(void)button;
|
(void)button;
|
||||||
dialog = gtk_file_chooser_dialog_new (_("Import GTK3 Theme"), ui->parent,
|
dialog = gtk_file_chooser_native_new (_("Import GTK3 Theme"), ui->parent,
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||||
_("Import _Folder"), 1,
|
_("_Import"),
|
||||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
_("_Cancel"));
|
||||||
_("_Import"), GTK_RESPONSE_ACCEPT,
|
|
||||||
NULL);
|
|
||||||
theme_manager_attach_window (dialog);
|
|
||||||
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), TRUE);
|
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), TRUE);
|
||||||
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), FALSE);
|
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), FALSE);
|
||||||
filter = gtk_file_filter_new ();
|
filter = gtk_file_filter_new ();
|
||||||
@@ -1426,43 +1582,15 @@ theme_preferences_gtk3_import_cb (GtkWidget *button, gpointer user_data)
|
|||||||
gtk_file_filter_add_pattern (filter, "*.tbz");
|
gtk_file_filter_add_pattern (filter, "*.tbz");
|
||||||
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
||||||
|
|
||||||
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
if (gtk_native_dialog_run (GTK_NATIVE_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT)
|
||||||
if (response == 1)
|
|
||||||
{
|
{
|
||||||
gtk_widget_destroy (dialog);
|
g_object_unref (dialog);
|
||||||
folder_dialog = gtk_file_chooser_dialog_new (_("Import GTK3 Theme Folder"), ui->parent,
|
|
||||||
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
|
||||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
||||||
_("_Import"), GTK_RESPONSE_ACCEPT,
|
|
||||||
NULL);
|
|
||||||
theme_manager_attach_window (folder_dialog);
|
|
||||||
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (folder_dialog), TRUE);
|
|
||||||
if (gtk_dialog_run (GTK_DIALOG (folder_dialog)) != GTK_RESPONSE_ACCEPT)
|
|
||||||
{
|
|
||||||
gtk_widget_destroy (folder_dialog);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (folder_dialog));
|
|
||||||
gtk_widget_destroy (folder_dialog);
|
|
||||||
}
|
|
||||||
else if (response == GTK_RESPONSE_ACCEPT)
|
|
||||||
{
|
|
||||||
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
|
||||||
gtk_widget_destroy (dialog);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_widget_destroy (dialog);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!zoitechat_gtk3_theme_service_import (path, &id, &error))
|
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
||||||
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
|
g_object_unref (dialog);
|
||||||
error ? error->message : _("Failed to import GTK3 theme."));
|
theme_preferences_gtk3_import_path (ui, path);
|
||||||
g_clear_error (&error);
|
|
||||||
g_free (path);
|
|
||||||
theme_preferences_populate_gtk3 (ui);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -13,5 +13,9 @@ GtkWidget *theme_preferences_create_color_page (GtkWindow *parent,
|
|||||||
struct zoitechatprefs *setup_prefs,
|
struct zoitechatprefs *setup_prefs,
|
||||||
gboolean *color_change_flag);
|
gboolean *color_change_flag);
|
||||||
void theme_preferences_apply_to_session (session_gui *gui, InputStyle *input_style);
|
void theme_preferences_apply_to_session (session_gui *gui, InputStyle *input_style);
|
||||||
|
void theme_preferences_stage_begin (void);
|
||||||
|
void theme_preferences_stage_apply (void);
|
||||||
|
void theme_preferences_stage_commit (void);
|
||||||
|
void theme_preferences_stage_discard (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
@@ -276,7 +277,7 @@ theme_runtime_load_migrated_legacy_color (char *cfg,
|
|||||||
return palette_read_legacy_color (cfg, mode->legacy_prefix, def->legacy_index, out_color);
|
return palette_read_legacy_color (cfg, mode->legacy_prefix, def->legacy_index, out_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
palette_write_token_color (int fh, const char *mode_name, const ThemePaletteTokenDef *def, const GdkRGBA *color)
|
palette_write_token_color (int fh, const char *mode_name, const ThemePaletteTokenDef *def, const GdkRGBA *color)
|
||||||
{
|
{
|
||||||
char prefname[256];
|
char prefname[256];
|
||||||
@@ -284,13 +285,13 @@ palette_write_token_color (int fh, const char *mode_name, const ThemePaletteToke
|
|||||||
guint16 green;
|
guint16 green;
|
||||||
guint16 blue;
|
guint16 blue;
|
||||||
|
|
||||||
g_return_if_fail (mode_name != NULL);
|
g_return_val_if_fail (mode_name != NULL, FALSE);
|
||||||
g_return_if_fail (def != NULL);
|
g_return_val_if_fail (def != NULL, FALSE);
|
||||||
g_return_if_fail (color != NULL);
|
g_return_val_if_fail (color != NULL, FALSE);
|
||||||
|
|
||||||
g_snprintf (prefname, sizeof prefname, "theme.mode.%s.token.%s", mode_name, def->name);
|
g_snprintf (prefname, sizeof prefname, "theme.mode.%s.token.%s", mode_name, def->name);
|
||||||
theme_palette_color_get_rgb16 (color, &red, &green, &blue);
|
theme_palette_color_get_rgb16 (color, &red, &green, &blue);
|
||||||
cfg_put_color (fh, red, green, blue, prefname);
|
return cfg_put_color (fh, red, green, blue, prefname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -449,12 +450,11 @@ theme_runtime_load (void)
|
|||||||
user_colors_valid = TRUE;
|
user_colors_valid = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static gboolean
|
||||||
theme_runtime_save (void)
|
theme_runtime_save_to_fd (int fh)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t j;
|
size_t j;
|
||||||
int fh;
|
|
||||||
ThemePalettePersistenceMode modes[] = {
|
ThemePalettePersistenceMode modes[] = {
|
||||||
{ "light", "color", &light_palette, &user_colors_valid },
|
{ "light", "color", &light_palette, &user_colors_valid },
|
||||||
{ "dark", "dark_color", &dark_palette, &dark_user_colors_valid },
|
{ "dark", "dark_color", &dark_palette, &dark_user_colors_valid },
|
||||||
@@ -485,11 +485,8 @@ theme_runtime_save (void)
|
|||||||
else
|
else
|
||||||
modes[1].palette = &dark_palette;
|
modes[1].palette = &dark_palette;
|
||||||
|
|
||||||
fh = zoitechat_open_file ("colors.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
|
if (!cfg_put_int (fh, THEME_PALETTE_MIGRATION_MARKER_VALUE, (char *) THEME_PALETTE_MIGRATION_MARKER_KEY))
|
||||||
if (fh == -1)
|
return FALSE;
|
||||||
return;
|
|
||||||
|
|
||||||
cfg_put_int (fh, THEME_PALETTE_MIGRATION_MARKER_VALUE, (char *) THEME_PALETTE_MIGRATION_MARKER_KEY);
|
|
||||||
|
|
||||||
for (i = 0; i < mode_count; i++)
|
for (i = 0; i < mode_count; i++)
|
||||||
{
|
{
|
||||||
@@ -507,11 +504,101 @@ theme_runtime_save (void)
|
|||||||
if (!custom_tokens[def->token])
|
if (!custom_tokens[def->token])
|
||||||
continue;
|
continue;
|
||||||
g_assert (theme_palette_get_color (modes[i].palette, def->token, &color));
|
g_assert (theme_palette_get_color (modes[i].palette, def->token, &color));
|
||||||
palette_write_token_color (fh, modes[i].mode_name, def, &color);
|
if (!palette_write_token_color (fh, modes[i].mode_name, def, &color))
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close (fh);
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
theme_runtime_save_prepare (char **temp_path)
|
||||||
|
{
|
||||||
|
int fh;
|
||||||
|
char *temp_name;
|
||||||
|
const char *config_dir;
|
||||||
|
|
||||||
|
if (!temp_path)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
config_dir = get_xdir ();
|
||||||
|
if (!config_dir)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
temp_name = g_build_filename (config_dir, "colors.conf.new.XXXXXX", NULL);
|
||||||
|
fh = g_mkstemp (temp_name);
|
||||||
|
if (fh == -1)
|
||||||
|
{
|
||||||
|
g_free (temp_name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!theme_runtime_save_to_fd (fh))
|
||||||
|
{
|
||||||
|
close (fh);
|
||||||
|
g_unlink (temp_name);
|
||||||
|
g_free (temp_name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (close (fh) == -1)
|
||||||
|
{
|
||||||
|
g_unlink (temp_name);
|
||||||
|
g_free (temp_name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*temp_path = temp_name;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
theme_runtime_save_finalize (const char *temp_path)
|
||||||
|
{
|
||||||
|
char *config_path;
|
||||||
|
|
||||||
|
if (!temp_path)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
config_path = g_build_filename (get_xdir (), "colors.conf", NULL);
|
||||||
|
#ifdef WIN32
|
||||||
|
g_unlink (config_path);
|
||||||
|
#endif
|
||||||
|
if (g_rename (temp_path, config_path) == -1)
|
||||||
|
{
|
||||||
|
g_free (config_path);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
g_free (config_path);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
theme_runtime_save_discard (const char *temp_path)
|
||||||
|
{
|
||||||
|
if (!temp_path)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_unlink (temp_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
theme_runtime_save (void)
|
||||||
|
{
|
||||||
|
char *temp_path = NULL;
|
||||||
|
gboolean result;
|
||||||
|
|
||||||
|
if (!theme_runtime_save_prepare (&temp_path))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
result = theme_runtime_save_finalize (temp_path);
|
||||||
|
if (!result)
|
||||||
|
theme_runtime_save_discard (temp_path);
|
||||||
|
g_free (temp_path);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ typedef struct
|
|||||||
} ThemeGtkPaletteMap;
|
} ThemeGtkPaletteMap;
|
||||||
|
|
||||||
void theme_runtime_load (void);
|
void theme_runtime_load (void);
|
||||||
void theme_runtime_save (void);
|
gboolean theme_runtime_save (void);
|
||||||
|
gboolean theme_runtime_save_prepare (char **temp_path);
|
||||||
|
gboolean theme_runtime_save_finalize (const char *temp_path);
|
||||||
|
void theme_runtime_save_discard (const char *temp_path);
|
||||||
gboolean theme_runtime_apply_mode (unsigned int mode, gboolean *palette_changed);
|
gboolean theme_runtime_apply_mode (unsigned int mode, gboolean *palette_changed);
|
||||||
gboolean theme_runtime_apply_dark_mode (gboolean enable);
|
gboolean theme_runtime_apply_dark_mode (gboolean enable);
|
||||||
void theme_runtime_user_set_color (ThemeSemanticToken token, const GdkRGBA *col);
|
void theme_runtime_user_set_color (ThemeSemanticToken token, const GdkRGBA *col);
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ url_treeview_new (GtkWidget *box)
|
|||||||
scroll = gtk_widget_get_parent (view);
|
scroll = gtk_widget_get_parent (view);
|
||||||
gtk_widget_set_hexpand (scroll, TRUE);
|
gtk_widget_set_hexpand (scroll, TRUE);
|
||||||
gtk_widget_set_vexpand (scroll, TRUE);
|
gtk_widget_set_vexpand (scroll, TRUE);
|
||||||
g_signal_connect (G_OBJECT (view), "button_press_event",
|
g_signal_connect (G_OBJECT (view), "button-press-event",
|
||||||
G_CALLBACK (url_treeview_url_clicked_cb), NULL);
|
G_CALLBACK (url_treeview_url_clicked_cb), NULL);
|
||||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
|
||||||
gtk_widget_show (view);
|
gtk_widget_show (view);
|
||||||
|
|||||||
@@ -52,21 +52,48 @@ enum
|
|||||||
|
|
||||||
static void userlist_store_color (GtkListStore *store, GtkTreeIter *iter, ThemeSemanticToken token, gboolean has_token);
|
static void userlist_store_color (GtkListStore *store, GtkTreeIter *iter, ThemeSemanticToken token, gboolean has_token);
|
||||||
|
|
||||||
|
static void
|
||||||
|
userlist_column_width_notify_cb (GtkTreeViewColumn *column, GParamSpec *pspec, gpointer userdata)
|
||||||
|
{
|
||||||
|
(void)pspec;
|
||||||
|
|
||||||
|
int width = gtk_tree_view_column_get_width (column);
|
||||||
|
int *target = (int *)userdata;
|
||||||
|
|
||||||
|
if (!target || width < 1 || *target == width)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*target = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
userlist_apply_saved_column_width (GtkTreeViewColumn *column, int width)
|
||||||
|
{
|
||||||
|
if (!column || width < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gtk_tree_view_column_set_fixed_width (column, width);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
userlist_update_min_width (session *sess)
|
userlist_update_min_width (session *sess)
|
||||||
{
|
{
|
||||||
GtkRequisition minimum;
|
GtkRequisition minimum;
|
||||||
GtkRequisition natural;
|
GtkRequisition natural;
|
||||||
|
GtkWidget *scrolled_window;
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
if (!sess || !sess->gui || !sess->gui->user_box || !sess->gui->namelistinfo)
|
if (!sess || !sess->gui || !sess->gui->user_box || !sess->gui->namelistinfo || !sess->gui->user_tree)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gtk_widget_get_preferred_size (sess->gui->namelistinfo, &minimum, &natural);
|
gtk_widget_get_preferred_size (sess->gui->namelistinfo, &minimum, &natural);
|
||||||
width = MAX (minimum.width, natural.width) + 16;
|
width = MAX (minimum.width, natural.width);
|
||||||
if (width < 1)
|
if (width < 1)
|
||||||
width = 1;
|
width = 1;
|
||||||
|
|
||||||
|
scrolled_window = gtk_widget_get_parent (sess->gui->user_tree);
|
||||||
|
if (GTK_IS_SCROLLED_WINDOW (scrolled_window))
|
||||||
|
gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (scrolled_window), width);
|
||||||
gtk_widget_set_size_request (sess->gui->user_box, width, -1);
|
gtk_widget_set_size_request (sess->gui->user_box, width, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -682,6 +709,7 @@ static void
|
|||||||
userlist_add_columns (GtkTreeView * treeview)
|
userlist_add_columns (GtkTreeView * treeview)
|
||||||
{
|
{
|
||||||
GtkCellRenderer *renderer;
|
GtkCellRenderer *renderer;
|
||||||
|
GtkTreeViewColumn *column;
|
||||||
|
|
||||||
/* icon column */
|
/* icon column */
|
||||||
renderer = gtk_cell_renderer_pixbuf_new ();
|
renderer = gtk_cell_renderer_pixbuf_new ();
|
||||||
@@ -690,15 +718,27 @@ userlist_add_columns (GtkTreeView * treeview)
|
|||||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||||
-1, NULL, renderer,
|
-1, NULL, renderer,
|
||||||
"pixbuf", 0, NULL);
|
"pixbuf", 0, NULL);
|
||||||
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), 0);
|
||||||
|
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||||
|
|
||||||
/* nick column */
|
/* nick column */
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
if (prefs.hex_gui_compact)
|
if (prefs.hex_gui_compact)
|
||||||
g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);
|
g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);
|
||||||
|
g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
||||||
gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1);
|
gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1);
|
||||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||||
-1, NULL, renderer,
|
-1, NULL, renderer,
|
||||||
"text", 1, THEME_GTK_FOREGROUND_PROPERTY, 4, NULL);
|
"text", 1, THEME_GTK_FOREGROUND_PROPERTY, 4, NULL);
|
||||||
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), 1);
|
||||||
|
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||||
|
gtk_tree_view_column_set_expand (column, TRUE);
|
||||||
|
gtk_tree_view_column_set_min_width (column, 1);
|
||||||
|
gtk_tree_view_column_set_resizable (column, TRUE);
|
||||||
|
userlist_apply_saved_column_width (column, prefs.hex_gui_ulist_nick_width);
|
||||||
|
g_signal_connect (G_OBJECT (column), "notify::width",
|
||||||
|
G_CALLBACK (userlist_column_width_notify_cb),
|
||||||
|
&prefs.hex_gui_ulist_nick_width);
|
||||||
|
|
||||||
if (prefs.hex_gui_ulist_show_hosts)
|
if (prefs.hex_gui_ulist_show_hosts)
|
||||||
{
|
{
|
||||||
@@ -706,10 +746,20 @@ userlist_add_columns (GtkTreeView * treeview)
|
|||||||
renderer = gtk_cell_renderer_text_new ();
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
if (prefs.hex_gui_compact)
|
if (prefs.hex_gui_compact)
|
||||||
g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);
|
g_object_set (G_OBJECT (renderer), "ypad", 0, NULL);
|
||||||
|
g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
||||||
gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1);
|
gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (renderer), 1);
|
||||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
|
||||||
-1, NULL, renderer,
|
-1, NULL, renderer,
|
||||||
"text", 2, NULL);
|
"text", 2, NULL);
|
||||||
|
column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), 2);
|
||||||
|
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||||
|
gtk_tree_view_column_set_expand (column, TRUE);
|
||||||
|
gtk_tree_view_column_set_min_width (column, 1);
|
||||||
|
gtk_tree_view_column_set_resizable (column, TRUE);
|
||||||
|
userlist_apply_saved_column_width (column, prefs.hex_gui_ulist_host_width);
|
||||||
|
g_signal_connect (G_OBJECT (column), "notify::width",
|
||||||
|
G_CALLBACK (userlist_column_width_notify_cb),
|
||||||
|
&prefs.hex_gui_ulist_host_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -836,7 +886,7 @@ userlist_create (GtkWidget *box)
|
|||||||
treeview = gtk_tree_view_new ();
|
treeview = gtk_tree_view_new ();
|
||||||
gtk_widget_set_name (treeview, "zoitechat-userlist");
|
gtk_widget_set_name (treeview, "zoitechat-userlist");
|
||||||
gtk_widget_set_can_focus (treeview, TRUE);
|
gtk_widget_set_can_focus (treeview, TRUE);
|
||||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), TRUE);
|
||||||
gtk_tree_selection_set_mode (gtk_tree_view_get_selection
|
gtk_tree_selection_set_mode (gtk_tree_view_get_selection
|
||||||
(GTK_TREE_VIEW (treeview)),
|
(GTK_TREE_VIEW (treeview)),
|
||||||
GTK_SELECTION_MULTIPLE);
|
GTK_SELECTION_MULTIPLE);
|
||||||
@@ -847,26 +897,26 @@ userlist_create (GtkWidget *box)
|
|||||||
gtk_drag_source_set (treeview, GDK_BUTTON1_MASK, dnd_src_target, 1, GDK_ACTION_MOVE);
|
gtk_drag_source_set (treeview, GDK_BUTTON1_MASK, dnd_src_target, 1, GDK_ACTION_MOVE);
|
||||||
|
|
||||||
/* file DND (for DCC) */
|
/* file DND (for DCC) */
|
||||||
g_signal_connect (G_OBJECT (treeview), "drag_motion",
|
g_signal_connect (G_OBJECT (treeview), "drag-motion",
|
||||||
G_CALLBACK (userlist_dnd_motion), treeview);
|
G_CALLBACK (userlist_dnd_motion), treeview);
|
||||||
g_signal_connect (G_OBJECT (treeview), "drag_leave",
|
g_signal_connect (G_OBJECT (treeview), "drag-leave",
|
||||||
G_CALLBACK (userlist_dnd_leave), 0);
|
G_CALLBACK (userlist_dnd_leave), 0);
|
||||||
g_signal_connect (G_OBJECT (treeview), "drag_data_received",
|
g_signal_connect (G_OBJECT (treeview), "drag-data-received",
|
||||||
G_CALLBACK (userlist_dnd_drop), treeview);
|
G_CALLBACK (userlist_dnd_drop), treeview);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (treeview), "button_press_event",
|
g_signal_connect (G_OBJECT (treeview), "button-press-event",
|
||||||
G_CALLBACK (userlist_click_cb), 0);
|
G_CALLBACK (userlist_click_cb), 0);
|
||||||
g_signal_connect (G_OBJECT (treeview), "key_press_event",
|
g_signal_connect (G_OBJECT (treeview), "key-press-event",
|
||||||
G_CALLBACK (userlist_key_cb), 0);
|
G_CALLBACK (userlist_key_cb), 0);
|
||||||
|
|
||||||
/* tree/chanview DND */
|
/* tree/chanview DND */
|
||||||
g_signal_connect (G_OBJECT (treeview), "drag_begin",
|
g_signal_connect (G_OBJECT (treeview), "drag-begin",
|
||||||
G_CALLBACK (mg_drag_begin_cb), NULL);
|
G_CALLBACK (mg_drag_begin_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (treeview), "drag_drop",
|
g_signal_connect (G_OBJECT (treeview), "drag-drop",
|
||||||
G_CALLBACK (mg_drag_drop_cb), NULL);
|
G_CALLBACK (mg_drag_drop_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (treeview), "drag_motion",
|
g_signal_connect (G_OBJECT (treeview), "drag-motion",
|
||||||
G_CALLBACK (mg_drag_motion_cb), NULL);
|
G_CALLBACK (mg_drag_motion_cb), NULL);
|
||||||
g_signal_connect (G_OBJECT (treeview), "drag_end",
|
g_signal_connect (G_OBJECT (treeview), "drag-end",
|
||||||
G_CALLBACK (mg_drag_end_cb), NULL);
|
G_CALLBACK (mg_drag_end_cb), NULL);
|
||||||
|
|
||||||
userlist_add_columns (GTK_TREE_VIEW (treeview));
|
userlist_add_columns (GTK_TREE_VIEW (treeview));
|
||||||
|
|||||||
@@ -581,6 +581,19 @@ fe_exit (void)
|
|||||||
g_main_loop_quit(main_loop);
|
g_main_loop_quit(main_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fe_preferences_save_result
|
||||||
|
fe_preferences_persistence_save_all (void)
|
||||||
|
{
|
||||||
|
fe_preferences_save_result result;
|
||||||
|
|
||||||
|
result.success = save_config () != 0;
|
||||||
|
result.partial_failure = FALSE;
|
||||||
|
result.config_failed = !result.success;
|
||||||
|
result.theme_failed = FALSE;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fe_new_server (struct server *serv)
|
fe_new_server (struct server *serv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,12 +4,6 @@
|
|||||||
;#define APPARCH "x64"
|
;#define APPARCH "x64"
|
||||||
;#define PROJECTDIR "C:\...\zoitechat\win32\installer\"
|
;#define PROJECTDIR "C:\...\zoitechat\win32\installer\"
|
||||||
|
|
||||||
;http://mitrich.net23.net/?/inno-download-plugin.html
|
|
||||||
#ifexist "idp.iss"
|
|
||||||
#define USE_INNO_DOWNLOAD_PLUGIN
|
|
||||||
#include <idp.iss>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[Setup]
|
[Setup]
|
||||||
AppName=ZoiteChat
|
AppName=ZoiteChat
|
||||||
AppVersion={#APPVER}
|
AppVersion={#APPVER}
|
||||||
@@ -65,8 +59,8 @@ Name: "plugins\upd"; Description: "Update Checker"; Types: normal custom; Flags:
|
|||||||
Name: "plugins\winamp"; Description: "Winamp"; Types: custom; Flags: disablenouninstallwarning
|
Name: "plugins\winamp"; Description: "Winamp"; Types: custom; Flags: disablenouninstallwarning
|
||||||
Name: "langs"; Description: "Language Interfaces"; Types: custom; Flags: disablenouninstallwarning
|
Name: "langs"; Description: "Language Interfaces"; Types: custom; Flags: disablenouninstallwarning
|
||||||
Name: "langs\lua"; Description: "Lua"; Types: normal custom; Flags: disablenouninstallwarning
|
Name: "langs\lua"; Description: "Lua"; Types: normal custom; Flags: disablenouninstallwarning
|
||||||
Name: "langs\perl"; Description: "Perl (requires Perl 5.20)"; Types: custom; Flags: disablenouninstallwarning
|
Name: "langs\perl"; Description: "Perl (requires Perl 5.42)"; Types: custom; Flags: disablenouninstallwarning
|
||||||
Name: "langs\python"; Description: "Python (requires Python 3.14.2)"; Types: custom; Flags: disablenouninstallwarning
|
Name: "langs\python"; Description: "Python (requires Python 3.14.3)"; Types: custom; Flags: disablenouninstallwarning
|
||||||
|
|
||||||
[Tasks]
|
[Tasks]
|
||||||
Name: portable; Description: "Yes"; GroupDescription: "Portable Mode: Stores configuration files within install directory for portable drives."; Flags: unchecked
|
Name: portable; Description: "Yes"; GroupDescription: "Portable Mode: Stores configuration files within install directory for portable drives."; Flags: unchecked
|
||||||
@@ -282,8 +276,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
|
|
||||||
REDIST := 'https://github.com/zoitechat/gvsbuild/releases/download/zoitechat-2.16.2/vcredist_2015_x64.exe';
|
REDIST := 'https://github.com/zoitechat/gvsbuild/releases/download/zoitechat-2.16.2/vcredist_2015_x64.exe';
|
||||||
PERL := 'https://github.com/zoitechat/gvsbuild/releases/download/zoitechat-2.16.2/Perl.5.20.0.x64.msi';
|
PERL := 'https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_54201_64bit/strawberry-perl-5.42.0.1-64bit.msi';
|
||||||
PY3 := 'https://www.python.org/ftp/python/3.14.2/python-3.14.2-amd64.exe';
|
PY3 := 'https://www.python.org/ftp/python/3.14.3/python-3.14.3-amd64.exe';
|
||||||
SPELL := 'https://github.com/zoitechat/gvsbuild/releases/download/zoitechat-2.16.2/ZoiteChat.Spelling.Dictionaries.r2.exe';
|
SPELL := 'https://github.com/zoitechat/gvsbuild/releases/download/zoitechat-2.16.2/ZoiteChat.Spelling.Dictionaries.r2.exe';
|
||||||
|
|
||||||
if not CheckVCInstall() then
|
if not CheckVCInstall() then
|
||||||
@@ -294,7 +288,7 @@ begin
|
|||||||
|
|
||||||
if not WizardSilent() then
|
if not WizardSilent() then
|
||||||
begin
|
begin
|
||||||
if IsComponentSelected('langs\perl') and not CheckDLL('perl520.dll') then
|
if IsComponentSelected('langs\perl') and not CheckDLL('perl542.dll') then
|
||||||
begin
|
begin
|
||||||
idpAddFile(PERL, ExpandConstant('{tmp}\perl.msi'))
|
idpAddFile(PERL, ExpandConstant('{tmp}\perl.msi'))
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<YourDepsPath>c:\gtk-build\gtk</YourDepsPath>
|
<YourDepsPath>c:\gtk-build\gtk</YourDepsPath>
|
||||||
<YourGendefPath>c:\gtk-build\gendef</YourGendefPath>
|
<YourGendefPath>c:\gtk-build\gendef</YourGendefPath>
|
||||||
<YourPerlPath>c:\gtk-build\perl-5.20</YourPerlPath>
|
<YourPerlPath>c:\gtk-build\perl-5.42.0.1</YourPerlPath>
|
||||||
<YourPython3Path>c:\gtk-build\python-3.14</YourPython3Path>
|
<YourPython3Path>c:\gtk-build\python-3.14</YourPython3Path>
|
||||||
<YourWinSparklePath>c:\gtk-build\WinSparkle</YourWinSparklePath>
|
<YourWinSparklePath>c:\gtk-build\WinSparkle</YourWinSparklePath>
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<GendefPath>$(YourGendefPath)</GendefPath>
|
<GendefPath>$(YourGendefPath)</GendefPath>
|
||||||
<WinSparklePath>$(YourWinSparklePath)\$(ZoiteChatPlatform)</WinSparklePath>
|
<WinSparklePath>$(YourWinSparklePath)\$(ZoiteChatPlatform)</WinSparklePath>
|
||||||
<PerlPath>$(YourPerlPath)\$(ZoiteChatPlatform)</PerlPath>
|
<PerlPath>$(YourPerlPath)\$(ZoiteChatPlatform)</PerlPath>
|
||||||
<PerlLib>perl520</PerlLib>
|
<PerlLib>perl542</PerlLib>
|
||||||
|
|
||||||
<Python3Path>$(YourPython3Path)\$(ZoiteChatPlatform)</Python3Path>
|
<Python3Path>$(YourPython3Path)\$(ZoiteChatPlatform)</Python3Path>
|
||||||
<Python3Lib>python314</Python3Lib>
|
<Python3Lib>python314</Python3Lib>
|
||||||
|
|||||||
Reference in New Issue
Block a user