Compare commits
104 Commits
master.min
...
tricia-bac
Author | SHA1 | Date |
---|---|---|
|
0f6148c892 | |
|
5fae2771c8 | |
|
c912a44774 | |
|
0d006777fc | |
|
2e074fd0ed | |
|
8a0c1f6e08 | |
|
3e37213b5e | |
|
b7ee3bf83b | |
|
359fcb87c5 | |
|
a549184217 | |
|
eda7a9a23c | |
|
4dff6fa7e1 | |
|
8763fbf5df | |
|
9d3d2acfd9 | |
|
96d6a9c0fb | |
|
7cc3d5967b | |
|
54978e6e8f | |
|
69895bd026 | |
|
3066879089 | |
|
f4c882e3b5 | |
|
cd94beb376 | |
|
350e3ffc29 | |
|
52ee1591f7 | |
|
db60af5efb | |
|
dde92eecbf | |
|
7bdc217e8c | |
|
2520d1c087 | |
|
116bfc2ac1 | |
|
1820d0db69 | |
|
17062aaa18 | |
|
aa7dabad39 | |
|
15ec9b4e65 | |
|
612f36cea9 | |
|
e7328ad12e | |
|
172f323b4b | |
|
4044529191 | |
|
992ca7a3ec | |
|
67892da099 | |
|
2ebff67c9c | |
|
43ee0436d8 | |
|
fb0002bdcd | |
|
2e3f337e84 | |
|
d208cae3bc | |
|
05b68fb5f5 | |
|
42da8bc289 | |
|
fe1c4f1e38 | |
|
c57ad618a1 | |
|
39e08bd3b8 | |
|
b868ebde1c | |
|
dc1104c93b | |
|
c30f2a988d | |
|
465226e185 | |
|
7220975463 | |
|
088ec7b031 | |
|
f6bc8206ed | |
|
0ec63fc00e | |
|
7ce2a750db | |
|
6e36dc4a5f | |
|
39cadaa36e | |
|
834266682c | |
|
3523968707 | |
|
494a2e7ce3 | |
|
0b1133ac44 | |
|
986655d6aa | |
|
06a20265ea | |
|
66c155a386 | |
|
fe3fa259fb | |
|
ac9d0a9343 | |
|
bc381189c7 | |
|
d4de361efb | |
|
d99074ec5e | |
|
dfcf007a44 | |
|
4f43977c59 | |
|
7bebfc9b97 | |
|
8c6125e8fa | |
|
e7c4d897dd | |
|
44ec63074e | |
|
fdd6c18a51 | |
|
51383ae711 | |
|
7951868e92 | |
|
9788914d86 | |
|
0409e91288 | |
|
8a32b92c33 | |
|
3999de8f59 | |
|
37338603dc | |
|
87cd264acf | |
|
a86c482308 | |
|
bd32e81f13 | |
|
19354f86c1 | |
|
39dcfcab0b | |
|
6c7e40c3ba | |
|
0a25600883 | |
|
a5af28a95d | |
|
a13a573228 | |
|
100428eaf9 | |
|
d86c906848 | |
|
ddaf70747c | |
|
6159ad5be2 | |
|
6383f71fa0 | |
|
c269c57777 | |
|
561c94e71a | |
|
78ca6d13e0 | |
|
bc18f166a3 | |
|
ef9294aae2 |
|
@ -46,11 +46,6 @@ shared: &shared
|
|||
fi
|
||||
|
||||
jobs:
|
||||
"mint18":
|
||||
<<: *shared
|
||||
docker:
|
||||
- image: linuxmintd/mint18-amd64
|
||||
|
||||
"mint19":
|
||||
<<: *shared
|
||||
docker:
|
||||
|
@ -65,6 +60,5 @@ workflows:
|
|||
version: 2
|
||||
build:
|
||||
jobs:
|
||||
- "mint18"
|
||||
- "mint19"
|
||||
- "lmde3"
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# Specify filepatterns you want git to ignore.
|
||||
debian/tmp/
|
||||
debian/build/
|
||||
debian/.debhelper/
|
||||
debian/xed/
|
||||
debian/xed-common/
|
||||
debian/xed-dbg/
|
||||
debian/xed-dev/
|
||||
debian/xed-doc/
|
||||
debian/files
|
||||
debian/*.log
|
||||
debian/*.substvars
|
||||
build
|
70
Makefile.am
70
Makefile.am
|
@ -1,70 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
||||
|
||||
SUBDIRS = xed pixmaps po data plugins docs help
|
||||
|
||||
distuninstallcheck_listfiles = find . -type f -print
|
||||
|
||||
EXTRA_DIST = \
|
||||
autogen.sh \
|
||||
ChangeLog \
|
||||
HACKING \
|
||||
NEWS \
|
||||
NEWS.GNOME \
|
||||
README \
|
||||
xmldocs.make \
|
||||
omf.make \
|
||||
intltool-extract.in \
|
||||
intltool-merge.in \
|
||||
intltool-update.in
|
||||
|
||||
DISTCLEANFILES = \
|
||||
intltool-extract \
|
||||
intltool-merge \
|
||||
intltool-update
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
aclocal.m4 \
|
||||
config.guess \
|
||||
config.h.in \
|
||||
config.sub \
|
||||
depcomp \
|
||||
intltool-extract.in \
|
||||
intltool-merge.in \
|
||||
intltool-update.in \
|
||||
configure \
|
||||
INSTALL \
|
||||
gtk-doc.make \
|
||||
install-sh \
|
||||
ltmain.sh \
|
||||
missing \
|
||||
mkinstalldirs \
|
||||
omf.make \
|
||||
py-compile \
|
||||
xmldocs.make \
|
||||
m4/gtk-doc.m4 \
|
||||
m4/intltool.m4 \
|
||||
m4/libtool.m4 \
|
||||
m4/ltoptions.m4 \
|
||||
m4/ltsugar.m4 \
|
||||
m4/ltversion.m4 \
|
||||
m4/lt~obsolete.m4 \
|
||||
`find "$(srcdir)" -type f -name Makefile.in -print`
|
||||
|
||||
DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
|
||||
|
||||
dist-hook:
|
||||
@if test -d "$(srcdir)/.git"; \
|
||||
then \
|
||||
echo Creating ChangeLog && \
|
||||
(GIT_DIR=$(top_srcdir)/.git \
|
||||
./missing --run git log --stat -M -C --name-status --date=short --no-color) | \
|
||||
fmt --split-only > ChangeLog.tmp \
|
||||
&& mv -f ChangeLog.tmp $(top_distdir)/ChangeLog \
|
||||
|| ( rm -f ChangeLog.tmp ; \
|
||||
echo Failed to generate ChangeLog >&2 ); \
|
||||
else \
|
||||
echo A git clone is required to generate a ChangeLog >&2; \
|
||||
fi
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
8
README
8
README
|
@ -35,7 +35,9 @@ Installation
|
|||
|
||||
Simple install procedure:
|
||||
|
||||
% ./autogen.sh # run the `configure' script
|
||||
% make # build xed
|
||||
% meson --prefix=/usr/local build # run the `configure' script
|
||||
% ninja -v -C build # build xed
|
||||
[ Become root if necessary ]
|
||||
% make install # install xed
|
||||
% sudo ninja install -v -C build # install xed
|
||||
|
||||
see linuxmint/xed#265 if you see GLib-GIO-ERROR
|
||||
|
|
31
autogen.sh
31
autogen.sh
|
@ -1,31 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Run this to generate all the initial makefiles, etc.
|
||||
|
||||
srcdir=`dirname $0`
|
||||
test -z "$srcdir" && srcdir=.
|
||||
|
||||
PKG_NAME="xed"
|
||||
|
||||
(test -f $srcdir/configure.ac) || {
|
||||
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
|
||||
echo " top-level $PKG_NAME directory"
|
||||
exit 1
|
||||
}
|
||||
|
||||
which gnome-autogen.sh || {
|
||||
echo "You need to install gnome-common"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
which yelp-build || {
|
||||
echo "You need to install yelp-tools"
|
||||
exit 1
|
||||
}
|
||||
|
||||
REQUIRED_AUTOMAKE_VERSION=1.9
|
||||
GNOME_DATADIR="$gnome_datadir"
|
||||
USE_COMMON_DOC_BUILD=yes
|
||||
|
||||
. gnome-autogen.sh
|
||||
|
260
configure.ac
260
configure.ac
|
@ -1,260 +0,0 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.63.2)
|
||||
|
||||
m4_define(xed_major_version, 1)
|
||||
m4_define(xed_minor_version, 6)
|
||||
m4_define(xed_micro_version, 3)
|
||||
m4_define(xed_version, xed_major_version.xed_minor_version.xed_micro_version)
|
||||
|
||||
AC_INIT([xed], [xed_version],
|
||||
[https://github.com/linuxmint/xed/issues],
|
||||
[xed], [http://github.com/linuxmint/xed])
|
||||
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
AC_CONFIG_SRCDIR(xed/xed.c)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AC_DEFINE(XED_MAJOR_VERSION, xed_major_version, [Xed major version])
|
||||
AC_SUBST(XED_MAJOR_VERSION, xed_major_version)
|
||||
AC_DEFINE(XED_MINOR_VERSION, xed_minor_version, [Xed minor version])
|
||||
AC_SUBST(XED_MINOR_VERSION, xed_minor_version)
|
||||
AC_DEFINE(XED_MICRO_VERSION, xed_micro_version, [Xed micro version])
|
||||
AC_SUBST(XED_MICRO_VERSION, xed_micro_version)
|
||||
|
||||
AM_INIT_AUTOMAKE([1.10 dist-xz no-dist-gzip -Wno-portability check-news])
|
||||
AM_MAINTAINER_MODE
|
||||
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
||||
|
||||
# Checks for programs
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MAKE_SET
|
||||
AC_SYS_LARGEFILE
|
||||
PKG_PROG_PKG_CONFIG
|
||||
|
||||
# Initialize libtool
|
||||
LT_PREREQ([2.2.6])
|
||||
LT_INIT(disable-static)
|
||||
|
||||
GTK_DOC_CHECK([1.0],[--flavour=no-tmpl])
|
||||
|
||||
AC_CHECK_FUNC(sigaction)
|
||||
AC_CHECK_LIB(m, floor)
|
||||
|
||||
dnl make sure we keep ACLOCAL_FLAGS around for maintainer builds to work
|
||||
AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS -I m4")
|
||||
|
||||
dnl toolbar style for GSettings schemas
|
||||
TOOLBAR_STYLE="XED_TOOLBAR_SYSTEM"
|
||||
AC_SUBST(TOOLBAR_STYLE)
|
||||
|
||||
dnl ===============================================================
|
||||
dnl Expanded dirs
|
||||
dnl ===============================================================
|
||||
|
||||
# This macro expands DIR and assigns it to RET.
|
||||
# If DIR is NONE, then it's replaced by DEFAULT.
|
||||
# Based on AC_DEFINE_DIR
|
||||
AC_DEFUN([XED_FULLPATH], [
|
||||
test "x$prefix" = xNONE && prefix="$ac_default_prefix"
|
||||
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
|
||||
ac_expand=[$]$1
|
||||
test "x$ac_expand" = xNONE && ac_expand="[$]$2"
|
||||
ac_expand=`eval echo [$]ac_expand`
|
||||
$3=`eval echo [$]ac_expand`
|
||||
])
|
||||
|
||||
dnl ================================================================
|
||||
dnl Gettext stuff.
|
||||
dnl ================================================================
|
||||
|
||||
IT_PROG_INTLTOOL([0.50.1])
|
||||
GETTEXT_PACKAGE=xed
|
||||
AC_SUBST([GETTEXT_PACKAGE])
|
||||
AM_GLIB_GNU_GETTEXT
|
||||
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Define to the Gettext package name])
|
||||
|
||||
dnl ================================================================
|
||||
dnl Use gvfs metadata or the old xml file store.
|
||||
dnl ================================================================
|
||||
|
||||
AC_ARG_ENABLE([gvfs-metadata],
|
||||
AS_HELP_STRING([--enable-gvfs-metadata], [Enable using gvfs to store metadata]),
|
||||
[enable_gvfs_metadata=$enableval],
|
||||
[enable_gvfs_metadata=yes])
|
||||
|
||||
AM_CONDITIONAL(ENABLE_GVFS_METADATA, test "x$enable_gvfs_metadata" != "xno")
|
||||
|
||||
if test "x$enable_gvfs_metadata" != "xno"; then
|
||||
AC_DEFINE([ENABLE_GVFS_METADATA], [1], [Define to enable using gvfs metadata])
|
||||
fi
|
||||
|
||||
dnl ================================================================
|
||||
dnl spell plugins checks: enchant and iso-codes
|
||||
dnl ================================================================
|
||||
|
||||
ENCHANT_REQUIRED=1.2.0
|
||||
ISO_CODES_REQUIRED=0.35
|
||||
|
||||
AC_ARG_ENABLE([spell],
|
||||
AS_HELP_STRING([--disable-spell],[Disable spell plugin (default: enabled)]),
|
||||
[enable_enchant=$enableval],
|
||||
[enable_enchant=yes])
|
||||
|
||||
if test "x$enable_enchant" = "xyes" ; then
|
||||
|
||||
PKG_CHECK_MODULES(ENCHANT, enchant >= $ENCHANT_REQUIRED, \
|
||||
have_enchant=yes, have_enchant=no)
|
||||
|
||||
if test "x$have_enchant" = "xyes"; then
|
||||
|
||||
PKG_CHECK_EXISTS([iso-codes >= $ISO_CODES_REQUIRED],
|
||||
[have_iso_codes=yes],[have_iso_codes=no])
|
||||
|
||||
if test "x$have_iso_codes" = "xyes"; then
|
||||
AC_MSG_CHECKING([whether iso-codes has iso-639 and iso-3166 domains])
|
||||
if $PKG_CONFIG --variable=domains iso-codes | grep 639 > /dev/null && \
|
||||
$PKG_CONFIG --variable=domains iso-codes | grep 3166 > /dev/null ; then
|
||||
result=yes
|
||||
else
|
||||
result=no
|
||||
have_iso_codes=no
|
||||
fi
|
||||
AC_MSG_RESULT([$result])
|
||||
fi
|
||||
|
||||
if test "x$have_iso_codes" = "xyes"; then
|
||||
AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["`$PKG_CONFIG --variable=prefix iso-codes`"],[ISO codes prefix])
|
||||
AC_DEFINE([HAVE_ISO_CODES],[1],[Define if you have the iso-codes package])
|
||||
else
|
||||
AC_MSG_ERROR([iso-codes is required to build the spell plugin. Use --disable-spell to build without spell plugin.])
|
||||
fi
|
||||
else
|
||||
enable_enchant=no
|
||||
AC_MSG_ERROR([Enchant library not found or too old. Use --disable-spell to build without spell plugin.])
|
||||
fi
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(ENABLE_ENCHANT, test x"$enable_enchant" = "xyes")
|
||||
|
||||
dnl ================================================================
|
||||
dnl Start of pkg-config checks
|
||||
dnl ================================================================
|
||||
|
||||
PKG_CHECK_MODULES(GMODULE,gmodule-2.0,[GMODULE_ADD="gmodule-2.0"],[GMODULE_ADD=""])
|
||||
PKG_CHECK_MODULES(XED, [
|
||||
libxml-2.0 >= 2.5.0
|
||||
glib-2.0 >= 2.40.0
|
||||
$GMODULE_ADD
|
||||
gthread-2.0 >= 2.13.0
|
||||
gio-2.0 >= 2.40.0
|
||||
gtk+-3.0 >= 3.18.0
|
||||
gtksourceview-3.0 >= 3.18.0
|
||||
libpeas-1.0 >= 1.12.0
|
||||
libpeas-gtk-1.0 >= 1.12.0
|
||||
])
|
||||
|
||||
PKG_CHECK_MODULES(X11, [x11])
|
||||
|
||||
XED_CFLAGS="$XED_CFLAGS $X11_CFLAGS"
|
||||
XED_LIBS="$XED_LIBS $X11_LIBS"
|
||||
|
||||
AC_SUBST(XED_CFLAGS)
|
||||
AC_SUBST(XED_LIBS)
|
||||
|
||||
# Introspection
|
||||
GOBJECT_INTROSPECTION_CHECK([0.9.3])
|
||||
|
||||
if test "$found_introspection" = "yes"; then
|
||||
enable_introspection=yes
|
||||
AC_DEFINE([ENABLE_INTROSPECTION], [1], [Define to enable GObject Introspection])
|
||||
else
|
||||
enable_introspection=no
|
||||
fi
|
||||
|
||||
AM_PATH_PYTHON([3.4])
|
||||
|
||||
dnl ================================================================
|
||||
dnl GSettings related settings
|
||||
dnl ================================================================
|
||||
|
||||
GLIB_GSETTINGS
|
||||
|
||||
dnl ================================================================
|
||||
dnl Misc
|
||||
dnl ================================================================
|
||||
AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
|
||||
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
|
||||
AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
|
||||
|
||||
GNOME_COMPILE_WARNINGS(yes)
|
||||
|
||||
AC_ARG_ENABLE(deprecations,
|
||||
[AS_HELP_STRING([--enable-deprecations],
|
||||
[warn about deprecated usages [default=no]])],,
|
||||
[enable_deprecations=no])
|
||||
|
||||
if test "x$enable_deprecations" = "xyes"; then
|
||||
DISABLE_DEPRECATED_CFLAGS="\
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGTK_DISABLE_DEPRECATED \
|
||||
-DGDK_PIXBUF_DISABLE_DEPRECATED \
|
||||
-DGNOME_DISABLE_DEPRECATED"
|
||||
AC_SUBST(DISABLE_DEPRECATED_CFLAGS)
|
||||
fi
|
||||
|
||||
PLUGIN_LIBTOOL_FLAGS="-module -avoid-version"
|
||||
|
||||
AC_SUBST(PLUGIN_LIBTOOL_FLAGS)
|
||||
|
||||
XED_PLUGINS_DATA_DIR="$datadir/xed/plugins"
|
||||
AC_SUBST(XED_PLUGINS_DATA_DIR)
|
||||
|
||||
XED_PLUGINS_LIBS_DIR="$libdir/xed/plugins"
|
||||
AC_SUBST(XED_PLUGINS_LIBS_DIR)
|
||||
|
||||
YELP_HELP_INIT
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
data/xed.desktop.in
|
||||
data/xed-bugreport.sh
|
||||
data/xed.pc
|
||||
data/org.x.editor.gschema.xml
|
||||
data/Makefile
|
||||
docs/Makefile
|
||||
docs/reference/Makefile
|
||||
xed/Makefile
|
||||
help/Makefile
|
||||
pixmaps/Makefile
|
||||
plugins/Makefile
|
||||
plugins/docinfo/Makefile
|
||||
plugins/filebrowser/Makefile
|
||||
plugins/filebrowser/org.x.editor.plugins.filebrowser.gschema.xml
|
||||
plugins/modelines/Makefile
|
||||
plugins/sort/Makefile
|
||||
plugins/spell/Makefile
|
||||
plugins/spell/org.x.editor.plugins.spell.gschema.xml
|
||||
plugins/taglist/Makefile
|
||||
plugins/textsize/Makefile
|
||||
plugins/textsize/textsize/Makefile
|
||||
plugins/time/Makefile
|
||||
plugins/time/org.x.editor.plugins.time.gschema.xml
|
||||
plugins/trailsave/Makefile
|
||||
po/Makefile.in
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
echo "
|
||||
|
||||
Configuration:
|
||||
|
||||
Source code location: ${srcdir}
|
||||
Compiler: ${CC}
|
||||
Spell Plugin enabled: $enable_enchant
|
||||
Gvfs metadata enabled: $enable_gvfs_metadata
|
||||
GObject Introspection: ${enable_introspection}
|
||||
"
|
|
@ -1,49 +0,0 @@
|
|||
desktopdir = $(datadir)/applications
|
||||
desktop_in_files = xed.desktop.in
|
||||
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
|
||||
@INTLTOOL_DESKTOP_RULE@
|
||||
|
||||
@INTLTOOL_XML_RULE@
|
||||
|
||||
appdatadir = $(datadir)/appdata
|
||||
appdata_in_files = xed.appdata.xml.in
|
||||
appdata_DATA = $(appdata_in_files:.xml.in=.xml)
|
||||
|
||||
gsettings_SCHEMAS = org.x.editor.gschema.xml
|
||||
|
||||
@GSETTINGS_RULES@
|
||||
|
||||
servicedir = $(datadir)/dbus-1/services
|
||||
service_in_files = org.x.editor.service.in
|
||||
service_DATA = $(service_in_files:.service.in=.service)
|
||||
|
||||
$(service_DATA): $(service_in_files) Makefile
|
||||
@sed -e "s|\@bindir\@|$(bindir)|" $<> $@
|
||||
|
||||
man_MANS = xed.1
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = xed.pc
|
||||
|
||||
bugreportdir = $(libexecdir)/xed
|
||||
bugreport_SCRIPTS = xed-bugreport.sh
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(appdata_in_files) \
|
||||
$(desktop_in_files) \
|
||||
$(service_in_files) \
|
||||
$(man_MANS) \
|
||||
xed.pc.in \
|
||||
xed-bugreport.sh.in
|
||||
|
||||
CLEANFILES = \
|
||||
$(desktop_DATA) \
|
||||
$(service_DATA) \
|
||||
$(gsettings_SCHEMAS) \
|
||||
$(pkgconfig_DATA) \
|
||||
$(appdata_DATA)
|
||||
|
||||
|
||||
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,42 @@
|
|||
desktop = custom_target(
|
||||
'desktop',
|
||||
input: 'xed.desktop.in.in',
|
||||
output: 'xed.desktop',
|
||||
command: [intltool_merge, '-d', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: desktopdir,
|
||||
)
|
||||
|
||||
appdata = custom_target(
|
||||
'appdata',
|
||||
input: 'xed.appdata.xml.in',
|
||||
output: 'xed.appdata.xml',
|
||||
command: [intltool_merge, '-x', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: join_paths(datadir, 'metainfo'),
|
||||
)
|
||||
|
||||
schema_conf = configuration_data()
|
||||
schema_conf.set('GETTEXT_PACKAGE', 'xed')
|
||||
|
||||
schema_file = configure_file(
|
||||
input: 'org.x.editor.gschema.xml.in',
|
||||
output: 'org.x.editor.gschema.xml',
|
||||
configuration: schema_conf,
|
||||
install_dir: join_paths(datadir, 'glib-2.0', 'schemas')
|
||||
)
|
||||
|
||||
service_conf = configuration_data()
|
||||
service_conf.set('bindir', join_paths(prefix, bindir))
|
||||
|
||||
configure_file(
|
||||
input: 'org.x.editor.service.in',
|
||||
output: 'org.x.editor.service',
|
||||
configuration: service_conf,
|
||||
install_dir: join_paths(datadir, 'dbus-1', 'services')
|
||||
)
|
||||
|
||||
install_data(
|
||||
'xed.1',
|
||||
install_dir : join_paths(get_option('prefix'), get_option('mandir'), 'man1')
|
||||
)
|
|
@ -167,6 +167,36 @@
|
|||
<description>Whether xed will ensure that documents always end with a trailing newline.</description>
|
||||
</key>
|
||||
|
||||
<key name="draw-whitespace" type="b">
|
||||
<default>false</default>
|
||||
<summary>Draw whitespace</summary>
|
||||
<description>Whether xed should render whitespace</description>
|
||||
</key>
|
||||
|
||||
<key name="draw-whitespace-leading" type="b">
|
||||
<default>false</default>
|
||||
<summary>Draw leading whitespace</summary>
|
||||
<description>Whether xed should render leading whitespace</description>
|
||||
</key>
|
||||
|
||||
<key name="draw-whitespace-inside" type="b">
|
||||
<default>false</default>
|
||||
<summary>Draw whitespace within text</summary>
|
||||
<description>Whether xed should render whitespace between words and characters</description>
|
||||
</key>
|
||||
|
||||
<key name="draw-whitespace-trailing" type="b">
|
||||
<default>false</default>
|
||||
<summary>Draw trailing whitespace</summary>
|
||||
<description>Whether xed should render trailing whitespace</description>
|
||||
</key>
|
||||
|
||||
<key name="draw-whitespace-newline" type="b">
|
||||
<default>false</default>
|
||||
<summary>Draw newline characters</summary>
|
||||
<description>Whether xed should render newline characters</description>
|
||||
</key>
|
||||
|
||||
</schema>
|
||||
|
||||
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.x.editor.preferences.ui" path="/org/x/editor/preferences/ui/">
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
PKG_CONFIG_MODULES="glib-2.0 gtk+-3.0 gtksourceview-3.0 enchant iso-codes"
|
||||
|
||||
echo_padded ()
|
||||
{
|
||||
echo -n " - $1 "
|
||||
N=$(echo -n $1 | wc -m)
|
||||
while test $N -le 20
|
||||
do
|
||||
echo -n " "
|
||||
N=`expr $N + 1`
|
||||
done
|
||||
}
|
||||
|
||||
if (which gsettings >/dev/null)
|
||||
then
|
||||
echo "GSettings configuration dump:"
|
||||
gsettings list-recursively org.x.editor
|
||||
echo
|
||||
fi
|
||||
|
||||
echo "Active plugins:"
|
||||
gsettings get org.x.editor active-plugins \
|
||||
| sed -r -e 's/^\[(.*)\]$/\1/' -e 's/, /\n/g' \
|
||||
| sed -e 's/^.*$/ - \0/'
|
||||
echo
|
||||
|
||||
# Manually installed plugins (in $HOME)
|
||||
if [ -d $HOME/.config/xed/plugins ]
|
||||
then
|
||||
echo "Plugins in \$HOME:"
|
||||
ls $HOME/.config/xed/plugins/*.xed-plugin \
|
||||
| sed -r -e 's#.*/([^/]*)\.xed-plugin$# - \1#'
|
||||
else
|
||||
echo "No plugin installed in \$HOME."
|
||||
fi
|
||||
echo
|
||||
|
||||
echo "Module versions:"
|
||||
if (which pkg-config > /dev/null)
|
||||
then
|
||||
for i in $PKG_CONFIG_MODULES
|
||||
do
|
||||
echo_padded "`echo -n $i | sed -r -e 's/^(.*)-[0-9]\.[0-9]$/\1/'`"
|
||||
pkg-config --modversion $i 2>/dev/null || echo
|
||||
done
|
||||
else
|
||||
echo " pkg-config unavailable"
|
||||
fi
|
||||
echo
|
|
@ -1,12 +0,0 @@
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
pluginsdir=@libdir@/xed/plugins
|
||||
|
||||
Name: xed
|
||||
Description: xed
|
||||
Requires: gtksourceview-3.0 libpeas-1.0 libpeas-gtk-1.0
|
||||
Version: @VERSION@
|
||||
Cflags: -I${includedir}/xed
|
||||
Libs: -L${libdir}
|
|
@ -1,3 +1,239 @@
|
|||
xed (2.4.3) tricia; urgency=medium
|
||||
|
||||
[ okaestne ] [backported by wolfpackmars2]
|
||||
* Implement #225: Options to render whitespace
|
||||
* backported from xed-3
|
||||
|
||||
xed (2.4.2) tricia; urgency=medium
|
||||
|
||||
* l10n: Update translations
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Wed, 11 Dec 2019 14:49:32 +0000
|
||||
|
||||
xed (2.4.1) tricia; urgency=medium
|
||||
|
||||
* l10n: Update translations
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Tue, 26 Nov 2019 17:14:23 +0000
|
||||
|
||||
xed (2.4.0) tricia; urgency=medium
|
||||
|
||||
[ Michael Webster ]
|
||||
* print-preview: add a print button to the preview toolbar, to immediately print the previewed document.
|
||||
|
||||
[ nardholio ]
|
||||
* Packaging: remove dependency on libpeas-1.0-0-python3loader (#325)
|
||||
|
||||
[ Pavel Shlyak ]
|
||||
* Cleanup (#321)
|
||||
|
||||
[ Leigh Scott ]
|
||||
* add open uri plugin (#317)
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* open-uri: Make the plugin built-in
|
||||
* open-uri: Simplify and fix translations
|
||||
* Print preview: Reuse existing msgid
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Fri, 22 Nov 2019 12:12:12 +0000
|
||||
|
||||
xed (2.2.3) tina; urgency=medium
|
||||
|
||||
* l10n: Update translations
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Sun, 28 Jul 2019 15:03:33 +0200
|
||||
|
||||
xed (2.2.2) tina; urgency=medium
|
||||
|
||||
* Preferences: Make dialog slightly taller
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Thu, 25 Jul 2019 10:59:55 +0200
|
||||
|
||||
xed (2.2.1) tina; urgency=medium
|
||||
|
||||
[ Alexander Drozdov ]
|
||||
* Automatically open new Xed window on current workspace... (#319)
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* l10n: Update translations
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Wed, 10 Jul 2019 11:26:12 +0200
|
||||
|
||||
xed (2.2.0) tina; urgency=medium
|
||||
|
||||
[ Eli Schwartz ]
|
||||
* meson: require itstool command to be available (#266)
|
||||
|
||||
[ JosephMcc ]
|
||||
* statusbar: Fix the menu button styling (#281)
|
||||
* cleanup: Remove an unused Makefile.am (#280)
|
||||
|
||||
[ Stephen Collins ]
|
||||
* print preview: fix layout drawing for 1X2 and 2X1 layouts (#291)
|
||||
* Filebrowser: Kill the click policy property with fire (#293)
|
||||
|
||||
[ JosephMcc ]
|
||||
* xed-window: Fix the tabs/spaces label in the statusbar (#283)
|
||||
* xed-notebook: Always show the main notebook tabs (#285)
|
||||
|
||||
[ Stephen Collins ]
|
||||
* Fix some deprecation warnings (#289)
|
||||
* print preview: fix logic for forward button sensitivity (#292)
|
||||
* Add toggle comment and toggle comment block actions w/ keybindings (#290)
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* l10n: Update POT
|
||||
|
||||
[ Stephen Collins ]
|
||||
* print job: replace some deprecated font button functions (#294)
|
||||
* Replace deprecated gdk_cursor_new with gdk_cursor_new_for_display (#295)
|
||||
* Print preview: remove a couple calls to gtk_adjustment_value_changed (#296)
|
||||
* Search: replace a few functions that were deprecated in Gtk 3.22 (#297)
|
||||
* Fix stuttering and disappearing of the toolbar when fullscreen (#300)
|
||||
* Switch deprecated gtk_icon_info_free to g_object_unref (#301)
|
||||
* Remove references to deprecated GTK_STOCK_* (#298)
|
||||
* Remove deprecated call to gtk_widget_override_background_color (#299)
|
||||
* Tab width popup: only select a menu item when the menu is open (#311)
|
||||
* Simplify an if statement. The logic is identical, but easier to read (#314)
|
||||
|
||||
[ Leigh Scott ]
|
||||
* Add minimum required version for xapp (#313)
|
||||
|
||||
[ Stephen Collins ]
|
||||
* Prevent a warning when closing the window while print preview is open (#315)
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* l10n: Update POT
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Sat, 29 Jun 2019 17:23:48 +0200
|
||||
|
||||
xed (2.0.2) tessa; urgency=medium
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* Fix non-translated desktop file
|
||||
|
||||
[ Michael Webster ]
|
||||
* highlight mode window: Make activatable via shortcut (ctrl-shift-H), focus the search entry by default, and allow Escape to cancel the dialog from the search entry.
|
||||
|
||||
[ chingyinwan123 ]
|
||||
* Fix warnings when building xed 2.0.1 (#264)
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* l10n: Update translations
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Tue, 11 Dec 2018 14:10:08 +0000
|
||||
|
||||
xed (2.0.1) tessa; urgency=medium
|
||||
|
||||
[ Leigh Scott ]
|
||||
* Switch build instructions for meson port. (#263)
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* l10n: Update translations
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Tue, 27 Nov 2018 18:33:21 +0000
|
||||
|
||||
xed (2.0.0) tessa; urgency=medium
|
||||
|
||||
[ Tomasz Gąsior ]
|
||||
* Import GeditHighlightModeDialog and -Selector from Gedit to Xed.
|
||||
* Use highlight dialog instead submenu in "View" menu.
|
||||
* XedWindow cleanup.
|
||||
* Import GeditStatusMenuButton.
|
||||
* Fix compilation warning.
|
||||
* Use popover with highlight selector instead loooong menu in statusbar.
|
||||
* Use XedStatusMenuButton instead -ComboBox in statusbar, for consistency.
|
||||
* Kill XedStatusComboBox. It's not used now.
|
||||
|
||||
[ JosephMcc ]
|
||||
* xed-window: Indicate if we are currently using spaces or tabs in statusbar (#246)
|
||||
|
||||
[ NikoKrause ]
|
||||
* Use icon for keyboard shortcuts help entry (#255)
|
||||
* Rearrange help entries (xapp consistency) (#256)
|
||||
* close dialog: use "suggested-action" style class (#261)
|
||||
|
||||
[ Stephen Collins ]
|
||||
* Port to meson (#258)
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* Fix merge issues
|
||||
* l10n: Update POT
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Mon, 19 Nov 2018 11:34:46 +0000
|
||||
|
||||
xed (1.8.3) tara; urgency=medium
|
||||
|
||||
[ Michael Webster ]
|
||||
* search bar/xed-history-entry: Set a 'width-chars' on the GtkEntry widgets of the search and replace entry widgets, and allow their labels to ellipsize upon resizing.
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Tue, 17 Jul 2018 09:32:59 +0200
|
||||
|
||||
xed (1.8.2) tara; urgency=medium
|
||||
|
||||
[ NikoKrause ]
|
||||
* missing l10n: Help -> Shortcuts (#229)
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* l10n: Update POT file
|
||||
* l10n: Update translations
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Tue, 26 Jun 2018 13:21:55 +0200
|
||||
|
||||
xed (1.8.1) tara; urgency=medium
|
||||
|
||||
* l10n: Update translations
|
||||
* l10n: Update files
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Tue, 22 May 2018 12:53:38 +0100
|
||||
|
||||
xed (1.8.0) tara; urgency=medium
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* Add CI configuration
|
||||
|
||||
[ Leigh Scott ]
|
||||
* Fix clang compile issue (#209)
|
||||
* Fix Py*DeprecationWarning (#202)
|
||||
|
||||
[ JosephMcc ]
|
||||
* Pull upstream fixes for gtk and gtksourceview changes
|
||||
* preferences-dialog: Complete revamp
|
||||
* xed-window: Rework the fullscreen toolbar
|
||||
* xed-status-combo-box: Remove some deprecated css functionality
|
||||
* xed-view-frame: Fix the css for the minimap frame
|
||||
* xed-notebook: Clean up some gtk3.20+ conditionals
|
||||
* Add a shortcuts window
|
||||
* xed-view: Add shortcuts for change case
|
||||
* debian: Add --enable-silent-rules to debian/rules
|
||||
* css: Add support for Adwaita
|
||||
* xed-searchbar: Fix the size of the searchbar close button
|
||||
* xed-spell-checker.c: Clean up the code formatting
|
||||
* spell-plugin: Update for removal of some deprecated functionality
|
||||
* xed-notebook: Allow changing tabs with mouse back/forward buttons
|
||||
* Fix a couple of issues turned up by Codacy
|
||||
* Clean up a few build warnings
|
||||
* spell-plugin: Port to gspell
|
||||
* spell-plugin: Fix a link to the help file
|
||||
|
||||
[ Nic ]
|
||||
* Add C tags to the taglist plugin (#188)
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* CI: Don't build for Mint 18
|
||||
|
||||
[ JosephMcc ]
|
||||
* xed-window: Fix a potential crash
|
||||
|
||||
[ Mickael Albertus ]
|
||||
* Creation of plugin Word completion (#199)
|
||||
|
||||
[ Clement Lefebvre ]
|
||||
* Wordcompletion: Fix a few mgsids
|
||||
* l10n: Update POT file
|
||||
|
||||
-- Clement Lefebvre <root@linuxmint.com> Sun, 06 May 2018 16:43:18 +0100
|
||||
|
||||
xed (1.6.3) sylvia; urgency=medium
|
||||
|
||||
* l10n: Update translations
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
debian/build/
|
|
@ -2,18 +2,17 @@ Source: xed
|
|||
Section: x11
|
||||
Priority: optional
|
||||
Maintainer: Linux Mint <root@linuxmint.com>
|
||||
Build-Depends: autotools-dev,
|
||||
debhelper (>= 9),
|
||||
Build-Depends: debhelper (>= 9),
|
||||
gobject-introspection,
|
||||
gtk-doc-tools,
|
||||
intltool,
|
||||
iso-codes,
|
||||
libenchant-dev,
|
||||
libgirepository1.0-dev,
|
||||
libglib2.0-dev,
|
||||
libgspell-1-dev,
|
||||
libgtk-3-dev,
|
||||
libgtksourceview-3.0-dev,
|
||||
libpeas-dev,
|
||||
libxapp-dev,
|
||||
libsm-dev,
|
||||
libx11-dev,
|
||||
libxml2-dev,
|
||||
|
@ -21,6 +20,7 @@ Build-Depends: autotools-dev,
|
|||
python3,
|
||||
python3-gi,
|
||||
yelp-tools,
|
||||
meson
|
||||
Standards-Version: 3.9.6
|
||||
|
||||
Package: xed
|
||||
|
@ -30,7 +30,6 @@ Depends: iso-codes,
|
|||
${misc:Depends},
|
||||
${python:Depends},
|
||||
${shlibs:Depends},
|
||||
libpeas-1.0-0-python3loader | debian-system-adjustments,
|
||||
python3,
|
||||
python3-gi,
|
||||
xapps-common,
|
||||
|
@ -145,4 +144,4 @@ Description: Text editor (documentation files)
|
|||
includes support for spell checking, comparing files, viewing CVS
|
||||
ChangeLogs, and adjusting indentation levels.
|
||||
.
|
||||
This package contains the documentation files.
|
||||
This package contains the documentation files.
|
||||
|
|
|
@ -5,27 +5,28 @@ DHFLAGS=--parallel
|
|||
%:
|
||||
dh $@ $(DHFLAGS) --with gir
|
||||
|
||||
override_dh_install:
|
||||
rm -rfv debian/tmp/usr/lib/*/xed/plugins/*.la
|
||||
rm -rfv debian/tmp/usr/lib/*/xed/*.la
|
||||
dh_install --fail-missing
|
||||
|
||||
override_dh_auto_configure:
|
||||
# upstream tarball is without configure. autogen.sh will create it
|
||||
NOCONFIGURE=1 ./autogen.sh
|
||||
dh_auto_configure $(DHFLAGS) -- \
|
||||
--disable-silent-rules \
|
||||
--libexecdir=/usr/lib/ \
|
||||
--enable-gtk-doc
|
||||
meson debian/build \
|
||||
--prefix=/usr \
|
||||
--buildtype=plain \
|
||||
-D docs=true \
|
||||
-D deprecated_warnings=false
|
||||
|
||||
override_dh_installchangelogs:
|
||||
dh_installchangelogs NEWS
|
||||
|
||||
override_dh_auto_test:
|
||||
DEB_BUILD_OPTIONS=nocheck dh_auto_test
|
||||
ninja -C debian/build test
|
||||
|
||||
override_dh_strip:
|
||||
dh_strip --dbg-package=xed-dbg
|
||||
|
||||
get-orig-source:
|
||||
uscan --noconf --force-download --rename --download-current-version --destdir=..
|
||||
|
||||
override_dh_auto_install:
|
||||
DESTDIR=${CURDIR}/debian/tmp \
|
||||
ninja -C debian/build install
|
||||
|
||||
override_dh_auto_build:
|
||||
ninja -C debian/build
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
usr/share/appdata
|
||||
usr/share/metainfo
|
||||
usr/share/xed/plugins
|
||||
usr/share/glib-2.0
|
||||
usr/share/help
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
usr/bin/xed
|
||||
usr/lib/*/xed/girepository-1.0/
|
||||
usr/lib/xed/xed-bugreport.sh
|
||||
usr/lib/*/xed/plugins/
|
||||
usr/lib/*/xed/*.so
|
||||
usr/share/applications/xed.desktop
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
SUBDIRS = reference
|
||||
|
||||
EXTRA_DIST = class-diagram.dia
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -1,74 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
# see /gtk-doc/examples/Makefile.am
|
||||
|
||||
# We require automake 1.6 at least.
|
||||
AUTOMAKE_OPTIONS = 1.6
|
||||
|
||||
# The name of the module, e.g. 'glib'.
|
||||
DOC_MODULE = xed
|
||||
|
||||
# The top-level XML file (SGML in the past).
|
||||
DOC_MAIN_SGML_FILE = xed-docs.xml
|
||||
|
||||
# The directory containing the source code. Relative to $(srcdir).
|
||||
DOC_SOURCE_DIR = ../../xed
|
||||
|
||||
# Extra options to supply to gtkdoc-scan.
|
||||
# e.g. SCAN_OPTIONS = --deprecated-guards="GTK_DISABLE_DEPRECATED"
|
||||
SCAN_OPTIONS = --rebuild-types
|
||||
|
||||
# Extra options to supply to gtkdoc-mkdb.
|
||||
MKDB_OPTIONS = --xml-mode --output-format=xml
|
||||
|
||||
# Used for dependencies. The docs will be rebuilt if any of these change.
|
||||
HFILE_GLOB = $(top_srcdir)/xed/*.h
|
||||
CFILE_GLOB = $(top_srcdir)/xed/*.c
|
||||
|
||||
# Header files to ignore when scanning (These are internal to xed).
|
||||
IGNORE_HFILES= \
|
||||
xed-close-confirmation-dialog.h \
|
||||
xed-dirs.h \
|
||||
xed-commands.h \
|
||||
xed-documents-panel.h \
|
||||
xed-io-error-info-bar.h \
|
||||
xed-languages-manager.h \
|
||||
xed-plugins-engine.h \
|
||||
xed-session.h \
|
||||
xed-ui.h \
|
||||
xed-window-private.h \
|
||||
xed-output-window.h \
|
||||
xed-encodings-dialog.h \
|
||||
xed-open-location-dialog.h \
|
||||
xed-page-setup-dialog.h \
|
||||
xed-preferences-dialog.h \
|
||||
xed-search-dialog.h \
|
||||
xed-marshal.h \
|
||||
xed-enum-types.h
|
||||
|
||||
# Images to copy into HTML directory.
|
||||
HTML_IMAGES =
|
||||
|
||||
# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
|
||||
content_files =
|
||||
|
||||
# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
|
||||
# Only needed if you are using gtkdoc-scangobj to dynamically query widget
|
||||
# signals and properties.
|
||||
GTKDOC_CFLAGS = \
|
||||
-I$(top_srcdir)/xed \
|
||||
-I$(top_builddir)/xed \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir) \
|
||||
$(XED_CFLAGS)
|
||||
|
||||
GTKDOC_LIBS = \
|
||||
$(top_builddir)/xed/libxed.la \
|
||||
$(XED_LIBS)
|
||||
|
||||
MAINTAINERCLEANFILES = xed.types
|
||||
|
||||
# This includes the standard gtk-doc make rules, copied by gtkdocize.
|
||||
include $(top_srcdir)/gtk-doc.make
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,36 @@
|
|||
docs_ignore_h = [
|
||||
'xed-close-confirmation-dialog.h',
|
||||
'xed-dirs.h',
|
||||
'xed-commands.h',
|
||||
'xed-documents-panel.h',
|
||||
'xed-io-error-info-bar.h',
|
||||
'xed-languages-manager.h',
|
||||
'xed-plugins-engine.h',
|
||||
'xed-session.h',
|
||||
'xed-ui.h',
|
||||
'xed-window-private.h',
|
||||
'xed-output-window.h',
|
||||
'xed-encodings-dialog.h',
|
||||
'xed-open-location-dialog.h',
|
||||
'xed-page-setup-dialog.h',
|
||||
'xed-preferences-dialog.h',
|
||||
'xed-search-dialog.h',
|
||||
'xed-marshal.h',
|
||||
'xed-enum-types.h'
|
||||
]
|
||||
|
||||
gnome.gtkdoc(
|
||||
'xed',
|
||||
mode: 'xml',
|
||||
install: true,
|
||||
main_xml: 'xed-docs.xml',
|
||||
gobject_typesfile: 'xed.types',
|
||||
src_dir: [
|
||||
join_paths(meson.source_root(), 'xed'),
|
||||
join_paths(meson.build_root(), 'xed'),
|
||||
],
|
||||
ignore_headers: docs_ignore_h,
|
||||
dependencies: libxed_dep,
|
||||
scan_args: ['--rebuild-types'],
|
||||
mkdb_args: ['--xml-mode', '--output-format=xml'],
|
||||
)
|
|
@ -458,8 +458,6 @@ xed_help_display
|
|||
GBOOLEAN_TO_POINTER
|
||||
GPOINTER_TO_BOOLEAN
|
||||
IS_VALID_BOOLEAN
|
||||
xed_utils_menu_position_under_widget
|
||||
xed_utils_menu_position_under_tree_view
|
||||
xed_gtk_button_new_with_stock_icon
|
||||
xed_dialog_add_button
|
||||
xed_utils_escape_underscores
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
ar
|
||||
bg
|
||||
ca
|
||||
cs
|
||||
da
|
||||
de
|
||||
el
|
||||
es
|
||||
fi
|
||||
fr
|
||||
hu
|
||||
it
|
||||
ja
|
||||
ko
|
||||
oc
|
||||
pt_BR
|
||||
ru
|
||||
sv
|
||||
th
|
||||
uk
|
||||
zh_CN
|
||||
zh_HK
|
||||
zh_TW
|
|
@ -1,16 +0,0 @@
|
|||
@YELP_HELP_RULES@
|
||||
|
||||
HELP_ID = xed
|
||||
HELP_FILES = index.docbook legal.xml
|
||||
HELP_MEDIA = \
|
||||
figures/xed_format_bold.png \
|
||||
figures/xed_format_italic.png \
|
||||
figures/xed_format_strikethrough.png \
|
||||
figures/xed_format_underline.png \
|
||||
figures/xed_recent_files_menu_icon.png \
|
||||
figures/xed_window.png
|
||||
|
||||
HELP_LINGUAS = ar bg ca cs da de el es fi fr hu it ja ko oc pt_BR ru sv th uk zh_CN zh_HK zh_TW
|
||||
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,20 @@
|
|||
help_sources = [
|
||||
'index.docbook',
|
||||
'legal.xml'
|
||||
]
|
||||
|
||||
help_media = [
|
||||
'figures/xed_format_bold.png',
|
||||
'figures/xed_format_italic.png',
|
||||
'figures/xed_format_strikethrough.png',
|
||||
'figures/xed_format_underline.png',
|
||||
'figures/xed_recent_files_menu_icon.png',
|
||||
'figures/xed_window.png'
|
||||
]
|
||||
|
||||
gnome.yelp(
|
||||
meson.project_name(),
|
||||
sources: help_sources,
|
||||
media: help_media,
|
||||
symlink_media: false
|
||||
)
|
|
@ -0,0 +1,104 @@
|
|||
project('xed', 'c', version : '2.4.3')
|
||||
|
||||
gnome = import('gnome')
|
||||
i18n = import('i18n')
|
||||
pkgconfig = import('pkgconfig')
|
||||
|
||||
version = meson.project_version()
|
||||
|
||||
xed_conf = configuration_data()
|
||||
xed_conf.set_quoted('VERSION', version)
|
||||
xed_conf.set_quoted('GETTEXT_PACKAGE', 'xed')
|
||||
|
||||
# directories
|
||||
prefix = get_option('prefix')
|
||||
bindir = get_option('bindir')
|
||||
datadir = get_option('datadir')
|
||||
libdir = get_option('libdir')
|
||||
includedir = get_option('includedir')
|
||||
libexecdir = get_option('libexecdir')
|
||||
desktopdir = join_paths(datadir, 'applications')
|
||||
schema_dir = join_paths(datadir, 'glib-2.0', 'schemas')
|
||||
|
||||
po_dir = join_paths(meson.source_root(), 'po')
|
||||
|
||||
# dependencies
|
||||
libxml = dependency('libxml-2.0', version: '>= 2.5.0')
|
||||
glib = dependency('glib-2.0', version: '>= 2.40.0')
|
||||
gthread = dependency('gthread-2.0', version: '>= 2.13.0')
|
||||
gio = dependency('gio-2.0', version: '>= 2.40.0')
|
||||
gtk = dependency('gtk+-3.0', version: '>= 3.19.3')
|
||||
gtksourceview = dependency('gtksourceview-3.0', version: '>= 3.19.0')
|
||||
libpeas = dependency('libpeas-1.0', version: '>= 1.12.0')
|
||||
libpeas_gtk = dependency('libpeas-gtk-1.0', version: '>= 1.12.0')
|
||||
gir_dep = dependency('gobject-introspection-1.0', version: '>= 0.6.7', required: false)
|
||||
gmodule = dependency('gmodule-2.0')
|
||||
xapp = dependency('xapp', version: '>= 1.4.0')
|
||||
X11 = dependency('x11')
|
||||
pango = dependency('pango')
|
||||
|
||||
if gir_dep.found()
|
||||
xed_conf.set('ENABLE_INTROSPECTION', 1)
|
||||
endif
|
||||
|
||||
enable_spell = get_option('enable_spell')
|
||||
if enable_spell
|
||||
gspell = dependency('gspell-1', version: '>= 0.2.5')
|
||||
endif
|
||||
|
||||
if get_option('enable_gvfs_metadata')
|
||||
xed_conf.set('ENABLE_GVFS_METADATA', true)
|
||||
endif
|
||||
|
||||
# on some systems we need to find the math lib to make sure it builds
|
||||
cc = meson.get_compiler('c')
|
||||
math = cc.find_library('m', required: false)
|
||||
|
||||
intltool_merge = find_program('intltool-merge')
|
||||
itstool = find_program('itstool')
|
||||
|
||||
# generate config.h
|
||||
config_h_file = configure_file(
|
||||
output : 'config.h',
|
||||
configuration : xed_conf
|
||||
)
|
||||
|
||||
config_h = declare_dependency(
|
||||
sources: config_h_file
|
||||
)
|
||||
|
||||
include_dirs = include_directories('.', 'xed')
|
||||
|
||||
# compiler flags
|
||||
add_global_arguments('-DDATADIR="@0@"'.format(join_paths(prefix, datadir)), language: 'c')
|
||||
add_global_arguments('-DLIBDIR="@0@"'.format(join_paths(prefix, libdir)), language: 'c')
|
||||
|
||||
# remove this later or add as build option
|
||||
if not get_option('deprecated_warnings')
|
||||
add_global_arguments([
|
||||
'-Wno-deprecated-declarations',
|
||||
'-Wno-deprecated',
|
||||
'-Wno-declaration-after-statement',
|
||||
],
|
||||
language: 'c',
|
||||
)
|
||||
endif
|
||||
|
||||
subdir('xed')
|
||||
subdir('pixmaps')
|
||||
subdir('po')
|
||||
subdir('data')
|
||||
subdir('plugins')
|
||||
subdir('help')
|
||||
if get_option('docs')
|
||||
subdir('docs/reference')
|
||||
endif
|
||||
|
||||
message('prefix = @0@'.format(prefix))
|
||||
message('bindir = @0@'.format(bindir))
|
||||
message('datadir = @0@'.format(datadir))
|
||||
message('libdir = @0@'.format(libdir))
|
||||
message('includedir = @0@'.format(includedir))
|
||||
message('libexecdir = @0@'.format(libexecdir))
|
||||
message('desktopdir = @0@'.format(desktopdir))
|
||||
message('schema_dir = @0@'.format(schema_dir))
|
|
@ -0,0 +1,23 @@
|
|||
option(
|
||||
'enable_spell',
|
||||
type : 'boolean',
|
||||
value : true,
|
||||
description : 'enable gspell'
|
||||
)
|
||||
option(
|
||||
'enable_gvfs_metadata',
|
||||
type : 'boolean',
|
||||
value : true,
|
||||
description : 'enable gvfs metadata'
|
||||
)
|
||||
option('docs',
|
||||
type: 'boolean',
|
||||
value: false,
|
||||
description: 'Build the API references (requires gtk-doc)'
|
||||
)
|
||||
option(
|
||||
'deprecated_warnings',
|
||||
type : 'boolean',
|
||||
value : false,
|
||||
description: 'Show build warnings for deprecations'
|
||||
)
|
|
@ -1,8 +0,0 @@
|
|||
icondir = $(datadir)/xed/icons
|
||||
icon_DATA = xed-plugin.png
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(icon_DATA) \
|
||||
xed.ico
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,4 @@
|
|||
install_data(
|
||||
'xed-plugin.png',
|
||||
install_dir: join_paths(datadir, 'xed', 'icons')
|
||||
)
|
|
@ -1,26 +0,0 @@
|
|||
DIST_SUBDIRS = \
|
||||
docinfo \
|
||||
filebrowser \
|
||||
modelines \
|
||||
sort \
|
||||
spell \
|
||||
taglist \
|
||||
textsize \
|
||||
time \
|
||||
trailsave
|
||||
|
||||
SUBDIRS = \
|
||||
docinfo \
|
||||
filebrowser \
|
||||
modelines \
|
||||
sort \
|
||||
taglist \
|
||||
textsize \
|
||||
time \
|
||||
trailsave
|
||||
|
||||
if ENABLE_ENCHANT
|
||||
SUBDIRS += spell
|
||||
endif
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -1,34 +0,0 @@
|
|||
# docinfo plugin
|
||||
plugindir = $(XED_PLUGINS_LIBS_DIR)
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(XED_CFLAGS) \
|
||||
$(WARN_CFLAGS) \
|
||||
$(DISABLE_DEPRECATED_CFLAGS)
|
||||
|
||||
plugin_LTLIBRARIES = libdocinfo.la
|
||||
|
||||
libdocinfo_la_SOURCES = \
|
||||
xed-docinfo-plugin.h \
|
||||
xed-docinfo-plugin.c
|
||||
|
||||
libdocinfo_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
|
||||
libdocinfo_la_LIBADD = $(XED_LIBS)
|
||||
|
||||
uidir = $(XED_PLUGINS_DATA_DIR)/docinfo
|
||||
ui_DATA = docinfo.ui
|
||||
|
||||
plugin_in_files = docinfo.plugin.desktop.in
|
||||
|
||||
%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
|
||||
|
||||
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
|
||||
|
||||
EXTRA_DIST = $(ui_DATA) $(plugin_in_files)
|
||||
|
||||
CLEANFILES = $(plugin_DATA)
|
||||
DISTCLEANFILES = $(plugin_DATA)
|
||||
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,37 @@
|
|||
docinfo_sources = [
|
||||
'xed-docinfo-plugin.h',
|
||||
'xed-docinfo-plugin.c'
|
||||
]
|
||||
|
||||
docinfo_deps = [
|
||||
config_h,
|
||||
glib,
|
||||
gmodule,
|
||||
gtksourceview,
|
||||
libpeas,
|
||||
pango
|
||||
]
|
||||
|
||||
library('docinfo',
|
||||
docinfo_sources,
|
||||
dependencies: docinfo_deps,
|
||||
include_directories: include_dirs,
|
||||
link_with: libxed,
|
||||
install_rpath: join_paths(prefix, libdir, 'xed'),
|
||||
install: true,
|
||||
install_dir: join_paths(libdir, 'xed', 'plugins')
|
||||
)
|
||||
|
||||
install_data(
|
||||
'docinfo.ui',
|
||||
install_dir: join_paths(pluginsdatadir, 'docinfo')
|
||||
)
|
||||
|
||||
docinfo_desktop = custom_target(
|
||||
'docinfo_desktop',
|
||||
input: 'docinfo.plugin.desktop.in',
|
||||
output: 'docinfo.plugin',
|
||||
command: [intltool_merge, '-d', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: pluginslibdir,
|
||||
)
|
|
@ -19,14 +19,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xed-docinfo-plugin.h"
|
||||
|
||||
#include <string.h> /* For strlen (...) */
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <pango/pango-break.h>
|
||||
#include <gmodule.h>
|
||||
|
@ -36,6 +30,8 @@
|
|||
#include <xed/xed-debug.h>
|
||||
#include <xed/xed-utils.h>
|
||||
|
||||
#include "xed-docinfo-plugin.h"
|
||||
|
||||
#define MENU_PATH "/MenuBar/ToolsMenu/ToolsOps_2"
|
||||
|
||||
struct _XedDocInfoPluginPrivate
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
# filebrowser
|
||||
|
||||
plugindir = $(XED_PLUGINS_LIBS_DIR)
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(XED_CFLAGS) \
|
||||
$(WARN_CFLAGS) \
|
||||
$(DISABLE_DEPRECATED_CFLAGS)
|
||||
|
||||
BUILT_SOURCES = \
|
||||
xed-file-browser-enum-types.h \
|
||||
xed-file-browser-enum-types.c \
|
||||
xed-file-browser-marshal.h \
|
||||
xed-file-browser-marshal.c
|
||||
|
||||
plugin_LTLIBRARIES = libfilebrowser.la
|
||||
|
||||
NOINST_H_FILES = \
|
||||
xed-file-bookmarks-store.h \
|
||||
xed-file-browser-store.h \
|
||||
xed-file-browser-view.h \
|
||||
xed-file-browser-widget.h \
|
||||
xed-file-browser-error.h \
|
||||
xed-file-browser-utils.h \
|
||||
xed-file-browser-plugin.h \
|
||||
xed-file-browser-messages.h
|
||||
|
||||
libfilebrowser_la_SOURCES = \
|
||||
$(BUILT_SOURCES) \
|
||||
xed-file-bookmarks-store.c \
|
||||
xed-file-browser-store.c \
|
||||
xed-file-browser-view.c \
|
||||
xed-file-browser-widget.c \
|
||||
xed-file-browser-utils.c \
|
||||
xed-file-browser-plugin.c \
|
||||
xed-file-browser-messages.c \
|
||||
$(NOINST_H_FILES)
|
||||
|
||||
libfilebrowser_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
|
||||
libfilebrowser_la_LIBADD = $(XED_LIBS)
|
||||
|
||||
# UI files (if you use ui for your plugin, list those files here)
|
||||
uidir = $(XED_PLUGINS_DATA_DIR)/filebrowser
|
||||
ui_DATA = xed-file-browser-widget-ui.xml
|
||||
|
||||
plugin_in_files = filebrowser.plugin.desktop.in
|
||||
|
||||
%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
|
||||
|
||||
xed-file-browser-enum-types.h: xed-file-browser-enum-types.h.template $(NOINST_H_FILES) $(GLIB_MKENUMS)
|
||||
(cd $(srcdir) && $(GLIB_MKENUMS) --template xed-file-browser-enum-types.h.template $(NOINST_H_FILES)) > $@
|
||||
|
||||
xed-file-browser-enum-types.c: xed-file-browser-enum-types.c.template xed-file-browser-enum-register.c.template $(NOINST_H_FILES) $(GLIB_MKENUMS)
|
||||
$(AM_V_GEN) (cd $(srcdir) && \
|
||||
$(GLIB_MKENUMS) --template xed-file-browser-enum-types.c.template $(NOINST_H_FILES) && \
|
||||
$(GLIB_MKENUMS) --template xed-file-browser-enum-register.c.template $(NOINST_H_FILES)) > $@
|
||||
|
||||
xed-file-browser-marshal.h: xed-file-browser-marshal.list $(GLIB_GENMARSHAL)
|
||||
$(AM_V_GEN) $(GLIB_GENMARSHAL) $< --header --prefix=xed_file_browser_marshal > $@
|
||||
|
||||
xed-file-browser-marshal.c: xed-file-browser-marshal.list $(GLIB_GENMARSHAL)
|
||||
$(AM_V_GEN) echo "#include \"xed-file-browser-marshal.h\"" > $@ && \
|
||||
$(GLIB_GENMARSHAL) $< --body --prefix=xed_file_browser_marshal >> $@
|
||||
|
||||
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
|
||||
|
||||
@INTLTOOL_XML_NOMERGE_RULE@
|
||||
filebrowser_gschema_in = org.x.editor.plugins.filebrowser.gschema.xml.in
|
||||
gsettings_SCHEMAS = $(filebrowser_gschema_in:.xml.in=.xml)
|
||||
@GSETTINGS_RULES@
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(ui_DATA) \
|
||||
$(plugin_in_files) \
|
||||
$(filebrowser_gschema_in) \
|
||||
xed-file-browser-enum-types.h.template \
|
||||
xed-file-browser-enum-types.c.template \
|
||||
xed-file-browser-enum-register.c.template \
|
||||
xed-file-browser-marshal.list
|
||||
|
||||
CLEANFILES = \
|
||||
$(plugin_DATA) \
|
||||
$(gsettings_SCHEMAS_in) \
|
||||
$(gsettings_SCHEMAS) \
|
||||
$(BUILT_SOURCES)
|
||||
|
||||
DISTCLEANFILES = \
|
||||
$(plugin_DATA) \
|
||||
$(gsettings_SCHEMAS_in) \
|
||||
$(gsettings_SCHEMAS) \
|
||||
$(BUILT_SOURCES)
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,73 @@
|
|||
filebrowser_headers = [
|
||||
'xed-file-bookmarks-store.h',
|
||||
'xed-file-browser-store.h',
|
||||
'xed-file-browser-view.h',
|
||||
'xed-file-browser-widget.h',
|
||||
'xed-file-browser-error.h',
|
||||
'xed-file-browser-utils.h',
|
||||
'xed-file-browser-plugin.h',
|
||||
'xed-file-browser-messages.h'
|
||||
]
|
||||
|
||||
filebrowser_lib_sources = [
|
||||
'xed-file-bookmarks-store.c',
|
||||
'xed-file-browser-store.c',
|
||||
'xed-file-browser-view.c',
|
||||
'xed-file-browser-widget.c',
|
||||
'xed-file-browser-utils.c',
|
||||
'xed-file-browser-plugin.c',
|
||||
'xed-file-browser-messages.c'
|
||||
]
|
||||
|
||||
filebrowser_enums = gnome.mkenums_simple(
|
||||
'xed-file-browser-enum-types',
|
||||
sources : filebrowser_headers,
|
||||
identifier_prefix : 'XedFileBrowser',
|
||||
symbol_prefix : 'xed_file_browser'
|
||||
)
|
||||
|
||||
filebrowser_marshal = gnome.genmarshal(
|
||||
'xed-file-browser-marshal',
|
||||
sources: 'xed-file-browser-marshal.list',
|
||||
prefix: 'xed_file_browser_marshal'
|
||||
)
|
||||
|
||||
filebrowser_deps = [
|
||||
config_h,
|
||||
gio,
|
||||
glib,
|
||||
gmodule,
|
||||
gtk,
|
||||
gtksourceview,
|
||||
libpeas
|
||||
]
|
||||
|
||||
library(
|
||||
'filebrowser',
|
||||
filebrowser_headers + filebrowser_lib_sources + filebrowser_enums + filebrowser_marshal,
|
||||
link_with: libxed,
|
||||
dependencies: filebrowser_deps,
|
||||
include_directories: include_dirs,
|
||||
install_rpath: join_paths(prefix, libdir, 'xed'),
|
||||
install: true,
|
||||
install_dir: join_paths(libdir, 'xed', 'plugins')
|
||||
)
|
||||
|
||||
install_data(
|
||||
'xed-file-browser-widget-ui.xml',
|
||||
install_dir: join_paths(pluginsdatadir, 'filebrowser')
|
||||
)
|
||||
|
||||
filebrowser_desktop = custom_target(
|
||||
'filebrowser_desktop',
|
||||
input: 'filebrowser.plugin.desktop.in',
|
||||
output: 'filebrowser.plugin',
|
||||
command: [intltool_merge, '-d', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: pluginslibdir,
|
||||
)
|
||||
|
||||
install_data(
|
||||
'org.x.editor.plugins.filebrowser.gschema.xml',
|
||||
install_dir: schema_dir
|
||||
)
|
|
@ -911,7 +911,7 @@ xed_file_bookmarks_store_get_location (XedFileBookmarksStore *model,
|
|||
}
|
||||
else if (!isfs)
|
||||
{
|
||||
file = g_object_ref (obj);
|
||||
file = G_FILE (g_object_ref (obj));
|
||||
}
|
||||
|
||||
g_object_unref (obj);
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/*** BEGIN file-header ***/
|
||||
void
|
||||
xed_file_browser_enum_and_flag_register_type (GTypeModule * module)
|
||||
{
|
||||
/*** END file-header ***/
|
||||
|
||||
/*** BEGIN file-production ***/
|
||||
/* Enumerations from "@filename@" */
|
||||
|
||||
/*** END file-production ***/
|
||||
|
||||
/*** BEGIN enumeration-production ***/
|
||||
register_@enum_name@ (module);
|
||||
|
||||
/*** END enumeration-production ***/
|
||||
|
||||
/*** BEGIN file-tail ***/
|
||||
}
|
||||
|
||||
/*** END file-tail ***/
|
|
@ -1,45 +0,0 @@
|
|||
/*** BEGIN file-header ***/
|
||||
#include "xed-file-browser-enum-types.h"
|
||||
|
||||
/*** END file-header ***/
|
||||
|
||||
/*** BEGIN file-production ***/
|
||||
/* enumerations from "@filename@" */
|
||||
#include "@filename@"
|
||||
|
||||
/*** END file-production ***/
|
||||
|
||||
/*** BEGIN value-header ***/
|
||||
static GType @enum_name@_type = 0;
|
||||
|
||||
static GType
|
||||
register_@enum_name@ (GTypeModule *module)
|
||||
{
|
||||
static const G@Type@Value values[] = {
|
||||
/*** END value-header ***/
|
||||
|
||||
/*** BEGIN value-production ***/
|
||||
{ @VALUENAME@,
|
||||
"@VALUENAME@",
|
||||
"@valuenick@" },
|
||||
/*** END value-production ***/
|
||||
|
||||
/*** BEGIN value-tail ***/
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
@enum_name@_type =
|
||||
g_type_module_register_@type@ (module,
|
||||
"@EnumName@",
|
||||
values);
|
||||
|
||||
return @enum_name@_type;
|
||||
}
|
||||
|
||||
GType
|
||||
@enum_name@_get_type (void)
|
||||
{
|
||||
return @enum_name@_type;
|
||||
}
|
||||
|
||||
/*** END value-tail ***/
|
|
@ -1,29 +0,0 @@
|
|||
/*** BEGIN file-header ***/
|
||||
#ifndef __XED_FILE_BROWSER_ENUM_TYPES_H__
|
||||
#define __XED_FILE_BROWSER_ENUM_TYPES_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*** END file-header ***/
|
||||
|
||||
/*** BEGIN file-production ***/
|
||||
/* Enumerations from "@filename@" */
|
||||
|
||||
/*** END file-production ***/
|
||||
|
||||
/*** BEGIN enumeration-production ***/
|
||||
#define XED_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
|
||||
GType @enum_name@_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/*** END enumeration-production ***/
|
||||
|
||||
/*** BEGIN file-tail ***/
|
||||
void xed_file_browser_enum_and_flag_register_type (GTypeModule * module);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_FILE_BROWSER_ENUM_TYPES_H__ */
|
||||
/*** END file-tail ***/
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
VOID:UINT,STRING
|
||||
VOID:OBJECT,OBJECT
|
||||
BOOL:OBJECT,POINTER
|
||||
BOOL:POINTER
|
||||
BOOL:VOID
|
||||
BOOLEAN:OBJECT,POINTER
|
||||
BOOLEAN:POINTER
|
||||
BOOLEAN:VOID
|
||||
|
|
|
@ -20,10 +20,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gmodule.h>
|
||||
|
@ -111,7 +108,6 @@ G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedFileBrowserPlugin,
|
|||
G_IMPLEMENT_INTERFACE_DYNAMIC (XED_TYPE_WINDOW_ACTIVATABLE,
|
||||
xed_window_activatable_iface_init) \
|
||||
\
|
||||
xed_file_browser_enum_and_flag_register_type (type_module); \
|
||||
_xed_file_browser_store_register_type (type_module); \
|
||||
_xed_file_bookmarks_store_register_type (type_module); \
|
||||
_xed_file_browser_view_register_type (type_module); \
|
||||
|
@ -532,8 +528,6 @@ xed_file_browser_plugin_activate (XedWindowActivatable *activatable)
|
|||
XedPanel *panel;
|
||||
XedFileBrowserStore *store;
|
||||
gchar *data_dir;
|
||||
GSettingsSchemaSource *schema_source;
|
||||
GSettingsSchema *schema;
|
||||
|
||||
priv = plugin->priv;
|
||||
|
||||
|
|
|
@ -19,10 +19,7 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gio/gio.h>
|
||||
|
@ -350,7 +347,7 @@ xed_file_browser_store_class_init (XedFileBrowserStoreClass * klass)
|
|||
g_param_spec_flags ("filter-mode",
|
||||
"Filter Mode",
|
||||
"The filter mode",
|
||||
XED_TYPE_FILE_BROWSER_STORE_FILTER_MODE,
|
||||
XED_FILE_BROWSER_TYPE_STORE_FILTER_MODE,
|
||||
xed_file_browser_store_filter_mode_get_default (),
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
|
@ -384,7 +381,7 @@ xed_file_browser_store_class_init (XedFileBrowserStoreClass * klass)
|
|||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (XedFileBrowserStoreClass,
|
||||
no_trash), g_signal_accumulator_true_handled, NULL,
|
||||
xed_file_browser_marshal_BOOL__POINTER,
|
||||
xed_file_browser_marshal_BOOLEAN__POINTER,
|
||||
G_TYPE_BOOLEAN, 1, G_TYPE_POINTER);
|
||||
model_signals[RENAME] =
|
||||
g_signal_new ("rename",
|
||||
|
@ -3592,7 +3589,7 @@ delete_file_finished (GFile *file,
|
|||
/* Process the next file */
|
||||
data->iter = data->iter->next;
|
||||
}
|
||||
else if (!ok && error != NULL)
|
||||
else if (error != NULL)
|
||||
{
|
||||
gint code = error->code;
|
||||
g_error_free (error);
|
||||
|
|
|
@ -19,10 +19,7 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <xed/xed-utils.h>
|
||||
|
||||
|
@ -94,7 +91,7 @@ xed_file_browser_utils_pixbuf_from_icon (GIcon *icon,
|
|||
}
|
||||
|
||||
ret = gtk_icon_info_load_icon (info, NULL);
|
||||
gtk_icon_info_free (info);
|
||||
g_object_unref (info);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -44,8 +44,6 @@ struct _XedFileBrowserViewPrivate
|
|||
GtkTreeModel *model;
|
||||
GtkTreeRowReference *editable;
|
||||
|
||||
/* CLick policy */
|
||||
XedFileBrowserViewClickPolicy click_policy;
|
||||
GtkTreePath *double_click_path[2]; /* Both clicks in a double click need to be on the same row */
|
||||
GtkTreePath *hover_path;
|
||||
GdkCursor *hand_cursor;
|
||||
|
@ -64,7 +62,6 @@ enum
|
|||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_CLICK_POLICY,
|
||||
PROP_RESTORE_EXPAND_STATE
|
||||
};
|
||||
|
||||
|
@ -227,139 +224,6 @@ row_collapsed (GtkTreeView *tree_view,
|
|||
_xed_file_browser_store_iter_collapsed (XED_FILE_BROWSER_STORE (view->priv->model), iter);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
leave_notify_event (GtkWidget *widget,
|
||||
GdkEventCrossing *event)
|
||||
{
|
||||
XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (widget);
|
||||
|
||||
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE &&
|
||||
view->priv->hover_path != NULL)
|
||||
{
|
||||
gtk_tree_path_free (view->priv->hover_path);
|
||||
view->priv->hover_path = NULL;
|
||||
}
|
||||
|
||||
// Chainup
|
||||
return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->leave_notify_event (widget, event);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
enter_notify_event (GtkWidget *widget,
|
||||
GdkEventCrossing *event)
|
||||
{
|
||||
XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (widget);
|
||||
|
||||
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
|
||||
{
|
||||
if (view->priv->hover_path != NULL)
|
||||
{
|
||||
gtk_tree_path_free (view->priv->hover_path);
|
||||
}
|
||||
|
||||
gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
|
||||
event->x, event->y,
|
||||
&view->priv->hover_path,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
if (view->priv->hover_path != NULL)
|
||||
{
|
||||
gdk_window_set_cursor (gtk_widget_get_window (widget), view->priv->hand_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
// Chainup
|
||||
return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->enter_notify_event (widget, event);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
motion_notify_event (GtkWidget *widget,
|
||||
GdkEventMotion *event)
|
||||
{
|
||||
GtkTreePath *old_hover_path;
|
||||
XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (widget);
|
||||
|
||||
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
|
||||
{
|
||||
old_hover_path = view->priv->hover_path;
|
||||
gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
|
||||
event->x, event->y,
|
||||
&view->priv->hover_path,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
if ((old_hover_path != NULL) != (view->priv->hover_path != NULL))
|
||||
{
|
||||
if (view->priv->hover_path != NULL)
|
||||
{
|
||||
gdk_window_set_cursor (gtk_widget_get_window (widget), view->priv->hand_cursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_window_set_cursor (gtk_widget_get_window (widget), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (old_hover_path != NULL)
|
||||
{
|
||||
gtk_tree_path_free (old_hover_path);
|
||||
}
|
||||
}
|
||||
|
||||
// Chainup
|
||||
return GTK_WIDGET_CLASS (xed_file_browser_view_parent_class)->motion_notify_event (widget, event);
|
||||
}
|
||||
|
||||
static void
|
||||
set_click_policy_property (XedFileBrowserView *obj,
|
||||
XedFileBrowserViewClickPolicy click_policy)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GdkDisplay *display;
|
||||
GdkWindow *win;
|
||||
|
||||
obj->priv->click_policy = click_policy;
|
||||
|
||||
if (click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
|
||||
{
|
||||
if (obj->priv->hand_cursor == NULL)
|
||||
{
|
||||
obj->priv->hand_cursor = gdk_cursor_new(GDK_HAND2);
|
||||
}
|
||||
}
|
||||
else if (click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE)
|
||||
{
|
||||
if (obj->priv->hover_path != NULL)
|
||||
{
|
||||
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (obj->priv->model), &iter, obj->priv->hover_path))
|
||||
{
|
||||
gtk_tree_model_row_changed (GTK_TREE_MODEL (obj->priv->model), obj->priv->hover_path, &iter);
|
||||
}
|
||||
|
||||
gtk_tree_path_free (obj->priv->hover_path);
|
||||
obj->priv->hover_path = NULL;
|
||||
}
|
||||
|
||||
if (gtk_widget_get_realized (GTK_WIDGET (obj)))
|
||||
{
|
||||
win = gtk_widget_get_window (GTK_WIDGET (obj));
|
||||
gdk_window_set_cursor (win, NULL);
|
||||
|
||||
display = gtk_widget_get_display (GTK_WIDGET (obj));
|
||||
|
||||
if (display != NULL)
|
||||
{
|
||||
gdk_display_flush (display);
|
||||
}
|
||||
}
|
||||
|
||||
if (obj->priv->hand_cursor)
|
||||
{
|
||||
g_object_unref (obj->priv->hand_cursor);
|
||||
obj->priv->hand_cursor = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
directory_activated (XedFileBrowserView *view,
|
||||
GtkTreeIter *iter)
|
||||
|
@ -503,14 +367,7 @@ did_not_drag (XedFileBrowserView *view,
|
|||
|
||||
if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y, &path, NULL, NULL, NULL))
|
||||
{
|
||||
if ((view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
|
||||
&& !button_event_modifies_selection(event)
|
||||
&& (event->button == 1 || event->button == 2))
|
||||
{
|
||||
/* Activate all selected items, and leave them selected */
|
||||
activate_selected_items (view);
|
||||
}
|
||||
else if ((event->button == 1 || event->button == 2)
|
||||
if ((event->button == 1 || event->button == 2)
|
||||
&& ((event->state & GDK_CONTROL_MASK) != 0 ||
|
||||
(event->state & GDK_SHIFT_MASK) == 0)
|
||||
&& view->priv->selected_on_button_down)
|
||||
|
@ -589,12 +446,6 @@ button_press_event (GtkWidget *widget,
|
|||
|
||||
last_click_time = event->time;
|
||||
|
||||
/* Ignore double click if we are in single click mode */
|
||||
if (view->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE && click_count >= 2)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
view->priv->ignore_release = FALSE;
|
||||
call_parent = TRUE;
|
||||
|
||||
|
@ -654,7 +505,7 @@ button_press_event (GtkWidget *widget,
|
|||
if (selected)
|
||||
{
|
||||
call_parent = on_expander || gtk_tree_selection_count_selected_rows (selection) == 1;
|
||||
view->priv->ignore_release = call_parent && view->priv->click_policy != XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE;
|
||||
view->priv->ignore_release = call_parent;
|
||||
}
|
||||
else if ((event->state & GDK_CONTROL_MASK) != 0)
|
||||
{
|
||||
|
@ -881,9 +732,6 @@ get_property (GObject *object,
|
|||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CLICK_POLICY:
|
||||
g_value_set_enum (value, obj->priv->click_policy);
|
||||
break;
|
||||
case PROP_RESTORE_EXPAND_STATE:
|
||||
g_value_set_boolean (value, obj->priv->restore_expand_state);
|
||||
break;
|
||||
|
@ -903,9 +751,6 @@ set_property (GObject *object,
|
|||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CLICK_POLICY:
|
||||
set_click_policy_property (obj, g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_RESTORE_EXPAND_STATE:
|
||||
set_restore_expand_state (obj, g_value_get_boolean (value));
|
||||
break;
|
||||
|
@ -927,9 +772,6 @@ xed_file_browser_view_class_init (XedFileBrowserViewClass *klass)
|
|||
object_class->set_property = set_property;
|
||||
|
||||
/* Event handlers */
|
||||
widget_class->motion_notify_event = motion_notify_event;
|
||||
widget_class->enter_notify_event = enter_notify_event;
|
||||
widget_class->leave_notify_event = leave_notify_event;
|
||||
widget_class->button_press_event = button_press_event;
|
||||
widget_class->button_release_event = button_release_event;
|
||||
widget_class->drag_begin = drag_begin;
|
||||
|
@ -943,14 +785,6 @@ xed_file_browser_view_class_init (XedFileBrowserViewClass *klass)
|
|||
/* Default handlers */
|
||||
klass->directory_activated = directory_activated;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_CLICK_POLICY,
|
||||
g_param_spec_enum ("click-policy",
|
||||
"Click Policy",
|
||||
"The click policy",
|
||||
XED_TYPE_FILE_BROWSER_VIEW_CLICK_POLICY,
|
||||
XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_RESTORE_EXPAND_STATE,
|
||||
g_param_spec_boolean ("restore-expand-state",
|
||||
"Restore Expand State",
|
||||
|
@ -1013,14 +847,6 @@ cell_data_cb (GtkTreeViewColumn *tree_column,
|
|||
|
||||
path = gtk_tree_model_get_path (tree_model, iter);
|
||||
|
||||
if (obj->priv->click_policy == XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE)
|
||||
{
|
||||
if (obj->priv->hover_path != NULL && gtk_tree_path_compare (path, obj->priv->hover_path) == 0)
|
||||
{
|
||||
underline = PANGO_UNDERLINE_SINGLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (XED_IS_FILE_BROWSER_STORE (tree_model))
|
||||
{
|
||||
if (obj->priv->editable != NULL && gtk_tree_row_reference_valid (obj->priv->editable))
|
||||
|
@ -1200,17 +1026,6 @@ xed_file_browser_view_start_rename (XedFileBrowserView *tree_view,
|
|||
FALSE, 0.0, 0.0);
|
||||
}
|
||||
|
||||
void
|
||||
xed_file_browser_view_set_click_policy (XedFileBrowserView *tree_view,
|
||||
XedFileBrowserViewClickPolicy policy)
|
||||
{
|
||||
g_return_if_fail (XED_IS_FILE_BROWSER_VIEW (tree_view));
|
||||
|
||||
set_click_policy_property (tree_view, policy);
|
||||
|
||||
g_object_notify (G_OBJECT (tree_view), "click-policy");
|
||||
}
|
||||
|
||||
void
|
||||
xed_file_browser_view_set_restore_expand_state (XedFileBrowserView *tree_view,
|
||||
gboolean restore_expand_state)
|
||||
|
|
|
@ -37,12 +37,6 @@ typedef struct _XedFileBrowserView XedFileBrowserView;
|
|||
typedef struct _XedFileBrowserViewClass XedFileBrowserViewClass;
|
||||
typedef struct _XedFileBrowserViewPrivate XedFileBrowserViewPrivate;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
XED_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE,
|
||||
XED_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE
|
||||
} XedFileBrowserViewClickPolicy;
|
||||
|
||||
struct _XedFileBrowserView
|
||||
{
|
||||
GtkTreeView parent;
|
||||
|
@ -74,8 +68,6 @@ void xed_file_browser_view_set_model (XedFileBrowserView *tree_view,
|
|||
GtkTreeModel *model);
|
||||
void xed_file_browser_view_start_rename (XedFileBrowserView *tree_view,
|
||||
GtkTreeIter *iter);
|
||||
void xed_file_browser_view_set_click_policy (XedFileBrowserView *tree_view,
|
||||
XedFileBrowserViewClickPolicy policy);
|
||||
void xed_file_browser_view_set_restore_expand_state (XedFileBrowserView *tree_view,
|
||||
gboolean restore_expand_state);
|
||||
|
||||
|
|
|
@ -19,10 +19,7 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
|
@ -30,7 +27,6 @@
|
|||
#include <glib/gi18n-lib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include <xed/xed-utils.h>
|
||||
|
||||
#include "xed-file-browser-utils.h"
|
||||
|
@ -470,7 +466,7 @@ xed_file_browser_widget_class_init (XedFileBrowserWidgetClass *klass)
|
|||
confirm_delete),
|
||||
g_signal_accumulator_true_handled,
|
||||
NULL,
|
||||
xed_file_browser_marshal_BOOL__OBJECT_POINTER,
|
||||
xed_file_browser_marshal_BOOLEAN__OBJECT_POINTER,
|
||||
G_TYPE_BOOLEAN,
|
||||
2,
|
||||
G_TYPE_OBJECT,
|
||||
|
@ -483,7 +479,7 @@ xed_file_browser_widget_class_init (XedFileBrowserWidgetClass *klass)
|
|||
confirm_no_trash),
|
||||
g_signal_accumulator_true_handled,
|
||||
NULL,
|
||||
xed_file_browser_marshal_BOOL__POINTER,
|
||||
xed_file_browser_marshal_BOOLEAN__POINTER,
|
||||
G_TYPE_BOOLEAN,
|
||||
1,
|
||||
G_TYPE_POINTER);
|
||||
|
@ -712,7 +708,7 @@ fill_combo_model (XedFileBrowserWidget *obj)
|
|||
GtkTreeIter iter;
|
||||
GdkPixbuf *icon;
|
||||
|
||||
icon = xed_file_browser_utils_pixbuf_from_theme (GTK_STOCK_HOME, GTK_ICON_SIZE_MENU);
|
||||
icon = xed_file_browser_utils_pixbuf_from_theme ("go-home", GTK_ICON_SIZE_MENU);
|
||||
|
||||
gtk_tree_store_append (store, &iter, NULL);
|
||||
gtk_tree_store_set (store, &iter,
|
||||
|
@ -805,7 +801,7 @@ static const GtkActionEntry tree_actions_sensitive[] =
|
|||
|
||||
static const GtkToggleActionEntry tree_actions_toggle[] =
|
||||
{
|
||||
{"FilterHidden", GTK_STOCK_DIALOG_AUTHENTICATION, N_("Show _Hidden"), NULL,
|
||||
{"FilterHidden", NULL, N_("Show _Hidden"), NULL,
|
||||
N_("Show hidden files and folders"), G_CALLBACK (on_action_filter_hidden), FALSE},
|
||||
{"FilterBinary", NULL, N_("Show _Binary"), NULL,
|
||||
N_("Show binary files"), G_CALLBACK (on_action_filter_binary), FALSE}
|
||||
|
@ -1187,7 +1183,7 @@ xed_file_browser_widget_init (XedFileBrowserWidget *obj)
|
|||
gtk_box_set_spacing (GTK_BOX (obj), 3);
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (obj), GTK_ORIENTATION_VERTICAL);
|
||||
|
||||
obj->priv->busy_cursor = gdk_cursor_new (GDK_WATCH);
|
||||
obj->priv->busy_cursor = gdk_cursor_new_for_display (gdk_display_get_default(), GDK_WATCH);
|
||||
}
|
||||
|
||||
/* Private */
|
||||
|
@ -1251,6 +1247,7 @@ popup_menu (XedFileBrowserWidget *obj,
|
|||
GtkTreeModel *model)
|
||||
{
|
||||
GtkWidget *menu;
|
||||
GtkTreeView *tree;
|
||||
|
||||
if (XED_IS_FILE_BROWSER_STORE (model))
|
||||
{
|
||||
|
@ -1267,16 +1264,18 @@ popup_menu (XedFileBrowserWidget *obj,
|
|||
|
||||
g_return_val_if_fail (menu != NULL, FALSE);
|
||||
|
||||
tree = GTK_TREE_VIEW (obj->priv->treeview);
|
||||
|
||||
if (event != NULL)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (obj->priv->treeview));
|
||||
selection = gtk_tree_view_get_selection (tree);
|
||||
|
||||
if (gtk_tree_selection_count_selected_rows (selection) <= 1)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
|
||||
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (obj->priv->treeview),
|
||||
if (gtk_tree_view_get_path_at_pos (tree,
|
||||
(gint)event->x, (gint)event->y,
|
||||
&path, NULL, NULL, NULL))
|
||||
{
|
||||
|
@ -1286,14 +1285,38 @@ popup_menu (XedFileBrowserWidget *obj,
|
|||
}
|
||||
}
|
||||
|
||||
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
|
||||
gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *) event);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
|
||||
xed_utils_menu_position_under_tree_view,
|
||||
obj->priv->treeview, 0,
|
||||
gtk_get_current_event_time ());
|
||||
GtkTreeModel *model;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeIter iter;
|
||||
|
||||
model = gtk_tree_view_get_model (tree);
|
||||
g_return_val_if_fail (model != NULL, FALSE);
|
||||
|
||||
selection = gtk_tree_view_get_selection (tree);
|
||||
g_return_val_if_fail (selection != NULL, FALSE);
|
||||
|
||||
if (gtk_tree_selection_get_selected (selection, NULL, &iter))
|
||||
{
|
||||
GtkTreePath *path;
|
||||
GdkRectangle rect;
|
||||
|
||||
path = gtk_tree_model_get_path (model, &iter);
|
||||
gtk_tree_view_get_cell_area (tree, path, gtk_tree_view_get_column (tree, 0), &rect);
|
||||
gtk_menu_popup_at_rect (GTK_MENU (menu), gtk_widget_get_window (GTK_WIDGET (tree)),
|
||||
&rect, GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST, NULL);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_menu_popup_at_widget (GTK_MENU (menu), GTK_WIDGET (obj->priv->treeview),
|
||||
GDK_GRAVITY_SOUTH, GDK_GRAVITY_NORTH, NULL);
|
||||
}
|
||||
|
||||
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
|
||||
}
|
||||
|
||||
|
@ -1965,11 +1988,7 @@ set_busy (XedFileBrowserWidget *obj,
|
|||
|
||||
if (busy)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
cursor = gdk_cursor_new (GDK_WATCH);
|
||||
gdk_window_set_cursor (window, cursor);
|
||||
g_object_unref (obj->priv->busy_cursor);
|
||||
gdk_window_set_cursor (window, obj->priv->busy_cursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2333,7 +2352,8 @@ directory_open (XedFileBrowserWidget *obj,
|
|||
|
||||
uri = g_file_get_uri (location);
|
||||
|
||||
if (!gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (obj)), uri, GDK_CURRENT_TIME, &error))
|
||||
if (!gtk_show_uri_on_window (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (obj))),
|
||||
uri, GDK_CURRENT_TIME, &error))
|
||||
{
|
||||
g_signal_emit (obj, signals[ERROR], 0, XED_FILE_BROWSER_ERROR_OPEN_DIRECTORY, error->message);
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
pluginsdatadir = join_paths(datadir, 'xed', 'plugins')
|
||||
pluginslibdir = join_paths(libdir, 'xed', 'plugins')
|
||||
|
||||
subdir('docinfo')
|
||||
subdir('filebrowser')
|
||||
subdir('modelines')
|
||||
subdir('open-uri-context-menu')
|
||||
subdir('sort')
|
||||
subdir('taglist')
|
||||
subdir('textsize')
|
||||
subdir('time')
|
||||
subdir('trailsave')
|
||||
subdir('wordcompletion')
|
||||
|
||||
if enable_spell
|
||||
subdir('spell')
|
||||
endif
|
|
@ -1,38 +0,0 @@
|
|||
# Modelines Plugin
|
||||
plugindir = $(XED_PLUGINS_LIBS_DIR)
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(XED_CFLAGS) \
|
||||
$(WARN_CFLAGS) \
|
||||
$(DISABLE_DEPRECATED_CFLAGS)
|
||||
|
||||
modelinesdir = $(XED_PLUGINS_DATA_DIR)/modelines
|
||||
modelines_DATA = \
|
||||
language-mappings
|
||||
|
||||
plugin_LTLIBRARIES = libmodelines.la
|
||||
|
||||
libmodelines_la_SOURCES = \
|
||||
xed-modeline-plugin.h \
|
||||
xed-modeline-plugin.c \
|
||||
modeline-parser.h \
|
||||
modeline-parser.c
|
||||
|
||||
libmodelines_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
|
||||
libmodelines_la_LIBADD = $(XED_LIBS)
|
||||
|
||||
plugin_in_files = modelines.plugin.desktop.in
|
||||
%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
|
||||
|
||||
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(plugin_in_files) \
|
||||
$(modelines_DATA)
|
||||
|
||||
CLEANFILES = $(plugin_DATA)
|
||||
DISTCLEANFILES = $(plugin_DATA)
|
||||
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,40 @@
|
|||
modelines_sources = [
|
||||
'xed-modeline-plugin.h',
|
||||
'xed-modeline-plugin.c',
|
||||
'modeline-parser.h',
|
||||
'modeline-parser.c'
|
||||
]
|
||||
|
||||
modelines_deps = [
|
||||
config_h,
|
||||
glib,
|
||||
gmodule,
|
||||
gtk,
|
||||
gtksourceview,
|
||||
libpeas
|
||||
]
|
||||
|
||||
library(
|
||||
'modelines',
|
||||
modelines_sources,
|
||||
link_with: libxed,
|
||||
dependencies: modelines_deps,
|
||||
include_directories: include_dirs,
|
||||
install_rpath: join_paths(prefix, libdir, 'xed'),
|
||||
install: true,
|
||||
install_dir: join_paths(libdir, 'xed', 'plugins')
|
||||
)
|
||||
|
||||
install_data(
|
||||
'language-mappings',
|
||||
install_dir: join_paths(pluginsdatadir, 'modelines')
|
||||
)
|
||||
|
||||
modelines_desktop = custom_target(
|
||||
'modelines_desktop',
|
||||
input: 'modelines.plugin.desktop.in',
|
||||
output: 'modelines.plugin',
|
||||
command: [intltool_merge, '-d', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: pluginslibdir,
|
||||
)
|
|
@ -19,19 +19,16 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gmodule.h>
|
||||
#include "xed-modeline-plugin.h"
|
||||
#include "modeline-parser.h"
|
||||
|
||||
#include <xed/xed-debug.h>
|
||||
#include <xed/xed-view-activatable.h>
|
||||
#include <xed/xed-view.h>
|
||||
|
||||
#include "xed-modeline-plugin.h"
|
||||
#include "modeline-parser.h"
|
||||
|
||||
struct _XedModelinePluginPrivate
|
||||
{
|
||||
XedView *view;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
install_subdir(
|
||||
'open-uri-context-menu',
|
||||
install_dir: pluginslibdir
|
||||
)
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
@ -0,0 +1,11 @@
|
|||
[Plugin]
|
||||
Loader=python3
|
||||
Module=open-uri-context-menu
|
||||
IAge=3
|
||||
Name=Open URI
|
||||
Description=Adds context menu item to open an URI at the pointer position.
|
||||
Icon=gtk-open
|
||||
Authors=Martin Szulecki <opensuse@sukimashita.com>\nJean-Philippe Fleury <contact@jpfleury.net>
|
||||
Copyright=Copyright © 2007-2008 Martin Szulecki\nCopyright © 2011 Jean-Philippe Fleury
|
||||
Website=https://github.com/jpfleury/open-uri-context-menu
|
||||
Builtin=true
|
|
@ -0,0 +1,179 @@
|
|||
# Copyright (C) 2007-2008 Martin Szulecki
|
||||
# Copyright (C) 2011 Jean-Philippe Fleury <contact@jpfleury.net>
|
||||
#
|
||||
# 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
'''
|
||||
Adds context menu item to open an URI at the pointer position
|
||||
'''
|
||||
|
||||
from gi.repository import Gtk, Xed, Gio, GObject, GtkSource
|
||||
import gettext
|
||||
import re
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import string
|
||||
|
||||
gettext.install("xed")
|
||||
|
||||
ACCEPTED_SCHEMES = ['file', 'ftp', 'sftp', 'smb', 'dav', 'davs', 'ssh', 'http', 'https']
|
||||
RE_DELIM = re.compile(r'[\w#/\?:%@&\=\+\.\\~-]+', re.UNICODE|re.MULTILINE)
|
||||
RE_URI_RFC2396 = re.compile("((([a-zA-Z][0-9a-zA-Z+\\-\\.]*):)?/{0,2}([0-9a-zA-Z;:,/\?@&=\+\$\.\-_!~\*'\(\)%]+))?(#[0-9a-zA-Z;,/\?:@&\=+$\.\\-_!~\*'\(\)%]+)?")
|
||||
|
||||
class OpenURIContextMenuPlugin(GObject.Object, Xed.WindowActivatable):
|
||||
__gtype_name__ = "OpenURIContextMenuPlugin"
|
||||
window = GObject.property(type=Xed.Window)
|
||||
|
||||
def __init__(self):
|
||||
GObject.Object.__init__(self)
|
||||
self.uri = ""
|
||||
self.window = None
|
||||
self.encoding = GtkSource.Encoding.get_from_charset("UTF-8")
|
||||
|
||||
def do_activate(self):
|
||||
handler_ids = []
|
||||
for signal in ('tab-added', 'tab-removed'):
|
||||
method = getattr(self, 'on_window_' + signal.replace('-', '_'))
|
||||
handler_ids.append(self.window.connect(signal, method))
|
||||
self.window.OpenURIContextMenuPluginID = handler_ids
|
||||
for view in self.window.get_views():
|
||||
self.connect_view(view)
|
||||
|
||||
def do_deactivate(self):
|
||||
widgets = [self.window] + self.window.get_views()
|
||||
for widget in widgets:
|
||||
handler_ids = widget.OpenURIContextMenuPluginID
|
||||
if not handler_ids is None:
|
||||
for handler_id in handler_ids:
|
||||
widget.disconnect(handler_id)
|
||||
widget.OpenURIContextMenuPluginID = None
|
||||
self.window = None
|
||||
|
||||
def connect_view(self, view):
|
||||
handler_id = view.connect('populate-popup', self.on_view_populate_popup)
|
||||
view.OpenURIContextMenuPluginID = [handler_id]
|
||||
|
||||
def update_ui(self, window):
|
||||
pass
|
||||
|
||||
def browse_url(self, menu_item, url):
|
||||
command = ['xdg-open', url]
|
||||
# Avoid to run the browser as user root
|
||||
if os.getuid() == 0 and os.environ.has_key('SUDO_USER'):
|
||||
command = ['sudo', '-u', os.environ['SUDO_USER']] + command
|
||||
subprocess.Popen(command)
|
||||
|
||||
def on_window_tab_added(self, window, tab):
|
||||
self.connect_view(tab.get_view())
|
||||
|
||||
def on_window_tab_removed(self, window, tab):
|
||||
pass
|
||||
|
||||
def on_view_populate_popup(self, view, menu):
|
||||
doc = view.get_buffer()
|
||||
win = view.get_window(Gtk.TextWindowType.TEXT);
|
||||
ptr_window, x, y, mod = win.get_pointer()
|
||||
x, y = view.window_to_buffer_coords(Gtk.TextWindowType.TEXT, x, y);
|
||||
|
||||
# First try at pointer location
|
||||
# Starting with GTK 3.20, get_iter_at_location returns a tuple of type
|
||||
# (gboolean, GtkTextIter). Earlier versions return only the GtkTextIter.
|
||||
insert = view.get_iter_at_location(x, y);
|
||||
if isinstance(insert, tuple):
|
||||
insert = insert[1] if insert[0] else None
|
||||
|
||||
# Second try at cursor
|
||||
if insert == None:
|
||||
insert = doc.get_iter_at_mark(doc.get_insert())
|
||||
if isinstance(insert, tuple):
|
||||
insert = insert[1] if insert[0] else None
|
||||
|
||||
while insert.forward_char():
|
||||
if not RE_DELIM.match(insert.get_char()):
|
||||
break
|
||||
|
||||
start = insert.copy()
|
||||
while start.backward_char():
|
||||
if not RE_DELIM.match(start.get_char()):
|
||||
start.forward_char();
|
||||
break
|
||||
|
||||
word = doc.get_text(start, insert, False)
|
||||
if len(word) == 0:
|
||||
return True
|
||||
|
||||
word = self.validate_uri(word)
|
||||
if not word:
|
||||
return True
|
||||
|
||||
displayed_word = word
|
||||
if len(displayed_word) > 50:
|
||||
displayed_word = displayed_word[:50] + u"\u2026"
|
||||
|
||||
browse_to = False
|
||||
if word.startswith("http://") or word.startswith("https://"):
|
||||
browse_to = True
|
||||
|
||||
if browse_to:
|
||||
browse_uri_item = Gtk.MenuItem(_("Open '%s'") % (displayed_word))
|
||||
browse_uri_item.connect('activate', self.browse_url, word);
|
||||
browse_uri_item.show();
|
||||
|
||||
separator = Gtk.SeparatorMenuItem()
|
||||
separator.show();
|
||||
menu.prepend(separator)
|
||||
menu.prepend(browse_uri_item)
|
||||
return True
|
||||
|
||||
def validate_uri(self, uri):
|
||||
m = RE_URI_RFC2396.search(uri);
|
||||
if not m:
|
||||
return False
|
||||
|
||||
target = m.group()
|
||||
|
||||
if m.group(4) == None or m.group(4) == "/":
|
||||
return False
|
||||
|
||||
if m.group(2) != None:
|
||||
if m.group(3) in ACCEPTED_SCHEMES:
|
||||
return target
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
if m.group(4).startswith("www."):
|
||||
return 'http://' + target
|
||||
|
||||
target = os.path.expanduser(target)
|
||||
if os.path.isfile(target):
|
||||
if os.path.isabs(target):
|
||||
return 'file://' + target
|
||||
|
||||
doc_dir = self.window.get_active_document().get_uri_for_display()
|
||||
if doc_dir != None:
|
||||
if doc_dir.startswith('file://'):
|
||||
f = os.path.join(os.path.dirname(doc_dir), target)
|
||||
if os.path.isfile(f.replace('file://', '', 1)):
|
||||
return f
|
||||
else:
|
||||
return os.path.join(os.path.dirname(doc_dir), target)
|
||||
|
||||
paths = string.split(os.environ["PATH"], os.pathsep)
|
||||
for dirname in paths:
|
||||
f = os.path.join(os.path.dirname(dirname), 'include', target)
|
||||
if os.path.isfile(f):
|
||||
return 'file://' + f
|
||||
|
||||
return False
|
|
@ -1,31 +0,0 @@
|
|||
# sort plugin
|
||||
plugindir = $(XED_PLUGINS_LIBS_DIR)
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(XED_CFLAGS) \
|
||||
$(WARN_CFLAGS) \
|
||||
$(DISABLE_DEPRECATED_CFLAGS)
|
||||
|
||||
plugin_LTLIBRARIES = libsort.la
|
||||
|
||||
libsort_la_SOURCES = \
|
||||
xed-sort-plugin.h \
|
||||
xed-sort-plugin.c
|
||||
|
||||
libsort_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
|
||||
libsort_la_LIBADD = $(XED_LIBS)
|
||||
|
||||
plugin_in_files = sort.plugin.desktop.in
|
||||
|
||||
%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
|
||||
|
||||
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
|
||||
|
||||
EXTRA_DIST = $(plugin_in_files)
|
||||
|
||||
CLEANFILES = $(plugin_DATA)
|
||||
DISTCLEANFILES = $(plugin_DATA)
|
||||
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,31 @@
|
|||
sort_sources = [
|
||||
'xed-sort-plugin.h',
|
||||
'xed-sort-plugin.c'
|
||||
]
|
||||
|
||||
sort_deps = [
|
||||
config_h,
|
||||
glib,
|
||||
gtksourceview,
|
||||
libpeas
|
||||
]
|
||||
|
||||
library(
|
||||
'sort',
|
||||
sort_sources,
|
||||
link_with: libxed,
|
||||
dependencies: sort_deps,
|
||||
include_directories: include_dirs,
|
||||
install_rpath: join_paths(prefix, libdir, 'xed'),
|
||||
install: true,
|
||||
install_dir: join_paths(libdir, 'xed', 'plugins'),
|
||||
)
|
||||
|
||||
sort_desktop = custom_target(
|
||||
'sort_desktop',
|
||||
input: 'sort.plugin.desktop.in',
|
||||
output: 'sort.plugin',
|
||||
command: [intltool_merge, '-d', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: pluginslibdir,
|
||||
)
|
|
@ -21,22 +21,18 @@
|
|||
* $Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xed-sort-plugin.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include <xed/xed-window.h>
|
||||
#include <xed/xed-window-activatable.h>
|
||||
#include <xed/xed-debug.h>
|
||||
#include <xed/xed-utils.h>
|
||||
#include <xed/xed-app.h>
|
||||
|
||||
#include "xed-sort-plugin.h"
|
||||
|
||||
#define XED_SORT_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_SORT_PLUGIN, XedSortPluginPrivate))
|
||||
|
||||
#define MENU_PATH "/MenuBar/EditMenu/EditOps_6"
|
||||
|
@ -169,7 +165,6 @@ buffer_sort_lines (GtkSourceBuffer *buffer,
|
|||
gint end_line;
|
||||
gint num_lines;
|
||||
SortLine *lines;
|
||||
gchar *last_line = NULL;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GTK_SOURCE_IS_BUFFER (buffer));
|
||||
|
@ -230,8 +225,6 @@ buffer_sort_lines (GtkSourceBuffer *buffer,
|
|||
{
|
||||
gtk_text_buffer_insert (text_buffer, start, lines[i].line, -1);
|
||||
gtk_text_buffer_insert (text_buffer, start, "\n", -1);
|
||||
|
||||
last_line = lines[i].line;
|
||||
}
|
||||
|
||||
gtk_text_buffer_end_user_action (text_buffer);
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
# Spell checker plugin
|
||||
plugindir = $(XED_PLUGINS_LIBS_DIR)
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(XED_CFLAGS) \
|
||||
$(ENCHANT_CFLAGS) \
|
||||
$(WARN_CFLAGS) \
|
||||
$(DISABLE_DEPRECATED_CFLAGS)
|
||||
|
||||
BUILT_SOURCES = \
|
||||
xed-spell-marshal.c \
|
||||
xed-spell-marshal.h
|
||||
|
||||
plugin_LTLIBRARIES = libspell.la
|
||||
|
||||
libspell_la_SOURCES = \
|
||||
xed-spell-plugin.c \
|
||||
xed-spell-plugin.h \
|
||||
xed-spell-checker.c \
|
||||
xed-spell-checker.h \
|
||||
xed-spell-checker-dialog.c \
|
||||
xed-spell-checker-dialog.h \
|
||||
xed-spell-checker-language.c \
|
||||
xed-spell-checker-language.h \
|
||||
xed-spell-language-dialog.c \
|
||||
xed-spell-language-dialog.h \
|
||||
xed-automatic-spell-checker.c \
|
||||
xed-automatic-spell-checker.h \
|
||||
xed-spell-utils.c \
|
||||
xed-spell-utils.h \
|
||||
$(BUILT_SOURCES)
|
||||
|
||||
libspell_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
|
||||
libspell_la_LIBADD = $(XED_LIBS) $(ENCHANT_LIBS)
|
||||
|
||||
uidir = $(XED_PLUGINS_DATA_DIR)/spell
|
||||
ui_DATA = spell-checker.ui languages-dialog.ui xed-spell-setup-dialog.ui
|
||||
|
||||
xed-spell-marshal.h: xed-spell-marshal.list $(GLIB_GENMARSHAL)
|
||||
$(AM_V_GEN) $(GLIB_GENMARSHAL) $< --header --prefix=xed_marshal > $@
|
||||
|
||||
xed-spell-marshal.c: xed-spell-marshal.list $(GLIB_GENMARSHAL)
|
||||
$(AM_V_GEN) echo "#include \"xed-spell-marshal.h\"" > $@ && \
|
||||
$(GLIB_GENMARSHAL) $< --body --prefix=xed_marshal >> $@
|
||||
|
||||
plugin_in_files = spell.plugin.desktop.in
|
||||
|
||||
%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
|
||||
|
||||
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
|
||||
|
||||
@INTLTOOL_XML_NOMERGE_RULE@
|
||||
spell_gschema_in = org.x.editor.plugins.spell.gschema.xml.in
|
||||
gsettings_SCHEMAS = $(spell_gschema_in:.xml.in=.xml)
|
||||
@GSETTINGS_RULES@
|
||||
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(ui_DATA) \
|
||||
$(plugin_in_files) \
|
||||
xed-spell-marshal.list \
|
||||
$(spell_gschema_in)
|
||||
|
||||
CLEANFILES = $(BUILT_SOURCES) $(plugin_DATA) $(gsettings_SCHEMAS)
|
||||
|
||||
dist-hook:
|
||||
cd $(distdir); rm -f $(BUILT_SOURCES)
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -1,140 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.18.3 -->
|
||||
<!--*- mode: xml -*-->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.10"/>
|
||||
<object class="GtkDialog" id="dialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">5</property>
|
||||
<property name="title" translatable="yes">Set language</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="dialog-vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="helpbutton1">
|
||||
<property name="label">gtk-help</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="closebutton1">
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="content">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="border_width">5</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">11</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Select the _language of the current document.</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="mnemonic_widget">languages_treeview</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="height_request">180</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="shadow_type">etched-in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="languages_treeview">
|
||||
<property name="height_request">180</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection1"/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-11">helpbutton1</action-widget>
|
||||
<action-widget response="-6">closebutton1</action-widget>
|
||||
<action-widget response="-5">button1</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
|
@ -0,0 +1,57 @@
|
|||
spell_sources = [
|
||||
'xed-spell-plugin.c',
|
||||
'xed-spell-plugin.h'
|
||||
]
|
||||
|
||||
spell_marshal = gnome.genmarshal(
|
||||
'xed-spell-marshal',
|
||||
sources: 'xed-spell-marshal.list',
|
||||
prefix: 'xed_spell_marshal'
|
||||
)
|
||||
|
||||
spell_deps = [
|
||||
config_h,
|
||||
glib,
|
||||
gspell,
|
||||
gtksourceview,
|
||||
libpeas,
|
||||
libpeas_gtk
|
||||
]
|
||||
|
||||
library(
|
||||
'spell',
|
||||
spell_sources + spell_marshal,
|
||||
link_with: libxed,
|
||||
dependencies: spell_deps,
|
||||
include_directories: include_dirs,
|
||||
install_rpath: join_paths(prefix, libdir, 'xed'),
|
||||
install: true,
|
||||
install_dir: join_paths(libdir, 'xed', 'plugins')
|
||||
)
|
||||
|
||||
install_data(
|
||||
'xed-spell-setup-dialog.ui',
|
||||
install_dir: join_paths(pluginsdatadir, 'spell')
|
||||
)
|
||||
|
||||
spell_desktop = custom_target(
|
||||
'spell_desktop',
|
||||
input: 'spell.plugin.desktop.in',
|
||||
output: 'spell.plugin',
|
||||
command: [intltool_merge, '-d', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: pluginslibdir,
|
||||
)
|
||||
|
||||
|
||||
spell_schema_file = configure_file(
|
||||
input: 'org.x.editor.plugins.spell.gschema.xml.in',
|
||||
output: 'org.x.editor.plugins.spell.gschema.xml',
|
||||
configuration: schema_conf,
|
||||
install_dir: join_paths(datadir, 'glib-2.0', 'schemas')
|
||||
)
|
||||
|
||||
install_data(
|
||||
spell_schema_file,
|
||||
install_dir: schema_dir
|
||||
)
|
|
@ -1,369 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.18.3 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.10"/>
|
||||
<object class="GtkWindow" id="check_spelling_window">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<property name="skip_taskbar_hint">True</property>
|
||||
<property name="startup_id">Check spelling</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="content">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">12</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<property name="column_spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Misspelled word:</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="misspelled_word_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">word</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">center</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Change _to:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="word_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="check_word_button">
|
||||
<property name="label" translatable="yes">Check _Word</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="row_spacing">6</property>
|
||||
<property name="column_spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">_Suggestions:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="suggestions_list">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection1"/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="row_spacing">12</property>
|
||||
<property name="column_spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="ignore_button">
|
||||
<property name="label" translatable="yes">_Ignore</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="ignore_all_button">
|
||||
<property name="label" translatable="yes">Ignore _All</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="change_button">
|
||||
<property name="label" translatable="yes">Cha_nge</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="change_all_button">
|
||||
<property name="label" translatable="yes">Change A_ll</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">11</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">User dictionary:</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box7">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="add_word_button">
|
||||
<property name="label" translatable="yes">Add w_ord</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Language:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="language_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Language</property>
|
||||
<property name="use_markup">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButtonBox" id="buttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="close_button">
|
||||
<property name="label" translatable="yes">_Close</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="use_underline">True</property>
|
||||
<style>
|
||||
<class name="text-button"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -1,967 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* xed-automatic-spell-checker.c
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2002 Paolo Maggi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the xed Team, 2002. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
/* This is a modified version of gtkspell 2.0.5 (gtkspell.sf.net) */
|
||||
/* gtkspell - a spell-checking addon for GTK's TextView widget
|
||||
* Copyright (c) 2002 Evan Martin.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "xed-automatic-spell-checker.h"
|
||||
#include "xed-spell-utils.h"
|
||||
|
||||
struct _XedAutomaticSpellChecker
|
||||
{
|
||||
XedDocument *doc;
|
||||
GSList *views;
|
||||
|
||||
GtkTextMark *mark_insert_start;
|
||||
GtkTextMark *mark_insert_end;
|
||||
gboolean deferred_check;
|
||||
|
||||
GtkTextTag *tag_highlight;
|
||||
GtkTextMark *mark_click;
|
||||
|
||||
XedSpellChecker *spell_checker;
|
||||
};
|
||||
|
||||
static GQuark automatic_spell_checker_id = 0;
|
||||
static GQuark suggestion_id = 0;
|
||||
|
||||
static void xed_automatic_spell_checker_free_internal (XedAutomaticSpellChecker *spell);
|
||||
|
||||
static void
|
||||
view_destroy (XedView *view,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
xed_automatic_spell_checker_detach_view (spell, view);
|
||||
}
|
||||
|
||||
static void
|
||||
check_word (XedAutomaticSpellChecker *spell,
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end)
|
||||
{
|
||||
gchar *word;
|
||||
|
||||
word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), start, end, FALSE);
|
||||
|
||||
/*
|
||||
g_print ("Check word: %s [%d - %d]\n", word, gtk_text_iter_get_offset (start),
|
||||
gtk_text_iter_get_offset (end));
|
||||
*/
|
||||
|
||||
if (!xed_spell_checker_check_word (spell->spell_checker, word, -1))
|
||||
{
|
||||
/*
|
||||
g_print ("Apply tag: [%d - %d]\n", gtk_text_iter_get_offset (start),
|
||||
gtk_text_iter_get_offset (end));
|
||||
*/
|
||||
gtk_text_buffer_apply_tag (GTK_TEXT_BUFFER (spell->doc), spell->tag_highlight, start, end);
|
||||
}
|
||||
|
||||
g_free (word);
|
||||
}
|
||||
|
||||
static void
|
||||
check_range (XedAutomaticSpellChecker *spell,
|
||||
GtkTextIter start,
|
||||
GtkTextIter end,
|
||||
gboolean force_all)
|
||||
{
|
||||
/* we need to "split" on word boundaries.
|
||||
* luckily, Pango knows what "words" are
|
||||
* so we don't have to figure it out. */
|
||||
|
||||
GtkTextIter wstart;
|
||||
GtkTextIter wend;
|
||||
GtkTextIter cursor;
|
||||
GtkTextIter precursor;
|
||||
gboolean highlight;
|
||||
|
||||
/*
|
||||
g_print ("Check range: [%d - %d]\n", gtk_text_iter_get_offset (&start),
|
||||
gtk_text_iter_get_offset (&end));
|
||||
*/
|
||||
|
||||
if (gtk_text_iter_inside_word (&end))
|
||||
{
|
||||
gtk_text_iter_forward_word_end (&end);
|
||||
}
|
||||
|
||||
if (!gtk_text_iter_starts_word (&start))
|
||||
{
|
||||
if (gtk_text_iter_inside_word (&start) || gtk_text_iter_ends_word (&start))
|
||||
{
|
||||
gtk_text_iter_backward_word_start (&start);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if we're neither at the beginning nor inside a word,
|
||||
* me must be in some spaces.
|
||||
* skip forward to the beginning of the next word. */
|
||||
|
||||
if (gtk_text_iter_forward_word_end (&start))
|
||||
{
|
||||
gtk_text_iter_backward_word_start (&start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (spell->doc),
|
||||
&cursor,
|
||||
gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (spell->doc)));
|
||||
|
||||
precursor = cursor;
|
||||
gtk_text_iter_backward_char (&precursor);
|
||||
|
||||
highlight = gtk_text_iter_has_tag (&cursor, spell->tag_highlight) ||
|
||||
gtk_text_iter_has_tag (&precursor, spell->tag_highlight);
|
||||
|
||||
gtk_text_buffer_remove_tag (GTK_TEXT_BUFFER (spell->doc), spell->tag_highlight, &start, &end);
|
||||
|
||||
/* Fix a corner case when replacement occurs at beginning of buffer:
|
||||
* An iter at offset 0 seems to always be inside a word,
|
||||
* even if it's not. Possibly a pango bug.
|
||||
*/
|
||||
if (gtk_text_iter_get_offset (&start) == 0)
|
||||
{
|
||||
gtk_text_iter_forward_word_end(&start);
|
||||
gtk_text_iter_backward_word_start(&start);
|
||||
}
|
||||
|
||||
wstart = start;
|
||||
|
||||
while (xed_spell_utils_skip_no_spell_check (&wstart, &end) && gtk_text_iter_compare (&wstart, &end) < 0)
|
||||
{
|
||||
gboolean inword;
|
||||
|
||||
/* move wend to the end of the current word. */
|
||||
wend = wstart;
|
||||
|
||||
gtk_text_iter_forward_word_end (&wend);
|
||||
|
||||
inword = (gtk_text_iter_compare (&wstart, &cursor) < 0) && (gtk_text_iter_compare (&cursor, &wend) <= 0);
|
||||
|
||||
if (inword && !force_all)
|
||||
{
|
||||
/* this word is being actively edited,
|
||||
* only check if it's already highligted,
|
||||
* otherwise defer this check until later. */
|
||||
if (highlight)
|
||||
{
|
||||
check_word (spell, &wstart, &wend);
|
||||
}
|
||||
else
|
||||
{
|
||||
spell->deferred_check = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
check_word (spell, &wstart, &wend);
|
||||
spell->deferred_check = FALSE;
|
||||
}
|
||||
|
||||
/* now move wend to the beginning of the next word, */
|
||||
gtk_text_iter_forward_word_end (&wend);
|
||||
gtk_text_iter_backward_word_start (&wend);
|
||||
|
||||
/* make sure we've actually advanced
|
||||
* (we don't advance in some corner cases), */
|
||||
if (gtk_text_iter_equal (&wstart, &wend))
|
||||
{
|
||||
break; /* we're done in these cases.. */
|
||||
}
|
||||
|
||||
/* and then pick this as the new next word beginning. */
|
||||
wstart = wend;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
check_deferred_range (XedAutomaticSpellChecker *spell,
|
||||
gboolean force_all)
|
||||
{
|
||||
GtkTextIter start, end;
|
||||
|
||||
gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (spell->doc), &start, spell->mark_insert_start);
|
||||
gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (spell->doc), &end, spell->mark_insert_end);
|
||||
|
||||
check_range (spell, start, end, force_all);
|
||||
}
|
||||
|
||||
/* insertion works like this:
|
||||
* - before the text is inserted, we mark the position in the buffer.
|
||||
* - after the text is inserted, we see where our mark is and use that and
|
||||
* the current position to check the entire range of inserted text.
|
||||
*
|
||||
* this may be overkill for the common case (inserting one character). */
|
||||
|
||||
static void
|
||||
insert_text_before (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
gchar *text,
|
||||
gint len,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
gtk_text_buffer_move_mark (buffer, spell->mark_insert_start, iter);
|
||||
}
|
||||
|
||||
static void
|
||||
insert_text_after (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
gchar *text,
|
||||
gint len,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
GtkTextIter start;
|
||||
|
||||
/* we need to check a range of text. */
|
||||
gtk_text_buffer_get_iter_at_mark (buffer, &start, spell->mark_insert_start);
|
||||
|
||||
check_range (spell, start, *iter, FALSE);
|
||||
|
||||
gtk_text_buffer_move_mark (buffer, spell->mark_insert_end, iter);
|
||||
}
|
||||
|
||||
/* deleting is more simple: we're given the range of deleted text.
|
||||
* after deletion, the start and end iters should be at the same position
|
||||
* (because all of the text between them was deleted!).
|
||||
* this means we only really check the words immediately bounding the
|
||||
* deletion.
|
||||
*/
|
||||
|
||||
static void
|
||||
delete_range_after (GtkTextBuffer *buffer,
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
check_range (spell, *start, *end, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
mark_set (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
GtkTextMark *mark,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
/* if the cursor has moved and there is a deferred check so handle it now */
|
||||
if ((mark == gtk_text_buffer_get_insert (buffer)) && spell->deferred_check)
|
||||
{
|
||||
check_deferred_range (spell, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_word_extents_from_mark (GtkTextBuffer *buffer,
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end,
|
||||
GtkTextMark *mark)
|
||||
{
|
||||
gtk_text_buffer_get_iter_at_mark(buffer, start, mark);
|
||||
|
||||
if (!gtk_text_iter_starts_word (start))
|
||||
{
|
||||
gtk_text_iter_backward_word_start (start);
|
||||
}
|
||||
|
||||
*end = *start;
|
||||
|
||||
if (gtk_text_iter_inside_word (end))
|
||||
{
|
||||
gtk_text_iter_forward_word_end (end);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
remove_tag_to_word (XedAutomaticSpellChecker *spell,
|
||||
const gchar *word)
|
||||
{
|
||||
GtkTextIter iter;
|
||||
GtkTextIter match_start, match_end;
|
||||
|
||||
gboolean found;
|
||||
|
||||
gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (spell->doc), &iter, 0);
|
||||
|
||||
found = TRUE;
|
||||
|
||||
while (found)
|
||||
{
|
||||
found = gtk_text_iter_forward_search (&iter,
|
||||
word,
|
||||
GTK_TEXT_SEARCH_VISIBLE_ONLY | GTK_TEXT_SEARCH_TEXT_ONLY,
|
||||
&match_start,
|
||||
&match_end,
|
||||
NULL);
|
||||
|
||||
if (found)
|
||||
{
|
||||
if (gtk_text_iter_starts_word (&match_start) && gtk_text_iter_ends_word (&match_end))
|
||||
{
|
||||
gtk_text_buffer_remove_tag (GTK_TEXT_BUFFER (spell->doc),
|
||||
spell->tag_highlight,
|
||||
&match_start,
|
||||
&match_end);
|
||||
}
|
||||
|
||||
iter = match_end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_to_dictionary (GtkWidget *menuitem,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
gchar *word;
|
||||
|
||||
GtkTextIter start, end;
|
||||
|
||||
get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click);
|
||||
|
||||
word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE);
|
||||
|
||||
xed_spell_checker_add_word_to_personal (spell->spell_checker, word, -1);
|
||||
|
||||
g_free (word);
|
||||
}
|
||||
|
||||
static void
|
||||
ignore_all (GtkWidget *menuitem,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
gchar *word;
|
||||
|
||||
GtkTextIter start, end;
|
||||
|
||||
get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click);
|
||||
|
||||
word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE);
|
||||
|
||||
xed_spell_checker_add_word_to_session (spell->spell_checker, word, -1);
|
||||
|
||||
g_free (word);
|
||||
}
|
||||
|
||||
static void
|
||||
replace_word (GtkWidget *menuitem,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
gchar *oldword;
|
||||
const gchar *newword;
|
||||
|
||||
GtkTextIter start, end;
|
||||
|
||||
get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click);
|
||||
|
||||
oldword = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE);
|
||||
|
||||
newword = g_object_get_qdata (G_OBJECT (menuitem), suggestion_id);
|
||||
g_return_if_fail (newword != NULL);
|
||||
|
||||
gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (spell->doc));
|
||||
|
||||
gtk_text_buffer_delete (GTK_TEXT_BUFFER (spell->doc), &start, &end);
|
||||
gtk_text_buffer_insert (GTK_TEXT_BUFFER (spell->doc), &start, newword, -1);
|
||||
|
||||
gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (spell->doc));
|
||||
|
||||
xed_spell_checker_set_correction (spell->spell_checker,
|
||||
oldword, strlen (oldword),
|
||||
newword, strlen (newword));
|
||||
|
||||
g_free (oldword);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
build_suggestion_menu (XedAutomaticSpellChecker *spell,
|
||||
const gchar *word)
|
||||
{
|
||||
GtkWidget *topmenu, *menu;
|
||||
GtkWidget *mi;
|
||||
GSList *suggestions;
|
||||
GSList *list;
|
||||
gchar *label_text;
|
||||
|
||||
topmenu = menu = gtk_menu_new();
|
||||
|
||||
suggestions = xed_spell_checker_get_suggestions (spell->spell_checker, word, -1);
|
||||
|
||||
list = suggestions;
|
||||
|
||||
if (suggestions == NULL)
|
||||
{
|
||||
/* no suggestions. put something in the menu anyway... */
|
||||
GtkWidget *label;
|
||||
/* Translators: Displayed in the "Check Spelling" dialog if there are no suggestions for the current misspelled word */
|
||||
label = gtk_label_new (_("(no suggested words)"));
|
||||
|
||||
mi = gtk_menu_item_new ();
|
||||
gtk_widget_set_sensitive (mi, FALSE);
|
||||
gtk_container_add (GTK_CONTAINER(mi), label);
|
||||
gtk_widget_show_all (mi);
|
||||
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
|
||||
}
|
||||
else
|
||||
{
|
||||
gint count = 0;
|
||||
|
||||
/* build a set of menus with suggestions. */
|
||||
while (suggestions != NULL)
|
||||
{
|
||||
GtkWidget *label;
|
||||
|
||||
if (count == 10)
|
||||
{
|
||||
/* Separator */
|
||||
mi = gtk_menu_item_new ();
|
||||
gtk_widget_show (mi);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
|
||||
|
||||
mi = gtk_menu_item_new_with_mnemonic (_("_More..."));
|
||||
gtk_widget_show (mi);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu);
|
||||
count = 0;
|
||||
}
|
||||
|
||||
label_text = g_strdup_printf ("<b>%s</b>", (gchar*) suggestions->data);
|
||||
|
||||
label = gtk_label_new (label_text);
|
||||
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||
|
||||
mi = gtk_menu_item_new ();
|
||||
gtk_container_add (GTK_CONTAINER (mi), label);
|
||||
|
||||
gtk_widget_show_all (mi);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
|
||||
|
||||
g_object_set_qdata_full (G_OBJECT (mi),
|
||||
suggestion_id,
|
||||
g_strdup (suggestions->data),
|
||||
(GDestroyNotify)g_free);
|
||||
|
||||
g_free (label_text);
|
||||
g_signal_connect (mi, "activate",
|
||||
G_CALLBACK (replace_word), spell);
|
||||
|
||||
count++;
|
||||
|
||||
suggestions = g_slist_next (suggestions);
|
||||
}
|
||||
}
|
||||
|
||||
/* free the suggestion list */
|
||||
suggestions = list;
|
||||
|
||||
while (list)
|
||||
{
|
||||
g_free (list->data);
|
||||
list = g_slist_next (list);
|
||||
}
|
||||
|
||||
g_slist_free (suggestions);
|
||||
|
||||
/* Separator */
|
||||
mi = gtk_menu_item_new ();
|
||||
gtk_widget_show (mi);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
|
||||
|
||||
/* Ignore all */
|
||||
mi = gtk_menu_item_new_with_mnemonic (_("_Ignore All"));
|
||||
|
||||
g_signal_connect (mi, "activate",
|
||||
G_CALLBACK(ignore_all), spell);
|
||||
|
||||
gtk_widget_show_all (mi);
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
|
||||
|
||||
/* + Add to Dictionary */
|
||||
mi = gtk_menu_item_new_with_mnemonic (_("_Add"));
|
||||
|
||||
g_signal_connect (mi, "activate",
|
||||
G_CALLBACK (add_to_dictionary), spell);
|
||||
|
||||
gtk_widget_show_all (mi);
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
|
||||
|
||||
return topmenu;
|
||||
}
|
||||
|
||||
static void
|
||||
populate_popup (GtkTextView *textview,
|
||||
GtkMenu *menu,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
GtkWidget *mi;
|
||||
GtkTextIter start, end;
|
||||
char *word;
|
||||
|
||||
/* we need to figure out if they picked a misspelled word. */
|
||||
get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click);
|
||||
|
||||
/* if our highlight algorithm ever messes up,
|
||||
* this isn't correct, either. */
|
||||
if (!gtk_text_iter_has_tag (&start, spell->tag_highlight))
|
||||
{
|
||||
return; /* word wasn't misspelled. */
|
||||
}
|
||||
|
||||
/* menu separator comes first. */
|
||||
mi = gtk_menu_item_new ();
|
||||
gtk_widget_show (mi);
|
||||
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
|
||||
|
||||
/* then, on top of it, the suggestions menu. */
|
||||
mi = gtk_menu_item_new_with_mnemonic (_("_Spelling Suggestions..."));
|
||||
|
||||
word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE);
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), build_suggestion_menu (spell, word));
|
||||
g_free(word);
|
||||
|
||||
gtk_widget_show_all (mi);
|
||||
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
|
||||
}
|
||||
|
||||
void
|
||||
xed_automatic_spell_checker_recheck_all (XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
GtkTextIter start, end;
|
||||
|
||||
g_return_if_fail (spell != NULL);
|
||||
|
||||
gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (spell->doc), &start, &end);
|
||||
|
||||
check_range (spell, start, end, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
add_word_signal_cb (XedSpellChecker *checker,
|
||||
const gchar *word,
|
||||
gint len,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
gchar *w;
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
w = g_strdup (word);
|
||||
}
|
||||
else
|
||||
{
|
||||
w = g_strndup (word, len);
|
||||
}
|
||||
|
||||
remove_tag_to_word (spell, w);
|
||||
|
||||
g_free (w);
|
||||
}
|
||||
|
||||
static void
|
||||
set_language_cb (XedSpellChecker *checker,
|
||||
const XedSpellCheckerLanguage *lang,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
xed_automatic_spell_checker_recheck_all (spell);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_session_cb (XedSpellChecker *checker,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
xed_automatic_spell_checker_recheck_all (spell);
|
||||
}
|
||||
|
||||
/* When the user right-clicks on a word, they want to check that word.
|
||||
* Here, we do NOT move the cursor to the location of the clicked-upon word
|
||||
* since that prevents the use of edit functions on the context menu.
|
||||
*/
|
||||
static gboolean
|
||||
button_press_event (GtkTextView *view,
|
||||
GdkEventButton *event,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
if (event->button == 3)
|
||||
{
|
||||
gint x, y;
|
||||
GtkTextIter iter;
|
||||
|
||||
GtkTextBuffer *buffer = gtk_text_view_get_buffer (view);
|
||||
|
||||
/* handle deferred check if it exists */
|
||||
if (spell->deferred_check)
|
||||
{
|
||||
check_deferred_range (spell, TRUE);
|
||||
}
|
||||
|
||||
gtk_text_view_window_to_buffer_coords (view, GTK_TEXT_WINDOW_TEXT, event->x, event->y, &x, &y);
|
||||
|
||||
gtk_text_view_get_iter_at_location (view, &iter, x, y);
|
||||
|
||||
gtk_text_buffer_move_mark (buffer, spell->mark_click, &iter);
|
||||
}
|
||||
|
||||
return FALSE; /* false: let gtk process this event, too.
|
||||
we don't want to eat any events. */
|
||||
}
|
||||
|
||||
/* Move the insert mark before popping up the menu, otherwise it
|
||||
* will contain the wrong set of suggestions.
|
||||
*/
|
||||
static gboolean
|
||||
popup_menu_event (GtkTextView *view,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
GtkTextIter iter;
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (view);
|
||||
|
||||
/* handle deferred check if it exists */
|
||||
if (spell->deferred_check)
|
||||
{
|
||||
check_deferred_range (spell, TRUE);
|
||||
}
|
||||
|
||||
gtk_text_buffer_get_iter_at_mark (buffer, &iter, gtk_text_buffer_get_insert (buffer));
|
||||
gtk_text_buffer_move_mark (buffer, spell->mark_click, &iter);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
tag_table_changed (GtkTextTagTable *table,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
g_return_if_fail (spell->tag_highlight != NULL);
|
||||
|
||||
gtk_text_tag_set_priority (spell->tag_highlight, gtk_text_tag_table_get_size (table) - 1);
|
||||
}
|
||||
|
||||
static void
|
||||
tag_added_or_removed (GtkTextTagTable *table,
|
||||
GtkTextTag *tag,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
tag_table_changed (table, spell);
|
||||
}
|
||||
|
||||
static void
|
||||
tag_changed (GtkTextTagTable *table,
|
||||
GtkTextTag *tag,
|
||||
gboolean size_changed,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
tag_table_changed (table, spell);
|
||||
}
|
||||
|
||||
static void
|
||||
highlight_updated (GtkSourceBuffer *buffer,
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end,
|
||||
XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
check_range (spell, *start, *end, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
spell_tag_destroyed (XedAutomaticSpellChecker *spell,
|
||||
GObject *where_the_object_was)
|
||||
{
|
||||
spell->tag_highlight = NULL;
|
||||
}
|
||||
|
||||
XedAutomaticSpellChecker *
|
||||
xed_automatic_spell_checker_new (XedDocument *doc,
|
||||
XedSpellChecker *checker)
|
||||
{
|
||||
XedAutomaticSpellChecker *spell;
|
||||
GtkTextTagTable *tag_table;
|
||||
GtkTextIter start, end;
|
||||
|
||||
g_return_val_if_fail (XED_IS_DOCUMENT (doc), NULL);
|
||||
g_return_val_if_fail (XED_IS_SPELL_CHECKER (checker), NULL);
|
||||
g_return_val_if_fail ((spell = xed_automatic_spell_checker_get_from_document (doc)) == NULL, spell);
|
||||
|
||||
/* attach to the widget */
|
||||
spell = g_new0 (XedAutomaticSpellChecker, 1);
|
||||
|
||||
spell->doc = doc;
|
||||
spell->spell_checker = g_object_ref (checker);
|
||||
|
||||
if (automatic_spell_checker_id == 0)
|
||||
{
|
||||
automatic_spell_checker_id = g_quark_from_string ("XedAutomaticSpellCheckerID");
|
||||
}
|
||||
if (suggestion_id == 0)
|
||||
{
|
||||
suggestion_id = g_quark_from_string ("XedAutoSuggestionID");
|
||||
}
|
||||
|
||||
g_object_set_qdata_full (G_OBJECT (doc), automatic_spell_checker_id,
|
||||
spell, (GDestroyNotify)xed_automatic_spell_checker_free_internal);
|
||||
|
||||
g_signal_connect (doc, "insert-text",
|
||||
G_CALLBACK (insert_text_before), spell);
|
||||
g_signal_connect_after (doc, "insert-text",
|
||||
G_CALLBACK (insert_text_after), spell);
|
||||
g_signal_connect_after (doc, "delete-range",
|
||||
G_CALLBACK (delete_range_after), spell);
|
||||
g_signal_connect (doc, "mark-set",
|
||||
G_CALLBACK (mark_set), spell);
|
||||
|
||||
g_signal_connect (doc, "highlight-updated",
|
||||
G_CALLBACK (highlight_updated), spell);
|
||||
|
||||
g_signal_connect (spell->spell_checker, "add_word_to_session",
|
||||
G_CALLBACK (add_word_signal_cb), spell);
|
||||
g_signal_connect (spell->spell_checker, "add_word_to_personal",
|
||||
G_CALLBACK (add_word_signal_cb), spell);
|
||||
g_signal_connect (spell->spell_checker, "clear_session",
|
||||
G_CALLBACK (clear_session_cb), spell);
|
||||
g_signal_connect (spell->spell_checker, "set_language",
|
||||
G_CALLBACK (set_language_cb), spell);
|
||||
|
||||
spell->tag_highlight = gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (doc),
|
||||
"gtkspell-misspelled",
|
||||
"underline", PANGO_UNDERLINE_ERROR,
|
||||
NULL);
|
||||
|
||||
g_object_weak_ref (G_OBJECT (spell->tag_highlight), (GWeakNotify)spell_tag_destroyed, spell);
|
||||
|
||||
tag_table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (doc));
|
||||
|
||||
gtk_text_tag_set_priority (spell->tag_highlight, gtk_text_tag_table_get_size (tag_table) - 1);
|
||||
|
||||
g_signal_connect (tag_table, "tag-added",
|
||||
G_CALLBACK (tag_added_or_removed), spell);
|
||||
g_signal_connect (tag_table, "tag-removed",
|
||||
G_CALLBACK (tag_added_or_removed), spell);
|
||||
g_signal_connect (tag_table, "tag-changed",
|
||||
G_CALLBACK (tag_changed), spell);
|
||||
|
||||
/* we create the mark here, but we don't use it until text is
|
||||
* inserted, so we don't really care where iter points. */
|
||||
gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc), &start, &end);
|
||||
|
||||
spell->mark_insert_start = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc),
|
||||
"xed-automatic-spell-checker-insert-start");
|
||||
|
||||
if (spell->mark_insert_start == NULL)
|
||||
{
|
||||
spell->mark_insert_start = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc),
|
||||
"xed-automatic-spell-checker-insert-start",
|
||||
&start,
|
||||
TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), spell->mark_insert_start, &start);
|
||||
}
|
||||
|
||||
spell->mark_insert_end = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc),
|
||||
"xed-automatic-spell-checker-insert-end");
|
||||
|
||||
if (spell->mark_insert_end == NULL)
|
||||
{
|
||||
spell->mark_insert_end = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc),
|
||||
"xed-automatic-spell-checker-insert-end",
|
||||
&start,
|
||||
TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), spell->mark_insert_end, &start);
|
||||
}
|
||||
|
||||
spell->mark_click = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc),
|
||||
"xed-automatic-spell-checker-click");
|
||||
|
||||
if (spell->mark_click == NULL)
|
||||
{
|
||||
spell->mark_click = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc),
|
||||
"xed-automatic-spell-checker-click",
|
||||
&start,
|
||||
TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), spell->mark_click, &start);
|
||||
}
|
||||
|
||||
spell->deferred_check = FALSE;
|
||||
|
||||
return spell;
|
||||
}
|
||||
|
||||
XedAutomaticSpellChecker *
|
||||
xed_automatic_spell_checker_get_from_document (const XedDocument *doc)
|
||||
{
|
||||
g_return_val_if_fail (XED_IS_DOCUMENT (doc), NULL);
|
||||
|
||||
if (automatic_spell_checker_id == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_object_get_qdata (G_OBJECT (doc), automatic_spell_checker_id);
|
||||
}
|
||||
|
||||
void
|
||||
xed_automatic_spell_checker_free (XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
g_return_if_fail (spell != NULL);
|
||||
g_return_if_fail (xed_automatic_spell_checker_get_from_document (spell->doc) == spell);
|
||||
|
||||
if (automatic_spell_checker_id == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_set_qdata (G_OBJECT (spell->doc), automatic_spell_checker_id, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_automatic_spell_checker_free_internal (XedAutomaticSpellChecker *spell)
|
||||
{
|
||||
GtkTextTagTable *table;
|
||||
GtkTextIter start, end;
|
||||
GSList *list;
|
||||
|
||||
g_return_if_fail (spell != NULL);
|
||||
|
||||
table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (spell->doc));
|
||||
|
||||
if (table != NULL && spell->tag_highlight != NULL)
|
||||
{
|
||||
gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (spell->doc), &start, &end);
|
||||
gtk_text_buffer_remove_tag (GTK_TEXT_BUFFER (spell->doc), spell->tag_highlight, &start, &end);
|
||||
|
||||
g_signal_handlers_disconnect_matched (G_OBJECT (table),
|
||||
G_SIGNAL_MATCH_DATA,
|
||||
0, 0, NULL, NULL,
|
||||
spell);
|
||||
|
||||
gtk_text_tag_table_remove (table, spell->tag_highlight);
|
||||
}
|
||||
|
||||
g_signal_handlers_disconnect_matched (G_OBJECT (spell->doc),
|
||||
G_SIGNAL_MATCH_DATA,
|
||||
0, 0, NULL, NULL,
|
||||
spell);
|
||||
|
||||
g_signal_handlers_disconnect_matched (G_OBJECT (spell->spell_checker),
|
||||
G_SIGNAL_MATCH_DATA,
|
||||
0, 0, NULL, NULL,
|
||||
spell);
|
||||
|
||||
g_object_unref (spell->spell_checker);
|
||||
|
||||
list = spell->views;
|
||||
while (list != NULL)
|
||||
{
|
||||
XedView *view = XED_VIEW (list->data);
|
||||
|
||||
g_signal_handlers_disconnect_matched (G_OBJECT (view),
|
||||
G_SIGNAL_MATCH_DATA,
|
||||
0, 0, NULL, NULL,
|
||||
spell);
|
||||
|
||||
g_signal_handlers_disconnect_matched (G_OBJECT (view),
|
||||
G_SIGNAL_MATCH_DATA,
|
||||
0, 0, NULL, NULL,
|
||||
spell);
|
||||
|
||||
list = g_slist_next (list);
|
||||
}
|
||||
|
||||
g_slist_free (spell->views);
|
||||
|
||||
g_free (spell);
|
||||
}
|
||||
|
||||
void
|
||||
xed_automatic_spell_checker_attach_view (XedAutomaticSpellChecker *spell,
|
||||
XedView *view)
|
||||
{
|
||||
g_return_if_fail (spell != NULL);
|
||||
g_return_if_fail (XED_IS_VIEW (view));
|
||||
|
||||
g_return_if_fail (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)) == GTK_TEXT_BUFFER (spell->doc));
|
||||
|
||||
g_signal_connect (view, "button-press-event",
|
||||
G_CALLBACK (button_press_event), spell);
|
||||
g_signal_connect (view, "popup-menu",
|
||||
G_CALLBACK (popup_menu_event), spell);
|
||||
g_signal_connect (view, "populate-popup",
|
||||
G_CALLBACK (populate_popup), spell);
|
||||
g_signal_connect (view, "destroy",
|
||||
G_CALLBACK (view_destroy), spell);
|
||||
|
||||
spell->views = g_slist_prepend (spell->views, view);
|
||||
}
|
||||
|
||||
void
|
||||
xed_automatic_spell_checker_detach_view (XedAutomaticSpellChecker *spell,
|
||||
XedView *view)
|
||||
{
|
||||
g_return_if_fail (spell != NULL);
|
||||
g_return_if_fail (XED_IS_VIEW (view));
|
||||
|
||||
g_return_if_fail (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)) == GTK_TEXT_BUFFER (spell->doc));
|
||||
g_return_if_fail (spell->views != NULL);
|
||||
|
||||
g_signal_handlers_disconnect_matched (G_OBJECT (view),
|
||||
G_SIGNAL_MATCH_DATA,
|
||||
0, 0, NULL, NULL,
|
||||
spell);
|
||||
|
||||
g_signal_handlers_disconnect_matched (G_OBJECT (view),
|
||||
G_SIGNAL_MATCH_DATA,
|
||||
0, 0, NULL, NULL,
|
||||
spell);
|
||||
|
||||
spell->views = g_slist_remove (spell->views, view);
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* xed-automatic-spell-checker.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2002 Paolo Maggi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the xed Team, 2002. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
/* This is a modified version of gtkspell 2.0.2 (gtkspell.sf.net) */
|
||||
/* gtkspell - a spell-checking addon for GTK's TextView widget
|
||||
* Copyright (c) 2002 Evan Martin.
|
||||
*/
|
||||
|
||||
#ifndef __XED_AUTOMATIC_SPELL_CHECKER_H__
|
||||
#define __XED_AUTOMATIC_SPELL_CHECKER_H__
|
||||
|
||||
#include <xed/xed-document.h>
|
||||
#include <xed/xed-view.h>
|
||||
|
||||
#include "xed-spell-checker.h"
|
||||
|
||||
typedef struct _XedAutomaticSpellChecker XedAutomaticSpellChecker;
|
||||
|
||||
XedAutomaticSpellChecker *xed_automatic_spell_checker_new (
|
||||
XedDocument *doc,
|
||||
XedSpellChecker *checker);
|
||||
|
||||
XedAutomaticSpellChecker *xed_automatic_spell_checker_get_from_document (
|
||||
const XedDocument *doc);
|
||||
|
||||
void xed_automatic_spell_checker_free (
|
||||
XedAutomaticSpellChecker *spell);
|
||||
|
||||
void xed_automatic_spell_checker_attach_view (
|
||||
XedAutomaticSpellChecker *spell,
|
||||
XedView *view);
|
||||
|
||||
void xed_automatic_spell_checker_detach_view (
|
||||
XedAutomaticSpellChecker *spell,
|
||||
XedView *view);
|
||||
|
||||
void xed_automatic_spell_checker_recheck_all (
|
||||
XedAutomaticSpellChecker *spell);
|
||||
|
||||
#endif /* __XED_AUTOMATIC_SPELL_CHECKER_H__ */
|
||||
|
|
@ -1,726 +0,0 @@
|
|||
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* xed-spell-checker-dialog.c
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2002 Paolo Maggi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the xed Team, 2002. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <xed/xed-utils.h>
|
||||
#include "xed-spell-checker-dialog.h"
|
||||
#include "xed-spell-marshal.h"
|
||||
|
||||
struct _XedSpellCheckerDialog
|
||||
{
|
||||
GtkWindow parent_instance;
|
||||
|
||||
XedSpellChecker *spell_checker;
|
||||
|
||||
gchar *misspelled_word;
|
||||
|
||||
GtkWidget *misspelled_word_label;
|
||||
GtkWidget *word_entry;
|
||||
GtkWidget *check_word_button;
|
||||
GtkWidget *ignore_button;
|
||||
GtkWidget *ignore_all_button;
|
||||
GtkWidget *change_button;
|
||||
GtkWidget *change_all_button;
|
||||
GtkWidget *add_word_button;
|
||||
GtkWidget *close_button;
|
||||
GtkWidget *suggestions_list;
|
||||
GtkWidget *language_label;
|
||||
|
||||
GtkTreeModel *suggestions_list_model;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
IGNORE,
|
||||
IGNORE_ALL,
|
||||
CHANGE,
|
||||
CHANGE_ALL,
|
||||
ADD_WORD_TO_PERSONAL,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
COLUMN_SUGGESTIONS,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
static void update_suggestions_list_model (XedSpellCheckerDialog *dlg,
|
||||
GSList *suggestions);
|
||||
|
||||
static void word_entry_changed_handler (GtkEditable *editable,
|
||||
XedSpellCheckerDialog *dlg);
|
||||
static void close_button_clicked_handler (GtkButton *button,
|
||||
XedSpellCheckerDialog *dlg);
|
||||
static void suggestions_list_selection_changed_handler (GtkTreeSelection *selection,
|
||||
XedSpellCheckerDialog *dlg);
|
||||
static void check_word_button_clicked_handler (GtkButton *button,
|
||||
XedSpellCheckerDialog *dlg);
|
||||
static void add_word_button_clicked_handler (GtkButton *button,
|
||||
XedSpellCheckerDialog *dlg);
|
||||
static void ignore_button_clicked_handler (GtkButton *button,
|
||||
XedSpellCheckerDialog *dlg);
|
||||
static void ignore_all_button_clicked_handler (GtkButton *button,
|
||||
XedSpellCheckerDialog *dlg);
|
||||
static void change_button_clicked_handler (GtkButton *button,
|
||||
XedSpellCheckerDialog *dlg);
|
||||
static void change_all_button_clicked_handler (GtkButton *button,
|
||||
XedSpellCheckerDialog *dlg);
|
||||
static void suggestions_list_row_activated_handler (GtkTreeView *view,
|
||||
GtkTreePath *path,
|
||||
GtkTreeViewColumn *column,
|
||||
XedSpellCheckerDialog *dlg);
|
||||
|
||||
|
||||
static guint signals [LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE(XedSpellCheckerDialog, xed_spell_checker_dialog, GTK_TYPE_WINDOW)
|
||||
|
||||
static void
|
||||
xed_spell_checker_dialog_dispose (GObject *object)
|
||||
{
|
||||
XedSpellCheckerDialog *dlg = XED_SPELL_CHECKER_DIALOG (object);
|
||||
|
||||
if (dlg->spell_checker != NULL)
|
||||
{
|
||||
g_object_unref (dlg->spell_checker);
|
||||
dlg->spell_checker = NULL;
|
||||
}
|
||||
|
||||
if (dlg->misspelled_word != NULL)
|
||||
{
|
||||
g_free (dlg->misspelled_word);
|
||||
dlg->misspelled_word = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (xed_spell_checker_dialog_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_spell_checker_dialog_class_init (XedSpellCheckerDialogClass * klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = xed_spell_checker_dialog_dispose;
|
||||
|
||||
signals[IGNORE] =
|
||||
g_signal_new ("ignore",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (XedSpellCheckerDialogClass, ignore),
|
||||
NULL, NULL,
|
||||
xed_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_STRING);
|
||||
|
||||
signals[IGNORE_ALL] =
|
||||
g_signal_new ("ignore_all",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (XedSpellCheckerDialogClass, ignore_all),
|
||||
NULL, NULL,
|
||||
xed_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_STRING);
|
||||
|
||||
signals[CHANGE] =
|
||||
g_signal_new ("change",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (XedSpellCheckerDialogClass, change),
|
||||
NULL, NULL,
|
||||
xed_marshal_VOID__STRING_STRING,
|
||||
G_TYPE_NONE,
|
||||
2,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
|
||||
signals[CHANGE_ALL] =
|
||||
g_signal_new ("change_all",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (XedSpellCheckerDialogClass, change_all),
|
||||
NULL, NULL,
|
||||
xed_marshal_VOID__STRING_STRING,
|
||||
G_TYPE_NONE,
|
||||
2,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
|
||||
signals[ADD_WORD_TO_PERSONAL] =
|
||||
g_signal_new ("add_word_to_personal",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (XedSpellCheckerDialogClass, add_word_to_personal),
|
||||
NULL, NULL,
|
||||
xed_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_STRING);
|
||||
}
|
||||
|
||||
static void
|
||||
create_dialog (XedSpellCheckerDialog *dlg,
|
||||
const gchar *data_dir)
|
||||
{
|
||||
GtkWidget *error_widget;
|
||||
GtkWidget *content;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkCellRenderer *cell;
|
||||
GtkTreeSelection *selection;
|
||||
gchar *root_objects[] = {
|
||||
"content",
|
||||
"check_word_image",
|
||||
"add_word_image",
|
||||
"ignore_image",
|
||||
"change_image",
|
||||
"ignore_all_image",
|
||||
"change_all_image",
|
||||
NULL
|
||||
};
|
||||
gboolean ret;
|
||||
gchar *ui_file;
|
||||
|
||||
g_return_if_fail (dlg != NULL);
|
||||
|
||||
dlg->spell_checker = NULL;
|
||||
dlg->misspelled_word = NULL;
|
||||
|
||||
ui_file = g_build_filename (data_dir, "spell-checker.ui", NULL);
|
||||
ret = xed_utils_get_ui_objects (ui_file,
|
||||
root_objects,
|
||||
&error_widget,
|
||||
|
||||
"content", &content,
|
||||
"misspelled_word_label", &dlg->misspelled_word_label,
|
||||
"word_entry", &dlg->word_entry,
|
||||
"check_word_button", &dlg->check_word_button,
|
||||
"ignore_button", &dlg->ignore_button,
|
||||
"ignore_all_button", &dlg->ignore_all_button,
|
||||
"change_button", &dlg->change_button,
|
||||
"change_all_button", &dlg->change_all_button,
|
||||
"add_word_button", &dlg->add_word_button,
|
||||
"close_button", &dlg->close_button,
|
||||
"suggestions_list", &dlg->suggestions_list,
|
||||
"language_label", &dlg->language_label,
|
||||
NULL);
|
||||
g_free (ui_file);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
gtk_widget_show (error_widget);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
|
||||
error_widget, TRUE, TRUE, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (dlg->misspelled_word_label), "");
|
||||
gtk_widget_set_sensitive (dlg->word_entry, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->check_word_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->ignore_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->ignore_all_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->change_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->change_all_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->add_word_button, FALSE);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (dlg->language_label), "");
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (dlg), content);
|
||||
g_object_unref (content);
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);
|
||||
gtk_window_set_title (GTK_WINDOW (dlg), _("Check Spelling"));
|
||||
|
||||
/* Suggestion list */
|
||||
dlg->suggestions_list_model = GTK_TREE_MODEL (
|
||||
gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING));
|
||||
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->suggestions_list),
|
||||
dlg->suggestions_list_model);
|
||||
|
||||
/* Add the suggestions column */
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes (_("Suggestions"), cell,
|
||||
"text", COLUMN_SUGGESTIONS, NULL);
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->suggestions_list), column);
|
||||
|
||||
gtk_tree_view_set_search_column (GTK_TREE_VIEW (dlg->suggestions_list),
|
||||
COLUMN_SUGGESTIONS);
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->suggestions_list));
|
||||
|
||||
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
|
||||
|
||||
/* Set default button */
|
||||
gtk_widget_set_can_default (dlg->change_button, TRUE);
|
||||
gtk_widget_grab_default (dlg->change_button);
|
||||
|
||||
gtk_entry_set_activates_default (GTK_ENTRY (dlg->word_entry), TRUE);
|
||||
|
||||
/* Connect signals */
|
||||
g_signal_connect (dlg->word_entry, "changed",
|
||||
G_CALLBACK (word_entry_changed_handler), dlg);
|
||||
g_signal_connect (dlg->close_button, "clicked",
|
||||
G_CALLBACK (close_button_clicked_handler), dlg);
|
||||
g_signal_connect (selection, "changed",
|
||||
G_CALLBACK (suggestions_list_selection_changed_handler),
|
||||
dlg);
|
||||
g_signal_connect (dlg->check_word_button, "clicked",
|
||||
G_CALLBACK (check_word_button_clicked_handler), dlg);
|
||||
g_signal_connect (dlg->add_word_button, "clicked",
|
||||
G_CALLBACK (add_word_button_clicked_handler), dlg);
|
||||
g_signal_connect (dlg->ignore_button, "clicked",
|
||||
G_CALLBACK (ignore_button_clicked_handler), dlg);
|
||||
g_signal_connect (dlg->ignore_all_button, "clicked",
|
||||
G_CALLBACK (ignore_all_button_clicked_handler), dlg);
|
||||
g_signal_connect (dlg->change_button, "clicked",
|
||||
G_CALLBACK (change_button_clicked_handler), dlg);
|
||||
g_signal_connect (dlg->change_all_button, "clicked",
|
||||
G_CALLBACK (change_all_button_clicked_handler), dlg);
|
||||
g_signal_connect (dlg->suggestions_list, "row-activated",
|
||||
G_CALLBACK (suggestions_list_row_activated_handler), dlg);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_spell_checker_dialog_init (XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
xed_spell_checker_dialog_new (const gchar *data_dir)
|
||||
{
|
||||
XedSpellCheckerDialog *dlg;
|
||||
|
||||
dlg = XED_SPELL_CHECKER_DIALOG (
|
||||
g_object_new (XED_TYPE_SPELL_CHECKER_DIALOG, NULL));
|
||||
|
||||
g_return_val_if_fail (dlg != NULL, NULL);
|
||||
|
||||
create_dialog (dlg, data_dir);
|
||||
|
||||
return GTK_WIDGET (dlg);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
xed_spell_checker_dialog_new_from_spell_checker (XedSpellChecker *spell,
|
||||
const gchar *data_dir)
|
||||
{
|
||||
XedSpellCheckerDialog *dlg;
|
||||
|
||||
g_return_val_if_fail (spell != NULL, NULL);
|
||||
|
||||
dlg = XED_SPELL_CHECKER_DIALOG (
|
||||
g_object_new (XED_TYPE_SPELL_CHECKER_DIALOG, NULL));
|
||||
|
||||
g_return_val_if_fail (dlg != NULL, NULL);
|
||||
|
||||
create_dialog (dlg, data_dir);
|
||||
|
||||
xed_spell_checker_dialog_set_spell_checker (dlg, spell);
|
||||
|
||||
return GTK_WIDGET (dlg);
|
||||
}
|
||||
|
||||
void
|
||||
xed_spell_checker_dialog_set_spell_checker (XedSpellCheckerDialog *dlg, XedSpellChecker *spell)
|
||||
{
|
||||
const XedSpellCheckerLanguage* language;
|
||||
const gchar *lang;
|
||||
gchar *tmp;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
g_return_if_fail (spell != NULL);
|
||||
|
||||
if (dlg->spell_checker != NULL)
|
||||
g_object_unref (dlg->spell_checker);
|
||||
|
||||
dlg->spell_checker = spell;
|
||||
g_object_ref (dlg->spell_checker);
|
||||
|
||||
language = xed_spell_checker_get_language (dlg->spell_checker);
|
||||
|
||||
lang = xed_spell_checker_language_to_string (language);
|
||||
tmp = g_strdup_printf("<b>%s</b>", lang);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (dlg->language_label), tmp);
|
||||
g_free (tmp);
|
||||
|
||||
if (dlg->misspelled_word != NULL)
|
||||
xed_spell_checker_dialog_set_misspelled_word (dlg, dlg->misspelled_word, -1);
|
||||
else
|
||||
gtk_list_store_clear (GTK_LIST_STORE (dlg->suggestions_list_model));
|
||||
|
||||
/* TODO: reset all widgets */
|
||||
}
|
||||
|
||||
void
|
||||
xed_spell_checker_dialog_set_misspelled_word (XedSpellCheckerDialog *dlg,
|
||||
const gchar *word,
|
||||
gint len)
|
||||
{
|
||||
gchar *tmp;
|
||||
GSList *sug;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
g_return_if_fail (word != NULL);
|
||||
|
||||
g_return_if_fail (dlg->spell_checker != NULL);
|
||||
g_return_if_fail (!xed_spell_checker_check_word (dlg->spell_checker, word, -1));
|
||||
|
||||
/* build_suggestions_list */
|
||||
if (dlg->misspelled_word != NULL)
|
||||
g_free (dlg->misspelled_word);
|
||||
|
||||
dlg->misspelled_word = g_strdup (word);
|
||||
|
||||
tmp = g_strdup_printf("<b>%s</b>", word);
|
||||
gtk_label_set_label (GTK_LABEL (dlg->misspelled_word_label), tmp);
|
||||
g_free (tmp);
|
||||
|
||||
sug = xed_spell_checker_get_suggestions (dlg->spell_checker,
|
||||
dlg->misspelled_word,
|
||||
-1);
|
||||
|
||||
update_suggestions_list_model (dlg, sug);
|
||||
|
||||
/* free the suggestion list */
|
||||
g_slist_foreach (sug, (GFunc)g_free, NULL);
|
||||
g_slist_free (sug);
|
||||
|
||||
gtk_widget_set_sensitive (dlg->ignore_button, TRUE);
|
||||
gtk_widget_set_sensitive (dlg->ignore_all_button, TRUE);
|
||||
gtk_widget_set_sensitive (dlg->add_word_button, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
update_suggestions_list_model (XedSpellCheckerDialog *dlg, GSList *suggestions)
|
||||
{
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeSelection *sel;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
g_return_if_fail (GTK_IS_LIST_STORE (dlg->suggestions_list_model));
|
||||
|
||||
store = GTK_LIST_STORE (dlg->suggestions_list_model);
|
||||
gtk_list_store_clear (store);
|
||||
|
||||
gtk_widget_set_sensitive (dlg->word_entry, TRUE);
|
||||
|
||||
if (suggestions == NULL)
|
||||
{
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
/* Translators: Displayed in the "Check Spelling" dialog if there are no suggestions
|
||||
* for the current misspelled word */
|
||||
COLUMN_SUGGESTIONS, _("(no suggested words)"),
|
||||
-1);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (dlg->word_entry), "");
|
||||
|
||||
gtk_widget_set_sensitive (dlg->suggestions_list, FALSE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive (dlg->suggestions_list, TRUE);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (dlg->word_entry), (gchar*)suggestions->data);
|
||||
|
||||
while (suggestions != NULL)
|
||||
{
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
COLUMN_SUGGESTIONS, (gchar*)suggestions->data,
|
||||
-1);
|
||||
|
||||
suggestions = g_slist_next (suggestions);
|
||||
}
|
||||
|
||||
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->suggestions_list));
|
||||
gtk_tree_model_get_iter_first (dlg->suggestions_list_model, &iter);
|
||||
gtk_tree_selection_select_iter (sel, &iter);
|
||||
}
|
||||
|
||||
static void
|
||||
word_entry_changed_handler (GtkEditable *editable, XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
const gchar *text;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
|
||||
text = gtk_entry_get_text (GTK_ENTRY (dlg->word_entry));
|
||||
|
||||
if (g_utf8_strlen (text, -1) > 0)
|
||||
{
|
||||
gtk_widget_set_sensitive (dlg->check_word_button, TRUE);
|
||||
gtk_widget_set_sensitive (dlg->change_button, TRUE);
|
||||
gtk_widget_set_sensitive (dlg->change_all_button, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive (dlg->check_word_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->change_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->change_all_button, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
close_button_clicked_handler (GtkButton *button, XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (dlg));
|
||||
}
|
||||
|
||||
static void
|
||||
suggestions_list_selection_changed_handler (GtkTreeSelection *selection,
|
||||
XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GValue value = {0, };
|
||||
const gchar *text;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
|
||||
if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
|
||||
return;
|
||||
|
||||
gtk_tree_model_get_value (dlg->suggestions_list_model, &iter,
|
||||
COLUMN_SUGGESTIONS,
|
||||
&value);
|
||||
|
||||
text = g_value_get_string (&value);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (dlg->word_entry), text);
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
static void
|
||||
check_word_button_clicked_handler (GtkButton *button, XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
const gchar *word;
|
||||
gssize len;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
|
||||
word = gtk_entry_get_text (GTK_ENTRY (dlg->word_entry));
|
||||
len = strlen (word);
|
||||
g_return_if_fail (len > 0);
|
||||
|
||||
if (xed_spell_checker_check_word (dlg->spell_checker, word, len))
|
||||
{
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
|
||||
store = GTK_LIST_STORE (dlg->suggestions_list_model);
|
||||
gtk_list_store_clear (store);
|
||||
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
/* Translators: Displayed in the "Check Spelling" dialog if the current word isn't misspelled */
|
||||
COLUMN_SUGGESTIONS, _("(correct spelling)"),
|
||||
-1);
|
||||
|
||||
gtk_widget_set_sensitive (dlg->suggestions_list, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSList *sug;
|
||||
|
||||
sug = xed_spell_checker_get_suggestions (dlg->spell_checker,
|
||||
word,
|
||||
len);
|
||||
|
||||
update_suggestions_list_model (dlg, sug);
|
||||
|
||||
/* free the suggestion list */
|
||||
g_slist_foreach (sug, (GFunc)g_free, NULL);
|
||||
g_slist_free (sug);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_word_button_clicked_handler (GtkButton *button, XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
gchar *word;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
g_return_if_fail (dlg->misspelled_word != NULL);
|
||||
|
||||
xed_spell_checker_add_word_to_personal (dlg->spell_checker,
|
||||
dlg->misspelled_word,
|
||||
-1);
|
||||
|
||||
word = g_strdup (dlg->misspelled_word);
|
||||
|
||||
g_signal_emit (G_OBJECT (dlg), signals [ADD_WORD_TO_PERSONAL], 0, word);
|
||||
|
||||
g_free (word);
|
||||
}
|
||||
|
||||
static void
|
||||
ignore_button_clicked_handler (GtkButton *button, XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
gchar *word;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
g_return_if_fail (dlg->misspelled_word != NULL);
|
||||
|
||||
word = g_strdup (dlg->misspelled_word);
|
||||
|
||||
g_signal_emit (G_OBJECT (dlg), signals [IGNORE], 0, word);
|
||||
|
||||
g_free (word);
|
||||
}
|
||||
|
||||
static void
|
||||
ignore_all_button_clicked_handler (GtkButton *button, XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
gchar *word;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
g_return_if_fail (dlg->misspelled_word != NULL);
|
||||
|
||||
xed_spell_checker_add_word_to_session (dlg->spell_checker,
|
||||
dlg->misspelled_word,
|
||||
-1);
|
||||
|
||||
word = g_strdup (dlg->misspelled_word);
|
||||
|
||||
g_signal_emit (G_OBJECT (dlg), signals [IGNORE_ALL], 0, word);
|
||||
|
||||
g_free (word);
|
||||
}
|
||||
|
||||
static void
|
||||
change_button_clicked_handler (GtkButton *button, XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
const gchar *entry_text;
|
||||
gchar *change;
|
||||
gchar *word;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
g_return_if_fail (dlg->misspelled_word != NULL);
|
||||
|
||||
entry_text = gtk_entry_get_text (GTK_ENTRY (dlg->word_entry));
|
||||
g_return_if_fail (entry_text != NULL);
|
||||
g_return_if_fail (*entry_text != '\0');
|
||||
change = g_strdup (entry_text);
|
||||
|
||||
xed_spell_checker_set_correction (dlg->spell_checker,
|
||||
dlg->misspelled_word, -1,
|
||||
change, -1);
|
||||
|
||||
word = g_strdup (dlg->misspelled_word);
|
||||
|
||||
g_signal_emit (G_OBJECT (dlg), signals [CHANGE], 0, word, change);
|
||||
|
||||
g_free (word);
|
||||
g_free (change);
|
||||
}
|
||||
|
||||
/* double click on one of the suggestions is like clicking on "change" */
|
||||
static void
|
||||
suggestions_list_row_activated_handler (GtkTreeView *view,
|
||||
GtkTreePath *path,
|
||||
GtkTreeViewColumn *column,
|
||||
XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
|
||||
change_button_clicked_handler (GTK_BUTTON (dlg->change_button), dlg);
|
||||
}
|
||||
|
||||
static void
|
||||
change_all_button_clicked_handler (GtkButton *button, XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
const gchar *entry_text;
|
||||
gchar *change;
|
||||
gchar *word;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
g_return_if_fail (dlg->misspelled_word != NULL);
|
||||
|
||||
entry_text = gtk_entry_get_text (GTK_ENTRY (dlg->word_entry));
|
||||
g_return_if_fail (entry_text != NULL);
|
||||
g_return_if_fail (*entry_text != '\0');
|
||||
change = g_strdup (entry_text);
|
||||
|
||||
xed_spell_checker_set_correction (dlg->spell_checker,
|
||||
dlg->misspelled_word, -1,
|
||||
change, -1);
|
||||
|
||||
word = g_strdup (dlg->misspelled_word);
|
||||
|
||||
g_signal_emit (G_OBJECT (dlg), signals [CHANGE_ALL], 0, word, change);
|
||||
|
||||
g_free (word);
|
||||
g_free (change);
|
||||
}
|
||||
|
||||
void
|
||||
xed_spell_checker_dialog_set_completed (XedSpellCheckerDialog *dlg)
|
||||
{
|
||||
gchar *tmp;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER_DIALOG (dlg));
|
||||
|
||||
tmp = g_strdup_printf("<b>%s</b>", _("Completed spell checking"));
|
||||
gtk_label_set_label (GTK_LABEL (dlg->misspelled_word_label),
|
||||
tmp);
|
||||
g_free (tmp);
|
||||
|
||||
gtk_list_store_clear (GTK_LIST_STORE (dlg->suggestions_list_model));
|
||||
gtk_entry_set_text (GTK_ENTRY (dlg->word_entry), "");
|
||||
|
||||
gtk_widget_set_sensitive (dlg->word_entry, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->check_word_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->ignore_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->ignore_all_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->change_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->change_all_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->add_word_button, FALSE);
|
||||
gtk_widget_set_sensitive (dlg->suggestions_list, FALSE);
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* xed-spell-checker-dialog.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2002 Paolo Maggi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the xed Team, 2002. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
#ifndef __XED_SPELL_CHECKER_DIALOG_H__
|
||||
#define __XED_SPELL_CHECKER_DIALOG_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "xed-spell-checker.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define XED_TYPE_SPELL_CHECKER_DIALOG (xed_spell_checker_dialog_get_type ())
|
||||
#define XED_SPELL_CHECKER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_SPELL_CHECKER_DIALOG, XedSpellCheckerDialog))
|
||||
#define XED_SPELL_CHECKER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_SPELL_CHECKER_DIALOG, XedSpellCheckerDialog))
|
||||
#define XED_IS_SPELL_CHECKER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_SPELL_CHECKER_DIALOG))
|
||||
#define XED_IS_SPELL_CHECKER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_SPELL_CHECKER_DIALOG))
|
||||
#define XED_SPELL_CHECKER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_SPELL_CHECKER_DIALOG, XedSpellCheckerDialog))
|
||||
|
||||
|
||||
typedef struct _XedSpellCheckerDialog XedSpellCheckerDialog;
|
||||
|
||||
typedef struct _XedSpellCheckerDialogClass XedSpellCheckerDialogClass;
|
||||
|
||||
struct _XedSpellCheckerDialogClass
|
||||
{
|
||||
GtkWindowClass parent_class;
|
||||
|
||||
/* Signals */
|
||||
void (*ignore) (XedSpellCheckerDialog *dlg,
|
||||
const gchar *word);
|
||||
void (*ignore_all) (XedSpellCheckerDialog *dlg,
|
||||
const gchar *word);
|
||||
void (*change) (XedSpellCheckerDialog *dlg,
|
||||
const gchar *word,
|
||||
const gchar *change_to);
|
||||
void (*change_all) (XedSpellCheckerDialog *dlg,
|
||||
const gchar *word,
|
||||
const gchar *change_to);
|
||||
void (*add_word_to_personal) (XedSpellCheckerDialog *dlg,
|
||||
const gchar *word);
|
||||
|
||||
};
|
||||
|
||||
GType xed_spell_checker_dialog_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* Constructors */
|
||||
GtkWidget *xed_spell_checker_dialog_new (const gchar *data_dir);
|
||||
GtkWidget *xed_spell_checker_dialog_new_from_spell_checker
|
||||
(XedSpellChecker *spell,
|
||||
const gchar *data_dir);
|
||||
|
||||
void xed_spell_checker_dialog_set_spell_checker
|
||||
(XedSpellCheckerDialog *dlg,
|
||||
XedSpellChecker *spell);
|
||||
void xed_spell_checker_dialog_set_misspelled_word
|
||||
(XedSpellCheckerDialog *dlg,
|
||||
const gchar* word,
|
||||
gint len);
|
||||
|
||||
void xed_spell_checker_dialog_set_completed
|
||||
(XedSpellCheckerDialog *dlg);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_SPELL_CHECKER_DIALOG_H__ */
|
||||
|
|
@ -1,439 +0,0 @@
|
|||
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* xed-spell-checker-language.c
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2006 Paolo Maggi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the xed Team, 2006. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
/* Part of the code taked from Epiphany.
|
||||
*
|
||||
* Copyright (C) 2003, 2004 Christian Persch
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <enchant.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <libxml/xmlreader.h>
|
||||
|
||||
#include "xed-spell-checker-language.h"
|
||||
|
||||
#include <xed/xed-debug.h>
|
||||
|
||||
#define ISO_639_DOMAIN "iso_639"
|
||||
#define ISO_3166_DOMAIN "iso_3166"
|
||||
|
||||
#define ISOCODESLOCALEDIR ISO_CODES_PREFIX "/share/locale"
|
||||
|
||||
struct _XedSpellCheckerLanguage
|
||||
{
|
||||
gchar *abrev;
|
||||
gchar *name;
|
||||
};
|
||||
|
||||
static gboolean available_languages_initialized = FALSE;
|
||||
static GSList *available_languages = NULL;
|
||||
|
||||
static GHashTable *iso_639_table = NULL;
|
||||
static GHashTable *iso_3166_table = NULL;
|
||||
|
||||
static void
|
||||
bind_iso_domains (void)
|
||||
{
|
||||
static gboolean bound = FALSE;
|
||||
|
||||
if (bound == FALSE)
|
||||
{
|
||||
bindtextdomain (ISO_639_DOMAIN, ISOCODESLOCALEDIR);
|
||||
bind_textdomain_codeset (ISO_639_DOMAIN, "UTF-8");
|
||||
|
||||
bindtextdomain(ISO_3166_DOMAIN, ISOCODESLOCALEDIR);
|
||||
bind_textdomain_codeset (ISO_3166_DOMAIN, "UTF-8");
|
||||
|
||||
bound = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
read_iso_639_entry (xmlTextReaderPtr reader,
|
||||
GHashTable *table)
|
||||
{
|
||||
xmlChar *code, *name;
|
||||
|
||||
code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "iso_639_1_code");
|
||||
name = xmlTextReaderGetAttribute (reader, (const xmlChar *) "name");
|
||||
|
||||
/* Get iso-639-2 code */
|
||||
if (code == NULL || code[0] == '\0')
|
||||
{
|
||||
xmlFree (code);
|
||||
/* FIXME: use the 2T or 2B code? */
|
||||
code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "iso_639_2T_code");
|
||||
}
|
||||
|
||||
if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0')
|
||||
{
|
||||
g_hash_table_insert (table, code, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlFree (code);
|
||||
xmlFree (name);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
read_iso_3166_entry (xmlTextReaderPtr reader,
|
||||
GHashTable *table)
|
||||
{
|
||||
xmlChar *code, *name;
|
||||
|
||||
code = xmlTextReaderGetAttribute (reader, (const xmlChar *) "alpha_2_code");
|
||||
name = xmlTextReaderGetAttribute (reader, (const xmlChar *) "name");
|
||||
|
||||
if (code != NULL && code[0] != '\0' && name != NULL && name[0] != '\0')
|
||||
{
|
||||
char *lcode;
|
||||
|
||||
lcode = g_ascii_strdown ((char *) code, -1);
|
||||
xmlFree (code);
|
||||
|
||||
/* g_print ("%s -> %s\n", lcode, name); */
|
||||
|
||||
g_hash_table_insert (table, lcode, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlFree (code);
|
||||
xmlFree (name);
|
||||
}
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STATE_START,
|
||||
STATE_STOP,
|
||||
STATE_ENTRIES,
|
||||
} ParserState;
|
||||
|
||||
static void
|
||||
load_iso_entries (int iso,
|
||||
GFunc read_entry_func,
|
||||
gpointer user_data)
|
||||
{
|
||||
xmlTextReaderPtr reader;
|
||||
ParserState state = STATE_START;
|
||||
xmlChar iso_entries[32], iso_entry[32];
|
||||
char *filename;
|
||||
int ret = -1;
|
||||
|
||||
xed_debug_message (DEBUG_PLUGINS, "Loading ISO-%d codes", iso);
|
||||
|
||||
filename = g_strdup_printf (ISO_CODES_PREFIX "/share/xml/iso-codes/iso_%d.xml", iso);
|
||||
reader = xmlNewTextReaderFilename (filename);
|
||||
if (reader == NULL) goto out;
|
||||
|
||||
xmlStrPrintf (iso_entries, sizeof (iso_entries), (const xmlChar *)"iso_%d_entries", iso);
|
||||
xmlStrPrintf (iso_entry, sizeof (iso_entry), (const xmlChar *)"iso_%d_entry", iso);
|
||||
|
||||
ret = xmlTextReaderRead (reader);
|
||||
|
||||
while (ret == 1)
|
||||
{
|
||||
const xmlChar *tag;
|
||||
xmlReaderTypes type;
|
||||
|
||||
tag = xmlTextReaderConstName (reader);
|
||||
type = xmlTextReaderNodeType (reader);
|
||||
|
||||
if (state == STATE_ENTRIES &&
|
||||
type == XML_READER_TYPE_ELEMENT &&
|
||||
xmlStrEqual (tag, iso_entry))
|
||||
{
|
||||
read_entry_func (reader, user_data);
|
||||
}
|
||||
else if (state == STATE_START &&
|
||||
type == XML_READER_TYPE_ELEMENT &&
|
||||
xmlStrEqual (tag, iso_entries))
|
||||
{
|
||||
state = STATE_ENTRIES;
|
||||
}
|
||||
else if (state == STATE_ENTRIES &&
|
||||
type == XML_READER_TYPE_END_ELEMENT &&
|
||||
xmlStrEqual (tag, iso_entries))
|
||||
{
|
||||
state = STATE_STOP;
|
||||
}
|
||||
else if (type == XML_READER_TYPE_SIGNIFICANT_WHITESPACE ||
|
||||
type == XML_READER_TYPE_WHITESPACE ||
|
||||
type == XML_READER_TYPE_TEXT ||
|
||||
type == XML_READER_TYPE_COMMENT)
|
||||
{
|
||||
/* eat it */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ignore it */
|
||||
}
|
||||
|
||||
ret = xmlTextReaderRead (reader);
|
||||
}
|
||||
|
||||
xmlFreeTextReader (reader);
|
||||
|
||||
out:
|
||||
if (ret < 0 || state != STATE_STOP)
|
||||
{
|
||||
g_warning ("Failed to load ISO-%d codes from %s!\n",
|
||||
iso, filename);
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
static GHashTable *
|
||||
create_iso_639_table (void)
|
||||
{
|
||||
GHashTable *table;
|
||||
|
||||
bind_iso_domains ();
|
||||
table = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify) xmlFree,
|
||||
(GDestroyNotify) xmlFree);
|
||||
|
||||
load_iso_entries (639, (GFunc) read_iso_639_entry, table);
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
static GHashTable *
|
||||
create_iso_3166_table (void)
|
||||
{
|
||||
GHashTable *table;
|
||||
|
||||
bind_iso_domains ();
|
||||
table = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify) g_free,
|
||||
(GDestroyNotify) xmlFree);
|
||||
|
||||
load_iso_entries (3166, (GFunc) read_iso_3166_entry, table);
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
static char *
|
||||
create_name_for_language (const char *code)
|
||||
{
|
||||
char **str;
|
||||
char *name = NULL;
|
||||
const char *langname, *localename;
|
||||
int len;
|
||||
|
||||
g_return_val_if_fail (iso_639_table != NULL, NULL);
|
||||
g_return_val_if_fail (iso_3166_table != NULL, NULL);
|
||||
|
||||
str = g_strsplit (code, "_", -1);
|
||||
len = g_strv_length (str);
|
||||
g_return_val_if_fail (len != 0, NULL);
|
||||
|
||||
langname = (const char *) g_hash_table_lookup (iso_639_table, str[0]);
|
||||
|
||||
if (len == 1 && langname != NULL)
|
||||
{
|
||||
name = g_strdup (dgettext (ISO_639_DOMAIN, langname));
|
||||
}
|
||||
else if (len == 2 && langname != NULL)
|
||||
{
|
||||
gchar *locale_code = g_ascii_strdown (str[1], -1);
|
||||
|
||||
localename = (const char *) g_hash_table_lookup (iso_3166_table, locale_code);
|
||||
g_free (locale_code);
|
||||
|
||||
if (localename != NULL)
|
||||
{
|
||||
/* Translators: the first %s is the language name, and
|
||||
* the second %s is the locale name. Example:
|
||||
* "French (France)"
|
||||
*/
|
||||
name = g_strdup_printf (C_("language", "%s (%s)"),
|
||||
dgettext (ISO_639_DOMAIN, langname),
|
||||
dgettext (ISO_3166_DOMAIN, localename));
|
||||
}
|
||||
else
|
||||
{
|
||||
name = g_strdup_printf (C_("language", "%s (%s)"),
|
||||
dgettext (ISO_639_DOMAIN, langname), str[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Translators: this refers to an unknown language code
|
||||
* (one which isn't in our built-in list).
|
||||
*/
|
||||
name = g_strdup_printf (C_("language", "Unknown (%s)"), code);
|
||||
}
|
||||
|
||||
g_strfreev (str);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
static void
|
||||
enumerate_dicts (const char * const lang_tag,
|
||||
const char * const provider_name,
|
||||
const char * const provider_desc,
|
||||
const char * const provider_file,
|
||||
void * user_data)
|
||||
{
|
||||
gchar *lang_name;
|
||||
|
||||
GTree *dicts = (GTree *)user_data;
|
||||
|
||||
lang_name = create_name_for_language (lang_tag);
|
||||
g_return_if_fail (lang_name != NULL);
|
||||
|
||||
/* g_print ("%s - %s\n", lang_tag, lang_name); */
|
||||
|
||||
g_tree_replace (dicts, g_strdup (lang_tag), lang_name);
|
||||
}
|
||||
|
||||
static gint
|
||||
key_cmp (gconstpointer a, gconstpointer b, gpointer user_data)
|
||||
{
|
||||
return strcmp (a, b);
|
||||
}
|
||||
|
||||
static gint
|
||||
lang_cmp (const XedSpellCheckerLanguage *a,
|
||||
const XedSpellCheckerLanguage *b)
|
||||
{
|
||||
return g_utf8_collate (a->name, b->name);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
build_langs_list (const gchar *key,
|
||||
const gchar *value,
|
||||
gpointer data)
|
||||
{
|
||||
XedSpellCheckerLanguage *lang = g_new (XedSpellCheckerLanguage, 1);
|
||||
|
||||
lang->abrev = g_strdup (key);
|
||||
lang->name = g_strdup (value);
|
||||
|
||||
available_languages = g_slist_insert_sorted (available_languages,
|
||||
lang,
|
||||
(GCompareFunc)lang_cmp);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const GSList *
|
||||
xed_spell_checker_get_available_languages (void)
|
||||
{
|
||||
EnchantBroker *broker;
|
||||
GTree *dicts;
|
||||
|
||||
if (available_languages_initialized)
|
||||
return available_languages;
|
||||
|
||||
g_return_val_if_fail (available_languages == NULL, NULL);
|
||||
|
||||
available_languages_initialized = TRUE;
|
||||
|
||||
broker = enchant_broker_init ();
|
||||
g_return_val_if_fail (broker != NULL, NULL);
|
||||
|
||||
/* Use a GTree to efficiently remove duplicates while building the list */
|
||||
dicts = g_tree_new_full (key_cmp,
|
||||
NULL,
|
||||
(GDestroyNotify)g_free,
|
||||
(GDestroyNotify)g_free);
|
||||
|
||||
iso_639_table = create_iso_639_table ();
|
||||
iso_3166_table = create_iso_3166_table ();
|
||||
|
||||
enchant_broker_list_dicts (broker, enumerate_dicts, dicts);
|
||||
|
||||
enchant_broker_free (broker);
|
||||
|
||||
g_hash_table_destroy (iso_639_table);
|
||||
g_hash_table_destroy (iso_3166_table);
|
||||
|
||||
iso_639_table = NULL;
|
||||
iso_3166_table = NULL;
|
||||
|
||||
g_tree_foreach (dicts, (GTraverseFunc)build_langs_list, NULL);
|
||||
|
||||
g_tree_destroy (dicts);
|
||||
|
||||
return available_languages;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
xed_spell_checker_language_to_string (const XedSpellCheckerLanguage *lang)
|
||||
{
|
||||
if (lang == NULL)
|
||||
/* Translators: this refers the Default language used by the
|
||||
* spell checker
|
||||
*/
|
||||
return C_("language", "Default");
|
||||
|
||||
return lang->name;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
xed_spell_checker_language_to_key (const XedSpellCheckerLanguage *lang)
|
||||
{
|
||||
g_return_val_if_fail (lang != NULL, NULL);
|
||||
|
||||
return lang->abrev;
|
||||
}
|
||||
|
||||
const XedSpellCheckerLanguage *
|
||||
xed_spell_checker_language_from_key (const gchar *key)
|
||||
{
|
||||
const GSList *langs;
|
||||
|
||||
g_return_val_if_fail (key != NULL, NULL);
|
||||
|
||||
langs = xed_spell_checker_get_available_languages ();
|
||||
|
||||
while (langs != NULL)
|
||||
{
|
||||
const XedSpellCheckerLanguage *l = (const XedSpellCheckerLanguage *)langs->data;
|
||||
|
||||
if (g_ascii_strcasecmp (key, l->abrev) == 0)
|
||||
return l;
|
||||
|
||||
langs = g_slist_next (langs);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* xed-spell-checker-language.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2006 Paolo Maggi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the xed Team, 2006. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
#ifndef __XED_SPELL_CHECKER_LANGUAGE_H__
|
||||
#define __XED_SPELL_CHECKER_LANGUAGE_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _XedSpellCheckerLanguage XedSpellCheckerLanguage;
|
||||
|
||||
const gchar *xed_spell_checker_language_to_string (const XedSpellCheckerLanguage *lang);
|
||||
|
||||
const gchar *xed_spell_checker_language_to_key (const XedSpellCheckerLanguage *lang);
|
||||
|
||||
const XedSpellCheckerLanguage *xed_spell_checker_language_from_key (const gchar *key);
|
||||
|
||||
/* GSList contains "XedSpellCheckerLanguage*" items */
|
||||
const GSList *xed_spell_checker_get_available_languages
|
||||
(void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_SPELL_CHECKER_LANGUAGE_H__ */
|
|
@ -1,520 +0,0 @@
|
|||
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* xed-spell-checker.c
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2002-2006 Paolo Maggi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the xed Team, 2002-2006. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <enchant.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "xed-spell-checker.h"
|
||||
#include "xed-spell-utils.h"
|
||||
#include "xed-spell-marshal.h"
|
||||
|
||||
struct _XedSpellChecker
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
EnchantDict *dict;
|
||||
EnchantBroker *broker;
|
||||
const XedSpellCheckerLanguage *active_lang;
|
||||
};
|
||||
|
||||
/* GObject properties */
|
||||
enum {
|
||||
PROP_0 = 0,
|
||||
PROP_LANGUAGE,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
/* Signals */
|
||||
enum {
|
||||
ADD_WORD_TO_PERSONAL = 0,
|
||||
ADD_WORD_TO_SESSION,
|
||||
SET_LANGUAGE,
|
||||
CLEAR_SESSION,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE(XedSpellChecker, xed_spell_checker, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
xed_spell_checker_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
/*
|
||||
XedSpellChecker *spell = XED_SPELL_CHECKER (object);
|
||||
*/
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_LANGUAGE:
|
||||
/* TODO */
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xed_spell_checker_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
/*
|
||||
XedSpellChecker *spell = XED_SPELL_CHECKER (object);
|
||||
*/
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_LANGUAGE:
|
||||
/* TODO */
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xed_spell_checker_finalize (GObject *object)
|
||||
{
|
||||
XedSpellChecker *spell_checker;
|
||||
|
||||
g_return_if_fail (XED_IS_SPELL_CHECKER (object));
|
||||
|
||||
spell_checker = XED_SPELL_CHECKER (object);
|
||||
|
||||
if (spell_checker->dict != NULL)
|
||||
enchant_broker_free_dict (spell_checker->broker, spell_checker->dict);
|
||||
|
||||
if (spell_checker->broker != NULL)
|
||||
enchant_broker_free (spell_checker->broker);
|
||||
|
||||
G_OBJECT_CLASS (xed_spell_checker_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_spell_checker_class_init (XedSpellCheckerClass * klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = xed_spell_checker_set_property;
|
||||
object_class->get_property = xed_spell_checker_get_property;
|
||||
|
||||
object_class->finalize = xed_spell_checker_finalize;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_LANGUAGE,
|
||||
g_param_spec_pointer ("language",
|
||||
"Language",
|
||||
"The language used by the spell checker",
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
signals[ADD_WORD_TO_PERSONAL] =
|
||||
g_signal_new ("add_word_to_personal",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (XedSpellCheckerClass, add_word_to_personal),
|
||||
NULL, NULL,
|
||||
xed_marshal_VOID__STRING_INT,
|
||||
G_TYPE_NONE,
|
||||
2,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_INT);
|
||||
|
||||
signals[ADD_WORD_TO_SESSION] =
|
||||
g_signal_new ("add_word_to_session",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (XedSpellCheckerClass, add_word_to_session),
|
||||
NULL, NULL,
|
||||
xed_marshal_VOID__STRING_INT,
|
||||
G_TYPE_NONE,
|
||||
2,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_INT);
|
||||
|
||||
signals[SET_LANGUAGE] =
|
||||
g_signal_new ("set_language",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (XedSpellCheckerClass, set_language),
|
||||
NULL, NULL,
|
||||
xed_marshal_VOID__POINTER,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_POINTER);
|
||||
|
||||
signals[CLEAR_SESSION] =
|
||||
g_signal_new ("clear_session",
|
||||
G_OBJECT_CLASS_TYPE (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (XedSpellCheckerClass, clear_session),
|
||||
NULL, NULL,
|
||||
xed_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_spell_checker_init (XedSpellChecker *spell_checker)
|
||||
{
|
||||
spell_checker->broker = enchant_broker_init ();
|
||||
spell_checker->dict = NULL;
|
||||
spell_checker->active_lang = NULL;
|
||||
}
|
||||
|
||||
XedSpellChecker *
|
||||
xed_spell_checker_new (void)
|
||||
{
|
||||
XedSpellChecker *spell;
|
||||
|
||||
spell = XED_SPELL_CHECKER (
|
||||
g_object_new (XED_TYPE_SPELL_CHECKER, NULL));
|
||||
|
||||
g_return_val_if_fail (spell != NULL, NULL);
|
||||
|
||||
return spell;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
lazy_init (XedSpellChecker *spell,
|
||||
const XedSpellCheckerLanguage *language)
|
||||
{
|
||||
if (spell->dict != NULL)
|
||||
return TRUE;
|
||||
|
||||
g_return_val_if_fail (spell->broker != NULL, FALSE);
|
||||
|
||||
spell->active_lang = NULL;
|
||||
|
||||
if (language != NULL)
|
||||
{
|
||||
spell->active_lang = language;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* First try to get a default language */
|
||||
const XedSpellCheckerLanguage *l;
|
||||
gint i = 0;
|
||||
const gchar * const *lang_tags = g_get_language_names ();
|
||||
|
||||
while (lang_tags [i])
|
||||
{
|
||||
l = xed_spell_checker_language_from_key (lang_tags [i]);
|
||||
|
||||
if (l != NULL)
|
||||
{
|
||||
spell->active_lang = l;
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Second try to get a default language */
|
||||
if (spell->active_lang == NULL)
|
||||
spell->active_lang = xed_spell_checker_language_from_key ("en_US");
|
||||
|
||||
/* Last try to get a default language */
|
||||
if (spell->active_lang == NULL)
|
||||
{
|
||||
const GSList *langs;
|
||||
langs = xed_spell_checker_get_available_languages ();
|
||||
if (langs != NULL)
|
||||
spell->active_lang = (const XedSpellCheckerLanguage *)langs->data;
|
||||
}
|
||||
|
||||
if (spell->active_lang != NULL)
|
||||
{
|
||||
const gchar *key;
|
||||
|
||||
key = xed_spell_checker_language_to_key (spell->active_lang);
|
||||
|
||||
spell->dict = enchant_broker_request_dict (spell->broker,
|
||||
key);
|
||||
}
|
||||
|
||||
if (spell->dict == NULL)
|
||||
{
|
||||
spell->active_lang = NULL;
|
||||
|
||||
if (language != NULL)
|
||||
g_warning ("Spell checker plugin: cannot select a default language.");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xed_spell_checker_set_language (XedSpellChecker *spell,
|
||||
const XedSpellCheckerLanguage *language)
|
||||
{
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail (XED_IS_SPELL_CHECKER (spell), FALSE);
|
||||
|
||||
if (spell->dict != NULL)
|
||||
{
|
||||
enchant_broker_free_dict (spell->broker, spell->dict);
|
||||
spell->dict = NULL;
|
||||
}
|
||||
|
||||
ret = lazy_init (spell, language);
|
||||
|
||||
if (ret)
|
||||
g_signal_emit (G_OBJECT (spell), signals[SET_LANGUAGE], 0, language);
|
||||
else
|
||||
g_warning ("Spell checker plugin: cannot use language %s.",
|
||||
xed_spell_checker_language_to_string (language));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const XedSpellCheckerLanguage *
|
||||
xed_spell_checker_get_language (XedSpellChecker *spell)
|
||||
{
|
||||
g_return_val_if_fail (XED_IS_SPELL_CHECKER (spell), NULL);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
return NULL;
|
||||
|
||||
return spell->active_lang;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xed_spell_checker_check_word (XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gssize len)
|
||||
{
|
||||
gint enchant_result;
|
||||
gboolean res = FALSE;
|
||||
|
||||
g_return_val_if_fail (XED_IS_SPELL_CHECKER (spell), FALSE);
|
||||
g_return_val_if_fail (word != NULL, FALSE);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
return FALSE;
|
||||
|
||||
if (len < 0)
|
||||
len = strlen (word);
|
||||
|
||||
if (strcmp (word, "xed") == 0)
|
||||
return TRUE;
|
||||
|
||||
if (xed_spell_utils_is_digit (word, len))
|
||||
return TRUE;
|
||||
|
||||
g_return_val_if_fail (spell->dict != NULL, FALSE);
|
||||
enchant_result = enchant_dict_check (spell->dict, word, len);
|
||||
|
||||
switch (enchant_result)
|
||||
{
|
||||
case -1:
|
||||
/* error */
|
||||
res = FALSE;
|
||||
|
||||
g_warning ("Spell checker plugin: error checking word '%s' (%s).",
|
||||
word, enchant_dict_get_error (spell->dict));
|
||||
|
||||
break;
|
||||
case 1:
|
||||
/* it is not in the directory */
|
||||
res = FALSE;
|
||||
break;
|
||||
case 0:
|
||||
/* is is in the directory */
|
||||
res = TRUE;
|
||||
break;
|
||||
default:
|
||||
g_return_val_if_reached (FALSE);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/* return NULL on error or if no suggestions are found */
|
||||
GSList *
|
||||
xed_spell_checker_get_suggestions (XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gssize len)
|
||||
{
|
||||
gchar **suggestions;
|
||||
size_t n_suggestions = 0;
|
||||
GSList *suggestions_list = NULL;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (XED_IS_SPELL_CHECKER (spell), NULL);
|
||||
g_return_val_if_fail (word != NULL, NULL);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
return NULL;
|
||||
|
||||
g_return_val_if_fail (spell->dict != NULL, NULL);
|
||||
|
||||
if (len < 0)
|
||||
len = strlen (word);
|
||||
|
||||
suggestions = enchant_dict_suggest (spell->dict, word, len, &n_suggestions);
|
||||
|
||||
if (n_suggestions == 0)
|
||||
return NULL;
|
||||
|
||||
g_return_val_if_fail (suggestions != NULL, NULL);
|
||||
|
||||
for (i = 0; i < (gint)n_suggestions; i++)
|
||||
{
|
||||
suggestions_list = g_slist_prepend (suggestions_list,
|
||||
suggestions[i]);
|
||||
}
|
||||
|
||||
/* The single suggestions will be freed by the caller */
|
||||
g_free (suggestions);
|
||||
|
||||
suggestions_list = g_slist_reverse (suggestions_list);
|
||||
|
||||
return suggestions_list;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xed_spell_checker_add_word_to_personal (XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gssize len)
|
||||
{
|
||||
g_return_val_if_fail (XED_IS_SPELL_CHECKER (spell), FALSE);
|
||||
g_return_val_if_fail (word != NULL, FALSE);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
return FALSE;
|
||||
|
||||
g_return_val_if_fail (spell->dict != NULL, FALSE);
|
||||
|
||||
if (len < 0)
|
||||
len = strlen (word);
|
||||
|
||||
enchant_dict_add_to_pwl (spell->dict, word, len);
|
||||
|
||||
g_signal_emit (G_OBJECT (spell), signals[ADD_WORD_TO_PERSONAL], 0, word, len);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xed_spell_checker_add_word_to_session (XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gssize len)
|
||||
{
|
||||
g_return_val_if_fail (XED_IS_SPELL_CHECKER (spell), FALSE);
|
||||
g_return_val_if_fail (word != NULL, FALSE);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
return FALSE;
|
||||
|
||||
g_return_val_if_fail (spell->dict != NULL, FALSE);
|
||||
|
||||
if (len < 0)
|
||||
len = strlen (word);
|
||||
|
||||
enchant_dict_add_to_session (spell->dict, word, len);
|
||||
|
||||
g_signal_emit (G_OBJECT (spell), signals[ADD_WORD_TO_SESSION], 0, word, len);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xed_spell_checker_clear_session (XedSpellChecker *spell)
|
||||
{
|
||||
g_return_val_if_fail (XED_IS_SPELL_CHECKER (spell), FALSE);
|
||||
|
||||
/* free and re-request dictionary */
|
||||
if (spell->dict != NULL)
|
||||
{
|
||||
enchant_broker_free_dict (spell->broker, spell->dict);
|
||||
spell->dict = NULL;
|
||||
}
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
return FALSE;
|
||||
|
||||
g_signal_emit (G_OBJECT (spell), signals[CLEAR_SESSION], 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Informs dictionary, that word 'word' will be replaced/corrected by word
|
||||
* 'replacement'
|
||||
*/
|
||||
gboolean
|
||||
xed_spell_checker_set_correction (XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gssize w_len,
|
||||
const gchar *replacement,
|
||||
gssize r_len)
|
||||
{
|
||||
g_return_val_if_fail (XED_IS_SPELL_CHECKER (spell), FALSE);
|
||||
g_return_val_if_fail (word != NULL, FALSE);
|
||||
g_return_val_if_fail (replacement != NULL, FALSE);
|
||||
|
||||
if (!lazy_init (spell, spell->active_lang))
|
||||
return FALSE;
|
||||
|
||||
g_return_val_if_fail (spell->dict != NULL, FALSE);
|
||||
|
||||
if (w_len < 0)
|
||||
w_len = strlen (word);
|
||||
|
||||
if (r_len < 0)
|
||||
r_len = strlen (replacement);
|
||||
|
||||
enchant_dict_store_replacement (spell->dict,
|
||||
word,
|
||||
w_len,
|
||||
replacement,
|
||||
r_len);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* xed-spell-checker.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2002-2006 Paolo Maggi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the xed Team, 2002. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
#ifndef __XED_SPELL_CHECKER_H__
|
||||
#define __XED_SPELL_CHECKER_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "xed-spell-checker-language.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define XED_TYPE_SPELL_CHECKER (xed_spell_checker_get_type ())
|
||||
#define XED_SPELL_CHECKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_SPELL_CHECKER, XedSpellChecker))
|
||||
#define XED_SPELL_CHECKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XED_TYPE_SPELL_CHECKER, XedSpellChecker))
|
||||
#define XED_IS_SPELL_CHECKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_SPELL_CHECKER))
|
||||
#define XED_IS_SPELL_CHECKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_SPELL_CHECKER))
|
||||
#define XED_SPELL_CHECKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XED_TYPE_SPELL_CHECKER, XedSpellChecker))
|
||||
|
||||
typedef struct _XedSpellChecker XedSpellChecker;
|
||||
|
||||
typedef struct _XedSpellCheckerClass XedSpellCheckerClass;
|
||||
|
||||
struct _XedSpellCheckerClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
/* Signals */
|
||||
void (*add_word_to_personal) (XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gint len);
|
||||
|
||||
void (*add_word_to_session) (XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gint len);
|
||||
|
||||
void (*set_language) (XedSpellChecker *spell,
|
||||
const XedSpellCheckerLanguage *lang);
|
||||
|
||||
void (*clear_session) (XedSpellChecker *spell);
|
||||
};
|
||||
|
||||
|
||||
GType xed_spell_checker_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* Constructors */
|
||||
XedSpellChecker *xed_spell_checker_new (void);
|
||||
|
||||
gboolean xed_spell_checker_set_language (XedSpellChecker *spell,
|
||||
const XedSpellCheckerLanguage *lang);
|
||||
const XedSpellCheckerLanguage
|
||||
*xed_spell_checker_get_language (XedSpellChecker *spell);
|
||||
|
||||
gboolean xed_spell_checker_check_word (XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gssize len);
|
||||
|
||||
GSList *xed_spell_checker_get_suggestions (XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gssize len);
|
||||
|
||||
gboolean xed_spell_checker_add_word_to_personal
|
||||
(XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gssize len);
|
||||
|
||||
gboolean xed_spell_checker_add_word_to_session
|
||||
(XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gssize len);
|
||||
|
||||
gboolean xed_spell_checker_clear_session (XedSpellChecker *spell);
|
||||
|
||||
gboolean xed_spell_checker_set_correction (XedSpellChecker *spell,
|
||||
const gchar *word,
|
||||
gssize w_len,
|
||||
const gchar *replacement,
|
||||
gssize r_len);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_SPELL_CHECKER_H__ */
|
||||
|
|
@ -1,284 +0,0 @@
|
|||
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* xed-spell-language-dialog.c
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2002 Paolo Maggi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the xed Team, 2002. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <xed/xed-utils.h>
|
||||
#include <xed/xed-app.h>
|
||||
#include "xed-spell-language-dialog.h"
|
||||
#include "xed-spell-checker-language.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
COLUMN_LANGUAGE_NAME = 0,
|
||||
COLUMN_LANGUAGE_POINTER,
|
||||
ENCODING_NUM_COLS
|
||||
};
|
||||
|
||||
|
||||
struct _XedSpellLanguageDialog
|
||||
{
|
||||
GtkDialog dialog;
|
||||
|
||||
GtkWidget *languages_treeview;
|
||||
GtkTreeModel *model;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (XedSpellLanguageDialog, xed_spell_language_dialog, GTK_TYPE_DIALOG)
|
||||
|
||||
|
||||
static void
|
||||
xed_spell_language_dialog_class_init (XedSpellLanguageDialogClass *klass)
|
||||
{
|
||||
/* GObjectClass *object_class = G_OBJECT_CLASS (klass); */
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_response_handler (GtkDialog *dlg,
|
||||
gint res_id)
|
||||
{
|
||||
if (res_id == GTK_RESPONSE_HELP)
|
||||
{
|
||||
xed_app_show_help (XED_APP (g_application_get_default ()), GTK_WINDOW (dlg), NULL, "xed-spell-checker-plugin");
|
||||
|
||||
g_signal_stop_emission_by_name (dlg, "response");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
scroll_to_selected (GtkTreeView *tree_view)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeIter iter;
|
||||
|
||||
model = gtk_tree_view_get_model (tree_view);
|
||||
g_return_if_fail (model != NULL);
|
||||
|
||||
/* Scroll to selected */
|
||||
selection = gtk_tree_view_get_selection (tree_view);
|
||||
g_return_if_fail (selection != NULL);
|
||||
|
||||
if (gtk_tree_selection_get_selected (selection, NULL, &iter))
|
||||
{
|
||||
GtkTreePath* path;
|
||||
|
||||
path = gtk_tree_model_get_path (model, &iter);
|
||||
g_return_if_fail (path != NULL);
|
||||
|
||||
gtk_tree_view_scroll_to_cell (tree_view, path, NULL, TRUE, 1.0, 0.0);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
language_row_activated (GtkTreeView *tree_view,
|
||||
GtkTreePath *path,
|
||||
GtkTreeViewColumn *column,
|
||||
XedSpellLanguageDialog *dialog)
|
||||
{
|
||||
gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
create_dialog (XedSpellLanguageDialog *dlg,
|
||||
const gchar *data_dir)
|
||||
{
|
||||
GtkWidget *error_widget;
|
||||
GtkWidget *content;
|
||||
gboolean ret;
|
||||
GtkCellRenderer *cell;
|
||||
GtkTreeViewColumn *column;
|
||||
gchar *ui_file;
|
||||
gchar *root_objects[] = {
|
||||
"content",
|
||||
NULL
|
||||
};
|
||||
|
||||
gtk_dialog_add_buttons (GTK_DIALOG (dlg),
|
||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||
_("_OK"), GTK_RESPONSE_OK,
|
||||
_("_Help"), GTK_RESPONSE_HELP,
|
||||
NULL);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (dlg), _("Set language"));
|
||||
gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
|
||||
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
|
||||
|
||||
/* HIG defaults */
|
||||
gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
|
||||
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), 5);
|
||||
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), 6);
|
||||
|
||||
g_signal_connect (dlg, "response",
|
||||
G_CALLBACK (dialog_response_handler), NULL);
|
||||
|
||||
ui_file = g_build_filename (data_dir, "languages-dialog.ui", NULL);
|
||||
ret = xed_utils_get_ui_objects (ui_file,
|
||||
root_objects,
|
||||
&error_widget,
|
||||
"content", &content,
|
||||
"languages_treeview", &dlg->languages_treeview,
|
||||
NULL);
|
||||
g_free (ui_file);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
gtk_widget_show (error_widget);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), error_widget, TRUE, TRUE, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), content, TRUE, TRUE, 0);
|
||||
g_object_unref (content);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (content), 5);
|
||||
|
||||
dlg->model = GTK_TREE_MODEL (gtk_list_store_new (ENCODING_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER));
|
||||
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (dlg->languages_treeview), dlg->model);
|
||||
|
||||
g_object_unref (dlg->model);
|
||||
|
||||
/* Add the encoding column */
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes (_("Languages"),
|
||||
cell,
|
||||
"text",
|
||||
COLUMN_LANGUAGE_NAME,
|
||||
NULL);
|
||||
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (dlg->languages_treeview), column);
|
||||
|
||||
gtk_tree_view_set_search_column (GTK_TREE_VIEW (dlg->languages_treeview), COLUMN_LANGUAGE_NAME);
|
||||
|
||||
g_signal_connect (dlg->languages_treeview, "realize",
|
||||
G_CALLBACK (scroll_to_selected), dlg);
|
||||
g_signal_connect (dlg->languages_treeview, "row-activated",
|
||||
G_CALLBACK (language_row_activated), dlg);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_spell_language_dialog_init (XedSpellLanguageDialog *dlg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
populate_language_list (XedSpellLanguageDialog *dlg,
|
||||
const XedSpellCheckerLanguage *cur_lang)
|
||||
{
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
|
||||
const GSList* langs;
|
||||
|
||||
/* create list store */
|
||||
store = GTK_LIST_STORE (dlg->model);
|
||||
|
||||
langs = xed_spell_checker_get_available_languages ();
|
||||
|
||||
while (langs)
|
||||
{
|
||||
const gchar *name;
|
||||
|
||||
name = xed_spell_checker_language_to_string ((const XedSpellCheckerLanguage*)langs->data);
|
||||
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
COLUMN_LANGUAGE_NAME, name,
|
||||
COLUMN_LANGUAGE_POINTER, langs->data,
|
||||
-1);
|
||||
|
||||
if (langs->data == cur_lang)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->languages_treeview));
|
||||
g_return_if_fail (selection != NULL);
|
||||
|
||||
gtk_tree_selection_select_iter (selection, &iter);
|
||||
}
|
||||
|
||||
langs = g_slist_next (langs);
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
xed_spell_language_dialog_new (GtkWindow *parent,
|
||||
const XedSpellCheckerLanguage *cur_lang,
|
||||
const gchar *data_dir)
|
||||
{
|
||||
XedSpellLanguageDialog *dlg;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
|
||||
|
||||
dlg = g_object_new (XED_TYPE_SPELL_LANGUAGE_DIALOG, NULL);
|
||||
|
||||
create_dialog (dlg, data_dir);
|
||||
|
||||
populate_language_list (dlg, cur_lang);
|
||||
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
|
||||
gtk_widget_grab_focus (dlg->languages_treeview);
|
||||
|
||||
return GTK_WIDGET (dlg);
|
||||
}
|
||||
|
||||
const XedSpellCheckerLanguage *
|
||||
xed_spell_language_get_selected_language (XedSpellLanguageDialog *dlg)
|
||||
{
|
||||
GValue value = {0, };
|
||||
const XedSpellCheckerLanguage* lang;
|
||||
|
||||
GtkTreeIter iter;
|
||||
GtkTreeSelection *selection;
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->languages_treeview));
|
||||
g_return_val_if_fail (selection != NULL, NULL);
|
||||
|
||||
if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gtk_tree_model_get_value (dlg->model, &iter, COLUMN_LANGUAGE_POINTER, &value);
|
||||
|
||||
lang = (const XedSpellCheckerLanguage* ) g_value_get_pointer (&value);
|
||||
|
||||
return lang;
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* xed-spell-language-dialog.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2002 Paolo Maggi
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modified by the xed Team, 2002. See the AUTHORS file for a
|
||||
* list of people on the xed Team.
|
||||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
#ifndef __XED_SPELL_LANGUAGE_DIALOG_H__
|
||||
#define __XED_SPELL_LANGUAGE_DIALOG_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "xed-spell-checker-language.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define XED_TYPE_SPELL_LANGUAGE_DIALOG (xed_spell_language_dialog_get_type())
|
||||
#define XED_SPELL_LANGUAGE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XED_TYPE_SPELL_LANGUAGE_DIALOG, XedSpellLanguageDialog))
|
||||
#define XED_SPELL_LANGUAGE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), XED_TYPE_SPELL_LANGUAGE_DIALOG, XedSpellLanguageDialogClass))
|
||||
#define XED_IS_SPELL_LANGUAGE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), XED_TYPE_SPELL_LANGUAGE_DIALOG))
|
||||
#define XED_IS_SPELL_LANGUAGE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XED_TYPE_SPELL_LANGUAGE_DIALOG))
|
||||
#define XED_SPELL_LANGUAGE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), XED_TYPE_SPELL_LANGUAGE_DIALOG, XedSpellLanguageDialogClass))
|
||||
|
||||
|
||||
typedef struct _XedSpellLanguageDialog XedSpellLanguageDialog;
|
||||
typedef struct _XedSpellLanguageDialogClass XedSpellLanguageDialogClass;
|
||||
|
||||
struct _XedSpellLanguageDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
};
|
||||
|
||||
GType xed_spell_language_dialog_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget *xed_spell_language_dialog_new (GtkWindow *parent,
|
||||
const XedSpellCheckerLanguage *cur_lang,
|
||||
const gchar *data_dir);
|
||||
|
||||
const XedSpellCheckerLanguage *xed_spell_language_get_selected_language (XedSpellLanguageDialog *dlg);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_SPELL_LANGUAGE_DIALOG_H__ */
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* xed-spell-utils.c
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2010 - Jesse van den Kieboom
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "xed-spell-utils.h"
|
||||
#include <gtksourceview/gtksource.h>
|
||||
|
||||
gboolean
|
||||
xed_spell_utils_is_digit (const char *text, gssize length)
|
||||
{
|
||||
gunichar c;
|
||||
const gchar *p;
|
||||
const gchar *end;
|
||||
|
||||
g_return_val_if_fail (text != NULL, FALSE);
|
||||
|
||||
if (length < 0)
|
||||
length = strlen (text);
|
||||
|
||||
p = text;
|
||||
end = text + length;
|
||||
|
||||
while (p != end) {
|
||||
const gchar *next;
|
||||
next = g_utf8_next_char (p);
|
||||
|
||||
c = g_utf8_get_char (p);
|
||||
|
||||
if (!g_unichar_isdigit (c) && c != '.' && c != ',')
|
||||
return FALSE;
|
||||
|
||||
p = next;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
xed_spell_utils_skip_no_spell_check (GtkTextIter *start,
|
||||
GtkTextIter *end)
|
||||
{
|
||||
GtkSourceBuffer *buffer = GTK_SOURCE_BUFFER (gtk_text_iter_get_buffer (start));
|
||||
|
||||
while (gtk_source_buffer_iter_has_context_class (buffer, start, "no-spell-check"))
|
||||
{
|
||||
GtkTextIter last = *start;
|
||||
|
||||
if (!gtk_source_buffer_iter_forward_to_context_class_toggle (buffer, start, "no-spell-check"))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (gtk_text_iter_compare (start, &last) <= 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gtk_text_iter_forward_word_end (start);
|
||||
gtk_text_iter_backward_word_start (start);
|
||||
|
||||
if (gtk_text_iter_compare (start, &last) <= 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (gtk_text_iter_compare (start, end) >= 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* xed-spell-utils.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* Copyright (C) 2010 - Jesse van den Kieboom
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef __XED_SPELL_UTILS_H__
|
||||
#define __XED_SPELL_UTILS_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean xed_spell_utils_is_digit (const char *text, gssize length);
|
||||
|
||||
gboolean xed_spell_utils_skip_no_spell_check (GtkTextIter *start, GtkTextIter *end);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_SPELL_UTILS_H__ */
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
# Tag list plugin
|
||||
plugindir = $(XED_PLUGINS_LIBS_DIR)
|
||||
|
||||
taglistdir = $(XED_PLUGINS_DATA_DIR)/taglist
|
||||
|
||||
taglist_in_files = \
|
||||
HTML.tags.xml.in \
|
||||
Latex.tags.xml.in \
|
||||
XSLT.tags.xml.in \
|
||||
XUL.tags.xml.in
|
||||
|
||||
taglist_DATA = $(taglist_in_files:.tags.xml.in=.tags.gz)
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(XED_CFLAGS) \
|
||||
$(WARN_CFLAGS) \
|
||||
$(DISABLE_DEPRECATED_CFLAGS)
|
||||
|
||||
plugin_LTLIBRARIES = libtaglist.la
|
||||
|
||||
libtaglist_la_SOURCES = \
|
||||
xed-taglist-plugin-parser.c \
|
||||
xed-taglist-plugin-parser.h \
|
||||
xed-taglist-plugin-panel.c \
|
||||
xed-taglist-plugin-panel.h \
|
||||
xed-taglist-plugin.c \
|
||||
xed-taglist-plugin.h
|
||||
|
||||
libtaglist_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
|
||||
libtaglist_la_LIBADD = $(XED_LIBS)
|
||||
|
||||
plugin_in_files = taglist.plugin.desktop.in
|
||||
|
||||
%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po)
|
||||
$(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
|
||||
|
||||
GZIP_ENV = -9
|
||||
|
||||
%.tags.gz: %.tags.xml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po)
|
||||
LC_ALL=C $(INTLTOOL_MERGE) $(top_srcdir)/po $< $(@:.gz=) -x -u -c $(top_builddir)/po/.intltool-merge-cache
|
||||
GZIP=$(GZIP_ENV) gzip -n -f $(@:.gz=)
|
||||
|
||||
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(taglist_in_files) $(taglist_DATA) \
|
||||
$(plugin_in_files) $(plugin_DATA)
|
||||
|
||||
CLEANFILES = \
|
||||
$(taglist_DATA) \
|
||||
$(plugin_DATA)
|
||||
DISTCLEANFILES = \
|
||||
$(taglist_DATA) \
|
||||
$(plugin_DATA)
|
||||
|
||||
|
||||
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,63 @@
|
|||
taglist_sources = [
|
||||
'xed-taglist-plugin-parser.c',
|
||||
'xed-taglist-plugin-parser.h',
|
||||
'xed-taglist-plugin-panel.c',
|
||||
'xed-taglist-plugin-panel.h',
|
||||
'xed-taglist-plugin.c',
|
||||
'xed-taglist-plugin.h'
|
||||
]
|
||||
|
||||
taglist_in_files = [
|
||||
'C.tags@0@',
|
||||
'HTML.tags@0@',
|
||||
'Latex.tags@0@',
|
||||
'XSLT.tags@0@',
|
||||
'XUL.tags@0@'
|
||||
]
|
||||
|
||||
taglist_deps = [
|
||||
config_h,
|
||||
glib,
|
||||
gtk,
|
||||
gtksourceview,
|
||||
libpeas,
|
||||
libxml
|
||||
]
|
||||
|
||||
library(
|
||||
'taglist',
|
||||
taglist_sources,
|
||||
link_with: libxed,
|
||||
dependencies: taglist_deps,
|
||||
include_directories: include_dirs,
|
||||
install_rpath: join_paths(prefix, libdir, 'xed'),
|
||||
install: true,
|
||||
install_dir: join_paths(libdir, 'xed', 'plugins')
|
||||
)
|
||||
|
||||
taglist_desktop = custom_target(
|
||||
'taglist_desktop',
|
||||
input: 'taglist.plugin.desktop.in',
|
||||
output: 'taglist.plugin',
|
||||
command: [intltool_merge, '-d', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: pluginslibdir,
|
||||
)
|
||||
|
||||
foreach tagtype : taglist_in_files
|
||||
taglist_xml = custom_target(
|
||||
'@0@xmltags'.format(tagtype.format('')),
|
||||
input: tagtype.format('.xml.in'),
|
||||
output: tagtype.format(''),
|
||||
command: [intltool_merge, '-x', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
)
|
||||
|
||||
taglist_gz = custom_target(
|
||||
'@0@gztags'.format(tagtype.format('')),
|
||||
input: taglist_xml,
|
||||
output: tagtype.format('.gz'),
|
||||
command: ['gzip', '-9', '-n', '-f', '@INPUT@'],
|
||||
install: true,
|
||||
install_dir: join_paths(pluginsdatadir, 'taglist')
|
||||
)
|
||||
endforeach
|
|
@ -28,22 +28,17 @@
|
|||
* $Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "xed-taglist-plugin-panel.h"
|
||||
#include "xed-taglist-plugin-parser.h"
|
||||
|
||||
#include <xed/xed-utils.h>
|
||||
#include <xed/xed-debug.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "xed-taglist-plugin-panel.h"
|
||||
#include "xed-taglist-plugin-parser.h"
|
||||
|
||||
#define XED_TAGLIST_PLUGIN_PANEL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||
XED_TYPE_TAGLIST_PLUGIN_PANEL, \
|
||||
XedTaglistPluginPanelPrivate))
|
||||
|
@ -717,7 +712,6 @@ xed_taglist_plugin_panel_init (XedTaglistPluginPanel *panel)
|
|||
panel->priv->tag_groups_combo,
|
||||
ATK_RELATION_CONTROLLED_BY);
|
||||
|
||||
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (panel->priv->tags_list), FALSE);
|
||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (panel->priv->tags_list), FALSE);
|
||||
|
||||
g_object_set (panel->priv->tags_list, "has-tooltip", TRUE, NULL);
|
||||
|
|
|
@ -30,15 +30,11 @@
|
|||
|
||||
/* FIXME: we should rewrite the parser to avoid using DOM */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include <xed/xed-debug.h>
|
||||
|
||||
#include "xed-taglist-plugin-parser.h"
|
||||
|
|
|
@ -27,20 +27,16 @@
|
|||
* $Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <xed/xed-window.h>
|
||||
#include <xed/xed-window-activatable.h>
|
||||
#include <xed/xed-debug.h>
|
||||
|
||||
#include "xed-taglist-plugin.h"
|
||||
#include "xed-taglist-plugin-panel.h"
|
||||
#include "xed-taglist-plugin-parser.h"
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include <xed/xed-window.h>
|
||||
#include <xed/xed-window-activatable.h>
|
||||
#include <xed/xed-debug.h>
|
||||
|
||||
#define XED_TAGLIST_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), XED_TYPE_TAGLIST_PLUGIN, XedTaglistPluginPrivate))
|
||||
|
||||
struct _XedTaglistPluginPrivate
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
# Textsize Plugin
|
||||
SUBDIRS = textsize
|
||||
plugindir = $(XED_PLUGINS_LIBS_DIR)
|
||||
|
||||
plugin_in_files = textsize.plugin.desktop.in
|
||||
%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
|
||||
|
||||
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(plugin_in_files)
|
||||
|
||||
CLEANFILES = $(plugin_DATA)
|
||||
DISTCLEANFILES = $(plugin_DATA)
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,13 @@
|
|||
install_subdir(
|
||||
'textsize',
|
||||
install_dir: pluginslibdir
|
||||
)
|
||||
|
||||
textsize_desktop = custom_target(
|
||||
'textsize_desktop',
|
||||
input: 'textsize.plugin.desktop.in',
|
||||
output: 'textsize.plugin',
|
||||
command: [intltool_merge, '-d', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: pluginslibdir,
|
||||
)
|
|
@ -1,11 +0,0 @@
|
|||
plugindir = $(XED_PLUGINS_LIBS_DIR)/textsize
|
||||
|
||||
plugin_PYTHON = \
|
||||
__init__.py \
|
||||
signals.py \
|
||||
documenthelper.py
|
||||
|
||||
CLEANFILES =
|
||||
DISTCLEANFILES =
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -1,41 +0,0 @@
|
|||
# time plugin
|
||||
plugindir = $(XED_PLUGINS_LIBS_DIR)
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(XED_CFLAGS) \
|
||||
$(WARN_CFLAGS) \
|
||||
$(DISABLE_DEPRECATED_CFLAGS)
|
||||
|
||||
plugin_LTLIBRARIES = libtime.la
|
||||
|
||||
libtime_la_SOURCES = \
|
||||
xed-time-plugin.h \
|
||||
xed-time-plugin.c
|
||||
|
||||
libtime_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
|
||||
libtime_la_LIBADD = $(XED_LIBS)
|
||||
|
||||
uidir = $(XED_PLUGINS_DATA_DIR)/time
|
||||
ui_DATA = \
|
||||
xed-time-dialog.ui \
|
||||
xed-time-setup-dialog.ui
|
||||
|
||||
plugin_in_files = time.plugin.desktop.in
|
||||
|
||||
%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
|
||||
|
||||
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
|
||||
|
||||
@INTLTOOL_XML_NOMERGE_RULE@
|
||||
time_gschema_in = org.x.editor.plugins.time.gschema.xml.in
|
||||
gsettings_SCHEMAS = $(time_gschema_in:.xml.in=.xml)
|
||||
@GSETTINGS_RULES@
|
||||
|
||||
EXTRA_DIST = $(ui_DATA) $(plugin_in_files) $(time_gschema_in)
|
||||
|
||||
CLEANFILES = $(plugin_DATA) $(gsettings_SCHEMAS_in) $(gsettings_SCHEMASn)
|
||||
DISTCLEANFILES = $(plugin_DATA) $(gsettings_SCHEMAS_in) $(gsettings_SCHEMAS)
|
||||
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,55 @@
|
|||
time_sources = [
|
||||
'xed-time-plugin.h',
|
||||
'xed-time-plugin.c'
|
||||
]
|
||||
|
||||
time_deps = [
|
||||
config_h,
|
||||
gio,
|
||||
glib,
|
||||
gtksourceview,
|
||||
libpeas,
|
||||
libpeas_gtk
|
||||
]
|
||||
|
||||
library(
|
||||
'time',
|
||||
time_sources,
|
||||
link_with: libxed,
|
||||
dependencies: time_deps,
|
||||
include_directories: include_dirs,
|
||||
install_rpath: join_paths(prefix, libdir, 'xed'),
|
||||
install: true,
|
||||
install_dir: join_paths(libdir, 'xed', 'plugins')
|
||||
)
|
||||
|
||||
time_ui_sources = [
|
||||
'xed-time-dialog.ui',
|
||||
'xed-time-setup-dialog.ui'
|
||||
]
|
||||
|
||||
install_data(
|
||||
time_ui_sources,
|
||||
install_dir: join_paths(pluginsdatadir, 'time')
|
||||
)
|
||||
|
||||
time_desktop = custom_target(
|
||||
'time_desktop',
|
||||
input: 'time.plugin.desktop.in',
|
||||
output: 'time.plugin',
|
||||
command: [intltool_merge, '-d', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: pluginslibdir,
|
||||
)
|
||||
|
||||
time_schema_file = configure_file(
|
||||
input: 'org.x.editor.plugins.time.gschema.xml.in',
|
||||
output: 'org.x.editor.plugins.time.gschema.xml',
|
||||
configuration: schema_conf,
|
||||
install_dir: join_paths(datadir, 'glib-2.0', 'schemas')
|
||||
)
|
||||
|
||||
install_data(
|
||||
time_schema_file,
|
||||
install_dir: schema_dir
|
||||
)
|
|
@ -24,22 +24,18 @@
|
|||
* See the ChangeLog files for a list of changes.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <glib.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include <xed/xed-window.h>
|
||||
#include <xed/xed-window-activatable.h>
|
||||
#include <libpeas-gtk/peas-gtk-configurable.h>
|
||||
#include <xed/xed-debug.h>
|
||||
#include <xed/xed-utils.h>
|
||||
#include <xed/xed-app.h>
|
||||
|
||||
#include "xed-time-plugin.h"
|
||||
|
||||
#define XED_TIME_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
# trailsave plugin
|
||||
plugindir = $(XED_PLUGINS_LIBS_DIR)
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir) \
|
||||
$(XED_CFLAGS) \
|
||||
$(WARN_CFLAGS) \
|
||||
$(DISABLE_DEPRECATED_CFLAGS)
|
||||
|
||||
plugin_LTLIBRARIES = libtrailsave.la
|
||||
|
||||
libtrailsave_la_SOURCES = \
|
||||
xed-trail-save-plugin.h \
|
||||
xed-trail-save-plugin.c
|
||||
|
||||
libtrailsave_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
|
||||
libtrailsave_la_LIBADD = $(XED_LIBS)
|
||||
|
||||
plugin_in_files = trailsave.plugin.desktop.in
|
||||
|
||||
%.plugin: %.plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
|
||||
|
||||
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
|
||||
|
||||
EXTRA_DIST = $(plugin_in_files)
|
||||
|
||||
CLEANFILES = $(plugin_DATA)
|
||||
DISTCLEANFILES = $(plugin_DATA)
|
||||
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -0,0 +1,31 @@
|
|||
trailsave_sources = [
|
||||
'xed-trail-save-plugin.h',
|
||||
'xed-trail-save-plugin.c'
|
||||
]
|
||||
|
||||
trailsave_deps = [
|
||||
config_h,
|
||||
glib,
|
||||
gtksourceview,
|
||||
libpeas
|
||||
]
|
||||
|
||||
library(
|
||||
'trailsave',
|
||||
trailsave_sources,
|
||||
link_with: libxed,
|
||||
dependencies: trailsave_deps,
|
||||
include_directories: include_dirs,
|
||||
install_rpath: join_paths(prefix, libdir, 'xed'),
|
||||
install: true,
|
||||
install_dir: join_paths(libdir, 'xed', 'plugins')
|
||||
)
|
||||
|
||||
trailsave_desktop = custom_target(
|
||||
'trailsave_desktop',
|
||||
input: 'trailsave.plugin.desktop.in',
|
||||
output: 'trailsave.plugin',
|
||||
command: [intltool_merge, '-d', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: pluginslibdir,
|
||||
)
|
|
@ -16,18 +16,14 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "xed-trail-save-plugin.h"
|
||||
|
||||
#include <xed/xed-window.h>
|
||||
#include <xed/xed-window-activatable.h>
|
||||
#include <xed/xed-debug.h>
|
||||
|
||||
#include "xed-trail-save-plugin.h"
|
||||
|
||||
#define XED_TRAIL_SAVE_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \
|
||||
XED_TYPE_TRAIL_SAVE_PLUGIN, \
|
||||
XedTrailSavePluginPrivate))
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
wordcompletion_sources = [
|
||||
'xed-wordcompletion-plugin.h',
|
||||
'xed-wordcompletion-plugin.c'
|
||||
]
|
||||
|
||||
wordcompletion_deps = [
|
||||
config_h,
|
||||
gio,
|
||||
glib,
|
||||
gtksourceview,
|
||||
libpeas,
|
||||
libpeas_gtk
|
||||
]
|
||||
|
||||
library(
|
||||
'wordcompletion',
|
||||
wordcompletion_sources,
|
||||
link_with: libxed,
|
||||
dependencies: wordcompletion_deps,
|
||||
include_directories: include_dirs,
|
||||
install_rpath: join_paths(prefix, libdir, 'xed'),
|
||||
install: true,
|
||||
install_dir: join_paths(libdir, 'xed', 'plugins')
|
||||
)
|
||||
|
||||
wordcompletion_desktop = custom_target(
|
||||
'wordcompletion_desktop',
|
||||
input: 'wordcompletion.plugin.desktop.in',
|
||||
output: 'wordcompletion.plugin',
|
||||
command: [intltool_merge, '-d', '-u', po_dir, '@INPUT@', '@OUTPUT@'],
|
||||
install: true,
|
||||
install_dir: pluginslibdir,
|
||||
)
|
||||
|
||||
install_data(
|
||||
'xed-wordcompletion-configure.ui',
|
||||
install_dir: join_paths(pluginsdatadir, 'wordcompletion')
|
||||
)
|
||||
|
||||
install_data(
|
||||
'org.x.editor.plugins.wordcompletion.gschema.xml',
|
||||
install_dir: schema_dir
|
||||
)
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist gettext-domain="xed">
|
||||
<schema id="org.x.editor.plugins.wordcompletion" path="/org/x/editor/plugins/wordcompletion/">
|
||||
<key name="interactive-completion" type="b">
|
||||
<default>true</default>
|
||||
<summary>Interactive Completion</summary>
|
||||
<description>Whether to enable interactive completion.</description>
|
||||
</key>
|
||||
<key name="minimum-word-size" type="u">
|
||||
<range min="2" max="100" />
|
||||
<default>2</default>
|
||||
<summary>Minimum Word Size</summary>
|
||||
<description>The minimum word size to complete.</description>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist gettext-domain="@GETTEXT_PACKAGE@">
|
||||
<schema id="org.x.editor.plugins.wordcompletion" path="/org/x/editor/plugins/wordcompletion/">
|
||||
<key name="interactive-completion" type="b">
|
||||
<default>true</default>
|
||||
<summary>Interactive Completion</summary>
|
||||
<description>Whether to enable interactive completion.</description>
|
||||
</key>
|
||||
<key name="minimum-word-size" type="u">
|
||||
<range min="2" max="100" />
|
||||
<default>2</default>
|
||||
<summary>Minimum Word Size</summary>
|
||||
<description>The minimum word size to complete.</description>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
|
@ -0,0 +1,33 @@
|
|||
[Plugin]
|
||||
Module=wordcompletion
|
||||
IAge=3
|
||||
Name=Word Completion
|
||||
Name[am]=ቃላት መጠቅለያ
|
||||
Name[bg]=Довършване на думи
|
||||
Name[ca]=Compleció de paraules
|
||||
Name[cs]=Dokončování slov
|
||||
Name[cy]=Cwblhad Geiriau
|
||||
Name[da]=Ordfuldførelse
|
||||
Name[de]=Wortvervollständigung
|
||||
Name[en_GB]=Word Completion
|
||||
Name[es]=Completar palabras
|
||||
Name[eu]=Hitzak osatzea
|
||||
Name[fr]=Complétion des mots
|
||||
Name[hr]=Dovršavanje riječi
|
||||
Name[hu]=Szókiegészítés
|
||||
Name[ia]=Completamento de parola
|
||||
Name[it]=Completamento Parole
|
||||
Name[ko]=단어 완성
|
||||
Name[lt]=Žodžių užbaigimas
|
||||
Name[nl]=Woordaanvulling
|
||||
Name[pt_BR]=Preenchimento de palavras
|
||||
Name[ru]=Завершение слов
|
||||
Name[sr]=Завршетак речи
|
||||
Name[sv]=Ordkomplettering
|
||||
Name[tr]=Kelime Tamamlama
|
||||
Name[zh_CN]=单词补全
|
||||
Description=Predicts the rest of the word after a few characters have been typed.
|
||||
Authors=Jesse van den Kieboom <jesse@gnome.org>\nIgnacio Casal Quinteiro <icq@gnome.org>\nMickael Albertus <mickael.albertus@gmail.com>
|
||||
Copyright=Copyright © 2017 Mickael Albertus\n2009 Jesse van den Kieboom
|
||||
Website=https://github.com/linuxmint/xed
|
||||
Version=@VERSION@
|
|
@ -0,0 +1,9 @@
|
|||
[Plugin]
|
||||
Module=wordcompletion
|
||||
IAge=3
|
||||
_Name=Word Completion
|
||||
_Description=Predicts the rest of the word after a few characters have been typed.
|
||||
Authors=Jesse van den Kieboom <jesse@gnome.org>\nIgnacio Casal Quinteiro <icq@gnome.org>\nMickael Albertus <mickael.albertus@gmail.com>
|
||||
Copyright=Copyright © 2017 Mickael Albertus\n2009 Jesse van den Kieboom
|
||||
Website=https://github.com/linuxmint/xed
|
||||
Version=@VERSION@
|
|
@ -0,0 +1,140 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.18.3 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.0"/>
|
||||
<object class="GtkAdjustment" id="adjustment1">
|
||||
<property name="lower">2</property>
|
||||
<property name="upper">100</property>
|
||||
<property name="value">2</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkDialog" id="configure_dialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Word Completion</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="type_hint">normal</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="dialog-vbox1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">2</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox" id="dialog-action_area1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="yalign">0.52999997138977051</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">10</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">9</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ypad">6</property>
|
||||
<property name="label" translatable="yes">Use Ctrl+Space to manually trigger word completion.</property>
|
||||
<attributes>
|
||||
<attribute name="style" value="italic"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="check_button_interactive_completion">
|
||||
<property name="label" translatable="yes">Automatic completion</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="xalign">0.10000000149011612</property>
|
||||
<property name="yalign">0.44999998807907104</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Minimum word size for auto-completion</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="spin_button_min_word_size">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="adjustment">adjustment1</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="0">button1</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
|
@ -0,0 +1,465 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Ignacio Casal Quinteiro <icq@gnome.org>
|
||||
* 2009 Jesse van den Kieboom <jesse@gnome.org>
|
||||
* 2013 Sébastien Wilmet <swilmet@gnome.org>
|
||||
* 2017 Mickael Albertus <mickael.albertus@gmail.com>
|
||||
*
|
||||
* 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, 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <glib.h>
|
||||
#include <gio/gio.h>
|
||||
#include <xed/xed-debug.h>
|
||||
#include <xed/xed-window.h>
|
||||
#include <xed/xed-window-activatable.h>
|
||||
#include <xed/xed-utils.h>
|
||||
#include <xed/xed-view.h>
|
||||
#include <xed/xed-view-activatable.h>
|
||||
#include <libpeas-gtk/peas-gtk-configurable.h>
|
||||
#include <gtksourceview/gtksource.h>
|
||||
#include <gtksourceview/completion-providers/words/gtksourcecompletionwords.h>
|
||||
|
||||
#include "xed-wordcompletion-plugin.h"
|
||||
|
||||
#define WINDOW_PROVIDER "XedWordCompletionPluginProvider"
|
||||
|
||||
#define WORDCOMPLETION_SETTINGS_BASE "org.x.editor.plugins.wordcompletion"
|
||||
#define SETTINGS_KEY_INTERACTIVE_COMPLETION "interactive-completion"
|
||||
#define SETTINGS_KEY_MINIMUM_WORD_SIZE "minimum-word-size"
|
||||
|
||||
static void xed_window_activatable_iface_init (XedWindowActivatableInterface *iface);
|
||||
static void xed_view_activatable_iface_init (XedViewActivatableInterface *iface);
|
||||
static void peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface);
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE_EXTENDED (XedWordCompletionPlugin,
|
||||
xed_wordcompletion_plugin,
|
||||
PEAS_TYPE_EXTENSION_BASE,
|
||||
0,
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (XED_TYPE_WINDOW_ACTIVATABLE,
|
||||
xed_window_activatable_iface_init)
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (XED_TYPE_VIEW_ACTIVATABLE,
|
||||
xed_view_activatable_iface_init)
|
||||
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_GTK_TYPE_CONFIGURABLE,
|
||||
peas_gtk_configurable_iface_init))
|
||||
|
||||
struct _XedWordCompletionPluginPrivate
|
||||
{
|
||||
GtkWidget *window;
|
||||
XedView *view;
|
||||
GtkSourceCompletionProvider *provider;
|
||||
GSettings *settings;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_WINDOW,
|
||||
PROP_VIEW
|
||||
};
|
||||
|
||||
|
||||
typedef struct _WordCompletionConfigureWidget WordCompletionConfigureWidget;
|
||||
|
||||
struct _WordCompletionConfigureWidget
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *min_word_size;
|
||||
GtkWidget *interactive_completion;
|
||||
|
||||
GSettings *settings;
|
||||
};
|
||||
|
||||
static void
|
||||
xed_wordcompletion_plugin_init (XedWordCompletionPlugin *plugin)
|
||||
{
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedWordCompletionPlugin initializing");
|
||||
|
||||
plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin,
|
||||
XED_TYPE_WORDCOMPLETION_PLUGIN,
|
||||
XedWordCompletionPluginPrivate);
|
||||
|
||||
plugin->priv->settings = g_settings_new (WORDCOMPLETION_SETTINGS_BASE);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_wordcompletion_plugin_finalize (GObject *object)
|
||||
{
|
||||
XedWordCompletionPlugin *plugin = XED_WORDCOMPLETION_PLUGIN (object);
|
||||
|
||||
xed_debug_message (DEBUG_PLUGINS, "XedWordCompletionPlugin finalizing");
|
||||
|
||||
g_object_unref (G_OBJECT (plugin->priv->settings));
|
||||
|
||||
G_OBJECT_CLASS (xed_wordcompletion_plugin_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
xed_wordcompletion_plugin_dispose (GObject *object)
|
||||
{
|
||||
XedWordCompletionPlugin *plugin = XED_WORDCOMPLETION_PLUGIN (object);
|
||||
|
||||
if (plugin->priv->window != NULL)
|
||||
{
|
||||
g_object_unref (plugin->priv->window);
|
||||
plugin->priv->window = NULL;
|
||||
}
|
||||
|
||||
if (plugin->priv->view != NULL)
|
||||
{
|
||||
g_object_unref (plugin->priv->view);
|
||||
plugin->priv->view = NULL;
|
||||
}
|
||||
|
||||
if (plugin->priv->provider != NULL)
|
||||
{
|
||||
g_object_unref (plugin->priv->provider);
|
||||
plugin->priv->provider = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (xed_wordcompletion_plugin_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_wordcompletion_plugin_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
XedWordCompletionPlugin *plugin = XED_WORDCOMPLETION_PLUGIN (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_WINDOW:
|
||||
plugin->priv->window = g_value_dup_object (value);
|
||||
break;
|
||||
case PROP_VIEW:
|
||||
plugin->priv->view = XED_VIEW (g_value_dup_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xed_wordcompletion_plugin_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
XedWordCompletionPlugin *plugin = XED_WORDCOMPLETION_PLUGIN (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_WINDOW:
|
||||
g_value_set_object (value, plugin->priv->window);
|
||||
break;
|
||||
case PROP_VIEW:
|
||||
g_value_set_object (value, plugin->priv->view);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_activation (GtkSourceCompletionWords *provider,
|
||||
GSettings *settings)
|
||||
{
|
||||
GtkSourceCompletionActivation activation;
|
||||
|
||||
g_object_get (provider, "activation", &activation, NULL);
|
||||
|
||||
if (g_settings_get_boolean (settings, SETTINGS_KEY_INTERACTIVE_COMPLETION))
|
||||
{
|
||||
activation |= GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
activation &= ~GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE;
|
||||
}
|
||||
|
||||
g_object_set (provider, "activation", activation, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
on_interactive_completion_changed_cb (GSettings *settings,
|
||||
gchar *key,
|
||||
GtkSourceCompletionWords *provider)
|
||||
{
|
||||
update_activation (provider, settings);
|
||||
}
|
||||
|
||||
static GtkSourceCompletionWords *
|
||||
create_provider (void)
|
||||
{
|
||||
GtkSourceCompletionWords *provider;
|
||||
GSettings *settings;
|
||||
|
||||
provider = gtk_source_completion_words_new (_("Word completion"), NULL);
|
||||
|
||||
settings = g_settings_new (WORDCOMPLETION_SETTINGS_BASE);
|
||||
|
||||
g_settings_bind (settings, SETTINGS_KEY_MINIMUM_WORD_SIZE,
|
||||
provider, "minimum-word-size",
|
||||
G_SETTINGS_BIND_GET);
|
||||
|
||||
update_activation (provider, settings);
|
||||
|
||||
g_signal_connect_object (settings,
|
||||
"changed::" SETTINGS_KEY_INTERACTIVE_COMPLETION,
|
||||
G_CALLBACK (on_interactive_completion_changed_cb),
|
||||
provider,
|
||||
0);
|
||||
|
||||
g_object_unref (settings);
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
static void
|
||||
xed_wordcompletion_window_activate (XedWindowActivatable *activatable)
|
||||
{
|
||||
XedWordCompletionPluginPrivate *priv;
|
||||
GtkSourceCompletionWords *provider;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
priv = XED_WORDCOMPLETION_PLUGIN (activatable)->priv;
|
||||
|
||||
provider = create_provider ();
|
||||
|
||||
g_object_set_data_full (G_OBJECT (priv->window),
|
||||
WINDOW_PROVIDER,
|
||||
provider,
|
||||
(GDestroyNotify)g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_wordcompletion_window_deactivate (XedWindowActivatable *activatable)
|
||||
{
|
||||
XedWordCompletionPluginPrivate *priv;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
priv = XED_WORDCOMPLETION_PLUGIN (activatable)->priv;
|
||||
|
||||
g_object_set_data (G_OBJECT (priv->window), WINDOW_PROVIDER, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_wordcompletion_view_activate (XedViewActivatable *activatable)
|
||||
{
|
||||
XedWordCompletionPluginPrivate *priv;
|
||||
GtkSourceCompletion *completion;
|
||||
GtkSourceCompletionProvider *provider;
|
||||
GtkTextBuffer *buf;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
priv = XED_WORDCOMPLETION_PLUGIN (activatable)->priv;
|
||||
|
||||
priv->window = gtk_widget_get_toplevel (GTK_WIDGET (priv->view));
|
||||
|
||||
/* We are disposing the window */
|
||||
g_object_ref (priv->window);
|
||||
|
||||
completion = gtk_source_view_get_completion (GTK_SOURCE_VIEW (priv->view));
|
||||
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->view));
|
||||
|
||||
provider = g_object_get_data (G_OBJECT (priv->window), WINDOW_PROVIDER);
|
||||
|
||||
if (provider == NULL)
|
||||
{
|
||||
/* Standalone provider */
|
||||
provider = GTK_SOURCE_COMPLETION_PROVIDER (create_provider ());
|
||||
}
|
||||
|
||||
priv->provider = g_object_ref (provider);
|
||||
|
||||
gtk_source_completion_add_provider (completion, provider, NULL);
|
||||
gtk_source_completion_words_register (GTK_SOURCE_COMPLETION_WORDS (provider),
|
||||
buf);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_wordcompletion_view_deactivate (XedViewActivatable *activatable)
|
||||
{
|
||||
XedWordCompletionPluginPrivate *priv;
|
||||
GtkSourceCompletion *completion;
|
||||
GtkTextBuffer *buf;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
priv = XED_WORDCOMPLETION_PLUGIN (activatable)->priv;
|
||||
|
||||
completion = gtk_source_view_get_completion (GTK_SOURCE_VIEW (priv->view));
|
||||
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->view));
|
||||
|
||||
gtk_source_completion_remove_provider (completion,
|
||||
priv->provider,
|
||||
NULL);
|
||||
|
||||
gtk_source_completion_words_unregister (GTK_SOURCE_COMPLETION_WORDS (priv->provider),
|
||||
buf);
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_response_cb (GtkWidget *widget,
|
||||
gint response,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_widget_destroy (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
configure_widget_destroyed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
WordCompletionConfigureWidget *conf_widget = (WordCompletionConfigureWidget *) data;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
g_object_unref (conf_widget->settings);
|
||||
g_slice_free (WordCompletionConfigureWidget, data);
|
||||
|
||||
xed_debug_message (DEBUG_PLUGINS, "END");
|
||||
}
|
||||
|
||||
static WordCompletionConfigureWidget *
|
||||
get_configure_widget (XedWordCompletionPlugin *plugin)
|
||||
{
|
||||
WordCompletionConfigureWidget *widget;
|
||||
gchar *data_dir;
|
||||
gchar *ui_file;
|
||||
GtkWidget *error_widget;
|
||||
gboolean ret;
|
||||
|
||||
xed_debug (DEBUG_PLUGINS);
|
||||
|
||||
widget = g_slice_new (WordCompletionConfigureWidget);
|
||||
widget->settings = g_object_ref (plugin->priv->settings);
|
||||
|
||||
data_dir = peas_extension_base_get_data_dir (PEAS_EXTENSION_BASE (plugin));
|
||||
ui_file = g_build_filename (data_dir, "xed-wordcompletion-configure.ui", NULL);
|
||||
ret = xed_utils_get_ui_objects (ui_file,
|
||||
NULL,
|
||||
&error_widget,
|
||||
"configure_dialog", &widget->dialog,
|
||||
"spin_button_min_word_size", &widget->min_word_size,
|
||||
"check_button_interactive_completion", &widget->interactive_completion,
|
||||
NULL);
|
||||
|
||||
g_free (data_dir);
|
||||
g_free (ui_file);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gtk_window_set_modal (GTK_WINDOW (widget->dialog), TRUE);
|
||||
|
||||
g_settings_bind (widget->settings, SETTINGS_KEY_INTERACTIVE_COMPLETION,
|
||||
widget->interactive_completion, "active",
|
||||
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_GET_NO_CHANGES);
|
||||
|
||||
g_settings_bind (widget->settings, SETTINGS_KEY_MINIMUM_WORD_SIZE,
|
||||
widget->min_word_size, "value",
|
||||
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_GET_NO_CHANGES);
|
||||
|
||||
g_signal_connect (widget->dialog, "destroy",
|
||||
G_CALLBACK (configure_widget_destroyed), widget);
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (widget->dialog));
|
||||
g_signal_connect (widget->dialog, "response",
|
||||
G_CALLBACK (dialog_response_cb), widget);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
xed_wordcompletion_create_configure_widget (PeasGtkConfigurable *configurable)
|
||||
{
|
||||
|
||||
WordCompletionConfigureWidget *widget;
|
||||
|
||||
widget = get_configure_widget (XED_WORDCOMPLETION_PLUGIN (configurable));
|
||||
|
||||
return widget->dialog;
|
||||
}
|
||||
|
||||
static void
|
||||
xed_wordcompletion_plugin_class_init (XedWordCompletionPluginClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = xed_wordcompletion_plugin_finalize;
|
||||
object_class->dispose = xed_wordcompletion_plugin_dispose;
|
||||
object_class->set_property = xed_wordcompletion_plugin_set_property;
|
||||
object_class->get_property = xed_wordcompletion_plugin_get_property;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_WINDOW, "window");
|
||||
g_object_class_override_property (object_class, PROP_VIEW, "view");
|
||||
|
||||
g_type_class_add_private (klass, sizeof (XedWordCompletionPluginPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
xed_wordcompletion_plugin_class_finalize (XedWordCompletionPluginClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
xed_window_activatable_iface_init (XedWindowActivatableInterface *iface)
|
||||
{
|
||||
iface->activate = xed_wordcompletion_window_activate;
|
||||
iface->deactivate = xed_wordcompletion_window_deactivate;
|
||||
}
|
||||
|
||||
static void
|
||||
xed_view_activatable_iface_init (XedViewActivatableInterface *iface)
|
||||
{
|
||||
iface->activate = xed_wordcompletion_view_activate;
|
||||
iface->deactivate = xed_wordcompletion_view_deactivate;
|
||||
}
|
||||
|
||||
static void
|
||||
peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface)
|
||||
{
|
||||
iface->create_configure_widget = xed_wordcompletion_create_configure_widget;
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
peas_register_types (PeasObjectModule *module)
|
||||
{
|
||||
xed_wordcompletion_plugin_register_type (G_TYPE_MODULE (module));
|
||||
|
||||
peas_object_module_register_extension_type (module,
|
||||
XED_TYPE_WINDOW_ACTIVATABLE,
|
||||
XED_TYPE_WORDCOMPLETION_PLUGIN);
|
||||
|
||||
peas_object_module_register_extension_type (module,
|
||||
XED_TYPE_VIEW_ACTIVATABLE,
|
||||
XED_TYPE_WORDCOMPLETION_PLUGIN);
|
||||
|
||||
peas_object_module_register_extension_type (module,
|
||||
PEAS_GTK_TYPE_CONFIGURABLE,
|
||||
XED_TYPE_WORDCOMPLETION_PLUGIN);
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (C) 2009 Ignacio Casal Quinteiro <icq@gnome.org>
|
||||
* 2017 Mickael Albertus <mickael.albertus@gmail.com>
|
||||
*
|
||||
* 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, 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __XED_WORDCOMPLETION_PLUGIN_H__
|
||||
#define __XED_WORDCOMPLETION_PLUGIN_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <libpeas/peas-extension-base.h>
|
||||
#include <libpeas/peas-object-module.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define XED_TYPE_WORDCOMPLETION_PLUGIN (xed_wordcompletion_plugin_get_type ())
|
||||
#define XED_WORDCOMPLETION_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XED_TYPE_WORDCOMPLETION_PLUGIN, XedWordCompletionPlugin))
|
||||
#define XED_WORDCOMPLETION_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), XED_TYPE_WORDCOMPLETION_PLUGIN, XedWordCompletionPluginClass))
|
||||
#define XED_IS_WORDCOMPLETION_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), XED_TYPE_WORDCOMPLETION_PLUGIN))
|
||||
#define XED_IS_WORDCOMPLETION_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), XED_TYPE_WORDCOMPLETION_PLUGIN))
|
||||
#define XED_WORDCOMPLETION_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), XED_TYPE_WORDCOMPLETION_PLUGIN, XedWordCompletionPluginClass))
|
||||
|
||||
typedef struct _XedWordCompletionPlugin XedWordCompletionPlugin;
|
||||
typedef struct _XedWordCompletionPluginPrivate XedWordCompletionPluginPrivate;
|
||||
typedef struct _XedWordCompletionPluginClass XedWordCompletionPluginClass;
|
||||
|
||||
struct _XedWordCompletionPlugin
|
||||
{
|
||||
PeasExtensionBase parent_instance;
|
||||
|
||||
XedWordCompletionPluginPrivate *priv;
|
||||
};
|
||||
|
||||
struct _XedWordCompletionPluginClass
|
||||
{
|
||||
PeasExtensionBaseClass parent_class;
|
||||
};
|
||||
|
||||
GType xed_wordcompletion_plugin_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_WORDCOMPLETION_PLUGIN_H__ */
|
|
@ -47,6 +47,7 @@ hu
|
|||
hy
|
||||
ia
|
||||
id
|
||||
ie
|
||||
is
|
||||
it
|
||||
ja
|
||||
|
@ -93,6 +94,7 @@ sr@latin
|
|||
sv
|
||||
ta
|
||||
te
|
||||
tg
|
||||
th
|
||||
tk
|
||||
tr
|
||||
|
|
|
@ -22,6 +22,8 @@ xed/xed-documents-panel.c
|
|||
xed/xed-encodings-combo-box.c
|
||||
xed/xed-encodings-dialog.c
|
||||
xed/xed-file-chooser-dialog.c
|
||||
xed/xed-highlight-mode-dialog.c
|
||||
xed/xed-highlight-mode-selector.c
|
||||
xed/xed-history-entry.c
|
||||
xed/xed-io-error-info-bar.c
|
||||
xed/xed-message-bus.c
|
||||
|
@ -37,16 +39,20 @@ xed/xed-preferences-dialog.c
|
|||
xed/xed-print-job.c
|
||||
xed/xed-print-preview.c
|
||||
xed/xed-progress-info-bar.c
|
||||
[type: gettext/glade]xed/resources/ui/xed-highlight-mode-dialog.ui
|
||||
[type: gettext/glade]xed/resources/ui/xed-highlight-mode-selector.ui
|
||||
[type: gettext/glade]xed/resources/ui/xed-status-menu-button.ui
|
||||
[type: gettext/glade]xed/resources/ui/xed-encodings-dialog.ui
|
||||
[type: gettext/glade]xed/resources/ui/xed-preferences-dialog.ui
|
||||
[type: gettext/glade]xed/resources/ui/xed-print-preferences.ui
|
||||
[type: gettext/glade]xed/resources/ui/xed-searchbar.ui
|
||||
[type: gettext/glade]xed/resources/ui/xed-shortcuts.ui
|
||||
[type: gettext/glade]xed/resources/ui/xed-view-frame.ui
|
||||
xed/resources/ui/xed-ui.xml
|
||||
xed/xed-searchbar.c
|
||||
xed/xed-searchbar.c
|
||||
xed/xed-settings.c
|
||||
xed/xed-status-combo-box.c
|
||||
xed/xed-status-menu-button.c
|
||||
xed/xed-statusbar.c
|
||||
xed/xed-statusbar.c
|
||||
xed/xed-tab-label.c
|
||||
|
@ -64,7 +70,7 @@ plugins/docinfo/docinfo.plugin.desktop.in
|
|||
[type: gettext/glade]plugins/docinfo/docinfo.ui
|
||||
plugins/docinfo/xed-docinfo-plugin.c
|
||||
plugins/filebrowser/filebrowser.plugin.desktop.in
|
||||
[type: gettext/gsettings]plugins/filebrowser/org.x.editor.plugins.filebrowser.gschema.xml.in
|
||||
[type: gettext/gsettings]plugins/filebrowser/org.x.editor.plugins.filebrowser.gschema.xml
|
||||
plugins/filebrowser/xed-file-bookmarks-store.c
|
||||
plugins/filebrowser/xed-file-browser-messages.c
|
||||
plugins/filebrowser/xed-file-browser-plugin.c
|
||||
|
@ -77,18 +83,10 @@ plugins/modelines/modelines.plugin.desktop.in
|
|||
plugins/modelines/xed-modeline-plugin.c
|
||||
plugins/sort/sort.plugin.desktop.in
|
||||
plugins/sort/xed-sort-plugin.c
|
||||
[type: gettext/glade]plugins/spell/languages-dialog.ui
|
||||
[type: gettext/gsettings]plugins/spell/org.x.editor.plugins.spell.gschema.xml.in
|
||||
[type: gettext/glade]plugins/spell/spell-checker.ui
|
||||
plugins/spell/spell.plugin.desktop.in
|
||||
plugins/spell/xed-automatic-spell-checker.c
|
||||
plugins/spell/xed-spell-checker-dialog.c
|
||||
plugins/spell/xed-spell-checker-language.c
|
||||
plugins/spell/xed-spell-checker.c
|
||||
plugins/spell/xed-spell-language-dialog.c
|
||||
plugins/spell/xed-spell-plugin.c
|
||||
[type: gettext/glade]plugins/spell/xed-spell-setup-dialog.ui
|
||||
plugins/spell/xed-spell-utils.c
|
||||
plugins/taglist/HTML.tags.xml.in
|
||||
plugins/taglist/Latex.tags.xml.in
|
||||
plugins/taglist/taglist.plugin.desktop.in
|
||||
|
@ -106,3 +104,5 @@ plugins/time/xed-time-plugin.c
|
|||
[type: gettext/glade]plugins/time/xed-time-setup-dialog.ui
|
||||
plugins/trailsave/trailsave.plugin.desktop.in
|
||||
plugins/trailsave/xed-trail-save-plugin.c
|
||||
[type: gettext/glade]plugins/wordcompletion/xed-wordcompletion-configure.ui
|
||||
plugins/wordcompletion/xed-wordcompletion-plugin.c
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue