Compare commits

..
Author SHA1 Message Date
deepend c801c1fb11 Make magick cmd available across CI envs 2026-03-27 17:56:03 -06:00
deepend 3ad7dbd008 Install ImageMagick in all CI builds 2026-03-27 17:36:54 -06:00
deepend 39f5dabf24 Generate app icons from SVG at build time 2026-03-27 17:28:53 -06:00
108 changed files with 2183 additions and 5211 deletions
+9 -35
View File
@@ -28,16 +28,20 @@ jobs:
sudo apt-get install -y --no-install-recommends \ sudo apt-get install -y --no-install-recommends \
build-essential pkg-config meson ninja-build cmake \ build-essential pkg-config meson ninja-build cmake \
gettext \ gettext \
libcanberra-dev libglib2.0-dev \ libcanberra-dev libdbus-glib-1-dev libglib2.0-dev \
libarchive-dev \ libarchive-dev \
libgtk-3-dev \ libgtk-3-dev \
libwayland-client0 libwayland-cursor0 libwayland-egl1 \ libwayland-client0 libwayland-cursor0 libwayland-egl1 \
libxkbcommon0 \ libxkbcommon0 \
libgtk-3-bin libglib2.0-bin shared-mime-info gsettings-desktop-schemas \ libgtk-3-bin libglib2.0-bin shared-mime-info gsettings-desktop-schemas \
liblua5.4-dev libpci-dev libperl-dev libssl-dev libayatana-appindicator3-dev \ libluajit-5.1-dev libpci-dev libperl-dev libssl-dev libayatana-appindicator3-dev \
perl python3 python3-minimal python3-dev python3-cffi mono-devel desktop-file-utils \ perl python3 python3-minimal python3-dev python3-cffi mono-devel desktop-file-utils \
fonts-noto-color-emoji breeze-gtk-theme \ fonts-noto-color-emoji breeze-gtk-theme \
patchelf file curl patchelf file curl imagemagick
if ! command -v magick >/dev/null 2>&1 && command -v convert >/dev/null 2>&1; then
printf '%s\n' '#!/bin/sh' 'exec convert "$@"' | sudo tee /usr/local/bin/magick >/dev/null
sudo chmod +x /usr/local/bin/magick
fi
- name: Configure - name: Configure
run: | run: |
@@ -86,21 +90,11 @@ jobs:
cp -a /usr/lib/x86_64-linux-gnu/python3/dist-packages AppDir/usr/lib/x86_64-linux-gnu/python3/ cp -a /usr/lib/x86_64-linux-gnu/python3/dist-packages AppDir/usr/lib/x86_64-linux-gnu/python3/
fi fi
if [ -d "/usr/lib/x86_64-linux-gnu/perl-base" ]; then
install -d AppDir/usr/lib/x86_64-linux-gnu
cp -a /usr/lib/x86_64-linux-gnu/perl-base AppDir/usr/lib/x86_64-linux-gnu/
fi
if [ -d "/usr/lib/x86_64-linux-gnu/perl" ]; then if [ -d "/usr/lib/x86_64-linux-gnu/perl" ]; then
install -d AppDir/usr/lib/x86_64-linux-gnu install -d AppDir/usr/lib/x86_64-linux-gnu
cp -a /usr/lib/x86_64-linux-gnu/perl AppDir/usr/lib/x86_64-linux-gnu/ cp -a /usr/lib/x86_64-linux-gnu/perl AppDir/usr/lib/x86_64-linux-gnu/
fi fi
if [ -d "/usr/lib/x86_64-linux-gnu/perl5" ]; then
install -d AppDir/usr/lib/x86_64-linux-gnu
cp -a /usr/lib/x86_64-linux-gnu/perl5 AppDir/usr/lib/x86_64-linux-gnu/
fi
if [ -d "/usr/share/perl" ]; then if [ -d "/usr/share/perl" ]; then
install -d AppDir/usr/share install -d AppDir/usr/share
cp -a /usr/share/perl AppDir/usr/share/ cp -a /usr/share/perl AppDir/usr/share/
@@ -110,10 +104,6 @@ jobs:
install -d AppDir/usr/share install -d AppDir/usr/share
cp -a /usr/share/perl5 AppDir/usr/share/ cp -a /usr/share/perl5 AppDir/usr/share/
fi fi
perl -MFile::Spec -e 'print "Build host File::Spec: $INC{\"File/Spec.pm\"}\n"'
find AppDir/usr -path '*/File/Spec.pm' -print -quit | grep -q .
if compgen -G '/usr/lib/x86_64-linux-gnu/libpython3*.so*' > /dev/null; then if compgen -G '/usr/lib/x86_64-linux-gnu/libpython3*.so*' > /dev/null; then
install -d AppDir/usr/lib/x86_64-linux-gnu install -d AppDir/usr/lib/x86_64-linux-gnu
cp -a /usr/lib/x86_64-linux-gnu/libpython3*.so* AppDir/usr/lib/x86_64-linux-gnu/ cp -a /usr/lib/x86_64-linux-gnu/libpython3*.so* AppDir/usr/lib/x86_64-linux-gnu/
@@ -176,7 +166,7 @@ jobs:
APPDIR="${APPDIR:-$(dirname "$(readlink -f "$0")")}" APPDIR="${APPDIR:-$(dirname "$(readlink -f "$0")")}"
export PATH="$APPDIR/usr/bin:${PATH:-/usr/bin:/bin}" export PATH="${PATH:-/usr/bin:/bin}:$APPDIR/usr/bin"
export LD_LIBRARY_PATH="$APPDIR/usr/lib:$APPDIR/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH:-}" export LD_LIBRARY_PATH="$APPDIR/usr/lib:$APPDIR/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH:-}"
export XDG_DATA_DIRS="$APPDIR/usr/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" export XDG_DATA_DIRS="$APPDIR/usr/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
export GTK_EXE_PREFIX="$APPDIR/usr" export GTK_EXE_PREFIX="$APPDIR/usr"
@@ -225,23 +215,6 @@ jobs:
unset GTK_MODULES unset GTK_MODULES
perl5lib_entries=""
for dir in \
"$APPDIR/usr/lib/x86_64-linux-gnu/perl-base" \
"$APPDIR/usr/lib/x86_64-linux-gnu/perl"/* \
"$APPDIR/usr/lib/x86_64-linux-gnu/perl5"/* \
"$APPDIR/usr/share/perl"/* \
"$APPDIR/usr/share/perl5"
do
if [ -d "$dir" ]; then
perl5lib_entries="${perl5lib_entries:+$perl5lib_entries:}$dir"
fi
done
if [ -n "$perl5lib_entries" ]; then
export PERL5LIB="$perl5lib_entries${PERL5LIB:+:$PERL5LIB}"
fi
export PYTHONHOME="$APPDIR/usr" export PYTHONHOME="$APPDIR/usr"
python_stdlib_dir="$(find "$APPDIR/usr/lib" -maxdepth 1 -type d -name 'python3.*' | head -n 1 || true)" python_stdlib_dir="$(find "$APPDIR/usr/lib" -maxdepth 1 -type d -name 'python3.*' | head -n 1 || true)"
pythonpath_entries="" pythonpath_entries=""
@@ -287,6 +260,7 @@ jobs:
EOF EOF
chmod +x AppRun chmod +x AppRun
VERSION="$(git describe --tags --always)" VERSION="$(git describe --tags --always)"
./linuxdeploy-x86_64.AppImage \ ./linuxdeploy-x86_64.AppImage \
+8 -2
View File
@@ -25,8 +25,14 @@ jobs:
with: with:
submodules: true submodules: true
- name: Generate PSL list - name: Install ImageMagick
run: curl -fsSL https://publicsuffix.org/list/public_suffix_list.dat -o src/common/public_suffix_list.dat run: |
apt-get update
apt-get install -y --no-install-recommends imagemagick
if ! command -v magick >/dev/null 2>&1 && command -v convert >/dev/null 2>&1; then
printf '%s\n' '#!/bin/sh' 'exec convert "$@"' > /usr/local/bin/magick
chmod +x /usr/local/bin/magick
fi
- name: Build Flatpak - name: Build Flatpak
id: flatpak_builder id: flatpak_builder
+8 -1
View File
@@ -32,14 +32,21 @@ jobs:
glib2-devel \ glib2-devel \
gtk3 \ gtk3 \
openssl \ openssl \
dbus-glib \
libcanberra \ libcanberra \
libayatana-appindicator \ libayatana-appindicator \
luajit \
iso-codes \ iso-codes \
lua \ lua \
perl \ perl \
python \ python \
python-cffi \ python-cffi \
pciutils pciutils \
imagemagick
if ! command -v magick >/dev/null 2>&1 && command -v convert >/dev/null 2>&1; then
printf '%s\n' '#!/bin/sh' 'exec convert "$@"' > /usr/local/bin/magick
chmod +x /usr/local/bin/magick
fi
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v5 uses: actions/checkout@v5
+9 -2
View File
@@ -39,6 +39,13 @@ jobs:
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install cffi python -m pip install cffi
python -m pip install zstandard python -m pip install zstandard
choco install imagemagick -y --no-progress
if (-not (Get-Command magick -ErrorAction SilentlyContinue)) {
$magickDir = Get-ChildItem 'C:\Program Files\ImageMagick-*' -Directory -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if ($magickDir) {
$magickDir.FullName | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
}
}
$ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue'
function Download-WithRetry { function Download-WithRetry {
@@ -65,8 +72,8 @@ jobs:
Download-WithRetry -Url https://github.com/jrsoftware/issrc/releases/download/is-6_7_1/innosetup-6.7.1.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.18.1/GTK3_Gvsbuild_zoitechat-2.18.1_x64.zip -OutFile deps\gtk-${{ matrix.arch }}.zip 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
Expand-Archive -LiteralPath deps\gtk-${{ matrix.arch }}.zip -DestinationPath C:\gtk-build\gtk\x64\release -Force & 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()"
-81
View File
@@ -1,87 +1,6 @@
ZoiteChat ChangeLog ZoiteChat ChangeLog
================= =================
2.18.2 (2026-06-20)
-------------------
- Improved security and connection handling with stronger TLS defaults,
safer certificate/hostname validation, FiSHLiM OpenSSL fixes, keyring support,
and getaddrinfo-based DCC lookups.
- Expanded FiSHLiM usability with a GTK key manager, context-menu access, and clearer
channel/private-message key handling.
- Improved keyboard and navigation behavior with customizable keybinds, reset support,
channel-name switching, /server -noproxy, and configurable stale-link ping checks.
- Refined the GTK interface with native file chooser dialogs, topic layout preferences,
timestamp/date hover tooltips, better restore-down relayout, text scroll speed controls,
and aligned network meters.
- Added privacy and display options, including hiding join/part hostmasks and improved
topic/multiline mode layout controls.
- Fixed several platform/UI edge cases, including tray restore from iconified state, DBus unload
handling, GTK3 theme refresh/saving, and tab switcher compatibility.
2.18.1 (2026-05-21)
-------------------
- Migrated D-Bus handling to GDBus.
- Enabled mouse wheel channel switching by default and consumed handled tab wheel events.
- Switched main panes to native GTK scrollbars.
- Tightened userlist button and meter layout.
- Made the native Windows file chooser modal.
- Set the Windows AppUserModelID before GTK startup.
- Updated Windows CI to use the new GTK3 bundle zip.
- Updated Windows installer architecture checks to use x64-compatible detection.
- Bumped the Flatpak Perl runtime to 5.42.2.
- Fixed palette color reads to preserve base GTK state.
- Fixed auto-replace whole-word matching.
- Fixed checksum file stream cleanup.
- Fixed byte handling in the Python console.
- Guarded GTK drag-and-drop handlers against null windows.
- Fixed size_t and integer handling issues.
- Removed the Winamp plugin.
2.18.0 (2026-04-20)
-------------------
- Added optional close buttons on tabs.
- Added Ctrl+W to close tabs and Ctrl+Shift+T to reopen recently closed tabs.
- Expanded theme import support with .hct support in colors.conf import.
- Added pevent import support from .hct theme files and improved import result messaging.
- Expanded palette and selection CSS styling for better theme consistency.
- Auto-sizes the topic bar to wrapped text for better multi-line topic handling.
- Refined command-character parsing when pasting path-like text.
- Tightened topic link detection and opening rules.
- Added Public Suffix List validation for host links to reduce bad link matches.
- Improved channel tree behavior by ignoring collapsed parent selections.
- Sanitized the Linux open environment for AppImage builds and added safer fallback handling.
- Labeled Windows installer runtimes with exact versions.
- Fixed the notification icon and corrected the Flatpak screenshot asset.
- Improved AppStream metainfo validation.
2.18.0~pre6 (2026-03-30)
------------------------
- Applied app theme CSS to the menubar consistently across the app.
- Restored horizontal separator lines in menus.
- Improved Windows installer VC++ redistributable handling by failing loudly when missing and using the official Microsoft download endpoint.
- Fixed Windows locale path resolution in both GTK and text frontends.
- Fixed duplicate dialog buttons persisting in the UI.
- Fixed GTK auto-replace cursor snapback.
- Restored hiding of formatting control bytes so only formatted output is shown.
- Added one-click client SSL certificate tools, including generation with P-256 certificates.
- Added client SSL certificate import support in the network editor.
- Added 99-color support.
- Fixed xtext link hit-testing coordinates.
- Fixed short-palette fallback clobbering tab colors.
- Lazy-loads Preferences pages on first open for faster dialog startup.
- Removed unused UI icons.
- Added a None option for resetting the GTK3 theme back to system/default behavior.
- Added channel-only mode to Ctrl+F search.
- Disabled disk info in sysinfo.
- Wrapped the topic bar in a scroller with bounded height.
- Added close buttons to tabs.
- Fixed fallback GTK menu highlight states.
- Applied configured font preferences to the topic bar, channel tree, user list, and input box.
2.18.0~pre5 (2026-03-22) 2.18.0~pre5 (2026-03-22)
------------------------ ------------------------
- Overhauled preferences/config saving: fully staged and transactional, debounced - Overhauled preferences/config saving: fully staged and transactional, debounced
+121
View File
@@ -0,0 +1,121 @@
#!/usr/bin/env python3
import argparse
import contextlib
import pathlib
import shutil
import subprocess
import tempfile
SIZES = [16, 24, 32, 40, 48, 64, 96, 128, 256]
def run(cmd):
subprocess.run(cmd, check=True)
def try_run(cmd):
result = subprocess.run(cmd, text=True, capture_output=True)
return result.returncode == 0, result.stderr.strip()
def magick_cmd():
magick = shutil.which('magick')
if not magick:
raise RuntimeError('missing tool: install ImageMagick (magick)')
return magick
@contextlib.contextmanager
def magick_svg(svg):
text = pathlib.Path(svg).read_text(encoding='utf-8')
fixed = text.replace('href="image/', 'href="data:image/')
fixed = fixed.replace('xlink:href="image/', 'xlink:href="data:image/')
if fixed == text:
yield str(svg)
return
with tempfile.NamedTemporaryFile('w', suffix='.svg', delete=False, encoding='utf-8') as tmp:
tmp.write(fixed)
tmp_path = tmp.name
try:
yield tmp_path
finally:
pathlib.Path(tmp_path).unlink(missing_ok=True)
def render_png(svg, out_png, size):
errors = []
rsvg = shutil.which('rsvg-convert')
if rsvg:
ok, err = try_run([rsvg, '-w', str(size), '-h', str(size), '-o', str(out_png), str(svg)])
if ok:
return
errors.append(err)
inkscape = shutil.which('inkscape')
if inkscape:
ok, err = try_run([
inkscape,
str(svg),
'--export-type=png',
'--export-width',
str(size),
'--export-height',
str(size),
'--export-filename',
str(out_png),
])
if ok:
return
errors.append(err)
with magick_svg(svg) as svg_for_magick:
ok, err = try_run([
magick_cmd(),
svg_for_magick,
'-background',
'none',
'-resize',
f'{size}x{size}',
str(out_png),
])
if ok:
return
errors.append(err)
raise RuntimeError('failed to render png: ' + ' | '.join(e for e in errors if e))
def build_ico(svg, out_ico):
with magick_svg(svg) as svg_for_magick:
run([
magick_cmd(),
svg_for_magick,
'-background',
'none',
'-define',
'icon:auto-resize=' + ','.join(str(size) for size in SIZES),
str(out_ico),
])
def parse_args():
parser = argparse.ArgumentParser(prog='generate_icons.py')
parser.add_argument('input_svg')
parser.add_argument('output_png')
parser.add_argument('--ico', dest='output_ico')
parser.add_argument('--size', type=int, default=48)
return parser.parse_args()
def main():
args = parse_args()
magick_cmd()
svg = pathlib.Path(args.input_svg)
out_png = pathlib.Path(args.output_png)
out_png.parent.mkdir(parents=True, exist_ok=True)
render_png(svg, out_png, args.size)
if args.output_ico:
out_ico = pathlib.Path(args.output_ico)
out_ico.parent.mkdir(parents=True, exist_ok=True)
build_ico(svg, out_ico)
if __name__ == '__main__':
main()
+19 -4
View File
@@ -1,9 +1,24 @@
icon_gen = find_program('generate_icons.py')
find_program('magick', required: true)
icondir = join_paths(get_option('datadir'), 'icons/hicolor') icondir = join_paths(get_option('datadir'), 'icons/hicolor')
install_data( custom_target('zoitechat_png',
'zoitechat.png', input: 'zoitechat.svg',
rename: 'net.zoite.Zoitechat.png', output: 'net.zoite.Zoitechat.png',
install_dir: join_paths(icondir, '48x48/apps') command: [icon_gen, '@INPUT@', '@OUTPUT@', '--size', '48'],
install: true,
install_dir: join_paths(icondir, '48x48/apps'),
) )
if host_machine.system() == 'windows'
custom_target('zoitechat_ico',
input: 'zoitechat.svg',
output: 'zoitechat.ico',
command: [icon_gen, '@INPUT@', '@PRIVATE_DIR@/zoitechat.png', '--size', '48', '--ico', '@OUTPUT@'],
build_by_default: true,
)
endif
install_data( install_data(
'zoitechat.svg', 'zoitechat.svg',
rename: 'net.zoite.Zoitechat.svg', rename: 'net.zoite.Zoitechat.svg',
Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

+6 -13
View File
@@ -13,16 +13,16 @@ if get_option('gtk-frontend')
install_dir: metainfodir install_dir: metainfodir
) )
appstreamcli = find_program('appstreamcli', required: false) appstream_util = find_program('appstream-util', required: false)
if appstreamcli.found() if appstream_util.found()
test('Validate net.zoite.Zoitechat.appdata.xml', appstreamcli, test('Validate net.zoite.Zoitechat.appdata.xml', appstream_util,
args: ['validate', zoitechat_appdata] args: ['validate-relax', zoitechat_appdata]
) )
endif endif
endif endif
desktop_conf = configuration_data() desktop_conf = configuration_data()
if dbus_dep.found() if dbus_glib_dep.found()
desktop_conf.set('exec_command', 'zoitechat --existing %U') desktop_conf.set('exec_command', 'zoitechat --existing %U')
else else
desktop_conf.set('exec_command', 'zoitechat %U') desktop_conf.set('exec_command', 'zoitechat %U')
@@ -97,18 +97,11 @@ if get_option('plugin')
conf.set('SUMMARY', metainfo[1]) conf.set('SUMMARY', metainfo[1])
conf.set('LICENSE', metainfo[2]) conf.set('LICENSE', metainfo[2])
plugin_appdata = configure_file( configure_file(
input: 'net.zoite.Zoitechat.Plugin.metainfo.xml.in', input: 'net.zoite.Zoitechat.Plugin.metainfo.xml.in',
output: 'net.zoite.Zoitechat.Plugin.@[email protected]'.format(name), output: 'net.zoite.Zoitechat.Plugin.@[email protected]'.format(name),
configuration: conf, configuration: conf,
install_dir: get_option('install-plugin-metainfo') ? metainfodir : '', install_dir: get_option('install-plugin-metainfo') ? metainfodir : '',
) )
if appstreamcli.found()
test('Validate net.zoite.Zoitechat.Plugin.@[email protected]'.format(name), appstreamcli,
args: ['validate', plugin_appdata]
)
endif
endforeach endforeach
endif endif
@@ -4,7 +4,7 @@
<extends>net.zoite.Zoitechat</extends> <extends>net.zoite.Zoitechat</extends>
<name>@NAME@ Plugin</name> <name>@NAME@ Plugin</name>
<summary>@SUMMARY@</summary> <summary>@SUMMARY@</summary>
<url type="homepage">https://zoitechat.org/</url> <url type="homepage">https://zoitechat.zoite.net/</url>
<project_license>@LICENSE@</project_license> <project_license>@LICENSE@</project_license>
<metadata_license>CC0-1.0</metadata_license> <metadata_license>CC0-1.0</metadata_license>
<update_contact>deepend_AT_zoite.net</update_contact> <update_contact>deepend_AT_zoite.net</update_contact>
+12 -119
View File
@@ -16,12 +16,12 @@
<p>ZoiteChat is an easy to use yet extensible IRC Client based on Hexchat. It allows you to securely join multiple networks and talk to users privately or in channels using a customizable interface. You can even transfer files.</p> <p>ZoiteChat is an easy to use yet extensible IRC Client based on Hexchat. It allows you to securely join multiple networks and talk to users privately or in channels using a customizable interface. You can even transfer files.</p>
<p>ZoiteChat supports features such as: DCC, SASL, proxies, spellcheck, alerts, logging, custom themes, and Python/Perl scripts.</p> <p>ZoiteChat supports features such as: DCC, SASL, proxies, spellcheck, alerts, logging, custom themes, and Python/Perl scripts.</p>
</description> </description>
<url type="homepage">https://zoitechat.org</url> <url type="homepage">https://zoitechat.zoite.net</url>
<url type="bugtracker">https://github.com/zoitechat/zoitechat</url> <url type="bugtracker">https://github.com/zoitechat/zoitechat</url>
<url type="help">https://docs.zoitechat.org/en/latest/</url> <url type="help">https://docs.zoitechat.zoite.net/en/latest/</url>
<screenshots> <screenshots>
<screenshot type="default"> <screenshot type="default">
<image>https://zoitechat.org/assets/img/zoitechat-screenshot.png</image> <image>https://zoitechat.zoite.net/assets/ZoiteChat.png</image>
<caption>Main Chat Window</caption> <caption>Main Chat Window</caption>
</screenshot> </screenshot>
</screenshots> </screenshots>
@@ -29,122 +29,7 @@
<id>zoitechat.desktop</id> <id>zoitechat.desktop</id>
</provides> </provides>
<releases> <releases>
<release date="2026-06-20" version="2.18.2"> <release date="2026-03-22" version="2.18.0~pre5">
<description>
<p>Security and connections:</p>
<ul>
<li>Improved TLS, certificate and hostname validation, FiSHLiM OpenSSL handling, keyring support, and DCC host lookups.</li>
</ul>
<p>FiSHLiM:</p>
<ul>
<li>Added a GTK key manager with context-menu access and clearer channel/private-message key handling.</li>
</ul>
<p>Interface and preferences:</p>
<ul>
<li>Improved keybind customization, reset support, channel-name switching, <code>/server -noproxy</code>, and stale-link ping checks.</li>
<li>Refined GTK behavior with native file choosers, topic layout preferences, timestamp/date tooltips, text scroll controls, and aligned network meters.</li>
<li>Added privacy and display options for hiding join/part hostmasks and controlling topic/multiline layout.</li>
</ul>
<p>Fixes:</p>
<ul>
<li>Fixed tray restore, DBus unload handling, GTK3 theme refresh/saving, topic relayout, and tab switcher compatibility.</li>
<li>Updated project documentation.</li>
</ul>
</description>
</release>
<release date="2026-05-21" version="2.18.1">
<description>
<ul>
<li>Migrated D-Bus handling to GDBus.</li>
<li>Enabled mouse wheel channel switching by default and consumed handled tab wheel events.</li>
<li>Switched main panes to native GTK scrollbars.</li>
<li>Tightened userlist button and meter layout.</li>
<li>Made the native Windows file chooser modal.</li>
<li>Set the Windows AppUserModelID before GTK startup.</li>
<li>Updated Windows CI to use the new GTK3 bundle zip.</li>
<li>Updated Windows installer architecture checks to use x64-compatible detection.</li>
<li>Bumped the Flatpak Perl runtime to 5.42.2.</li>
<li>Fixed palette color reads to preserve base GTK state.</li>
<li>Fixed auto-replace whole-word matching.</li>
<li>Fixed checksum file stream cleanup.</li>
<li>Fixed byte handling in the Python console.</li>
<li>Guarded GTK drag-and-drop handlers against null windows.</li>
<li>Fixed size_t and integer handling issues.</li>
<li>Removed the Winamp plugin.</li>
</ul>
</description>
</release>
<release date="2026-04-20" version="2.18.0">
<description>
<p>Tabs and navigation:</p>
<ul>
<li>Added optional close buttons on tabs.</li>
<li>Added Ctrl+W to close tabs and Ctrl+Shift+T to reopen recently closed tabs.</li>
<li>Improved channel tree behavior by ignoring collapsed parent selections.</li>
</ul>
<p>Themes and appearance:</p>
<ul>
<li>Expanded theme import support with .hct support in colors.conf import.</li>
<li>Added pevent import support from .hct theme files and improved import result messaging.</li>
<li>Expanded palette and selection CSS styling for better theme consistency.</li>
<li>Auto-sizes the topic bar to wrapped text for better multi-line topic handling.</li>
</ul>
<p>Links and text handling:</p>
<ul>
<li>Refined command-character parsing when pasting path-like text.</li>
<li>Tightened topic link detection and opening rules.</li>
<li>Added Public Suffix List validation for host links to reduce bad link matches.</li>
</ul>
<p>Packaging and platform integration:</p>
<ul>
<li>Sanitized the Linux open environment for AppImage builds and added safer fallback handling.</li>
<li>Labeled Windows installer runtimes with exact versions.</li>
<li>Fixed the notification icon and corrected the Flatpak screenshot asset.</li>
<li>Improved AppStream metainfo validation.</li>
</ul>
</description>
</release>
<release date="2026-03-30" version="2.18.0~pre6">
<description>
<p>GTK theme and UI:</p>
<ul>
<li>Applied app theme CSS to the menubar consistently across the app.</li>
<li>Restored horizontal separator lines in menus.</li>
<li>Fixed duplicate dialog buttons persisting in the UI.</li>
<li>Fixed GTK auto-replace cursor snapback.</li>
<li>Restored hiding of formatting control bytes so only formatted output is shown.</li>
<li>Fixed xtext link hit-testing coordinates.</li>
<li>Fixed short-palette fallback clobbering tab colors.</li>
<li>Added a None option for resetting the GTK3 theme back to system/default behavior.</li>
<li>Wrapped the topic bar in a scroller with bounded height.</li>
<li>Fixed fallback GTK menu highlight states.</li>
<li>Applied configured font preferences to the topic bar, channel tree, user list, and input box.</li>
<li>Removed unused UI icons.</li>
<li>Added close buttons to tabs.</li>
</ul>
<p>Preferences and search:</p>
<ul>
<li>Lazy-loads Preferences pages on first open for faster dialog startup.</li>
<li>Added channel-only mode to Ctrl+F search.</li>
</ul>
<p>Security and certificates:</p>
<ul>
<li>Added one-click client SSL certificate tools, including generation with P-256 certificates.</li>
<li>Added client SSL certificate import support in the network editor.</li>
</ul>
<p>Windows and packaging:</p>
<ul>
<li>Improved Windows installer VC++ redistributable handling by failing loudly when missing and using the official Microsoft download endpoint.</li>
<li>Fixed Windows locale path resolution in both GTK and text frontends.</li>
</ul>
<p>Other changes:</p>
<ul>
<li>Added 99-color support.</li>
<li>Disabled disk info in sysinfo.</li>
</ul>
</description>
</release>
<release date="2026-03-22" version="2.18.0~pre5">
<description> <description>
<p>Preferences and config saving:</p> <p>Preferences and config saving:</p>
<ul> <ul>
@@ -175,6 +60,14 @@
</ul> </ul>
</description> </description>
</release> </release>
<release date="2026-03-22" version="2.18.0~pre5">
<description>
<p>Version metadata update:</p>
<ul>
<li>Bumped release version references to <code>2.18.0~pre5</code> across build and packaging files.</li>
</ul>
</description>
</release>
<release date="2026-03-14" version="2.18.0~pre4"> <release date="2026-03-14" version="2.18.0~pre4">
<description> <description>
<p>UI fixes, topic bar improvements, and selection styling updates:</p> <p>UI fixes, topic bar improvements, and selection styling updates:</p>
+27
View File
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/icons">
<file alias="zoitechat.png" preprocess="to-pixdata">@ZOITECHAT_PNG@</file>
<file alias="zoitechat.svg">icons/zoitechat.svg</file>
<file alias="book.png" preprocess="to-pixdata">icons/book.png</file>
<file alias="ulist_voice.png" preprocess="to-pixdata">icons/ulist_voice.png</file>
<file alias="ulist_halfop.png" preprocess="to-pixdata">icons/ulist_halfop.png</file>
<file alias="ulist_op.png" preprocess="to-pixdata">icons/ulist_op.png</file>
<file alias="ulist_owner.png" preprocess="to-pixdata">icons/ulist_owner.png</file>
<file alias="ulist_founder.png" preprocess="to-pixdata">icons/ulist_founder.png</file>
<file alias="ulist_netop.png" preprocess="to-pixdata">icons/ulist_netop.png</file>
<file alias="tray_normal.png" preprocess="to-pixdata">@ZOITECHAT_PNG@</file>
<file alias="tray_fileoffer.png" preprocess="to-pixdata">icons/tray_fileoffer.png</file>
<file alias="tray_highlight.png" preprocess="to-pixdata">icons/tray_highlight.png</file>
<file alias="tray_message.png" preprocess="to-pixdata">icons/tray_message.png</file>
<file alias="tree_channel.png" preprocess="to-pixdata">icons/tree_channel.png</file>
<file alias="tree_dialog.png" preprocess="to-pixdata">icons/tree_dialog.png</file>
<file alias="tree_server.png" preprocess="to-pixdata">icons/tree_server.png</file>
<file alias="tree_util.png" preprocess="to-pixdata">icons/tree_util.png</file>
</gresource>
</gresources>
+7 -5
View File
@@ -7,13 +7,14 @@
"command": "zoitechat", "command": "zoitechat",
"finish-args": [ "finish-args": [
"--share=ipc", "--share=ipc",
"--socket=wayland", "--socket=x11",
"--socket=fallback-x11",
"--share=network", "--share=network",
"--socket=pulseaudio", "--socket=pulseaudio",
"--filesystem=xdg-download", "--filesystem=xdg-download",
"--filesystem=xdg-data/themes:ro", "--filesystem=xdg-data/themes:ro",
"--filesystem=xdg-data/icons:ro", "--filesystem=xdg-data/icons:ro",
"--filesystem=~/.themes:ro",
"--filesystem=~/.icons:ro",
"--filesystem=xdg-run/tray-icon:create", "--filesystem=xdg-run/tray-icon:create",
"--env=GTK_CSD=1", "--env=GTK_CSD=1",
"--talk-name=org.freedesktop.Notifications", "--talk-name=org.freedesktop.Notifications",
@@ -33,6 +34,7 @@
} }
}, },
"modules": [ "modules": [
"shared-modules/dbus-glib/dbus-glib.json",
"shared-modules/lua5.4/lua-5.4.json", "shared-modules/lua5.4/lua-5.4.json",
"shared-modules/libcanberra/libcanberra.json", "shared-modules/libcanberra/libcanberra.json",
"shared-modules/libayatana-appindicator/libayatana-appindicator-gtk3.json", "shared-modules/libayatana-appindicator/libayatana-appindicator-gtk3.json",
@@ -43,9 +45,9 @@
"buildsystem": "meson", "buildsystem": "meson",
"sources": [ "sources": [
{ {
"type": "archive", "type": "git",
"url": "https://github.com/pavouk/lgi/archive/c9b8e4473c6421f2a215d8c06c0d94b86eb0b26a.tar.gz", "url": "https://github.com/pavouk/lgi.git",
"sha256": "db67b2b7ee89fa566f783486d56be7203552a997bc55f35020b57dd2776b9943" "commit": "c9b8e4473c6421f2a215d8c06c0d94b86eb0b26a"
} }
] ]
}, },
+2 -2
View File
@@ -13,8 +13,8 @@
"sources": [ "sources": [
{ {
"type": "archive", "type": "archive",
"url": "https://www.cpan.org/src/5.0/perl-5.42.2.tar.xz", "url": "https://www.cpan.org/src/5.0/perl-5.40.1.tar.xz",
"sha256": "0a585eeb9e363c0f80482ddb3571625250c2c86aeb408853e8ea50805cfb14bb" "sha256": "dfa20c2eef2b4af133525610bbb65dd13777ecf998c9c5b1ccf0d308e732ee3f"
} }
] ]
} }
+4 -6
View File
@@ -1,5 +1,5 @@
project('zoitechat', 'c', project('zoitechat', 'c',
version: '2.18.2', version: '2.18.0~pre5',
meson_version: '>= 0.55.0', meson_version: '>= 0.55.0',
default_options: [ default_options: [
'c_std=c17', 'c_std=c17',
@@ -18,8 +18,7 @@ libgmodule_dep = dependency('gmodule-2.0')
libcanberra_dep = dependency('libcanberra', version: '>= 0.22', libcanberra_dep = dependency('libcanberra', version: '>= 0.22',
required: get_option('libcanberra')) required: get_option('libcanberra'))
dbus_dep = dependency('gio-2.0', required: get_option('dbus')) dbus_glib_dep = dependency('dbus-glib-1', required: get_option('dbus'))
libsecret_dep = dependency('libsecret-1', required: false)
global_deps = [] global_deps = []
if cc.get_id() == 'msvc' if cc.get_id() == 'msvc'
@@ -40,8 +39,7 @@ config_h.set10('ENABLE_NLS', true)
# Optional features # Optional features
config_h.set('USE_OPENSSL', libssl_dep.found()) config_h.set('USE_OPENSSL', libssl_dep.found())
config_h.set('USE_LIBCANBERRA', libcanberra_dep.found()) config_h.set('USE_LIBCANBERRA', libcanberra_dep.found())
config_h.set('USE_DBUS', dbus_dep.found()) config_h.set('USE_DBUS', dbus_glib_dep.found())
config_h.set('HAVE_LIBSECRET', libsecret_dep.found())
config_h.set('USE_PLUGIN', get_option('plugin')) config_h.set('USE_PLUGIN', get_option('plugin'))
config_h.set('USE_GTK_FRONTEND', get_option('gtk-frontend')) config_h.set('USE_GTK_FRONTEND', get_option('gtk-frontend'))
@@ -183,7 +181,7 @@ if meson.version().version_compare('>= 0.55.0')
'GTK Frontend': get_option('gtk-frontend') ? 'enabled (GTK+ 3.22+)' : 'disabled', 'GTK Frontend': get_option('gtk-frontend') ? 'enabled (GTK+ 3.22+)' : 'disabled',
'TLS (openssl)': libssl_dep.found(), 'TLS (openssl)': libssl_dep.found(),
'Plugin Support': get_option('plugin'), 'Plugin Support': get_option('plugin'),
'DBus Support': dbus_dep.found(), 'DBus Support': dbus_glib_dep.found(),
'libcanberra': libcanberra_dep.found(), 'libcanberra': libcanberra_dep.found(),
}, section: 'Features') }, section: 'Features')
+4 -1
View File
@@ -44,7 +44,7 @@ option('with-exec', type: 'boolean',
option('with-fishlim', type: 'boolean', option('with-fishlim', type: 'boolean',
description: 'Fish encryption plugin, requires openssl' description: 'Fish encryption plugin, requires openssl'
) )
option('with-lua', type: 'string', value: 'lua-5.4', option('with-lua', type: 'string', value: 'luajit',
description: 'Lua scripting plugin, value is pkg-config name to use or "false"' description: 'Lua scripting plugin, value is pkg-config name to use or "false"'
) )
option('with-perl', type: 'string', value: 'perl', option('with-perl', type: 'string', value: 'perl',
@@ -59,6 +59,9 @@ option('with-sysinfo', type: 'boolean',
option('with-upd', type: 'boolean', option('with-upd', type: 'boolean',
description: 'Update plugin, Windows only' description: 'Update plugin, Windows only'
) )
option('with-winamp', type: 'boolean',
description: 'Winamp plugin, Windows only'
)
option('with-perl-legacy-api', type: 'boolean', value: false, option('with-perl-legacy-api', type: 'boolean', value: false,
description: 'Enables the legacy IRC perl module for compatibility with old scripts' description: 'Enables the legacy IRC perl module for compatibility with old scripts'
) )
-102
View File
@@ -1,102 +0,0 @@
Name: zoitechat
Version: 2.18.2
Release: %autorelease
Summary: HexChat-based IRC client
License: GPL-2.0-or-later WITH cryptsetup-OpenSSL-exception
URL: https://github.com/ZoiteChat/zoitechat
Source0: %{url}/archive/refs/tags/%{name}-%{version}.tar.gz
BuildRequires: desktop-file-utils
BuildRequires: gcc
BuildRequires: gettext
BuildRequires: libappstream-glib
BuildRequires: meson >= 0.55.0
BuildRequires: perl
BuildRequires: perl-devel
BuildRequires: python3
BuildRequires: python3-cffi
BuildRequires: publicsuffix-list
BuildRequires: xwayland-run
BuildRequires: weston
BuildRequires: pkgconfig(ayatana-appindicator3-0.1)
BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(gio-2.0) >= 2.36.0
BuildRequires: pkgconfig(gmodule-2.0)
BuildRequires: pkgconfig(gtk+-3.0) >= 3.22
BuildRequires: pkgconfig(iso-codes)
BuildRequires: pkgconfig(libarchive)
BuildRequires: pkgconfig(libcanberra) >= 0.22
BuildRequires: pkgconfig(libpci)
BuildRequires: pkgconfig(lua)
BuildRequires: pkgconfig(openssl) >= 0.9.8
BuildRequires: pkgconfig(python3)
Requires: hicolor-icon-theme
Requires: iso-codes
%package devel
Summary: Development files for ZoiteChat plugins
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
Development files for building ZoiteChat plugins.
%description
ZoiteChat is a HexChat-based IRC client for Windows and UNIX-like operating
systems.
%prep
%autosetup -C
%build
%meson \
-Dtext-frontend=false \
-Dwith-checksum=true \
-Dwith-fishlim=true \
-Dwith-lua=lua \
-Dwith-perl=perl \
-Dwith-python=python3 \
-Dwith-sysinfo=true \
-Dinstall-appdata=true \
-Dinstall-plugin-metainfo=true
%meson_build
%install
%meson_install
%find_lang %{name}
%check
desktop-file-validate %{buildroot}%{_datadir}/applications/net.zoite.Zoitechat.desktop
appstream-util validate-relax --nonet %{buildroot}%{_datadir}/metainfo/net.zoite.Zoitechat.appdata.xml
appstream-util validate-relax --nonet %{buildroot}%{_datadir}/metainfo/net.zoite.Zoitechat*.metainfo.xml
xwfb-run -- /usr/bin/meson test -C %{_vpath_builddir} --num-processes %{_smp_build_ncpus} --print-errorlogs \
"Theme Manager Dispatch Routing Tests" \
"Validate net.zoite.Zoitechat.desktop" \
"Validate translations" \
"Fishlim Tests"
%files -f %{name}.lang
%license COPYING
%doc readme.md troubleshooting.md
%{_bindir}/zoitechat
%{_datadir}/applications/net.zoite.Zoitechat.desktop
%{_datadir}/dbus-1/services/org.zoitechat.service.service
%{_datadir}/icons/hicolor/48x48/apps/net.zoite.Zoitechat.png
%{_datadir}/icons/hicolor/scalable/apps/net.zoite.Zoitechat.svg
%{_datadir}/metainfo/net.zoite.Zoitechat.appdata.xml
%{_datadir}/metainfo/net.zoite.Zoitechat*.metainfo.xml
%dir %{_libdir}/zoitechat
%dir %{_libdir}/zoitechat/plugins
%dir %{_libdir}/zoitechat/python
%{_libdir}/zoitechat/plugins/*.so
%{_libdir}/zoitechat/python/*.py
%{_mandir}/man1/zoitechat.1*
%files devel
%{_includedir}/zoitechat-plugin.h
%{_libdir}/pkgconfig/zoitechat-plugin.pc
%changelog
%autochangelog
+1
View File
@@ -8,6 +8,7 @@ arch=('x86_64')
url='https://github.com/zoitechat/zoitechat' url='https://github.com/zoitechat/zoitechat'
license=('GPL-2.0-or-later') license=('GPL-2.0-or-later')
depends=( depends=(
'dbus-glib'
'glib2' 'glib2'
'gtk3' 'gtk3'
'iso-codes' 'iso-codes'
+2 -4
View File
@@ -104,14 +104,12 @@ thread_sha256_file (GTask *task, GFile *file, gpointer task_data, GCancellable *
g_checksum_update (checksum, buffer, ret); g_checksum_update (checksum, buffer, ret);
if (error) { if (error) {
g_checksum_free (checksum);
g_task_return_error (task, error); g_task_return_error (task, error);
goto cleanup; return;
} }
g_task_return_pointer (task, g_strdup (g_checksum_get_string (checksum)), g_free); g_task_return_pointer (task, g_strdup (g_checksum_get_string (checksum)), g_free);
cleanup:
g_input_stream_close(G_INPUT_STREAM(istream), NULL, NULL);
g_object_unref(istream);
g_checksum_free (checksum); g_checksum_free (checksum);
} }
+22 -8
View File
@@ -91,13 +91,27 @@ static const signed char fish_unbase64[256] = {
#include <openssl/provider.h> #include <openssl/provider.h>
static OSSL_PROVIDER *legacy_provider; static OSSL_PROVIDER *legacy_provider;
static OSSL_PROVIDER *default_provider; static OSSL_PROVIDER *default_provider;
static OSSL_LIB_CTX *ossl_ctx;
#endif #endif
int fish_init(void) int fish_init(void)
{ {
#if OPENSSL_VERSION_NUMBER >= 0x30000000L #if OPENSSL_VERSION_NUMBER >= 0x30000000L
legacy_provider = OSSL_PROVIDER_load(NULL, "legacy"); ossl_ctx = OSSL_LIB_CTX_new();
default_provider = OSSL_PROVIDER_load(NULL, "default"); if (!ossl_ctx)
return 0;
legacy_provider = OSSL_PROVIDER_load(ossl_ctx, "legacy");
if (!legacy_provider) {
fish_deinit();
return 0;
}
default_provider = OSSL_PROVIDER_load(ossl_ctx, "default");
if (!default_provider) {
fish_deinit();
return 0;
}
#endif #endif
return 1; return 1;
} }
@@ -115,6 +129,10 @@ void fish_deinit(void)
default_provider = NULL; default_provider = NULL;
} }
if (ossl_ctx) {
OSSL_LIB_CTX_free(ossl_ctx);
ossl_ctx = NULL;
}
#endif #endif
} }
@@ -260,9 +278,7 @@ char *fish_cipher(const char *plaintext, size_t plaintext_len, const char *key,
} }
#if OPENSSL_VERSION_NUMBER >= 0x30000000L #if OPENSSL_VERSION_NUMBER >= 0x30000000L
cipher = EVP_CIPHER_fetch(NULL, "BF-CBC", NULL); cipher = EVP_CIPHER_fetch(ossl_ctx, "BF-CBC", NULL);
if (!cipher)
cipher = (EVP_CIPHER *) EVP_bf_cbc();
#else #else
cipher = (EVP_CIPHER *) EVP_bf_cbc(); cipher = (EVP_CIPHER *) EVP_bf_cbc();
#endif #endif
@@ -270,9 +286,7 @@ char *fish_cipher(const char *plaintext, size_t plaintext_len, const char *key,
} else if (mode == EVP_CIPH_ECB_MODE) { } else if (mode == EVP_CIPH_ECB_MODE) {
#if OPENSSL_VERSION_NUMBER >= 0x30000000L #if OPENSSL_VERSION_NUMBER >= 0x30000000L
cipher = EVP_CIPHER_fetch(NULL, "BF-ECB", NULL); cipher = EVP_CIPHER_fetch(ossl_ctx, "BF-ECB", NULL);
if (!cipher)
cipher = (EVP_CIPHER *) EVP_bf_ecb();
#else #else
cipher = (EVP_CIPHER *) EVP_bf_ecb(); cipher = (EVP_CIPHER *) EVP_bf_ecb();
#endif #endif
+1 -1
View File
@@ -26,7 +26,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile> <ClCompile>
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;HAVE_DH_SET0_PQG;HAVE_DH_GET0_KEY;HAVE_DH_SET0_KEY;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;FISHLIM_EXPORTS;HAVE_DH_SET0_PQG;HAVE_DH_GET0_KEY;HAVE_DH_SET0_KEY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(OpenSslInclude);$(Glib);$(Gtk);..\..\src\common;$(ZoiteChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(DepsRoot)\include;$(OpenSslInclude);$(Glib);..\..\src\common;$(ZoiteChatLib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<ModuleDefinitionFile>fishlim.def</ModuleDefinitionFile> <ModuleDefinitionFile>fishlim.def</ModuleDefinitionFile>
-13
View File
@@ -194,18 +194,6 @@ static gboolean keyfile_save_to_file (GKeyFile *keyfile, char *filename) {
} }
#endif #endif
gchar **keystore_get_targets(gsize *length) {
GKeyFile *keyfile;
gchar **groups;
keyfile = getConfigFile();
groups = g_key_file_get_groups(keyfile, length);
g_key_file_free(keyfile);
return groups;
}
/** /**
* Writes the key store file to disk. * Writes the key store file to disk.
*/ */
@@ -229,7 +217,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
/** /**
* Sets a key in the key store file. * Sets a key in the key store file.
*/ */
gboolean keystore_store_key(const char *nick, const char *key, enum fish_mode mode) { gboolean keystore_store_key(const char *nick, const char *key, enum fish_mode mode) {
const char *password; const char *password;
char *encrypted; char *encrypted;
-1
View File
@@ -33,7 +33,6 @@
char *keystore_get_key(const char *nick, enum fish_mode *mode); char *keystore_get_key(const char *nick, enum fish_mode *mode);
gboolean keystore_store_key(const char *nick, const char *key, enum fish_mode mode); gboolean keystore_store_key(const char *nick, const char *key, enum fish_mode mode);
gboolean keystore_delete_nick(const char *nick); gboolean keystore_delete_nick(const char *nick);
gchar **keystore_get_targets(gsize *length);
#endif #endif
+1 -1
View File
@@ -15,7 +15,7 @@ fishlim_sources = [
] ]
shared_module('fishlim', fishlim_sources, shared_module('fishlim', fishlim_sources,
dependencies: [libgio_dep, gtk_dep, zoitechat_plugin_dep, libssl_dep], dependencies: [libgio_dep, zoitechat_plugin_dep, libssl_dep],
c_args: ['-DOPENSSL_API_COMPAT=0x10100000L'], c_args: ['-DOPENSSL_API_COMPAT=0x10100000L'],
install: true, install: true,
install_dir: plugindir, install_dir: plugindir,
+12 -354
View File
@@ -27,7 +27,6 @@
#include "config.h" #include "config.h"
#include <glib.h> #include <glib.h>
#include <gtk/gtk.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "zoitechat-plugin.h" #include "zoitechat-plugin.h"
@@ -45,7 +44,7 @@ static const char plugin_version[] = "1.0.0";
static const char usage_setkey[] = "Usage: SETKEY [<nick or #channel>] [<mode>:]<password>, sets the key for a channel or nick. Modes: ECB, CBC"; static const char usage_setkey[] = "Usage: SETKEY [<nick or #channel>] [<mode>:]<password>, sets the key for a channel or nick. Modes: ECB, CBC";
static const char usage_delkey[] = "Usage: DELKEY [<nick or #channel>], deletes the key for a channel or nick"; static const char usage_delkey[] = "Usage: DELKEY [<nick or #channel>], deletes the key for a channel or nick";
static const char usage_keyx[] = "Usage: KEYX [<nick>] [ECB|CBC], performs DH1080 key-exchange with <nick>"; static const char usage_keyx[] = "Usage: KEYX [<nick>], performs DH1080 key-exchange with <nick>";
static const char usage_topic[] = "Usage: TOPIC+ <topic>, sets a new encrypted topic for the current channel"; static const char usage_topic[] = "Usage: TOPIC+ <topic>, sets a new encrypted topic for the current channel";
static const char usage_notice[] = "Usage: NOTICE+ <nick or #channel> <notice>"; static const char usage_notice[] = "Usage: NOTICE+ <nick or #channel> <notice>";
static const char usage_msg[] = "Usage: MSG+ <nick or #channel> <message>"; static const char usage_msg[] = "Usage: MSG+ <nick or #channel> <message>";
@@ -53,13 +52,6 @@ static const char usage_msg[] = "Usage: MSG+ <nick or #channel> <message>";
static zoitechat_plugin *ph; static zoitechat_plugin *ph;
static GHashTable *pending_exchanges; static GHashTable *pending_exchanges;
static GtkWidget *fishlim_dialog;
static GtkWidget *fishlim_target_entry;
static GtkWidget *fishlim_key_entry;
static GtkWidget *fishlim_mode_combo;
static GtkWidget *fishlim_status_label;
static GtkListStore *fishlim_store;
static GtkWidget *fishlim_view;
/** /**
@@ -429,7 +421,7 @@ static int handle_keyx_notice(char *word[], char *word_eol[], void *userdata) {
zoitechat_commandf(ph, "quote NOTICE %s :DH1080_FINISH %s%s", sender, pub_key, (mode == FISH_CBC_MODE) ? " CBC" : ""); zoitechat_commandf(ph, "quote NOTICE %s :DH1080_FINISH %s%s", sender, pub_key, (mode == FISH_CBC_MODE) ? " CBC" : "");
g_free(pub_key); g_free(pub_key);
} else { } else {
zoitechat_printf(ph, "Failed to generate keys"); zoitechat_print(ph, "Failed to generate keys");
goto cleanup; goto cleanup;
} }
} else if (!strcmp (dh_message, "DH1080_FINISH")) { } else if (!strcmp (dh_message, "DH1080_FINISH")) {
@@ -454,7 +446,7 @@ static int handle_keyx_notice(char *word[], char *word_eol[], void *userdata) {
zoitechat_printf(ph, "Stored new key for %s (%s)", sender, fish_modes[mode]); zoitechat_printf(ph, "Stored new key for %s (%s)", sender, fish_modes[mode]);
g_free(secret_key); g_free(secret_key);
} else { } else {
zoitechat_printf(ph, "Failed to create secret key!"); zoitechat_print(ph, "Failed to create secret key!");
} }
cleanup: cleanup:
@@ -463,314 +455,6 @@ cleanup:
return ZOITECHAT_EAT_ALL; return ZOITECHAT_EAT_ALL;
} }
static const char *fishlim_gui_target(void) {
const char *target;
target = gtk_entry_get_text(GTK_ENTRY(fishlim_target_entry));
if (target && *target)
return target;
return zoitechat_get_info(ph, "channel");
}
static void fishlim_gui_refresh(void) {
GtkTreeIter iter;
gchar **targets;
gsize length, i;
const char *target;
char *key;
enum fish_mode mode;
if (!fishlim_dialog)
return;
gtk_list_store_clear(fishlim_store);
targets = keystore_get_targets(&length);
for (i = 0; targets && i < length; i++) {
key = keystore_get_key(targets[i], &mode);
gtk_list_store_append(fishlim_store, &iter);
gtk_list_store_set(fishlim_store, &iter, 0, targets[i], 1, fish_modes[mode], 2, key ? "Stored" : "Unreadable", -1);
g_free(key);
}
g_strfreev(targets);
target = fishlim_gui_target();
key = target ? keystore_get_key(target, &mode) : NULL;
if (key) {
char *text = g_strdup_printf("Key stored for %s (%s)", target, fish_modes[mode]);
gtk_label_set_text(GTK_LABEL(fishlim_status_label), text);
gtk_combo_box_set_active(GTK_COMBO_BOX(fishlim_mode_combo), mode == FISH_CBC_MODE ? 1 : 0);
g_free(text);
g_free(key);
} else if (target && *target) {
char *text = g_strdup_printf("No key for %s", target);
gtk_label_set_text(GTK_LABEL(fishlim_status_label), text);
g_free(text);
} else {
gtk_label_set_text(GTK_LABEL(fishlim_status_label), "No target selected");
}
}
static void fishlim_gui_refresh_cb(GtkWidget *widget, gpointer data) {
fishlim_gui_refresh();
}
static void fishlim_gui_send_channel_key(const char *channel, const char *mode, const char *key) {
GtkWidget *dialog, *content, *entry, *label;
char **users;
int i;
if (!channel || !*channel || irc_is_query(channel))
return;
dialog = gtk_dialog_new_with_buttons("Share Channel Key", GTK_WINDOW(fishlim_dialog), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, "_Skip", GTK_RESPONSE_CANCEL, "_Send", GTK_RESPONSE_OK, NULL);
content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
label = gtk_label_new("Send this channel key to users by private message. Enter users separated by commas.");
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
gtk_box_pack_start(GTK_BOX(content), label, FALSE, FALSE, 6);
entry = gtk_entry_new();
gtk_entry_set_placeholder_text(GTK_ENTRY(entry), "nick1, nick2, nick3");
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
gtk_box_pack_start(GTK_BOX(content), entry, FALSE, FALSE, 6);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
gtk_widget_show_all(dialog);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
users = g_strsplit(gtk_entry_get_text(GTK_ENTRY(entry)), ",", -1);
for (i = 0; users && users[i]; i++) {
char *user = g_strstrip(users[i]);
if (*user)
zoitechat_commandf(ph, "msg %s Encrypted chat invite: join %s, open FiSHLiM Key Manager, add channel %s with %s key: %s. Key exchange is for private messages only.", user, channel, channel, mode, key);
}
g_strfreev(users);
}
gtk_widget_destroy(dialog);
}
static void fishlim_gui_set(GtkWidget *widget, gpointer data) {
const char *target = fishlim_gui_target();
const char *key = gtk_entry_get_text(GTK_ENTRY(fishlim_key_entry));
const char *mode = gtk_combo_box_get_active(GTK_COMBO_BOX(fishlim_mode_combo)) == 1 ? "CBC" : "ECB";
if (!target || !*target || !key || !*key) {
zoitechat_printf(ph, "%s\n", usage_setkey);
return;
}
zoitechat_commandf(ph, "SETKEY %s %s:%s", target, mode, key);
fishlim_gui_send_channel_key(target, mode, key);
gtk_entry_set_text(GTK_ENTRY(fishlim_key_entry), "");
fishlim_gui_refresh();
}
static gboolean fishlim_gui_confirm_delete(const char *target) {
GtkWidget *dialog;
char *message;
gboolean confirmed;
message = g_strdup_printf("Delete the key for %s?", target);
dialog = gtk_message_dialog_new(GTK_WINDOW(fishlim_dialog), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, "%s", message);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "This cannot be undone.");
gtk_dialog_add_buttons(GTK_DIALOG(dialog), "_Cancel", GTK_RESPONSE_CANCEL, "_Delete", GTK_RESPONSE_ACCEPT, NULL);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
confirmed = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
gtk_widget_destroy(dialog);
g_free(message);
return confirmed;
}
static char *fishlim_gui_selected_target(void) {
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;
char *target = NULL;
if (!fishlim_view)
return NULL;
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(fishlim_view));
if (gtk_tree_selection_get_selected(selection, &model, &iter))
gtk_tree_model_get(model, &iter, 0, &target, -1);
return target;
}
static void fishlim_gui_delete(GtkWidget *widget, gpointer data) {
char *selected = fishlim_gui_selected_target();
const char *target = selected ? selected : fishlim_gui_target();
if (!target || !*target) {
zoitechat_printf(ph, "%s\n", usage_delkey);
g_free(selected);
return;
}
if (fishlim_gui_confirm_delete(target)) {
zoitechat_commandf(ph, "DELKEY %s", target);
fishlim_gui_refresh();
}
g_free(selected);
}
static char *fishlim_gui_prompt_target(const char *title, const char *initial) {
GtkWidget *dialog, *content, *entry;
char *target = NULL;
dialog = gtk_dialog_new_with_buttons(title, GTK_WINDOW(fishlim_dialog), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, "_Cancel", GTK_RESPONSE_CANCEL, "_OK", GTK_RESPONSE_OK, NULL);
content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
entry = gtk_entry_new();
if (initial && *initial)
gtk_entry_set_text(GTK_ENTRY(entry), initial);
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
gtk_box_pack_start(GTK_BOX(content), gtk_label_new("Private message user"), FALSE, FALSE, 6);
gtk_box_pack_start(GTK_BOX(content), entry, FALSE, FALSE, 6);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
gtk_widget_show_all(dialog);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
const char *text = gtk_entry_get_text(GTK_ENTRY(entry));
if (text && *text)
target = g_strdup(text);
}
gtk_widget_destroy(dialog);
return target;
}
static void fishlim_gui_keyx(GtkWidget *widget, gpointer data) {
char *target;
const char *initial = fishlim_gui_target();
const char *mode = gtk_combo_box_get_active(GTK_COMBO_BOX(fishlim_mode_combo)) == 1 ? "CBC" : "ECB";
if (!initial || !*initial || !irc_is_query(initial))
initial = NULL;
target = fishlim_gui_prompt_target("Key Exchange", initial);
if (!target)
return;
zoitechat_commandf(ph, "KEYX %s %s", target, mode);
g_free(target);
}
static void fishlim_gui_row_activated(GtkTreeView *tree, GtkTreePath *path, GtkTreeViewColumn *column, gpointer data) {
GtkTreeModel *model = gtk_tree_view_get_model(tree);
GtkTreeIter iter;
char *target;
if (!gtk_tree_model_get_iter(model, &iter, path))
return;
gtk_tree_model_get(model, &iter, 0, &target, -1);
gtk_entry_set_text(GTK_ENTRY(fishlim_target_entry), target);
g_free(target);
fishlim_gui_refresh();
}
static void fishlim_gui_destroy(GtkWidget *widget, gpointer data) {
fishlim_dialog = NULL;
fishlim_target_entry = NULL;
fishlim_key_entry = NULL;
fishlim_mode_combo = NULL;
fishlim_status_label = NULL;
fishlim_store = NULL;
fishlim_view = NULL;
}
static int handle_fishlim(char *word[], char *word_eol[], void *userdata) {
GtkWidget *content, *grid, *view, *scroll, *buttons, *button;
GtkCellRenderer *renderer;
const char *target;
target = *word_eol[2] ? word_eol[2] : zoitechat_get_info(ph, "channel");
if (fishlim_dialog) {
if (target)
gtk_entry_set_text(GTK_ENTRY(fishlim_target_entry), target);
gtk_window_present(GTK_WINDOW(fishlim_dialog));
return ZOITECHAT_EAT_ZOITECHAT;
}
fishlim_dialog = gtk_dialog_new_with_buttons("FiSHLiM Key Manager", NULL, GTK_DIALOG_DESTROY_WITH_PARENT, "_Close", GTK_RESPONSE_CLOSE, NULL);
gtk_window_set_default_size(GTK_WINDOW(fishlim_dialog), 520, 360);
g_signal_connect(fishlim_dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
g_signal_connect(fishlim_dialog, "destroy", G_CALLBACK(fishlim_gui_destroy), NULL);
content = gtk_dialog_get_content_area(GTK_DIALOG(fishlim_dialog));
grid = gtk_grid_new();
gtk_grid_set_row_spacing(GTK_GRID(grid), 8);
gtk_grid_set_column_spacing(GTK_GRID(grid), 8);
gtk_container_set_border_width(GTK_CONTAINER(grid), 12);
gtk_box_pack_start(GTK_BOX(content), grid, TRUE, TRUE, 0);
fishlim_target_entry = gtk_entry_new();
if (target)
gtk_entry_set_text(GTK_ENTRY(fishlim_target_entry), target);
gtk_grid_attach(GTK_GRID(grid), gtk_label_new("Target nick or channel"), 0, 0, 1, 1);
gtk_grid_attach(GTK_GRID(grid), fishlim_target_entry, 1, 0, 2, 1);
fishlim_mode_combo = gtk_combo_box_text_new();
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(fishlim_mode_combo), "ECB");
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(fishlim_mode_combo), "CBC");
gtk_combo_box_set_active(GTK_COMBO_BOX(fishlim_mode_combo), 1);
gtk_grid_attach(GTK_GRID(grid), gtk_label_new("Mode"), 0, 1, 1, 1);
gtk_grid_attach(GTK_GRID(grid), fishlim_mode_combo, 1, 1, 2, 1);
gtk_grid_attach(GTK_GRID(grid), gtk_label_new("CBC may not work with older clients. Key exchange is private-message only."), 1, 2, 2, 1);
fishlim_key_entry = gtk_entry_new();
gtk_entry_set_visibility(GTK_ENTRY(fishlim_key_entry), FALSE);
gtk_grid_attach(GTK_GRID(grid), gtk_label_new("Key"), 0, 3, 1, 1);
gtk_grid_attach(GTK_GRID(grid), fishlim_key_entry, 1, 3, 2, 1);
buttons = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
gtk_button_box_set_layout(GTK_BUTTON_BOX(buttons), GTK_BUTTONBOX_END);
gtk_grid_attach(GTK_GRID(grid), buttons, 0, 4, 3, 1);
button = gtk_button_new_with_label("Set Key");
g_signal_connect(button, "clicked", G_CALLBACK(fishlim_gui_set), NULL);
gtk_container_add(GTK_CONTAINER(buttons), button);
button = gtk_button_new_with_label("Delete Key");
g_signal_connect(button, "clicked", G_CALLBACK(fishlim_gui_delete), NULL);
gtk_container_add(GTK_CONTAINER(buttons), button);
button = gtk_button_new_with_label("Private Message Key Exchange");
g_signal_connect(button, "clicked", G_CALLBACK(fishlim_gui_keyx), NULL);
gtk_container_add(GTK_CONTAINER(buttons), button);
fishlim_status_label = gtk_label_new(NULL);
gtk_label_set_xalign(GTK_LABEL(fishlim_status_label), 0.0);
gtk_grid_attach(GTK_GRID(grid), fishlim_status_label, 0, 5, 3, 1);
fishlim_store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(fishlim_store));
fishlim_view = view;
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, "Target", renderer, "text", 0, NULL);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, "Mode", renderer, "text", 1, NULL);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, "Status", renderer, "text", 2, NULL);
g_signal_connect(view, "row-activated", G_CALLBACK(fishlim_gui_row_activated), NULL);
scroll = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_set_vexpand(scroll, TRUE);
gtk_container_add(GTK_CONTAINER(scroll), view);
gtk_grid_attach(GTK_GRID(grid), scroll, 0, 6, 3, 1);
g_signal_connect(fishlim_target_entry, "changed", G_CALLBACK(fishlim_gui_refresh_cb), NULL);
fishlim_gui_refresh();
gtk_widget_show_all(fishlim_dialog);
return ZOITECHAT_EAT_ZOITECHAT;
}
/** /**
* Command handler for /setkey * Command handler for /setkey
*/ */
@@ -806,8 +490,6 @@ static int handle_setkey(char *word[], char *word_eol[], void *userdata) {
/* Set password */ /* Set password */
if (keystore_store_key(nick, key, mode)) { if (keystore_store_key(nick, key, mode)) {
zoitechat_printf(ph, "Stored key for %s (%s)\n", nick, fish_modes[mode]); zoitechat_printf(ph, "Stored key for %s (%s)\n", nick, fish_modes[mode]);
if (mode == FISH_CBC_MODE)
zoitechat_printf(ph, "Warning: CBC may not work with older clients.\n");
} else { } else {
zoitechat_printf(ph, "\00305Failed to store key in addon_fishlim.conf\n"); zoitechat_printf(ph, "\00305Failed to store key in addon_fishlim.conf\n");
} }
@@ -851,18 +533,8 @@ static int handle_keyx(char *word[], char *word_eol[], void *userdata) {
const char *target = word[2]; const char *target = word[2];
zoitechat_context *query_ctx = NULL; zoitechat_context *query_ctx = NULL;
char *pub_key, *priv_key; char *pub_key, *priv_key;
enum fish_mode mode = FISH_CBC_MODE;
int ctx_type; int ctx_type;
if (*word[3]) {
if (g_ascii_strcasecmp(word[3], "ECB") == 0)
mode = FISH_ECB_MODE;
else if (g_ascii_strcasecmp(word[3], "CBC") != 0) {
zoitechat_printf(ph, "%s", usage_keyx);
return ZOITECHAT_EAT_ALL;
}
}
if (*target) if (*target)
query_ctx = find_context_on_network(target); query_ctx = find_context_on_network(target);
else { else {
@@ -876,21 +548,19 @@ static int handle_keyx(char *word[], char *word_eol[], void *userdata) {
} }
if ((query_ctx && ctx_type != 3) || (!query_ctx && !irc_is_query(target))) { if ((query_ctx && ctx_type != 3) || (!query_ctx && !irc_is_query(target))) {
zoitechat_printf(ph, "You can only exchange keys with individuals"); zoitechat_print(ph, "You can only exchange keys with individuals");
return ZOITECHAT_EAT_ALL; return ZOITECHAT_EAT_ALL;
} }
if (dh1080_generate_key(&priv_key, &pub_key)) { if (dh1080_generate_key(&priv_key, &pub_key)) {
g_hash_table_replace (pending_exchanges, g_ascii_strdown(target, -1), priv_key); g_hash_table_replace (pending_exchanges, g_ascii_strdown(target, -1), priv_key);
zoitechat_commandf(ph, "quote NOTICE %s :DH1080_INIT %s%s", target, pub_key, (mode == FISH_CBC_MODE) ? " CBC" : ""); zoitechat_commandf(ph, "quote NOTICE %s :DH1080_INIT %s CBC", target, pub_key);
zoitechat_printf(ph, "Sent public key to %s (%s), waiting for reply...", target, fish_modes[mode]); zoitechat_printf(ph, "Sent public key to %s (CBC), waiting for reply...", target);
if (mode == FISH_CBC_MODE)
zoitechat_printf(ph, "Warning: CBC may not work with older clients.");
g_free(pub_key); g_free(pub_key);
} else { } else {
zoitechat_printf(ph, "Failed to generate keys"); zoitechat_print(ph, "Failed to generate keys");
} }
return ZOITECHAT_EAT_ALL; return ZOITECHAT_EAT_ALL;
@@ -907,7 +577,7 @@ static int handle_crypt_topic(char *word[], char *word_eol[], void *userdata) {
GSList *encrypted_list; GSList *encrypted_list;
if (!*topic) { if (!*topic) {
zoitechat_printf(ph, "%s", usage_topic); zoitechat_print(ph, usage_topic);
return ZOITECHAT_EAT_ALL; return ZOITECHAT_EAT_ALL;
} }
@@ -954,7 +624,7 @@ static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
GSList *encrypted_list, *encrypted_item; GSList *encrypted_list, *encrypted_item;
if (!*target || !*notice) { if (!*target || !*notice) {
zoitechat_printf(ph, "%s", usage_notice); zoitechat_print(ph, usage_notice);
return ZOITECHAT_EAT_ALL; return ZOITECHAT_EAT_ALL;
} }
@@ -1006,7 +676,7 @@ static int handle_crypt_msg(char *word[], char *word_eol[], void *userdata) {
GSList *encrypted_list, *encrypted_item; GSList *encrypted_list, *encrypted_item;
if (!*target || !*message) { if (!*target || !*message) {
zoitechat_printf(ph, "%s", usage_msg); zoitechat_print(ph, usage_msg);
return ZOITECHAT_EAT_ALL; return ZOITECHAT_EAT_ALL;
} }
@@ -1119,7 +789,6 @@ int zoitechat_plugin_init(zoitechat_plugin *plugin_handle,
*version = plugin_version; *version = plugin_version;
/* Register commands */ /* Register commands */
zoitechat_hook_command(ph, "FISHLIM", ZOITECHAT_PRI_NORM, handle_fishlim, "Usage: FISHLIM, opens the FiSHLiM key manager", NULL);
zoitechat_hook_command(ph, "SETKEY", ZOITECHAT_PRI_NORM, handle_setkey, usage_setkey, NULL); zoitechat_hook_command(ph, "SETKEY", ZOITECHAT_PRI_NORM, handle_setkey, usage_setkey, NULL);
zoitechat_hook_command(ph, "DELKEY", ZOITECHAT_PRI_NORM, handle_delkey, usage_delkey, NULL); zoitechat_hook_command(ph, "DELKEY", ZOITECHAT_PRI_NORM, handle_delkey, usage_delkey, NULL);
zoitechat_hook_command(ph, "KEYX", ZOITECHAT_PRI_NORM, handle_keyx, usage_keyx, NULL); zoitechat_hook_command(ph, "KEYX", ZOITECHAT_PRI_NORM, handle_keyx, usage_keyx, NULL);
@@ -1136,31 +805,20 @@ int zoitechat_plugin_init(zoitechat_plugin *plugin_handle,
zoitechat_hook_server_attrs(ph, "TOPIC", ZOITECHAT_PRI_NORM, handle_incoming, NULL); zoitechat_hook_server_attrs(ph, "TOPIC", ZOITECHAT_PRI_NORM, handle_incoming, NULL);
zoitechat_hook_server_attrs(ph, "332", ZOITECHAT_PRI_NORM, handle_incoming, NULL); zoitechat_hook_server_attrs(ph, "332", ZOITECHAT_PRI_NORM, handle_incoming, NULL);
if (!fish_init()) { if (!fish_init())
zoitechat_printf(ph, "FiSHLiM failed to initialize crypto backend");
return 0; return 0;
}
if (!dh1080_init()) { if (!dh1080_init())
zoitechat_printf(ph, "FiSHLiM failed to initialize DH1080");
return 0; return 0;
}
pending_exchanges = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); pending_exchanges = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
zoitechat_command(ph, "MENU ADD \"Window/FiSHLiM Key Manager\" \"FISHLIM\"");
zoitechat_command(ph, "MENU ADD \"$NICK/FiSHLiM Key Manager\" \"FISHLIM %s\"");
zoitechat_printf(ph, "%s plugin loaded\n", plugin_name); zoitechat_printf(ph, "%s plugin loaded\n", plugin_name);
/* Return success */ /* Return success */
return 1; return 1;
} }
int zoitechat_plugin_deinit(void) { int zoitechat_plugin_deinit(void) {
zoitechat_command(ph, "MENU DEL \"Window/FiSHLiM Key Manager\"");
zoitechat_command(ph, "MENU DEL \"$NICK/FiSHLiM Key Manager\"");
if (fishlim_dialog)
gtk_widget_destroy(fishlim_dialog);
g_clear_pointer(&pending_exchanges, g_hash_table_destroy); g_clear_pointer(&pending_exchanges, g_hash_table_destroy);
dh1080_deinit(); dh1080_deinit();
fish_deinit(); fish_deinit();
+1 -13
View File
@@ -1,19 +1,7 @@
if cc.get_id() == 'msvc' if cc.get_id() == 'msvc'
lua_dep = cc.find_library('lua51') lua_dep = cc.find_library('lua51')
else else
lua_opt = get_option('with-lua') lua_dep = dependency(get_option('with-lua'))
lua_dep = dependency(lua_opt, required: false)
if not lua_dep.found() and lua_opt == 'lua-5.4'
foreach lua_name : ['lua5.4', 'lua-5.3', 'lua5.3', 'lua']
lua_dep = dependency(lua_name, required: false)
if lua_dep.found()
break
endif
endforeach
endif
if not lua_dep.found()
error('Dependency "' + lua_opt + '" not found')
endif
endif endif
shared_module('lua', 'lua.c', shared_module('lua', 'lua.c',
+3
View File
@@ -9,6 +9,9 @@ if host_machine.system() == 'windows'
subdir('upd') subdir('upd')
endif endif
if get_option('with-winamp')
subdir('winamp')
endif
endif endif
if get_option('with-checksum') if get_option('with-checksum')
+2 -2
View File
@@ -1457,14 +1457,14 @@ perl_load_file (char *filename)
"You must have a Visual C++ build of Perl " "You must have a Visual C++ build of Perl "
PERL_REQUIRED_VERSION " installed in order to\n" PERL_REQUIRED_VERSION " installed in order to\n"
"run Perl scripts. A reboot may be required.\n\n" "run Perl scripts. A reboot may be required.\n\n"
"http://zoitechat.org/downloads.html\n\n" "http://zoitechat.zoite.net/downloads.html\n\n"
"I have found Perl 5.6, but that is too old."); "I have found Perl 5.6, but that is too old.");
} else { } else {
thread_mbox ("Cannot open " PERL_DLL "!\n\n" thread_mbox ("Cannot open " PERL_DLL "!\n\n"
"You must have a Visual C++ build of Perl " "You must have a Visual C++ build of Perl "
PERL_REQUIRED_VERSION " installed in order to\n" PERL_REQUIRED_VERSION " installed in order to\n"
"run Perl scripts. A reboot may be required.\n\n" "run Perl scripts. A reboot may be required.\n\n"
"http://zoitechat.org/downloads.html\n\n" "http://zoitechat.zoite.net/downloads.html\n\n"
"Make sure Perl's bin directory is in your PATH."); "Make sure Perl's bin directory is in your PATH.");
} }
} }
+3 -3
View File
@@ -19,7 +19,7 @@ else:
if not hasattr(sys, 'argv'): if not hasattr(sys, 'argv'):
sys.argv = ['<zoitechat>'] sys.argv = ['<zoitechat>']
VERSION = b'2.18.2' VERSION = b'2.18.0~pre5'
PLUGIN_NAME = ffi.new('char[]', b'Python') PLUGIN_NAME = ffi.new('char[]', b'Python')
PLUGIN_DESC = ffi.new('char[]', b'Python %d.%d scripting interface' % (sys.version_info[0], sys.version_info[1])) PLUGIN_DESC = ffi.new('char[]', b'Python %d.%d scripting interface' % (sys.version_info[0], sys.version_info[1]))
PLUGIN_VERSION = ffi.new('char[]', VERSION) PLUGIN_VERSION = ffi.new('char[]', VERSION)
@@ -320,9 +320,9 @@ def _on_say_command(word, word_eol, userdata):
return 0 return 0
try: try:
python = __decode(_cstr(word_eol[1])) python = _cstr(word_eol[1])
except Exception: except Exception:
python = '' python = b''
if not python: if not python:
return 1 return 1
+2 -2
View File
@@ -41,7 +41,7 @@ static zoitechat_plugin *ph;
static char name[] = "Sysinfo"; static char name[] = "Sysinfo";
static char desc[] = "Display info about your hardware and OS"; static char desc[] = "Display info about your hardware and OS";
static char version[] = "1.0"; static char version[] = "1.0";
static char sysinfo_help[] = "SysInfo Usage:\n /SYSINFO [-e|-o] [CLIENT|UI|OS|CPU|RAM|STORAGE|GPU|CHIPSET|SOUND|ETHERNET|UPTIME], print various details about your system or print a summary without arguments\n /SYSINFO SET <variable>\n"; static char sysinfo_help[] = "SysInfo Usage:\n /SYSINFO [-e|-o] [CLIENT|UI|OS|CPU|RAM|DISK|GPU|CHIPSET|SOUND|ETHERNET|UPTIME], print various details about your system or print a summary without arguments\n /SYSINFO SET <variable>\n";
typedef struct typedef struct
{ {
@@ -68,7 +68,7 @@ static hwinfo hwinfos[] = {
{"os", "OS", sysinfo_backend_get_os}, {"os", "OS", sysinfo_backend_get_os},
{"cpu", "CPU", sysinfo_backend_get_cpu}, {"cpu", "CPU", sysinfo_backend_get_cpu},
{"memory", "Memory", sysinfo_backend_get_memory}, {"memory", "Memory", sysinfo_backend_get_memory},
{"storage", "Storage", sysinfo_backend_get_disk, TRUE}, {"storage", "Storage", sysinfo_backend_get_disk},
{"gpu", "GPU", sysinfo_backend_get_gpu}, {"gpu", "GPU", sysinfo_backend_get_gpu},
{"chipset", "CHIPSET", sysinfo_backend_get_chipset, TRUE}, {"chipset", "CHIPSET", sysinfo_backend_get_chipset, TRUE},
{"sound", "Sound", sysinfo_backend_get_sound, TRUE}, {"sound", "Sound", sysinfo_backend_get_sound, TRUE},
+1 -1
View File
@@ -24,7 +24,7 @@
#include "zoitechat-plugin.h" #include "zoitechat-plugin.h"
#define APPCAST_URL "https://zoitechat.org/appcast.xml" #define APPCAST_URL "https://zoitechat.zoite.net/appcast.xml"
static zoitechat_plugin *ph; static zoitechat_plugin *ph;
static char name[] = "Update Checker"; static char name[] = "Update Checker";
+7
View File
@@ -0,0 +1,7 @@
shared_module('winamp', 'winamp.c',
dependencies: [libgio_dep, zoitechat_plugin_dep],
install: true,
install_dir: plugindir,
name_prefix: '',
vs_module_defs: 'winamp.def',
)
+153
View File
@@ -0,0 +1,153 @@
/********************* Winamp Plugin 0.3******************************
*
* Distribution: GPL
*
* Originally written by: Leo - [email protected]
* Modified by: SilvereX - [email protected]
* Modified again by: Derek Buitenhuis - [email protected]
* Modified yet again by: Berke Viktor - [email protected]
*********************************************************************/
#include "windows.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "zoitechat-plugin.h"
#define PLAYING 1
#define PAUSED 3
static zoitechat_plugin *ph;
static int
winamp(char *word[], char *word_eol[], void *userdata)
{
HWND hwndWinamp = FindWindowW(L"Winamp v1.x",NULL);
if (hwndWinamp)
{
if (!stricmp("PAUSE", word[2]))
{
if (SendMessage(hwndWinamp,WM_USER, 0, 104))
{
SendMessage(hwndWinamp, WM_COMMAND, 40046, 0);
if (SendMessage(hwndWinamp, WM_USER, 0, 104) == PLAYING)
zoitechat_printf(ph, "Winamp: playing");
else
zoitechat_printf(ph, "Winamp: paused");
}
}
else if (!stricmp("STOP", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40047, 0);
zoitechat_printf(ph, "Winamp: stopped");
}
else if (!stricmp("PLAY", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40045, 0);
zoitechat_printf(ph, "Winamp: playing");
}
else if (!stricmp("NEXT", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40048, 0);
zoitechat_printf(ph, "Winamp: next playlist entry");
}
else if (!stricmp("PREV", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40044, 0);
zoitechat_printf(ph, "Winamp: previous playlist entry");
}
else if (!stricmp("START", word[2]))
{
SendMessage(hwndWinamp, WM_COMMAND, 40154, 0);
zoitechat_printf(ph, "Winamp: playlist start");
}
else if (!word_eol[2][0])
{
wchar_t wcurrent_play[2048];
char *current_play, *p;
int len = GetWindowTextW(hwndWinamp, wcurrent_play, G_N_ELEMENTS(wcurrent_play));
current_play = g_utf16_to_utf8 (wcurrent_play, len, NULL, NULL, NULL);
if (!current_play)
{
zoitechat_print (ph, "Winamp: Error getting song information.");
return ZOITECHAT_EAT_ALL;
}
if (strchr(current_play, '-'))
{
/* Remove any trailing text and whitespace */
p = current_play + strlen(current_play) - 8;
while (p >= current_play)
{
if (!strnicmp(p, "- Winamp", 8))
break;
p--;
}
if (p >= current_play)
p--;
while (p >= current_play && *p == ' ')
p--;
*++p = '\0';
/* Ignore any leading track number */
p = strstr (current_play, ". ");
if (p)
p += 2;
else
p = current_play;
if (*p != '\0')
zoitechat_commandf (ph, "me is now playing: %s", p);
else
zoitechat_print (ph, "Winamp: No song information found.");
g_free (current_play);
}
else
zoitechat_print(ph, "Winamp: Nothing being played.");
}
else
zoitechat_printf(ph, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START]\n");
}
else
{
zoitechat_print(ph, "Winamp not found.\n");
}
return ZOITECHAT_EAT_ALL;
}
int
zoitechat_plugin_init(zoitechat_plugin *plugin_handle,
char **plugin_name,
char **plugin_desc,
char **plugin_version,
char *arg)
{
ph = plugin_handle;
*plugin_name = "Winamp";
*plugin_desc = "Winamp plugin for ZoiteChat";
*plugin_version = "0.6";
zoitechat_hook_command (ph, "WINAMP", ZOITECHAT_PRI_NORM, winamp, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START] - control Winamp or show what's currently playing", 0);
zoitechat_command (ph, "MENU -ishare\\music.png ADD \"Window/Display Current Song (Winamp)\" \"WINAMP\"");
zoitechat_print (ph, "Winamp plugin loaded\n");
return 1;
}
int
zoitechat_plugin_deinit(void)
{
zoitechat_command (ph, "MENU DEL \"Window/Display Current Song (Winamp)\"");
zoitechat_print (ph, "Winamp plugin unloaded\n");
return 1;
}
+3
View File
@@ -0,0 +1,3 @@
EXPORTS
zoitechat_plugin_init
zoitechat_plugin_deinit
+48
View File
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Configuration">
<PlatformToolset>v142</PlatformToolset>
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E78C0D9A-798E-4BF6-B0CC-6FECB8CA2FCE}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>winamp</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\win32\zoitechat.props" />
<PropertyGroup>
<TargetName>hcwinamp</TargetName>
<OutDir>$(ZoiteChatRel)plugins\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;WINAMP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(DepsRoot)\include;$(OpenSslInclude);$(Glib);..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<ModuleDefinitionFile>winamp.def</ModuleDefinitionFile>
<AdditionalDependencies>$(DepLibs);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="winamp.def" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="winamp.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="winamp.def">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="winamp.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
+5 -12
View File
@@ -8,7 +8,7 @@
[![Version][github-version-img]][github-version-uri] [![Downloads][github-downloads-img]][github-downloads-uri] [![Size][github-size-img]][github-size-img] [![Last Commit][github-commit-img]][github-commit-img] [![Contributors][contribs-all-img]](#contributors-) [![Version][github-version-img]][github-version-uri] [![Downloads][github-downloads-img]][github-downloads-uri] [![Size][github-size-img]][github-size-img] [![Last Commit][github-commit-img]][github-commit-img] [![Contributors][contribs-all-img]](#contributors-)
[![View Official Documentation](https://img.shields.io/badge/View_Official_Documentation-526CFE?style=for-the-badge&logo=MaterialForMkDocs&logoColor=white)](https://docs.zoitechat.org) [![View Official Documentation](https://img.shields.io/badge/View_Official_Documentation-526CFE?style=for-the-badge&logo=MaterialForMkDocs&logoColor=white)](https://docs.zoitechat.zoite.net)
</div> </div>
@@ -31,19 +31,12 @@
<br /> <br />
ZoiteChat is a GTK3 IRC client based on HexChat, available for Windows and UNIX-like operating systems. ZoiteChat is an HexChat based IRC client for Windows and UNIX-like operating systems.
Features include HexChat-compatible Python, Perl and Lua scripting support, a plugin API,
multiple server/channel windows, spell checking, multiple authentication methods including SASL,
and customizable notifications.
See [IRCHelp.org](http://irchelp.org) for information about IRC in general. See [IRCHelp.org](http://irchelp.org) for information about IRC in general.
For more information on ZoiteChat please read our [documentation](https://docs.zoitechat.zoite.net/):
- [Downloads](https://zoitechat.zoite.net/download)
For more information on ZoiteChat: - [Troubleshooting](troubleshooting.md)
- [Main Documentation](https://docs.zoitechat.org/) and [FAQ](https://docs.zoitechat.org/en/latest/faq.html)
- [Downloads](https://zoitechat.org/download.php)
--- ---
+2 -23
View File
@@ -428,7 +428,6 @@ const struct prefs vars[] =
{"gui_lagometer", P_OFFINT (hex_gui_lagometer), TYPE_INT}, {"gui_lagometer", P_OFFINT (hex_gui_lagometer), TYPE_INT},
{"gui_lang", P_OFFINT (hex_gui_lang), TYPE_INT}, {"gui_lang", P_OFFINT (hex_gui_lang), TYPE_INT},
{"gui_mode_buttons", P_OFFINT (hex_gui_mode_buttons), TYPE_BOOL}, {"gui_mode_buttons", P_OFFINT (hex_gui_mode_buttons), TYPE_BOOL},
{"gui_mode_buttons_inline", P_OFFINT (hex_gui_mode_buttons_inline), TYPE_BOOL},
{"gui_pane_divider_position", P_OFFINT (hex_gui_pane_divider_position), TYPE_INT}, {"gui_pane_divider_position", P_OFFINT (hex_gui_pane_divider_position), TYPE_INT},
{"gui_pane_left_size", P_OFFINT (hex_gui_pane_left_size), TYPE_INT}, {"gui_pane_left_size", P_OFFINT (hex_gui_pane_left_size), TYPE_INT},
{"gui_pane_right_size", P_OFFINT (hex_gui_pane_right_size), TYPE_INT}, {"gui_pane_right_size", P_OFFINT (hex_gui_pane_right_size), TYPE_INT},
@@ -446,9 +445,7 @@ const struct prefs vars[] =
{"gui_dark_mode", P_OFFINT (hex_gui_dark_mode), TYPE_INT}, {"gui_dark_mode", P_OFFINT (hex_gui_dark_mode), TYPE_INT},
{"gui_gtk3_variant", P_OFFINT (hex_gui_gtk3_variant), TYPE_INT}, {"gui_gtk3_variant", P_OFFINT (hex_gui_gtk3_variant), TYPE_INT},
{"gui_tab_layout", P_OFFINT (hex_gui_tab_layout), TYPE_INT}, {"gui_tab_layout", P_OFFINT (hex_gui_tab_layout), TYPE_INT},
{"gui_tab_closebuttons", P_OFFINT (hex_gui_tab_closebuttons), TYPE_BOOL},
{"gui_tab_middleclose", P_OFFINT (hex_gui_tab_middleclose), TYPE_BOOL}, {"gui_tab_middleclose", P_OFFINT (hex_gui_tab_middleclose), TYPE_BOOL},
{"gui_mouse_scroll_speed", P_OFFINT (hex_gui_mouse_scroll_speed), TYPE_INT},
{"gui_tab_newtofront", P_OFFINT (hex_gui_tab_newtofront), TYPE_INT}, {"gui_tab_newtofront", P_OFFINT (hex_gui_tab_newtofront), TYPE_INT},
{"gui_tab_pos", P_OFFINT (hex_gui_tab_pos), TYPE_INT}, {"gui_tab_pos", P_OFFINT (hex_gui_tab_pos), TYPE_INT},
{"gui_tab_scrollchans", P_OFFINT (hex_gui_tab_scrollchans), TYPE_BOOL}, {"gui_tab_scrollchans", P_OFFINT (hex_gui_tab_scrollchans), TYPE_BOOL},
@@ -459,7 +456,6 @@ const struct prefs vars[] =
{"gui_tab_utils", P_OFFINT (hex_gui_tab_utils), TYPE_BOOL}, {"gui_tab_utils", P_OFFINT (hex_gui_tab_utils), TYPE_BOOL},
{"gui_throttlemeter", P_OFFINT (hex_gui_throttlemeter), TYPE_INT}, {"gui_throttlemeter", P_OFFINT (hex_gui_throttlemeter), TYPE_INT},
{"gui_topicbar", P_OFFINT (hex_gui_topicbar), TYPE_BOOL}, {"gui_topicbar", P_OFFINT (hex_gui_topicbar), TYPE_BOOL},
{"gui_topicbar_multiline", P_OFFINT (hex_gui_topicbar_multiline), TYPE_BOOL},
{"gui_transparency", P_OFFINT (hex_gui_transparency), TYPE_INT}, {"gui_transparency", P_OFFINT (hex_gui_transparency), TYPE_INT},
{"gui_tray", P_OFFINT (hex_gui_tray), TYPE_BOOL}, {"gui_tray", P_OFFINT (hex_gui_tray), TYPE_BOOL},
{"gui_tray_away", P_OFFINT (hex_gui_tray_away), TYPE_BOOL}, {"gui_tray_away", P_OFFINT (hex_gui_tray_away), TYPE_BOOL},
@@ -520,7 +516,6 @@ const struct prefs vars[] =
{"irc_conf_mode", P_OFFINT (hex_irc_conf_mode), TYPE_BOOL}, {"irc_conf_mode", P_OFFINT (hex_irc_conf_mode), TYPE_BOOL},
{"irc_extra_hilight", P_OFFSET (hex_irc_extra_hilight), TYPE_STR}, {"irc_extra_hilight", P_OFFSET (hex_irc_extra_hilight), TYPE_STR},
{"irc_hide_nickchange", P_OFFINT (hex_irc_hide_nickchange), TYPE_BOOL}, {"irc_hide_nickchange", P_OFFINT (hex_irc_hide_nickchange), TYPE_BOOL},
{"irc_hide_join_part_hostmask", P_OFFINT (hex_irc_hide_join_part_hostmask), TYPE_BOOL},
{"irc_hide_version", P_OFFINT (hex_irc_hide_version), TYPE_BOOL}, {"irc_hide_version", P_OFFINT (hex_irc_hide_version), TYPE_BOOL},
{"irc_hidehost", P_OFFINT (hex_irc_hidehost), TYPE_BOOL}, {"irc_hidehost", P_OFFINT (hex_irc_hidehost), TYPE_BOOL},
{"irc_id_ntext", P_OFFSET (hex_irc_id_ntext), TYPE_STR}, {"irc_id_ntext", P_OFFSET (hex_irc_id_ntext), TYPE_STR},
@@ -552,10 +547,6 @@ const struct prefs vars[] =
#endif #endif
{"net_bind_host", P_OFFSET (hex_net_bind_host), TYPE_STR}, {"net_bind_host", P_OFFSET (hex_net_bind_host), TYPE_STR},
{"net_ping_timeout", P_OFFINT (hex_net_ping_timeout), TYPE_INT, zoitechat_reinit_timers}, {"net_ping_timeout", P_OFFINT (hex_net_ping_timeout), TYPE_INT, zoitechat_reinit_timers},
{"net_lag_check", P_OFFINT (hex_net_lag_check), TYPE_INT, zoitechat_reinit_timers},
{"net_keepalive_idle", P_OFFINT (hex_net_keepalive_idle), TYPE_INT},
{"net_keepalive_interval", P_OFFINT (hex_net_keepalive_interval), TYPE_INT},
{"net_keepalive_count", P_OFFINT (hex_net_keepalive_count), TYPE_INT},
{"net_proxy_auth", P_OFFINT (hex_net_proxy_auth), TYPE_BOOL}, {"net_proxy_auth", P_OFFINT (hex_net_proxy_auth), TYPE_BOOL},
{"net_proxy_host", P_OFFSET (hex_net_proxy_host), TYPE_STR}, {"net_proxy_host", P_OFFSET (hex_net_proxy_host), TYPE_STR},
{"net_proxy_pass", P_OFFSET (hex_net_proxy_pass), TYPE_STR}, {"net_proxy_pass", P_OFFSET (hex_net_proxy_pass), TYPE_STR},
@@ -786,18 +777,13 @@ load_default_config(void)
prefs.hex_gui_tab_chans = 1; prefs.hex_gui_tab_chans = 1;
prefs.hex_gui_tab_dialogs = 1; prefs.hex_gui_tab_dialogs = 1;
prefs.hex_gui_tab_icons = 1; prefs.hex_gui_tab_icons = 1;
prefs.hex_gui_tab_closebuttons = 1;
prefs.hex_gui_tab_middleclose = 1; prefs.hex_gui_tab_middleclose = 1;
prefs.hex_gui_tab_server = 1; prefs.hex_gui_tab_server = 1;
prefs.hex_gui_tab_sort = 1; prefs.hex_gui_tab_sort = 1;
prefs.hex_gui_tab_scrollchans = 1;
prefs.hex_gui_mouse_scroll_speed = 10;
prefs.hex_gui_topicbar = 1; prefs.hex_gui_topicbar = 1;
prefs.hex_gui_topicbar_multiline = 1;
prefs.hex_gui_transparency = 255; prefs.hex_gui_transparency = 255;
prefs.hex_gui_tray = 1; prefs.hex_gui_tray = 1;
prefs.hex_gui_tray_blink = 1; prefs.hex_gui_tray_blink = 1;
prefs.hex_gui_ulist_color = 1;
prefs.hex_gui_ulist_count = 1; prefs.hex_gui_ulist_count = 1;
prefs.hex_gui_ulist_icons = 1; prefs.hex_gui_ulist_icons = 1;
prefs.hex_gui_ulist_style = 1; prefs.hex_gui_ulist_style = 1;
@@ -868,10 +854,6 @@ load_default_config(void)
prefs.hex_irc_ban_type = 1; prefs.hex_irc_ban_type = 1;
prefs.hex_irc_join_delay = 5; prefs.hex_irc_join_delay = 5;
prefs.hex_net_ping_timeout = 60; prefs.hex_net_ping_timeout = 60;
prefs.hex_net_lag_check = 60;
prefs.hex_net_keepalive_idle = 60;
prefs.hex_net_keepalive_interval = 20;
prefs.hex_net_keepalive_count = 3;
prefs.hex_net_reconnect_delay = 10; prefs.hex_net_reconnect_delay = 10;
prefs.hex_notify_timeout = 15; prefs.hex_notify_timeout = 15;
prefs.hex_text_max_indent = 256; prefs.hex_text_max_indent = 256;
@@ -1182,11 +1164,8 @@ set_showval (session *sess, const struct prefs *var, char *tbuf)
switch (var->type) switch (var->type)
{ {
case TYPE_STR: case TYPE_STR:
{ sprintf (tbuf + len, "\0033:\017 %s\n", (char *) &prefs + var->offset);
const char *value = (char *) &prefs + var->offset; break;
sprintf (tbuf + len, "\0033:\017 %s\n", value ? value : "");
}
break;
case TYPE_INT: case TYPE_INT:
sprintf (tbuf + len, "\0033:\017 %d\n", *((int *) &prefs + var->offset)); sprintf (tbuf + len, "\0033:\017 %d\n", *((int *) &prefs + var->offset));
break; break;
-4
View File
@@ -29,10 +29,8 @@
<ClInclude Include="plugin-timer.h" /> <ClInclude Include="plugin-timer.h" />
<ClInclude Include="plugin.h" /> <ClInclude Include="plugin.h" />
<ClInclude Include="proto-irc.h" /> <ClInclude Include="proto-irc.h" />
<ClInclude Include="public_suffix_data.h" />
<ClInclude Include="server.h" /> <ClInclude Include="server.h" />
<ClInclude Include="servlist.h" /> <ClInclude Include="servlist.h" />
<ClInclude Include="secretstore.h" />
<ClInclude Include="ssl.h" /> <ClInclude Include="ssl.h" />
<ClInclude Include="scram.h" /> <ClInclude Include="scram.h" />
<ClInclude Include="sysinfo\sysinfo.h" /> <ClInclude Include="sysinfo\sysinfo.h" />
@@ -69,7 +67,6 @@
<ClCompile Include="proto-irc.c" /> <ClCompile Include="proto-irc.c" />
<ClCompile Include="server.c" /> <ClCompile Include="server.c" />
<ClCompile Include="servlist.c" /> <ClCompile Include="servlist.c" />
<ClCompile Include="secretstore.c" />
<ClCompile Include="ssl.c" /> <ClCompile Include="ssl.c" />
<ClCompile Include="scram.c" /> <ClCompile Include="scram.c" />
<ClCompile Include="sts.c" /> <ClCompile Include="sts.c" />
@@ -112,7 +109,6 @@
<Command><![CDATA[ <Command><![CDATA[
SET SOLUTIONDIR=$(SolutionDir)..\ SET SOLUTIONDIR=$(SolutionDir)..\
"$(Python3Path)\python.exe" $(ProjectDir)make-te.py "$(ProjectDir)textevents.in" "$(ZoiteChatLib)textevents.h" "$(ZoiteChatLib)textenums.h" "$(Python3Path)\python.exe" $(ProjectDir)make-te.py "$(ProjectDir)textevents.in" "$(ZoiteChatLib)textevents.h" "$(ZoiteChatLib)textenums.h"
"$(Python3Path)\python.exe" $(ProjectDir)gen-public-suffix.py "$(ZoiteChatLib)public_suffix_data.h"
powershell -File "$(SolutionDir)..\win32\version-template.ps1" "$(SolutionDir)..\win32\config.h.tt" "$(ZoiteChatLib)config.h" powershell -File "$(SolutionDir)..\win32\version-template.ps1" "$(SolutionDir)..\win32\config.h.tt" "$(ZoiteChatLib)config.h"
$(GlibGenMarshal) --prefix=_zoitechat_marshal --header "$(ProjectDir)marshalers.list" --output "$(ZoiteChatLib)marshal.h" $(GlibGenMarshal) --prefix=_zoitechat_marshal --header "$(ProjectDir)marshalers.list" --output "$(ZoiteChatLib)marshal.h"
$(GlibGenMarshal) --prefix=_zoitechat_marshal --body "$(ProjectDir)marshalers.list" --output "$(ZoiteChatLib)marshal.c" $(GlibGenMarshal) --prefix=_zoitechat_marshal --body "$(ProjectDir)marshalers.list" --output "$(ZoiteChatLib)marshal.c"
-9
View File
@@ -65,18 +65,12 @@
<ClInclude Include="proto-irc.h"> <ClInclude Include="proto-irc.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="public_suffix_data.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="server.h"> <ClInclude Include="server.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="servlist.h"> <ClInclude Include="servlist.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="secretstore.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ssl.h"> <ClInclude Include="ssl.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@@ -181,9 +175,6 @@
<ClCompile Include="servlist.c"> <ClCompile Include="servlist.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="secretstore.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ssl.c"> <ClCompile Include="ssl.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
+4
View File
@@ -82,6 +82,10 @@ has_theme_argument (void)
void void
zoitechat_remote (void) zoitechat_remote (void)
/* TODO: dbus_g_connection_unref (connection) are commented because it makes
* dbus to crash. Fixed in dbus >=0.70 ?!?
* https://launchpad.net/distros/ubuntu/+source/dbus/+bug/54375
*/
{ {
GDBusConnection *connection; GDBusConnection *connection;
GDBusProxy *dbus = NULL; GDBusProxy *dbus = NULL;
File diff suppressed because it is too large Load Diff
+175 -94
View File
@@ -1,122 +1,203 @@
#include <gio/gio.h> /* example.c - program to demonstrate some D-BUS stuffs.
#include <glib.h> * Copyright (C) 2006 Claessens Xavier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Claessens Xavier
* [email protected]
*/
#include <config.h>
#include <dbus/dbus-glib.h>
#include <stdlib.h> #include <stdlib.h>
#include "../marshal.c"
#define DBUS_SERVICE "org.zoitechat.service" #define DBUS_SERVICE "org.zoitechat.service"
#define DBUS_CONNECTION_PATH "/org/zoitechat" #define DBUS_REMOTE "/org/zoitechat/Remote"
#define DBUS_CONNECTION_INTERFACE "org.zoitechat.connection" #define DBUS_REMOTE_CONNECTION_INTERFACE "org.zoitechat.connection"
#define DBUS_PLUGIN_INTERFACE "org.zoitechat.plugin" #define DBUS_REMOTE_PLUGIN_INTERFACE "org.zoitechat.plugin"
static gboolean guint command_id;
call_sync (GDBusProxy *proxy, const char *method, GVariant *params, GVariant **out) guint server_id;
static void
write_error (const char *message,
GError **error)
{
if (error == NULL || *error == NULL) {
return;
}
g_printerr ("%s: %s\n", message, (*error)->message);
g_clear_error (error);
}
static void
test_server_cb (DBusGProxy *proxy,
char *word[],
char *word_eol[],
guint hook_id,
guint context_id,
gpointer user_data)
{
if (hook_id == server_id) {
g_print ("message: %s\n", word_eol[0]);
}
}
static void
test_command_cb (DBusGProxy *proxy,
char *word[],
char *word_eol[],
guint hook_id,
guint context_id,
gpointer user_data)
{ {
GError *error = NULL; GError *error = NULL;
GVariant *result;
result = g_dbus_proxy_call_sync (proxy, if (hook_id == command_id) {
method, if (!dbus_g_proxy_call (proxy, "Unhook",
params, &error,
G_DBUS_CALL_FLAGS_NONE, G_TYPE_UINT, hook_id,
-1, G_TYPE_INVALID, G_TYPE_INVALID)) {
NULL, write_error ("Failed to complete unhook", &error);
&error); }
if (!result) /* Now if you write "/test blah" again in the ZoiteChat window
{ * you'll get a "Unknown command" error message */
g_printerr ("%s failed: %s\n", method, error->message); g_print ("test command received: %s\n", word_eol[1]);
g_clear_error (&error); if (!dbus_g_proxy_call (proxy, "Print",
return FALSE; &error,
G_TYPE_STRING, "test command succeed",
G_TYPE_INVALID,
G_TYPE_INVALID)) {
write_error ("Failed to complete Print", &error);
}
} }
}
if (out) static void
*out = result; unload_cb (void)
else {
g_variant_unref (result); g_print ("Good bye !\n");
exit (EXIT_SUCCESS);
return TRUE;
} }
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
GDBusConnection *connection; DBusGConnection *connection;
GDBusProxy *connection_proxy; DBusGProxy *remote_object;
GDBusProxy *plugin_proxy; GMainLoop *mainloop;
GVariant *connect_result = NULL; gchar *path;
gchar *remote_path = NULL;
gchar *command = NULL;
const char *path_tmp;
int status = EXIT_FAILURE;
GError *error = NULL; GError *error = NULL;
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); #if ! GLIB_CHECK_VERSION (2, 36, 0)
if (!connection) g_type_init ();
{ #endif
g_printerr ("Bus connection failed: %s\n", error->message);
g_clear_error (&error); connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (connection == NULL) {
write_error ("Couldn't connect to session bus", &error);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
connection_proxy = g_dbus_proxy_new_sync (connection, remote_object = dbus_g_proxy_new_for_name (connection,
G_DBUS_PROXY_FLAGS_NONE, DBUS_SERVICE,
NULL, DBUS_REMOTE,
DBUS_SERVICE, DBUS_REMOTE_CONNECTION_INTERFACE);
DBUS_CONNECTION_PATH, if (!dbus_g_proxy_call (remote_object, "Connect",
DBUS_CONNECTION_INTERFACE, &error,
NULL, G_TYPE_STRING, argv[0],
&error); G_TYPE_STRING, "example",
if (!connection_proxy) G_TYPE_STRING, "Example of a D-Bus client",
{ G_TYPE_STRING, "1.0",
g_printerr ("Connection proxy failed: %s\n", error->message); G_TYPE_INVALID,
g_clear_error (&error); G_TYPE_STRING, &path, G_TYPE_INVALID)) {
g_object_unref (connection); write_error ("Failed to complete Connect", &error);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
g_object_unref (remote_object);
if (!call_sync (connection_proxy, remote_object = dbus_g_proxy_new_for_name (connection,
"Connect", DBUS_SERVICE,
g_variant_new ("(ssss)", "example", "example", "GDBus example", "1.0"), path,
&connect_result)) DBUS_REMOTE_PLUGIN_INTERFACE);
goto cleanup; g_free (path);
g_variant_get (connect_result, "(&s)", &path_tmp); if (!dbus_g_proxy_call (remote_object, "HookCommand",
remote_path = g_strdup (path_tmp); &error,
g_variant_unref (connect_result); G_TYPE_STRING, "test",
connect_result = NULL; G_TYPE_INT, 0,
G_TYPE_STRING, "Simple D-BUS example",
plugin_proxy = g_dbus_proxy_new_sync (connection, G_TYPE_INT, 1, G_TYPE_INVALID,
G_DBUS_PROXY_FLAGS_NONE, G_TYPE_UINT, &command_id, G_TYPE_INVALID)) {
NULL, write_error ("Failed to complete HookCommand", &error);
DBUS_SERVICE, return EXIT_FAILURE;
remote_path,
DBUS_PLUGIN_INTERFACE,
NULL,
&error);
if (!plugin_proxy)
{
g_printerr ("Plugin proxy failed: %s\n", error->message);
g_clear_error (&error);
goto cleanup;
} }
g_print ("Command hook id=%d\n", command_id);
if (argc > 1) if (!dbus_g_proxy_call (remote_object, "HookServer",
command = g_strjoinv (" ", &argv[1]); &error,
else G_TYPE_STRING, "RAW LINE",
command = g_strdup ("gui focus"); G_TYPE_INT, 0,
G_TYPE_INT, 0, G_TYPE_INVALID,
if (!call_sync (plugin_proxy, "Command", g_variant_new ("(s)", command), NULL)) G_TYPE_UINT, &server_id, G_TYPE_INVALID)) {
{ write_error ("Failed to complete HookServer", &error);
g_object_unref (plugin_proxy); return EXIT_FAILURE;
goto cleanup;
} }
g_print ("Server hook id=%d\n", server_id);
call_sync (connection_proxy, "Disconnect", g_variant_new ("()"), NULL); dbus_g_object_register_marshaller (
status = EXIT_SUCCESS; _zoitechat_marshal_VOID__POINTER_POINTER_UINT_UINT,
g_object_unref (plugin_proxy); G_TYPE_NONE,
G_TYPE_STRV, G_TYPE_STRV, G_TYPE_UINT, G_TYPE_UINT,
G_TYPE_INVALID);
cleanup: dbus_g_object_register_marshaller (
g_free (command); g_cclosure_marshal_VOID__VOID,
g_free (remote_path); G_TYPE_NONE,
g_object_unref (connection_proxy); G_TYPE_INVALID);
g_object_unref (connection);
return status; dbus_g_proxy_add_signal (remote_object, "CommandSignal",
G_TYPE_STRV,
G_TYPE_STRV,
G_TYPE_UINT,
G_TYPE_UINT,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal (remote_object, "CommandSignal",
G_CALLBACK (test_command_cb),
NULL, NULL);
dbus_g_proxy_add_signal (remote_object, "ServerSignal",
G_TYPE_STRV,
G_TYPE_STRV,
G_TYPE_UINT,
G_TYPE_UINT,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal (remote_object, "ServerSignal",
G_CALLBACK (test_server_cb),
NULL, NULL);
dbus_g_proxy_add_signal (remote_object, "UnloadSignal",
G_TYPE_INVALID);
dbus_g_proxy_connect_signal (remote_object, "UnloadSignal",
G_CALLBACK (unload_cb),
NULL, NULL);
/* Now you can write on the ZoiteChat windows: "/test arg1 arg2 ..." */
mainloop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (mainloop);
return EXIT_SUCCESS;
} }
+12 -2
View File
@@ -1,4 +1,6 @@
dbus_deps = [] dbus_deps = [
dbus_glib_dep
]
dbus_sources = [ dbus_sources = [
'dbus-plugin.c', 'dbus-plugin.c',
@@ -33,8 +35,16 @@ configure_file(
install_dir: dbus_service_dir install_dir: dbus_service_dir
) )
dbus_binding_tool = find_program('dbus-binding-tool')
dbus_remote_object = custom_target('remote-object-glue',
input: 'remote-object.xml',
output: 'remote-object-glue.h',
command: [dbus_binding_tool, '--prefix=remote_object', '--mode=glib-server',
'--output=@OUTPUT@', '@INPUT@']
)
zoitechat_dbus = static_library('zoitechatdbus', zoitechat_dbus = static_library('zoitechatdbus',
sources: marshal + dbus_sources, sources: [dbus_remote_object, marshal] + dbus_sources,
c_args: dbus_cargs, c_args: dbus_cargs,
dependencies: common_deps + dbus_deps, dependencies: common_deps + dbus_deps,
include_directories: dbus_includes, include_directories: dbus_includes,
+21 -5
View File
@@ -304,24 +304,29 @@ dcc_check_timeouts (void)
static int static int
dcc_lookup_proxy (char *host, struct sockaddr_in *addr) dcc_lookup_proxy (char *host, struct sockaddr_in *addr)
{ {
struct hostent *h;
static char *cache_host = NULL; static char *cache_host = NULL;
static guint32 cache_addr; static guint32 cache_addr;
/* too lazy to thread this, so we cache results */
if (cache_host) if (cache_host)
{ {
if (strcmp (host, cache_host) == 0) if (strcmp (host, cache_host) == 0)
{ {
addr->sin_addr.s_addr = cache_addr; memcpy (&addr->sin_addr, &cache_addr, 4);
return TRUE; return TRUE;
} }
g_free (cache_host); g_free (cache_host);
cache_host = NULL; cache_host = NULL;
} }
if (net_lookup_ipv4 (host, &addr->sin_addr.s_addr)) h = gethostbyname (host);
if (h != NULL && h->h_length == 4 && h->h_addr_list[0] != NULL)
{ {
cache_addr = addr->sin_addr.s_addr; memcpy (&addr->sin_addr, h->h_addr_list[0], 4);
memcpy (&cache_addr, h->h_addr_list[0], 4);
cache_host = g_strdup (host); cache_host = g_strdup (host);
/* cppcheck-suppress memleak */
return TRUE; return TRUE;
} }
@@ -1609,14 +1614,25 @@ dcc_accept (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
} }
guint32 guint32
dcc_get_my_address (session *sess) dcc_get_my_address (session *sess) /* the address we'll tell the other person */
{ {
struct hostent *dns_query;
guint32 addr = 0; guint32 addr = 0;
if (prefs.hex_dcc_ip_from_server && sess->server->dcc_ip) if (prefs.hex_dcc_ip_from_server && sess->server->dcc_ip)
addr = sess->server->dcc_ip; addr = sess->server->dcc_ip;
else if (prefs.hex_dcc_ip[0]) else if (prefs.hex_dcc_ip[0])
net_lookup_ipv4 ((const char *) prefs.hex_dcc_ip, &addr); {
dns_query = gethostbyname ((const char *) prefs.hex_dcc_ip);
if (dns_query != NULL &&
dns_query->h_length == 4 &&
dns_query->h_addr_list[0] != NULL)
{
/*we're offered at least one IPv4 address: we take the first*/
addr = *((guint32*) dns_query->h_addr_list[0]);
}
}
return addr; return addr;
} }
-71
View File
@@ -1,71 +0,0 @@
#!/usr/bin/env python3
import sys
import urllib.request
from pathlib import Path
URLS = (
"https://raw.githubusercontent.com/publicsuffix/list/main/public_suffix_list.dat",
"https://publicsuffix.org/list/public_suffix_list.dat",
)
def parse_rules(text: str):
rules = []
for raw in text.splitlines():
line = raw.strip()
if not line or line.startswith("//"):
continue
if " " in line or "\t" in line:
line = line.split()[0]
rules.append(line.lower())
return sorted(set(rules))
def emit_header(path: str, rules):
with open(path, "w", encoding="utf-8", newline="\n") as out:
out.write("#pragma once\n")
out.write("static const char * const public_suffix_rules[] = {\n")
for rule in rules:
escaped = rule.replace("\\", "\\\\").replace('"', '\\"')
out.write(f'\t"{escaped}",\n')
out.write("};\n")
out.write(
"static const unsigned int public_suffix_rules_len = sizeof(public_suffix_rules) / sizeof(public_suffix_rules[0]);\n"
)
def main():
if len(sys.argv) not in (2, 3):
raise SystemExit("usage: gen-public-suffix.py <output> [source]")
output = Path(sys.argv[1])
sources = []
if len(sys.argv) == 3:
sources.append(Path(sys.argv[2]))
sources.extend(
[
Path(__file__).with_name("public_suffix_list.dat"),
Path("/usr/share/publicsuffix/public_suffix_list.dat"),
Path("/app/share/publicsuffix/public_suffix_list.dat"),
]
)
data = None
for url in URLS:
try:
with urllib.request.urlopen(url, timeout=30) as resp:
data = resp.read().decode("utf-8")
break
except Exception:
pass
if data is None:
for source in sources:
if source.exists():
data = source.read_text(encoding="utf-8")
break
if data is None:
raise SystemExit("unable to load public suffix list")
rules = parse_rules(data)
emit_header(str(output), rules)
if __name__ == "__main__":
main()
-88
View File
@@ -1221,94 +1221,6 @@ extract_archive (const char *source, GError **error)
#endif #endif
} }
static char *
path_find_first_file_recursive (const char *root, const char *name, int depth)
{
GDir *dir;
const char *entry;
if (!root || !name || depth < 0 || !g_file_test (root, G_FILE_TEST_IS_DIR))
return NULL;
{
char *candidate = g_build_filename (root, name, NULL);
if (g_file_test (candidate, G_FILE_TEST_IS_REGULAR))
return candidate;
g_free (candidate);
}
if (depth == 0)
return NULL;
dir = g_dir_open (root, 0, NULL);
if (!dir)
return NULL;
while ((entry = g_dir_read_name (dir)) != NULL)
{
char *child = g_build_filename (root, entry, NULL);
char *found = NULL;
if (g_file_test (child, G_FILE_TEST_IS_DIR))
found = path_find_first_file_recursive (child, name, depth - 1);
g_free (child);
if (found)
{
g_dir_close (dir);
return found;
}
}
g_dir_close (dir);
return NULL;
}
gboolean
zoitechat_gtk3_theme_service_read_archive_text_file (const char *archive_path, const char *name, char **contents, GError **error)
{
char *root;
char *path;
gboolean ok;
GError *local_error = NULL;
if (contents)
*contents = NULL;
if (!archive_path || !*archive_path)
return g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_INVAL, "No archive path provided."), FALSE;
if (!name || !*name)
return g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_INVAL, "No file name provided."), FALSE;
if (!contents)
return g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_INVAL, "No output buffer provided."), FALSE;
root = extract_archive (archive_path, error);
if (!root)
return FALSE;
path = path_find_first_file_recursive (root, name, 8);
if (!path)
{
remove_tree (root);
g_free (root);
return g_set_error_literal (error, G_FILE_ERROR, G_FILE_ERROR_NOENT, "Requested file was not found in archive."), FALSE;
}
ok = g_file_get_contents (path, contents, NULL, &local_error);
g_free (path);
remove_tree (root);
g_free (root);
if (!ok)
{
if (error)
*error = local_error;
else
g_clear_error (&local_error);
return FALSE;
}
return TRUE;
}
gboolean gboolean
zoitechat_gtk3_theme_service_import (const char *source_path, char **imported_id, GError **error) zoitechat_gtk3_theme_service_import (const char *source_path, char **imported_id, GError **error)
{ {
-1
View File
@@ -48,6 +48,5 @@ gboolean zoitechat_gtk3_theme_service_remove_user_theme (const char *theme_id, G
char *zoitechat_gtk3_theme_pick_css_dir_for_minor (const char *theme_root, int preferred_minor); char *zoitechat_gtk3_theme_pick_css_dir_for_minor (const char *theme_root, int preferred_minor);
char *zoitechat_gtk3_theme_pick_css_dir (const char *theme_root); char *zoitechat_gtk3_theme_pick_css_dir (const char *theme_root);
GPtrArray *zoitechat_gtk3_theme_build_inheritance_chain (const char *theme_root); GPtrArray *zoitechat_gtk3_theme_build_inheritance_chain (const char *theme_root);
gboolean zoitechat_gtk3_theme_service_read_archive_text_file (const char *archive_path, const char *name, char **contents, GError **error);
#endif #endif
+5 -5
View File
@@ -38,7 +38,6 @@
#include "ignore.h" #include "ignore.h"
#include "fe.h" #include "fe.h"
#include "modes.h" #include "modes.h"
#include "network.h"
#include "notify.h" #include "notify.h"
#include "outbound.h" #include "outbound.h"
#include "inbound.h" #include "inbound.h"
@@ -1477,13 +1476,14 @@ inbound_uback (server *serv, const message_tags_data *tags_data)
void void
inbound_foundip (session *sess, char *ip, const message_tags_data *tags_data) inbound_foundip (session *sess, char *ip, const message_tags_data *tags_data)
{ {
struct in_addr addr; struct hostent *HostAddr;
if (net_lookup_ipv4 (ip, &addr.s_addr)) HostAddr = gethostbyname (ip);
if (HostAddr)
{ {
sess->server->dcc_ip = addr.s_addr; sess->server->dcc_ip = ((struct in_addr *) HostAddr->h_addr_list[0])->s_addr;
EMIT_SIGNAL_TIMESTAMP (XP_TE_FOUNDIP, sess->server->server_session, EMIT_SIGNAL_TIMESTAMP (XP_TE_FOUNDIP, sess->server->server_session,
inet_ntoa (addr), inet_ntoa (*((struct in_addr *) HostAddr->h_addr_list[0])),
NULL, NULL, NULL, 0, tags_data->timestamp); NULL, NULL, NULL, 0, tags_data->timestamp);
} }
} }
+3 -16
View File
@@ -27,8 +27,6 @@ common_sources = [
'util.c' 'util.c'
] ]
secretstore_sources = files('secretstore.c')
common_sysinfo_deps = [] common_sysinfo_deps = []
libarchive_dep = dependency('libarchive', required: host_machine.system() != 'windows') libarchive_dep = dependency('libarchive', required: host_machine.system() != 'windows')
@@ -40,9 +38,6 @@ common_deps = [
if libarchive_dep.found() if libarchive_dep.found()
common_deps += libarchive_dep common_deps += libarchive_dep
endif endif
if libsecret_dep.found()
common_deps += libsecret_dep
endif
common_includes = [ common_includes = [
config_h_include, config_h_include,
@@ -101,14 +96,6 @@ marshal = [
make_te = find_program('make-te.py') make_te = find_program('make-te.py')
python3 = find_program('python3', required: true)
public_suffix_data = custom_target('public_suffix_data_h',
output: 'public_suffix_data.h',
command: [python3, files('gen-public-suffix.py'), '@OUTPUT@']
)
textevents = custom_target('textevents', textevents = custom_target('textevents',
input: 'textevents.in', input: 'textevents.in',
output: ['textevents.h', 'textenums.h'], output: ['textevents.h', 'textenums.h'],
@@ -120,7 +107,7 @@ if libssl_dep.found()
common_deps += libssl_dep common_deps += libssl_dep
endif endif
if dbus_dep.found() if dbus_glib_dep.found()
subdir('dbus') subdir('dbus')
common_deps += zoitechat_dbus_dep common_deps += zoitechat_dbus_dep
common_includes += include_directories('dbus') common_includes += include_directories('dbus')
@@ -132,7 +119,7 @@ if get_option('plugin')
endif endif
zoitechat_common = static_library('zoitechatcommon', zoitechat_common = static_library('zoitechatcommon',
sources: [textevents, public_suffix_data] + marshal + common_sources + secretstore_sources, sources: [textevents] + marshal + common_sources,
include_directories: config_h_include, include_directories: config_h_include,
dependencies: common_deps + common_sysinfo_deps, dependencies: common_deps + common_sysinfo_deps,
c_args: common_cflags, c_args: common_cflags,
@@ -140,7 +127,7 @@ zoitechat_common = static_library('zoitechatcommon',
) )
zoitechat_common_dep = declare_dependency( zoitechat_common_dep = declare_dependency(
sources: [textevents, public_suffix_data] + marshal, sources: [textevents] + marshal,
link_with: zoitechat_common, link_with: zoitechat_common,
include_directories: common_includes, include_directories: common_includes,
compile_args: common_cflags, compile_args: common_cflags,
-51
View File
@@ -34,9 +34,6 @@
#ifndef WIN32 #ifndef WIN32
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif
#endif #endif
#define WANTSOCKET #define WANTSOCKET
@@ -46,9 +43,6 @@
#define NETWORK_PRIVATE #define NETWORK_PRIVATE
#include "network.h" #include "network.h"
#include "zoitechat.h"
extern struct zoitechatprefs prefs;
#define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n))) #define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n)))
@@ -64,27 +58,6 @@ net_set_socket_options (int sok)
setsockopt (sok, SOL_SOCKET, SO_REUSEADDR, (char *) &sw, sizeof (sw)); setsockopt (sok, SOL_SOCKET, SO_REUSEADDR, (char *) &sw, sizeof (sw));
sw = 1; sw = 1;
setsockopt (sok, SOL_SOCKET, SO_KEEPALIVE, (char *) &sw, sizeof (sw)); setsockopt (sok, SOL_SOCKET, SO_KEEPALIVE, (char *) &sw, sizeof (sw));
#ifdef TCP_KEEPIDLE
{
int keepidle = prefs.hex_net_keepalive_idle;
if (keepidle > 0)
setsockopt (sok, IPPROTO_TCP, TCP_KEEPIDLE, (char *) &keepidle, sizeof (keepidle));
}
#endif
#ifdef TCP_KEEPINTVL
{
int keepintvl = prefs.hex_net_keepalive_interval;
if (keepintvl > 0)
setsockopt (sok, IPPROTO_TCP, TCP_KEEPINTVL, (char *) &keepintvl, sizeof (keepintvl));
}
#endif
#ifdef TCP_KEEPCNT
{
int keepcnt = prefs.hex_net_keepalive_count;
if (keepcnt > 0)
setsockopt (sok, IPPROTO_TCP, TCP_KEEPCNT, (char *) &keepcnt, sizeof (keepcnt));
}
#endif
} }
char * char *
@@ -96,30 +69,6 @@ net_ip (uint32_t addr)
return inet_ntoa (ia); return inet_ntoa (ia);
} }
int
net_lookup_ipv4 (const char *hostname, uint32_t *addr)
{
struct addrinfo hints;
struct addrinfo *res;
struct sockaddr_in *sin;
int ret;
memset (&hints, 0, sizeof (hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_ADDRCONFIG;
ret = getaddrinfo (hostname, NULL, &hints, &res);
if (ret != 0)
return FALSE;
sin = (struct sockaddr_in *) res->ai_addr;
*addr = sin->sin_addr.s_addr;
freeaddrinfo (res);
return TRUE;
}
void void
net_store_destroy (netstore * ns) net_store_destroy (netstore * ns)
{ {
-1
View File
@@ -39,7 +39,6 @@ int net_connect (netstore *ns, int sok4, int sok6, int *sok_return);
char *net_resolve (netstore *ns, char *hostname, int port, char **real_host); char *net_resolve (netstore *ns, char *hostname, int port, char **real_host);
void net_bind (netstore *tobindto, int sok4, int sok6); void net_bind (netstore *tobindto, int sok4, int sok6);
char *net_ip (uint32_t addr); char *net_ip (uint32_t addr);
int net_lookup_ipv4 (const char *hostname, uint32_t *addr);
void net_sockets (int *sok4, int *sok6); void net_sockets (int *sok4, int *sok6);
#endif #endif
+66 -66
View File
@@ -3462,45 +3462,28 @@ cmd_server (struct session *sess, char *tbuf, char *word[], char *word_eol[])
int use_ssl = FALSE; int use_ssl = FALSE;
#endif #endif
int is_url = TRUE; int is_url = TRUE;
int no_proxy = FALSE;
server *serv = sess->server; server *serv = sess->server;
ircnet *net = NULL; ircnet *net = NULL;
while (TRUE)
{
#ifdef USE_OPENSSL #ifdef USE_OPENSSL
if (g_strcmp0 (word[2 + offset], "-ssl") == 0 || g_strcmp0 (word[2 + offset], "-e") == 0) /* BitchX uses -ssl, mIRC uses -e, let's support both */
{ if (g_strcmp0 (word[2], "-ssl") == 0 || g_strcmp0 (word[2], "-e") == 0)
use_ssl = TRUE; {
use_ssl_noverify = FALSE; use_ssl = TRUE;
offset++; offset++; /* args move up by 1 word */
}
else if (g_strcmp0 (word[2 + offset], "-ssl-noverify") == 0)
{
use_ssl = TRUE;
use_ssl_noverify = TRUE;
offset++;
}
else if (g_strcmp0 (word[2 + offset], "-insecure") == 0)
{
use_ssl = FALSE;
use_ssl_noverify = FALSE;
offset++;
}
else
#endif
if (g_strcmp0 (word[2 + offset], "-noproxy") == 0)
{
no_proxy = TRUE;
offset++;
}
else
{
break;
}
} }
else if (g_strcmp0 (word[2], "-ssl-noverify") == 0)
serv->dont_use_proxy = no_proxy; {
use_ssl = TRUE;
use_ssl_noverify = TRUE;
offset++; /* args move up by 1 word */
}
else if (g_strcmp0 (word[2], "-insecure") == 0)
{
use_ssl = FALSE;
offset++; /* args move up by 1 word */
}
#endif
if (!parse_irc_url (word[2 + offset], &server_name, &port, &channel, &key, &use_ssl)) if (!parse_irc_url (word[2 + offset], &server_name, &port, &channel, &key, &use_ssl))
{ {
@@ -3601,18 +3584,10 @@ cmd_servchan (struct session *sess, char *tbuf, char *word[],
{ {
int offset = 0; int offset = 0;
while (TRUE)
{
#ifdef USE_OPENSSL #ifdef USE_OPENSSL
if (g_strcmp0 (word[2 + offset], "-ssl") == 0 || g_strcmp0 (word[2 + offset], "-ssl-noverify") == 0 || g_strcmp0 (word[2 + offset], "-insecure") == 0) if (g_strcmp0 (word[2], "-ssl") == 0 || g_strcmp0 (word[2], "-ssl-noverify") == 0 || g_strcmp0 (word[2], "-insecure") == 0)
offset++; offset++;
else
#endif #endif
if (g_strcmp0 (word[2 + offset], "-noproxy") == 0)
offset++;
else
break;
}
if (*word[4 + offset]) if (*word[4 + offset])
{ {
@@ -4095,7 +4070,7 @@ const struct commands xc_cmds[] = {
{"ME", cmd_me, 0, 0, 1, {"ME", cmd_me, 0, 0, 1,
N_("ME <action>, sends the action to the current channel (actions are written in the 3rd person, like /me jumps)")}, N_("ME <action>, sends the action to the current channel (actions are written in the 3rd person, like /me jumps)")},
{"MENU", cmd_menu, 0, 0, 1, "MENU [-eX] [-i<ICONFILE>] [-k<mod>,<key>] [-m] [-pX] [-r<X,group>] [-tX] {ADD|DEL} <path> [command] [unselect command]\n" {"MENU", cmd_menu, 0, 0, 1, "MENU [-eX] [-i<ICONFILE>] [-k<mod>,<key>] [-m] [-pX] [-r<X,group>] [-tX] {ADD|DEL} <path> [command] [unselect command]\n"
" See https://docs.zoitechat.org/en/latest/en/latest/plugins.html#controlling-the-gui for more details."}, " See https://docs.zoitechat.zoite.net/en/latest/en/latest/plugins.html#controlling-the-gui for more details."},
{"MHOP", cmd_mhop, 1, 1, 1, {"MHOP", cmd_mhop, 1, 1, 1,
N_("MHOP, Mass hop's all users in the current channel (needs chanop)")}, N_("MHOP, Mass hop's all users in the current channel (needs chanop)")},
{"MKICK", cmd_mkick, 1, 1, 1, {"MKICK", cmd_mkick, 1, 1, 1,
@@ -4144,17 +4119,17 @@ const struct commands xc_cmds[] = {
{"SEND", cmd_send, 0, 0, 1, N_("SEND <nick> [<file>]")}, {"SEND", cmd_send, 0, 0, 1, N_("SEND <nick> [<file>]")},
#ifdef USE_OPENSSL #ifdef USE_OPENSSL
{"SERVCHAN", cmd_servchan, 0, 0, 1, {"SERVCHAN", cmd_servchan, 0, 0, 1,
N_("SERVCHAN [-noproxy] [-insecure|-ssl|-ssl-noverify] <host> <port> <channel>, connects and joins a channel using ssl unless otherwise specified")}, N_("SERVCHAN [-insecure|-ssl|-ssl-noverify] <host> <port> <channel>, connects and joins a channel using ssl unless otherwise specified")},
#else #else
{"SERVCHAN", cmd_servchan, 0, 0, 1, {"SERVCHAN", cmd_servchan, 0, 0, 1,
N_("SERVCHAN [-noproxy] <host> <port> <channel>, connects and joins a channel")}, N_("SERVCHAN <host> <port> <channel>, connects and joins a channel")},
#endif #endif
#ifdef USE_OPENSSL #ifdef USE_OPENSSL
{"SERVER", cmd_server, 0, 0, 1, {"SERVER", cmd_server, 0, 0, 1,
N_("SERVER [-noproxy] [-insecure|-ssl|-ssl-noverify] <host> [<port>] [<password>], connects to a server using ssl unless otherwise specified, the default port is 6697 for ssl connections and 6667 for insecure connections")}, N_("SERVER [-insecure|-ssl|-ssl-noverify] <host> [<port>] [<password>], connects to a server using ssl unless otherwise specified, the default port is 6697 for ssl connections and 6667 for insecure connections")},
#else #else
{"SERVER", cmd_server, 0, 0, 1, {"SERVER", cmd_server, 0, 0, 1,
N_("SERVER [-noproxy] <host> [<port>] [<password>], connects to a server, the default port is 6667")}, N_("SERVER <host> [<port>] [<password>], connects to a server, the default port is 6667")},
#endif #endif
{"SET", cmd_set, 0, 0, 1, N_("SET [-e] [-off|-on] [-quiet] <variable> [<value>]")}, {"SET", cmd_set, 0, 0, 1, N_("SET [-e] [-off|-on] [-quiet] <variable> [<value>]")},
{"SETCURSOR", cmd_setcursor, 0, 0, 1, N_("SETCURSOR [-|+]<position>, reposition the cursor in the inputbox")}, {"SETCURSOR", cmd_setcursor, 0, 0, 1, N_("SETCURSOR [-|+]<position>, reposition the cursor in the inputbox")},
@@ -4191,10 +4166,10 @@ const struct commands xc_cmds[] = {
static int static int
command_compare (const void *a, const void *b) command_compare (const void *a, const void *b)
{ {
return g_ascii_strcasecmp (a, ((const struct commands *)b)->name); return g_ascii_strcasecmp (a, ((struct commands *)b)->name);
} }
static const struct commands * static struct commands *
find_internal_command (char *name) find_internal_command (char *name)
{ {
/* the "-1" is to skip the NULL terminator */ /* the "-1" is to skip the NULL terminator */
@@ -4230,7 +4205,7 @@ usercommand_show_help (session *sess, char *name)
static void static void
help (session *sess, char *tbuf, char *helpcmd, int quiet) help (session *sess, char *tbuf, char *helpcmd, int quiet)
{ {
const struct commands *cmd; struct commands *cmd;
if (plugin_show_help (sess, helpcmd)) if (plugin_show_help (sess, helpcmd))
return; return;
@@ -4422,7 +4397,7 @@ void
check_special_chars (char *cmd, int do_ascii) /* check for %X */ check_special_chars (char *cmd, int do_ascii) /* check for %X */
{ {
int occur = 0; int occur = 0;
size_t len = strlen (cmd); int len = strlen (cmd);
char *buf, *utf; char *buf, *utf;
char tbuf[4]; char tbuf[4];
int i = 0, j = 0; int i = 0, j = 0;
@@ -4788,7 +4763,7 @@ handle_command (session *sess, char *cmd, int check_spch)
char *word[PDIWORDS+1]; char *word[PDIWORDS+1];
char *word_eol[PDIWORDS+1]; char *word_eol[PDIWORDS+1];
static int command_level = 0; static int command_level = 0;
const struct commands *int_cmd; struct commands *int_cmd;
char *pdibuf; char *pdibuf;
char *tbuf; char *tbuf;
int len; int len;
@@ -4908,9 +4883,6 @@ xit:
static int static int
handle_user_input (session *sess, char *text, int history, int nocommand) handle_user_input (session *sess, char *text, int history, int nocommand)
{ {
char cmd_char = prefs.hex_input_command_char[0];
unsigned int i;
if (*text == '\0') if (*text == '\0')
return 1; return 1;
@@ -4918,23 +4890,51 @@ handle_user_input (session *sess, char *text, int history, int nocommand)
history_add (&sess->history, text); history_add (&sess->history, text);
/* is it NOT a command, just text? */ /* is it NOT a command, just text? */
if (nocommand || text[0] != cmd_char) if (nocommand || text[0] != prefs.hex_input_command_char[0])
{ {
handle_say (sess, text, TRUE); handle_say (sess, text, TRUE);
return 1; return 1;
} }
for (i = 1; text[i]; i++) /* check for // */
if (text[0] == prefs.hex_input_command_char[0] && text[1] == prefs.hex_input_command_char[0])
{ {
if (text[i] == cmd_char) handle_say (sess, text + 1, TRUE);
{ return 1;
handle_say (sess, text, TRUE);
return 1;
}
if (text[i] == ' ')
break;
} }
#if 0 /* Who would remember all this? */
if (prefs.hex_input_command_char[0] == '/')
{
int i;
const char *unix_dirs [] = {
"/bin/",
"/boot/",
"/dev/",
"/etc/",
"/home/",
"/lib/",
"/lost+found/",
"/mnt/",
"/opt/",
"/proc/",
"/root/",
"/sbin/",
"/tmp/",
"/usr/",
"/var/",
"/gnome/",
NULL
};
for (i = 0; unix_dirs[i] != NULL; i++)
if (strncmp (text, unix_dirs[i], strlen (unix_dirs[i]))==0)
{
handle_say (sess, text, TRUE);
return 1;
}
}
#endif
return handle_command (sess, text + 1, TRUE); return handle_command (sess, text + 1, TRUE);
} }
+3
View File
@@ -493,6 +493,7 @@ plugin_auto_load (session *sess)
for_files (lib_dir, "hcperl.dll", plugin_auto_load_cb); for_files (lib_dir, "hcperl.dll", plugin_auto_load_cb);
for_files (lib_dir, "hcpython3.dll", plugin_auto_load_cb); for_files (lib_dir, "hcpython3.dll", plugin_auto_load_cb);
for_files (lib_dir, "hcupd.dll", plugin_auto_load_cb); for_files (lib_dir, "hcupd.dll", plugin_auto_load_cb);
for_files (lib_dir, "hcwinamp.dll", plugin_auto_load_cb);
for_files (lib_dir, "hcsysinfo.dll", plugin_auto_load_cb); for_files (lib_dir, "hcsysinfo.dll", plugin_auto_load_cb);
#else #else
for_files (lib_dir, "*."PLUGIN_SUFFIX, plugin_auto_load_cb); for_files (lib_dir, "*."PLUGIN_SUFFIX, plugin_auto_load_cb);
@@ -1213,6 +1214,8 @@ zoitechat_get_info (zoitechat_plugin *ph, const char *id)
case 0x4889ba9b: /* password */ case 0x4889ba9b: /* password */
case 0x438fdf9: /* nickserv */ case 0x438fdf9: /* nickserv */
if (sess->server->network)
return ((ircnet *)sess->server->network)->pass;
return NULL; return NULL;
case 0xca022f43: /* server */ case 0xca022f43: /* server */
+1 -1
View File
@@ -1017,7 +1017,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
char *account; char *account;
char ip[128], nick[NICKLEN]; char ip[128], nick[NICKLEN];
char *text, *ex; char *text, *ex;
size_t len = strlen (type); int len = strlen (type);
/* fill in the "ip" and "nick" buffers */ /* fill in the "ip" and "nick" buffers */
ex = strchr (word[1], '!'); ex = strchr (word[1], '!');
-173
View File
@@ -1,173 +0,0 @@
#include "zoitechat.h"
#include "cfgfiles.h"
#include "secretstore.h"
#include <string.h>
#ifdef WIN32
#include <windows.h>
#include <wincred.h>
#endif
#ifdef HAVE_LIBSECRET
#include <libsecret/secret.h>
#endif
static char *secretstore_target (const char *network_name)
{
return g_strdup_printf ("zoitechat/network/%s", network_name ? network_name : "default");
}
int secretstore_is_keyring_available (void)
{
#ifdef WIN32
return TRUE;
#elif defined(HAVE_LIBSECRET)
return TRUE;
#else
return FALSE;
#endif
}
char *secretstore_get_network_password (const char *network_name)
{
char *target;
target = secretstore_target (network_name);
#ifdef WIN32
{
PCREDENTIALA cred = NULL;
char *ret = NULL;
if (CredReadA (target, CRED_TYPE_GENERIC, 0, &cred))
{
ret = g_strndup ((const char *) cred->CredentialBlob, cred->CredentialBlobSize);
CredFree (cred);
}
g_free (target);
return ret;
}
#elif defined(HAVE_LIBSECRET)
{
static const SecretSchema schema = {
"net.zoite.ZoiteChat.Network", SECRET_SCHEMA_NONE,
{
{ "network", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ NULL, 0 },
}
};
char *ret = secret_password_lookup_sync (&schema, NULL, NULL, "network", target, NULL);
g_free (target);
return ret;
}
#else
g_free (target);
return NULL;
#endif
}
int secretstore_set_network_password (const char *network_name, const char *password)
{
char *target;
target = secretstore_target (network_name);
#ifdef WIN32
{
CREDENTIALA cred;
memset (&cred, 0, sizeof (cred));
cred.Type = CRED_TYPE_GENERIC;
cred.TargetName = target;
cred.CredentialBlobSize = (DWORD) strlen (password);
cred.CredentialBlob = (LPBYTE) password;
cred.Persist = CRED_PERSIST_LOCAL_MACHINE;
cred.UserName = "zoitechat";
if (!CredWriteA (&cred, 0))
{
g_free (target);
return FALSE;
}
g_free (target);
return TRUE;
}
#elif defined(HAVE_LIBSECRET)
{
static const SecretSchema schema = {
"net.zoite.ZoiteChat.Network", SECRET_SCHEMA_NONE,
{
{ "network", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ NULL, 0 },
}
};
gboolean ok = secret_password_store_sync (&schema, SECRET_COLLECTION_DEFAULT,
"ZoiteChat network password", password, NULL, NULL, "network", target, NULL);
g_free (target);
return ok;
}
#else
g_free (target);
return FALSE;
#endif
}
int secretstore_delete_network_password (const char *network_name)
{
char *target;
target = secretstore_target (network_name);
#ifdef WIN32
{
gboolean ok = CredDeleteA (target, CRED_TYPE_GENERIC, 0);
g_free (target);
return ok;
}
#elif defined(HAVE_LIBSECRET)
{
static const SecretSchema schema = {
"net.zoite.ZoiteChat.Network", SECRET_SCHEMA_NONE,
{
{ "network", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ NULL, 0 },
}
};
gboolean ok = secret_password_clear_sync (&schema, NULL, NULL, "network", target, NULL);
g_free (target);
return ok;
}
#else
g_free (target);
return FALSE;
#endif
}
int secretstore_require_unlock (const char *network_name)
{
#ifdef WIN32
return TRUE;
#elif defined(HAVE_LIBSECRET)
{
static const SecretSchema schema = {
"net.zoite.ZoiteChat.Network", SECRET_SCHEMA_NONE,
{
{ "network", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ NULL, 0 },
}
};
char *target;
char *password;
GError *error = NULL;
target = secretstore_target (network_name);
password = secret_password_lookup_sync (&schema, NULL, &error, "network", target, NULL);
g_free (target);
if (password)
{
memset (password, 0, strlen (password));
g_free (password);
return TRUE;
}
if (error)
{
g_error_free (error);
return FALSE;
}
return TRUE;
}
#else
return TRUE;
#endif
}
-10
View File
@@ -1,10 +0,0 @@
#ifndef ZOITECHAT_SECRETSTORE_H
#define ZOITECHAT_SECRETSTORE_H
char *secretstore_get_network_password (const char *network_name);
int secretstore_set_network_password (const char *network_name, const char *password);
int secretstore_delete_network_password (const char *network_name);
int secretstore_is_keyring_available (void);
int secretstore_require_unlock (const char *network_name);
#endif
+26 -21
View File
@@ -522,7 +522,7 @@ ssl_cb_verify (int ok, X509_STORE_CTX * ctx)
X509 *current_cert = X509_STORE_CTX_get_current_cert (ctx); X509 *current_cert = X509_STORE_CTX_get_current_cert (ctx);
if (!current_cert) if (!current_cert)
return ok; return TRUE;
X509_NAME_oneline (X509_get_subject_name (current_cert), X509_NAME_oneline (X509_get_subject_name (current_cert),
subject, sizeof (subject)); subject, sizeof (subject));
@@ -534,21 +534,13 @@ ssl_cb_verify (int ok, X509_STORE_CTX * ctx)
g_snprintf (buf, sizeof (buf), "* Issuer: %s", issuer); g_snprintf (buf, sizeof (buf), "* Issuer: %s", issuer);
EMIT_SIGNAL (XP_TE_SSLMESSAGE, g_sess, buf, NULL, NULL, NULL, 0); EMIT_SIGNAL (XP_TE_SSLMESSAGE, g_sess, buf, NULL, NULL, NULL, 0);
if (!ok) return TRUE;
{
int err = X509_STORE_CTX_get_error (ctx);
g_snprintf (buf, sizeof (buf), "* Verify E: %s (%d)",
X509_verify_cert_error_string (err), err);
EMIT_SIGNAL (XP_TE_SSLMESSAGE, g_sess, buf, NULL, NULL, NULL, 0);
}
return ok;
} }
static int static int
ssl_do_connect (server * serv) ssl_do_connect (server * serv)
{ {
char buf[256]; char buf[256]; // ERR_error_string() MUST have this size
g_sess = serv->server_session; g_sess = serv->server_session;
@@ -567,10 +559,9 @@ ssl_do_connect (server * serv)
if (SSL_connect (serv->ssl) <= 0) if (SSL_connect (serv->ssl) <= 0)
{ {
char err_buf[128]; char err_buf[128];
int err, ssl_err; int err;
g_sess = NULL; g_sess = NULL;
ssl_err = SSL_get_error (serv->ssl, -1);
if ((err = ERR_get_error ()) > 0) if ((err = ERR_get_error ()) > 0)
{ {
ERR_error_string (err, err_buf); ERR_error_string (err, err_buf);
@@ -580,8 +571,6 @@ ssl_do_connect (server * serv)
if (ERR_GET_REASON (err) == SSL_R_WRONG_VERSION_NUMBER) if (ERR_GET_REASON (err) == SSL_R_WRONG_VERSION_NUMBER)
PrintText (serv->server_session, _("Are you sure this is a SSL capable server and port?\n")); PrintText (serv->server_session, _("Are you sure this is a SSL capable server and port?\n"));
else if (ssl_err == SSL_ERROR_SSL)
EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, "* TLS handshake rejected by protocol/certificate/cipher policy", NULL, NULL, NULL, 0);
server_cleanup (serv); server_cleanup (serv);
@@ -660,13 +649,29 @@ ssl_do_connect (server * serv)
int hostname_err; int hostname_err;
if ((hostname_err = _SSL_check_hostname(cert, serv->hostname)) != 0) if ((hostname_err = _SSL_check_hostname(cert, serv->hostname)) != 0)
{ {
g_snprintf (buf, sizeof (buf), "* Verify E: Failed to validate hostname (%d)", g_snprintf (buf, sizeof (buf), "* Verify E: Failed to validate hostname? (%d)%s",
hostname_err); hostname_err, serv->accept_invalid_cert ? " -- Ignored" : "");
EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0); if (serv->accept_invalid_cert)
goto conn_fail; EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL, NULL, 0);
else
goto conn_fail;
} }
break; break;
} }
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
case X509_V_ERR_CERT_HAS_EXPIRED:
if (serv->accept_invalid_cert)
{
g_snprintf (buf, sizeof (buf), "* Verify E: %s.? (%d) -- Ignored",
X509_verify_cert_error_string (verify_error),
verify_error);
EMIT_SIGNAL (XP_TE_SSLMESSAGE, serv->server_session, buf, NULL, NULL,
NULL, 0);
break;
}
default: default:
g_snprintf (buf, sizeof (buf), "%s.? (%d)", g_snprintf (buf, sizeof (buf), "%s.? (%d)",
X509_verify_cert_error_string (verify_error), X509_verify_cert_error_string (verify_error),
@@ -876,7 +881,7 @@ server_read_child (GIOChannel *source, GIOCondition condition, server *serv)
if (prefs.hex_net_auto_reconnectonfail) if (prefs.hex_net_auto_reconnectonfail)
auto_reconnect (serv, FALSE, -1); auto_reconnect (serv, FALSE, -1);
break; break;
case '3': /* resolver finished */ case '3': /* gethostbyname finished */
waitline2 (source, host, sizeof host); waitline2 (source, host, sizeof host);
waitline2 (source, ip, sizeof ip); waitline2 (source, ip, sizeof ip);
waitline2 (source, outbuf, sizeof outbuf); waitline2 (source, outbuf, sizeof outbuf);
@@ -927,7 +932,7 @@ server_read_child (GIOChannel *source, GIOCondition condition, server *serv)
waitline2 (source, tbuf, sizeof tbuf); waitline2 (source, tbuf, sizeof tbuf);
prefs.local_ip = inet_addr (tbuf); prefs.local_ip = inet_addr (tbuf);
break; break;
case '7': /* prefs.hex_net_bind_host resolve failed */ case '7': /* gethostbyname (prefs.hex_net_bind_host) failed */
sprintf (outbuf, sprintf (outbuf,
_("Cannot resolve hostname %s\nCheck your IP Settings!\n"), _("Cannot resolve hostname %s\nCheck your IP Settings!\n"),
prefs.hex_net_bind_host); prefs.hex_net_bind_host);
+21 -165
View File
@@ -33,152 +33,9 @@
#include "text.h" #include "text.h"
#include "util.h" /* token_foreach */ #include "util.h" /* token_foreach */
#include "zoitechatc.h" #include "zoitechatc.h"
#include "secretstore.h"
#include "servlist.h" #include "servlist.h"
#ifdef USE_OPENSSL
#include <openssl/evp.h>
#include <openssl/rand.h>
#endif
char *
servlist_password_encrypt_for_storage (const char *pass)
{
gchar *material;
unsigned char salt[16];
unsigned char iv[16];
unsigned char key[32];
unsigned char *ciphertext;
int outlen1;
int outlen2;
int inlen;
int cipherlen;
EVP_CIPHER_CTX *ctx;
char *b64;
char *ret;
if (!pass || !*pass)
return NULL;
#ifdef USE_OPENSSL
if (RAND_bytes (salt, sizeof (salt)) != 1 || RAND_bytes (iv, sizeof (iv)) != 1)
return NULL;
material = g_strdup_printf ("%s|%s", g_get_user_name (), get_xdir ());
if (!PKCS5_PBKDF2_HMAC (material, -1, salt, sizeof (salt), 300000, EVP_sha256 (), sizeof (key), key))
{
g_free (material);
return NULL;
}
g_free (material);
inlen = (int) strlen (pass);
ciphertext = g_malloc (inlen + EVP_MAX_BLOCK_LENGTH);
ctx = EVP_CIPHER_CTX_new ();
if (!ctx)
{
memset (key, 0, sizeof (key));
g_free (ciphertext);
return NULL;
}
if (EVP_EncryptInit_ex (ctx, EVP_aes_256_cbc (), NULL, key, iv) != 1 ||
EVP_EncryptUpdate (ctx, ciphertext, &outlen1, (const unsigned char *) pass, inlen) != 1 ||
EVP_EncryptFinal_ex (ctx, ciphertext + outlen1, &outlen2) != 1)
{
EVP_CIPHER_CTX_free (ctx);
memset (key, 0, sizeof (key));
g_free (ciphertext);
return NULL;
}
EVP_CIPHER_CTX_free (ctx);
cipherlen = outlen1 + outlen2;
{
gsize payload_len = sizeof (salt) + sizeof (iv) + (gsize) cipherlen;
unsigned char *payload = g_malloc (payload_len);
memcpy (payload, salt, sizeof (salt));
memcpy (payload + sizeof (salt), iv, sizeof (iv));
memcpy (payload + sizeof (salt) + sizeof (iv), ciphertext, cipherlen);
b64 = g_base64_encode (payload, payload_len);
memset (payload, 0, payload_len);
g_free (payload);
}
memset (key, 0, sizeof (key));
memset (ciphertext, 0, inlen + EVP_MAX_BLOCK_LENGTH);
g_free (ciphertext);
#else
b64 = g_base64_encode ((const guchar *) pass, strlen (pass));
#endif
ret = g_strdup_printf ("enc:%s", b64);
g_free (b64);
return ret;
}
gboolean
servlist_password_is_encrypted (const char *pass)
{
return pass && g_str_has_prefix (pass, "enc:");
}
char *
servlist_password_decrypt_for_storage (const char *enc)
{
guchar *raw;
gsize len;
char *ret;
if (!enc || !*enc)
return NULL;
if (!g_str_has_prefix (enc, "enc:"))
return g_strdup (enc);
raw = g_base64_decode (enc + 4, &len);
#ifdef USE_OPENSSL
if (len <= 32)
{
g_free (raw);
return NULL;
}
{
unsigned char *salt = raw;
unsigned char *iv = raw + 16;
unsigned char *ciphertext = raw + 32;
int cipherlen = (int) (len - 32);
unsigned char key[32];
gchar *material = g_strdup_printf ("%s|%s", g_get_user_name (), get_xdir ());
unsigned char *plaintext = g_malloc ((gsize) cipherlen + 1);
int outlen1;
int outlen2;
EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new ();
if (!ctx || !PKCS5_PBKDF2_HMAC (material, -1, salt, 16, 300000, EVP_sha256 (), sizeof (key), key))
{
g_free (material);
if (ctx)
EVP_CIPHER_CTX_free (ctx);
g_free (plaintext);
g_free (raw);
return NULL;
}
g_free (material);
if (EVP_DecryptInit_ex (ctx, EVP_aes_256_cbc (), NULL, key, iv) != 1 ||
EVP_DecryptUpdate (ctx, plaintext, &outlen1, ciphertext, cipherlen) != 1 ||
EVP_DecryptFinal_ex (ctx, plaintext + outlen1, &outlen2) != 1)
{
EVP_CIPHER_CTX_free (ctx);
memset (key, 0, sizeof (key));
memset (plaintext, 0, (gsize) cipherlen + 1);
g_free (plaintext);
g_free (raw);
return NULL;
}
EVP_CIPHER_CTX_free (ctx);
memset (key, 0, sizeof (key));
plaintext[outlen1 + outlen2] = 0;
ret = g_strdup ((const char *) plaintext);
memset (plaintext, 0, (gsize) cipherlen + 1);
g_free (plaintext);
}
#else
ret = g_strndup ((const char *) raw, len);
#endif
g_free (raw);
return ret;
}
struct defaultserver struct defaultserver
{ {
@@ -487,29 +344,10 @@ servlist_connect (session *sess, ircnet *net, gboolean join)
} }
serv->password[0] = 0; serv->password[0] = 0;
if ((net->flags & FLAG_USE_KEYRING) && net->name)
if (net->pass)
{ {
char *stored_pass = secretstore_get_network_password (net->name); safe_strcpy (serv->password, net->pass, sizeof (serv->password));
if (stored_pass && *stored_pass)
{
safe_strcpy (serv->password, stored_pass, sizeof (serv->password));
}
if (stored_pass)
{
memset (stored_pass, 0, strlen (stored_pass));
g_free (stored_pass);
}
}
else if (net->pass)
{
char *plain = servlist_password_decrypt_for_storage (net->pass);
if (plain && *plain)
safe_strcpy (serv->password, plain, sizeof (serv->password));
if (plain)
{
memset (plain, 0, strlen (plain));
g_free (plain);
}
} }
if (net->flags & FLAG_USE_GLOBAL) if (net->flags & FLAG_USE_GLOBAL)
@@ -1144,6 +982,24 @@ servlist_load (void)
* *
* Should be removed at some point. * Should be removed at some point.
*/ */
case 'A':
if (!net->pass)
{
net->pass = g_strdup (buf + 2);
if (!net->logintype)
{
net->logintype = LOGIN_SASL;
}
}
case 'B':
if (!net->pass)
{
net->pass = g_strdup (buf + 2);
if (!net->logintype)
{
net->logintype = LOGIN_NICKSERV;
}
}
} }
} }
if (buf[0] == 'N') if (buf[0] == 'N')
+1 -5
View File
@@ -62,8 +62,7 @@ extern GSList *network_list;
#define FLAG_USE_PROXY 16 #define FLAG_USE_PROXY 16
#define FLAG_ALLOW_INVALID 32 #define FLAG_ALLOW_INVALID 32
#define FLAG_FAVORITE 64 #define FLAG_FAVORITE 64
#define FLAG_USE_KEYRING 128 #define FLAG_COUNT 7
#define FLAG_COUNT 8
/* Login methods. Use server password by default - if we had a NickServ password, it'd be set to 2 already by servlist_load() */ /* Login methods. Use server password by default - if we had a NickServ password, it'd be set to 2 already by servlist_load() */
#define LOGIN_DEFAULT_REAL LOGIN_PASS /* this is to set the default login method for unknown servers */ #define LOGIN_DEFAULT_REAL LOGIN_PASS /* this is to set the default login method for unknown servers */
@@ -125,8 +124,5 @@ favchannel *servlist_favchan_copy (favchannel *fav);
GSList *servlist_favchan_listadd (GSList *chanlist, char *channel, char *key); GSList *servlist_favchan_listadd (GSList *chanlist, char *channel, char *key);
gboolean joinlist_is_in_list (server *serv, char *channel); gboolean joinlist_is_in_list (server *serv, char *channel);
char *servlist_password_encrypt_for_storage (const char *pass);
char *servlist_password_decrypt_for_storage (const char *pass);
gboolean servlist_password_is_encrypted (const char *pass);
#endif #endif
+8 -9
View File
@@ -86,17 +86,15 @@ _SSL_context_init (void (*info_cb_func))
SSLeay_add_ssl_algorithms (); SSLeay_add_ssl_algorithms ();
SSL_load_error_strings (); SSL_load_error_strings ();
ctx = SSL_CTX_new (TLS_client_method ()); ctx = SSL_CTX_new (SSLv23_client_method ());
SSL_CTX_set_session_cache_mode (ctx, SSL_SESS_CACHE_BOTH); SSL_CTX_set_session_cache_mode (ctx, SSL_SESS_CACHE_BOTH);
SSL_CTX_set_timeout (ctx, 300); SSL_CTX_set_timeout (ctx, 300);
SSL_CTX_set_options (ctx, SSL_OP_NO_COMPRESSION SSL_CTX_set_options (ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3
|SSL_OP_NO_COMPRESSION
|SSL_OP_SINGLE_DH_USE|SSL_OP_SINGLE_ECDH_USE |SSL_OP_SINGLE_DH_USE|SSL_OP_SINGLE_ECDH_USE
|SSL_OP_NO_TICKET |SSL_OP_NO_TICKET
|SSL_OP_NO_RENEGOTIATION); |SSL_OP_CIPHER_SERVER_PREFERENCE);
SSL_CTX_set_min_proto_version (ctx, TLS1_2_VERSION);
SSL_CTX_set_cipher_list (ctx, "HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!DSS");
SSL_CTX_set_ciphersuites (ctx, "TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256");
#if OPENSSL_VERSION_NUMBER >= 0x00908000L && !defined (OPENSSL_NO_COMP) /* workaround for OpenSSL 0.9.8 */ #if OPENSSL_VERSION_NUMBER >= 0x00908000L && !defined (OPENSSL_NO_COMP) /* workaround for OpenSSL 0.9.8 */
sk_SSL_COMP_zero(SSL_COMP_get_compression_methods()); sk_SSL_COMP_zero(SSL_COMP_get_compression_methods());
@@ -313,7 +311,7 @@ _SSL_socket (SSL_CTX *ctx, int sd)
#else #else
method = SSL_CTX_get_ssl_method (ctx); method = SSL_CTX_get_ssl_method (ctx);
#endif #endif
if (method == TLS_client_method()) if (method == SSLv23_client_method())
SSL_set_connect_state (ssl); SSL_set_connect_state (ssl);
else else
SSL_set_accept_state(ssl); SSL_set_accept_state(ssl);
@@ -350,13 +348,14 @@ _SSL_close (SSL * ssl)
{ {
SSL_set_shutdown (ssl, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); SSL_set_shutdown (ssl, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);
SSL_free (ssl); SSL_free (ssl);
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#ifdef HAVE_ERR_REMOVE_THREAD_STATE #ifdef HAVE_ERR_REMOVE_THREAD_STATE
#if OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER < 0x10100000L
/* OpenSSL handles this itself in 1.1+ and this is a no-op */
ERR_remove_thread_state (NULL); ERR_remove_thread_state (NULL);
#endif
#else #else
ERR_remove_state (0); ERR_remove_state (0);
#endif #endif
#endif
} }
/* Hostname validation code based on OpenBSD's libtls. */ /* Hostname validation code based on OpenBSD's libtls. */
+2 -17
View File
@@ -22,7 +22,6 @@
#include <ctype.h> #include <ctype.h>
#include <inttypes.h> #include <inttypes.h>
#include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
@@ -75,18 +74,6 @@ typedef struct
static bool string_builder_init (StringBuilder *builder); static bool string_builder_init (StringBuilder *builder);
static void string_builder_free (StringBuilder *builder); static void string_builder_free (StringBuilder *builder);
static bool string_builder_append (StringBuilder *builder, const char *text); static bool string_builder_append (StringBuilder *builder, const char *text);
static int size_to_int (size_t value);
static int
size_to_int (size_t value)
{
if (value > (size_t) INT_MAX)
{
return INT_MAX;
}
return (int) value;
}
char * char *
sysinfo_get_cpu (void) sysinfo_get_cpu (void)
@@ -524,7 +511,6 @@ static char *read_hdd_info (IWbemClassObject *object)
static char *bstr_to_utf8 (BSTR bstr) static char *bstr_to_utf8 (BSTR bstr)
{ {
int utf8_len; int utf8_len;
int wide_len;
char *utf8; char *utf8;
if (bstr == NULL) if (bstr == NULL)
@@ -532,8 +518,7 @@ static char *bstr_to_utf8 (BSTR bstr)
return NULL; return NULL;
} }
wide_len = size_to_int ((size_t) SysStringLen (bstr)); utf8_len = WideCharToMultiByte (CP_UTF8, 0, bstr, SysStringLen (bstr), NULL, 0, NULL, NULL);
utf8_len = WideCharToMultiByte (CP_UTF8, 0, bstr, wide_len, NULL, 0, NULL, NULL);
if (utf8_len <= 0) if (utf8_len <= 0)
{ {
return NULL; return NULL;
@@ -545,7 +530,7 @@ static char *bstr_to_utf8 (BSTR bstr)
return NULL; return NULL;
} }
if (WideCharToMultiByte (CP_UTF8, 0, bstr, wide_len, utf8, utf8_len, NULL, NULL) <= 0) if (WideCharToMultiByte (CP_UTF8, 0, bstr, SysStringLen (bstr), utf8, utf8_len, NULL, NULL) <= 0)
{ {
free (utf8); free (utf8);
return NULL; return NULL;
+1 -86
View File
@@ -1809,97 +1809,12 @@ format_event (session *sess, int index, char **args, char *o, gsize sizeofo, uns
o[0] = 0; o[0] = 0;
} }
static char *
text_event_without_hostmask_format (const char *format, int host_arg)
{
char token[3];
const char *arg;
const char *open;
const char *close;
const char *start;
char *out;
gsize prefix_len;
g_snprintf (token, sizeof (token), "$%d", host_arg);
arg = strstr (format, token);
if (!arg)
return NULL;
open = arg;
while (open > format && *open != '(' && *open != '\n')
open--;
close = arg + strlen (token);
while (*close && *close != ')' && *close != '\n')
close++;
if (*open != '(' || *close != ')')
return NULL;
start = open;
if (start > format && start[-1] == ' ')
start--;
prefix_len = start - format;
out = g_malloc (prefix_len + strlen (close + 1) + 1);
memcpy (out, format, prefix_len);
strcpy (out + prefix_len, close + 1);
return out;
}
static void
display_event_string (session *sess, int event, char **args, char *format,
unsigned int stripcolor_args, time_t timestamp)
{
char *compiled;
char *saved;
char o[4096];
int max_arg;
if (pevt_build_string (format, &compiled, &max_arg) != 0)
return;
saved = pntevts[event];
pntevts[event] = compiled;
format_event (sess, event, args, o, sizeof (o), stripcolor_args);
pntevts[event] = saved;
g_free (compiled);
if (o[0])
PrintTextTimeStamp (sess, o, timestamp);
}
static void static void
display_event (session *sess, int event, char **args, display_event (session *sess, int event, char **args,
unsigned int stripcolor_args, time_t timestamp) unsigned int stripcolor_args, time_t timestamp)
{ {
char o[4096]; char o[4096];
char *format; format_event (sess, event, args, o, sizeof (o), stripcolor_args);
char *host;
int host_arg;
if (prefs.hex_irc_hide_join_part_hostmask &&
(event == XP_TE_JOIN || event == XP_TE_PART || event == XP_TE_PARTREASON))
{
host_arg = event == XP_TE_JOIN ? 3 : 2;
format = text_event_without_hostmask_format (pntevts_text[event], host_arg);
if (format)
{
display_event_string (sess, event, args, format, stripcolor_args, timestamp);
g_free (format);
return;
}
host = args[host_arg];
args[host_arg] = "";
format_event (sess, event, args, o, sizeof (o), stripcolor_args);
args[host_arg] = host;
}
else
{
format_event (sess, event, args, o, sizeof (o), stripcolor_args);
}
if (o[0]) if (o[0])
PrintTextTimeStamp (sess, o, timestamp); PrintTextTimeStamp (sess, o, timestamp);
} }
+2 -146
View File
@@ -20,14 +20,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <glib.h>
#include "zoitechat.h" #include "zoitechat.h"
#include "zoitechatc.h" #include "zoitechatc.h"
#include "cfgfiles.h" #include "cfgfiles.h"
#include "fe.h" #include "fe.h"
#include "tree.h" #include "tree.h"
#include "url.h" #include "url.h"
#include "public_suffix_data.h"
#ifdef HAVE_STRINGS_H #ifdef HAVE_STRINGS_H
#include <strings.h> #include <strings.h>
#endif #endif
@@ -37,7 +35,6 @@ GTree *url_btree = NULL;
static gboolean regex_match (const GRegex *re, const char *word, static gboolean regex_match (const GRegex *re, const char *word,
int *start, int *end); int *start, int *end);
static const GRegex *re_url (void); static const GRegex *re_url (void);
static const GRegex *re_url_no_scheme (void);
static const GRegex *re_email (void); static const GRegex *re_email (void);
static const GRegex *re_nick (void); static const GRegex *re_nick (void);
static const GRegex *re_channel (void); static const GRegex *re_channel (void);
@@ -45,8 +42,6 @@ static gboolean match_nick (const char *word, int *start, int *end);
static gboolean match_channel (const char *word, int *start, int *end); static gboolean match_channel (const char *word, int *start, int *end);
static gboolean match_url (const char *word, int *start, int *end); static gboolean match_url (const char *word, int *start, int *end);
static gboolean match_email (const char *word, int *start, int *end); static gboolean match_email (const char *word, int *start, int *end);
static gboolean host_has_public_suffix (const char *host);
static gboolean host_has_public_suffix_range (const char *word, int start, int end);
static int static int
url_free (char *url, void *data) url_free (char *url, void *data)
@@ -271,16 +266,7 @@ match_channel (const char *word, int *start, int *end)
static gboolean static gboolean
match_url (const char *word, int *start, int *end) match_url (const char *word, int *start, int *end)
{ {
if (regex_match (re_url (), word, start, end)) return regex_match (re_url (), word, start, end);
return TRUE;
if (!regex_match (re_url_no_scheme (), word, start, end))
return FALSE;
if (*start > 0 && word[*start - 1] == '@')
return FALSE;
return host_has_public_suffix_range (word, *start, *end);
} }
static gboolean static gboolean
@@ -321,7 +307,7 @@ url_check_line (char *buf)
for (i = 0; i < ARRAY_SIZE (commands); i++) for (i = 0; i < ARRAY_SIZE (commands); i++)
{ {
char *cmd = commands[i]; char *cmd = commands[i];
size_t len = strlen (cmd); int len = strlen (cmd);
if (strncmp (cmd, po, len) == 0) if (strncmp (cmd, po, len) == 0)
{ {
@@ -407,114 +393,6 @@ regex_match (const GRegex *re, const char *word, int *start, int *end)
return found; return found;
} }
static gboolean
host_has_public_suffix_range (const char *word, int start, int end)
{
char *candidate;
const char *host_start;
const char *host_end;
const char *host_colon;
gboolean ok;
int host_len;
char *host;
candidate = g_strndup (word + start, end - start);
host_start = candidate;
host_end = candidate + strlen (candidate);
if (*host_start == '[')
{
g_free (candidate);
return FALSE;
}
host_colon = strchr (host_start, ':');
if (host_colon)
host_end = host_colon;
host_colon = strchr (host_start, '/');
if (host_colon && host_colon < host_end)
host_end = host_colon;
host_len = (int)(host_end - host_start);
if (host_len <= 0)
{
g_free (candidate);
return FALSE;
}
host = g_strndup (host_start, host_len);
ok = host_has_public_suffix (host);
g_free (host);
g_free (candidate);
return ok;
}
static GHashTable *
public_suffix_table (void)
{
static GHashTable *table = NULL;
unsigned int i;
if (table)
return table;
table = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; i < public_suffix_rules_len; i++)
{
g_hash_table_add (table, (gpointer)public_suffix_rules[i]);
}
return table;
}
static gboolean
host_has_public_suffix (const char *host)
{
GHashTable *table;
gchar **labels;
int i;
int n;
gboolean matched = FALSE;
if (!strchr (host, '.'))
return FALSE;
labels = g_strsplit (host, ".", -1);
for (n = 0; labels[n]; n++)
{
if (labels[n][0] == '\0')
{
g_strfreev (labels);
return FALSE;
}
}
table = public_suffix_table ();
for (i = 0; i < n; i++)
{
char *tail = g_strjoinv (".", &labels[i]);
if (g_hash_table_contains (table, tail))
matched = TRUE;
if (i + 1 < n)
{
char *tail_wild = g_strjoinv (".", &labels[i + 1]);
char *wild = g_strconcat ("*.", tail_wild, NULL);
if (g_hash_table_contains (table, wild))
matched = TRUE;
g_free (tail_wild);
g_free (wild);
}
if (i > 0)
{
char *exc = g_strconcat ("!", tail, NULL);
if (g_hash_table_contains (table, exc))
matched = TRUE;
g_free (exc);
}
g_free (tail);
if (matched)
break;
}
g_strfreev (labels);
return matched;
}
/* Miscellaneous description --- */ /* Miscellaneous description --- */
#define DOMAIN_LABEL "[\\pL\\pN](?:[-\\pL\\pN]{0,61}[\\pL\\pN])?" #define DOMAIN_LABEL "[\\pL\\pN](?:[-\\pL\\pN]{0,61}[\\pL\\pN])?"
#define DOMAIN DOMAIN_LABEL "(\\." DOMAIN_LABEL ")*" #define DOMAIN DOMAIN_LABEL "(\\." DOMAIN_LABEL ")*"
@@ -599,28 +477,6 @@ re_url (void)
return url_ret; return url_ret;
} }
static const GRegex *
re_url_no_scheme (void)
{
static GRegex *url_ret = NULL;
GString *grist_gstr;
char *grist;
if (url_ret) return url_ret;
grist_gstr = g_string_new (NULL);
g_string_append (grist_gstr, "(");
g_string_append (grist_gstr, HOST_URL_OPT_TLD OPT_PORT);
g_string_append_printf (grist_gstr, "(/" PATH ")?");
g_string_append (grist_gstr, ")");
grist = g_string_free (grist_gstr, FALSE);
url_ret = make_re (grist);
g_free (grist);
return url_ret;
}
#define EMAIL_LOCAL_ATOM "[\\pL\\pN!#$%&'*+/=?^_`{|}~-]+" #define EMAIL_LOCAL_ATOM "[\\pL\\pN!#$%&'*+/=?^_`{|}~-]+"
#define EMAIL_LOCAL EMAIL_LOCAL_ATOM "(\\." EMAIL_LOCAL_ATOM ")*" #define EMAIL_LOCAL EMAIL_LOCAL_ATOM "(\\." EMAIL_LOCAL_ATOM ")*"
#define EMAIL EMAIL_LOCAL "@" DOMAIN TLD #define EMAIL EMAIL_LOCAL "@" DOMAIN TLD
+1 -1
View File
@@ -98,7 +98,7 @@ path_part (char *file, char *path, int pathlen)
char * /* like strstr(), but nocase */ char * /* like strstr(), but nocase */
nocasestrstr (const char *s, const char *wanted) nocasestrstr (const char *s, const char *wanted)
{ {
register const size_t len = strlen (wanted); register const int len = strlen (wanted);
if (len == 0) if (len == 0)
return (char *)s; return (char *)s;
+6 -6
View File
@@ -2,10 +2,10 @@
* Copyright (C) 1998-2010 Peter Zelezny. * Copyright (C) 1998-2010 Peter Zelezny.
* Copyright (C) 2009-2013 Berke Viktor. * Copyright (C) 2009-2013 Berke Viktor.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or modify
* modify it under the terms of the GNU General Public License * it under the terms of the GNU General Public License as published by
* as published by the Free Software Foundation; either version 2 * the Free Software Foundation; either version 2 of the License, or
* of the License, or (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,8 +13,8 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, see * along with this program; if not, write to the Free Software
* <https://www.gnu.org/licenses/>. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/* You can distribute this header with your plugins for easy compilation */ /* You can distribute this header with your plugins for easy compilation */
+6 -7
View File
@@ -379,7 +379,6 @@ lag_check (void)
char tbuf[128]; char tbuf[128];
time_t now = time (0); time_t now = time (0);
time_t lag; time_t lag;
time_t ping_age;
tim = make_ping_time (); tim = make_ping_time ();
@@ -389,7 +388,7 @@ lag_check (void)
if (serv->connected && serv->end_of_motd) if (serv->connected && serv->end_of_motd)
{ {
lag = now - serv->ping_recv; lag = now - serv->ping_recv;
if (serv->lag_sent && prefs.hex_net_ping_timeout != 0 && lag > prefs.hex_net_ping_timeout && lag > 0) if (prefs.hex_net_ping_timeout != 0 && lag > prefs.hex_net_ping_timeout && lag > 0)
{ {
sprintf (tbuf, "%" G_GINT64_FORMAT, (gint64) lag); sprintf (tbuf, "%" G_GINT64_FORMAT, (gint64) lag);
EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL, EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL,
@@ -399,11 +398,11 @@ lag_check (void)
} }
else else
{ {
ping_age = now - serv->ping_recv; g_snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim);
if (!serv->lag_sent && prefs.hex_net_lag_check > 0 && ping_age >= prefs.hex_net_lag_check) serv->p_ping (serv, "", tbuf);
if (!serv->lag_sent)
{ {
g_snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim);
serv->p_ping (serv, "", tbuf);
serv->lag_sent = tim; serv->lag_sent = tim;
fe_set_lag (serv, -1); fe_set_lag (serv, -1);
} }
@@ -526,7 +525,7 @@ zoitechat_reinit_timers (void)
if ((prefs.hex_net_ping_timeout != 0 || prefs.hex_gui_lagometer) if ((prefs.hex_net_ping_timeout != 0 || prefs.hex_gui_lagometer)
&& lag_check_tag == 0) && lag_check_tag == 0)
{ {
lag_check_tag = fe_timeout_add_seconds (1, zoitechat_lag_check, NULL); lag_check_tag = fe_timeout_add_seconds (30, zoitechat_lag_check, NULL);
} }
else if ((!prefs.hex_net_ping_timeout && !prefs.hex_gui_lagometer) else if ((!prefs.hex_net_ping_timeout && !prefs.hex_gui_lagometer)
&& lag_check_tag != 0) && lag_check_tag != 0)
-9
View File
@@ -133,7 +133,6 @@ struct zoitechatprefs
unsigned int hex_gui_input_style; unsigned int hex_gui_input_style;
unsigned int hex_gui_join_dialog; unsigned int hex_gui_join_dialog;
unsigned int hex_gui_mode_buttons; unsigned int hex_gui_mode_buttons;
unsigned int hex_gui_mode_buttons_inline;
unsigned int hex_gui_quit_dialog; unsigned int hex_gui_quit_dialog;
/* unsigned int hex_gui_single; */ /* unsigned int hex_gui_single; */
unsigned int hex_gui_slist_fav; unsigned int hex_gui_slist_fav;
@@ -149,7 +148,6 @@ struct zoitechatprefs
unsigned int hex_gui_tab_sort; unsigned int hex_gui_tab_sort;
unsigned int hex_gui_tab_utils; unsigned int hex_gui_tab_utils;
unsigned int hex_gui_topicbar; unsigned int hex_gui_topicbar;
unsigned int hex_gui_topicbar_multiline;
unsigned int hex_gui_tray; unsigned int hex_gui_tray;
unsigned int hex_gui_tray_away; unsigned int hex_gui_tray_away;
unsigned int hex_gui_tray_blink; unsigned int hex_gui_tray_blink;
@@ -190,7 +188,6 @@ struct zoitechatprefs
unsigned int hex_irc_conf_mode; unsigned int hex_irc_conf_mode;
unsigned int hex_irc_hidehost; unsigned int hex_irc_hidehost;
unsigned int hex_irc_hide_nickchange; unsigned int hex_irc_hide_nickchange;
unsigned int hex_irc_hide_join_part_hostmask;
unsigned int hex_irc_hide_version; unsigned int hex_irc_hide_version;
unsigned int hex_irc_invisible; unsigned int hex_irc_invisible;
unsigned int hex_irc_logging; unsigned int hex_irc_logging;
@@ -268,9 +265,7 @@ struct zoitechatprefs
int hex_gui_search_pos; int hex_gui_search_pos;
int hex_gui_slist_select; int hex_gui_slist_select;
int hex_gui_tab_layout; int hex_gui_tab_layout;
int hex_gui_tab_closebuttons;
int hex_gui_tab_middleclose; int hex_gui_tab_middleclose;
int hex_gui_mouse_scroll_speed;
int hex_gui_tab_newtofront; int hex_gui_tab_newtofront;
int hex_gui_tab_pos; int hex_gui_tab_pos;
int hex_gui_tab_small; int hex_gui_tab_small;
@@ -293,10 +288,6 @@ struct zoitechatprefs
int hex_irc_join_delay; int hex_irc_join_delay;
int hex_irc_notice_pos; int hex_irc_notice_pos;
int hex_net_ping_timeout; int hex_net_ping_timeout;
int hex_net_lag_check;
int hex_net_keepalive_idle;
int hex_net_keepalive_interval;
int hex_net_keepalive_count;
int hex_net_proxy_port; int hex_net_proxy_port;
int hex_net_proxy_type; /* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */ int hex_net_proxy_type; /* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */
int hex_net_proxy_use; /* 0=all 1=IRC_ONLY 2=DCC_ONLY */ int hex_net_proxy_use; /* 0=all 1=IRC_ONLY 2=DCC_ONLY */
+1 -1
View File
@@ -452,7 +452,7 @@ void
fe_add_chan_list (server *serv, char *chan, char *users, char *topic) fe_add_chan_list (server *serv, char *chan, char *users, char *topic)
{ {
chanlistrow *next_row; chanlistrow *next_row;
size_t len = strlen (chan) + 1; int len = strlen (chan) + 1;
/* we allocate the struct and channel string in one go */ /* we allocate the struct and channel string in one go */
next_row = g_malloc (sizeof (chanlistrow) + len); next_row = g_malloc (sizeof (chanlistrow) + len);
+121 -174
View File
@@ -27,6 +27,8 @@ typedef struct
GtkWidget *b2; /* button2 */ GtkWidget *b2; /* button2 */
} tabview; } tabview;
#define ICON_CHANVIEW_CLOSE "gtk-close"
static void chanview_populate (chanview *cv); static void chanview_populate (chanview *cv);
/* ignore "toggled" signal? */ /* ignore "toggled" signal? */
@@ -61,19 +63,28 @@ static tab_scroll_animation *tab_right_animation;
*/ */
static inline gint static inline gint
cv_tabs_get_viewport_size (GtkAdjustment *adj) cv_tabs_get_viewport_size (GdkWindow *parent_win, gboolean vertical)
{ {
return (gint) gtk_adjustment_get_page_size (adj); gint viewport_size = 0;
if (vertical)
viewport_size = gdk_window_get_height (parent_win);
else
viewport_size = gdk_window_get_width (parent_win);
return viewport_size;
} }
static void static void
cv_tabs_sizealloc (GtkWidget *widget, GtkAllocation *allocation, chanview *cv) cv_tabs_sizealloc (GtkWidget *widget, GtkAllocation *allocation, chanview *cv)
{ {
GdkWindow *parent_win;
GtkAdjustment *adj; GtkAdjustment *adj;
GtkWidget *inner; GtkWidget *inner;
gint viewport_size; gint viewport_size;
inner = ((tabview *)cv)->inner; inner = ((tabview *)cv)->inner;
parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner));
if (cv->vertical) if (cv->vertical)
{ {
@@ -83,20 +94,16 @@ cv_tabs_sizealloc (GtkWidget *widget, GtkAllocation *allocation, chanview *cv)
adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent (inner))); adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent (inner)));
} }
viewport_size = cv_tabs_get_viewport_size (adj); viewport_size = cv_tabs_get_viewport_size (parent_win, cv->vertical);
if (gtk_adjustment_get_upper (adj) <= viewport_size) if (gtk_adjustment_get_upper (adj) <= viewport_size)
{ {
if (((tabview *)cv)->b1) gtk_widget_hide (((tabview *)cv)->b1);
gtk_widget_hide (((tabview *)cv)->b1); gtk_widget_hide (((tabview *)cv)->b2);
if (((tabview *)cv)->b2)
gtk_widget_hide (((tabview *)cv)->b2);
} else } else
{ {
if (((tabview *)cv)->b1) gtk_widget_show (((tabview *)cv)->b1);
gtk_widget_show (((tabview *)cv)->b1); gtk_widget_show (((tabview *)cv)->b2);
if (((tabview *)cv)->b2)
gtk_widget_show (((tabview *)cv)->b2);
} }
} }
@@ -236,8 +243,10 @@ tab_scroll_left_up_clicked (GtkWidget *widget, chanview *cv)
gint viewport_size; gint viewport_size;
gfloat new_value; gfloat new_value;
GtkWidget *inner; GtkWidget *inner;
GdkWindow *parent_win;
inner = ((tabview *)cv)->inner; inner = ((tabview *)cv)->inner;
parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner));
if (cv->vertical) if (cv->vertical)
{ {
@@ -247,7 +256,7 @@ tab_scroll_left_up_clicked (GtkWidget *widget, chanview *cv)
adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent(inner))); adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent(inner)));
} }
viewport_size = cv_tabs_get_viewport_size (adj); viewport_size = cv_tabs_get_viewport_size (parent_win, cv->vertical);
new_value = tab_search_offset (inner, gtk_adjustment_get_value (adj), 0, cv->vertical); new_value = tab_search_offset (inner, gtk_adjustment_get_value (adj), 0, cv->vertical);
@@ -272,8 +281,10 @@ tab_scroll_right_down_clicked (GtkWidget *widget, chanview *cv)
gint viewport_size; gint viewport_size;
gfloat new_value; gfloat new_value;
GtkWidget *inner; GtkWidget *inner;
GdkWindow *parent_win;
inner = ((tabview *)cv)->inner; inner = ((tabview *)cv)->inner;
parent_win = gtk_widget_get_window (gtk_widget_get_parent (inner));
if (cv->vertical) if (cv->vertical)
{ {
@@ -283,7 +294,7 @@ tab_scroll_right_down_clicked (GtkWidget *widget, chanview *cv)
adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent(inner))); adj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (gtk_widget_get_parent(inner)));
} }
viewport_size = cv_tabs_get_viewport_size (adj); viewport_size = cv_tabs_get_viewport_size (parent_win, cv->vertical);
new_value = tab_search_offset (inner, gtk_adjustment_get_value (adj), 1, cv->vertical); new_value = tab_search_offset (inner, gtk_adjustment_get_value (adj), 1, cv->vertical);
@@ -304,44 +315,76 @@ tab_scroll_right_down_clicked (GtkWidget *widget, chanview *cv)
static gboolean static gboolean
tab_scroll_cb (GtkWidget *widget, GdkEventScroll *event, gpointer cv) tab_scroll_cb (GtkWidget *widget, GdkEventScroll *event, gpointer cv)
{ {
int direction = cv_scroll_direction (event);
int i;
if (prefs.hex_gui_tab_scrollchans) if (prefs.hex_gui_tab_scrollchans)
{ {
if (direction != 0) if (event->direction == GDK_SCROLL_DOWN)
{ mg_switch_page (1, 1);
for (i = 0; i < cv_scroll_step_count (); i++) else if (event->direction == GDK_SCROLL_UP)
mg_switch_page (1, direction); mg_switch_page (1, -1);
return TRUE;
}
} }
else else
{ {
if (direction < 0) /* mouse wheel scrolling */
{ if (event->direction == GDK_SCROLL_UP)
for (i = 0; i < cv_scroll_step_count (); i++) tab_scroll_left_up_clicked (widget, cv);
tab_scroll_left_up_clicked (widget, cv); else if (event->direction == GDK_SCROLL_DOWN)
return TRUE; tab_scroll_right_down_clicked (widget, cv);
}
else if (direction > 0)
{
for (i = 0; i < cv_scroll_step_count (); i++)
tab_scroll_right_down_clicked (widget, cv);
return TRUE;
}
} }
return FALSE; return FALSE;
} }
static void
cv_tabs_xclick_cb (GtkWidget *button, chanview *cv)
{
cv->cb_xbutton (cv, cv->focused, cv->focused->tag, cv->focused->userdata);
}
/* make a Scroll (arrow) button */
static GtkWidget *
make_sbutton (GtkArrowType type, void *click_cb, void *userdata)
{
GtkWidget *button, *arrow;
const char *icon_name = "pan-end-symbolic";
button = gtk_button_new ();
switch (type)
{
case GTK_ARROW_UP:
icon_name = "pan-up-symbolic";
break;
case GTK_ARROW_DOWN:
icon_name = "pan-down-symbolic";
break;
case GTK_ARROW_LEFT:
icon_name = "pan-start-symbolic";
break;
case GTK_ARROW_RIGHT:
default:
icon_name = "pan-end-symbolic";
break;
}
arrow = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER (button), arrow);
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (click_cb), userdata);
g_signal_connect (G_OBJECT (button), "scroll-event",
G_CALLBACK (tab_scroll_cb), userdata);
gtk_widget_show (arrow);
return button;
}
static void static void
cv_tabs_init (chanview *cv) cv_tabs_init (chanview *cv)
{ {
GtkWidget *box; GtkWidget *box, *hbox = NULL;
GtkWidget *viewport; GtkWidget *viewport;
GtkWidget *outer; GtkWidget *outer;
GtkWidget *tree; GtkWidget *button;
if (cv->vertical) if (cv->vertical)
{ {
@@ -356,19 +399,12 @@ cv_tabs_init (chanview *cv)
G_CALLBACK (cv_tabs_sizealloc), cv); G_CALLBACK (cv_tabs_sizealloc), cv);
gtk_widget_show (outer); gtk_widget_show (outer);
viewport = gtk_scrolled_window_new (0, 0); viewport = gtk_viewport_new (0, 0);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (viewport), GTK_SHADOW_NONE); gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
if (cv->vertical) if (cv->vertical)
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (viewport), gtk_widget_set_size_request (viewport, -1, 1);
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
else else
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (viewport), gtk_widget_set_size_request (viewport, 1, -1);
GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (viewport), 1);
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (viewport), 1);
gtk_widget_set_hexpand (viewport, TRUE);
gtk_widget_set_vexpand (viewport, TRUE);
cv_add_scroll_events (viewport);
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);
@@ -386,10 +422,39 @@ cv_tabs_init (chanview *cv)
gtk_container_add (GTK_CONTAINER (viewport), box); gtk_container_add (GTK_CONTAINER (viewport), box);
gtk_widget_show (box); gtk_widget_show (box);
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (cv->store)); /* if vertical, the buttons can be side by side */
gtk_widget_set_name (tree, "zoitechat-tree"); if (cv->vertical)
gtk_widget_set_no_show_all (tree, TRUE); {
gtk_box_pack_start (GTK_BOX (outer), tree, 0, 0, 0); hbox = gtkutil_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);
gtk_box_pack_start (GTK_BOX (outer), hbox, 0, 0, 0);
gtk_widget_show (hbox);
}
/* make the Scroll buttons */
((tabview *)cv)->b2 = make_sbutton (cv->vertical ?
GTK_ARROW_UP : GTK_ARROW_LEFT,
tab_scroll_left_up_clicked,
cv);
((tabview *)cv)->b1 = make_sbutton (cv->vertical ?
GTK_ARROW_DOWN : GTK_ARROW_RIGHT,
tab_scroll_right_down_clicked,
cv);
if (hbox)
{
gtk_container_add (GTK_CONTAINER (hbox), ((tabview *)cv)->b2);
gtk_container_add (GTK_CONTAINER (hbox), ((tabview *)cv)->b1);
} else
{
gtk_box_pack_start (GTK_BOX (outer), ((tabview *)cv)->b2, 0, 0, 0);
gtk_box_pack_start (GTK_BOX (outer), ((tabview *)cv)->b1, 0, 0, 0);
}
button = gtkutil_button (outer, ICON_CHANVIEW_CLOSE, NULL, cv_tabs_xclick_cb,
cv, 0);
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
gtk_widget_set_can_focus (button, FALSE);
gtk_container_add (GTK_CONTAINER (cv->box), outer); gtk_container_add (GTK_CONTAINER (cv->box), outer);
} }
@@ -594,135 +659,20 @@ tab_toggled_cb (GtkToggleButton *tab, chan *ch)
static gboolean static gboolean
tab_click_cb (GtkWidget *wid, GdkEventButton *event, chan *ch) tab_click_cb (GtkWidget *wid, GdkEventButton *event, chan *ch)
{ {
GtkWidget *close_button;
gint close_x;
gint close_y;
GtkAllocation close_alloc;
if (event->button == 1 && event->type == GDK_BUTTON_PRESS)
{
close_button = g_object_get_data (G_OBJECT (wid), "tab-close-button");
if (prefs.hex_gui_tab_closebuttons && close_button &&
gtk_widget_translate_coordinates (close_button, wid, 0, 0, &close_x, &close_y))
{
gtk_widget_get_allocation (close_button, &close_alloc);
if (event->x >= close_x && event->x < close_x + close_alloc.width &&
event->y >= close_y && event->y < close_y + close_alloc.height)
{
ch->cv->cb_xbutton (ch->cv, ch, ch->tag, ch->userdata);
return TRUE;
}
}
}
return ch->cv->cb_contextmenu (ch->cv, ch, ch->tag, ch->userdata, event); return ch->cv->cb_contextmenu (ch->cv, ch, ch->tag, ch->userdata, event);
} }
static gboolean
tab_close_motion_cb (GtkWidget *wid, GdkEventMotion *event, chan *ch)
{
GtkWidget *close_button;
gint close_x;
gint close_y;
GtkAllocation close_alloc;
gboolean hover = FALSE;
close_button = g_object_get_data (G_OBJECT (wid), "tab-close-button");
if (prefs.hex_gui_tab_closebuttons && close_button &&
gtk_widget_translate_coordinates (close_button, wid, 0, 0, &close_x, &close_y))
{
gtk_widget_get_allocation (close_button, &close_alloc);
hover = event->x >= close_x && event->x < close_x + close_alloc.width &&
event->y >= close_y && event->y < close_y + close_alloc.height;
}
if (hover)
{
GdkCursor *cursor;
gtk_widget_set_state_flags (close_button, GTK_STATE_FLAG_PRELIGHT, TRUE);
if (gtk_widget_get_window (wid))
{
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (wid), GDK_HAND2);
gdk_window_set_cursor (gtk_widget_get_window (wid), cursor);
g_object_unref (cursor);
}
}
else
{
gtk_widget_unset_state_flags (close_button, GTK_STATE_FLAG_PRELIGHT);
if (gtk_widget_get_window (wid))
gdk_window_set_cursor (gtk_widget_get_window (wid), NULL);
}
return FALSE;
}
static gboolean
tab_close_leave_cb (GtkWidget *wid, GdkEventCrossing *event, chan *ch)
{
GtkWidget *close_button;
close_button = g_object_get_data (G_OBJECT (wid), "tab-close-button");
if (prefs.hex_gui_tab_closebuttons && close_button)
gtk_widget_unset_state_flags (close_button, GTK_STATE_FLAG_PRELIGHT);
if (gtk_widget_get_window (wid))
gdk_window_set_cursor (gtk_widget_get_window (wid), NULL);
return FALSE;
}
static GtkWidget *
tab_get_label (GtkWidget *tab)
{
GtkWidget *label;
label = g_object_get_data (G_OBJECT (tab), "tab-label");
if (label)
return label;
return gtk_bin_get_child (GTK_BIN (tab));
}
static void * static void *
cv_tabs_add (chanview *cv, chan *ch, char *name, GtkTreeIter *parent) cv_tabs_add (chanview *cv, chan *ch, char *name, GtkTreeIter *parent)
{ {
GtkWidget *but; GtkWidget *but;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *close_button;
GtkWidget *close_icon;
but = gtk_toggle_button_new (); but = gtk_toggle_button_new_with_label (name);
gtk_widget_set_name (but, "zoitechat-tab"); gtk_widget_set_name (but, "zoitechat-tab");
gtk_widget_set_size_request (but, -1, 14);
gtk_widget_add_events (but, GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK);
cv_add_scroll_events (but);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
label = gtk_label_new (name);
close_button = gtk_button_new ();
cv_add_scroll_events (close_button);
gtk_style_context_add_class (gtk_widget_get_style_context (close_button), "flat");
close_icon = gtk_image_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_MENU);
gtk_image_set_pixel_size (GTK_IMAGE (close_icon), 8);
gtk_button_set_always_show_image (GTK_BUTTON (close_button), TRUE);
gtk_widget_set_can_focus (close_button, FALSE);
gtk_container_add (GTK_CONTAINER (close_button), close_icon);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (but), hbox);
g_object_set_data (G_OBJECT (but), "tab-label", label);
g_object_set_data (G_OBJECT (but), "tab-close-button", close_button);
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);
g_signal_connect (G_OBJECT (but), "scroll-event",
G_CALLBACK (tab_scroll_cb), cv);
g_signal_connect (G_OBJECT (close_button), "scroll-event",
G_CALLBACK (tab_scroll_cb), cv);
g_signal_connect (G_OBJECT (but), "motion-notify-event",
G_CALLBACK (tab_close_motion_cb), ch);
g_signal_connect (G_OBJECT (but), "leave-notify-event",
G_CALLBACK (tab_close_leave_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);
@@ -734,9 +684,6 @@ cv_tabs_add (chanview *cv, chan *ch, char *name, GtkTreeIter *parent)
g_signal_connect (G_OBJECT (but), "toggled", g_signal_connect (G_OBJECT (but), "toggled",
G_CALLBACK (tab_toggled_cb), ch); G_CALLBACK (tab_toggled_cb), ch);
g_object_set_data (G_OBJECT (but), "u", ch->userdata); g_object_set_data (G_OBJECT (but), "u", ch->userdata);
gtk_widget_show_all (hbox);
if (!prefs.hex_gui_tab_closebuttons)
gtk_widget_hide (close_button);
tab_add_real (cv, but, ch); tab_add_real (cv, but, ch);
@@ -945,7 +892,7 @@ cv_tabs_cleanup (chanview *cv)
static void static void
cv_tabs_set_color (chan *ch, PangoAttrList *list) cv_tabs_set_color (chan *ch, PangoAttrList *list)
{ {
gtk_label_set_attributes (GTK_LABEL (tab_get_label (ch->impl)), list); gtk_label_set_attributes (GTK_LABEL (gtk_bin_get_child (GTK_BIN (ch->impl))), list);
} }
static void static void
@@ -954,16 +901,16 @@ cv_tabs_rename (chan *ch, char *name)
PangoAttrList *attr; PangoAttrList *attr;
GtkWidget *tab = ch->impl; GtkWidget *tab = ch->impl;
attr = gtk_label_get_attributes (GTK_LABEL (tab_get_label (tab))); attr = gtk_label_get_attributes (GTK_LABEL (gtk_bin_get_child (GTK_BIN (tab))));
if (attr) if (attr)
pango_attr_list_ref (attr); pango_attr_list_ref (attr);
gtk_label_set_text (GTK_LABEL (tab_get_label (tab)), name); gtk_button_set_label (GTK_BUTTON (tab), name);
gtk_widget_queue_resize (gtk_widget_get_parent(gtk_widget_get_parent(gtk_widget_get_parent(tab)))); gtk_widget_queue_resize (gtk_widget_get_parent(gtk_widget_get_parent(gtk_widget_get_parent(tab))));
if (attr) if (attr)
{ {
gtk_label_set_attributes (GTK_LABEL (tab_get_label (tab)), attr); gtk_label_set_attributes (GTK_LABEL (gtk_bin_get_child (GTK_BIN (tab))), attr);
pango_attr_list_unref (attr); pango_attr_list_unref (attr);
} }
} }
+5 -25
View File
@@ -45,8 +45,6 @@ cv_tree_sel_cb (GtkTreeSelection *sel, chanview *cv)
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter prev_iter; GtkTreeIter prev_iter;
GtkTreeIter iter; GtkTreeIter iter;
GtkTreePath *path;
GtkTreeView *view;
chan *ch; chan *ch;
chan *prev_ch; chan *prev_ch;
gboolean has_prev; gboolean has_prev;
@@ -62,20 +60,6 @@ cv_tree_sel_cb (GtkTreeSelection *sel, chanview *cv)
if (has_prev) if (has_prev)
{ {
gtk_tree_model_get (model, &prev_iter, COL_CHAN, &prev_ch, -1); gtk_tree_model_get (model, &prev_iter, COL_CHAN, &prev_ch, -1);
if (prev_ch != ch && gtk_tree_store_is_ancestor (cv->store, &iter, &prev_iter))
{
view = gtk_tree_selection_get_tree_view (sel);
path = gtk_tree_model_get_path (model, &iter);
if (path)
{
if (!gtk_tree_view_row_expanded (view, path))
{
gtk_tree_path_free (path);
return;
}
gtk_tree_path_free (path);
}
}
if (prev_ch != ch) if (prev_ch != ch)
gtk_tree_store_set (cv->store, &prev_iter, COL_UNDERLINE, PANGO_UNDERLINE_NONE, -1); gtk_tree_store_set (cv->store, &prev_iter, COL_UNDERLINE, PANGO_UNDERLINE_NONE, -1);
} }
@@ -111,14 +95,12 @@ cv_tree_scroll_event_cb (GtkWidget *widget, GdkEventScroll *event, gpointer user
{ {
if (prefs.hex_gui_tab_scrollchans) if (prefs.hex_gui_tab_scrollchans)
{ {
int direction = cv_scroll_direction (event); if (event->direction == GDK_SCROLL_DOWN)
int i; mg_switch_page (1, 1);
else if (event->direction == GDK_SCROLL_UP)
mg_switch_page (1, -1);
if (direction != 0) return TRUE;
for (i = 0; i < cv_scroll_step_count (); i++)
mg_switch_page (1, direction);
return direction != 0;
} }
return FALSE; return FALSE;
@@ -143,7 +125,6 @@ cv_tree_init (chanview *cv)
win = gtk_scrolled_window_new (0, 0); win = gtk_scrolled_window_new (0, 0);
gtk_widget_set_hexpand (win, TRUE); gtk_widget_set_hexpand (win, TRUE);
gtk_widget_set_vexpand (win, TRUE); gtk_widget_set_vexpand (win, TRUE);
cv_add_scroll_events (win);
/*gtk_container_set_border_width (GTK_CONTAINER (win), 1);*/ /*gtk_container_set_border_width (GTK_CONTAINER (win), 1);*/
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (win), gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (win),
@@ -157,7 +138,6 @@ cv_tree_init (chanview *cv)
view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (cv->store)); view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (cv->store));
gtk_widget_set_hexpand (view, TRUE); gtk_widget_set_hexpand (view, TRUE);
gtk_widget_set_vexpand (view, TRUE); gtk_widget_set_vexpand (view, TRUE);
cv_add_scroll_events (view);
gtk_widget_set_name (view, "zoitechat-tree"); gtk_widget_set_name (view, "zoitechat-tree");
{ {
ThemeWidgetStyleValues style_values; ThemeWidgetStyleValues style_values;
-40
View File
@@ -95,46 +95,6 @@ static chan *cv_find_chan_by_number (chanview *cv, int num);
static int cv_find_number_of_chan (chanview *cv, chan *find_ch); static int cv_find_number_of_chan (chanview *cv, chan *find_ch);
static void cv_find_neighbors_for_removal (chanview *cv, chan *find_ch, chan **left_ch, chan **first_ch); static void cv_find_neighbors_for_removal (chanview *cv, chan *find_ch, chan **left_ch, chan **first_ch);
static void
cv_add_scroll_events (GtkWidget *widget)
{
gtk_widget_add_events (widget, GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK);
}
static int
cv_scroll_direction (GdkEventScroll *event)
{
gdouble dx;
gdouble dy;
if (event->direction == GDK_SCROLL_SMOOTH && gdk_event_get_scroll_deltas ((GdkEvent *) event, &dx, &dy))
{
if (dy > 0)
return 1;
if (dy < 0)
return -1;
}
switch (event->direction)
{
case GDK_SCROLL_DOWN:
return 1;
case GDK_SCROLL_UP:
return -1;
default:
return 0;
}
}
static int
cv_scroll_step_count (void)
{
int speed = prefs.hex_gui_mouse_scroll_speed;
if (speed < 1)
speed = 1;
return (speed + 9) / 10;
}
/* ======= TABS ======= */ /* ======= TABS ======= */
+35 -73
View File
@@ -124,25 +124,6 @@ create_msg_dialog (gchar *title, gchar *message)
static char *win32_argv0_dir; static char *win32_argv0_dir;
static void
win32_set_appusermodelid (void)
{
HMODULE shell32;
HRESULT (WINAPI *set_appid) (PCWSTR);
shell32 = GetModuleHandleW (L"shell32.dll");
if (!shell32)
shell32 = LoadLibraryW (L"shell32.dll");
if (!shell32)
return;
set_appid = (HRESULT (WINAPI *) (PCWSTR)) GetProcAddress (shell32, "SetCurrentProcessExplicitAppUserModelID");
if (!set_appid)
return;
set_appid (L"ZoiteChat.Desktop.Notify");
}
static void static void
win32_set_gsettings_schema_dir (void) win32_set_gsettings_schema_dir (void)
{ {
@@ -441,7 +422,6 @@ fe_args (int argc, char *argv[])
#ifdef WIN32 #ifdef WIN32
win32_set_gsettings_schema_dir (); win32_set_gsettings_schema_dir ();
win32_set_appusermodelid ();
win32_configure_pixbuf_loaders (); win32_configure_pixbuf_loaders ();
/* this is mainly for irc:// URL handling. When windows calls us from */ /* this is mainly for irc:// URL handling. When windows calls us from */
@@ -812,19 +792,18 @@ fe_set_topic (session *sess, char *topic, char *stripped_topic)
{ {
if (!sess->gui->is_tab || sess == current_tab) if (!sess->gui->is_tab || sess == current_tab)
{ {
GtkTextBuffer *topic_buffer;
GtkTextIter start;
topic_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (sess->gui->topic_entry));
if (prefs.hex_text_stripcolor_topic) if (prefs.hex_text_stripcolor_topic)
gtk_text_buffer_set_text (topic_buffer, stripped_topic, -1); {
gtk_text_buffer_set_text (
gtk_text_view_get_buffer (GTK_TEXT_VIEW (sess->gui->topic_entry)),
stripped_topic, -1);
}
else else
gtk_text_buffer_set_text (topic_buffer, topic, -1); {
gtk_text_buffer_set_text (
gtk_text_buffer_get_start_iter (topic_buffer, &start); gtk_text_view_get_buffer (GTK_TEXT_VIEW (sess->gui->topic_entry)),
gtk_text_buffer_place_cursor (topic_buffer, &start); topic, -1);
gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (sess->gui->topic_entry), }
&start, 0.0, FALSE, 0.0, 0.0);
mg_set_topic_tip (sess); mg_set_topic_tip (sess);
} }
else else
@@ -1329,38 +1308,17 @@ maybe_escape_uri (const char *uri)
return g_strdup (uri); return g_strdup (uri);
} }
#ifndef WIN32
static gchar **
fe_open_url_env_sanitized (void)
{
gchar **env = g_get_environ ();
const char *vars[] = {"LD_LIBRARY_PATH", "LD_PRELOAD", "APPDIR", "APPIMAGE", "ARGV0", NULL};
int i;
for (i = 0; vars[i]; i++)
{
gchar **tmp_env = env;
env = g_environ_unsetenv (tmp_env, vars[i]);
if (env != tmp_env)
g_strfreev (tmp_env);
}
return env;
}
#endif
static void static void
fe_open_url_inner (const char *url) fe_open_url_inner (const char *url)
{ {
GError *error = NULL; GError *error = NULL;
char *escaped_url = maybe_escape_uri (url); char *escaped_url = maybe_escape_uri (url);
gboolean opened = FALSE; gboolean opened = g_app_info_launch_default_for_uri (escaped_url, NULL, &error);
#ifdef WIN32
opened = g_app_info_launch_default_for_uri (escaped_url, NULL, &error);
if (!opened) if (!opened)
{ {
g_clear_error (&error); g_clear_error (&error);
#ifdef WIN32
gunichar2 *url_utf16 = g_utf8_to_utf16 (escaped_url, -1, NULL, NULL, NULL); gunichar2 *url_utf16 = g_utf8_to_utf16 (escaped_url, -1, NULL, NULL, NULL);
if (url_utf16 != NULL) if (url_utf16 != NULL)
@@ -1368,11 +1326,22 @@ fe_open_url_inner (const char *url)
opened = ((INT_PTR) ShellExecuteW (0, L"open", url_utf16, NULL, NULL, SW_SHOWNORMAL)) > 32; opened = ((INT_PTR) ShellExecuteW (0, L"open", url_utf16, NULL, NULL, SW_SHOWNORMAL)) > 32;
g_free (url_utf16); g_free (url_utf16);
} }
}
#else #else
{
gchar *xdg_open_argv[] = {(gchar *) "xdg-open", escaped_url, NULL}; gchar *xdg_open_argv[] = {(gchar *) "xdg-open", escaped_url, NULL};
gchar **spawn_env = fe_open_url_env_sanitized (); gchar **spawn_env = NULL;
spawn_env = g_get_environ ();
{
gchar **tmp_env = spawn_env;
spawn_env = g_environ_unsetenv (tmp_env, "LD_LIBRARY_PATH");
if (spawn_env != tmp_env)
g_strfreev (tmp_env);
tmp_env = spawn_env;
spawn_env = g_environ_unsetenv (tmp_env, "LD_PRELOAD");
if (spawn_env != tmp_env)
g_strfreev (tmp_env);
}
if (g_spawn_async (NULL, xdg_open_argv, spawn_env, if (g_spawn_async (NULL, xdg_open_argv, spawn_env,
G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
@@ -1385,25 +1354,18 @@ fe_open_url_inner (const char *url)
g_clear_error (&error); g_clear_error (&error);
} }
g_strfreev (spawn_env); if (!opened && gtk_show_uri_on_window (NULL, escaped_url, GDK_CURRENT_TIME, &error))
} {
opened = TRUE;
if (!opened) }
{ else if (!opened)
opened = g_app_info_launch_default_for_uri (escaped_url, NULL, &error); {
if (!opened)
g_clear_error (&error); g_clear_error (&error);
} }
if (!opened && gtk_show_uri_on_window (NULL, escaped_url, GDK_CURRENT_TIME, &error)) g_strfreev (spawn_env);
{
opened = TRUE;
}
else if (!opened)
{
g_clear_error (&error);
}
#endif #endif
}
if (!opened) if (!opened)
{ {
+62 -431
View File
@@ -60,7 +60,6 @@
#define ICON_FKEYS_DELETE "edit-delete" #define ICON_FKEYS_DELETE "edit-delete"
#define ICON_FKEYS_CANCEL "dialog-cancel" #define ICON_FKEYS_CANCEL "dialog-cancel"
#define ICON_FKEYS_SAVE "document-save" #define ICON_FKEYS_SAVE "document-save"
#define ICON_FKEYS_RESET "edit-undo"
static void replace_handle (GtkWidget * wid); static void replace_handle (GtkWidget * wid);
void key_check_replace_on_change (GtkEditable *editable, gpointer data); void key_check_replace_on_change (GtkEditable *editable, gpointer data);
@@ -81,7 +80,7 @@ void key_action_tab_clean (void);
*/ */
/* Remember that the *number* of actions is this *plus* 1 --AGL */ /* Remember that the *number* of actions is this *plus* 1 --AGL */
#define KEY_MAX_ACTIONS 16 #define KEY_MAX_ACTIONS 14
struct key_binding struct key_binding
{ {
@@ -106,10 +105,7 @@ struct gcomp_data
}; };
static int key_load_kbs (void); static int key_load_kbs (void);
static int key_load_kbs_from_buffer (char *ibuf, off_t size, GSList **out_list);
static int key_save_kbs (void); static int key_save_kbs (void);
static void key_dialog_load (GtkListStore *store);
static void key_dialog_reset (GtkWidget *wid, gpointer userdata);
static int key_action_handle_command (GtkWidget * wid, GdkEventKey * evt, static int key_action_handle_command (GtkWidget * wid, GdkEventKey * evt,
char *d1, char *d2, char *d1, char *d2,
struct session *sess); struct session *sess);
@@ -146,13 +142,6 @@ static int key_action_move_tab_family_right (GtkWidget * wid, GdkEventKey * evt,
static int key_action_put_history (GtkWidget * wid, GdkEventKey * evt, static int key_action_put_history (GtkWidget * wid, GdkEventKey * evt,
char *d1, char *d2, char *d1, char *d2,
struct session *sess); struct session *sess);
static int key_action_menu_shortcut (GtkWidget * wid, GdkEventKey * evt,
char *d1, char *d2,
struct session *sess);
static int key_action_reopen_closed_tab (GtkWidget * wid, GdkEventKey * evt,
char *d1, char *d2,
struct session *sess);
static GSList *keybind_list = NULL; static GSList *keybind_list = NULL;
@@ -271,7 +260,7 @@ static const struct key_action key_actions[KEY_MAX_ACTIONS + 1] = {
{key_action_handle_command, "Run Command", {key_action_handle_command, "Run Command",
N_("The \002Run Command\002 action runs the data in Data 1 as if it had been typed into the entry box where you pressed the key sequence. Thus it can contain text (which will be sent to the channel/person), commands or user commands. Escapes in Data 1 are interpreted (for example \002\\n\002, \002\\r\002, \002\\t\002, \002\\xNN\002 and \002\\\\\002), so it is possible to run more than one command by using newlines.")}, N_("The \002Run Command\002 action runs the data in Data 1 as if it had been typed into the entry box where you pressed the key sequence. Thus it can contain text (which will be sent to the channel/person), commands or user commands. Escapes in Data 1 are interpreted (for example \002\\n\002, \002\\r\002, \002\\t\002, \002\\xNN\002 and \002\\\\\002), so it is possible to run more than one command by using newlines.")},
{key_action_page_switch, "Change Page", {key_action_page_switch, "Change Page",
N_("The \002Change Page\002 command switches between pages in the notebook. Set Data 1 to the page number, channel name, network/channel, or auto. If Data 2 is set to anything then numeric switches are relative to the current position. Auto switches to the page with the most recent and important activity (queries first, then channels with hilight, channels with dialogue, channels with other data)")}, N_("The \002Change Page\002 command switches between pages in the notebook. Set Data 1 to the page you want to switch to. If Data 2 is set to anything then the switch will be relative to the current position. Set Data 1 to auto to switch to the page with the most recent and important activity (queries first, then channels with hilight, channels with dialogue, channels with other data)")},
{key_action_insert, "Insert in Buffer", {key_action_insert, "Insert in Buffer",
N_("The \002Insert in Buffer\002 command will insert the contents of Data 1 into the entry where the key sequence was pressed at the current cursor position. Escapes in Data 1 are interpreted (for example \002\\n\002, \002\\r\002, \002\\t\002, \002\\xNN\002 and \002\\\\\002).")}, N_("The \002Insert in Buffer\002 command will insert the contents of Data 1 into the entry where the key sequence was pressed at the current cursor position. Escapes in Data 1 are interpreted (for example \002\\n\002, \002\\r\002, \002\\t\002, \002\\xNN\002 and \002\\\\\002).")},
{key_action_scroll_page, "Scroll Page", {key_action_scroll_page, "Scroll Page",
@@ -298,10 +287,6 @@ static const struct key_action key_actions[KEY_MAX_ACTIONS + 1] = {
N_("This command moves the current tab family to the right")}, N_("This command moves the current tab family to the right")},
{key_action_put_history, "Push input line into history", {key_action_put_history, "Push input line into history",
N_("Push input line into history but doesn't send to server")}, N_("Push input line into history but doesn't send to server")},
{key_action_menu_shortcut, "Menu Shortcut",
N_("Runs one of the built-in menu shortcuts. Set Data 1 to: network-list, new-server-tab, new-server-window, close, quit, menu-toggle, user-list-toggle, fullscreen-toggle, away-toggle, reset-marker, move-marker, copy-selection, search-text, search-next, search-previous or contents.")},
{key_action_reopen_closed_tab, "Reopen Closed Tab",
N_("Reopens the most recently closed channel tab")},
}; };
#define default_kb_cfg \ #define default_kb_cfg \
@@ -344,86 +329,7 @@ static const struct key_action key_actions[KEY_MAX_ACTIONS + 1] = {
"ACCEL=<Alt>Right\nMove front tab right\nD1!\nD2!\n\n"\ "ACCEL=<Alt>Right\nMove front tab right\nD1!\nD2!\n\n"\
"ACCEL=<Primary><Shift>Page_Up\nMove tab family left\nD1!\nD2!\n\n"\ "ACCEL=<Primary><Shift>Page_Up\nMove tab family left\nD1!\nD2!\n\n"\
"ACCEL=<Primary><Shift>Page_Down\nMove tab family right\nD1!\nD2!\n\n"\ "ACCEL=<Primary><Shift>Page_Down\nMove tab family right\nD1!\nD2!\n\n"\
"ACCEL=<Primary>s\nMenu Shortcut\nD1:network-list\nD2!\n\n"\ "ACCEL=F9\nRun Command\nD1:/GUI MENU TOGGLE\nD2!\n\n"
"ACCEL=<Primary>t\nMenu Shortcut\nD1:new-server-tab\nD2!\n\n"\
"ACCEL=<Primary>n\nMenu Shortcut\nD1:new-server-window\nD2!\n\n"\
"ACCEL=<Primary>w\nMenu Shortcut\nD1:close\nD2!\n\n"\
"ACCEL=<Primary>q\nMenu Shortcut\nD1:quit\nD2!\n\n"\
"ACCEL=<Primary>F9\nMenu Shortcut\nD1:menu-toggle\nD2!\n\n"\
"ACCEL=F7\nMenu Shortcut\nD1:user-list-toggle\nD2!\n\n"\
"ACCEL=F11\nMenu Shortcut\nD1:fullscreen-toggle\nD2!\n\n"\
"ACCEL=<Alt>a\nMenu Shortcut\nD1:away-toggle\nD2!\n\n"\
"ACCEL=<Primary>m\nMenu Shortcut\nD1:reset-marker\nD2!\n\n"\
"ACCEL=<Primary><Shift>M\nMenu Shortcut\nD1:move-marker\nD2!\n\n"\
"ACCEL=<Primary><Shift>C\nMenu Shortcut\nD1:copy-selection\nD2!\n\n"\
"ACCEL=<Primary>f\nMenu Shortcut\nD1:search-text\nD2!\n\n"\
"ACCEL=<Primary>g\nMenu Shortcut\nD1:search-next\nD2!\n\n"\
"ACCEL=<Primary><Shift>G\nMenu Shortcut\nD1:search-previous\nD2!\n\n"\
"ACCEL=F1\nMenu Shortcut\nD1:contents\nD2!\n\n"\
"ACCEL=<Primary><Shift>T\nReopen Closed Tab\nD1!\nD2!\n\n"
static gboolean
key_builtin_data_match (char *line, char *data)
{
if (line[2] == '!')
return data == NULL || data[0] == 0;
if (line[2] == ':')
return !strcmp (&line[3], data ? data : "");
return FALSE;
}
static gboolean
key_binding_is_builtin (struct key_binding *kb)
{
char *buf, *ibuf;
char *action;
int pnt = 0;
int state = 0;
gboolean match = FALSE;
gboolean d1_match = FALSE;
off_t size;
if (kb->action < 0 || kb->action > KEY_MAX_ACTIONS)
return FALSE;
action = key_actions[kb->action].name;
ibuf = g_strdup (default_kb_cfg);
size = strlen (default_kb_cfg);
while (buf_get_line (ibuf, &buf, &pnt, size))
{
if (strlen (buf) == 0)
continue;
switch (state)
{
case 0:
state = 1;
break;
case 1:
match = !strcmp (buf, action);
state = 2;
break;
case 2:
d1_match = match && key_builtin_data_match (buf, kb->data1);
state = 3;
break;
case 3:
if (d1_match && key_builtin_data_match (buf, kb->data2))
{
g_free (ibuf);
return TRUE;
}
state = 0;
break;
}
}
g_free (ibuf);
return FALSE;
}
void void
key_init () key_init ()
@@ -537,6 +443,7 @@ key_handle_key_press (GtkWidget *wid, GdkEventKey *evt, session *sess)
if (!list) if (!list)
return FALSE; return FALSE;
current_sess = sess; current_sess = sess;
if (plugin_emit_keypress (sess, evt->state, evt->keyval, gdk_keyval_to_unicode (evt->keyval))) if (plugin_emit_keypress (sess, evt->state, evt->keyval, gdk_keyval_to_unicode (evt->keyval)))
return 1; return 1;
@@ -580,31 +487,6 @@ key_handle_key_press (GtkWidget *wid, GdkEventKey *evt, session *sess)
return 0; return 0;
} }
gboolean
key_get_menu_accel (const char *name, guint *keyval, GdkModifierType *mod)
{
struct key_binding *kb;
GSList *list;
if (!name)
return FALSE;
list = keybind_list;
while (list)
{
kb = (struct key_binding*)list->data;
if (kb->action >= 0 && kb->action <= KEY_MAX_ACTIONS && kb->keyval != 0 && !strcmp (key_actions[kb->action].name, "Menu Shortcut") && kb->data1 && !strcmp (kb->data1, name))
{
*keyval = kb->keyval;
*mod = kb->mod;
return TRUE;
}
list = g_slist_next (list);
}
return FALSE;
}
/* ***** GUI code here ******************* */ /* ***** GUI code here ******************* */
@@ -615,7 +497,6 @@ enum
ACTION_COLUMN, ACTION_COLUMN,
D1_COLUMN, D1_COLUMN,
D2_COLUMN, D2_COLUMN,
CUSTOM_COLUMN,
N_COLUMNS N_COLUMNS
}; };
@@ -740,32 +621,16 @@ key_dialog_keypress (GtkWidget *wid, GdkEventKey *evt, gpointer userdata)
if (handled) if (handled)
{ {
gboolean custom1, custom2;
sel = gtk_tree_view_get_selection (view); sel = gtk_tree_view_get_selection (view);
if (!gtk_tree_selection_get_selected (sel, &store, &iter1)) gtk_tree_selection_get_selected (sel, &store, &iter1);
return FALSE;
path = gtk_tree_model_get_path (store, &iter1); path = gtk_tree_model_get_path (store, &iter1);
if (delta == 1) if (delta == 1)
gtk_tree_path_next (path); gtk_tree_path_next (path);
else if (!gtk_tree_path_prev (path)) else
{ gtk_tree_path_prev (path);
gtk_tree_path_free (path); gtk_tree_model_get_iter (store, &iter2, path);
return FALSE;
}
if (!gtk_tree_model_get_iter (store, &iter2, path))
{
gtk_tree_path_free (path);
return FALSE;
}
gtk_tree_path_free (path); gtk_tree_path_free (path);
gtk_tree_model_get (store, &iter1, CUSTOM_COLUMN, &custom1, -1); gtk_list_store_swap (GTK_LIST_STORE (store), &iter1, &iter2);
gtk_tree_model_get (store, &iter2, CUSTOM_COLUMN, &custom2, -1);
if (custom1 && custom2)
gtk_list_store_swap (GTK_LIST_STORE (store), &iter1, &iter2);
} }
return handled; return handled;
@@ -777,23 +642,14 @@ key_dialog_selection_changed (GtkTreeSelection *sel, gpointer userdata)
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
GtkXText *xtext; GtkXText *xtext;
GtkWidget *delete_button;
char *actiontext; char *actiontext;
gboolean custom;
int action; int action;
delete_button = g_object_get_data (G_OBJECT (key_dialog), "delete_button");
if (!gtk_tree_selection_get_selected (sel, &model, &iter) || model == NULL) if (!gtk_tree_selection_get_selected (sel, &model, &iter) || model == NULL)
{
if (delete_button)
gtk_widget_set_sensitive (delete_button, FALSE);
return; return;
}
xtext = GTK_XTEXT (g_object_get_data (G_OBJECT (key_dialog), "xtext")); xtext = GTK_XTEXT (g_object_get_data (G_OBJECT (key_dialog), "xtext"));
gtk_tree_model_get (model, &iter, ACTION_COLUMN, &actiontext, CUSTOM_COLUMN, &custom, -1); gtk_tree_model_get (model, &iter, ACTION_COLUMN, &actiontext, -1);
if (delete_button)
gtk_widget_set_sensitive (delete_button, custom);
if (actiontext) if (actiontext)
{ {
@@ -868,10 +724,7 @@ key_dialog_save (GtkWidget *wid, gpointer userdata)
} }
if (key_save_kbs () == 0) if (key_save_kbs () == 0)
{
menu_update_quit_accel ();
key_dialog_close (wid, NULL); key_dialog_close (wid, NULL);
}
} }
static void static void
@@ -884,7 +737,6 @@ key_dialog_add (GtkWidget *wid, gpointer userdata)
GtkTreePath *path; GtkTreePath *path;
gtk_list_store_append (store, &iter); gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, CUSTOM_COLUMN, TRUE, -1);
/* make sure the new row is visible and selected */ /* make sure the new row is visible and selected */
path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter); path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
@@ -894,134 +746,6 @@ key_dialog_add (GtkWidget *wid, gpointer userdata)
gtk_tree_path_free (path); gtk_tree_path_free (path);
} }
static char *
key_binding_signature (const char *action, const char *data1, const char *data2)
{
return g_strdup_printf ("%s\\n%s\\n%s", action ? action : "", data1 ? data1 : "", data2 ? data2 : "");
}
static int
key_dialog_reset_count (GHashTable *table, const char *key)
{
return GPOINTER_TO_INT (g_hash_table_lookup (table, key));
}
static void
key_dialog_reset_increment (GHashTable *table, char *key)
{
g_hash_table_replace (table, key, GINT_TO_POINTER (key_dialog_reset_count (table, key) + 1));
}
static void
key_dialog_reset (GtkWidget *wid, gpointer userdata)
{
GtkListStore *store = GTK_LIST_STORE (get_store ());
GtkListStore *custom_store;
GtkTreeIter iter, custom_iter;
GtkWidget *delete_button;
GHashTable *default_counts, *seen_counts;
GSList *list = NULL, *old_list, *default_iter;
struct key_binding *kb;
gboolean custom, keep;
char *key, *accel, *action, *data1, *data2, *signature;
if (key_load_kbs_from_buffer (g_strdup (default_kb_cfg), strlen (default_kb_cfg), &list) != 0)
return;
default_counts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
seen_counts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
for (default_iter = list; default_iter; default_iter = g_slist_next (default_iter))
{
kb = default_iter->data;
signature = key_binding_signature (key_actions[kb->action].name, kb->data1, kb->data2);
key_dialog_reset_increment (default_counts, signature);
}
custom_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
{
do
{
gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
KEY_COLUMN, &key,
ACCEL_COLUMN, &accel,
ACTION_COLUMN, &action,
D1_COLUMN, &data1,
D2_COLUMN, &data2,
CUSTOM_COLUMN, &custom,
-1);
signature = key_binding_signature (action, data1, data2);
keep = custom || key_dialog_reset_count (seen_counts, signature) >= key_dialog_reset_count (default_counts, signature);
if (!custom)
key_dialog_reset_increment (seen_counts, g_strdup (signature));
if (keep)
{
gtk_list_store_append (custom_store, &custom_iter);
gtk_list_store_set (custom_store, &custom_iter,
KEY_COLUMN, key,
ACCEL_COLUMN, accel,
ACTION_COLUMN, action,
D1_COLUMN, data1,
D2_COLUMN, data2,
CUSTOM_COLUMN, TRUE,
-1);
}
g_free (signature);
g_free (key);
g_free (accel);
g_free (action);
g_free (data1);
g_free (data2);
}
while (gtk_tree_model_iter_next (GTK_TREE_MODEL (store), &iter));
}
old_list = keybind_list;
keybind_list = list;
gtk_list_store_clear (store);
key_dialog_load (store);
keybind_list = old_list;
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (custom_store), &iter))
{
do
{
gtk_tree_model_get (GTK_TREE_MODEL (custom_store), &iter,
KEY_COLUMN, &key,
ACCEL_COLUMN, &accel,
ACTION_COLUMN, &action,
D1_COLUMN, &data1,
D2_COLUMN, &data2,
-1);
gtk_list_store_append (store, &custom_iter);
gtk_list_store_set (store, &custom_iter,
KEY_COLUMN, key,
ACCEL_COLUMN, accel,
ACTION_COLUMN, action,
D1_COLUMN, data1,
D2_COLUMN, data2,
CUSTOM_COLUMN, TRUE,
-1);
g_free (key);
g_free (accel);
g_free (action);
g_free (data1);
g_free (data2);
}
while (gtk_tree_model_iter_next (GTK_TREE_MODEL (custom_store), &iter));
}
delete_button = g_object_get_data (G_OBJECT (key_dialog), "delete_button");
if (delete_button)
gtk_widget_set_sensitive (delete_button, FALSE);
g_hash_table_destroy (default_counts);
g_hash_table_destroy (seen_counts);
g_object_unref (custom_store);
g_slist_free_full (list, key_free);
}
static void static void
key_dialog_delete (GtkWidget *wid, gpointer userdata) key_dialog_delete (GtkWidget *wid, gpointer userdata)
{ {
@@ -1029,14 +753,9 @@ key_dialog_delete (GtkWidget *wid, gpointer userdata)
GtkListStore *store = GTK_LIST_STORE (gtk_tree_view_get_model (view)); GtkListStore *store = GTK_LIST_STORE (gtk_tree_view_get_model (view));
GtkTreeIter iter; GtkTreeIter iter;
GtkTreePath *path; GtkTreePath *path;
gboolean custom;
if (gtkutil_treeview_get_selected (view, &iter, -1)) if (gtkutil_treeview_get_selected (view, &iter, -1))
{ {
gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, CUSTOM_COLUMN, &custom, -1);
if (!custom)
return;
/* delete this row, select next one */ /* delete this row, select next one */
if (gtk_list_store_remove (store, &iter)) if (gtk_list_store_remove (store, &iter))
{ {
@@ -1063,13 +782,13 @@ key_dialog_treeview_new (GtkWidget *box)
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); G_TYPE_STRING, G_TYPE_STRING);
g_return_val_if_fail (store != NULL, NULL); g_return_val_if_fail (store != NULL, NULL);
view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
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_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), FALSE); 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 (key_dialog_keypress), NULL); G_CALLBACK (key_dialog_keypress), NULL);
@@ -1139,8 +858,7 @@ key_dialog_treeview_new (GtkWidget *box)
G_CALLBACK (key_dialog_combo_changed), combostore); G_CALLBACK (key_dialog_combo_changed), combostore);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), ACTION_COLUMN, gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), ACTION_COLUMN,
"Action", render, "Action", render,
"text", ACTION_COLUMN, "text", ACTION_COLUMN,
"editable", CUSTOM_COLUMN,
NULL); NULL);
render = gtk_cell_renderer_text_new (); render = gtk_cell_renderer_text_new ();
@@ -1151,7 +869,6 @@ key_dialog_treeview_new (GtkWidget *box)
GTK_TREE_VIEW (view), D1_COLUMN, GTK_TREE_VIEW (view), D1_COLUMN,
"Data1", render, "Data1", render,
"text", D1_COLUMN, "text", D1_COLUMN,
"editable", CUSTOM_COLUMN,
NULL); NULL);
render = gtk_cell_renderer_text_new (); render = gtk_cell_renderer_text_new ();
@@ -1162,7 +879,6 @@ key_dialog_treeview_new (GtkWidget *box)
GTK_TREE_VIEW (view), D2_COLUMN, GTK_TREE_VIEW (view), D2_COLUMN,
"Data2", render, "Data2", render,
"text", D2_COLUMN, "text", D2_COLUMN,
"editable", CUSTOM_COLUMN,
NULL); NULL);
col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), KEY_COLUMN); col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), KEY_COLUMN);
@@ -1208,8 +924,7 @@ key_dialog_load (GtkListStore *store)
ACCEL_COLUMN, accel_text, ACCEL_COLUMN, accel_text,
ACTION_COLUMN, key_actions[kb->action].name, ACTION_COLUMN, key_actions[kb->action].name,
D1_COLUMN, kb->data1, D1_COLUMN, kb->data1,
D2_COLUMN, kb->data2, D2_COLUMN, kb->data2, -1);
CUSTOM_COLUMN, !key_binding_is_builtin (kb), -1);
g_free (accel_text); g_free (accel_text);
g_free (label_text); g_free (label_text);
@@ -1222,7 +937,7 @@ void
key_dialog_show () key_dialog_show ()
{ {
GtkWidget *vbox, *box; GtkWidget *vbox, *box;
GtkWidget *view, *xtext, *delete_button; GtkWidget *view, *xtext;
GtkListStore *store; GtkListStore *store;
XTextColor xtext_palette[XTEXT_COLS]; XTextColor xtext_palette[XTEXT_COLS];
char buf[128]; char buf[128];
@@ -1256,12 +971,8 @@ key_dialog_show ()
gtkutil_button (box, ICON_FKEYS_NEW, NULL, key_dialog_add, gtkutil_button (box, ICON_FKEYS_NEW, NULL, key_dialog_add,
NULL, _("Add")); NULL, _("Add"));
delete_button = gtkutil_button (box, ICON_FKEYS_DELETE, NULL, key_dialog_delete, gtkutil_button (box, ICON_FKEYS_DELETE, NULL, key_dialog_delete,
NULL, _("Delete")); NULL, _("Delete"));
g_object_set_data (G_OBJECT (key_dialog), "delete_button", delete_button);
gtk_widget_set_sensitive (delete_button, FALSE);
gtkutil_button (box, ICON_FKEYS_RESET, NULL, key_dialog_reset,
NULL, _("Reset"));
gtkutil_button (box, ICON_FKEYS_CANCEL, NULL, key_dialog_close, gtkutil_button (box, ICON_FKEYS_CANCEL, NULL, key_dialog_close,
NULL, _("Cancel")); NULL, _("Cancel"));
gtkutil_button (box, ICON_FKEYS_SAVE, NULL, key_dialog_save, gtkutil_button (box, ICON_FKEYS_SAVE, NULL, key_dialog_save,
@@ -1369,14 +1080,41 @@ key_load_kbs_helper_mod (char *buf, GdkModifierType *out)
} }
static int static int
key_load_kbs_from_buffer (char *ibuf, off_t size, GSList **out_list) key_load_kbs (void)
{ {
char *buf; char *buf, *ibuf;
struct stat st;
struct key_binding *kb = NULL; struct key_binding *kb = NULL;
int len, state = 0, pnt = 0; int fd, len, state = 0, pnt = 0;
guint keyval; guint keyval;
GdkModifierType mod = 0; GdkModifierType mod = 0;
GSList *list = NULL; off_t size;
fd = zoitechat_open_file ("keybindings.conf", O_RDONLY, 0, 0);
if (fd < 0)
{
ibuf = g_strdup (default_kb_cfg);
size = strlen (default_kb_cfg);
}
else
{
if (fstat (fd, &st) != 0)
{
close (fd);
return 1;
}
ibuf = g_malloc(st.st_size);
read (fd, ibuf, st.st_size);
size = st.st_size;
close (fd);
}
if (keybind_list)
{
g_slist_free_full (keybind_list, key_free);
keybind_list = NULL;
}
while (buf_get_line (ibuf, &buf, &pnt, size)) while (buf_get_line (ibuf, &buf, &pnt, size))
{ {
@@ -1390,12 +1128,14 @@ key_load_kbs_from_buffer (char *ibuf, off_t size, GSList **out_list)
case KBSTATE_MOD: case KBSTATE_MOD:
kb = g_new0 (struct key_binding, 1); kb = g_new0 (struct key_binding, 1);
/* New format */
if (strncmp (buf, "ACCEL=", 6) == 0) if (strncmp (buf, "ACCEL=", 6) == 0)
{ {
buf += 6; buf += 6;
gtk_accelerator_parse (buf, &keyval, &mod); gtk_accelerator_parse (buf, &keyval, &mod);
kb->keyval = keyval; kb->keyval = keyval;
kb->mod = key_modifier_get_valid (mod); kb->mod = key_modifier_get_valid (mod);
@@ -1418,8 +1158,6 @@ key_load_kbs_from_buffer (char *ibuf, off_t size, GSList **out_list)
if (keyval == 0) if (keyval == 0)
{ {
g_free (ibuf); g_free (ibuf);
key_free (kb);
g_slist_free_full (list, key_free);
return 2; return 2;
} }
@@ -1436,8 +1174,6 @@ key_load_kbs_from_buffer (char *ibuf, off_t size, GSList **out_list)
if (kb->action == KEY_MAX_ACTIONS + 1) if (kb->action == KEY_MAX_ACTIONS + 1)
{ {
g_free (ibuf); g_free (ibuf);
key_free (kb);
g_slist_free_full (list, key_free);
return 3; return 3;
} }
@@ -1455,8 +1191,6 @@ key_load_kbs_from_buffer (char *ibuf, off_t size, GSList **out_list)
if (buf[0] != 'D') if (buf[0] != 'D')
{ {
g_free (ibuf); g_free (ibuf);
key_free (kb);
g_slist_free_full (list, key_free);
return 4; return 4;
} }
@@ -1477,6 +1211,7 @@ key_load_kbs_from_buffer (char *ibuf, off_t size, GSList **out_list)
if (buf[2] == ':') if (buf[2] == ':')
{ {
len = strlen (buf); len = strlen (buf);
/* Add one for the NULL, subtract 3 for the "Dx:" */
len++; len++;
len -= 3; len -= 3;
if (state == KBSTATE_DT1) if (state == KBSTATE_DT1)
@@ -1499,8 +1234,7 @@ key_load_kbs_from_buffer (char *ibuf, off_t size, GSList **out_list)
continue; continue;
} else } else
{ {
list = g_slist_append (list, kb); keybind_list = g_slist_append (keybind_list, kb);
kb = NULL;
state = KBSTATE_MOD; state = KBSTATE_MOD;
} }
@@ -1509,56 +1243,14 @@ key_load_kbs_from_buffer (char *ibuf, off_t size, GSList **out_list)
} }
} }
g_free (ibuf); g_free (ibuf);
*out_list = list;
return 0; return 0;
corrupt_file: corrupt_file:
g_free (ibuf); g_free (ibuf);
key_free (kb); g_free (kb);
g_slist_free_full (list, key_free);
return 5; return 5;
} }
static int
key_load_kbs (void)
{
char *ibuf;
struct stat st;
int fd, result;
off_t size;
GSList *list = NULL;
fd = zoitechat_open_file ("keybindings.conf", O_RDONLY, 0, 0);
if (fd < 0)
{
ibuf = g_strdup (default_kb_cfg);
size = strlen (default_kb_cfg);
}
else
{
if (fstat (fd, &st) != 0)
{
close (fd);
return 1;
}
ibuf = g_malloc(st.st_size);
read (fd, ibuf, st.st_size);
size = st.st_size;
close (fd);
}
result = key_load_kbs_from_buffer (ibuf, size, &list);
if (result != 0)
return result;
if (keybind_list)
g_slist_free_full (keybind_list, key_free);
keybind_list = list;
return 0;
}
static int static int
key_action_handle_command (GtkWidget * wid, GdkEventKey * evt, char *d1, key_action_handle_command (GtkWidget * wid, GdkEventKey * evt, char *d1,
char *d2, struct session *sess) char *d2, struct session *sess)
@@ -1576,24 +1268,6 @@ key_action_handle_command (GtkWidget * wid, GdkEventKey * evt, char *d1,
return 0; return 0;
} }
static int
key_action_menu_shortcut (GtkWidget * wid, GdkEventKey * evt, char *d1,
char *d2, struct session *sess)
{
if (menu_key_action (d1, evt->keyval, evt->state))
return 2;
return 0;
}
static int
key_action_reopen_closed_tab (GtkWidget * wid, GdkEventKey * evt, char *d1,
char *d2, struct session *sess)
{
mg_reopen_closed_channel_tab ();
return 2;
}
/* /*
* Check if the given session is inside the main window. This predicate * Check if the given session is inside the main window. This predicate
* is passed to lastact_getfirst() as a way to filter out detached sessions. * is passed to lastact_getfirst() as a way to filter out detached sessions.
@@ -1612,9 +1286,6 @@ key_action_page_switch (GtkWidget * wid, GdkEventKey * evt, char *d1,
char *d2, struct session *sess) char *d2, struct session *sess)
{ {
session *newsess; session *newsess;
char *network;
char *channel;
char *slash;
int len, i, num; int len, i, num;
if (!d1) if (!d1)
@@ -1626,13 +1297,21 @@ key_action_page_switch (GtkWidget * wid, GdkEventKey * evt, char *d1,
if (g_ascii_strcasecmp(d1, "auto") == 0) if (g_ascii_strcasecmp(d1, "auto") == 0)
{ {
/* Auto switch makes no sense in detached sessions */
if (!sess->gui->is_tab) if (!sess->gui->is_tab)
return 1; return 1;
/* Obtain a session with recent activity */
newsess = lastact_getfirst(session_check_is_tab); newsess = lastact_getfirst(session_check_is_tab);
if (newsess) if (newsess)
{ {
/*
* Only sessions in the current window should be considered (i.e.
* we don't want to move the focus on a different window). This
* call could, in theory, do this, but we checked before that
* newsess->gui->is_tab and sess->gui->is_tab.
*/
mg_bring_tofront_sess(newsess); mg_bring_tofront_sess(newsess);
return 0; return 0;
} }
@@ -1646,27 +1325,8 @@ key_action_page_switch (GtkWidget * wid, GdkEventKey * evt, char *d1,
{ {
if (i == 0 && (d1[i] == '+' || d1[i] == '-')) if (i == 0 && (d1[i] == '+' || d1[i] == '-'))
continue; continue;
else
network = NULL; return 1;
channel = d1;
slash = strchr (d1, '/');
if (slash && slash[1])
{
network = g_strndup (d1, slash - d1);
channel = slash + 1;
}
newsess = plugin_find_context (network, channel, sess->server);
g_free (network);
if (newsess && newsess->gui)
{
mg_bring_tofront_sess(newsess);
return 0;
}
return 1;
} }
} }
@@ -2292,37 +1952,8 @@ replace_handle (GtkWidget *t)
{ {
ptrdiff_t found_offset = found - text; ptrdiff_t found_offset = found - text;
ptrdiff_t found_end_offset = found_offset + (ptrdiff_t) pop_len; ptrdiff_t found_end_offset = found_offset + (ptrdiff_t) pop_len;
gboolean start_ok;
gboolean end_ok;
int rank; int rank;
ptrdiff_t distance; ptrdiff_t distance;
const char *before = found;
const char *after = found + pop_len;
if (before > text)
{
before = g_utf8_find_prev_char (text, before);
start_ok = !before || (!g_unichar_isalnum (g_utf8_get_char (before)) && g_utf8_get_char (before) != '_');
}
else
{
start_ok = TRUE;
}
if (*after != '\0')
{
end_ok = !g_unichar_isalnum (g_utf8_get_char (after)) && g_utf8_get_char (after) != '_';
}
else
{
end_ok = TRUE;
}
if (!start_ok || !end_ok)
{
found++;
continue;
}
if (cursor_byte_offset >= found_offset && cursor_byte_offset <= found_end_offset) if (cursor_byte_offset >= found_offset && cursor_byte_offset <= found_end_offset)
{ {
-1
View File
@@ -35,6 +35,5 @@ int key_handle_key_press (GtkWidget * wid, GdkEventKey * evt, session *sess);
int key_action_insert (GtkWidget * wid, GdkEventKey * evt, char *d1, char *d2, int key_action_insert (GtkWidget * wid, GdkEventKey * evt, char *d1, char *d2,
session *sess); session *sess);
void key_check_replace_on_change (GtkEditable *editable, gpointer data); void key_check_replace_on_change (GtkEditable *editable, gpointer data);
gboolean key_get_menu_accel (const char *name, guint *keyval, GdkModifierType *mod);
#endif #endif
+140 -5
View File
@@ -272,6 +272,13 @@ gtkutil_apply_palette (GtkWidget *widget, const GdkRGBA *bg, const GdkRGBA *fg,
theme_manager_apply_palette_widget (widget, bg, fg, font_desc); theme_manager_apply_palette_widget (widget, bg, fg, font_desc);
} }
static void
gtkutil_file_req_destroy (GtkWidget * wid, struct file_req *freq)
{
freq->callback (freq->userdata, NULL);
g_free (freq);
}
static void static void
gtkutil_check_file (char *filename, struct file_req *freq) gtkutil_check_file (char *filename, struct file_req *freq)
{ {
@@ -383,6 +390,26 @@ gtkutil_file_req_done_chooser (GtkFileChooser *fs, struct file_req *freq)
} }
static void
gtkutil_file_req_done (GtkWidget * wid, struct file_req *freq)
{
gtkutil_file_req_done_chooser (GTK_FILE_CHOOSER (freq->dialog), freq);
gtk_widget_destroy (freq->dialog);
}
static void
gtkutil_file_req_response (GtkWidget *dialog, gint res, struct file_req *freq)
{
if (res == GTK_RESPONSE_ACCEPT)
{
gtkutil_file_req_done (dialog, freq);
return;
}
gtk_widget_destroy (dialog);
}
#ifdef WIN32
static gboolean static gboolean
gtkutil_native_dialog_unref_idle (gpointer native) gtkutil_native_dialog_unref_idle (gpointer native)
{ {
@@ -396,16 +423,27 @@ gtkutil_native_file_req_response (GtkNativeDialog *dialog, gint res, struct file
if (res == GTK_RESPONSE_ACCEPT) if (res == GTK_RESPONSE_ACCEPT)
gtkutil_file_req_done_chooser (GTK_FILE_CHOOSER (dialog), freq); gtkutil_file_req_done_chooser (GTK_FILE_CHOOSER (dialog), freq);
/* Match gtk dialog flow by always sending NULL to indicate completion. */
freq->callback (freq->userdata, NULL); freq->callback (freq->userdata, NULL);
g_free (freq); g_free (freq);
/*
* Defer unref until idle to avoid disposing the native chooser while
* still in the button-release signal stack on Windows.
*/
g_idle_add (gtkutil_native_dialog_unref_idle, dialog); g_idle_add (gtkutil_native_dialog_unref_idle, dialog);
} }
#endif
void void
gtkutil_file_req (GtkWindow *parent, const char *title, void *callback, void *userdata, char *filter, char *extensions, gtkutil_file_req (GtkWindow *parent, const char *title, void *callback, void *userdata, char *filter, char *extensions,
int flags) int flags)
{ {
struct file_req *freq; struct file_req *freq;
GtkWidget *dialog;
GtkFileFilter *filefilter;
char *token;
char *tokenbuffer;
const char *xdir; const char *xdir;
GtkWindow *effective_parent = parent; GtkWindow *effective_parent = parent;
@@ -415,6 +453,7 @@ gtkutil_file_req (GtkWindow *parent, const char *title, void *callback, void *us
xdir = get_xdir (); xdir = get_xdir ();
#ifdef WIN32
{ {
GtkFileChooserNative *native = gtk_file_chooser_native_new ( GtkFileChooserNative *native = gtk_file_chooser_native_new (
title, title,
@@ -483,14 +522,110 @@ gtkutil_file_req (GtkWindow *parent, const char *title, void *callback, void *us
g_signal_connect (native, "response", g_signal_connect (native, "response",
G_CALLBACK (gtkutil_native_file_req_response), freq); G_CALLBACK (gtkutil_native_file_req_response), freq);
if (flags & FRF_MODAL)
gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (native), TRUE);
gtk_native_dialog_show (GTK_NATIVE_DIALOG (native)); gtk_native_dialog_show (GTK_NATIVE_DIALOG (native));
return; return;
} }
#endif
if (flags & FRF_WRITE)
{
dialog = gtk_file_chooser_dialog_new (title, NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Save"), GTK_RESPONSE_ACCEPT,
NULL);
if (!(flags & FRF_NOASKOVERWRITE))
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
}
else
dialog = gtk_file_chooser_dialog_new (title, NULL,
GTK_FILE_CHOOSER_ACTION_OPEN,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Open"), GTK_RESPONSE_ACCEPT,
NULL);
theme_manager_attach_window (dialog);
if (filter && filter[0] && (flags & FRF_FILTERISINITIAL))
{
if (flags & FRF_WRITE)
{
char temp[1024];
path_part (filter, temp, sizeof (temp));
if (temp[0] && g_file_test (temp, G_FILE_TEST_IS_DIR))
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), temp);
else if (xdir && xdir[0] && g_file_test (xdir, G_FILE_TEST_IS_DIR))
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), xdir);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), file_part (filter));
}
else
{
if (g_file_test (filter, G_FILE_TEST_IS_DIR))
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), filter);
else if (xdir && xdir[0] && g_file_test (xdir, G_FILE_TEST_IS_DIR))
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), xdir);
}
}
else if (!(flags & FRF_RECENTLYUSED))
{
if (xdir && xdir[0] && g_file_test (xdir, G_FILE_TEST_IS_DIR))
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), xdir);
}
if (flags & FRF_MULTIPLE)
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
if (flags & FRF_CHOOSEFOLDER)
gtk_file_chooser_set_action (GTK_FILE_CHOOSER (dialog), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
if ((flags & FRF_EXTENSIONS || flags & FRF_MIMETYPES) && extensions != NULL)
{
filefilter = gtk_file_filter_new ();
tokenbuffer = g_strdup (extensions);
token = strtok (tokenbuffer, ";");
while (token != NULL)
{
if (flags & FRF_EXTENSIONS)
gtk_file_filter_add_pattern (filefilter, token);
else
gtk_file_filter_add_mime_type (filefilter, token);
token = strtok (NULL, ";");
}
g_free (tokenbuffer);
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filefilter);
}
if (xdir && xdir[0] && g_file_test (xdir, G_FILE_TEST_IS_DIR))
{
GError *shortcut_error = NULL;
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog), xdir, &shortcut_error);
if (shortcut_error)
g_error_free (shortcut_error);
}
freq = g_new (struct file_req, 1);
freq->dialog = dialog;
freq->flags = flags;
freq->callback = callback;
freq->userdata = userdata;
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (gtkutil_file_req_response), freq);
g_signal_connect (G_OBJECT (dialog), "destroy",
G_CALLBACK (gtkutil_file_req_destroy), (gpointer) freq);
if (effective_parent)
gtk_window_set_transient_for (GTK_WINDOW (dialog), effective_parent);
if (flags & FRF_MODAL)
{
g_assert (effective_parent);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
}
gtk_widget_show (dialog);
} }
static gboolean static gboolean
@@ -837,7 +972,7 @@ gtkutil_copy_to_clipboard (GtkWidget *widget, GdkAtom selection,
win = gtk_widget_get_toplevel (GTK_WIDGET (widget)); win = gtk_widget_get_toplevel (GTK_WIDGET (widget));
if (gtk_widget_is_toplevel (win)) if (gtk_widget_is_toplevel (win))
{ {
gint len = (gint) strlen (str); int len = strlen (str);
if (selection) if (selection)
{ {
+35 -492
View File
@@ -468,14 +468,6 @@ static session_gui static_mg_gui;
static session_gui *mg_gui = NULL; /* the shared irc tab */ static session_gui *mg_gui = NULL; /* the shared irc tab */
static int ignore_chanmode = FALSE; static int ignore_chanmode = FALSE;
static const char chan_flags[] = { 'c', 'n', 't', 'i', 'm', 'l', 'k' }; static const char chan_flags[] = { 'c', 'n', 't', 'i', 'm', 'l', 'k' };
typedef struct
{
int server_id;
char channel[CHANLEN];
char key[64];
}
mg_closed_channel_tab;
static GSList *mg_closed_channel_tabs;
static chan *active_tab = NULL; /* active tab */ static chan *active_tab = NULL; /* active tab */
GtkWidget *parent_window = NULL; /* the master window */ GtkWidget *parent_window = NULL; /* the master window */
@@ -870,99 +862,17 @@ fe_set_title (session *sess)
gtk_window_set_title (GTK_WINDOW (sess->gui->window), tbuf); gtk_window_set_title (GTK_WINDOW (sess->gui->window), tbuf);
} }
static void
mg_topicbar_update_height (GtkWidget *topic);
static void
mg_topicbar_queue_relayout (GtkWidget *topic);
static void
mg_queue_window_relayout (GtkWidget *window);
static session *
mg_session_from_window (GtkWidget *wid)
{
GSList *list;
session *sess;
list = sess_list;
while (list)
{
sess = list->data;
if (sess && sess->gui && sess->gui->window == wid)
return sess;
list = list->next;
}
return current_sess;
}
static gboolean
mg_window_relayout_idle_cb (gpointer userdata)
{
GtkWidget *window = GTK_WIDGET (userdata);
session *sess;
g_object_set_data (G_OBJECT (window), "mg-window-relayout-source", NULL);
sess = mg_session_from_window (window);
if (sess && sess->gui)
{
if (GTK_IS_WIDGET (sess->gui->topic_entry))
mg_topicbar_queue_relayout (sess->gui->topic_entry);
if (GTK_IS_XTEXT (sess->gui->xtext))
{
gtk_xtext_refresh (GTK_XTEXT (sess->gui->xtext));
gtk_widget_queue_resize (sess->gui->xtext);
gtk_widget_queue_draw (sess->gui->xtext);
}
if (GTK_IS_WIDGET (sess->gui->window))
{
gtk_widget_queue_resize (sess->gui->window);
gtk_widget_queue_draw (sess->gui->window);
}
}
g_object_unref (window);
return G_SOURCE_REMOVE;
}
static void
mg_queue_window_relayout (GtkWidget *window)
{
guint source_id;
if (!window || !GTK_IS_WIDGET (window))
return;
if (g_object_get_data (G_OBJECT (window), "mg-window-relayout-source") != NULL)
return;
source_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
mg_window_relayout_idle_cb,
g_object_ref (window),
NULL);
g_object_set_data (G_OBJECT (window), "mg-window-relayout-source",
GUINT_TO_POINTER (source_id));
}
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_state;
guint win_fullscreen; guint win_fullscreen;
gboolean changed = FALSE; gboolean changed = FALSE;
session *sess;
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 &&
gtkutil_tray_icon_supported (wid) gtkutil_tray_icon_supported (wid))
#ifndef WIN32
)
#else
&& !gtk_window_is_active (wid))
#endif
{ {
tray_toggle_visibility (TRUE); tray_toggle_visibility (TRUE);
} }
@@ -993,19 +903,10 @@ mg_windowstate_cb (GtkWindow *wid, GdkEventWindowState *event, gpointer userdata
mg_schedule_config_save (); mg_schedule_config_save ();
} }
sess = mg_session_from_window (GTK_WIDGET (wid)); menu_set_fullscreen (current_sess->gui, prefs.hex_gui_win_fullscreen);
if (sess && sess->gui && GTK_IS_WIDGET (sess->gui->window))
mg_queue_window_relayout (sess->gui->window);
else
mg_queue_window_relayout (GTK_WIDGET (wid));
if (current_sess && current_sess->gui)
menu_set_fullscreen (current_sess->gui, prefs.hex_gui_win_fullscreen);
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
if (event->changed_mask & mg_win32_allow_autohide_taskbar (wid, event);
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN))
mg_win32_allow_autohide_taskbar (wid, event);
#endif #endif
return FALSE; return FALSE;
@@ -1015,7 +916,6 @@ static gboolean
mg_configure_cb (GtkWidget *wid, GdkEventConfigure *event, session *sess) mg_configure_cb (GtkWidget *wid, GdkEventConfigure *event, session *sess)
{ {
gboolean changed = FALSE; gboolean changed = FALSE;
session *target_sess;
if (sess == NULL) if (sess == NULL)
{ {
@@ -1098,12 +998,6 @@ mg_configure_cb (GtkWidget *wid, GdkEventConfigure *event, session *sess)
mg_schedule_config_save (); mg_schedule_config_save ();
} }
target_sess = mg_session_from_window (wid);
if (target_sess && target_sess->gui && GTK_IS_WIDGET (target_sess->gui->window))
mg_queue_window_relayout (target_sess->gui->window);
else
mg_queue_window_relayout (wid);
return FALSE; return FALSE;
} }
@@ -1695,71 +1589,6 @@ mg_tab_close_cb (GtkWidget *dialog, gint arg1, session *sess)
} }
} }
static void
mg_closed_channel_tabs_add (session *sess)
{
mg_closed_channel_tab *item;
GSList *last;
if (!sess || sess->type != SESS_CHANNEL || !sess->channel[0])
return;
item = g_new0 (mg_closed_channel_tab, 1);
item->server_id = sess->server->id;
g_strlcpy (item->channel, sess->channel, sizeof (item->channel));
g_strlcpy (item->key, sess->channelkey, sizeof (item->key));
mg_closed_channel_tabs = g_slist_prepend (mg_closed_channel_tabs, item);
if (g_slist_length (mg_closed_channel_tabs) > 20)
{
last = g_slist_last (mg_closed_channel_tabs);
g_free (last->data);
mg_closed_channel_tabs = g_slist_delete_link (mg_closed_channel_tabs, last);
}
}
void
mg_reopen_closed_channel_tab (void)
{
mg_closed_channel_tab *item;
GSList *head;
GSList *list;
server *serv;
session *sess;
if (!mg_closed_channel_tabs)
return;
head = mg_closed_channel_tabs;
item = head->data;
mg_closed_channel_tabs = g_slist_delete_link (mg_closed_channel_tabs, head);
if (!item)
return;
serv = NULL;
for (list = serv_list; list; list = list->next)
{
server *candidate = list->data;
if (candidate->id == item->server_id)
{
serv = candidate;
break;
}
}
if (serv && serv->connected && item->channel[0])
{
sess = find_channel (serv, item->channel);
if (sess)
fe_ctrl_gui (sess, 2, 0);
else
{
new_ircwindow (serv, item->channel, SESS_CHANNEL, 1);
serv->p_join (serv, item->channel, item->key);
}
}
g_free (item);
}
void void
mg_tab_close (session *sess) mg_tab_close (session *sess)
{ {
@@ -1767,12 +1596,11 @@ mg_tab_close (session *sess)
GSList *list; GSList *list;
int i; int i;
if (chan_remove (sess->res->tab, FALSE)) if (chan_remove (sess->res->tab, FALSE))
{ {
mg_closed_channel_tabs_add (sess); sess->res->tab = NULL;
sess->res->tab = NULL; mg_ircdestroy (sess);
mg_ircdestroy (sess); }
}
else else
{ {
for (i = 0, list = sess_list; list; list = list->next) for (i = 0, list = sess_list; list; list = list->next)
@@ -2456,9 +2284,9 @@ mg_userlist_button (GtkWidget * box, char *label, char *cmd,
g_signal_connect (G_OBJECT (wid), "clicked", g_signal_connect (G_OBJECT (wid), "clicked",
G_CALLBACK (userlist_button_cb), cmd); G_CALLBACK (userlist_button_cb), cmd);
gtk_widget_set_hexpand (wid, TRUE); gtk_widget_set_hexpand (wid, TRUE);
gtk_widget_set_vexpand (wid, FALSE); gtk_widget_set_vexpand (wid, TRUE);
gtk_widget_set_halign (wid, GTK_ALIGN_FILL); gtk_widget_set_halign (wid, GTK_ALIGN_FILL);
gtk_widget_set_valign (wid, GTK_ALIGN_CENTER); gtk_widget_set_valign (wid, GTK_ALIGN_FILL);
gtk_grid_attach (GTK_GRID (box), wid, a, c, b - a, d - c); gtk_grid_attach (GTK_GRID (box), wid, a, c, b - a, d - c);
show_and_unfocus (wid); show_and_unfocus (wid);
} }
@@ -2615,7 +2443,6 @@ mg_topic_word_is_clickable (const char *word, int word_pos)
{ {
int start; int start;
int end; int end;
int word_type;
if (!word || word[0] == 0) if (!word || word[0] == 0)
return FALSE; return FALSE;
@@ -2623,8 +2450,7 @@ mg_topic_word_is_clickable (const char *word, int word_pos)
if (strcmp (word, "/") == 0) if (strcmp (word, "/") == 0)
return FALSE; return FALSE;
word_type = url_check_word (word); if (url_check_word (word) == 0)
if (word_type != WORD_URL && word_type != WORD_HOST && word_type != WORD_HOST6)
return FALSE; return FALSE;
url_last (&start, &end); url_last (&start, &end);
@@ -2673,8 +2499,7 @@ mg_topic_button_release_cb (GtkWidget *entry, GdkEventButton *event, gpointer us
if (!word) if (!word)
return FALSE; return FALSE;
if ((event->state & 13) == prefs.hex_gui_url_mod && if (mg_topic_word_is_clickable (word, word_pos))
mg_topic_word_is_clickable (word, word_pos))
{ {
url_last (&start, &end); url_last (&start, &end);
word[end] = 0; word[end] = 0;
@@ -2743,6 +2568,7 @@ mg_changui_destroy (session *sess)
/* it fixes: Gdk-CRITICAL **: gdk_colormap_get_screen: */ /* it fixes: Gdk-CRITICAL **: gdk_colormap_get_screen: */
/* assertion `GDK_IS_COLORMAP (cmap)' failed */ /* assertion `GDK_IS_COLORMAP (cmap)' failed */
ret = sess->gui->window; ret = sess->gui->window;
g_free (sess->gui);
sess->gui = NULL; sess->gui = NULL;
} }
return ret; return ret;
@@ -2764,17 +2590,13 @@ mg_link_irctab (session *sess, int focus)
return; return;
} }
session_gui *old_gui;
mg_unpopulate (sess); mg_unpopulate (sess);
old_gui = sess->gui;
win = mg_changui_destroy (sess); win = mg_changui_destroy (sess);
mg_changui_new (sess, sess->res, 1, focus); mg_changui_new (sess, sess->res, 1, focus);
/* the buffer is now attached to a different widget */ /* the buffer is now attached to a different widget */
((xtext_buffer *)sess->res->buffer)->xtext = (GtkXText *)sess->gui->xtext; ((xtext_buffer *)sess->res->buffer)->xtext = (GtkXText *)sess->gui->xtext;
if (win) if (win)
gtk_widget_destroy (win); gtk_widget_destroy (win);
g_free (old_gui);
} }
void void
@@ -3042,7 +2864,7 @@ mg_create_chanmodebuttons (session_gui *gui, GtkWidget *box)
gui->key_entry = gtk_entry_new (); gui->key_entry = gtk_entry_new ();
gtk_widget_set_name (gui->key_entry, "zoitechat-inputbox"); gtk_widget_set_name (gui->key_entry, "zoitechat-inputbox");
gtk_entry_set_max_length (GTK_ENTRY (gui->key_entry), 23); gtk_entry_set_max_length (GTK_ENTRY (gui->key_entry), 23);
gtk_widget_set_size_request (gui->key_entry, 58, 11); gtk_widget_set_size_request (gui->key_entry, 115, 11);
gtk_box_pack_start (GTK_BOX (box), gui->key_entry, 0, 0, 0); gtk_box_pack_start (GTK_BOX (box), gui->key_entry, 0, 0, 0);
mg_apply_emoji_fallback_widget (gui->key_entry); mg_apply_emoji_fallback_widget (gui->key_entry);
mg_apply_compact_mode_css (gui->key_entry); mg_apply_compact_mode_css (gui->key_entry);
@@ -3059,8 +2881,7 @@ mg_create_chanmodebuttons (session_gui *gui, GtkWidget *box)
gui->limit_entry = gtk_entry_new (); gui->limit_entry = gtk_entry_new ();
gtk_widget_set_name (gui->limit_entry, "zoitechat-inputbox"); gtk_widget_set_name (gui->limit_entry, "zoitechat-inputbox");
gtk_entry_set_max_length (GTK_ENTRY (gui->limit_entry), 10); gtk_entry_set_max_length (GTK_ENTRY (gui->limit_entry), 10);
gtk_entry_set_width_chars (GTK_ENTRY (gui->limit_entry), 5); gtk_widget_set_size_request (gui->limit_entry, 30, 11);
gtk_widget_set_size_request (gui->limit_entry, 45, 11);
gtk_box_pack_start (GTK_BOX (box), gui->limit_entry, 0, 0, 0); gtk_box_pack_start (GTK_BOX (box), gui->limit_entry, 0, 0, 0);
mg_apply_emoji_fallback_widget (gui->limit_entry); mg_apply_emoji_fallback_widget (gui->limit_entry);
mg_apply_compact_mode_css (gui->limit_entry); mg_apply_compact_mode_css (gui->limit_entry);
@@ -3147,193 +2968,10 @@ mg_create_dialogbuttons (GtkWidget *box)
} }
} }
static void
mg_topicbar_update_height (GtkWidget *topic)
{
GtkWidget *parent;
GtkWidget *grandparent;
GtkTextBuffer *buffer;
GtkTextIter start;
GtkTextIter end;
GtkTextView *view;
PangoLayout *layout;
char *text;
int width;
int line_height;
int line_count;
int target_height;
int margin_left;
int margin_right;
int margin_top;
int margin_bottom;
int old_height;
PangoContext *context;
PangoFontMetrics *metrics;
if (!topic || !GTK_IS_TEXT_VIEW (topic))
return;
view = GTK_TEXT_VIEW (topic);
parent = gtk_widget_get_parent (topic);
grandparent = parent ? gtk_widget_get_parent (parent) : NULL;
margin_left = gtk_text_view_get_left_margin (view);
margin_right = gtk_text_view_get_right_margin (view);
margin_top = gtk_text_view_get_top_margin (view);
margin_bottom = gtk_text_view_get_bottom_margin (view);
buffer = gtk_text_view_get_buffer (view);
gtk_text_buffer_get_bounds (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
layout = gtk_widget_create_pango_layout (topic, text && text[0] ? text : " ");
g_free (text);
width = gtk_widget_get_allocated_width (topic);
if (width <= 1 && parent)
width = gtk_widget_get_allocated_width (parent);
width -= margin_left + margin_right;
if (width < 1)
width = 1;
if (prefs.hex_gui_topicbar_multiline && !prefs.hex_gui_mode_buttons_inline)
{
pango_layout_set_width (layout, width * PANGO_SCALE);
pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
}
context = gtk_widget_get_pango_context (topic);
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
pango_context_get_language (context));
line_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
pango_font_metrics_get_descent (metrics));
pango_font_metrics_unref (metrics);
if (line_height <= 0)
line_height = 16;
line_count = prefs.hex_gui_topicbar_multiline && !prefs.hex_gui_mode_buttons_inline ?
pango_layout_get_line_count (layout) : 1;
if (line_count <= 0)
line_count = 1;
target_height = (line_height * line_count) + margin_top + margin_bottom;
if (target_height < line_height + margin_top + margin_bottom)
target_height = line_height + margin_top + margin_bottom;
old_height = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (topic),
"mg-topicbar-target-height"));
if (old_height != target_height)
{
g_object_set_data (G_OBJECT (topic), "mg-topicbar-target-height",
GINT_TO_POINTER (target_height));
gtk_widget_set_size_request (topic, -1, target_height);
if (parent && GTK_IS_SCROLLED_WINDOW (parent))
{
gtk_scrolled_window_set_max_content_height (GTK_SCROLLED_WINDOW (parent), -1);
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (parent), -1);
gtk_scrolled_window_set_max_content_height (GTK_SCROLLED_WINDOW (parent), target_height);
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (parent), target_height);
gtk_widget_set_size_request (parent, -1, target_height);
}
}
gtk_widget_queue_resize (topic);
if (parent)
gtk_widget_queue_resize (parent);
if (grandparent)
gtk_widget_queue_resize (grandparent);
gtk_widget_queue_draw (topic);
g_object_unref (layout);
}
static gboolean
mg_topicbar_relayout_idle_cb (gpointer userdata)
{
GtkWidget *topic = GTK_WIDGET (userdata);
g_object_set_data (G_OBJECT (topic), "mg-topicbar-relayout-source", NULL);
mg_topicbar_update_height (topic);
g_object_unref (topic);
return G_SOURCE_REMOVE;
}
static void
mg_topicbar_queue_relayout (GtkWidget *topic)
{
guint source_id;
if (!topic || !GTK_IS_TEXT_VIEW (topic))
return;
if (g_object_get_data (G_OBJECT (topic), "mg-topicbar-relayout-source") != NULL)
return;
source_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
mg_topicbar_relayout_idle_cb,
g_object_ref (topic),
NULL);
g_object_set_data (G_OBJECT (topic), "mg-topicbar-relayout-source",
GUINT_TO_POINTER (source_id));
}
static void
mg_topicbar_buffer_changed_cb (GtkTextBuffer *buffer, gpointer userdata)
{
(void) buffer;
mg_topicbar_queue_relayout (GTK_WIDGET (userdata));
}
static void
mg_topicbar_size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer userdata)
{
int old_width;
(void) userdata;
old_width = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"mg-topicbar-allocated-width"));
if (allocation->width == old_width)
return;
g_object_set_data (G_OBJECT (widget), "mg-topicbar-allocated-width",
GINT_TO_POINTER (allocation->width));
mg_topicbar_queue_relayout (widget);
}
void
mg_apply_session_font_prefs (session_gui *gui)
{
const PangoFontDescription *font = NULL;
if (!gui)
return;
if (input_style)
font = input_style->font_desc;
if (gui->topic_entry)
{
theme_manager_apply_entry_palette (gui->topic_entry, font);
mg_topicbar_update_height (gui->topic_entry);
}
if (gui->input_box && prefs.hex_gui_input_style)
theme_manager_apply_entry_palette (gui->input_box, font);
if (gui->chanview)
chanview_apply_theme (gui->chanview);
if (gui->user_tree)
theme_manager_apply_userlist_style (gui->user_tree,
theme_manager_get_userlist_palette_behavior (font));
}
static void static void
mg_create_topicbar (session *sess, GtkWidget *box) mg_create_topicbar (session *sess, GtkWidget *box)
{ {
GtkWidget *vbox, *hbox, *mode_hbox, *topic, *topic_scroll, *bbox; GtkWidget *vbox, *hbox, *mode_hbox, *topic, *bbox;
session_gui *gui = sess->gui; session_gui *gui = sess->gui;
gui->topic_bar = vbox = mg_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); gui->topic_bar = vbox = mg_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0);
@@ -3346,33 +2984,12 @@ mg_create_topicbar (session *sess, GtkWidget *box)
sess->res->tab = NULL; sess->res->tab = NULL;
gui->topic_entry = topic = gtk_text_view_new (); gui->topic_entry = topic = gtk_text_view_new ();
gtk_widget_set_name (topic, "zoitechat-topicbox"); gtk_widget_set_name (topic, "zoitechat-inputbox");
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (topic), gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (topic), GTK_WRAP_WORD_CHAR);
prefs.hex_gui_topicbar_multiline && !prefs.hex_gui_mode_buttons_inline ?
GTK_WRAP_WORD_CHAR : GTK_WRAP_NONE);
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (topic), 4); gtk_text_view_set_left_margin (GTK_TEXT_VIEW (topic), 4);
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (topic), 4); gtk_text_view_set_right_margin (GTK_TEXT_VIEW (topic), 4);
gtk_text_view_set_top_margin (GTK_TEXT_VIEW (topic), 4); gtk_box_pack_start (GTK_BOX (hbox), topic, TRUE, TRUE, 0);
gtk_text_view_set_bottom_margin (GTK_TEXT_VIEW (topic), 4); mg_apply_emoji_fallback_widget (topic);
gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (topic), 0);
gtk_text_view_set_pixels_below_lines (GTK_TEXT_VIEW (topic), 0);
gtk_text_view_set_pixels_inside_wrap (GTK_TEXT_VIEW (topic), 0);
theme_manager_apply_entry_palette (topic, input_style ? input_style->font_desc : NULL);
g_signal_connect (gtk_text_view_get_buffer (GTK_TEXT_VIEW (topic)), "changed",
G_CALLBACK (mg_topicbar_buffer_changed_cb), topic);
g_signal_connect (G_OBJECT (topic), "size-allocate",
G_CALLBACK (mg_topicbar_size_allocate_cb), NULL);
topic_scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_hexpand (topic_scroll, TRUE);
gtk_widget_set_size_request (topic_scroll, 1, -1);
gtk_widget_set_size_request (topic, 1, -1);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (topic_scroll),
GTK_POLICY_EXTERNAL, GTK_POLICY_NEVER);
gtk_scrolled_window_set_propagate_natural_width (GTK_SCROLLED_WINDOW (topic_scroll), FALSE);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (topic_scroll), GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (topic_scroll), topic);
mg_topicbar_update_height (topic);
gtk_box_pack_start (GTK_BOX (hbox), topic_scroll, TRUE, TRUE, 0);
gtk_widget_add_events (topic, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | gtk_widget_add_events (topic, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK);
g_signal_connect (G_OBJECT (topic), "key-press-event", g_signal_connect (G_OBJECT (topic), "key-press-event",
@@ -3389,13 +3006,9 @@ mg_create_topicbar (session *sess, GtkWidget *box)
mg_create_dialogbuttons (bbox); mg_create_dialogbuttons (bbox);
mode_hbox = mg_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); mode_hbox = mg_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);
if (prefs.hex_gui_mode_buttons_inline) gtk_box_pack_start (GTK_BOX (vbox), mode_hbox, 0, 0, 0);
gtk_box_pack_start (GTK_BOX (hbox), mode_hbox, 0, 0, 0);
else
gtk_box_pack_start (GTK_BOX (vbox), mode_hbox, 0, 0, 0);
gui->topicbutton_box = bbox = mg_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); gui->topicbutton_box = bbox = mg_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);
gtk_widget_set_valign (bbox, GTK_ALIGN_CENTER);
gtk_box_pack_end (GTK_BOX (mode_hbox), bbox, 0, 0, 0); gtk_box_pack_end (GTK_BOX (mode_hbox), bbox, 0, 0, 0);
mg_create_chanmodebuttons (gui, bbox); mg_create_chanmodebuttons (gui, bbox);
} }
@@ -3549,13 +3162,8 @@ mg_create_textarea (session *sess, GtkWidget *box)
inbox = mg_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 2); inbox = mg_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), inbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), inbox, TRUE, TRUE, 0);
frame = gtk_scrolled_window_new (NULL, NULL); frame = gtk_frame_new (NULL);
gtk_widget_set_hexpand (frame, TRUE); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_widget_set_vexpand (frame, TRUE);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (frame),
GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (frame),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (inbox), frame, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (inbox), frame, TRUE, TRUE, 0);
theme_get_xtext_colors_for_widget (frame, xtext_palette, XTEXT_COLS); theme_get_xtext_colors_for_widget (frame, xtext_palette, XTEXT_COLS);
@@ -3572,7 +3180,9 @@ mg_create_textarea (session *sess, GtkWidget *box)
g_signal_connect (G_OBJECT (xtext), "word_click", g_signal_connect (G_OBJECT (xtext), "word_click",
G_CALLBACK (mg_word_clicked), NULL); G_CALLBACK (mg_word_clicked), NULL);
gui->vscrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (frame)); gui->vscrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL,
GTK_XTEXT (xtext)->adj);
gtk_box_pack_start (GTK_BOX (inbox), gui->vscrollbar, FALSE, TRUE, 0);
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);
@@ -3598,7 +3208,7 @@ mg_create_infoframe (GtkWidget *box)
frame = gtk_frame_new (0); frame = gtk_frame_new (0);
gtk_frame_set_shadow_type ((GtkFrame*)frame, GTK_SHADOW_OUT); gtk_frame_set_shadow_type ((GtkFrame*)frame, GTK_SHADOW_OUT);
gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (box), frame, FALSE, TRUE, 0);
hbox = mg_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0); hbox = mg_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), hbox); gtk_container_add (GTK_CONTAINER (frame), hbox);
@@ -3615,11 +3225,11 @@ mg_create_meters (session_gui *gui, GtkWidget *parent_box)
GtkWidget *infbox, *wid, *box; GtkWidget *infbox, *wid, *box;
gui->meter_box = infbox = box = mg_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 1); gui->meter_box = infbox = box = mg_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 1);
gtk_box_pack_end (GTK_BOX (parent_box), box, 0, 0, 0); gtk_box_pack_start (GTK_BOX (parent_box), box, 0, 0, 0);
if ((prefs.hex_gui_lagometer & 2) || (prefs.hex_gui_throttlemeter & 2)) if ((prefs.hex_gui_lagometer & 2) || (prefs.hex_gui_throttlemeter & 2))
{ {
infbox = mg_box_new (GTK_ORIENTATION_HORIZONTAL, TRUE, 0); infbox = mg_box_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), infbox, 0, 0, 0); gtk_box_pack_start (GTK_BOX (box), infbox, 0, 0, 0);
} }
@@ -3705,44 +3315,6 @@ mg_theme_userlist_changed (const ThemeChangedEvent *event, gpointer userdata)
mg_theme_apply_userlist_style (gui); mg_theme_apply_userlist_style (gui);
} }
static void
mg_theme_refresh_menu_widget (GtkWidget *widget)
{
GtkRequisition minimum;
GtkRequisition natural;
if (!widget)
return;
gtk_widget_queue_resize (widget);
gtk_widget_get_preferred_size (widget, &minimum, &natural);
}
static void
mg_theme_refresh_menu_tree (GtkWidget *menu)
{
GList *children;
GList *node;
if (!menu || !GTK_IS_MENU_SHELL (menu))
return;
children = gtk_container_get_children (GTK_CONTAINER (menu));
for (node = children; node; node = node->next)
{
GtkWidget *item = GTK_WIDGET (node->data);
GtkWidget *submenu = NULL;
if (GTK_IS_MENU_ITEM (item))
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (item));
if (submenu)
mg_theme_refresh_menu_tree (submenu);
mg_theme_refresh_menu_widget (item);
}
g_list_free (children);
mg_theme_refresh_menu_widget (menu);
}
static void static void
mg_theme_window_changed (const ThemeChangedEvent *event, gpointer userdata) mg_theme_window_changed (const ThemeChangedEvent *event, gpointer userdata)
{ {
@@ -3753,11 +3325,8 @@ mg_theme_window_changed (const ThemeChangedEvent *event, gpointer userdata)
!theme_changed_event_has_reason (event, THEME_CHANGED_REASON_WIDGET_STYLE)) !theme_changed_event_has_reason (event, THEME_CHANGED_REASON_WIDGET_STYLE))
return; return;
if (!gui) if (gui)
return; theme_manager_apply_to_window (gui->window);
theme_manager_apply_to_window (gui->window);
mg_theme_refresh_menu_tree (gui->menu);
} }
static void static void
@@ -3800,14 +3369,8 @@ mg_create_userlist (session_gui *gui, GtkWidget *box)
gtk_box_pack_start (GTK_BOX (box), vbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (box), vbox, TRUE, TRUE, 0);
gui->namelistinfo = gtk_label_new (NULL); gui->namelistinfo = gtk_label_new (NULL);
gtk_label_set_xalign (GTK_LABEL (gui->namelistinfo), 0.5f); gtk_label_set_xalign (GTK_LABEL (gui->namelistinfo), 0.0f);
gtk_label_set_justify (GTK_LABEL (gui->namelistinfo), GTK_JUSTIFY_CENTER); gtk_widget_set_halign (gui->namelistinfo, GTK_ALIGN_START);
gtk_label_set_ellipsize (GTK_LABEL (gui->namelistinfo), PANGO_ELLIPSIZE_END);
gtk_label_set_width_chars (GTK_LABEL (gui->namelistinfo), 1);
gtk_widget_set_margin_start (gui->namelistinfo, 0);
gtk_widget_set_margin_end (gui->namelistinfo, 0);
gtk_widget_set_hexpand (gui->namelistinfo, TRUE);
gtk_widget_set_halign (gui->namelistinfo, GTK_ALIGN_FILL);
if (prefs.hex_gui_ulist_count) if (prefs.hex_gui_ulist_count)
gtk_box_pack_start (GTK_BOX (vbox), gui->namelistinfo, 0, 0, 0); gtk_box_pack_start (GTK_BOX (vbox), gui->namelistinfo, 0, 0, 0);
@@ -4863,14 +4426,7 @@ mg_win32_filter (GdkXEvent *xevent, GdkEvent *event, gpointer data)
{ {
if (strcmp (command, "__WIN32_TASKBAR_TOGGLE__") == 0) if (strcmp (command, "__WIN32_TASKBAR_TOGGLE__") == 0)
{ {
GdkWindowState state = 0; if (gtk_widget_get_visible (current_sess->gui->window))
GdkWindow *gdk_window = gtk_widget_get_window (current_sess->gui->window);
if (gdk_window)
state = gdk_window_get_state (gdk_window);
if (gtk_widget_get_visible (current_sess->gui->window)
&& (state & GDK_WINDOW_STATE_ICONIFIED) == 0)
fe_ctrl_gui (current_sess, FE_GUI_ICONIFY, 0); fe_ctrl_gui (current_sess, FE_GUI_ICONIFY, 0);
else else
fe_ctrl_gui (current_sess, FE_GUI_SHOW, 0); fe_ctrl_gui (current_sess, FE_GUI_SHOW, 0);
@@ -5384,14 +4940,9 @@ static void
mg_handle_drop (GtkWidget *widget, int y, int *pos, int *other_pos) mg_handle_drop (GtkWidget *widget, int y, int *pos, int *other_pos)
{ {
int height; int height;
GdkWindow *window;
session_gui *gui = current_sess->gui; session_gui *gui = current_sess->gui;
window = gtk_widget_get_window (widget); height = gdk_window_get_height (gtk_widget_get_window (widget));
if (!window)
return;
height = gdk_window_get_height (window);
if (y < height / 2) if (y < height / 2)
{ {
@@ -5469,9 +5020,6 @@ mg_drag_begin_cb (GtkWidget *widget, GdkDragContext *context, gpointer userdata)
return FALSE; return FALSE;
window = gtk_widget_get_window (widget); window = gtk_widget_get_window (widget);
if (!window)
return FALSE;
width = gdk_window_get_width (window); width = gdk_window_get_width (window);
height = gdk_window_get_height (window); height = gdk_window_get_height (window);
@@ -5549,16 +5097,11 @@ mg_drag_motion_cb (GtkWidget *widget, GdkDragContext *context, int x, int y, gui
width = allocation.width; width = allocation.width;
height = allocation.height; height = allocation.height;
window = gtk_widget_get_window (widget); window = gtk_widget_get_window (widget);
if (!window)
return FALSE;
} }
else else
{ {
ox = oy = 0; ox = oy = 0;
window = gtk_widget_get_window (widget); window = gtk_widget_get_window (widget);
if (!window)
return FALSE;
width = gdk_window_get_width (window); width = gdk_window_get_width (window);
height = gdk_window_get_height (window); height = gdk_window_get_height (window);
} }
-2
View File
@@ -37,10 +37,8 @@ GtkWidget *mg_create_generic_tab (char *name, char *title, int force_toplevel, i
void mg_set_title (GtkWidget *button, char *title); void mg_set_title (GtkWidget *button, char *title);
void mg_set_access_icon (session_gui *gui, GdkPixbuf *pix, gboolean away); void mg_set_access_icon (session_gui *gui, GdkPixbuf *pix, gboolean away);
void mg_apply_setup (void); void mg_apply_setup (void);
void mg_apply_session_font_prefs (session_gui *gui);
void mg_close_sess (session *); void mg_close_sess (session *);
void mg_tab_close (session *sess); void mg_tab_close (session *sess);
void mg_reopen_closed_channel_tab (void);
void mg_detach (session *sess, int mode); void mg_detach (session *sess, int mode);
void mg_progressbar_create (session_gui *gui); void mg_progressbar_create (session_gui *gui);
void mg_progressbar_destroy (session_gui *gui); void mg_progressbar_destroy (session_gui *gui);
+65 -190
View File
@@ -1717,7 +1717,7 @@ menu_ctcpguiopen (void)
static void static void
menu_docs (GtkWidget *wid, gpointer none) menu_docs (GtkWidget *wid, gpointer none)
{ {
fe_open_url ("https://docs.zoitechat.org/en/latest/"); fe_open_url ("https://docs.zoitechat.zoite.net/en/latest/");
} }
/*static void /*static void
@@ -1755,6 +1755,44 @@ menu_change_layout (void)
} }
} }
void
menu_update_quit_accel (void)
{
GSList *list;
list = sess_list;
while (list)
{
session *sess = list->data;
session_gui *gui = sess->gui;
GtkWidget *item;
GtkAccelGroup *accel_group;
int enabled;
list = list->next;
if (!gui)
continue;
item = gui->menu_item[MENU_ID_QUIT];
if (!item)
continue;
enabled = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "zc-ctrlq-enabled"));
if (enabled == (int)prefs.hex_gui_ctrlq_quit)
continue;
accel_group = g_object_get_data (G_OBJECT (item), "zc-quit-accel-group");
if (!accel_group)
continue;
if (prefs.hex_gui_ctrlq_quit)
gtk_widget_add_accelerator (item, "activate", accel_group, GDK_KEY_q, STATE_CTRL, GTK_ACCEL_VISIBLE);
else
gtk_widget_remove_accelerator (item, accel_group, GDK_KEY_q, STATE_CTRL);
g_object_set_data (G_OBJECT (item), "zc-ctrlq-enabled", GINT_TO_POINTER (prefs.hex_gui_ctrlq_quit));
}
}
static void static void
menu_layout_cb (GtkWidget *item, gpointer none) menu_layout_cb (GtkWidget *item, gpointer none)
{ {
@@ -1824,7 +1862,7 @@ about_dialog_response (GtkDialog *dialog, int response, gpointer data)
{ {
if (response == GTK_RESPONSE_HELP) if (response == GTK_RESPONSE_HELP)
{ {
fe_open_url ("http://zoitechat.org"); fe_open_url ("http://zoitechat.zoite.net");
return; return;
} }
if (response == GTK_RESPONSE_APPLY) if (response == GTK_RESPONSE_APPLY)
@@ -1877,7 +1915,14 @@ menu_about (GtkWidget *wid, gpointer sess)
gtk_about_dialog_set_website_label (dialog, NULL); gtk_about_dialog_set_website_label (dialog, NULL);
gtk_about_dialog_set_license (dialog, NULL); gtk_about_dialog_set_license (dialog, NULL);
gtk_about_dialog_set_wrap_license (dialog, FALSE); gtk_about_dialog_set_wrap_license (dialog, FALSE);
gtk_about_dialog_set_logo (dialog, pix_zoitechat); GdkPixbuf *about_logo;
about_logo = gdk_pixbuf_new_from_resource_at_scale ("/icons/zoitechat.svg", 48, 48, TRUE, NULL);
if (!about_logo && pix_zoitechat)
about_logo = gdk_pixbuf_scale_simple (pix_zoitechat, 48, 48, GDK_INTERP_BILINEAR);
gtk_about_dialog_set_logo (dialog, about_logo ? about_logo : pix_zoitechat);
if (about_logo)
g_object_unref (about_logo);
gtk_about_dialog_set_copyright (dialog, "\302\251 1998-2010 Peter \305\275elezn\303\275\n\302\251 2009-2014 Berke Viktor\n\302\251 2015-2025 Patrick Griffis\n\302\251 2026 deepend"); gtk_about_dialog_set_copyright (dialog, "\302\251 1998-2010 Peter \305\275elezn\303\275\n\302\251 2009-2014 Berke Viktor\n\302\251 2015-2025 Patrick Griffis\n\302\251 2026 deepend");
gtk_about_dialog_set_comments (dialog, comment); gtk_about_dialog_set_comments (dialog, comment);
actions = gtk_dialog_get_action_area (GTK_DIALOG (dialog)); actions = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
@@ -1901,13 +1946,13 @@ menu_about (GtkWidget *wid, gpointer sess)
static struct mymenu mymenu[] = { static struct mymenu mymenu[] = {
{N_("_ZoiteChat"), 0, 0, M_NEWMENU, MENU_ID_ZOITECHAT, 0, 1}, {N_("_ZoiteChat"), 0, 0, M_NEWMENU, MENU_ID_ZOITECHAT, 0, 1},
{N_("Network Li_st"), menu_open_server_list, 0, M_MENUITEM, 0, 0, 1}, {N_("Network Li_st"), menu_open_server_list, 0, M_MENUITEM, 0, 0, 1, GDK_KEY_s},
{0, 0, 0, M_SEP, 0, 0, 0}, {0, 0, 0, M_SEP, 0, 0, 0},
{N_("_New"), 0, 0, M_MENUSUB, 0, 0, 1}, {N_("_New"), 0, 0, M_MENUSUB, 0, 0, 1},
{N_("Server Tab"), menu_newserver_tab, 0, M_MENUITEM, 0, 0, 1}, {N_("Server Tab"), menu_newserver_tab, 0, M_MENUITEM, 0, 0, 1, GDK_KEY_t},
{N_("Channel Tab"), menu_newchannel_tab, 0, M_MENUITEM, 0, 0, 1}, {N_("Channel Tab"), menu_newchannel_tab, 0, M_MENUITEM, 0, 0, 1},
{N_("Server Window"), menu_newserver_window, 0, M_MENUITEM, 0, 0, 1}, {N_("Server Window"), menu_newserver_window, 0, M_MENUITEM, 0, 0, 1, GDK_KEY_n},
{N_("Channel Window"), menu_newchannel_window, 0, M_MENUITEM, 0, 0, 1}, {N_("Channel Window"), menu_newchannel_window, 0, M_MENUITEM, 0, 0, 1},
{0, 0, 0, M_END, 0, 0, 0}, {0, 0, 0, M_END, 0, 0, 0},
{0, 0, 0, M_SEP, 0, 0, 0}, {0, 0, 0, M_SEP, 0, 0, 0},
@@ -1919,13 +1964,13 @@ static struct mymenu mymenu[] = {
#define CLOSE_OFFSET (13) #define CLOSE_OFFSET (13)
{0, menu_close, 0, M_MENUITEM, 0, 0, 1}, {0, menu_close, 0, M_MENUITEM, 0, 0, 1},
{0, 0, 0, M_SEP, 0, 0, 0}, {0, 0, 0, M_SEP, 0, 0, 0},
{N_("_Quit"), menu_quit, 0, M_MENUITEM, MENU_ID_QUIT, 0, 1}, /* 15 */ {N_("_Quit"), menu_quit, 0, M_MENUITEM, MENU_ID_QUIT, 0, 1, GDK_KEY_q}, /* 15 */
{N_("_View"), 0, 0, M_NEWMENU, 0, 0, 1}, {N_("_View"), 0, 0, M_NEWMENU, 0, 0, 1},
#define MENUBAR_OFFSET (17) #define MENUBAR_OFFSET (17)
{N_("_Menu Bar"), menu_bar_toggle_cb, 0, M_MENUTOG, MENU_ID_MENUBAR, 0, 1}, {N_("_Menu Bar"), menu_bar_toggle_cb, 0, M_MENUTOG, MENU_ID_MENUBAR, 0, 1, GDK_KEY_F9},
{N_("_Topic Bar"), menu_topicbar_toggle, 0, M_MENUTOG, MENU_ID_TOPICBAR, 0, 1}, {N_("_Topic Bar"), menu_topicbar_toggle, 0, M_MENUTOG, MENU_ID_TOPICBAR, 0, 1},
{N_("_User List"), menu_userlist_toggle, 0, M_MENUTOG, MENU_ID_USERLIST, 0, 1}, {N_("_User List"), menu_userlist_toggle, 0, M_MENUTOG, MENU_ID_USERLIST, 0, 1, GDK_KEY_F7},
{N_("U_ser List Buttons"), menu_ulbuttons_toggle, 0, M_MENUTOG, MENU_ID_ULBUTTONS, 0, 1}, {N_("U_ser List Buttons"), menu_ulbuttons_toggle, 0, M_MENUTOG, MENU_ID_ULBUTTONS, 0, 1},
{N_("M_ode Buttons"), menu_cmbuttons_toggle, 0, M_MENUTOG, MENU_ID_MODEBUTTONS, 0, 1}, {N_("M_ode Buttons"), menu_cmbuttons_toggle, 0, M_MENUTOG, MENU_ID_MODEBUTTONS, 0, 1},
{0, 0, 0, M_SEP, 0, 0, 0}, {0, 0, 0, M_SEP, 0, 0, 0},
@@ -1942,7 +1987,7 @@ static struct mymenu mymenu[] = {
{N_("Both"), menu_metres_both, 0, M_MENURADIO, 0, 0, 1}, {N_("Both"), menu_metres_both, 0, M_MENURADIO, 0, 0, 1},
{0, 0, 0, M_END, 0, 0, 0}, /* 32 */ {0, 0, 0, M_END, 0, 0, 0}, /* 32 */
{ 0, 0, 0, M_SEP, 0, 0, 0 }, { 0, 0, 0, M_SEP, 0, 0, 0 },
{N_ ("_Fullscreen"), menu_fullscreen_toggle, 0, M_MENUTOG, MENU_ID_FULLSCREEN, 0, 1}, {N_ ("_Fullscreen"), menu_fullscreen_toggle, 0, M_MENUTOG, MENU_ID_FULLSCREEN, 0, 1, GDK_KEY_F11},
{N_("_Server"), 0, 0, M_NEWMENU, 0, 0, 1}, {N_("_Server"), 0, 0, M_NEWMENU, 0, 0, 1},
{N_("_Disconnect"), menu_disconnect, 0, M_MENUITEM, MENU_ID_DISCONNECT, 0, 1}, {N_("_Disconnect"), menu_disconnect, 0, M_MENUITEM, MENU_ID_DISCONNECT, 0, 1},
@@ -1951,7 +1996,7 @@ static struct mymenu mymenu[] = {
{N_("Channel _List"), menu_chanlist, 0, M_MENUITEM, 0, 0, 1}, {N_("Channel _List"), menu_chanlist, 0, M_MENUITEM, 0, 0, 1},
{0, 0, 0, M_SEP, 0, 0, 0}, {0, 0, 0, M_SEP, 0, 0, 0},
#define AWAY_OFFSET (41) #define AWAY_OFFSET (41)
{N_("Marked _Away"), menu_away_toggle, 0, M_MENUITEM, MENU_ID_AWAY, 0, 1}, {N_("Marked _Away"), menu_away_toggle, 0, M_MENUITEM, MENU_ID_AWAY, 0, 1, GDK_KEY_a},
{N_("_Usermenu"), 0, 0, M_NEWMENU, MENU_ID_USERMENU, 0, 1}, /* 40 */ {N_("_Usermenu"), 0, 0, M_NEWMENU, MENU_ID_USERMENU, 0, 1}, /* 40 */
@@ -1979,191 +2024,25 @@ static struct mymenu mymenu[] = {
{N_("_Raw Log"), menu_rawlog, 0, M_MENUITEM, 0, 0, 1}, /* 61 */ {N_("_Raw Log"), menu_rawlog, 0, M_MENUITEM, 0, 0, 1}, /* 61 */
{N_("_URL Grabber"), url_opengui, 0, M_MENUITEM, 0, 0, 1}, {N_("_URL Grabber"), url_opengui, 0, M_MENUITEM, 0, 0, 1},
{0, 0, 0, M_SEP, 0, 0, 0}, {0, 0, 0, M_SEP, 0, 0, 0},
{N_("Reset Marker Line"), menu_resetmarker, 0, M_MENUITEM, 0, 0, 1}, {N_("Reset Marker Line"), menu_resetmarker, 0, M_MENUITEM, 0, 0, 1, GDK_KEY_m},
{N_("Move to Marker Line"), menu_movetomarker, 0, M_MENUITEM, 0, 0, 1}, {N_("Move to Marker Line"), menu_movetomarker, 0, M_MENUITEM, 0, 0, 1, GDK_KEY_M},
{N_("_Copy Selection"), menu_copy_selection, 0, M_MENUITEM, 0, 0, 1}, {N_("_Copy Selection"), menu_copy_selection, 0, M_MENUITEM, 0, 0, 1, GDK_KEY_C},
{N_("C_lear Text"), menu_flushbuffer, 0, M_MENUITEM, 0, 0, 1}, {N_("C_lear Text"), menu_flushbuffer, 0, M_MENUITEM, 0, 0, 1},
{N_("Save Text" ELLIPSIS), menu_savebuffer, 0, M_MENUITEM, 0, 0, 1}, {N_("Save Text" ELLIPSIS), menu_savebuffer, 0, M_MENUITEM, 0, 0, 1},
#define SEARCH_OFFSET (70) #define SEARCH_OFFSET (70)
{N_("Search"), 0, 0, M_MENUSUB, 0, 0, 1}, {N_("Search"), 0, 0, M_MENUSUB, 0, 0, 1},
{N_("Search Text" ELLIPSIS), menu_search, 0, M_MENUITEM, 0, 0, 1}, {N_("Search Text" ELLIPSIS), menu_search, 0, M_MENUITEM, 0, 0, 1, GDK_KEY_f},
{N_("Search Next" ), menu_search_next, 0, M_MENUITEM, 0, 0, 1}, {N_("Search Next" ), menu_search_next, 0, M_MENUITEM, 0, 0, 1, GDK_KEY_g},
{N_("Search Previous" ), menu_search_prev, 0, M_MENUITEM, 0, 0, 1}, {N_("Search Previous" ), menu_search_prev, 0, M_MENUITEM, 0, 0, 1, GDK_KEY_G},
{0, 0, 0, M_END, 0, 0, 0}, {0, 0, 0, M_END, 0, 0, 0},
{N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 74 */ {N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 74 */
{N_("_Contents"), menu_docs, 0, M_MENUITEM, 0, 0, 1}, {N_("_Contents"), menu_docs, 0, M_MENUITEM, 0, 0, 1, GDK_KEY_F1},
{N_("_About"), menu_about, 0, M_MENUITEM, 0, 0, 1}, {N_("_About"), menu_about, 0, M_MENUITEM, 0, 0, 1},
{0, 0, 0, M_END, 0, 0, 0}, {0, 0, 0, M_END, 0, 0, 0},
}; };
static const char *
menu_get_key_action_name (int index)
{
switch (index)
{
case 1:
return "network-list";
case 4:
return "new-server-tab";
case 6:
return "new-server-window";
case CLOSE_OFFSET:
return "close";
case 15:
return "quit";
case MENUBAR_OFFSET:
return "menu-toggle";
case MENUBAR_OFFSET + 2:
return "user-list-toggle";
case 34:
return "fullscreen-toggle";
case AWAY_OFFSET:
return "away-toggle";
case 65:
return "reset-marker";
case 66:
return "move-marker";
case 67:
return "copy-selection";
case SEARCH_OFFSET + 1:
return "search-text";
case SEARCH_OFFSET + 2:
return "search-next";
case SEARCH_OFFSET + 3:
return "search-previous";
case 75:
return "contents";
}
return NULL;
}
static void
menu_add_keybinding_accel (GtkWidget *item, GtkAccelGroup *accel_group, const char *name)
{
guint keyval;
GdkModifierType mod;
if (!accel_group || !key_get_menu_accel (name, &keyval, &mod))
return;
if (!strcmp (name, "quit") && !prefs.hex_gui_ctrlq_quit && keyval == GDK_KEY_q && mod == STATE_CTRL)
return;
gtk_widget_add_accelerator (item, "activate", accel_group, keyval, mod, GTK_ACCEL_VISIBLE);
g_object_set_data (G_OBJECT (item), "zc-key-accel-key", GUINT_TO_POINTER (keyval));
g_object_set_data (G_OBJECT (item), "zc-key-accel-mod", GUINT_TO_POINTER (mod));
}
static void
menu_refresh_keybinding_accels (GtkWidget *widget, gpointer data)
{
GtkAccelGroup *accel_group = data;
const char *name;
guint keyval;
GdkModifierType mod;
GtkWidget *submenu;
GList *children, *list;
if (GTK_IS_MENU_ITEM (widget))
{
keyval = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "zc-key-accel-key"));
mod = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "zc-key-accel-mod"));
if (keyval != 0)
{
gtk_widget_remove_accelerator (widget, accel_group, keyval, mod);
g_object_set_data (G_OBJECT (widget), "zc-key-accel-key", NULL);
g_object_set_data (G_OBJECT (widget), "zc-key-accel-mod", NULL);
}
name = g_object_get_data (G_OBJECT (widget), "zc-key-action");
menu_add_keybinding_accel (widget, accel_group, name);
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
if (submenu)
menu_refresh_keybinding_accels (submenu, data);
}
if (GTK_IS_CONTAINER (widget))
{
children = gtk_container_get_children (GTK_CONTAINER (widget));
for (list = children; list; list = g_list_next (list))
menu_refresh_keybinding_accels (list->data, data);
g_list_free (children);
}
}
void
menu_update_quit_accel (void)
{
session *sess;
GSList *list;
GtkAccelGroup *accel_group;
list = sess_list;
while (list)
{
sess = list->data;
if (sess && sess->gui && sess->gui->menu)
{
accel_group = g_object_get_data (G_OBJECT (sess->gui->menu), "accel");
if (accel_group)
menu_refresh_keybinding_accels (sess->gui->menu, accel_group);
}
list = g_slist_next (list);
}
}
gboolean
menu_key_action (const char *name, guint keyval, GdkModifierType state)
{
if (!name)
return FALSE;
if (!strcmp (name, "network-list"))
menu_open_server_list (NULL, NULL);
else if (!strcmp (name, "new-server-tab"))
menu_newserver_tab (NULL, NULL);
else if (!strcmp (name, "new-server-window"))
menu_newserver_window (NULL, NULL);
else if (!strcmp (name, "close"))
menu_close (NULL, NULL);
else if (!strcmp (name, "quit"))
{
if (!prefs.hex_gui_ctrlq_quit && keyval == GDK_KEY_q && (state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == STATE_CTRL)
return FALSE;
menu_quit (NULL, NULL);
}
else if (!strcmp (name, "menu-toggle"))
menu_bar_toggle_cb ();
else if (!strcmp (name, "user-list-toggle"))
menu_userlist_toggle (NULL, NULL);
else if (!strcmp (name, "fullscreen-toggle"))
menu_fullscreen_toggle (NULL, NULL);
else if (!strcmp (name, "away-toggle"))
menu_away_toggle (NULL, NULL);
else if (!strcmp (name, "reset-marker"))
menu_resetmarker (NULL, NULL);
else if (!strcmp (name, "move-marker"))
menu_movetomarker (NULL, NULL);
else if (!strcmp (name, "copy-selection"))
menu_copy_selection (NULL, NULL);
else if (!strcmp (name, "search-text"))
menu_search ();
else if (!strcmp (name, "search-next"))
menu_search_next (NULL);
else if (!strcmp (name, "search-previous"))
menu_search_prev (NULL);
else if (!strcmp (name, "contents"))
menu_docs (NULL, NULL);
else
return FALSE;
return TRUE;
}
void void
menu_set_away (session_gui *gui, int away) menu_set_away (session_gui *gui, int away)
{ {
@@ -2437,7 +2316,7 @@ menu_reorder (GtkMenu *menu, GtkWidget *item, int pos)
if (pos < 0) /* position offset from end/bottom */ if (pos < 0) /* position offset from end/bottom */
{ {
GList *children = gtk_container_get_children (GTK_CONTAINER (menu)); GList *children = gtk_container_get_children (GTK_CONTAINER (menu));
gint length = (gint) g_list_length (children); int length = g_list_length (children);
g_list_free (children); g_list_free (children);
gtk_menu_reorder_child (menu, item, (length + pos) - 1); gtk_menu_reorder_child (menu, item, (length + pos) - 1);
@@ -2509,7 +2388,7 @@ menu_add_sub (GtkWidget *menu, menu_entry *me)
if (pos < 0) /* position offset from end/bottom */ if (pos < 0) /* position offset from end/bottom */
{ {
GList *children = gtk_container_get_children (GTK_CONTAINER (menu)); GList *children = gtk_container_get_children (GTK_CONTAINER (menu));
gint length = (gint) g_list_length (children); int length = g_list_length (children);
g_list_free (children); g_list_free (children);
pos = length + pos; pos = length + pos;
@@ -2769,8 +2648,6 @@ menu_create_main (void *accel_group, int bar, int away, int toplevel,
case M_MENUITEM: case M_MENUITEM:
item = gtk_menu_item_new_with_mnemonic (_(mymenu[i].text)); item = gtk_menu_item_new_with_mnemonic (_(mymenu[i].text));
normalitem: normalitem:
g_object_set_data (G_OBJECT (item), "zc-key-action", (gpointer) menu_get_key_action_name (i));
menu_add_keybinding_accel (item, accel_group, menu_get_key_action_name (i));
if (mymenu[i].key != 0 && !(mymenu[i].id == MENU_ID_QUIT && !prefs.hex_gui_ctrlq_quit)) if (mymenu[i].key != 0 && !(mymenu[i].id == MENU_ID_QUIT && !prefs.hex_gui_ctrlq_quit))
gtk_widget_add_accelerator (item, "activate", accel_group, gtk_widget_add_accelerator (item, "activate", accel_group,
mymenu[i].key, mymenu[i].key,
@@ -2799,8 +2676,6 @@ normalitem:
case M_MENUTOG: case M_MENUTOG:
item = gtk_check_menu_item_new_with_mnemonic (_(mymenu[i].text)); item = gtk_check_menu_item_new_with_mnemonic (_(mymenu[i].text));
togitem: togitem:
g_object_set_data (G_OBJECT (item), "zc-key-action", (gpointer) menu_get_key_action_name (i));
menu_add_keybinding_accel (item, accel_group, menu_get_key_action_name (i));
/* must avoid callback for Radio buttons */ /* must avoid callback for Radio buttons */
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), mymenu[i].state); gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), mymenu[i].state);
/*gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), /*gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
-1
View File
@@ -39,7 +39,6 @@ void menu_bar_toggle (void);
void menu_add_plugin_items (GtkWidget *menu, char *root, char *target); void menu_add_plugin_items (GtkWidget *menu, char *root, char *target);
void menu_change_layout (void); void menu_change_layout (void);
void menu_update_quit_accel (void); void menu_update_quit_accel (void);
gboolean menu_key_action (const char *name, guint keyval, GdkModifierType state);
void menu_set_away (session_gui *gui, int away); void menu_set_away (session_gui *gui, int away);
void menu_set_fullscreen (session_gui *gui, int fullscreen); void menu_set_fullscreen (session_gui *gui, int fullscreen);
+37 -2
View File
@@ -117,9 +117,29 @@ if get_option('plugin')
zoitechat_gtk_sources += 'plugingui.c' zoitechat_gtk_sources += 'plugingui.c'
endif endif
find_program('magick', required: true)
zoitechat_png_generated = custom_target('zoitechat_resource_png',
input: '../../data/icons/zoitechat.svg',
output: 'zoitechat.png',
command: [find_program('../../data/icons/generate_icons.py'), '@INPUT@', '@OUTPUT@', '--size', '256'],
)
zoitechat_gresource_conf = configuration_data()
zoitechat_gresource_conf.set('ZOITECHAT_PNG', 'zoitechat.png')
zoitechat_gresource_xml = configure_file(
input: '../../data/zoitechat.gresource.xml.in',
output: 'zoitechat.gresource.xml',
configuration: zoitechat_gresource_conf,
)
resources = gnome.compile_resources('resources', resources = gnome.compile_resources('resources',
'../../data/zoitechat.gresource.xml', zoitechat_gresource_xml,
source_dir: '../../data', source_dir: [
meson.current_build_dir(),
'../../data',
],
dependencies: [zoitechat_png_generated],
c_name: 'zoitechat', c_name: 'zoitechat',
extra_args: ['--manual-register'] extra_args: ['--manual-register']
) )
@@ -227,6 +247,21 @@ test('Theme Access Routing Tests', theme_access_tests,
timeout: 120, timeout: 120,
) )
theme_gtk3_settings_tests = executable('theme_gtk3_settings_tests',
[
'theme/tests/test-theme-gtk3-settings.c',
'theme/theme-gtk3.c',
],
include_directories: [config_h_include],
dependencies: [gtk_dep],
)
test('Theme GTK3 Settings Tests', theme_gtk3_settings_tests,
protocol: 'tap',
timeout: 120,
)
theme_preferences_gtk3_populate_tests = executable('theme_preferences_gtk3_populate_tests', theme_preferences_gtk3_populate_tests = executable('theme_preferences_gtk3_populate_tests',
'theme/tests/test-theme-preferences-gtk3-populate.c', 'theme/tests/test-theme-preferences-gtk3-populate.c',
include_directories: [config_h_include], include_directories: [config_h_include],
@@ -56,7 +56,7 @@ notification_backend_show (const char *title, const char *text)
g_variant_builder_init (&params, G_VARIANT_TYPE ("(susssasa{sv}i)")); g_variant_builder_init (&params, G_VARIANT_TYPE ("(susssasa{sv}i)"));
g_variant_builder_add (&params, "s", "zoitechat"); /* App name */ g_variant_builder_add (&params, "s", "zoitechat"); /* App name */
g_variant_builder_add (&params, "u", 0); /* ID, 0 means don't replace */ g_variant_builder_add (&params, "u", 0); /* ID, 0 means don't replace */
g_variant_builder_add (&params, "s", "net.zoite.Zoitechat"); /* App icon */ g_variant_builder_add (&params, "s", "io.github.Hexchat"); /* App icon */
g_variant_builder_add (&params, "s", title); g_variant_builder_add (&params, "s", title);
g_variant_builder_add (&params, "s", text); g_variant_builder_add (&params, "s", text);
g_variant_builder_add (&params, "as", NULL); /* Actions */ g_variant_builder_add (&params, "as", NULL); /* Actions */
@@ -65,7 +65,7 @@ notification_backend_show (const char *title, const char *text)
g_variant_builder_open (&params, G_VARIANT_TYPE ("a{sv}")); g_variant_builder_open (&params, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_open (&params, G_VARIANT_TYPE ("{sv}")); g_variant_builder_open (&params, G_VARIANT_TYPE ("{sv}"));
g_variant_builder_add (&params, "s", "desktop-entry"); g_variant_builder_add (&params, "s", "desktop-entry");
g_variant_builder_add (&params, "v", g_variant_new_string ("net.zoite.Zoitechat")); g_variant_builder_add (&params, "v", g_variant_new_string ("io.github.Hexchat"));
g_variant_builder_close (&params); g_variant_builder_close (&params);
g_variant_builder_close (&params); g_variant_builder_close (&params);
+6 -13
View File
@@ -855,7 +855,6 @@ tray_toggle_visibility (gboolean force_hide)
static int maximized; static int maximized;
static int fullscreen; static int fullscreen;
GtkWindow *win; GtkWindow *win;
WinStatus status;
if (!tray_backend_active) if (!tray_backend_active)
return FALSE; return FALSE;
@@ -871,9 +870,7 @@ tray_toggle_visibility (gboolean force_hide)
if (!win) if (!win)
return FALSE; return FALSE;
status = tray_get_window_status (); if (force_hide || gtk_widget_get_visible (GTK_WIDGET (win)))
if (force_hide || status != WS_HIDDEN)
{ {
if (prefs.hex_gui_tray_away) if (prefs.hex_gui_tray_away)
zoitechat_command (ph, "ALLSERV AWAY"); zoitechat_command (ph, "ALLSERV AWAY");
@@ -893,8 +890,8 @@ tray_toggle_visibility (gboolean force_hide)
gtk_window_maximize (win); gtk_window_maximize (win);
if (fullscreen) if (fullscreen)
gtk_window_fullscreen (win); gtk_window_fullscreen (win);
gtk_window_deiconify (win);
gtk_widget_show (GTK_WIDGET (win)); gtk_widget_show (GTK_WIDGET (win));
gtk_window_deiconify (win);
gtk_window_present (win); gtk_window_present (win);
} }
@@ -923,10 +920,7 @@ tray_menu_notify_cb (GObject *tray, GParamSpec *pspec, gpointer user_data)
{ {
if (!tray_backend_is_embedded ()) if (!tray_backend_is_embedded ())
{ {
if (!tray_restore_timer) tray_restore_timer = g_timeout_add(500, (GSourceFunc)tray_menu_try_restore, NULL);
{
tray_restore_timer = g_timeout_add (500, (GSourceFunc) tray_menu_try_restore, NULL);
}
} }
else else
{ {
@@ -942,10 +936,9 @@ tray_menu_notify_cb (GObject *tray, GParamSpec *pspec, gpointer user_data)
static gboolean static gboolean
tray_menu_try_restore (void) tray_menu_try_restore (void)
{ {
tray_restore_timer = 0; tray_cleanup();
tray_cleanup (); tray_init();
tray_init (); return TRUE;
return G_SOURCE_REMOVE;
} }
static void static void
+14 -421
View File
@@ -29,7 +29,6 @@
#include "../common/servlist.h" #include "../common/servlist.h"
#include "../common/cfgfiles.h" #include "../common/cfgfiles.h"
#include "../common/fe.h" #include "../common/fe.h"
#include "../common/secretstore.h"
#include "../common/util.h" #include "../common/util.h"
#include "fe-gtk.h" #include "fe-gtk.h"
@@ -86,19 +85,12 @@ static GtkWidget *edit_entry_nick2;
static GtkWidget *edit_entry_user; static GtkWidget *edit_entry_user;
static GtkWidget *edit_entry_real; static GtkWidget *edit_entry_real;
static GtkWidget *edit_entry_pass; static GtkWidget *edit_entry_pass;
static GtkWidget *edit_check_show_pass;
static GtkWidget *edit_check_use_keyring;
static GtkWidget *edit_button_encrypt_pass;
static GtkWidget *edit_button_import_pass;
static int edit_pass_changed;
static char *edit_loaded_password;
static GtkWidget *edit_label_nick; static GtkWidget *edit_label_nick;
static GtkWidget *edit_label_nick2; static GtkWidget *edit_label_nick2;
static GtkWidget *edit_label_real; static GtkWidget *edit_label_real;
static GtkWidget *edit_label_user; static GtkWidget *edit_label_user;
static GtkWidget *edit_trees[N_TREES]; static GtkWidget *edit_trees[N_TREES];
static GtkWidget *edit_button_cert_generate; static GtkWidget *edit_button_cert_generate;
static GtkWidget *edit_button_cert_import;
static GtkWidget *edit_button_cert_info; static GtkWidget *edit_button_cert_info;
static GtkWidget *edit_button_cert_delete; static GtkWidget *edit_button_cert_delete;
@@ -110,168 +102,6 @@ static session *servlist_sess;
static void servlist_network_row_cb (GtkTreeSelection *sel, gpointer user_data); static void servlist_network_row_cb (GtkTreeSelection *sel, gpointer user_data);
static GtkWidget *servlist_open_edit (GtkWidget *parent, ircnet *net); static GtkWidget *servlist_open_edit (GtkWidget *parent, ircnet *net);
static void servlist_password_changed_cb (GtkEditable *editable, gpointer userdata);
static void
servlist_update_password_tools (ircnet *net)
{
gboolean has_local;
gboolean use_keyring;
if (!edit_button_encrypt_pass || !edit_button_import_pass)
return;
use_keyring = net && (net->flags & FLAG_USE_KEYRING);
has_local = net && net->pass && *net->pass && !use_keyring && !edit_pass_changed;
gtk_widget_set_sensitive (edit_button_encrypt_pass, has_local && !servlist_password_is_encrypted (net->pass));
gtk_widget_set_sensitive (edit_button_import_pass, has_local);
}
static void
servlist_entry_set_text_silent (GtkWidget *entry, const char *text)
{
g_signal_handlers_block_by_func (G_OBJECT (entry), G_CALLBACK (servlist_password_changed_cb), NULL);
gtk_entry_set_text (GTK_ENTRY (entry), text);
g_signal_handlers_unblock_by_func (G_OBJECT (entry), G_CALLBACK (servlist_password_changed_cb), NULL);
}
static char *
servlist_display_password (ircnet *net)
{
if (!net)
return NULL;
if (edit_pass_changed)
return g_strdup (gtk_entry_get_text (GTK_ENTRY (edit_entry_pass)));
if (edit_loaded_password)
return g_strdup (edit_loaded_password);
if (net->flags & FLAG_USE_KEYRING)
return secretstore_get_network_password (net->name);
return servlist_password_decrypt_for_storage (net->pass);
}
static void
servlist_toggle_show_password_cb (GtkToggleButton *toggle, gpointer userdata)
{
if (gtk_toggle_button_get_active (toggle))
{
char *password = servlist_display_password (selected_net);
if (password)
{
if (edit_loaded_password)
{
memset (edit_loaded_password, 0, strlen (edit_loaded_password));
g_free (edit_loaded_password);
}
edit_loaded_password = g_strdup (password);
servlist_entry_set_text_silent (userdata, password);
memset (password, 0, strlen (password));
g_free (password);
}
gtk_entry_set_visibility (GTK_ENTRY (userdata), TRUE);
}
else
{
gtk_entry_set_visibility (GTK_ENTRY (userdata), FALSE);
if (edit_loaded_password && !edit_pass_changed)
servlist_entry_set_text_silent (userdata, "***");
}
}
static void
servlist_toggle_keyring_cb (GtkToggleButton *toggle, gpointer userdata)
{
servlist_update_password_tools (selected_net);
}
static void
servlist_password_changed_cb (GtkEditable *editable, gpointer userdata)
{
edit_pass_changed = 1;
if (edit_loaded_password && strcmp (gtk_entry_get_text (GTK_ENTRY (editable)), "***"))
{
memset (edit_loaded_password, 0, strlen (edit_loaded_password));
g_free (edit_loaded_password);
edit_loaded_password = NULL;
}
servlist_update_password_tools (selected_net);
}
static void
servlist_encrypt_password_cb (GtkWidget *button, gpointer userdata)
{
ircnet *net = userdata;
char *plain;
char *enc;
if (!net || (net->flags & FLAG_USE_KEYRING) || !net->pass || servlist_password_is_encrypted (net->pass))
return;
plain = servlist_password_decrypt_for_storage (net->pass);
if (!plain || !*plain)
{
if (plain)
{
memset (plain, 0, strlen (plain));
g_free (plain);
}
return;
}
enc = servlist_password_encrypt_for_storage (plain);
memset (plain, 0, strlen (plain));
g_free (plain);
if (!enc)
{
fe_message (_("Could not encrypt this password."), FE_MSG_WARN);
return;
}
g_free (net->pass);
net->pass = enc;
servlist_save ();
servlist_update_password_tools (net);
}
static void
servlist_import_password_cb (GtkWidget *button, gpointer userdata)
{
ircnet *net = userdata;
char *plain;
if (!net || !net->name || (net->flags & FLAG_USE_KEYRING) || !net->pass || !*net->pass)
return;
plain = servlist_password_decrypt_for_storage (net->pass);
if (!plain || !*plain)
{
if (plain)
{
memset (plain, 0, strlen (plain));
g_free (plain);
}
return;
}
if (!secretstore_set_network_password (net->name, plain))
{
memset (plain, 0, strlen (plain));
g_free (plain);
fe_message (_("Could not move this password into the system keyring."), FE_MSG_WARN);
return;
}
memset (plain, 0, strlen (plain));
g_free (plain);
g_free (net->pass);
net->pass = NULL;
net->flags |= FLAG_USE_KEYRING;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (edit_check_use_keyring), TRUE);
servlist_entry_set_text_silent (edit_entry_pass, "***");
edit_pass_changed = 0;
servlist_save ();
servlist_update_password_tools (net);
}
static char * static char *
servlist_get_cert_file (ircnet *net) servlist_get_cert_file (ircnet *net)
@@ -305,98 +135,12 @@ servlist_update_cert_buttons (ircnet *net)
if (edit_button_cert_generate) if (edit_button_cert_generate)
gtk_widget_set_visible (edit_button_cert_generate, !has_cert); gtk_widget_set_visible (edit_button_cert_generate, !has_cert);
if (edit_button_cert_import)
gtk_widget_set_visible (edit_button_cert_import, !has_cert);
if (edit_button_cert_info) if (edit_button_cert_info)
gtk_widget_set_visible (edit_button_cert_info, has_cert); gtk_widget_set_visible (edit_button_cert_info, has_cert);
if (edit_button_cert_delete) if (edit_button_cert_delete)
gtk_widget_set_visible (edit_button_cert_delete, has_cert); gtk_widget_set_visible (edit_button_cert_delete, has_cert);
} }
static void
servlist_import_client_cert_cb (GtkWidget *button, gpointer userdata)
{
ircnet *net = (ircnet *)userdata;
GtkWidget *dialog;
GtkWidget *message;
GtkFileFilter *filter;
char *cert_dir;
char *cert_file;
char *source_file;
char *contents;
gsize length;
if (!net || !net->name || !net->name[0])
return;
dialog = gtk_file_chooser_dialog_new (_("Import Client Certificate"),
GTK_WINDOW (edit_win),
GTK_FILE_CHOOSER_ACTION_OPEN,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Open"), GTK_RESPONSE_ACCEPT,
NULL);
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("Certificate files"));
gtk_file_filter_add_pattern (filter, "*.pem");
gtk_file_filter_add_pattern (filter, "*.crt");
gtk_file_filter_add_pattern (filter, "*.cer");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("All files"));
gtk_file_filter_add_pattern (filter, "*");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
theme_manager_attach_window (dialog);
if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT)
{
gtk_widget_destroy (dialog);
return;
}
source_file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
gtk_widget_destroy (dialog);
if (!source_file)
return;
cert_dir = g_build_filename (get_xdir (), "certs", NULL);
cert_file = servlist_get_cert_file (net);
contents = NULL;
length = 0;
if (cert_file &&
g_mkdir_with_parents (cert_dir, 0700) == 0 &&
g_file_get_contents (source_file, &contents, &length, NULL) &&
g_file_set_contents (cert_file, contents, length, NULL))
{
chmod (cert_file, 0600);
servlist_update_cert_buttons (net);
message = gtk_message_dialog_new (GTK_WINDOW (edit_win),
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
_("Client certificate imported for \"%s\"."),
net->name);
}
else
{
message = gtk_message_dialog_new (GTK_WINDOW (edit_win),
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
_("Failed to import client certificate for \"%s\"."),
net->name);
}
theme_manager_attach_window (message);
g_signal_connect_swapped (message, "response", G_CALLBACK (gtk_widget_destroy), message);
gtk_widget_show (message);
g_free (contents);
g_free (cert_file);
g_free (cert_dir);
g_free (source_file);
}
static void static void
servlist_generate_client_cert_cb (GtkWidget *button, gpointer userdata) servlist_generate_client_cert_cb (GtkWidget *button, gpointer userdata)
{ {
@@ -421,7 +165,6 @@ servlist_generate_client_cert_cb (GtkWidget *button, gpointer userdata)
gboolean success; gboolean success;
gint status; gint status;
char *argv[20]; char *argv[20];
char **envp;
if (!net || !net->name || !net->name[0]) if (!net || !net->name || !net->name[0])
return; return;
@@ -444,7 +187,6 @@ servlist_generate_client_cert_cb (GtkWidget *button, gpointer userdata)
crt_len = 0; crt_len = 0;
success = FALSE; success = FALSE;
status = 0; status = 0;
envp = g_environ_unsetenv (g_get_environ (), "LD_LIBRARY_PATH");
if (g_mkdir_with_parents (cert_dir, 0700) == 0 && if (g_mkdir_with_parents (cert_dir, 0700) == 0 &&
g_file_set_contents (openssl_conf, conf_data, -1, NULL)) g_file_set_contents (openssl_conf, conf_data, -1, NULL))
@@ -470,7 +212,7 @@ servlist_generate_client_cert_cb (GtkWidget *button, gpointer userdata)
argv[18] = subject; argv[18] = subject;
argv[19] = NULL; argv[19] = NULL;
spawned = g_spawn_sync (NULL, argv, envp, G_SPAWN_SEARCH_PATH, NULL, NULL, spawned = g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
&stdout_data, &stderr_data, &status, NULL); &stdout_data, &stderr_data, &status, NULL);
if (spawned && g_spawn_check_exit_status (status, NULL) && if (spawned && g_spawn_check_exit_status (status, NULL) &&
g_file_get_contents (key_file, &key_data, &key_len, NULL) && g_file_get_contents (key_file, &key_data, &key_len, NULL) &&
@@ -525,7 +267,6 @@ servlist_generate_client_cert_cb (GtkWidget *button, gpointer userdata)
g_free (openssl_conf); g_free (openssl_conf);
g_free (cert_file); g_free (cert_file);
g_free (cert_dir); g_free (cert_dir);
g_strfreev (envp);
#else #else
return; return;
#endif #endif
@@ -543,7 +284,6 @@ servlist_cert_info_cb (GtkWidget *button, gpointer userdata)
gboolean spawned; gboolean spawned;
gint status; gint status;
char *argv[12]; char *argv[12];
char **envp;
cert_file = servlist_get_cert_file (net); cert_file = servlist_get_cert_file (net);
if (!cert_file) if (!cert_file)
@@ -552,7 +292,6 @@ servlist_cert_info_cb (GtkWidget *button, gpointer userdata)
stdout_data = NULL; stdout_data = NULL;
stderr_data = NULL; stderr_data = NULL;
status = 0; status = 0;
envp = g_environ_unsetenv (g_get_environ (), "LD_LIBRARY_PATH");
argv[0] = "openssl"; argv[0] = "openssl";
argv[1] = "x509"; argv[1] = "x509";
argv[2] = "-in"; argv[2] = "-in";
@@ -566,7 +305,7 @@ servlist_cert_info_cb (GtkWidget *button, gpointer userdata)
argv[10] = "-sha256"; argv[10] = "-sha256";
argv[11] = NULL; argv[11] = NULL;
spawned = g_spawn_sync (NULL, argv, envp, G_SPAWN_SEARCH_PATH, NULL, NULL, spawned = g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
&stdout_data, &stderr_data, &status, NULL); &stdout_data, &stderr_data, &status, NULL);
if (spawned && g_spawn_check_exit_status (status, NULL) && stdout_data && stdout_data[0]) if (spawned && g_spawn_check_exit_status (status, NULL) && stdout_data && stdout_data[0])
@@ -597,7 +336,6 @@ servlist_cert_info_cb (GtkWidget *button, gpointer userdata)
g_free (stdout_data); g_free (stdout_data);
g_free (stderr_data); g_free (stderr_data);
g_free (cert_file); g_free (cert_file);
g_strfreev (envp);
#else #else
return; return;
#endif #endif
@@ -1247,79 +985,14 @@ servlist_update_from_entry (char **str, GtkWidget *entry)
*str = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); *str = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
} }
static char *
servlist_edit_current_password (ircnet *net)
{
if (!net)
return NULL;
if (net->flags & FLAG_USE_KEYRING)
return secretstore_get_network_password (net->name);
return servlist_password_decrypt_for_storage (net->pass);
}
static void static void
servlist_edit_update (ircnet *net) servlist_edit_update (ircnet *net)
{ {
gboolean use_keyring;
gboolean keyring_changed;
char *password = NULL;
servlist_update_from_entry (&net->nick, edit_entry_nick); servlist_update_from_entry (&net->nick, edit_entry_nick);
servlist_update_from_entry (&net->nick2, edit_entry_nick2); servlist_update_from_entry (&net->nick2, edit_entry_nick2);
servlist_update_from_entry (&net->user, edit_entry_user); servlist_update_from_entry (&net->user, edit_entry_user);
servlist_update_from_entry (&net->real, edit_entry_real); servlist_update_from_entry (&net->real, edit_entry_real);
if (net && net->name) servlist_update_from_entry (&net->pass, edit_entry_pass);
{
use_keyring = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (edit_check_use_keyring));
keyring_changed = !!(net->flags & FLAG_USE_KEYRING) != !!use_keyring;
if (!edit_pass_changed && !keyring_changed)
return;
if (edit_pass_changed)
password = g_strdup (gtk_entry_get_text (GTK_ENTRY (edit_entry_pass)));
else
password = servlist_edit_current_password (net);
if (use_keyring)
{
if (password && *password)
{
if (!secretstore_set_network_password (net->name, password))
{
fe_message (_("No system keyring is available. ZoiteChat can save this password using local encrypted fallback storage, but it is less protected than your desktop keyring."), FE_MSG_WARN);
memset (password, 0, strlen (password));
g_free (password);
return;
}
}
else
secretstore_delete_network_password (net->name);
net->flags |= FLAG_USE_KEYRING;
g_free (net->pass);
net->pass = NULL;
}
else
{
char *enc = NULL;
if (password && *password)
{
enc = servlist_password_encrypt_for_storage (password);
if (!enc)
{
fe_message (_("Could not encrypt this password."), FE_MSG_WARN);
memset (password, 0, strlen (password));
g_free (password);
return;
}
}
secretstore_delete_network_password (net->name);
net->flags &= ~FLAG_USE_KEYRING;
g_free (net->pass);
net->pass = enc;
}
if (password)
{
memset (password, 0, strlen (password));
g_free (password);
}
}
} }
static void static void
@@ -1327,19 +1000,9 @@ servlist_edit_close_cb (GtkWidget *button, gpointer userdata)
{ {
if (selected_net) if (selected_net)
servlist_edit_update (selected_net); servlist_edit_update (selected_net);
if (edit_loaded_password)
{
memset (edit_loaded_password, 0, strlen (edit_loaded_password));
g_free (edit_loaded_password);
edit_loaded_password = NULL;
}
gtk_widget_destroy (edit_win); gtk_widget_destroy (edit_win);
edit_win = NULL; edit_win = NULL;
edit_entry_pass = NULL;
edit_check_show_pass = NULL;
edit_button_encrypt_pass = NULL;
edit_button_import_pass = NULL;
} }
static gint static gint
@@ -1370,10 +1033,6 @@ servlist_edit_cb (GtkWidget *but, gpointer none)
{ {
if (!servlist_has_selection (GTK_TREE_VIEW (networks_tree))) if (!servlist_has_selection (GTK_TREE_VIEW (networks_tree)))
return; return;
if (!selected_net || !selected_net->name)
return;
if ((selected_net->flags & FLAG_USE_KEYRING) && !secretstore_require_unlock (selected_net->name))
return;
edit_win = servlist_open_edit (serverlist_win, selected_net); edit_win = servlist_open_edit (serverlist_win, selected_net);
gtkutil_set_icon (edit_win); gtkutil_set_icon (edit_win);
@@ -2565,7 +2224,7 @@ servlist_open_edit (GtkWidget *parent, ircnet *net)
/* Checkboxes and entries */ /* Checkboxes and entries */
table3 = gtkutil_grid_new (17, 2, FALSE); table3 = gtkutil_grid_new (14, 2, FALSE);
gtk_box_pack_start (GTK_BOX (vbox5), table3, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox5), table3, FALSE, FALSE, 0);
gtk_grid_set_row_spacing (GTK_GRID (table3), 2); gtk_grid_set_row_spacing (GTK_GRID (table3), 2);
gtk_grid_set_column_spacing (GTK_GRID (table3), 8); gtk_grid_set_column_spacing (GTK_GRID (table3), 8);
@@ -2584,97 +2243,38 @@ servlist_open_edit (GtkWidget *parent, ircnet *net)
#endif #endif
servlist_create_check (1, net->flags & FLAG_USE_GLOBAL, table3, 5, 0, _("Use global user information")); servlist_create_check (1, net->flags & FLAG_USE_GLOBAL, table3, 5, 0, _("Use global user information"));
edit_check_use_keyring = gtk_check_button_new_with_mnemonic (_("Use system keyring")); edit_entry_nick = servlist_create_entry (table3, _("_Nick name:"), 6, net->nick, &edit_label_nick, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (edit_check_use_keyring), net->flags & FLAG_USE_KEYRING); edit_entry_nick2 = servlist_create_entry (table3, _("Second choice:"), 7, net->nick2, &edit_label_nick2, 0);
servlist_table_attach (table3, edit_check_use_keyring, 0, 2, 6, 7, edit_entry_real = servlist_create_entry (table3, _("Rea_l name:"), 8, net->real, &edit_label_real, 0);
FALSE, FALSE, edit_entry_user = servlist_create_entry (table3, _("_User name:"), 9, net->user, &edit_label_user, 0);
SERVLIST_ALIGN_START, SERVLIST_ALIGN_CENTER,
SERVLIST_X_PADDING, SERVLIST_Y_PADDING);
g_signal_connect (G_OBJECT (edit_check_use_keyring), "toggled",
G_CALLBACK (servlist_toggle_keyring_cb), NULL);
edit_entry_nick = servlist_create_entry (table3, _("_Nick name:"), 7, net->nick, &edit_label_nick, 0);
edit_entry_nick2 = servlist_create_entry (table3, _("Second choice:"), 8, net->nick2, &edit_label_nick2, 0);
edit_entry_real = servlist_create_entry (table3, _("Rea_l name:"), 9, net->real, &edit_label_real, 0);
edit_entry_user = servlist_create_entry (table3, _("_User name:"), 10, net->user, &edit_label_user, 0);
label_logintype = gtk_label_new (_("Login method:")); label_logintype = gtk_label_new (_("Login method:"));
servlist_table_attach (table3, label_logintype, 0, 1, 11, 12, servlist_table_attach (table3, label_logintype, 0, 1, 10, 11,
FALSE, FALSE, FALSE, FALSE,
SERVLIST_ALIGN_START, SERVLIST_ALIGN_CENTER, SERVLIST_ALIGN_START, SERVLIST_ALIGN_CENTER,
SERVLIST_X_PADDING, SERVLIST_Y_PADDING); SERVLIST_X_PADDING, SERVLIST_Y_PADDING);
gtk_widget_set_halign (label_logintype, GTK_ALIGN_START); gtk_widget_set_halign (label_logintype, GTK_ALIGN_START);
gtk_widget_set_valign (label_logintype, GTK_ALIGN_CENTER); gtk_widget_set_valign (label_logintype, GTK_ALIGN_CENTER);
combobox_logintypes = servlist_create_logintypecombo (notebook); combobox_logintypes = servlist_create_logintypecombo (notebook);
servlist_table_attach (table3, combobox_logintypes, 1, 2, 11, 12, servlist_table_attach (table3, combobox_logintypes, 1, 2, 10, 11,
FALSE, FALSE, FALSE, FALSE,
SERVLIST_ALIGN_FILL, SERVLIST_ALIGN_FILL, SERVLIST_ALIGN_FILL, SERVLIST_ALIGN_FILL,
4, 2); 4, 2);
edit_entry_pass = servlist_create_entry (table3, _("Password:"), 12, NULL, 0, _("Password used for login. If in doubt, leave blank.")); edit_entry_pass = servlist_create_entry (table3, _("Password:"), 11, net->pass, 0, _("Password used for login. If in doubt, leave blank."));
if (edit_loaded_password)
{
memset (edit_loaded_password, 0, strlen (edit_loaded_password));
g_free (edit_loaded_password);
edit_loaded_password = NULL;
}
edit_pass_changed = 0;
g_signal_connect (G_OBJECT (edit_entry_pass), "changed",
G_CALLBACK (servlist_password_changed_cb), NULL);
if (net->flags & FLAG_USE_KEYRING)
{
char *stored = secretstore_get_network_password (net->name);
if (stored && *stored)
{
edit_loaded_password = g_strdup (stored);
servlist_entry_set_text_silent (edit_entry_pass, "***");
}
if (stored)
{
memset (stored, 0, strlen (stored));
g_free (stored);
}
}
else if (net->pass && *net->pass)
{
servlist_entry_set_text_silent (edit_entry_pass, "***");
}
edit_pass_changed = 0;
gtk_entry_set_visibility (GTK_ENTRY (edit_entry_pass), FALSE); gtk_entry_set_visibility (GTK_ENTRY (edit_entry_pass), FALSE);
if (selected_net && selected_net->logintype == LOGIN_SASLEXTERNAL) if (selected_net && selected_net->logintype == LOGIN_SASLEXTERNAL)
gtk_widget_set_sensitive (edit_entry_pass, FALSE); gtk_widget_set_sensitive (edit_entry_pass, FALSE);
edit_check_show_pass = gtk_check_button_new_with_mnemonic (_("Show password"));
servlist_table_attach (table3, edit_check_show_pass, 0, 2, 13, 14,
FALSE, FALSE,
SERVLIST_ALIGN_START, SERVLIST_ALIGN_CENTER,
4, 2);
g_signal_connect (G_OBJECT (edit_check_show_pass), "toggled",
G_CALLBACK (servlist_toggle_show_password_cb), edit_entry_pass);
edit_button_encrypt_pass = gtk_button_new_with_mnemonic (_("Encrypt saved password"));
servlist_table_attach (table3, edit_button_encrypt_pass, 0, 1, 14, 15,
FALSE, FALSE,
SERVLIST_ALIGN_START, SERVLIST_ALIGN_CENTER,
SERVLIST_X_PADDING, SERVLIST_Y_PADDING);
g_signal_connect (G_OBJECT (edit_button_encrypt_pass), "clicked",
G_CALLBACK (servlist_encrypt_password_cb), net);
edit_button_import_pass = gtk_button_new_with_mnemonic (_("Move password to keyring"));
servlist_table_attach (table3, edit_button_import_pass, 1, 2, 14, 15,
FALSE, FALSE,
SERVLIST_ALIGN_START, SERVLIST_ALIGN_CENTER,
4, 2);
g_signal_connect (G_OBJECT (edit_button_import_pass), "clicked",
G_CALLBACK (servlist_import_password_cb), net);
label34 = gtk_label_new (_("Character set:")); label34 = gtk_label_new (_("Character set:"));
servlist_table_attach (table3, label34, 0, 1, 15, 16, servlist_table_attach (table3, label34, 0, 1, 12, 13,
FALSE, FALSE, FALSE, FALSE,
SERVLIST_ALIGN_START, SERVLIST_ALIGN_CENTER, SERVLIST_ALIGN_START, SERVLIST_ALIGN_CENTER,
SERVLIST_X_PADDING, SERVLIST_Y_PADDING); SERVLIST_X_PADDING, SERVLIST_Y_PADDING);
gtk_widget_set_halign (label34, GTK_ALIGN_START); gtk_widget_set_halign (label34, GTK_ALIGN_START);
gtk_widget_set_valign (label34, GTK_ALIGN_CENTER); gtk_widget_set_valign (label34, GTK_ALIGN_CENTER);
comboboxentry_charset = servlist_create_charsetcombo (); comboboxentry_charset = servlist_create_charsetcombo ();
servlist_table_attach (table3, comboboxentry_charset, 1, 2, 15, 16, servlist_table_attach (table3, comboboxentry_charset, 1, 2, 12, 13,
FALSE, FALSE, FALSE, FALSE,
SERVLIST_ALIGN_FILL, SERVLIST_ALIGN_FILL, SERVLIST_ALIGN_FILL, SERVLIST_ALIGN_FILL,
4, 2); 4, 2);
@@ -2685,11 +2285,6 @@ servlist_open_edit (GtkWidget *parent, ircnet *net)
G_CALLBACK (servlist_generate_client_cert_cb), net); G_CALLBACK (servlist_generate_client_cert_cb), net);
gtk_box_pack_start (GTK_BOX (hbox_cert_buttons), edit_button_cert_generate, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox_cert_buttons), edit_button_cert_generate, FALSE, FALSE, 0);
edit_button_cert_import = gtk_button_new_with_mnemonic (_("Import client SSL cert"));
g_signal_connect (G_OBJECT (edit_button_cert_import), "clicked",
G_CALLBACK (servlist_import_client_cert_cb), net);
gtk_box_pack_start (GTK_BOX (hbox_cert_buttons), edit_button_cert_import, FALSE, FALSE, 0);
edit_button_cert_info = gtk_button_new_with_mnemonic (_("Client SSL cert info")); edit_button_cert_info = gtk_button_new_with_mnemonic (_("Client SSL cert info"));
g_signal_connect (G_OBJECT (edit_button_cert_info), "clicked", g_signal_connect (G_OBJECT (edit_button_cert_info), "clicked",
G_CALLBACK (servlist_cert_info_cb), net); G_CALLBACK (servlist_cert_info_cb), net);
@@ -2700,7 +2295,7 @@ servlist_open_edit (GtkWidget *parent, ircnet *net)
G_CALLBACK (servlist_delete_client_cert_cb), net); G_CALLBACK (servlist_delete_client_cert_cb), net);
gtk_box_pack_start (GTK_BOX (hbox_cert_buttons), edit_button_cert_delete, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox_cert_buttons), edit_button_cert_delete, FALSE, FALSE, 0);
servlist_table_attach (table3, hbox_cert_buttons, 0, 2, 16, 17, servlist_table_attach (table3, hbox_cert_buttons, 0, 2, 13, 14,
FALSE, FALSE, FALSE, FALSE,
SERVLIST_ALIGN_START, SERVLIST_ALIGN_CENTER, SERVLIST_ALIGN_START, SERVLIST_ALIGN_CENTER,
SERVLIST_X_PADDING, SERVLIST_Y_PADDING); SERVLIST_X_PADDING, SERVLIST_Y_PADDING);
@@ -2724,8 +2319,6 @@ servlist_open_edit (GtkWidget *parent, ircnet *net)
{ {
servlist_toggle_global_user (FALSE); servlist_toggle_global_user (FALSE);
} }
servlist_toggle_keyring_cb (GTK_TOGGLE_BUTTON (edit_check_use_keyring), NULL);
servlist_update_password_tools (net);
gtk_widget_grab_focus (button10); gtk_widget_grab_focus (button10);
gtk_widget_grab_default (button10); gtk_widget_grab_default (button10);
+7 -138
View File
@@ -58,7 +58,6 @@ static gboolean color_change;
static struct zoitechatprefs setup_prefs; static struct zoitechatprefs setup_prefs;
static GtkWidget *cancel_button; static GtkWidget *cancel_button;
static GtkWidget *font_dialog = NULL; static GtkWidget *font_dialog = NULL;
static GtkWidget *setup_topicbar_multiline_toggle = NULL;
enum enum
{ {
@@ -186,10 +185,6 @@ static const setting appearance_settings[] =
{ST_TOGGLR, N_("Show number of users"), P_OFFINTNL(hex_gui_win_ucount),0,0,0}, {ST_TOGGLR, N_("Show number of users"), P_OFFINTNL(hex_gui_win_ucount),0,0,0},
{ST_TOGGLE, N_("Show nickname"), P_OFFINTNL(hex_gui_win_nick),0,0,0}, {ST_TOGGLE, N_("Show nickname"), P_OFFINTNL(hex_gui_win_nick),0,0,0},
{ST_HEADER, N_("Topic Bar"),0,0,0},
{ST_TOGGLE, N_("Place mode buttons beside the topic"), P_OFFINTNL(hex_gui_mode_buttons_inline), 0, 0, 0},
{ST_TOGGLE, N_("Allow multi-line topics"), P_OFFINTNL(hex_gui_topicbar_multiline), 0, 0, 0},
{ST_END, 0, 0, 0, 0, 0} {ST_END, 0, 0, 0, 0, 0}
}; };
@@ -198,7 +193,6 @@ static const setting appearance_advanced_settings[] =
{ST_HEADER, N_("Advanced"),0,0,0}, {ST_HEADER, N_("Advanced"),0,0,0},
{ST_EFILE, N_ ("Background image:"), P_OFFSETNL (hex_text_background), 0, 0, sizeof prefs.hex_text_background}, {ST_EFILE, N_ ("Background image:"), P_OFFSETNL (hex_text_background), 0, 0, sizeof prefs.hex_text_background},
{ST_HSCALE, N_("Window opacity:"), P_OFFINTNL(hex_gui_transparency),0,0,0}, {ST_HSCALE, N_("Window opacity:"), P_OFFINTNL(hex_gui_transparency),0,0,0},
{ST_HSCALE, N_("Mouse wheel scroll speed (Slower ← → Faster):"), P_OFFINTNL(hex_gui_mouse_scroll_speed), 0, 0, 100},
{ST_END, 0, 0, 0, 0, 0} {ST_END, 0, 0, 0, 0, 0}
}; };
@@ -336,7 +330,6 @@ static const setting tabs_settings[] =
{ST_TOGGLE, N_("Show icons in the channel tree"), P_OFFINTNL(hex_gui_tab_icons), 0, 0, 0}, {ST_TOGGLE, N_("Show icons in the channel tree"), P_OFFINTNL(hex_gui_tab_icons), 0, 0, 0},
{ST_TOGGLE, N_("Show dotted lines in the channel tree"), P_OFFINTNL(hex_gui_tab_dots), 0, 0, 0}, {ST_TOGGLE, N_("Show dotted lines in the channel tree"), P_OFFINTNL(hex_gui_tab_dots), 0, 0, 0},
{ST_TOGGLE, N_("Scroll mouse-wheel to change tabs"), P_OFFINTNL (hex_gui_tab_scrollchans), 0, 0, 0}, {ST_TOGGLE, N_("Scroll mouse-wheel to change tabs"), P_OFFINTNL (hex_gui_tab_scrollchans), 0, 0, 0},
{ST_TOGGLE, N_("Show close button on tabs"), P_OFFINTNL(hex_gui_tab_closebuttons), 0, 0, 0},
{ST_TOGGLE, N_("Middle click to close tab"), P_OFFINTNL(hex_gui_tab_middleclose), 0, 0, 0}, {ST_TOGGLE, N_("Middle click to close tab"), P_OFFINTNL(hex_gui_tab_middleclose), 0, 0, 0},
{ST_TOGGLE, N_("Smaller text"), P_OFFINTNL(hex_gui_tab_small), 0, 0, 0}, {ST_TOGGLE, N_("Smaller text"), P_OFFINTNL(hex_gui_tab_small), 0, 0, 0},
{ST_MENU, N_("Focus new tabs:"), P_OFFINTNL(hex_gui_tab_newtofront), 0, focusnewtabsmenu, 0}, {ST_MENU, N_("Focus new tabs:"), P_OFFINTNL(hex_gui_tab_newtofront), 0, focusnewtabsmenu, 0},
@@ -373,7 +366,7 @@ static const setting filexfer_settings[] =
{ST_TOGGLE, N_("Receive window"), P_OFFINTNL(hex_gui_autoopen_recv), 0, 0, 0}, {ST_TOGGLE, N_("Receive window"), P_OFFINTNL(hex_gui_autoopen_recv), 0, 0, 0},
{ST_TOGGLE, N_("Chat window"), P_OFFINTNL(hex_gui_autoopen_chat), 0, 0, 0}, {ST_TOGGLE, N_("Chat window"), P_OFFINTNL(hex_gui_autoopen_chat), 0, 0, 0},
{ST_HEADER, N_("Maximum File Transfer Speeds (KiB/s or MiB/s)"), 0, 0, 0}, {ST_HEADER, N_("Maximum File Transfer Speeds (Byte per Second)"), 0, 0, 0},
{ST_NUMBER, N_("One upload:"), P_OFFINTNL(hex_dcc_max_send_cps), {ST_NUMBER, N_("One upload:"), P_OFFINTNL(hex_dcc_max_send_cps),
N_("Maximum speed for one transfer"), 0, 10000000}, N_("Maximum speed for one transfer"), 0, 10000000},
{ST_NUMBER, N_("One download:"), P_OFFINTNL(hex_dcc_max_get_cps), {ST_NUMBER, N_("One download:"), P_OFFINTNL(hex_dcc_max_get_cps),
@@ -551,7 +544,6 @@ static const setting general_settings[] =
{ST_TOGGLE, N_("WHOIS on notify"), P_OFFINTNL(hex_notify_whois_online), N_("Sends a /WHOIS when a user comes online in your notify list."), 0, 0}, {ST_TOGGLE, N_("WHOIS on notify"), P_OFFINTNL(hex_notify_whois_online), N_("Sends a /WHOIS when a user comes online in your notify list."), 0, 0},
{ST_TOGGLE, N_("Hide join and part messages"), P_OFFINTNL(hex_irc_conf_mode), N_("Hide channel join/part messages by default."), 0, 0}, {ST_TOGGLE, N_("Hide join and part messages"), P_OFFINTNL(hex_irc_conf_mode), N_("Hide channel join/part messages by default."), 0, 0},
{ST_TOGGLE, N_("Hide nick change messages"), P_OFFINTNL(hex_irc_hide_nickchange), 0, 0, 0}, {ST_TOGGLE, N_("Hide nick change messages"), P_OFFINTNL(hex_irc_hide_nickchange), 0, 0, 0},
{ST_TOGGLE, N_("Hide hostmasks in join and part messages"), P_OFFINTNL(hex_irc_hide_join_part_hostmask), 0, 0, 0},
{ST_TOGGLE, N_("Enable Ctrl+Q to quit"), P_OFFINTNL(hex_gui_ctrlq_quit), 0, 0, 0}, {ST_TOGGLE, N_("Enable Ctrl+Q to quit"), P_OFFINTNL(hex_gui_ctrlq_quit), 0, 0, 0},
{ST_END, 0, 0, 0, 0, 0} {ST_END, 0, 0, 0, 0, 0}
@@ -589,7 +581,6 @@ static const setting advanced_settings[] =
{ST_TOGGLE, N_("Display lists in compact mode"), P_OFFINTNL(hex_gui_compact), N_("Use less spacing between user list/channel tree rows."), 0, 0}, {ST_TOGGLE, N_("Display lists in compact mode"), P_OFFINTNL(hex_gui_compact), N_("Use less spacing between user list/channel tree rows."), 0, 0},
{ST_TOGGLE, N_("Use server time if supported"), P_OFFINTNL(hex_irc_cap_server_time), N_("Display timestamps obtained from server if it supports the time-server extension."), 0, 0}, {ST_TOGGLE, N_("Use server time if supported"), P_OFFINTNL(hex_irc_cap_server_time), N_("Display timestamps obtained from server if it supports the time-server extension."), 0, 0},
{ST_TOGGLE, N_("Automatically reconnect to servers on disconnect"), P_OFFINTNL(hex_net_auto_reconnect), 0, 0, 1}, {ST_TOGGLE, N_("Automatically reconnect to servers on disconnect"), P_OFFINTNL(hex_net_auto_reconnect), 0, 0, 1},
{ST_NUMBER, N_("Lag check interval:"), P_OFFINTNL(hex_net_lag_check), 0, (const char **)N_("seconds."), 9999},
{ST_NUMBER, N_("Auto reconnect delay:"), P_OFFINTNL(hex_net_reconnect_delay), 0, 0, 9999}, {ST_NUMBER, N_("Auto reconnect delay:"), P_OFFINTNL(hex_net_reconnect_delay), 0, 0, 9999},
{ST_NUMBER, N_("Auto join delay:"), P_OFFINTNL(hex_irc_join_delay), 0, 0, 9999}, {ST_NUMBER, N_("Auto join delay:"), P_OFFINTNL(hex_irc_join_delay), 0, 0, 9999},
{ST_MENU, N_("Ban Type:"), P_OFFINTNL(hex_irc_ban_type), N_("Attempt to use this banmask when banning or quieting. (requires irc_who_join)"), bantypemenu, 0}, {ST_MENU, N_("Ban Type:"), P_OFFINTNL(hex_irc_ban_type), N_("Attempt to use this banmask when banning or quieting. (requires irc_who_join)"), bantypemenu, 0},
@@ -663,11 +654,6 @@ static const setting network_settings[] =
{ST_MENU, N_("Type:"), P_OFFINTNL(hex_net_proxy_type), 0, proxytypes, 0}, {ST_MENU, N_("Type:"), P_OFFINTNL(hex_net_proxy_type), 0, proxytypes, 0},
{ST_MENU, N_("Use proxy for:"), P_OFFINTNL(hex_net_proxy_use), 0, proxyuse, 0}, {ST_MENU, N_("Use proxy for:"), P_OFFINTNL(hex_net_proxy_use), 0, proxyuse, 0},
{ST_HEADER, N_("Connection Health"), 0, 0, 0, 0},
{ST_NUMBER, N_("TCP keepalive idle:"), P_OFFINTNL(hex_net_keepalive_idle), 0, (const char **)N_("seconds."), 7200},
{ST_NUMBER, N_("TCP keepalive interval:"), P_OFFINTNL(hex_net_keepalive_interval), 0, (const char **)N_("seconds."), 600},
{ST_NUMBER, N_("TCP keepalive probes:"), P_OFFINTNL(hex_net_keepalive_count), 0, 0, 20},
{ST_HEADER, N_("Proxy Authentication"), 0, 0, 0, 0}, {ST_HEADER, N_("Proxy Authentication"), 0, 0, 0, 0},
{ST_TOGGLE, N_("Use authentication (HTTP or SOCKS5 only)"), P_OFFINTNL(hex_net_proxy_auth), 0, 0, 0}, {ST_TOGGLE, N_("Use authentication (HTTP or SOCKS5 only)"), P_OFFINTNL(hex_net_proxy_auth), 0, 0, 0},
{ST_ENTRY, N_("Username:"), P_OFFSETNL(hex_net_proxy_user), 0, 0, sizeof prefs.hex_net_proxy_user}, {ST_ENTRY, N_("Username:"), P_OFFSETNL(hex_net_proxy_user), 0, 0, sizeof prefs.hex_net_proxy_user},
@@ -838,16 +824,6 @@ setup_toggle_sensitive_cb (GtkToggleButton *but, GtkWidget *wid)
gtk_widget_set_sensitive (wid, gtk_toggle_button_get_active (but)); gtk_widget_set_sensitive (wid, gtk_toggle_button_get_active (but));
} }
static void
setup_topicbar_inline_toggled_cb (GtkToggleButton *but, gpointer userdata)
{
(void) userdata;
if (setup_topicbar_multiline_toggle)
gtk_widget_set_sensitive (setup_topicbar_multiline_toggle,
!gtk_toggle_button_get_active (but));
}
static void static void
setup_create_toggleR (GtkWidget *tab, int row, const setting *set) setup_create_toggleR (GtkWidget *tab, int row, const setting *set)
{ {
@@ -874,14 +850,6 @@ setup_create_toggleL (GtkWidget *tab, int row, const setting *set)
setup_get_int (&setup_prefs, set)); setup_get_int (&setup_prefs, set));
g_signal_connect (G_OBJECT (wid), "toggled", g_signal_connect (G_OBJECT (wid), "toggled",
G_CALLBACK (setup_toggle_cb), (gpointer)set); G_CALLBACK (setup_toggle_cb), (gpointer)set);
if (set->offset == STRUCT_OFFSET_INT (struct zoitechatprefs, hex_gui_mode_buttons_inline))
g_signal_connect (G_OBJECT (wid), "toggled",
G_CALLBACK (setup_topicbar_inline_toggled_cb), NULL);
if (set->offset == STRUCT_OFFSET_INT (struct zoitechatprefs, hex_gui_topicbar_multiline))
{
setup_topicbar_multiline_toggle = wid;
gtk_widget_set_sensitive (wid, !setup_prefs.hex_gui_mode_buttons_inline);
}
if (set->tooltip) if (set->tooltip)
gtk_widget_set_tooltip_text (wid, _(set->tooltip)); gtk_widget_set_tooltip_text (wid, _(set->tooltip));
setup_table_attach (tab, wid, 2, row==6 ? 6 : 4, row, row + 1, FALSE, FALSE, setup_table_attach (tab, wid, 2, row==6 ? 6 : 4, row, row + 1, FALSE, FALSE,
@@ -904,67 +872,6 @@ setup_create_italic_label (char *text)
return label; return label;
} }
typedef struct
{
const setting *set;
GtkSpinButton *spin;
GtkComboBox *unit;
} setup_dcc_speed_data;
static gboolean
setup_is_dcc_speed_setting (const setting *set)
{
return set->offset == P_OFFINTNL (hex_dcc_max_send_cps)
|| set->offset == P_OFFINTNL (hex_dcc_max_get_cps)
|| set->offset == P_OFFINTNL (hex_dcc_global_max_send_cps)
|| set->offset == P_OFFINTNL (hex_dcc_global_max_get_cps);
}
static int
setup_dcc_speed_multiplier (GtkComboBox *combo)
{
return gtk_combo_box_get_active (combo) == 1 ? 1024 * 1024 : 1024;
}
static void
setup_dcc_speed_spin_range (setup_dcc_speed_data *data)
{
int max = data->set->extra / setup_dcc_speed_multiplier (data->unit);
gtk_spin_button_set_range (data->spin, 0, max > 0 ? max : 0);
}
static void
setup_dcc_speed_store (setup_dcc_speed_data *data)
{
int value = gtk_spin_button_get_value_as_int (data->spin);
int speed = value * setup_dcc_speed_multiplier (data->unit);
if (speed > data->set->extra)
speed = data->set->extra;
setup_set_int (&setup_prefs, data->set, speed);
}
static void
setup_dcc_speed_spin_cb (GtkSpinButton *spin, setup_dcc_speed_data *data)
{
(void)spin;
setup_dcc_speed_store (data);
}
static void
setup_dcc_speed_unit_cb (GtkComboBox *combo, setup_dcc_speed_data *data)
{
int speed = setup_get_int (&setup_prefs, data->set);
int multiplier;
int value;
(void)combo;
setup_dcc_speed_spin_range (data);
multiplier = setup_dcc_speed_multiplier (data->unit);
value = (speed + (multiplier / 2)) / multiplier;
gtk_spin_button_set_value (data->spin, value);
setup_dcc_speed_store (data);
}
static void static void
setup_spin_cb (GtkSpinButton *spin, const setting *set) setup_spin_cb (GtkSpinButton *spin, const setting *set)
{ {
@@ -994,43 +901,11 @@ setup_create_spin (GtkWidget *table, int row, const setting *set)
g_object_set_data (G_OBJECT (wid), "lbl", label); g_object_set_data (G_OBJECT (wid), "lbl", label);
if (set->tooltip) if (set->tooltip)
gtk_widget_set_tooltip_text (wid, _(set->tooltip)); gtk_widget_set_tooltip_text (wid, _(set->tooltip));
if (setup_is_dcc_speed_setting (set)) gtk_spin_button_set_value (GTK_SPIN_BUTTON (wid),
{
GtkWidget *unit;
setup_dcc_speed_data *data = g_new0 (setup_dcc_speed_data, 1);
int speed = setup_get_int (&setup_prefs, set);
int use_mib = speed >= (1024 * 1024) && speed % (1024 * 1024) == 0;
int multiplier;
data->set = set;
data->spin = GTK_SPIN_BUTTON (wid);
unit = gtk_combo_box_text_new ();
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (unit), _("KiB/s"));
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (unit), _("MiB/s"));
gtk_combo_box_set_wrap_width (GTK_COMBO_BOX (unit), 1);
gtk_combo_box_set_active (GTK_COMBO_BOX (unit), use_mib ? 1 : 0);
data->unit = GTK_COMBO_BOX (unit);
setup_dcc_speed_spin_range (data);
multiplier = setup_dcc_speed_multiplier (data->unit);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (wid), (speed + (multiplier / 2)) / multiplier);
g_signal_connect (G_OBJECT (wid), "value-changed",
G_CALLBACK (setup_dcc_speed_spin_cb), data);
g_signal_connect (G_OBJECT (unit), "changed",
G_CALLBACK (setup_dcc_speed_unit_cb), data);
gtk_box_pack_start (GTK_BOX (rbox), wid, 0, 0, 0);
gtk_box_pack_start (GTK_BOX (rbox), unit, 0, 0, 6);
} else
{
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);
}
if (set->list) if (set->list)
{ {
@@ -1395,7 +1270,7 @@ setup_entry_cb (GtkEntry *entry, setting *set)
int size; int size;
int pos; int pos;
unsigned char *p = (unsigned char*)gtk_entry_get_text (entry); unsigned char *p = (unsigned char*)gtk_entry_get_text (entry);
size_t len = strlen ((const char *) p); int len = strlen (p);
/* need to truncate? */ /* need to truncate? */
if (len >= set->extra) if (len >= set->extra)
@@ -2191,7 +2066,7 @@ setup_apply_to_sess (session_gui *gui)
{ {
mg_update_xtext (gui->xtext); mg_update_xtext (gui->xtext);
mg_apply_session_font_prefs (gui); theme_preferences_apply_to_session (gui, input_style);
if (prefs.hex_gui_ulist_buttons) if (prefs.hex_gui_ulist_buttons)
gtk_widget_show (gui->button_box); gtk_widget_show (gui->button_box);
@@ -2211,7 +2086,7 @@ unslash (char *dir)
{ {
if (dir[0]) if (dir[0])
{ {
size_t len = strlen (dir) - 1; int len = strlen (dir) - 1;
#ifdef WIN32 #ifdef WIN32
if (dir[len] == '/' || dir[len] == '\\') if (dir[len] == '/' || dir[len] == '\\')
#else #else
@@ -2309,12 +2184,8 @@ setup_apply (struct zoitechatprefs *pr)
noapply = TRUE; noapply = TRUE;
if (DIFF (hex_gui_lagometer)) if (DIFF (hex_gui_lagometer))
noapply = TRUE; noapply = TRUE;
if (DIFF (hex_gui_mode_buttons_inline))
noapply = TRUE;
if (DIFF (hex_gui_tab_icons)) if (DIFF (hex_gui_tab_icons))
noapply = TRUE; noapply = TRUE;
if (DIFF (hex_gui_tab_closebuttons))
noapply = TRUE;
if (DIFF (hex_gui_tab_server)) if (DIFF (hex_gui_tab_server))
noapply = TRUE; noapply = TRUE;
if (DIFF (hex_gui_tab_small)) if (DIFF (hex_gui_tab_small))
@@ -2325,8 +2196,6 @@ setup_apply (struct zoitechatprefs *pr)
noapply = TRUE; noapply = TRUE;
if (DIFF (hex_gui_throttlemeter)) if (DIFF (hex_gui_throttlemeter))
noapply = TRUE; noapply = TRUE;
if (DIFF (hex_gui_topicbar_multiline))
noapply = TRUE;
if (DIFF (hex_gui_ulist_count)) if (DIFF (hex_gui_ulist_count))
noapply = TRUE; noapply = TRUE;
if (DIFF (hex_gui_ulist_icons)) if (DIFF (hex_gui_ulist_icons))
@@ -35,7 +35,6 @@ struct zoitechatprefs prefs;
static gboolean gtk_available; static gboolean gtk_available;
static char *temp_root; static char *temp_root;
static char *xdg_data_home;
static char *theme_parent_root; static char *theme_parent_root;
static char *theme_child_root; static char *theme_child_root;
static char *theme_switch_root; static char *theme_switch_root;
@@ -199,14 +198,6 @@ get_int_setting (const char *name)
return value; return value;
} }
static gboolean
has_default_seat (void)
{
GdkDisplay *display = gdk_display_get_default ();
return display && GDK_IS_SEAT (gdk_display_get_default_seat (display));
}
static void static void
setup_themes (void) setup_themes (void)
{ {
@@ -214,10 +205,6 @@ setup_themes (void)
temp_root = g_dir_make_tmp ("zoitechat-theme-gtk3-settings-XXXXXX", NULL); temp_root = g_dir_make_tmp ("zoitechat-theme-gtk3-settings-XXXXXX", NULL);
g_assert_nonnull (temp_root); g_assert_nonnull (temp_root);
xdg_data_home = g_build_filename (temp_root, "data", NULL);
g_assert_cmpint (g_mkdir_with_parents (xdg_data_home, 0700), ==, 0);
g_setenv ("XDG_DATA_HOME", xdg_data_home, TRUE);
theme_parent_root = g_build_filename (temp_root, "parent", NULL); theme_parent_root = g_build_filename (temp_root, "parent", NULL);
theme_child_root = g_build_filename (temp_root, "child", NULL); theme_child_root = g_build_filename (temp_root, "child", NULL);
theme_switch_root = g_build_filename (temp_root, "switch", NULL); theme_switch_root = g_build_filename (temp_root, "switch", NULL);
@@ -266,12 +253,10 @@ teardown_themes (void)
g_free (theme_parent_root); g_free (theme_parent_root);
g_free (theme_child_root); g_free (theme_child_root);
g_free (theme_switch_root); g_free (theme_switch_root);
g_free (xdg_data_home);
g_free (temp_root); g_free (temp_root);
theme_parent_root = NULL; theme_parent_root = NULL;
theme_child_root = NULL; theme_child_root = NULL;
theme_switch_root = NULL; theme_switch_root = NULL;
xdg_data_home = NULL;
temp_root = NULL; temp_root = NULL;
} }
@@ -317,13 +302,10 @@ test_settings_restored_on_disable_and_switch (void)
g_assert_true (theme_gtk3_apply ("layered", THEME_GTK3_VARIANT_PREFER_LIGHT, &error)); g_assert_true (theme_gtk3_apply ("layered", THEME_GTK3_VARIANT_PREFER_LIGHT, &error));
g_assert_no_error (error); g_assert_no_error (error);
g_assert_cmpint (get_int_setting ("gtk-cursor-blink-time"), ==, 333); g_assert_cmpint (get_int_setting ("gtk-cursor-blink-time"), ==, 333);
if (has_default_seat ()) g_object_get (gtk_settings_get_default (), "gtk-theme-name", &active_theme_name, NULL);
{ g_assert_cmpstr (active_theme_name, ==, "child");
g_object_get (gtk_settings_get_default (), "gtk-theme-name", &active_theme_name, NULL); g_free (active_theme_name);
g_assert_cmpstr (active_theme_name, ==, "child"); active_theme_name = NULL;
g_free (active_theme_name);
active_theme_name = NULL;
}
g_assert_true (theme_gtk3_apply ("switch", THEME_GTK3_VARIANT_PREFER_LIGHT, &error)); g_assert_true (theme_gtk3_apply ("switch", THEME_GTK3_VARIANT_PREFER_LIGHT, &error));
g_assert_no_error (error); g_assert_no_error (error);
@@ -333,12 +315,9 @@ test_settings_restored_on_disable_and_switch (void)
theme_gtk3_disable (); theme_gtk3_disable ();
g_assert_cmpint (get_int_setting ("gtk-cursor-blink-time"), ==, default_blink); g_assert_cmpint (get_int_setting ("gtk-cursor-blink-time"), ==, default_blink);
g_assert_cmpint (get_bool_setting ("gtk-enable-animations"), ==, default_animations); g_assert_cmpint (get_bool_setting ("gtk-enable-animations"), ==, default_animations);
if (has_default_seat ()) g_object_get (gtk_settings_get_default (), "gtk-theme-name", &active_theme_name, NULL);
{ g_assert_cmpstr (active_theme_name, ==, default_theme_name);
g_object_get (gtk_settings_get_default (), "gtk-theme-name", &active_theme_name, NULL); g_free (active_theme_name);
g_assert_cmpstr (active_theme_name, ==, default_theme_name);
g_free (active_theme_name);
}
g_free (default_theme_name); g_free (default_theme_name);
g_assert_false (theme_gtk3_is_active ()); g_assert_false (theme_gtk3_is_active ());
} }
@@ -349,8 +328,8 @@ main (int argc, char **argv)
int rc; int rc;
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
setup_themes ();
gtk_available = gtk_init_check (&argc, &argv); gtk_available = gtk_init_check (&argc, &argv);
setup_themes ();
g_test_add_func ("/theme/gtk3/settings_layer_precedence", test_settings_layer_precedence); g_test_add_func ("/theme/gtk3/settings_layer_precedence", test_settings_layer_precedence);
g_test_add_func ("/theme/gtk3/settings_restored_on_disable_and_switch", test_settings_restored_on_disable_and_switch); g_test_add_func ("/theme/gtk3/settings_restored_on_disable_and_switch", test_settings_restored_on_disable_and_switch);
@@ -59,17 +59,6 @@ fe_open_url (const char *url)
(void)url; (void)url;
} }
char *
get_xdir (void)
{
return (char *)"/tmp";
}
void
load_text_events (void)
{
}
gboolean gboolean
theme_get_color (ThemeSemanticToken token, GdkRGBA *color) theme_get_color (ThemeSemanticToken token, GdkRGBA *color)
{ {
@@ -107,23 +96,12 @@ theme_manager_reset_mode_colors (unsigned int mode, gboolean *palette_changed)
*palette_changed = FALSE; *palette_changed = FALSE;
} }
void
theme_runtime_clear_gtk_mapped_custom_tokens (void)
{
}
gboolean gboolean
theme_manager_save_preferences (void) theme_manager_save_preferences (void)
{ {
return TRUE; return TRUE;
} }
void
theme_manager_apply_to_window (GtkWidget *window)
{
(void)window;
}
void void
theme_manager_dispatch_changed (ThemeChangedReason reasons) theme_manager_dispatch_changed (ThemeChangedReason reasons)
{ {
@@ -210,16 +188,6 @@ zoitechat_gtk3_theme_service_import (const char *source_path, char **imported_id
return FALSE; return FALSE;
} }
gboolean
zoitechat_gtk3_theme_service_read_archive_text_file (const char *archive_path, const char *name, char **contents, GError **error)
{
(void)archive_path;
(void)name;
(void)contents;
(void)error;
return FALSE;
}
gboolean gboolean
zoitechat_gtk3_theme_service_remove_user_theme (const char *theme_id, GError **error) zoitechat_gtk3_theme_service_remove_user_theme (const char *theme_id, GError **error)
{ {
+7 -35
View File
@@ -82,36 +82,6 @@ theme_token_to_rgb16 (ThemeSemanticToken token, guint16 *red, guint16 *green, gu
return TRUE; return TRUE;
} }
static GtkStateFlags
theme_access_state_with_base (GtkStyleContext *context, GtkStateFlags state)
{
GtkStateFlags base_state;
base_state = gtk_style_context_get_state (context);
base_state &= (GTK_STATE_FLAG_DIR_LTR | GTK_STATE_FLAG_DIR_RTL | GTK_STATE_FLAG_BACKDROP | GTK_STATE_FLAG_FOCUSED);
return base_state | state;
}
static void
theme_access_context_get_color (GtkStyleContext *context, GtkStateFlags state, GdkRGBA *out_color)
{
gtk_style_context_save (context);
gtk_style_context_set_state (context, theme_access_state_with_base (context, state));
gtk_style_context_get_color (context, gtk_style_context_get_state (context), out_color);
gtk_style_context_restore (context);
}
static void
theme_access_context_get_background_color (GtkStyleContext *context, GtkStateFlags state, GdkRGBA *out_color)
{
gtk_style_context_save (context);
gtk_style_context_set_state (context, theme_access_state_with_base (context, state));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_style_context_get_background_color (context, gtk_style_context_get_state (context), out_color);
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_style_context_restore (context);
}
static gboolean static gboolean
theme_access_get_gtk_palette_map (GtkWidget *widget, ThemeGtkPaletteMap *out_map) theme_access_get_gtk_palette_map (GtkWidget *widget, ThemeGtkPaletteMap *out_map)
{ {
@@ -126,11 +96,13 @@ theme_access_get_gtk_palette_map (GtkWidget *widget, ThemeGtkPaletteMap *out_map
if (context == NULL) if (context == NULL)
return FALSE; return FALSE;
theme_access_context_get_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_foreground); gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_foreground);
theme_access_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_background); G_GNUC_BEGIN_IGNORE_DEPRECATIONS
theme_access_context_get_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_foreground); gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &out_map->text_background);
theme_access_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_background); gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_foreground);
theme_access_context_get_color (context, GTK_STATE_FLAG_LINK, &accent); gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &out_map->selection_background);
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_style_context_get_color (context, GTK_STATE_FLAG_LINK, &accent);
if (accent.alpha <= 0.0) if (accent.alpha <= 0.0)
accent = out_map->selection_background; accent = out_map->selection_background;
out_map->accent = accent; out_map->accent = accent;
+1 -7
View File
@@ -88,15 +88,9 @@ theme_application_apply_toplevel_theme (gboolean dark)
gboolean gboolean
theme_application_apply_mode (unsigned int mode, gboolean *palette_changed) theme_application_apply_mode (unsigned int mode, gboolean *palette_changed)
{ {
static gboolean runtime_loaded = FALSE;
gboolean dark; gboolean dark;
if (!runtime_loaded) theme_runtime_load ();
{
theme_runtime_load ();
runtime_loaded = TRUE;
}
dark = theme_runtime_apply_mode (mode, palette_changed); dark = theme_runtime_apply_mode (mode, palette_changed);
theme_application_apply_toplevel_theme (dark); theme_application_apply_toplevel_theme (dark);
+2 -25
View File
@@ -33,10 +33,6 @@ static const char *theme_css_selector_dark_class = "zoitechat-dark";
static const char *theme_css_selector_light_class = "zoitechat-light"; static const char *theme_css_selector_light_class = "zoitechat-light";
static const char *theme_css_palette_provider_key = "zoitechat-palette-provider"; static const char *theme_css_palette_provider_key = "zoitechat-palette-provider";
static const guint theme_css_provider_priority = GTK_STYLE_PROVIDER_PRIORITY_USER; static const guint theme_css_provider_priority = GTK_STYLE_PROVIDER_PRIORITY_USER;
static const char *theme_css_palette_scope_selectors =
".zoitechat-palette, .zoitechat-palette *, .zoitechat-palette box, .zoitechat-palette grid, .zoitechat-palette stack, .zoitechat-palette frame, .zoitechat-palette paned, .zoitechat-palette paned > separator, .zoitechat-palette separator, .zoitechat-palette viewport, .zoitechat-palette overlay, .zoitechat-palette revealer, .zoitechat-palette notebook, .zoitechat-palette notebook > header, .zoitechat-palette notebook > header > tabs, .zoitechat-palette notebook > header > tabs > tab, .zoitechat-palette scrolledwindow, .zoitechat-palette scrollbar, .zoitechat-palette scrollbar slider, .zoitechat-palette scrollbar trough, .zoitechat-palette treeview, .zoitechat-palette treeview.view, .zoitechat-palette treeview.view text, .zoitechat-palette treeview.view cell, .zoitechat-palette treeview.view row, .zoitechat-palette treeview header, .zoitechat-palette treeview header button, .zoitechat-palette list, .zoitechat-palette list row, .zoitechat-palette row, .zoitechat-palette textview, .zoitechat-palette textview text, .zoitechat-palette text, .zoitechat-palette entry, .zoitechat-palette entry text, .zoitechat-palette button, .zoitechat-palette button label, .zoitechat-palette check, .zoitechat-palette switch, .zoitechat-palette slider, .zoitechat-palette scale, .zoitechat-palette scale trough, .zoitechat-palette scale highlight, .zoitechat-palette spinbutton, .zoitechat-palette combobox, .zoitechat-palette combobox box, .zoitechat-palette progressbar, .zoitechat-palette progressbar trough, .zoitechat-palette levelbar, .zoitechat-palette levelbar trough, .zoitechat-palette menubar, .zoitechat-palette menu, .zoitechat-palette menuitem, .zoitechat-palette menuitem label, .zoitechat-palette toolbar, .zoitechat-palette headerbar, .zoitechat-palette label, .zoitechat-palette link, .zoitechat-palette infobar, .zoitechat-palette statusbar, .zoitechat-palette statusbar frame, .zoitechat-palette tooltip, .zoitechat-palette tooltip label";
static const char *theme_css_palette_selection_selectors =
".zoitechat-palette *:selected, .zoitechat-palette *:selected:focus, .zoitechat-palette *:selected:hover, .zoitechat-palette treeview.view:selected, .zoitechat-palette treeview.view:selected:focus, .zoitechat-palette treeview.view:selected:hover, .zoitechat-palette row:selected, .zoitechat-palette row:selected:focus, .zoitechat-palette row:selected:hover, .zoitechat-palette selection, .zoitechat-palette text selection, .zoitechat-palette entry selection, .zoitechat-palette entry text selection, .zoitechat-palette button:selected, .zoitechat-palette button:checked, .zoitechat-palette check:checked, .zoitechat-palette switch:checked, .zoitechat-palette slider:active, .zoitechat-palette menuitem:selected, .zoitechat-palette menuitem:hover, .zoitechat-palette notebook > header > tabs > tab:checked, .zoitechat-palette notebook > header > tabs > tab:hover, .zoitechat-palette treeview header button:hover, .zoitechat-palette treeview header button:active, .zoitechat-palette progressbar progress, .zoitechat-palette levelbar block.filled, .zoitechat-palette:focus selection, .zoitechat-palette:focus text selection";
typedef struct typedef struct
{ {
@@ -327,16 +323,13 @@ theme_css_apply_palette_widget (GtkWidget *widget, const GdkRGBA *bg, const GdkR
} }
gtkutil_append_font_css (css, font_desc); gtkutil_append_font_css (css, font_desc);
g_string_append (css, " }"); g_string_append (css, " }");
g_string_append_printf (css, "%s {", theme_css_palette_scope_selectors); g_string_append_printf (css, ".%s, .%s *, .%s treeview, .%s treeview.view, .%s treeview.view text, .%s treeview.view cell, .%s treeview.view row, .%s list, .%s list row, .%s text {", theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class);
if (bg) if (bg)
g_string_append_printf (css, " background-color: %s;", bg_color); g_string_append_printf (css, " background-color: %s;", bg_color);
if (fg) if (fg)
{
g_string_append_printf (css, " color: %s;", fg_color); g_string_append_printf (css, " color: %s;", fg_color);
g_string_append_printf (css, " caret-color: %s;", fg_color);
}
g_string_append (css, " }"); g_string_append (css, " }");
g_string_append_printf (css, "%s {", theme_css_palette_selection_selectors); g_string_append_printf (css, ".%s *:selected, .%s *:selected:focus, .%s *:selected:hover, .%s treeview.view:selected, .%s treeview.view:selected:focus, .%s treeview.view:selected:hover, .%s row:selected, .%s row:selected:focus, .%s row:selected:hover, .%s selection, .%s text selection, .%s entry selection, .%s entry text selection, .%s:focus selection, .%s:focus text selection {", theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class, theme_css_selector_palette_class);
if (sel_bg_color) if (sel_bg_color)
g_string_append_printf (css, " background-color: %s;", sel_bg_color); g_string_append_printf (css, " background-color: %s;", sel_bg_color);
else if (bg) else if (bg)
@@ -374,12 +367,6 @@ theme_css_build_toplevel_classes (void)
"color: @theme_fg_color;" "color: @theme_fg_color;"
"border-color: @theme_bg_color;" "border-color: @theme_bg_color;"
"}" "}"
"window.%s menuitem:hover, window.%s menuitem:selected {"
"background-color: @theme_selected_bg_color;"
"background-image: none;"
"color: @theme_selected_fg_color;"
"border-color: @theme_selected_bg_color;"
"}"
"window.%s, window.%s:backdrop, .%s {" "window.%s, window.%s:backdrop, .%s {"
"background-color: #f6f6f6;" "background-color: #f6f6f6;"
"color: #101010;" "color: #101010;"
@@ -390,12 +377,6 @@ theme_css_build_toplevel_classes (void)
"background-image: none;" "background-image: none;"
"color: @theme_fg_color;" "color: @theme_fg_color;"
"border-color: @theme_bg_color;" "border-color: @theme_bg_color;"
"}"
"window.%s menuitem:hover, window.%s menuitem:selected {"
"background-color: @theme_selected_bg_color;"
"background-image: none;"
"color: @theme_selected_fg_color;"
"border-color: @theme_selected_bg_color;"
"}", "}",
theme_css_selector_dark_class, theme_css_selector_dark_class,
theme_css_selector_dark_class, theme_css_selector_dark_class,
@@ -406,10 +387,6 @@ theme_css_build_toplevel_classes (void)
theme_css_selector_dark_class, theme_css_selector_dark_class,
theme_css_selector_dark_class, theme_css_selector_dark_class,
theme_css_selector_dark_class, theme_css_selector_dark_class,
theme_css_selector_dark_class,
theme_css_selector_dark_class,
theme_css_selector_light_class,
theme_css_selector_light_class,
theme_css_selector_light_class, theme_css_selector_light_class,
theme_css_selector_light_class, theme_css_selector_light_class,
theme_css_selector_light_class, theme_css_selector_light_class,
+4 -31
View File
@@ -135,12 +135,8 @@ settings_defaults_table (void)
static void static void
settings_rescan_icon_theme (void) settings_rescan_icon_theme (void)
{ {
GdkScreen *screen = gdk_screen_get_default ();
GtkIconTheme *icon_theme; GtkIconTheme *icon_theme;
if (!screen)
return;
icon_theme = gtk_icon_theme_get_default (); icon_theme = gtk_icon_theme_get_default ();
if (!icon_theme) if (!icon_theme)
return; return;
@@ -160,13 +156,8 @@ theme_gtk3_reset_widgets (void)
static void static void
settings_capture_icon_search_path (void) settings_capture_icon_search_path (void)
{ {
GdkScreen *screen = gdk_screen_get_default (); GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
GtkIconTheme *icon_theme;
if (!screen)
return;
icon_theme = gtk_icon_theme_get_default ();
if (!icon_theme || theme_gtk3_settings_state.icon_search_path_captured) if (!icon_theme || theme_gtk3_settings_state.icon_search_path_captured)
return; return;
@@ -177,13 +168,8 @@ settings_capture_icon_search_path (void)
static void static void
settings_append_icon_search_path (const char *path) settings_append_icon_search_path (const char *path)
{ {
GdkScreen *screen = gdk_screen_get_default (); GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
GtkIconTheme *icon_theme;
if (!screen)
return;
icon_theme = gtk_icon_theme_get_default ();
if (!icon_theme || !path || !g_file_test (path, G_FILE_TEST_IS_DIR)) if (!icon_theme || !path || !g_file_test (path, G_FILE_TEST_IS_DIR))
return; return;
@@ -213,13 +199,8 @@ settings_apply_icon_paths (const char *theme_root)
static void static void
settings_restore_icon_search_path (void) settings_restore_icon_search_path (void)
{ {
GdkScreen *screen = gdk_screen_get_default (); GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
GtkIconTheme *icon_theme;
if (!screen)
return;
icon_theme = gtk_icon_theme_get_default ();
if (!icon_theme || !theme_gtk3_settings_state.icon_search_path_captured) if (!icon_theme || !theme_gtk3_settings_state.icon_search_path_captured)
return; return;
@@ -413,14 +394,6 @@ settings_theme_link_search_path (const char *theme_root, const char *theme_name)
return ok; return ok;
} }
static gboolean
settings_default_seat_available (void)
{
GdkDisplay *display = gdk_display_get_default ();
return display && GDK_IS_SEAT (gdk_display_get_default_seat (display));
}
static void static void
settings_apply_theme_name (const char *theme_root) settings_apply_theme_name (const char *theme_root)
{ {
@@ -431,7 +404,7 @@ settings_apply_theme_name (const char *theme_root)
return; return;
settings = gtk_settings_get_default (); settings = gtk_settings_get_default ();
if (!settings || !settings_default_seat_available ()) if (!settings)
return; return;
theme_name = g_path_get_basename (theme_root); theme_name = g_path_get_basename (theme_root);
+2 -26
View File
@@ -415,24 +415,6 @@ theme_manager_is_kde_wayland (void)
return is_kde; return is_kde;
} }
static gint
theme_manager_get_system_headerbar_height (void)
{
GtkWidget *probe;
gint minimum;
gint natural;
probe = gtk_header_bar_new ();
gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (probe), TRUE);
gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (probe), "menu:minimize,maximize,close");
gtk_widget_show (probe);
gtk_widget_get_preferred_height (probe, &minimum, &natural);
gtk_widget_destroy (probe);
if (natural > 0)
return natural;
return minimum;
}
static void static void
theme_manager_apply_wayland_kde_csd (GtkWidget *window) theme_manager_apply_wayland_kde_csd (GtkWidget *window)
{ {
@@ -460,16 +442,10 @@ theme_manager_apply_wayland_kde_csd (GtkWidget *window)
headerbar = gtk_header_bar_new (); headerbar = gtk_header_bar_new ();
gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (headerbar), TRUE); gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (headerbar), TRUE);
gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (headerbar), "menu:minimize,maximize,close"); gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (headerbar), "menu:minimize,maximize,close");
g_object_set (G_OBJECT (headerbar), "spacing", 0, NULL); icon_pixbuf = gdk_pixbuf_new_from_resource_at_scale ("/icons/zoitechat.svg", 32, 32, TRUE, NULL);
gtk_widget_set_size_request (headerbar, -1, theme_manager_get_system_headerbar_height ());
icon_pixbuf = gdk_pixbuf_new_from_resource_at_scale ("/icons/zoitechat.svg", 24, 24, TRUE, NULL);
if (!icon_pixbuf) if (!icon_pixbuf)
icon_pixbuf = gdk_pixbuf_new_from_resource_at_scale ("/icons/zoitechat.png", 24, 24, TRUE, NULL); icon_pixbuf = gdk_pixbuf_new_from_resource_at_scale ("/icons/zoitechat.png", 32, 32, TRUE, NULL);
icon_image = icon_pixbuf ? gtk_image_new_from_pixbuf (icon_pixbuf) : gtk_image_new_from_resource ("/icons/zoitechat.png"); icon_image = icon_pixbuf ? gtk_image_new_from_pixbuf (icon_pixbuf) : gtk_image_new_from_resource ("/icons/zoitechat.png");
gtk_widget_set_margin_start (icon_image, 0);
gtk_widget_set_margin_end (icon_image, 0);
gtk_widget_set_margin_top (icon_image, 0);
gtk_widget_set_margin_bottom (icon_image, 0);
if (icon_pixbuf) if (icon_pixbuf)
g_object_unref (icon_pixbuf); g_object_unref (icon_pixbuf);
gtk_header_bar_pack_start (GTK_HEADER_BAR (headerbar), icon_image); gtk_header_bar_pack_start (GTK_HEADER_BAR (headerbar), icon_image);
+21 -129
View File
@@ -29,15 +29,11 @@
#include "../gtkutil.h" #include "../gtkutil.h"
#include "../../common/fe.h" #include "../../common/fe.h"
#include "../../common/cfgfiles.h"
#include "../../common/util.h" #include "../../common/util.h"
#include "../../common/gtk3-theme-service.h" #include "../../common/gtk3-theme-service.h"
#include "theme-gtk3.h" #include "theme-gtk3.h"
#include "theme-manager.h" #include "theme-manager.h"
#include "theme-preferences.h" #include "theme-preferences.h"
#include "theme-runtime.h"
extern void load_text_events (void);
typedef struct typedef struct
{ {
@@ -936,21 +932,6 @@ theme_preferences_show_import_error (GtkWidget *button, const char *message)
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
} }
static void
theme_preferences_show_import_info (GtkWidget *button, const char *message)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (button)),
GTK_DIALOG_MODAL,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
"%s",
message);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
static gboolean static gboolean
theme_preferences_parse_cfg_color (const char *cfg, theme_preferences_parse_cfg_color (const char *cfg,
const char *key, const char *key,
@@ -1057,77 +1038,40 @@ static void
theme_preferences_import_colors_conf_cb (GtkWidget *button, gpointer user_data) theme_preferences_import_colors_conf_cb (GtkWidget *button, gpointer user_data)
{ {
gboolean *color_change_flag = user_data; gboolean *color_change_flag = user_data;
GtkFileChooserNative *dialog; GtkWidget *dialog;
char *path; char *path;
char *lower_path;
char *cfg; char *cfg;
char *pevents_cfg = NULL;
GError *error = NULL; GError *error = NULL;
gboolean any_imported = FALSE; gboolean any_imported = FALSE;
gboolean imported_from_hct = FALSE;
gboolean imported_pevents = FALSE;
ThemeSemanticToken token; ThemeSemanticToken token;
GtkFileFilter *filter;
dialog = gtk_file_chooser_native_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,
_("_Import"), _("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Cancel")); _("_Import"), GTK_RESPONSE_ACCEPT,
NULL);
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 ();
gtk_file_filter_set_name (filter, _("Theme colors (*.conf, *.hct)"));
gtk_file_filter_add_pattern (filter, "*.conf");
gtk_file_filter_add_pattern (filter, "*.hct");
gtk_file_filter_add_pattern (filter, "*.HCT");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
if (gtk_native_dialog_run (GTK_NATIVE_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT) if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT)
{ {
g_object_unref (dialog); gtk_widget_destroy (dialog);
return; return;
} }
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
g_object_unref (dialog); gtk_widget_destroy (dialog);
if (!path) if (!path)
return; return;
lower_path = g_ascii_strdown (path, -1); if (!g_file_get_contents (path, &cfg, NULL, &error))
if (g_str_has_suffix (lower_path, ".hct"))
{
imported_from_hct = TRUE;
if (!zoitechat_gtk3_theme_service_read_archive_text_file (path, "colors.conf", &cfg, &error))
{
theme_preferences_show_import_error (button, _("Failed to read colors.conf from .hct file."));
g_clear_error (&error);
g_free (lower_path);
g_free (path);
return;
}
if (zoitechat_gtk3_theme_service_read_archive_text_file (path, "pevents.conf", &pevents_cfg, &error))
{
char *pevents_path = g_build_filename (get_xdir (), "pevents.conf", NULL);
if (g_file_set_contents (pevents_path, pevents_cfg, -1, &error))
{
load_text_events ();
imported_pevents = TRUE;
}
g_free (pevents_path);
g_clear_error (&error);
}
else
g_clear_error (&error);
}
else if (!g_file_get_contents (path, &cfg, NULL, &error))
{ {
theme_preferences_show_import_error (button, _("Failed to read colors.conf file.")); theme_preferences_show_import_error (button, _("Failed to read colors.conf file."));
g_clear_error (&error); g_clear_error (&error);
g_free (lower_path);
g_free (path); g_free (path);
return; return;
} }
g_free (lower_path);
for (token = THEME_TOKEN_MIRC_0; token < THEME_TOKEN_COUNT; token++) for (token = THEME_TOKEN_MIRC_0; token < THEME_TOKEN_COUNT; token++)
{ {
@@ -1142,22 +1086,9 @@ theme_preferences_import_colors_conf_cb (GtkWidget *button, gpointer user_data)
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 (imported_from_hct)
{
char *message = g_strdup_printf (imported_pevents ?
_("Imported colors.conf and pevents.conf from %s.") :
_("Imported colors.conf from %s."),
path);
theme_preferences_show_import_info (button, message);
g_free (message);
}
else if (color_change_flag) else if (color_change_flag)
*color_change_flag = theme_preferences_stage.active ? theme_preferences_stage.changed : *color_change_flag; *color_change_flag = theme_preferences_stage.active ? theme_preferences_stage.changed : *color_change_flag;
if (any_imported && color_change_flag)
*color_change_flag = theme_preferences_stage.active ? theme_preferences_stage.changed : *color_change_flag;
g_free (pevents_cfg);
g_free (cfg); g_free (cfg);
g_free (path); g_free (path);
} }
@@ -1418,56 +1349,17 @@ theme_preferences_gtk3_sync_remove_state (theme_preferences_ui *ui)
gtk_widget_set_sensitive (ui->gtk3_remove, source == ZOITECHAT_GTK3_THEME_SOURCE_USER); gtk_widget_set_sensitive (ui->gtk3_remove, source == ZOITECHAT_GTK3_THEME_SOURCE_USER);
} }
static void
theme_preferences_gtk3_sync_runtime_palette (theme_preferences_ui *ui)
{
ThemeWidgetStyleValues style_values;
GtkWidget *style_source = NULL;
if (ui && ui->parent)
style_source = GTK_WIDGET (ui->parent);
else if (ui && ui->gtk3_combo)
style_source = ui->gtk3_combo;
theme_runtime_clear_gtk_mapped_custom_tokens ();
theme_get_widget_style_values_for_widget (style_source, &style_values);
theme_preferences_staged_set_color (THEME_TOKEN_TEXT_FOREGROUND,
&style_values.foreground,
NULL,
TRUE);
theme_preferences_staged_set_color (THEME_TOKEN_TEXT_BACKGROUND,
&style_values.background,
NULL,
TRUE);
theme_preferences_staged_set_color (THEME_TOKEN_SELECTION_FOREGROUND,
&style_values.selection_foreground,
NULL,
TRUE);
theme_preferences_staged_set_color (THEME_TOKEN_SELECTION_BACKGROUND,
&style_values.selection_background,
NULL,
TRUE);
}
static gboolean static gboolean
theme_preferences_gtk3_apply_and_refresh (theme_preferences_ui *ui, GError **error) theme_preferences_gtk3_apply_and_refresh (GError **error)
{ {
if (!theme_gtk3_apply_current (error)) if (!theme_gtk3_apply_current (error))
return FALSE; return FALSE;
theme_manager_dispatch_changed (THEME_CHANGED_REASON_THEME_PACK |
if (ui && ui->parent) THEME_CHANGED_REASON_PALETTE |
theme_manager_apply_to_window (GTK_WIDGET (ui->parent)); THEME_CHANGED_REASON_WIDGET_STYLE |
THEME_CHANGED_REASON_USERLIST |
theme_preferences_gtk3_sync_runtime_palette (ui); THEME_CHANGED_REASON_MODE);
return TRUE;
theme_manager_dispatch_changed (THEME_CHANGED_REASON_THEME_PACK |
THEME_CHANGED_REASON_PALETTE |
THEME_CHANGED_REASON_WIDGET_STYLE |
THEME_CHANGED_REASON_USERLIST |
THEME_CHANGED_REASON_MODE);
return TRUE;
} }
static void static void
@@ -1503,7 +1395,7 @@ theme_preferences_gtk3_changed_cb (GtkComboBox *combo, gpointer user_data)
ui->setup_prefs->hex_gui_gtk3_variant = prefs.hex_gui_gtk3_variant; ui->setup_prefs->hex_gui_gtk3_variant = prefs.hex_gui_gtk3_variant;
} }
if (selection_changed && !theme_preferences_gtk3_apply_and_refresh (ui, &error)) if (selection_changed && !theme_preferences_gtk3_apply_and_refresh (&error))
{ {
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR, theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
error ? error->message : _("Failed to apply GTK3 theme.")); error ? error->message : _("Failed to apply GTK3 theme."));
@@ -1592,7 +1484,7 @@ theme_preferences_populate_gtk3 (theme_preferences_ui *ui)
g_free (final_id); g_free (final_id);
} }
if (should_apply && !theme_preferences_gtk3_apply_and_refresh (ui, &error)) if (should_apply && !theme_preferences_gtk3_apply_and_refresh (&error))
{ {
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR, theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
error ? error->message : _("Failed to apply GTK3 theme.")); error ? error->message : _("Failed to apply GTK3 theme."));
-14
View File
@@ -410,20 +410,6 @@ theme_runtime_reset_mode_colors (gboolean dark_mode)
dark_mode_active = FALSE; dark_mode_active = FALSE;
} }
void
theme_runtime_clear_gtk_mapped_custom_tokens (void)
{
light_custom_tokens[THEME_TOKEN_TEXT_FOREGROUND] = FALSE;
light_custom_tokens[THEME_TOKEN_TEXT_BACKGROUND] = FALSE;
light_custom_tokens[THEME_TOKEN_SELECTION_FOREGROUND] = FALSE;
light_custom_tokens[THEME_TOKEN_SELECTION_BACKGROUND] = FALSE;
dark_custom_tokens[THEME_TOKEN_TEXT_FOREGROUND] = FALSE;
dark_custom_tokens[THEME_TOKEN_TEXT_BACKGROUND] = FALSE;
dark_custom_tokens[THEME_TOKEN_SELECTION_FOREGROUND] = FALSE;
dark_custom_tokens[THEME_TOKEN_SELECTION_BACKGROUND] = FALSE;
}
void void
theme_runtime_load (void) theme_runtime_load (void)
{ {
-1
View File
@@ -47,7 +47,6 @@ 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);
void theme_runtime_dark_set_color (ThemeSemanticToken token, const GdkRGBA *col); void theme_runtime_dark_set_color (ThemeSemanticToken token, const GdkRGBA *col);
void theme_runtime_reset_mode_colors (gboolean dark_mode); void theme_runtime_reset_mode_colors (gboolean dark_mode);
void theme_runtime_clear_gtk_mapped_custom_tokens (void);
gboolean theme_runtime_get_color (ThemeSemanticToken token, GdkRGBA *out_rgba); gboolean theme_runtime_get_color (ThemeSemanticToken token, GdkRGBA *out_rgba);
gboolean theme_runtime_mode_has_user_colors (gboolean dark_mode); gboolean theme_runtime_mode_has_user_colors (gboolean dark_mode);
void theme_runtime_get_widget_style_values (ThemeWidgetStyleValues *out_values); void theme_runtime_get_widget_style_values (ThemeWidgetStyleValues *out_values);
+18 -11
View File
@@ -93,14 +93,23 @@ userlist_apply_saved_column_width (GtkTreeViewColumn *column, int width)
static void static void
userlist_update_min_width (session *sess) userlist_update_min_width (session *sess)
{ {
GtkRequisition minimum;
GtkRequisition natural;
GtkWidget *scrolled_window; GtkWidget *scrolled_window;
int width;
if (!sess || !sess->gui || !sess->gui->user_tree) 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);
width = MAX (minimum.width, natural.width);
if (width < 1)
width = 1;
scrolled_window = gtk_widget_get_parent (sess->gui->user_tree); scrolled_window = gtk_widget_get_parent (sess->gui->user_tree);
if (GTK_IS_SCROLLED_WINDOW (scrolled_window)) if (GTK_IS_SCROLLED_WINDOW (scrolled_window))
gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (scrolled_window), 1); gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (scrolled_window), width);
gtk_widget_set_size_request (sess->gui->user_box, width, -1);
} }
GdkPixbuf * GdkPixbuf *
@@ -541,9 +550,9 @@ fe_userlist_insert (session *sess, struct User *newuser, gboolean sel)
prefix_escaped = g_markup_escape_text (prefix_text, -1); prefix_escaped = g_markup_escape_text (prefix_text, -1);
prefix_color = userlist_prefix_color (newuser->prefix[0]); prefix_color = userlist_prefix_color (newuser->prefix[0]);
if (prefix_color) if (prefix_color)
prefix = g_strdup_printf ("<span foreground=\"%s\">%s</span>", prefix_color, prefix_escaped); prefix = g_strdup_printf ("<b><span foreground=\"%s\">%s</span></b>", prefix_color, prefix_escaped);
else else
prefix = g_strdup (prefix_escaped); prefix = g_strdup_printf ("<b>%s</b>", prefix_escaped);
g_free (prefix_escaped); g_free (prefix_escaped);
} }
pix = NULL; pix = NULL;
@@ -900,19 +909,17 @@ userlist_create (GtkWidget *box)
}; };
sw = gtk_scrolled_window_new (NULL, NULL); sw = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_hexpand (sw, TRUE);
gtk_widget_set_vexpand (sw, TRUE);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_IN); GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); prefs.hex_gui_ulist_show_hosts ?
gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (sw), 1); GTK_POLICY_AUTOMATIC :
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (box), sw, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (box), sw, TRUE, TRUE, 0);
gtk_widget_show (sw); gtk_widget_show (sw);
treeview = gtk_tree_view_new (); treeview = gtk_tree_view_new ();
gtk_widget_set_hexpand (treeview, TRUE);
gtk_widget_set_vexpand (treeview, TRUE);
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), FALSE);
+12 -166
View File
@@ -110,15 +110,6 @@ enum
TARGET_COMPOUND_TEXT TARGET_COMPOUND_TEXT
}; };
enum
{
PROP_0,
PROP_HADJUSTMENT,
PROP_VADJUSTMENT,
PROP_HSCROLL_POLICY,
PROP_VSCROLL_POLICY
};
/* Selection targets for PRIMARY selection / copy-paste. /* Selection targets for PRIMARY selection / copy-paste.
* *
@@ -167,8 +158,7 @@ gtk_xtext_install_selection_targets (GtkWidget *widget)
static guint xtext_signals[LAST_SIGNAL]; static guint xtext_signals[LAST_SIGNAL];
G_DEFINE_TYPE_WITH_CODE (GtkXText, gtk_xtext, GTK_TYPE_WIDGET, G_DEFINE_TYPE (GtkXText, gtk_xtext, GTK_TYPE_WIDGET)
G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
char *nocasestrstr (const char *text, const char *tofind); /* util.c */ char *nocasestrstr (const char *text, const char *tofind); /* util.c */
int xtext_get_stamp_str (time_t, char **); int xtext_get_stamp_str (time_t, char **);
@@ -178,13 +168,9 @@ static gboolean gtk_xtext_is_selecting (GtkXText *xtext);
static char *gtk_xtext_selection_get_text (GtkXText *xtext, int *len_ret); static char *gtk_xtext_selection_get_text (GtkXText *xtext, int *len_ret);
static textentry *gtk_xtext_nth (GtkXText *xtext, int line, int *subline); static textentry *gtk_xtext_nth (GtkXText *xtext, int line, int *subline);
static void gtk_xtext_adjustment_changed (GtkAdjustment * adj, static void gtk_xtext_adjustment_changed (GtkAdjustment * adj,
GtkXText * xtext); GtkXText * xtext);
static void gtk_xtext_scroll_adjustments (GtkXText *xtext, GtkAdjustment *hadj, static void gtk_xtext_scroll_adjustments (GtkXText *xtext, GtkAdjustment *hadj,
GtkAdjustment *vadj); GtkAdjustment *vadj);
static void gtk_xtext_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
static void gtk_xtext_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static int gtk_xtext_render_ents (GtkXText * xtext, textentry *, textentry *); static int gtk_xtext_render_ents (GtkXText * xtext, textentry *, textentry *);
static void gtk_xtext_recalc_widths (xtext_buffer *buf, int); static void gtk_xtext_recalc_widths (xtext_buffer *buf, int);
static void gtk_xtext_fix_indent (xtext_buffer *buf); static void gtk_xtext_fix_indent (xtext_buffer *buf);
@@ -808,9 +794,6 @@ gtk_xtext_init (GtkXText * xtext)
xtext->recycle = FALSE; xtext->recycle = FALSE;
xtext->dont_render = FALSE; xtext->dont_render = FALSE;
xtext->dont_render2 = FALSE; xtext->dont_render2 = FALSE;
xtext->hadj = NULL;
xtext->hscroll_policy = GTK_SCROLL_MINIMUM;
xtext->vscroll_policy = GTK_SCROLL_MINIMUM;
gtk_xtext_scroll_adjustments (xtext, NULL, NULL); gtk_xtext_scroll_adjustments (xtext, NULL, NULL);
gtk_xtext_install_selection_targets (GTK_WIDGET (xtext)); gtk_xtext_install_selection_targets (GTK_WIDGET (xtext));
@@ -903,66 +886,6 @@ gtk_xtext_adjustment_changed (GtkAdjustment * adj, GtkXText * xtext)
xtext->buffer->old_value = xtext_adj_get_value (adj); xtext->buffer->old_value = xtext_adj_get_value (adj);
} }
static void
gtk_xtext_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GtkXText *xtext = GTK_XTEXT (object);
GtkAdjustment *adj;
switch (prop_id)
{
case PROP_HADJUSTMENT:
adj = g_value_get_object (value);
if (xtext->hadj == adj)
break;
if (xtext->hadj)
g_object_unref (xtext->hadj);
xtext->hadj = adj ? g_object_ref (adj) : NULL;
g_object_notify (object, "hadjustment");
break;
case PROP_VADJUSTMENT:
gtk_xtext_scroll_adjustments (xtext, NULL, g_value_get_object (value));
g_object_notify (object, "vadjustment");
break;
case PROP_HSCROLL_POLICY:
xtext->hscroll_policy = g_value_get_enum (value);
g_object_notify (object, "hscroll-policy");
break;
case PROP_VSCROLL_POLICY:
xtext->vscroll_policy = g_value_get_enum (value);
g_object_notify (object, "vscroll-policy");
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_xtext_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
GtkXText *xtext = GTK_XTEXT (object);
switch (prop_id)
{
case PROP_HADJUSTMENT:
g_value_set_object (value, xtext->hadj);
break;
case PROP_VADJUSTMENT:
g_value_set_object (value, xtext->adj);
break;
case PROP_HSCROLL_POLICY:
g_value_set_enum (value, xtext->hscroll_policy);
break;
case PROP_VSCROLL_POLICY:
g_value_set_enum (value, xtext->vscroll_policy);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
GtkWidget * GtkWidget *
gtk_xtext_new (const XTextColor *palette, int separator) gtk_xtext_new (const XTextColor *palette, int separator)
{ {
@@ -1029,11 +952,6 @@ gtk_xtext_cleanup (GtkXText *xtext)
xtext->adj = NULL; xtext->adj = NULL;
} }
if (xtext->hadj)
{
g_object_unref (G_OBJECT (xtext->hadj));
xtext->hadj = NULL;
}
if (xtext->hand_cursor) if (xtext->hand_cursor)
{ {
@@ -2300,12 +2218,6 @@ gtk_xtext_leave_notify (GtkWidget * widget, GdkEventCrossing * event)
xtext->hilight_ent = NULL; xtext->hilight_ent = NULL;
} }
if (xtext->tooltip_stamp_set)
{
gtk_widget_set_tooltip_text (widget, NULL);
xtext->tooltip_stamp_set = FALSE;
}
return FALSE; return FALSE;
} }
@@ -2472,7 +2384,7 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
} }
if (xtext->urlcheck_function == NULL) if (xtext->urlcheck_function == NULL)
goto tooltip_check; return FALSE;
word_type = gtk_xtext_get_word_adjust (xtext, x, y, &word_ent, &offset, &len); word_type = gtk_xtext_get_word_adjust (xtext, x, y, &word_ent, &offset, &len);
if (word_type > 0) if (word_type > 0)
@@ -2510,46 +2422,6 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
return FALSE; return FALSE;
} }
tooltip_check:
if (xtext->buffer->time_stamp && xtext->buffer->indent > 0 && x >= 0 && x < xtext->stamp_width)
{
textentry *ent = gtk_xtext_find_char (xtext, x, y, NULL, NULL);
if (ent && (!xtext->tooltip_stamp_set || xtext->tooltip_stamp != ent->stamp))
{
char tooltip[96];
strftime_utf8 (tooltip, sizeof (tooltip), "%Y-%m-%d", ent->stamp);
gtk_widget_set_tooltip_text (widget, tooltip);
xtext->tooltip_stamp = ent->stamp;
xtext->tooltip_stamp_set = TRUE;
}
if (ent)
return FALSE;
}
else if (!xtext->buffer->time_stamp && x >= xtext->buffer->indent)
{
textentry *ent = gtk_xtext_find_char (xtext, x, y, NULL, NULL);
if (ent && ent->stamp && (!xtext->tooltip_stamp_set || xtext->tooltip_stamp != ent->stamp))
{
char tooltip[128];
char date[64];
char *stamp_text;
strftime_utf8 (date, sizeof (date), "%Y-%m-%d", ent->stamp);
xtext_get_stamp_str (ent->stamp, &stamp_text);
g_snprintf (tooltip, sizeof (tooltip), "%s %s", date, stamp_text);
gtk_widget_set_tooltip_text (widget, tooltip);
g_free (stamp_text);
xtext->tooltip_stamp = ent->stamp;
xtext->tooltip_stamp_set = TRUE;
}
if (ent)
return FALSE;
}
else if (xtext->tooltip_stamp_set)
{
gtk_widget_set_tooltip_text (widget, NULL);
xtext->tooltip_stamp_set = FALSE;
}
gtk_xtext_leave_notify (widget, NULL); gtk_xtext_leave_notify (widget, NULL);
return FALSE; return FALSE;
@@ -2984,41 +2856,19 @@ gtk_xtext_scroll (GtkWidget *widget, GdkEventScroll *event)
{ {
GtkXText *xtext = GTK_XTEXT (widget); GtkXText *xtext = GTK_XTEXT (widget);
gfloat new_value; gfloat new_value;
gfloat step;
gdouble dx;
gdouble dy;
int direction = 0;
int speed = prefs.hex_gui_mouse_scroll_speed;
if (speed < 1) if (event->direction == GDK_SCROLL_UP) /* mouse wheel pageUp */
speed = 1;
step = (xtext_adj_get_page_increment (xtext->adj) * speed) / 100.0f;
if (event->direction == GDK_SCROLL_SMOOTH &&
gdk_event_get_scroll_deltas ((GdkEvent *)event, &dx, &dy))
{
if (dy > 0)
direction = 1;
else if (dy < 0)
direction = -1;
}
else if (event->direction == GDK_SCROLL_UP)
direction = -1;
else if (event->direction == GDK_SCROLL_DOWN)
direction = 1;
if (direction < 0)
{ {
new_value = xtext_adj_get_value (xtext->adj) - new_value = xtext_adj_get_value (xtext->adj) -
step; (xtext_adj_get_page_increment (xtext->adj) / 10);
if (new_value < xtext_adj_get_lower (xtext->adj)) if (new_value < xtext_adj_get_lower (xtext->adj))
new_value = xtext_adj_get_lower (xtext->adj); new_value = xtext_adj_get_lower (xtext->adj);
xtext_adj_set_value (xtext->adj, new_value); xtext_adj_set_value (xtext->adj, new_value);
} }
else if (direction > 0) else if (event->direction == GDK_SCROLL_DOWN) /* mouse wheel pageDn */
{ {
new_value = xtext_adj_get_value (xtext->adj) + new_value = xtext_adj_get_value (xtext->adj) +
step; (xtext_adj_get_page_increment (xtext->adj) / 10);
if (new_value > (xtext_adj_get_upper (xtext->adj) - if (new_value > (xtext_adj_get_upper (xtext->adj) -
xtext_adj_get_page_size (xtext->adj))) xtext_adj_get_page_size (xtext->adj)))
new_value = xtext_adj_get_upper (xtext->adj) - new_value = xtext_adj_get_upper (xtext->adj) -
@@ -3026,7 +2876,7 @@ gtk_xtext_scroll (GtkWidget *widget, GdkEventScroll *event)
xtext_adj_set_value (xtext->adj, new_value); xtext_adj_set_value (xtext->adj, new_value);
} }
return direction != 0; return FALSE;
} }
static void static void
@@ -3074,13 +2924,6 @@ gtk_xtext_class_init (GtkXTextClass * class)
widget_class = (GtkWidgetClass *) class; widget_class = (GtkWidgetClass *) class;
xtext_class = (GtkXTextClass *) class; xtext_class = (GtkXTextClass *) class;
object_class->set_property = gtk_xtext_set_property;
object_class->get_property = gtk_xtext_get_property;
g_object_class_override_property (object_class, PROP_HADJUSTMENT, "hadjustment");
g_object_class_override_property (object_class, PROP_VADJUSTMENT, "vadjustment");
g_object_class_override_property (object_class, PROP_HSCROLL_POLICY, "hscroll-policy");
g_object_class_override_property (object_class, PROP_VSCROLL_POLICY, "vscroll-policy");
xtext_signals[WORD_CLICK] = xtext_signals[WORD_CLICK] =
g_signal_new ("word_click", g_signal_new ("word_click",
G_TYPE_FROM_CLASS (object_class), G_TYPE_FROM_CLASS (object_class),
@@ -4987,12 +4830,13 @@ gtk_xtext_check_marker_visibility (GtkXText * xtext)
static void static void
gtk_xtext_unstrip_color (gint start, gint end, GSList *slp, GList **gl, gint maxo) gtk_xtext_unstrip_color (gint start, gint end, GSList *slp, GList **gl, gint maxo)
{ {
gint off1, off2; gint off1, off2, curlen;
GSList *cursl; GSList *cursl;
offsets_t marks; offsets_t marks;
offlen_t *meta; offlen_t *meta;
off1 = 0; off1 = 0;
curlen = 0;
cursl = slp; cursl = slp;
while (cursl) while (cursl)
{ {
@@ -5002,6 +4846,7 @@ gtk_xtext_unstrip_color (gint start, gint end, GSList *slp, GList **gl, gint max
off1 = meta->off + start; off1 = meta->off + start;
break; break;
} }
curlen += meta->len;
start -= meta->len; start -= meta->len;
end -= meta->len; end -= meta->len;
cursl = g_slist_next (cursl); cursl = g_slist_next (cursl);
@@ -5016,6 +4861,7 @@ gtk_xtext_unstrip_color (gint start, gint end, GSList *slp, GList **gl, gint max
off2 = meta->off + end; off2 = meta->off + end;
break; break;
} }
curlen += meta->len;
end -= meta->len; end -= meta->len;
cursl = g_slist_next (cursl); cursl = g_slist_next (cursl);
} }
-5
View File
@@ -134,9 +134,6 @@ struct _GtkXText
xtext_buffer *selection_buffer; xtext_buffer *selection_buffer;
GtkAdjustment *adj; GtkAdjustment *adj;
GtkAdjustment *hadj;
GtkScrollablePolicy hscroll_policy;
GtkScrollablePolicy vscroll_policy;
cairo_surface_t *background_surface; /* 0 = use palette[19] */ cairo_surface_t *background_surface; /* 0 = use palette[19] */
cairo_surface_t *background_clip_surface; cairo_surface_t *background_clip_surface;
GdkWindow *draw_window; /* points to ->window */ GdkWindow *draw_window; /* points to ->window */
@@ -190,8 +187,6 @@ struct _GtkXText
textentry *hilight_ent; textentry *hilight_ent;
int hilight_start; int hilight_start;
int hilight_end; int hilight_end;
time_t tooltip_stamp;
unsigned int tooltip_stamp_set:1;
guint16 fontwidth[128]; /* each char's width, only the ASCII ones */ guint16 fontwidth[128]; /* each char's width, only the ASCII ones */

Some files were not shown because too many files have changed in this diff Show More