[Goodies-commits] r4117 - in xfce4-dict/trunk: . lib panel-plugin po src
Enrico Troeger
enrico at xfce.org
Thu Mar 27 20:36:43 CET 2008
Author: enrico
Date: 2008-03-27 19:36:43 +0000 (Thu, 27 Mar 2008)
New Revision: 4117
Added:
xfce4-dict/trunk/lib/
xfce4-dict/trunk/lib/Makefile.am
xfce4-dict/trunk/lib/aspell.c
xfce4-dict/trunk/lib/aspell.h
xfce4-dict/trunk/lib/common.c
xfce4-dict/trunk/lib/common.h
xfce4-dict/trunk/lib/dictd.c
xfce4-dict/trunk/lib/dictd.h
xfce4-dict/trunk/lib/popup_def.h
xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c
xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.desktop.in.in
xfce4-dict/trunk/src/
xfce4-dict/trunk/src/Makefile.am
xfce4-dict/trunk/src/popup_plugin.c
xfce4-dict/trunk/src/popup_plugin.h
xfce4-dict/trunk/src/xfce4-dict.c
xfce4-dict/trunk/src/xfce4-dict.desktop.in
xfce4-dict/trunk/xfce4-dict.svg
Removed:
xfce4-dict/trunk/panel-plugin/aspell.c
xfce4-dict/trunk/panel-plugin/dict-icon.svg
xfce4-dict/trunk/panel-plugin/dict.c
xfce4-dict/trunk/panel-plugin/dict.desktop.in.in
xfce4-dict/trunk/panel-plugin/dict.h
xfce4-dict/trunk/panel-plugin/inline-icon.h
xfce4-dict/trunk/panel-plugin/xfce4-popup-dict.c
xfce4-dict/trunk/panel-plugin/xfce4-popup-dict.h
Modified:
xfce4-dict/trunk/ChangeLog
xfce4-dict/trunk/Makefile.am
xfce4-dict/trunk/configure.in.in
xfce4-dict/trunk/panel-plugin/Makefile.am
xfce4-dict/trunk/po/POTFILES.in
Log:
Reorganise most of the code base to separat commonly used code from the panel plugin into a static library.
Move dictd server query code into an own file for better readibility.
Bump version requirement of libxfce*-libs to 4.4.0.
Add stand-alone application xfce4-dict.
(not yet finished, to be continued)
Modified: xfce4-dict/trunk/ChangeLog
===================================================================
--- xfce4-dict/trunk/ChangeLog 2008-03-25 08:20:17 UTC (rev 4116)
+++ xfce4-dict/trunk/ChangeLog 2008-03-27 19:36:43 UTC (rev 4117)
@@ -1,3 +1,13 @@
+2008-03-27 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+
+ * Reorganise most of the code base to separat commonly used code from the
+ panel plugin into a static library.
+ Move dictd server query code into an own file for better readibility.
+ Bump version requirement of libxfce*-libs to 4.4.0.
+ Add stand-alone application xfce4-dict.
+ (not yet finished, to be continued)
+
+
2008-03-22 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* Use GTK's predefined text targets for Drag'n'Drop. This fixes a strange
Modified: xfce4-dict/trunk/Makefile.am
===================================================================
--- xfce4-dict/trunk/Makefile.am 2008-03-25 08:20:17 UTC (rev 4116)
+++ xfce4-dict/trunk/Makefile.am 2008-03-27 19:36:43 UTC (rev 4117)
@@ -1,24 +1,41 @@
-SUBDIRS = \
- panel-plugin \
+SUBDIRS = \
+ lib \
+ panel-plugin \
+ src \
po
-AUTOMAKE_OPTIONS = \
- 1.8 \
+AUTOMAKE_OPTIONS = \
+ 1.8 \
dist-bzip2
distclean-local:
- rm -rf *.spec *.cache *~
+ rm -rf *.cache *~
-rpm: dist
- rpmbuild -ta $(PACKAGE)-$(VERSION).tar.gz
- @rm -f $(PACKAGE)-$(VERSION).tar.gz
-EXTRA_DIST = \
- intltool-extract.in \
- intltool-merge.in \
- intltool-update.in
+EXTRA_DIST = \
+ intltool-extract.in \
+ intltool-merge.in \
+ intltool-update.in \
+ xfce4-dict.svg
-DISTCLEANFILES = \
- intltool-extract \
- intltool-merge \
+DISTCLEANFILES = \
+ intltool-extract \
+ intltool-merge \
intltool-update
+
+hicolor48dir = $(datadir)/icons/hicolor/scalable/apps
+hicolor48_DATA = xfce4-dict.svg
+
+gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
+
+
+install-data-hook:
+ @-if test -z "$(DESTDIR)"; then \
+ echo "Updating Gtk icon cache."; \
+ $(gtk_update_icon_cache); \
+ else \
+ echo "*** Icon cache not updated. Remember to run:"; \
+ echo "***"; \
+ echo "*** $(gtk_update_icon_cache)"; \
+ echo "***"; \
+ fi
Modified: xfce4-dict/trunk/configure.in.in
===================================================================
--- xfce4-dict/trunk/configure.in.in 2008-03-25 08:20:17 UTC (rev 4116)
+++ xfce4-dict/trunk/configure.in.in 2008-03-27 19:36:43 UTC (rev 4117)
@@ -1,6 +1,6 @@
dnl configure.in.in
dnl
-dnl xfce4-dict-plugin
+dnl xfce4-dict
dnl
dnl version info
@@ -12,12 +12,13 @@
dnl init automake
DICT_VERSION=dict_version
-AM_INIT_AUTOMAKE([xfce4-dict-plugin], [$DICT_VERSION])
+AM_INIT_AUTOMAKE([xfce4-dict], [$DICT_VERSION])
AM_CONFIG_HEADER([config.h])
AM_MAINTAINER_MODE
dnl check for basic programs
AC_PROG_CC
+AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_INTLTOOL()
@@ -25,24 +26,23 @@
dnl check for standard header files
AC_HEADER_STDC
-dnl check for math library
-AC_CHECK_LIB([m], [sin])
-
dnl check for i18n support
XDT_I18N([@LINGUAS@])
dnl check for required packages
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.0])
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
-XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.3.90.2])
-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.3.90.2])
-XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.99.1])
+XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0.0])
+XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.4.0.0])
dnl check for debugging support
XDT_FEATURE_DEBUG()
AC_OUTPUT([
Makefile
+lib/Makefile
+panel-plugin/Makefile
+src/Makefile
po/Makefile.in
-panel-plugin/Makefile
])
Added: xfce4-dict/trunk/lib/Makefile.am
===================================================================
--- xfce4-dict/trunk/lib/Makefile.am (rev 0)
+++ xfce4-dict/trunk/lib/Makefile.am 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,24 @@
+
+
+noinst_LIBRARIES = \
+ libdict.a
+
+libdict_a_SOURCES = \
+ inline-icon.h \
+ popup_def.h \
+ aspell.c \
+ aspell.h \
+ common.c \
+ common.h \
+ dictd.h \
+ dictd.c
+
+libdict_a_CFLAGS = \
+ -I$(top_srcdir) \
+ $(LIBXFCEGUI4_CFLAGS) \
+ $(LIBXFCE4PANEL_CFLAGS) \
+ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+ @GTHREAD_CFLAGS@
+
+inline-icon.h: $(top_srcdir)/xfce4-dict.svg
+ gdk-pixbuf-csource --raw --name=dict_icon_data $(top_srcdir)/xfce4-dict.svg > $(srcdir)/inline-icon.h
Added: xfce4-dict/trunk/lib/aspell.c
===================================================================
--- xfce4-dict/trunk/lib/aspell.c (rev 0)
+++ xfce4-dict/trunk/lib/aspell.c 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,186 @@
+/* $Id$
+ *
+ * Copyright 2007-2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ *
+ * 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 Library 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.
+ */
+
+
+/* Code to execute the aspell (or ispell or anything command line compatible) binary
+ * with a given search term and reads it output. */
+
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <string.h>
+
+#include <gtk/gtk.h>
+
+#include <libxfcegui4/libxfcegui4.h>
+
+/* Simple forward declaration to avoid inclusion of libxfce4panel headers */
+typedef struct XfcePanelPlugin_t XfcePanelPlugin;
+
+#include "common.h"
+#include "aspell.h"
+
+
+static GIOChannel *set_up_io_channel(gint fd, GIOCondition cond, GIOFunc func, gconstpointer data)
+{
+ GIOChannel *ioc;
+
+ ioc = g_io_channel_unix_new(fd);
+
+ g_io_channel_set_flags(ioc, G_IO_FLAG_NONBLOCK, NULL);
+ g_io_channel_set_encoding(ioc, NULL, NULL);
+ /* "auto-close" */
+ g_io_channel_set_close_on_unref(ioc, TRUE);
+
+ g_io_add_watch(ioc, cond, func, (gpointer) data);
+ g_io_channel_unref(ioc);
+
+ return ioc;
+}
+
+
+static gboolean iofunc_read(GIOChannel *ioc, GIOCondition cond, gpointer data)
+{
+ if (cond & (G_IO_IN | G_IO_PRI))
+ {
+ gchar *msg, *tmp;
+ GtkTextIter iter;
+ DictData *dd = data;
+
+ gtk_text_buffer_get_start_iter(dd->main_textbuffer, &iter);
+ while (g_io_channel_read_line(ioc, &msg, NULL, NULL, NULL) && msg != NULL)
+ {
+ if (msg[0] == '&')
+ { /* & cmd 17 7: ... */
+ tmp = strchr(msg + 2, ' ') + 1;
+ dict_status_add(dd, _("%d suggestion(s) found."), atoi(tmp));
+
+ tmp = g_strdup_printf(_("Suggestions for \"%s\":\n"), dd->searched_word);
+ gtk_text_buffer_insert_with_tags(dd->main_textbuffer, &iter, tmp, -1,
+ dd->main_boldtag, NULL);
+ g_free(tmp);
+
+ tmp = strchr(msg, ':') + 2;
+ gtk_text_buffer_insert(dd->main_textbuffer, &iter, g_strchomp(tmp), -1);
+ }
+ else if (msg[0] == '*')
+ {
+ tmp = g_strdup_printf(_("\"%s\" is spelled correctly.\n"), dd->searched_word);
+ gtk_text_buffer_insert(dd->main_textbuffer, &iter, tmp, -1);
+ g_free(tmp);
+ }
+ else if (msg[0] == '#')
+ {
+ tmp = g_strdup_printf(_("No suggestions could be found for \"%s\".\n"),
+ dd->searched_word);
+ gtk_text_buffer_insert(dd->main_textbuffer, &iter, tmp, -1);
+ g_free(tmp);
+ }
+ g_free(msg);
+ }
+ }
+ if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+static gboolean iofunc_read_err(GIOChannel *ioc, GIOCondition cond, gpointer data)
+{
+ if (cond & (G_IO_IN | G_IO_PRI))
+ {
+ gchar *msg;
+ DictData *dd = data;
+
+ while (g_io_channel_read_line(ioc, &msg, NULL, NULL, NULL) && msg != NULL)
+ {
+ dict_status_add(dd, _("%s"), g_strstrip(msg));
+ g_free(msg);
+ }
+ }
+ if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+static gboolean iofunc_write(GIOChannel *ioc, GIOCondition cond, gpointer data)
+{
+ gsize written;
+
+ if (NZV((const gchar *) data))
+ g_io_channel_write_chars(ioc, (const gchar *) data, -1, &written, NULL);
+
+ return FALSE;
+}
+
+
+void dict_start_aspell_query(DictData *dd, const gchar *word)
+{
+ GError *error = NULL;
+ gchar **argv;
+ gchar *locale_cmd;
+ gint stdout_fd;
+ gint stderr_fd;
+ gint stdin_fd;
+
+ if (! NZV(dd->spell_bin))
+ {
+ dict_status_add(dd, _("Please set an appropriate aspell command."));
+ return;
+ }
+ if (! NZV(word))
+ {
+ dict_status_add(dd, _("Invalid input."));
+ return;
+ }
+ locale_cmd = g_locale_from_utf8(dd->spell_bin, -1, NULL, NULL, NULL);
+ if (locale_cmd == NULL)
+ locale_cmd = g_strdup(dd->spell_bin);
+
+ argv = g_new0(gchar*, 5);
+ argv[0] = locale_cmd;
+ argv[1] = g_strdup("-a");
+ argv[2] = g_strdup("-l");
+ argv[3] = g_strdup(dd->spell_dictionary);
+ argv[4] = NULL;
+
+ dict_clear_text_buffer(dd);
+
+ if (g_spawn_async_with_pipes(NULL, argv, NULL,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, NULL,
+ &stdin_fd, &stdout_fd, &stderr_fd, &error))
+ {
+ set_up_io_channel(stdin_fd, G_IO_OUT, iofunc_write, word);
+ set_up_io_channel(stdout_fd, G_IO_IN|G_IO_PRI|G_IO_HUP|G_IO_ERR|G_IO_NVAL, iofunc_read, dd);
+ set_up_io_channel(stderr_fd, G_IO_IN|G_IO_PRI|G_IO_HUP|G_IO_ERR|G_IO_NVAL, iofunc_read_err, dd);
+ dict_status_add(dd, _("Ready."));
+ }
+ else
+ {
+ dict_status_add(dd, _("Process failed (%s)"), error->message);
+ g_error_free(error);
+ error = NULL;
+ }
+
+ g_strfreev(argv);
+}
Property changes on: xfce4-dict/trunk/lib/aspell.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: xfce4-dict/trunk/lib/aspell.h
===================================================================
--- xfce4-dict/trunk/lib/aspell.h (rev 0)
+++ xfce4-dict/trunk/lib/aspell.h 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,27 @@
+/* $Id$
+ *
+ * Copyright 2006-2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ *
+ * 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 Library 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 ASPELL_H
+#define ASPELL_H 1
+
+void dict_start_aspell_query(DictData *dd, const gchar *word);
+
+
+#endif
Property changes on: xfce4-dict/trunk/lib/aspell.h
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: xfce4-dict/trunk/lib/common.c
===================================================================
--- xfce4-dict/trunk/lib/common.c (rev 0)
+++ xfce4-dict/trunk/lib/common.c 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,1102 @@
+/* $Id$
+ *
+ * Copyright 2006-2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ *
+ * 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 Library 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.
+ */
+
+
+/* All files in lib/ form a collection of common used code by the xfce4-dict stand-alone
+ * application and the xfce4-dict-plugin.
+ * This file contains very common code and has some glue to combine the aspell query code,
+ * the dictd server query code and the web dictionary code together. */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <gtk/gtk.h>
+
+#include <libxfcegui4/libxfcegui4.h>
+
+
+
+/* Simple forward declaration to avoid inclusion of libxfce4panel headers */
+typedef struct XfcePanelPlugin_t XfcePanelPlugin;
+
+#include "common.h"
+#include "aspell.h"
+#include "dictd.h"
+#include "inline-icon.h"
+
+
+
+/* the following extern declared functions are called here for interaction with the panel
+ * plugin (if in use) and to avoid to require linkage to libxfce4panel */
+extern void dict_panel_plugin_save_settings(DictData *dd);
+extern void dict_panel_plugin_unblock(DictData *dd);
+
+
+
+/* TODO make me UTF-8 safe */
+static gint dict_str_pos(const gchar *haystack, const gchar *needle)
+{
+ gint haystack_length = strlen(haystack);
+ gint needle_length = strlen(needle);
+ gint i, j, pos = -1;
+
+ if (needle_length > haystack_length)
+ {
+ return -1;
+ }
+ else
+ {
+ for (i = 0; (i < haystack_length) && pos == -1; i++)
+ {
+ if (haystack[i] == needle[0] && needle_length == 1) return i;
+ else if (haystack[i] == needle[0])
+ {
+ for (j = 1; (j < needle_length); j++)
+ {
+ if (haystack[i+j] == needle[j])
+ {
+ if (pos == -1) pos = i;
+ }
+ else
+ {
+ pos = -1;
+ break;
+ }
+ }
+ }
+ }
+ return pos;
+ }
+}
+
+
+/* Replaces all occurrences of needle in haystack with replacement.
+ * All strings have to be NULL-terminated and needle and replacement have to be different,
+ * e.g. needle "%" and replacement "%%" causes an endless loop */
+static gchar *dict_str_replace(gchar *haystack, const gchar *needle, const gchar *replacement)
+{
+ gint i;
+ gchar *start;
+ gint lt_pos;
+ gchar *result;
+ GString *str;
+
+ if (haystack == NULL)
+ return NULL;
+
+ if (needle == NULL || replacement == NULL)
+ return haystack;
+
+ if (strcmp(needle, replacement) == 0)
+ return haystack;
+
+ start = strstr(haystack, needle);
+ lt_pos = dict_str_pos(haystack, needle);
+
+ if (start == NULL || lt_pos == -1)
+ return haystack;
+
+ /* substitute by copying */
+ str = g_string_sized_new(strlen(haystack));
+ for (i = 0; i < lt_pos; i++)
+ {
+ g_string_append_c(str, haystack[i]);
+ }
+ g_string_append(str, replacement);
+ g_string_append(str, haystack + lt_pos + strlen(needle));
+
+ result = str->str;
+ g_free(haystack);
+ g_string_free(str, FALSE);
+ return dict_str_replace(result, needle, replacement);
+}
+
+
+void dict_set_panel_entry_text(DictData *dd, const gchar *text)
+{
+ if (dd->panel_entry != NULL)
+ gtk_entry_set_text(GTK_ENTRY(dd->panel_entry), text);
+}
+
+
+void dict_show_main_window(DictData *dd)
+{
+ gtk_widget_show(dd->window);
+ gtk_window_deiconify(GTK_WINDOW(dd->window));
+ gtk_window_present(GTK_WINDOW(dd->window));
+}
+
+
+void dict_status_add(DictData *dd, const gchar *format, ...)
+{
+ static gchar string[512];
+ va_list args;
+
+ string[0] = ' ';
+ va_start(args, format);
+ g_vsnprintf(string + 1, (sizeof string) - 1, format, args);
+ va_end(args);
+
+ gtk_statusbar_pop(GTK_STATUSBAR(dd->statusbar), 1);
+ gtk_statusbar_push(GTK_STATUSBAR(dd->statusbar), 1, string);
+}
+
+
+void dict_clear_text_buffer(DictData *dd)
+{
+ GtkTextIter start_iter, end_iter;
+
+ /* clear the TextBuffer */
+ gtk_text_buffer_get_start_iter(dd->main_textbuffer, &start_iter);
+ gtk_text_buffer_get_end_iter(dd->main_textbuffer, &end_iter);
+ gtk_text_buffer_delete(dd->main_textbuffer, &start_iter, &end_iter);
+}
+
+
+/* taken from xarchiver, thanks Giuseppe */
+static gboolean dict_open_browser(DictData *dd, const gchar *uri)
+{
+ gchar *argv[3];
+ gchar *browser_path;
+ gboolean result = FALSE;
+
+ browser_path = g_find_program_in_path("exo-open");
+ if (browser_path == NULL)
+ browser_path = g_find_program_in_path("htmlview");
+ if (browser_path == NULL)
+ browser_path = g_find_program_in_path("firefox");
+ if (browser_path == NULL)
+ browser_path = g_find_program_in_path("mozilla");
+ if (browser_path == NULL)
+ browser_path = g_find_program_in_path("opera");
+ if (browser_path == NULL)
+ browser_path = g_find_program_in_path("epiphany");
+ if (browser_path == NULL)
+ browser_path = g_find_program_in_path("konqueror");
+ if (browser_path == NULL)
+ browser_path = g_find_program_in_path("seamonkey");
+
+ if (browser_path == NULL) return FALSE;
+
+ argv[0] = browser_path;
+ argv[1] = (gchar*) uri;
+ argv[2] = NULL;
+
+ result = gdk_spawn_on_screen(gtk_widget_get_screen(GTK_WIDGET(dd->plugin)), NULL, argv, NULL,
+ G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
+
+ g_free (browser_path);
+
+ return result;
+}
+
+
+static gboolean dict_start_web_query(DictData *dd, const gchar *word)
+{
+ gboolean use_leo = FALSE;
+ gboolean success = TRUE;
+ gchar *uri, *base;
+
+ switch (dd->web_mode)
+ {
+ case WEBMODE_LEO_GERENG:
+ {
+ base = "http://dict.leo.org/ende?search={word}";
+ use_leo = TRUE;
+ break;
+ }
+ case WEBMODE_LEO_GERFRE:
+ {
+ base = "http://dict.leo.org/frde?search={word}";
+ use_leo = TRUE;
+ break;
+ }
+ case WEBMODE_LEO_GERSPA:
+ {
+ base = "http://dict.leo.org/esde?search={word}";
+ use_leo = TRUE;
+ break;
+ }
+ default: base = dd->web_url;
+ }
+
+ if (use_leo)
+ {
+ /* convert the text into ISO-8869-15 because dict.leo.org expects it ;-( */
+ gchar *tmp = g_convert(dd->searched_word, -1,
+ "ISO-8859-15", "UTF-8", NULL, NULL, NULL);
+ if (tmp != NULL)
+ {
+ g_free(dd->searched_word);
+ dd->searched_word = tmp;
+ }
+ }
+ uri = dict_str_replace(g_strdup(base), "{word}", dd->searched_word);
+ if (! dict_open_browser(dd, uri))
+ {
+ xfce_err(_("Browser could not be opened. Please check your preferences."));
+ success = FALSE;
+ }
+ g_free(uri);
+
+ return success;
+}
+
+
+void dict_search_word(DictData *dd, const gchar *word)
+{
+ gboolean browser_started = FALSE;
+
+ /* sanity checks */
+ if (! NZV(word))
+ {
+ dict_status_add(dd, _("Invalid input."));
+ return;
+ }
+
+ g_free(dd->searched_word);
+ if (! g_utf8_validate(word, -1, NULL))
+ { /* try to convert non-UTF8 input otherwise stop the query */
+ dd->searched_word = g_locale_to_utf8(word, -1, NULL, NULL, NULL);
+ if (dd->searched_word == NULL || ! g_utf8_validate(dd->searched_word, -1, NULL))
+ {
+ dict_status_add(dd, _("Invalid non-UTF8 input."));
+ gtk_entry_set_text(GTK_ENTRY(dd->main_entry), "");
+ dict_set_panel_entry_text(dd, "");
+ return;
+ }
+ gtk_entry_set_text(GTK_ENTRY(dd->main_entry), dd->searched_word);
+ dict_set_panel_entry_text(dd, dd->searched_word);
+ }
+ else
+ {
+ dd->searched_word = g_strdup(word);
+ }
+
+ switch (dd->mode)
+ {
+ case DICTMODE_DICT:
+ {
+ dict_start_server_query(dd, dd->searched_word);
+ break;
+ }
+ case DICTMODE_WEB:
+ {
+ browser_started = dict_start_web_query(dd, dd->searched_word);
+ break;
+ }
+ case DICTMODE_SPELL:
+ {
+ /* TODO search only for the first word when working on a sentence,
+ * workout a better solution */
+ gchar *first_word_end = dd->searched_word;
+ if ((first_word_end = strchr(dd->searched_word, ' ')) ||
+ (first_word_end = strchr(dd->searched_word, '-')) ||
+ (first_word_end = strchr(dd->searched_word, '_')) ||
+ (first_word_end = strchr(dd->searched_word, '.')) ||
+ (first_word_end = strchr(dd->searched_word, ',')))
+ {
+ *first_word_end = '\0';
+ }
+
+ dict_start_aspell_query(dd, dd->searched_word);
+ break;
+ }
+ }
+
+ /* If we started a web search, the browser was successfully started and we are not in the
+ * stand-alone app, then hide the main window in favour of the started browser.
+ * If we are in the stand-alone app, don't hide the main window, we don't want this */
+ if (browser_started && dd->plugin != NULL)
+ {
+ gtk_widget_hide(dd->window);
+ }
+ else
+ {
+ dict_show_main_window(dd);
+ }
+}
+
+
+void dict_read_rc_file(DictData *dd)
+{
+ XfceRc *rc;
+ gint mode = DICTMODE_DICT;
+ gint webmode = WEBMODE_LEO_GERENG;
+ gint port = 2628;
+ gint panel_entry_size = 120;
+ gboolean show_panel_entry = FALSE;
+ const gchar *server = "dict.org";
+ const gchar *dict = "*";
+ const gchar *weburl = NULL;
+ const gchar *spell_bin = "aspell";
+ const gchar *spell_dictionary = "en";
+
+ if ((rc = xfce_rc_config_open(XFCE_RESOURCE_CONFIG, "xfce4-dict/xfce4-dict.rc", TRUE)) != NULL)
+ {
+ mode = xfce_rc_read_int_entry(rc, "mode", mode);
+ webmode = xfce_rc_read_int_entry(rc, "web_mode", webmode);
+ weburl = xfce_rc_read_entry(rc, "web_url", weburl);
+ show_panel_entry = xfce_rc_read_bool_entry(rc, "show_panel_entry", show_panel_entry);
+ panel_entry_size = xfce_rc_read_int_entry(rc, "panel_entry_size", panel_entry_size);
+ port = xfce_rc_read_int_entry(rc, "port", port);
+ server = xfce_rc_read_entry(rc, "server", server);
+ dict = xfce_rc_read_entry(rc, "dict", dict);
+ spell_bin = xfce_rc_read_entry(rc, "spell_bin", spell_bin);
+ spell_dictionary = xfce_rc_read_entry(rc, "spell_dictionary", spell_dictionary);
+
+ xfce_rc_close(rc);
+ }
+
+ dd->mode = mode;
+ dd->web_mode = webmode;
+ dd->web_url = g_strdup(weburl);
+ dd->show_panel_entry = show_panel_entry;
+ dd->panel_entry_size = panel_entry_size;
+ dd->port = port;
+ dd->server = g_strdup(server);
+ dd->dictionary = g_strdup(dict);
+ dd->spell_bin = g_strdup(spell_bin);
+ dd->spell_dictionary = g_strdup(spell_dictionary);
+}
+
+
+void dict_write_rc_file(DictData *dd)
+{
+ XfceRc *rc;
+
+ if ((rc = xfce_rc_config_open(XFCE_RESOURCE_CONFIG, "xfce4-dict/xfce4-dict.rc", FALSE)) != NULL)
+ {
+ xfce_rc_write_int_entry(rc, "mode", dd->mode);
+ xfce_rc_write_int_entry(rc, "web_mode", dd->web_mode);
+ if (dd->web_url != NULL)
+ xfce_rc_write_entry(rc, "web_url", dd->web_url);
+ xfce_rc_write_bool_entry(rc, "show_panel_entry", dd->show_panel_entry);
+ xfce_rc_write_int_entry(rc, "panel_entry_size", dd->panel_entry_size);
+ xfce_rc_write_int_entry(rc, "port", dd->port);
+ xfce_rc_write_entry(rc, "server", dd->server);
+ xfce_rc_write_entry(rc, "dict", dd->dictionary);
+ xfce_rc_write_entry(rc, "spell_bin", dd->spell_bin);
+ xfce_rc_write_entry(rc, "spell_dictionary", dd->spell_dictionary);
+
+ xfce_rc_close(rc);
+ }
+}
+
+
+void dict_free_data(DictData *dd)
+{
+ if (dd->plugin != NULL)
+ {
+ /* Destroy the setting dialog, if this open */
+ GtkWidget *dialog = g_object_get_data(G_OBJECT(dd->plugin), "dialog");
+ if (dialog)
+ gtk_widget_destroy(dialog);
+ }
+
+ gtk_widget_destroy(dd->window);
+
+ dict_write_rc_file(dd);
+ g_free(dd->searched_word);
+ g_free(dd->dictionary);
+ g_free(dd->server);
+ g_free(dd->web_url);
+ g_free(dd->spell_bin);
+
+ if (dd->icon != NULL)
+ g_object_unref(dd->icon);
+ if (dd->tooltips != NULL)
+ gtk_object_sink(GTK_OBJECT(dd->tooltips));
+
+ g_free(dd);
+}
+
+
+
+
+static void dict_properties_dialog_response(GtkWidget *dlg, gint response, DictData *dd)
+{
+ g_object_set_data(G_OBJECT(dd->plugin), "dialog", NULL);
+
+ if (response == GTK_RESPONSE_OK)
+ {
+ gchar *tmp;
+ /* MODE DICT */
+ tmp = gtk_combo_box_get_active_text(GTK_COMBO_BOX(dd->dict_combo));
+ if (tmp == NULL || tmp[0] == '0' || tmp[0] == '-')
+ {
+ xfce_err(_("You have chosen an invalid dictionary entry."));
+ g_free(tmp);
+ return;
+ }
+
+ dd->port = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(dd->port_spinner));
+
+ g_free(dd->server);
+ dd->server = g_strdup(gtk_entry_get_text(GTK_ENTRY(dd->server_entry)));
+
+ g_free(dd->dictionary);
+ dd->dictionary = tmp;
+
+ /* MODE WEB */
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dd->web_radio_leo_gereng)))
+ dd->web_mode = WEBMODE_LEO_GERENG;
+ else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dd->web_radio_leo_gerfre)))
+ dd->web_mode = WEBMODE_LEO_GERFRE;
+ else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dd->web_radio_leo_gerspa)))
+ dd->web_mode = WEBMODE_LEO_GERSPA;
+ else
+ {
+ dd->web_mode = WEBMODE_OTHER;
+
+ g_free(dd->web_url);
+ dd->web_url = g_strdup(gtk_entry_get_text(GTK_ENTRY(dd->web_entry)));
+ }
+
+ /* MODE SPELL */
+ tmp = gtk_combo_box_get_active_text(GTK_COMBO_BOX(dd->spell_combo));
+ if (NZV(tmp))
+ {
+ g_free(dd->spell_dictionary);
+ dd->spell_dictionary = tmp;
+ }
+
+ g_free(dd->spell_bin);
+ dd->spell_bin = g_strdup(gtk_entry_get_text(GTK_ENTRY(dd->spell_entry)));
+
+ /* general settings */
+ dd->show_panel_entry = gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(dd->check_panel_entry));
+ dd->panel_entry_size = gtk_spin_button_get_value_as_int(
+ GTK_SPIN_BUTTON(dd->panel_entry_size_spinner));
+
+ if (dd->plugin != NULL)
+ dict_panel_plugin_save_settings(dd);
+
+ /* save settings */
+ dict_write_rc_file(dd);
+ }
+ gtk_widget_destroy(dlg);
+
+ if (dd->plugin != NULL)
+ dict_panel_plugin_unblock(dd);
+}
+
+
+static void dict_show_panel_entry_toggled(GtkToggleButton *tb, DictData *dd)
+{
+ gtk_widget_set_sensitive(dd->panel_entry_size_spinner, gtk_toggle_button_get_active(tb));
+ gtk_widget_set_sensitive(dd->panel_entry_size_label, gtk_toggle_button_get_active(tb));
+}
+
+
+static void dict_use_webserver_toggled(GtkToggleButton *tb, DictData *dd)
+{
+ gtk_widget_set_sensitive(dd->web_entry, gtk_toggle_button_get_active(tb));
+ gtk_widget_set_sensitive(dd->web_entry_label, gtk_toggle_button_get_active(tb));
+}
+
+
+void dict_get_spell_dictionaries(DictData *dd)
+{
+ if (NZV(dd->spell_bin))
+ {
+ gchar *tmp = NULL, *cmd, *locale_cmd;
+
+ cmd = g_strconcat(dd->spell_bin, " dump dicts", NULL);
+ locale_cmd = g_locale_from_utf8(cmd, -1, NULL, NULL, NULL);
+ if (locale_cmd == NULL)
+ locale_cmd = g_strdup(cmd);
+ g_spawn_command_line_sync(locale_cmd, &tmp, NULL, NULL, NULL);
+ if (NZV(tmp))
+ {
+ gchar **list = g_strsplit_set(tmp, "\n\r", -1);
+ gchar *item;
+ guint i, len = g_strv_length(list);
+ for (i = 0; i < len; i++)
+ {
+ item = g_strstrip(list[i]);
+ gtk_combo_box_append_text(GTK_COMBO_BOX(dd->spell_combo), item);
+ if (strcmp(dd->spell_dictionary, item) == 0)
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dd->spell_combo), i);
+ }
+ g_strfreev(list);
+ }
+
+ g_free(cmd);
+ g_free(locale_cmd);
+ g_free(tmp);
+ }
+}
+
+
+void dict_properties_dialog(DictData *dd)
+{
+ GtkWidget *dlg, *header, *vbox, *label3, *parent;
+
+ parent = (dd->plugin != NULL) ? GTK_WIDGET(dd->plugin) : dd->window;
+
+ dlg = gtk_dialog_new_with_buttons(_("Properties"),
+ GTK_WINDOW(gtk_widget_get_toplevel(parent)),
+ GTK_DIALOG_DESTROY_WITH_PARENT |
+ GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
+ NULL);
+
+ if (dd->plugin != NULL)
+ g_object_set_data(G_OBJECT(dd->plugin), "dialog", dlg);
+
+ gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER);
+
+ g_signal_connect(dlg, "response", G_CALLBACK(dict_properties_dialog_response), dd);
+
+ gtk_container_set_border_width(GTK_CONTAINER(dlg), 2);
+
+ header = xfce_create_header(NULL, _("Dictionary plugin"));
+ gtk_container_set_border_width(GTK_CONTAINER(header), 6);
+ gtk_widget_show(header);
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG (dlg)->vbox), header, FALSE, TRUE, 0);
+
+ vbox = gtk_vbox_new(FALSE, 3);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 6);
+ gtk_widget_show(vbox);
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dlg)->vbox), vbox, TRUE, TRUE, 0);
+
+ /*
+ * Mode: DICT
+ */
+ {
+ GtkWidget *label1, *label2, *table, *button_get_list, *frame1;
+
+ /* server address */
+ label1 = gtk_label_new_with_mnemonic(_("Server:"));
+ gtk_widget_show(label1);
+
+ dd->server_entry = gtk_entry_new();
+ gtk_entry_set_max_length(GTK_ENTRY(dd->server_entry), 256);
+ if (dd->server != NULL)
+ {
+ gtk_entry_set_text(GTK_ENTRY(dd->server_entry), dd->server);
+ }
+ gtk_widget_show(dd->server_entry);
+
+ /* server port */
+ label2 = gtk_label_new_with_mnemonic(_("Server Port:"));
+ gtk_widget_show(label2);
+
+ dd->port_spinner = gtk_spin_button_new_with_range(0.0, 65536.0, 1.0);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(dd->port_spinner), dd->port);
+ gtk_widget_show(dd->port_spinner);
+
+ /* dictionary */
+ label3 = gtk_label_new_with_mnemonic(_("Dictionary:"));
+ gtk_widget_show(label3);
+
+ dd->dict_combo = gtk_combo_box_new_text();
+ gtk_combo_box_append_text(GTK_COMBO_BOX(dd->dict_combo), _("* (use all)"));
+ gtk_combo_box_append_text(GTK_COMBO_BOX(dd->dict_combo),
+ _("! (use all, stop after first match)"));
+ gtk_combo_box_append_text(GTK_COMBO_BOX(dd->dict_combo), "----------------");
+ if (dd->dictionary != NULL)
+ {
+ if (dd->dictionary[0] == '*')
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dd->dict_combo), 0);
+ else if (dd->dictionary[0] == '!')
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dd->dict_combo), 1);
+ else
+ {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(dd->dict_combo), dd->dictionary);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dd->dict_combo), 3);
+ }
+ }
+
+ gtk_widget_show(dd->dict_combo);
+
+ button_get_list = gtk_button_new_from_stock("gtk-find");
+ gtk_widget_show(button_get_list);
+ g_signal_connect(button_get_list, "clicked", G_CALLBACK(dict_get_dict_list_cb), dd);
+
+
+ /* put it all together */
+ table = gtk_table_new(3, 3, FALSE);
+ gtk_widget_show(table);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 5);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 5);
+
+ gtk_table_attach(GTK_TABLE(table), label1, 0, 1, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 5, 5);
+ gtk_misc_set_alignment(GTK_MISC(label1), 1, 0);
+
+ gtk_table_attach(GTK_TABLE(table), dd->server_entry, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 5, 5);
+
+ gtk_table_attach(GTK_TABLE(table), label2, 0, 1, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 5, 0);
+ gtk_misc_set_alignment(GTK_MISC(label2), 1, 0);
+
+ gtk_table_attach(GTK_TABLE(table), dd->port_spinner, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 5, 5);
+
+ gtk_table_attach(GTK_TABLE(table), label3, 0, 1, 2, 3,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 5, 0);
+ gtk_misc_set_alignment(GTK_MISC(label3), 1, 0);
+
+ gtk_table_attach(GTK_TABLE(table), dd->dict_combo, 1, 2, 2, 3,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ gtk_table_attach(GTK_TABLE(table), button_get_list, 2, 3, 2, 3,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 5, 5);
+
+
+ frame1 = gtk_frame_new(_("Use a DICT server"));
+ gtk_frame_set_shadow_type(GTK_FRAME(frame1), GTK_SHADOW_ETCHED_OUT);
+ gtk_widget_show(frame1);
+ gtk_container_set_border_width(GTK_CONTAINER(frame1), 3);
+ gtk_container_add(GTK_CONTAINER(frame1), table);
+ gtk_box_pack_start(GTK_BOX(vbox), frame1, FALSE, FALSE, 0);
+ }
+
+ /*
+ * Mode: WEB
+ */
+ {
+ GtkWidget *web_vbox, *entry_hbox, *help_label, *frame2;
+ GSList *web_type;
+
+ web_vbox = gtk_vbox_new(FALSE, 5);
+ gtk_widget_show(web_vbox);
+
+ dd->web_radio_leo_gereng = gtk_radio_button_new_with_label(NULL,
+ _("dict.leo.org - German <-> English"));
+ web_type = gtk_radio_button_get_group(GTK_RADIO_BUTTON(dd->web_radio_leo_gereng));
+ if (dd->web_mode == WEBMODE_LEO_GERENG)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dd->web_radio_leo_gereng), TRUE);
+ gtk_widget_show(dd->web_radio_leo_gereng);
+ gtk_box_pack_start(GTK_BOX(web_vbox), dd->web_radio_leo_gereng, FALSE, FALSE, 0);
+
+ dd->web_radio_leo_gerfre = gtk_radio_button_new_with_label(web_type,
+ _("dict.leo.org - German <-> French"));
+ web_type = gtk_radio_button_get_group(GTK_RADIO_BUTTON(dd->web_radio_leo_gerfre));
+ if (dd->web_mode == WEBMODE_LEO_GERFRE)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dd->web_radio_leo_gerfre), TRUE);
+ gtk_widget_show(dd->web_radio_leo_gerfre);
+ gtk_box_pack_start(GTK_BOX(web_vbox), dd->web_radio_leo_gerfre, FALSE, FALSE, 0);
+
+ dd->web_radio_leo_gerspa = gtk_radio_button_new_with_label(web_type,
+ _("dict.leo.org - German <-> Spanish"));
+ web_type = gtk_radio_button_get_group(GTK_RADIO_BUTTON(dd->web_radio_leo_gerspa));
+ if (dd->web_mode == WEBMODE_LEO_GERSPA)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dd->web_radio_leo_gerspa), TRUE);
+ gtk_widget_show(dd->web_radio_leo_gerspa);
+ gtk_box_pack_start(GTK_BOX(web_vbox), dd->web_radio_leo_gerspa, FALSE, FALSE, 0);
+
+ dd->web_radio_other = gtk_radio_button_new_with_label(web_type, _("Use another website"));
+ if (dd->web_mode == WEBMODE_OTHER)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dd->web_radio_other), TRUE);
+ gtk_widget_show(dd->web_radio_other);
+ g_signal_connect(G_OBJECT(dd->web_radio_other), "toggled",
+ G_CALLBACK(dict_use_webserver_toggled), dd);
+ gtk_box_pack_start(GTK_BOX(web_vbox), dd->web_radio_other, FALSE, FALSE, 0);
+
+ dd->web_entry_label = gtk_label_new_with_mnemonic(_("URL:"));
+ gtk_widget_show(dd->web_entry_label);
+ dd->web_entry = gtk_entry_new();
+ if (dd->web_url != NULL)
+ gtk_entry_set_text(GTK_ENTRY(dd->web_entry), dd->web_url);
+ gtk_widget_show(dd->web_entry);
+
+ entry_hbox = gtk_hbox_new(FALSE, 0);
+ gtk_widget_show(entry_hbox);
+ gtk_box_pack_start(GTK_BOX(entry_hbox), dd->web_entry_label, FALSE, TRUE, 5);
+ gtk_box_pack_start(GTK_BOX(entry_hbox), dd->web_entry, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(web_vbox), entry_hbox, FALSE, FALSE, 0);
+
+ help_label = gtk_label_new(_("Enter an URL to a web site which offer translation services.\nUse {word} as placeholder for the searched word."));
+ gtk_label_set_line_wrap(GTK_LABEL(help_label), TRUE);
+ gtk_misc_set_alignment(GTK_MISC(help_label), 0, 0);
+ gtk_widget_show(help_label);
+ gtk_box_pack_start(GTK_BOX(web_vbox), help_label, TRUE, TRUE, 0);
+
+ frame2 = gtk_frame_new(_("Use a web site"));
+ gtk_frame_set_shadow_type(GTK_FRAME(frame2), GTK_SHADOW_ETCHED_OUT);
+ gtk_widget_show(frame2);
+ gtk_container_set_border_width(GTK_CONTAINER(frame2), 3);
+ gtk_container_add(GTK_CONTAINER(frame2), web_vbox);
+ gtk_box_pack_start(GTK_BOX(vbox), frame2, TRUE, TRUE, 0);
+ }
+
+ /*
+ * Mode: ASPELL
+ */
+ {
+ GtkWidget *label4, *label5, *table, *frame3;
+
+ label4 = gtk_label_new_with_mnemonic(_("Aspell program:"));
+ gtk_widget_show(label4);
+
+ dd->spell_entry = gtk_entry_new();
+ gtk_entry_set_max_length(GTK_ENTRY(dd->spell_entry), 256);
+ if (dd->spell_bin != NULL)
+ {
+ gtk_entry_set_text(GTK_ENTRY(dd->spell_entry), dd->spell_bin);
+ }
+ gtk_widget_show(dd->spell_entry);
+
+ label5 = gtk_label_new_with_mnemonic(_("Dictionary:"));
+ gtk_widget_show(label5);
+
+ dd->spell_combo = gtk_combo_box_new_text();
+ dict_get_spell_dictionaries(dd);
+ gtk_widget_show(dd->spell_combo);
+
+ table = gtk_table_new(2, 2, FALSE);
+ gtk_widget_show(table);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 5);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 5);
+
+ gtk_table_attach(GTK_TABLE(table), label4, 0, 1, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 5, 5);
+ gtk_misc_set_alignment(GTK_MISC(label4), 1, 0);
+
+ gtk_table_attach(GTK_TABLE(table), dd->spell_entry, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
+ (GtkAttachOptions) (0), 5, 5);
+
+ gtk_table_attach(GTK_TABLE(table), label5, 0, 1, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 5, 0);
+ gtk_misc_set_alignment(GTK_MISC(label5), 1, 0);
+
+ gtk_table_attach(GTK_TABLE(table), dd->spell_combo, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
+ (GtkAttachOptions) (0), 5, 5);
+
+ frame3 = gtk_frame_new(_("Use Aspell"));
+ gtk_frame_set_shadow_type(GTK_FRAME(frame3), GTK_SHADOW_ETCHED_OUT);
+ gtk_widget_show(frame3);
+ gtk_container_set_border_width(GTK_CONTAINER(frame3), 3);
+ gtk_container_add(GTK_CONTAINER(frame3), table);
+ gtk_box_pack_start(GTK_BOX(vbox), frame3, TRUE, FALSE, 0);
+ }
+
+ /* Display text entry in the panel */
+ {
+ GtkWidget *pe_hbox, *label;
+
+ /* show panel entry check box */
+ dd->check_panel_entry = gtk_check_button_new_with_label(
+ _("Show text field in the panel"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dd->check_panel_entry), dd->show_panel_entry);
+ gtk_tooltips_set_tip(dd->tooltips, dd->check_panel_entry,
+ _("This option can only be used when the panel has a horizontal orientation."), NULL);
+ gtk_widget_show(dd->check_panel_entry);
+ g_signal_connect(G_OBJECT(dd->check_panel_entry), "toggled",
+ G_CALLBACK(dict_show_panel_entry_toggled), dd);
+
+ /* panel entry size */
+ dd->panel_entry_size_label = gtk_label_new_with_mnemonic(_("Text field size:"));
+ gtk_widget_show(dd->panel_entry_size_label);
+ dd->panel_entry_size_spinner = gtk_spin_button_new_with_range(0.0, 500.0, 1.0);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(dd->panel_entry_size_spinner),
+ dd->panel_entry_size);
+ gtk_widget_show(dd->panel_entry_size_spinner);
+
+ pe_hbox = gtk_hbox_new(FALSE, 0);
+ gtk_widget_show(pe_hbox);
+
+ gtk_box_pack_start(GTK_BOX(pe_hbox), dd->panel_entry_size_label, FALSE, FALSE, 10);
+ gtk_box_pack_start(GTK_BOX(pe_hbox), dd->panel_entry_size_spinner, TRUE, TRUE, 0);
+
+ label = gtk_label_new(""); /* just to make some space, should be done better */
+ gtk_widget_show(label);
+ gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), dd->check_panel_entry, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), pe_hbox, FALSE, FALSE, 0);
+
+ }
+
+ /* init the sensitive widgets */
+ dict_use_webserver_toggled(GTK_TOGGLE_BUTTON(dd->web_radio_other), dd);
+ dict_show_panel_entry_toggled(GTK_TOGGLE_BUTTON(dd->check_panel_entry), dd);
+
+ gtk_widget_show(dlg);
+}
+
+
+void dict_entry_activate_cb(GtkEntry *entry, DictData *dd)
+{
+ const gchar *entered_text;
+
+ if (entry != NULL && GTK_WIDGET(entry) == dd->panel_entry)
+ {
+ entered_text = gtk_entry_get_text(GTK_ENTRY(dd->panel_entry));
+ gtk_entry_set_text(GTK_ENTRY(dd->main_entry), entered_text);
+ }
+ else
+ entered_text = gtk_entry_get_text(GTK_ENTRY(dd->main_entry));
+
+ dict_search_word(dd, entered_text);
+}
+
+
+void dict_entry_button_clicked_cb(GtkButton *button, DictData *dd)
+{
+ dict_entry_activate_cb(NULL, dd);
+ gtk_widget_grab_focus(dd->main_entry);
+}
+
+
+void dict_clear_button_clicked_cb(GtkButton *button, DictData *dd)
+{
+ dict_clear_text_buffer(dd);
+
+ /* clear the entries */
+ gtk_entry_set_text(GTK_ENTRY(dd->main_entry), "");
+ dict_set_panel_entry_text(dd, "");
+
+ dict_status_add(dd, _("Ready."));
+}
+
+
+void dict_search_mode_dict_toggled(GtkToggleButton *togglebutton, DictData *dd)
+{
+ if (gtk_toggle_button_get_active(togglebutton))
+ {
+ dd->mode = DICTMODE_DICT;
+ gtk_widget_grab_focus(dd->main_entry);
+ }
+}
+
+
+void dict_search_mode_web_toggled(GtkToggleButton *togglebutton, DictData *dd)
+{
+ if (gtk_toggle_button_get_active(togglebutton))
+ {
+ dd->mode = DICTMODE_WEB;
+ gtk_widget_grab_focus(dd->main_entry);
+ }
+}
+
+
+void dict_search_mode_spell_toggled(GtkToggleButton *togglebutton, DictData *dd)
+{
+ if (gtk_toggle_button_get_active(togglebutton))
+ {
+ dd->mode = DICTMODE_SPELL;
+ gtk_widget_grab_focus(dd->main_entry);
+ }
+}
+
+
+void dict_create_main_window(DictData *dd)
+{
+ GtkWidget *main_box;
+ GtkWidget *entry_box, *label_box, *entry_label, *entry_button, *clear_button;
+ GtkWidget *sep, *align, *scrolledwindow_results;
+ GdkPixbuf *icon;
+ GtkWidget *method_chooser, *radio, *label;
+
+ dd->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(dd->window), "Xfce Dictionary");
+ gtk_window_set_default_size(GTK_WINDOW(dd->window), 500, 300);
+
+ icon = gdk_pixbuf_new_from_inline(-1, dict_icon_data, FALSE, NULL);
+ gtk_window_set_icon(GTK_WINDOW(dd->window), icon);
+ g_object_unref(icon);
+
+ main_box = gtk_vbox_new(FALSE, 0);
+ gtk_widget_show(main_box);
+ gtk_container_add(GTK_CONTAINER(dd->window), main_box);
+
+ /* entry box (label, entry, buttons) */
+ entry_box = gtk_hbox_new(FALSE, 10);
+ gtk_widget_show(entry_box);
+ gtk_container_set_border_width(GTK_CONTAINER(entry_box), 2);
+ gtk_box_pack_start(GTK_BOX(main_box), entry_box, FALSE, TRUE, 5);
+
+ label_box = gtk_hbox_new(FALSE, 5);
+ gtk_widget_show(label_box);
+ gtk_box_pack_start(GTK_BOX(entry_box), label_box, TRUE, TRUE, 0);
+
+ entry_label = gtk_label_new(_("Text to search:"));
+ gtk_widget_show(entry_label);
+ gtk_misc_set_alignment(GTK_MISC(entry_label), 1, 0.5);
+
+ align = gtk_alignment_new(1, 0.5, 0, 0);
+ gtk_alignment_set_padding(GTK_ALIGNMENT(align), 0, 0, 5, 0);
+ gtk_widget_show(align);
+ gtk_container_add(GTK_CONTAINER(align), entry_label);
+ gtk_box_pack_start(GTK_BOX(label_box), align, FALSE, FALSE, 2);
+
+ dd->main_entry = gtk_entry_new();
+ gtk_widget_show(dd->main_entry);
+ gtk_box_pack_start(GTK_BOX(label_box), dd->main_entry, TRUE, TRUE, 0);
+ g_signal_connect(dd->main_entry, "activate", G_CALLBACK(dict_entry_activate_cb), dd);
+
+ entry_button = gtk_button_new_from_stock("gtk-find");
+ gtk_widget_show(entry_button);
+ gtk_box_pack_start(GTK_BOX(entry_box), entry_button, FALSE, FALSE, 0);
+ g_signal_connect(entry_button, "clicked", G_CALLBACK(dict_entry_button_clicked_cb), dd);
+
+ clear_button = gtk_button_new_from_stock("gtk-clear");
+ gtk_widget_show(clear_button);
+ gtk_box_pack_start(GTK_BOX(entry_box), clear_button, FALSE, FALSE, 0);
+ g_signal_connect(clear_button, "clicked", G_CALLBACK(dict_clear_button_clicked_cb), dd);
+
+ /* just make some space */
+ align = gtk_alignment_new(1, 0.5, 0, 0);
+ gtk_alignment_set_padding(GTK_ALIGNMENT(align), 0, 0, 10, 0);
+ gtk_widget_show(align);
+ gtk_container_add(GTK_CONTAINER(align), gtk_label_new(""));
+ gtk_box_pack_start(GTK_BOX(entry_box), align, FALSE, FALSE, 0);
+
+ dd->close_button = gtk_button_new_from_stock("gtk-close");
+ gtk_widget_show(dd->close_button);
+ gtk_box_pack_end(GTK_BOX(entry_box), dd->close_button, FALSE, FALSE, 2);
+
+ /* insert it here and it will(hopefully) be placed before the Close button */
+ sep = gtk_vseparator_new();
+ gtk_widget_show(sep);
+ gtk_box_pack_end(GTK_BOX(entry_box), sep, FALSE, FALSE, 5);
+
+ /* search method chooser */
+ method_chooser = gtk_hbox_new(FALSE, 0);
+ gtk_widget_show(method_chooser);
+ gtk_box_pack_start(GTK_BOX(main_box), method_chooser, FALSE, FALSE, 0);
+
+ label = gtk_label_new(_("Search with:"));
+ gtk_widget_show(label);
+ gtk_box_pack_start(GTK_BOX(method_chooser), label, FALSE, FALSE, 6);
+
+ radio = gtk_radio_button_new_with_label(NULL, _("Dict"));
+ gtk_widget_show(radio);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), (dd->mode == DICTMODE_DICT));
+ g_signal_connect(radio, "toggled", G_CALLBACK(dict_search_mode_dict_toggled), dd);
+ gtk_box_pack_start(GTK_BOX(method_chooser), radio, FALSE, FALSE, 6);
+
+ radio = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(radio), _("Web"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), (dd->mode == DICTMODE_WEB));
+ g_signal_connect(radio, "toggled", G_CALLBACK(dict_search_mode_web_toggled), dd);
+ gtk_widget_show(radio);
+ gtk_box_pack_start(GTK_BOX(method_chooser), radio, FALSE, FALSE, 6);
+
+ radio = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(radio), _("Spellcheck"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), (dd->mode == DICTMODE_SPELL));
+ g_signal_connect(radio, "toggled", G_CALLBACK(dict_search_mode_spell_toggled), dd);
+ gtk_widget_show(radio);
+ gtk_box_pack_start(GTK_BOX(method_chooser), radio, FALSE, FALSE, 6);
+
+ /* results area */
+ scrolledwindow_results = gtk_scrolled_window_new(NULL, NULL);
+ gtk_widget_show(scrolledwindow_results);
+ gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow_results), 4);
+ gtk_box_pack_start(GTK_BOX(main_box), scrolledwindow_results, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow_results),
+ GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow_results),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ /* searched words textview stuff */
+ dd->main_textview = gtk_text_view_new();
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(dd->main_textview), FALSE);
+ gtk_text_view_set_left_margin(GTK_TEXT_VIEW(dd->main_textview), 5);
+ gtk_text_view_set_right_margin(GTK_TEXT_VIEW(dd->main_textview), 5);
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(dd->main_textview), GTK_WRAP_WORD);
+ dd->main_textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(dd->main_textview));
+ dd->main_boldtag = gtk_text_buffer_create_tag(dd->main_textbuffer,
+ "bold", "weight", PANGO_WEIGHT_BOLD, NULL);
+
+ gtk_widget_show(dd->main_textview);
+ gtk_container_add(GTK_CONTAINER(scrolledwindow_results), dd->main_textview);
+
+ /* status bar */
+ dd->statusbar = gtk_statusbar_new();
+ gtk_widget_show(dd->statusbar);
+ gtk_box_pack_end(GTK_BOX(main_box), dd->statusbar, FALSE, FALSE, 0);
+}
+
+
+const guint8 *dict_get_icon_data(void)
+{
+ return dict_icon_data;
+}
+
+
+void dict_about_dialog(GtkWidget *widget, DictData *dd)
+{
+ GtkWidget *dialog;
+ XfceAboutInfo *info;
+
+ info = xfce_about_info_new("xfce4-dict", VERSION,
+ _("A client program to query different dictionaries."),
+ XFCE_COPYRIGHT_TEXT("2006-2008", "Enrico Tröger"),
+ XFCE_LICENSE_GPL);
+
+ xfce_about_info_add_credit(info, "Enrico Tröger", "enrico(dot)troeger(at)uvena(dot)de", _("Developer"));
+ xfce_about_info_set_homepage(info, "http://goodies.xfce.org");
+
+ dialog = xfce_about_dialog_new_with_values(GTK_WINDOW(widget), info, dd->icon);
+ g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(gtk_widget_destroy), NULL);
+ gtk_window_set_title(GTK_WINDOW(dialog), "Xfce Dictionary");
+ gtk_dialog_run(GTK_DIALOG(dialog));
+
+ xfce_about_info_free(info);
+}
+
+
+void dict_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y,
+ GtkSelectionData *data, guint info, guint ltime, DictData *dd)
+{
+ if ((data->length >= 0) && (data->format == 8))
+ {
+ drag_context->action = GDK_ACTION_COPY;
+
+ if (widget == dd->main_entry)
+ {
+ gtk_entry_set_text(GTK_ENTRY(dd->main_entry), "");
+ }
+ else
+ {
+ gtk_entry_set_text(GTK_ENTRY(dd->main_entry), (const gchar*) data->data);
+ dict_search_word(dd, (const gchar*) data->data);
+ }
+ gtk_drag_finish(drag_context, TRUE, FALSE, ltime);
+ }
+}
+
+
+void dict_signal_cb(gint sig)
+{
+ /* do nothing here and hope we never get called */
+}
+
+
Property changes on: xfce4-dict/trunk/lib/common.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: xfce4-dict/trunk/lib/common.h
===================================================================
--- xfce4-dict/trunk/lib/common.h (rev 0)
+++ xfce4-dict/trunk/lib/common.h 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,127 @@
+/* $Id$
+ *
+ * Copyright 2007-2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ *
+ * 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 Library 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 COMMON_H
+#define COMMON_H 1
+
+
+/* Returns: TRUE if ptr points to a non-zero value. */
+#define NZV(ptr) \
+ ((ptr) && (ptr)[0])
+
+
+typedef enum
+{
+ DICTMODE_DICT = 0,
+ DICTMODE_WEB,
+ DICTMODE_SPELL
+} dict_mode_t;
+
+typedef enum
+{
+ WEBMODE_OTHER,
+ WEBMODE_LEO_GERENG,
+ WEBMODE_LEO_GERFRE,
+ WEBMODE_LEO_GERSPA
+} web_mode_t;
+
+
+enum
+{
+ NO_CONNECTION,
+ NO_ERROR
+};
+
+
+typedef struct
+{
+ XfcePanelPlugin *plugin; /* only used when loaded as panel plugin */
+
+ dict_mode_t mode;
+ web_mode_t web_mode;
+
+ GtkWidget *window;
+ GtkWidget *statusbar;
+ GtkWidget *close_button;
+ GtkWidget *main_entry;
+ GtkWidget *panel_entry;
+ GtkWidget *main_textview;
+ GtkTextBuffer *main_textbuffer;
+ GtkTextTag *main_boldtag;
+
+ GtkWidget *server_entry;
+ GtkWidget *dict_combo;
+ GtkWidget *port_spinner;
+ GtkWidget *panel_entry_size_label;
+ GtkWidget *panel_entry_size_spinner;
+ GtkWidget *check_panel_entry;
+
+ GtkWidget *panel_button;
+ GtkWidget *panel_button_image;
+ GtkTooltips *tooltips;
+
+ gboolean show_panel_entry;
+ gint panel_entry_size;
+ gint port;
+ gchar *server;
+ gchar *dictionary;
+
+ gchar *searched_word; /* word to query the server */
+ gboolean query_is_running;
+ gint query_status;
+ gchar *query_buffer;
+
+ GtkWidget *web_entry_label;
+ GtkWidget *web_entry;
+ GtkWidget *web_radio_leo_gereng;
+ GtkWidget *web_radio_leo_gerfre;
+ GtkWidget *web_radio_leo_gerspa;
+ GtkWidget *web_radio_other;
+ gchar *web_url;
+
+ GtkWidget *spell_entry;
+ GtkWidget *spell_combo;
+ gchar *spell_bin;
+ gchar *spell_dictionary;
+
+ GdkPixbuf *icon;
+} DictData;
+
+
+
+void dict_status_add(DictData *dd, const gchar *format, ...);
+void dict_set_panel_entry_text(DictData *dd, const gchar *text);
+void dict_clear_text_buffer(DictData *dd);
+void dict_free_data(DictData *dd);
+void dict_write_rc_file(DictData *dd);
+void dict_read_rc_file(DictData *dd);
+void dict_search_word(DictData *dd, const gchar *word);
+void dict_show_main_window(DictData *dd);
+void dict_properties_dialog(DictData *dd);
+void dict_about_dialog(GtkWidget *widget, DictData *dd);
+const guint8 *dict_get_icon_data(void);
+void dict_signal_cb(gint sig);
+void dict_create_main_window(DictData *dd);
+void dict_entry_activate_cb(GtkEntry *entry, DictData *dd);
+void dict_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y,
+ GtkSelectionData *data, guint info, guint ltime, DictData *dd);
+
+
+#endif
Property changes on: xfce4-dict/trunk/lib/common.h
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: xfce4-dict/trunk/lib/dictd.c
===================================================================
--- xfce4-dict/trunk/lib/dictd.c (rev 0)
+++ xfce4-dict/trunk/lib/dictd.c 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,400 @@
+/* $Id$
+ *
+ * Copyright 2006-2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ *
+ * 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 Library 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.
+ */
+
+
+/* This file contains all networking related code to query a remote (or local)
+ * dictd server (RFC 2229). */
+/* TODO: This should be more separated from GUI code, sometime. */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <gtk/gtk.h>
+#include <libxfcegui4/libxfcegui4.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <netdb.h>
+#include <netinet/tcp.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <signal.h>
+#include <string.h>
+
+/* Simple forward declaration to avoid inclusion of libxfce4panel headers */
+typedef struct XfcePanelPlugin_t XfcePanelPlugin;
+
+
+#include "common.h"
+#include "dictd.h"
+
+#define BUF_SIZE 256
+
+
+
+static gint dict_open_socket(const gchar *host_name, gint port)
+{
+ struct sockaddr_in addr;
+ struct hostent *host_p;
+ gint fd;
+ gint opt = 1;
+
+ memset((gchar *) &addr, 0, sizeof (addr));
+
+ if ((addr.sin_addr.s_addr = inet_addr(host_name)) == INADDR_NONE)
+ {
+ host_p = gethostbyname(host_name);
+ if (host_p == NULL)
+ return (-1);
+ memcpy((gchar *)(&addr.sin_addr), host_p->h_addr, (size_t)host_p->h_length);
+ }
+
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons((gushort) port);
+
+ if ((fd = socket (AF_INET, SOCK_STREAM, 0)) < 0)
+ return (-1);
+
+ setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (gchar *) &opt, sizeof (opt));
+
+ if (connect(fd, (struct sockaddr *) &addr, sizeof (addr)) != 0)
+ {
+ close(fd);
+ return (-1);
+ }
+ /*fcntl( fd, F_SETFL, O_NONBLOCK );*/
+
+ return (fd);
+}
+
+
+static void dict_send_command(gint fd, const gchar *str)
+{
+ gchar buf[256];
+ gint len = strlen (str);
+
+ g_snprintf(buf, 256, "%s\n", str);
+ send(fd, buf, len + 2, 0);
+}
+
+
+static gboolean dict_process_server_response(DictData *dd)
+{
+ gint max_lines, i;
+ gint defs_found = 0;
+ gchar *answer, *tmp, **lines, *stripped;
+ GtkTextIter iter;
+
+ if (dd->query_status == NO_CONNECTION)
+ {
+ dict_status_add(dd, _("Could not connect to server."));
+ dd->query_status = NO_ERROR;
+ return FALSE;
+ }
+
+ if (dd->query_buffer == NULL || strlen(dd->query_buffer) == 0)
+ {
+ dict_status_add(dd, _("Unknown error while quering the server."));
+ g_free(dd->query_buffer);
+ return FALSE;
+ }
+
+ answer = dd->query_buffer;
+ if (strncmp("220", answer, 3) != 0)
+ {
+ dict_status_add(dd, _("Server not ready."));
+ g_free(dd->query_buffer);
+ return FALSE;
+ }
+
+ /* go to next line */
+ while (*answer != '\n') answer++;
+ answer++;
+
+ if (strncmp("552", answer, 3) == 0)
+ {
+ dict_status_add(dd, _("No matches could be found for \"%s\"."), dd->searched_word);
+ g_free(dd->query_buffer);
+ return FALSE;
+ }
+ else if (strncmp("150", answer, 3) != 0 && strncmp("552", answer, 3) != 0)
+ {
+ dict_status_add(dd, _("Unknown error while quering the server."));
+ g_free(dd->query_buffer);
+ return FALSE;
+ }
+ defs_found = atoi(answer + 4);
+ dict_status_add(dd, _("%d definition(s) found."), defs_found);
+
+ /* go to next line */
+ while (*answer != '\n') answer++;
+ answer++;
+
+ /* parse output */
+ lines = g_strsplit(answer, "\r\n", -1);
+ max_lines = g_strv_length(lines);
+ if (lines == NULL || max_lines == 0)
+ {
+ g_free(dd->query_buffer);
+ return FALSE;
+ }
+
+ gtk_text_buffer_get_start_iter(dd->main_textbuffer, &iter);
+ gtk_text_buffer_insert(dd->main_textbuffer, &iter, "\n", 1);
+
+ i = -1;
+ while (i < max_lines)
+ {
+ i++;
+ if (strncmp(lines[i], "250", 3) == 0) break; /* end of data */
+ if (strncmp(lines[i], "error:", 6) == 0) /* an error occurred */
+ {
+ gtk_text_buffer_insert(dd->main_textbuffer, &iter, lines[i], -1);
+ break;
+ }
+ if (strncmp(lines[i], "151", 3) != 0) continue; /* unexpected line start, try next line */
+
+ /* get the used dictionary */
+ tmp = strchr(lines[i], '"'); /* get the opening " of quoted search word */
+ if (tmp != NULL)
+ {
+ tmp = strchr(tmp + 1, '"'); /* get the closing " of quoted search word */
+ if (tmp != NULL)
+ {
+ /* skip the found quote and the following space */
+ gtk_text_buffer_insert_with_tags(dd->main_textbuffer, &iter, tmp + 2, -1,
+ dd->main_boldtag, NULL);
+ gtk_text_buffer_insert(dd->main_textbuffer, &iter, "\n", 1);
+ }
+ }
+ if (i >= (max_lines - 2)) break;
+
+ /* all following lines represents the translation */
+ i += 2; /* skip the next two lines */
+ while (lines[i] != NULL && lines[i][0] != '.' && lines[i][0] != '\r' && lines[i][0] != '\n')
+ {
+ stripped = g_strstrip(lines[i]);
+ if (strlen(stripped) > 0)
+ {
+ gtk_text_buffer_insert(dd->main_textbuffer, &iter, stripped, -1);
+ if (i < (max_lines - 1) && lines[i + 1][0] != '.')
+ gtk_text_buffer_insert(dd->main_textbuffer, &iter, "\n", 1);
+ }
+ i++;
+ }
+ gtk_text_buffer_insert(dd->main_textbuffer, &iter, "\n\n", 2);
+ }
+ g_strfreev(lines);
+ g_free(dd->query_buffer);
+
+ /* clear the panel entry to not search again when you click on the panel button */
+ dict_set_panel_entry_text(dd, "");
+
+ return FALSE;
+}
+
+
+static gchar *dict_get_answer(gint fd)
+{
+ gboolean fol = FALSE;
+ gboolean sol = FALSE;
+ gboolean tol = FALSE;
+ GString *str = g_string_sized_new(100);
+ gchar c, *tmp;
+ gchar ec[3];
+
+ alarm(10); /* abort after 5 seconds, there should went wrong something */
+ while (read(fd, &c, 1) > 0)
+ {
+ if (tol) /* third char of line */
+ {
+ ec[2] = c;
+ }
+ if (sol) /* second char of line */
+ {
+ ec[1] = c;
+ sol = FALSE;
+ tol = TRUE;
+ }
+ if (fol) /* first char of line */
+ {
+ ec[0] = c;
+ fol = FALSE;
+ sol = TRUE;
+ }
+ if (c == '\n') /* last char of line, so the next run is first char of next line */
+ fol = TRUE;
+
+ g_string_append_c(str, c);
+ if (tol &&
+ (
+ (strncmp(ec, "250", 3) == 0) || /* ok */
+ (strncmp(ec, "554", 3) == 0) || /* no databases present */
+ (strncmp(ec, "500", 3) == 0) || /* unknown command */
+ (strncmp(ec, "501", 3) == 0) || /* syntax error */
+ (strncmp(ec, "552", 3) == 0) /* nothing found */
+ )
+ )
+ break;
+ }
+ alarm(0);
+
+ g_string_append_c(str, '\0');
+ tmp = str->str;
+ g_string_free(str, FALSE);
+
+ return tmp;
+}
+
+
+static void dict_ask_server(DictData *dd)
+{
+ gint fd, i;
+ static gchar cmd[BUF_SIZE];
+
+ if ((fd = dict_open_socket(dd->server, dd->port)) == -1)
+ {
+ dd->query_status = NO_CONNECTION;
+ g_idle_add((GSourceFunc) dict_process_server_response, dd);
+ g_thread_exit(NULL);
+ return;
+ }
+
+ dd->query_is_running = TRUE;
+
+ /* take only the first part of the dictionary string, so let the string end at the space */
+ i = 0;
+ while (dd->dictionary[i] != ' ') i++;
+ dd->dictionary[i] = '\0';
+
+ g_snprintf(cmd, BUF_SIZE, "define %s \"%s\"\n", dd->dictionary, dd->searched_word);
+ dict_send_command(fd, cmd);
+
+ /* and now, "append" again the rest of the dictionary string again */
+ dd->dictionary[i] = ' ';
+
+ dd->query_buffer = dict_get_answer(fd);
+ close(fd);
+
+ dd->query_is_running = FALSE;
+ /* delegate parsing the response and related GUI stuff to GTK's main thread through the main loop */
+ g_idle_add((GSourceFunc) dict_process_server_response, dd);
+
+ g_thread_exit(NULL);
+}
+
+
+void dict_start_server_query(DictData *dd, const gchar *word)
+{
+ if (dd->query_is_running)
+ {
+ gdk_beep();
+ }
+ else
+ {
+ dict_clear_text_buffer(dd);
+
+ dict_status_add(dd, _("Querying the server %s..."), dd->server);
+
+ /* start the thread to query the server */
+ g_thread_create((GThreadFunc) dict_ask_server, dd, FALSE, NULL);
+ }
+}
+
+
+gboolean dict_get_dict_list_cb(GtkWidget *button, DictData *dd)
+{
+ gint fd, i;
+ gint max_lines;
+ gchar *buffer = NULL;
+ gchar *answer = NULL;
+ gchar **lines;
+ const gchar *host;
+ gint port;
+
+ host = gtk_entry_get_text(GTK_ENTRY(dd->server_entry));
+ port = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(dd->port_spinner));
+
+ if ((fd = dict_open_socket(host, port)) == -1)
+ {
+ xfce_err(_("Could not connect to server."));
+ return FALSE;
+ }
+
+ dict_send_command(fd, "show databases");
+
+ /* read all server output */
+ answer = buffer = dict_get_answer(fd);
+ close(fd);
+
+ /* go to next line */
+ while (*buffer != '\n') buffer++;
+ buffer++;
+
+ if (strncmp("554", buffer, 3) == 0)
+ {
+ close(fd);
+ xfce_err(_("The server doesn't offer any databases."));
+ return TRUE;
+ }
+ else if (strncmp("110", buffer, 3) != 0 && strncmp("554", buffer, 3) != 0)
+ {
+ xfce_err(_("Unknown error while quering the server."));
+ close(fd);
+ return FALSE;
+ }
+
+ /* go to next line */
+ while (*buffer != '\n') buffer++;
+ buffer++;
+
+ /* clear the combo box */
+ i = gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(dd->dict_combo)), NULL);
+ for (i -= 1; i > 2; i--) /* first three entries (*, ! and ----) should always exist */
+ {
+ gtk_combo_box_remove_text(GTK_COMBO_BOX(dd->dict_combo), i);
+ }
+
+ /* parse output */
+ lines = g_strsplit(buffer, "\r\n", -1);
+ max_lines = g_strv_length(lines);
+ if (lines == NULL || max_lines == 0) return FALSE;
+
+ i = 0;
+ while (i < max_lines && lines[i][0] != '.')
+ {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(dd->dict_combo), lines[i]);
+ i++;
+ }
+
+ g_strfreev(lines);
+ g_free(answer);
+
+ /* set the active entry to * because we don't know where the previously selected item now is in
+ * the list and we also don't know whether it exists at all, and I don't walk through the list */
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dd->dict_combo), 0);
+
+ return TRUE;
+}
Property changes on: xfce4-dict/trunk/lib/dictd.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: xfce4-dict/trunk/lib/dictd.h
===================================================================
--- xfce4-dict/trunk/lib/dictd.h (rev 0)
+++ xfce4-dict/trunk/lib/dictd.h 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,30 @@
+/* $Id$
+ *
+ * Copyright 2006-2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ *
+ * 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 Library 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 DICTD_H
+#define DICTD_H 1
+
+
+void dict_start_server_query(DictData *dd, const gchar *word);
+
+gboolean dict_get_dict_list_cb(GtkWidget *button, DictData *dd);
+
+
+#endif
Property changes on: xfce4-dict/trunk/lib/dictd.h
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: xfce4-dict/trunk/lib/popup_def.h
===================================================================
--- xfce4-dict/trunk/lib/popup_def.h (rev 0)
+++ xfce4-dict/trunk/lib/popup_def.h 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,38 @@
+/* $Id$
+ *
+ * Copyright 2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ *
+ * 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 Library 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 POPUP_DEF_H
+#define POPUP_DEF_H 1
+
+
+#ifndef XFCE_DICT_WINDOW_MESSAGE
+#define XFCE_DICT_WINDOW_MESSAGE "xfce4-dict"
+#endif
+
+#ifndef XFCE_DICT_TEXTFIELD_MESSAGE
+#define XFCE_DICT_TEXTFIELD_MESSAGE "xfce4-dict-atptr"
+#endif
+
+#ifndef XFCE_DICT_SELECTION
+#define XFCE_DICT_SELECTION "XFCE_DICT_SEL"
+#endif
+
+
+#endif
Property changes on: xfce4-dict/trunk/lib/popup_def.h
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: xfce4-dict/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-dict/trunk/panel-plugin/Makefile.am 2008-03-25 08:20:17 UTC (rev 4116)
+++ xfce4-dict/trunk/panel-plugin/Makefile.am 2008-03-27 19:36:43 UTC (rev 4117)
@@ -1,61 +1,36 @@
plugindir = $(libexecdir)/xfce4/panel-plugins
plugin_PROGRAMS = xfce4-dict-plugin
-bin_PROGRAMS = \
- xfce4-popup-dict
-xfce4_popup_dict_SOURCES = \
- xfce4-popup-dict.c \
- xfce4-popup-dict.h
-
-xfce4_popup_dict_CFLAGS = \
- -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
- $(GTK_CFLAGS) \
- $(PLATFORM_CFLAGS)
-
-xfce4_popup_dict_LDADD = \
- $(GTK_LIBS)
-
-
xfce4_dict_plugin_SOURCES = \
- inline-icon.h \
- aspell.c \
- dict.h \
- dict.c
+ xfce4-dict-plugin.c
xfce4_dict_plugin_CFLAGS = \
-I$(top_srcdir) \
+ -I$(top_srcdir)/lib \
$(LIBXFCEGUI4_CFLAGS) \
$(LIBXFCE4PANEL_CFLAGS) \
- $(EXO_CFLAGS) \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
@GTHREAD_CFLAGS@
xfce4_dict_plugin_LDADD = \
$(LIBXFCE4PANEL_LIBS) \
$(LIBXFCEGUI4_LIBS) \
- $(EXO_LIBS) \
- @GTHREAD_LIBS@
+ @GTHREAD_LIBS@ \
+ $(top_srcdir)/lib/libdict.a
-inline-icon.h: $(srcdir)/dict-icon.svg
- gdk-pixbuf-csource --raw --name=dict_icon_data dict-icon.svg > inline-icon.h
-
desktopdir = $(datadir)/xfce4/panel-plugins
-desktop_in_in_files = dict.desktop.in.in
+desktop_in_in_files = xfce4-dict-plugin.desktop.in.in
desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
%.desktop.in: %.desktop.in.in
sed -e "s,\@libexecdir\@,$(libexecdir),g" < $< > $@
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
-EXTRA_DIST = \
- $(desktop_in_in_files) \
- dict-icon.svg
+EXTRA_DIST = \
+ $(desktop_in_in_files)
-CLEANFILES = \
- $(desktop_in_files) \
+CLEANFILES = \
+ $(desktop_in_files) \
$(desktop_DATA)
-
-hicolor48dir = $(datadir)/icons/hicolor/scalable/apps
-hicolor48_DATA = dict-icon.svg
Deleted: xfce4-dict/trunk/panel-plugin/aspell.c
Deleted: xfce4-dict/trunk/panel-plugin/dict-icon.svg
Deleted: xfce4-dict/trunk/panel-plugin/dict.c
Deleted: xfce4-dict/trunk/panel-plugin/dict.desktop.in.in
Deleted: xfce4-dict/trunk/panel-plugin/dict.h
Deleted: xfce4-dict/trunk/panel-plugin/inline-icon.h
Added: xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c
===================================================================
--- xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c (rev 0)
+++ xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,347 @@
+/* $Id$
+ *
+ * Copyright 2006-2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ *
+ * 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 Library 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <gtk/gtk.h>
+
+#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4panel/xfce-panel-plugin.h>
+#include <libxfce4panel/xfce-panel-convenience.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <netdb.h>
+#include <netinet/tcp.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <signal.h>
+#include <string.h>
+
+#include "common.h"
+#include "popup_def.h"
+
+
+
+static GdkPixbuf *dict_load_and_scale(const guint8 *data, gint dstw, gint dsth)
+{
+ GdkPixbuf *pb, *pb_scaled;
+ int pb_w, pb_h;
+
+ pb = gdk_pixbuf_new_from_inline(-1, data, FALSE, NULL);
+ pb_w = gdk_pixbuf_get_width(pb);
+ pb_h = gdk_pixbuf_get_height(pb);
+
+ if (dstw == pb_w && dsth == pb_h)
+ return(pb);
+ else if (dstw < 0)
+ dstw = (dsth * pb_w) / pb_h;
+ else if (dsth < 0)
+ dsth = (dstw * pb_h) / pb_w;
+
+ pb_scaled = gdk_pixbuf_scale_simple(pb, dstw, dsth, GDK_INTERP_HYPER);
+ g_object_unref(G_OBJECT(pb));
+
+ return (pb_scaled);
+}
+
+
+static gboolean dict_plugin_panel_set_size(XfcePanelPlugin *plugin, gint wsize, DictData *dd)
+{
+ gint width;
+ gint size = wsize - 2 - (2 * MAX(dd->panel_button->style->xthickness,
+ dd->panel_button->style->ythickness));
+
+ /*g_object_unref(G_OBJECT(dd->icon));*/
+ dd->icon = dict_load_and_scale(dict_get_icon_data(), size, -1);
+
+ gtk_image_set_from_pixbuf(GTK_IMAGE(dd->panel_button_image), dd->icon);
+
+ if (dd->show_panel_entry && xfce_panel_plugin_get_orientation(dd->plugin) == GTK_ORIENTATION_HORIZONTAL)
+ {
+ width = size + dd->panel_entry_size;
+ gtk_widget_set_size_request(dd->panel_entry, dd->panel_entry_size, -1);
+ }
+ else
+ width = size;
+
+ gtk_widget_set_size_request(GTK_WIDGET(plugin), width, size);
+
+ return TRUE;
+}
+
+
+/* unused
+static void dict_toggle_main_window(GtkWidget *button, DictData *dd)
+{
+ if (GTK_WIDGET_VISIBLE(dd->window))
+ gtk_widget_hide(dd->window);
+ else
+ {
+ const gchar *panel_text = "";
+
+ if (dd->panel_entry != NULL)
+ panel_text = gtk_entry_get_text(GTK_ENTRY(dd->panel_entry));
+
+ dict_show_main_window(dd);
+ if (NZV(panel_text))
+ {
+ dict_search_word(dd, panel_text);
+ gtk_entry_set_text(GTK_ENTRY(dd->main_entry), panel_text);
+ }
+ gtk_widget_grab_focus(dd->main_entry);
+ }
+}
+*/
+
+
+static void dict_plugin_panel_button_clicked(GtkWidget *button, DictData *dd)
+{
+ if (GTK_WIDGET_VISIBLE(dd->window))
+ gtk_widget_hide(dd->window);
+ else
+ {
+ const gchar *panel_text = gtk_entry_get_text(GTK_ENTRY(dd->panel_entry));
+
+ dict_show_main_window(dd);
+ if (NZV(panel_text))
+ {
+ dict_search_word(dd, panel_text);
+ gtk_entry_set_text(GTK_ENTRY(dd->main_entry), panel_text);
+ }
+ gtk_widget_grab_focus(dd->main_entry);
+ }
+}
+
+
+/* Handle user messages (xfce4-popup-dict) */
+static gboolean dict_plugin_message_received(GtkWidget *w, GdkEventClient *ev, gpointer user_data)
+{
+ DictData *dd = user_data;
+
+ if (ev->data_format == 8 && *(ev->data.b) != '\0')
+ {
+ if (strcmp(XFCE_DICT_WINDOW_MESSAGE, ev->data.b) == 0)
+ { /* open the main window */
+ dict_plugin_panel_button_clicked(NULL, dd);
+ return TRUE;
+ }
+
+ if (strcmp(XFCE_DICT_TEXTFIELD_MESSAGE, ev->data.b) == 0)
+ { /* put the focus onto the panel entry */
+ if (dd->show_panel_entry)
+ xfce_panel_plugin_focus_widget(dd->plugin, dd->panel_entry);
+ }
+ }
+
+ return FALSE;
+}
+
+
+static gboolean dict_plugin_set_selection(DictData *dd)
+{
+ GdkScreen *gscreen;
+ gchar selection_name[32];
+ Atom selection_atom;
+ GtkWidget *win;
+ Window xwin;
+
+ win = gtk_invisible_new();
+ gtk_widget_realize(win);
+ xwin = GDK_WINDOW_XID(GTK_WIDGET(win)->window);
+
+ gscreen = gtk_widget_get_screen(win);
+ g_snprintf(selection_name, sizeof (selection_name),
+ XFCE_DICT_SELECTION"%d", gdk_screen_get_number(gscreen));
+ selection_atom = XInternAtom(GDK_DISPLAY(), selection_name, False);
+
+ if (XGetSelectionOwner(GDK_DISPLAY(), selection_atom))
+ {
+ gtk_widget_destroy(win);
+ return FALSE;
+ }
+
+ XSelectInput(GDK_DISPLAY(), xwin, PropertyChangeMask);
+ XSetSelectionOwner(GDK_DISPLAY(), selection_atom, xwin, GDK_CURRENT_TIME);
+
+ g_signal_connect(G_OBJECT(win), "client-event", G_CALLBACK(dict_plugin_message_received), dd);
+
+ return TRUE;
+}
+
+
+void dict_plugin_close_button_clicked(GtkWidget *button, DictData *dd)
+{
+ gtk_widget_hide(dd->window);
+}
+
+
+static void dict_plugin_free_data(XfcePanelPlugin *plugin, DictData *dd)
+{
+ dict_free_data(dd);
+}
+
+
+static void dict_plugin_panel_change_orientation(
+ XfcePanelPlugin *plugin, GtkOrientation orientation, DictData *dd)
+{
+ if (! dd->show_panel_entry || orientation == GTK_ORIENTATION_VERTICAL)
+ gtk_widget_hide(dd->panel_entry);
+ else
+ gtk_widget_show(dd->panel_entry);
+}
+
+
+static void dict_plugin_style_set(XfcePanelPlugin *plugin, gpointer unused, DictData *dd)
+{
+ dict_plugin_panel_set_size(plugin, xfce_panel_plugin_get_size(plugin), dd);
+}
+
+
+static gboolean dict_panel_entry_buttonpress_cb(GtkWidget *entry, GdkEventButton *event, DictData *dd)
+{
+ GtkWidget *toplevel;
+
+ /* Determine toplevel parent widget */
+ toplevel = gtk_widget_get_toplevel(entry);
+
+ /* Grab entry focus if possible */
+ if (event->button != 3 && toplevel && toplevel->window)
+ xfce_panel_plugin_focus_widget(dd->plugin, entry);
+
+ return FALSE;
+}
+
+
+static void dict_plugin_write_rc_file(XfcePanelPlugin *plugin, DictData *dd)
+{
+ dict_write_rc_file(dd);
+}
+
+
+static void dict_plugin_properties_dialog(XfcePanelPlugin *plugin, DictData *dd)
+{
+ xfce_panel_plugin_block_menu(plugin);
+
+ dict_properties_dialog(dd);
+}
+
+
+/* the following extern declared functions are called in libdict when panel plugin is in use */
+extern void dict_panel_plugin_save_settings(DictData *dd)
+{
+ if (dd->show_panel_entry &&
+ xfce_panel_plugin_get_orientation(dd->plugin) == GTK_ORIENTATION_HORIZONTAL)
+ {
+ gtk_widget_show(dd->panel_entry);
+ }
+ else
+ gtk_widget_hide(dd->panel_entry);
+
+ dict_plugin_panel_set_size(dd->plugin, xfce_panel_plugin_get_size(dd->plugin), dd);
+}
+
+
+extern void dict_panel_plugin_unblock(DictData *dd)
+{
+ xfce_panel_plugin_unblock_menu(dd->plugin);
+}
+
+
+static void dict_construct(XfcePanelPlugin *plugin)
+{
+ DictData *dd = g_new0(DictData, 1);
+ GtkWidget *hbox;
+
+ xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+
+ g_thread_init(NULL);
+
+ dd->plugin = plugin;
+ dd->searched_word = NULL;
+ dd->query_is_running = FALSE;
+ dd->query_status = NO_ERROR;
+
+ dict_read_rc_file(dd);
+
+ dd->panel_button = xfce_create_panel_button();
+
+ dd->tooltips = gtk_tooltips_new();
+ gtk_tooltips_set_tip(dd->tooltips, dd->panel_button, _("Look up a word"), NULL);
+
+ dd->panel_button_image = gtk_image_new();
+ gtk_container_add(GTK_CONTAINER(dd->panel_button), GTK_WIDGET(dd->panel_button_image));
+
+ gtk_widget_show_all(dd->panel_button);
+
+ g_signal_connect(dd->panel_button, "clicked", G_CALLBACK(dict_plugin_panel_button_clicked), dd);
+
+ dict_create_main_window(dd);
+
+ g_signal_connect(dd->window, "delete_event", G_CALLBACK(gtk_widget_hide_on_delete), NULL);
+ g_signal_connect(dd->close_button, "clicked", G_CALLBACK(dict_plugin_close_button_clicked), dd);
+ g_signal_connect(plugin, "free-data", G_CALLBACK(dict_plugin_free_data), dd);
+ g_signal_connect(plugin, "size-changed", G_CALLBACK(dict_plugin_panel_set_size), dd);
+ g_signal_connect(plugin, "orientation-changed", G_CALLBACK(dict_plugin_panel_change_orientation), dd);
+ g_signal_connect(plugin, "style-set", G_CALLBACK(dict_plugin_style_set), dd);
+ g_signal_connect(plugin, "save", G_CALLBACK(dict_plugin_write_rc_file), dd);
+ g_signal_connect(plugin, "configure-plugin", G_CALLBACK(dict_plugin_properties_dialog), dd);
+ g_signal_connect(plugin, "about", G_CALLBACK(dict_about_dialog), dd);
+
+ xfce_panel_plugin_menu_show_configure(plugin);
+ xfce_panel_plugin_menu_show_about(plugin);
+
+ /* panel entry */
+ dd->panel_entry = gtk_entry_new();
+ gtk_entry_set_width_chars(GTK_ENTRY(dd->panel_entry), 15);
+ g_signal_connect(dd->panel_entry, "activate", G_CALLBACK(dict_entry_activate_cb), dd);
+ g_signal_connect(dd->panel_entry, "button-press-event", G_CALLBACK(dict_panel_entry_buttonpress_cb), dd);
+
+ if (dd->show_panel_entry && xfce_panel_plugin_get_orientation(dd->plugin) == GTK_ORIENTATION_HORIZONTAL)
+ gtk_widget_show(dd->panel_entry);
+
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_widget_show(hbox);
+
+ gtk_container_add(GTK_CONTAINER(hbox), dd->panel_button);
+ gtk_container_add(GTK_CONTAINER(hbox), dd->panel_entry);
+ gtk_container_add(GTK_CONTAINER(plugin), hbox);
+
+ xfce_panel_plugin_add_action_widget(plugin, dd->panel_button);
+ dict_plugin_set_selection(dd);
+
+ /* DnD stuff */
+ gtk_drag_dest_set(GTK_WIDGET(dd->panel_button), GTK_DEST_DEFAULT_ALL,
+ NULL, 0, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+ gtk_drag_dest_add_text_targets(GTK_WIDGET(dd->panel_button));
+ g_signal_connect(dd->panel_button, "drag-data-received", G_CALLBACK(dict_drag_data_received), dd);
+ g_signal_connect(dd->main_entry, "drag-data-received", G_CALLBACK(dict_drag_data_received), dd);
+ g_signal_connect(dd->panel_entry, "drag-data-received", G_CALLBACK(dict_drag_data_received), dd);
+
+ dict_status_add(dd, _("Ready."));
+
+ siginterrupt(SIGALRM, 1);
+ signal(SIGALRM, dict_signal_cb);
+}
+XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(dict_construct);
Property changes on: xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.desktop.in.in
===================================================================
--- xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.desktop.in.in (rev 0)
+++ xfce4-dict/trunk/panel-plugin/xfce4-dict-plugin.desktop.in.in 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,7 @@
+[Xfce Panel]
+Type=X-XFCE-PanelPlugin
+Encoding=UTF-8
+_Name=Dictionary
+_Comment=A plugin to query different dictionaries.
+Icon=xfce4-dict
+X-XFCE-Exec=@libexecdir@/xfce4/panel-plugins/xfce4-dict-plugin
Deleted: xfce4-dict/trunk/panel-plugin/xfce4-popup-dict.c
Deleted: xfce4-dict/trunk/panel-plugin/xfce4-popup-dict.h
Modified: xfce4-dict/trunk/po/POTFILES.in
===================================================================
--- xfce4-dict/trunk/po/POTFILES.in 2008-03-25 08:20:17 UTC (rev 4116)
+++ xfce4-dict/trunk/po/POTFILES.in 2008-03-27 19:36:43 UTC (rev 4117)
@@ -1,3 +1,8 @@
-panel-plugin/dict.c
-panel-plugin/xfce4-popup-dict.c
-panel-plugin/dict.desktop.in.in
+panel-plugin/xfce4-dict-plugin.desktop.in.in
+panel-plugin/xfce4-dict-plugin.c
+src/popup_plugin.c
+src/xfce4-dict.c
+src/xfce4-dict.desktop.in
+lib/aspell.c
+lib/dict.c
+lib/dict.h
Added: xfce4-dict/trunk/src/Makefile.am
===================================================================
--- xfce4-dict/trunk/src/Makefile.am (rev 0)
+++ xfce4-dict/trunk/src/Makefile.am 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,34 @@
+
+bin_PROGRAMS = \
+ xfce4-dict
+
+xfce4_dict_SOURCES = \
+ xfce4-dict.c \
+ popup_plugin.c \
+ popup_plugin.h
+
+xfce4_dict_CFLAGS = \
+ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+ -I$(top_srcdir)/lib \
+ $(LIBXFCE4UTIL_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(PLATFORM_CFLAGS)
+
+xfce4_dict_LDADD = \
+ $(GTK_LIBS) \
+ $(LIBXFCE4UTIL_LIBS) \
+ $(LIBXFCEGUI4_LIBS) \
+ @GTHREAD_LIBS@ \
+ $(top_srcdir)/lib/libdict.a
+
+
+EXTRA_DIST = \
+ $(desktop_in_files)
+
+CLEANFILES = \
+ $(desktop_DATA)
+
+desktopdir = $(datadir)/applications
+desktop_in_files = xfce4-dict.desktop
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+ at INTLTOOL_DESKTOP_RULE@
Added: xfce4-dict/trunk/src/popup_plugin.c
===================================================================
--- xfce4-dict/trunk/src/popup_plugin.c (rev 0)
+++ xfce4-dict/trunk/src/popup_plugin.c 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,99 @@
+/* $Id$
+ *
+ * Copyright 2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ * Copyright 2006 Darren Salt
+ * Copyright 2002-2006 Olivier Fourdan
+ *
+ * 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 Library 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 <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include <X11/Xlib.h>
+#include <string.h>
+
+#include "popup_def.h"
+
+
+static gboolean xfce4_check_is_running(GtkWidget *widget, Window *xid)
+{
+ GdkScreen *gscreen;
+ gchar selection_name[32];
+ Atom selection_atom;
+
+ gscreen = gtk_widget_get_screen(widget);
+ g_snprintf(selection_name, sizeof(selection_name), XFCE_DICT_SELECTION"%d",
+ gdk_screen_get_number(gscreen));
+ selection_atom = XInternAtom(GDK_DISPLAY(), selection_name, False);
+
+ if ((*xid = XGetSelectionOwner(GDK_DISPLAY(), selection_atom)))
+ return TRUE;
+
+ return FALSE;
+}
+
+
+gboolean dict_find_panel_plugin(void)
+{
+ gboolean ret = FALSE;
+ GdkEventClient gev;
+ GtkWidget *win;
+ Window id;
+
+ gtk_window_set_default_icon_name("xfce4-dict");
+
+ win = gtk_invisible_new();
+ gtk_widget_realize(win);
+
+ gev.type = GDK_CLIENT_EVENT;
+ gev.window = win->window;
+ gev.send_event = TRUE;
+ gev.message_type = gdk_atom_intern("STRING", FALSE);
+ gev.data_format = 8;
+ /* temporary disabled */
+#if 0
+ if (argc > 1 && (strcmp(argv[1], "--text-field") == 0 || strcmp(argv[1], "-t") == 0))
+ {
+ strcpy(gev.data.b, XFCE_DICT_TEXTFIELD_MESSAGE);
+ }
+ else if (argc > 1 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0))
+ {
+ g_print(_("Usage: %s [options]\n"), argv[0]);
+ g_print(_("Options:\n"));
+ g_print(_(" -t, --text-field grap the focus on the text field in the panel\n"));
+ g_print(_(" -h, --help show this help and exit\n"));
+ g_print(_("If called without any options, the xfce4-dict-plugin main window is shown.\n"));
+ return 0;
+ }
+ else
+ {
+ strcpy(gev.data.b, XFCE_DICT_WINDOW_MESSAGE);
+ }
+#else
+ strcpy(gev.data.b, XFCE_DICT_WINDOW_MESSAGE);
+#endif
+
+ if (xfce4_check_is_running(win, &id))
+ {
+ gdk_event_send_client_message((GdkEvent*) &gev, (GdkNativeWindow) id);
+ ret = TRUE;
+ }
+
+ gdk_flush();
+ gtk_widget_destroy(win);
+
+ return ret;
+}
Property changes on: xfce4-dict/trunk/src/popup_plugin.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: xfce4-dict/trunk/src/popup_plugin.h
===================================================================
--- xfce4-dict/trunk/src/popup_plugin.h (rev 0)
+++ xfce4-dict/trunk/src/popup_plugin.h 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,27 @@
+/* $Id$
+ *
+ * Copyright 2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ *
+ * 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 Library 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 POPUP_DEF_H
+#define POPUP_DEF_H 1
+
+
+gboolean dict_find_panel_plugin(void);
+
+#endif
Property changes on: xfce4-dict/trunk/src/popup_plugin.h
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: xfce4-dict/trunk/src/xfce4-dict.c
===================================================================
--- xfce4-dict/trunk/src/xfce4-dict.c (rev 0)
+++ xfce4-dict/trunk/src/xfce4-dict.c 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,121 @@
+/* $Id$
+ *
+ * Copyright 2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ *
+ * 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 Library 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 <stdio.h>
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#include <libxfce4util/libxfce4util.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif
+
+/* Simple forward declaration to avoid inclusion of libxfce4panel headers */
+typedef struct XfcePanelPlugin_t XfcePanelPlugin;
+
+#include "common.h"
+#include "popup_plugin.h"
+
+
+
+extern void dict_panel_plugin_unblock(DictData *dd)
+{
+ // no-op
+}
+
+
+extern void dict_panel_plugin_save_settings(DictData *dd)
+{
+ // no-op
+}
+
+
+gboolean main_quit(GtkWidget *widget, GdkEvent *event, DictData *dd)
+{
+ dict_free_data(dd);
+ gtk_main_quit();
+
+ return FALSE;
+}
+
+
+void close_button_clicked(GtkWidget *button, DictData *dd)
+{
+ main_quit(NULL, NULL, dd);
+}
+
+
+gint main(gint argc, gchar *argv[])
+{
+ DictData *dd;
+
+#ifdef ENABLE_NLS
+ xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
+#endif
+
+ gtk_init(&argc, &argv);
+ gtk_window_set_default_icon_name("xfce4-dict");
+
+ /* try to find an existing panel plugin and pop it up */
+ if (dict_find_panel_plugin())
+ exit(0);
+
+ /* no plugin found, start usual stand-alone app */
+
+ dd = g_new0(DictData, 1);
+
+ g_thread_init(NULL);
+
+ /* initialise some pointers, unused panel plugins pointers defaults to NULL when not used */
+ dd->plugin = NULL;
+ dd->searched_word = NULL;
+ dd->query_is_running = FALSE;
+ dd->query_status = NO_ERROR;
+ dd->panel_button = NULL;
+ dd->tooltips = NULL;
+ dd->panel_button_image = NULL;
+ dd->panel_entry = NULL;
+
+ dict_read_rc_file(dd);
+
+ dict_create_main_window(dd);
+
+ g_signal_connect(dd->window, "delete-event", G_CALLBACK(main_quit), dd);
+ g_signal_connect(dd->close_button, "clicked", G_CALLBACK(close_button_clicked), dd);
+
+ dict_status_add(dd, _("Ready."));
+
+ siginterrupt(SIGALRM, 1);
+ signal(SIGALRM, dict_signal_cb);
+
+ gtk_widget_show_all(dd->window);
+
+ gtk_main();
+
+ return 0;
+}
Property changes on: xfce4-dict/trunk/src/xfce4-dict.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: xfce4-dict/trunk/src/xfce4-dict.desktop.in
===================================================================
--- xfce4-dict/trunk/src/xfce4-dict.desktop.in (rev 0)
+++ xfce4-dict/trunk/src/xfce4-dict.desktop.in 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Type=Application
+Version=1.0
+_Name=Xfce Dictionary
+_GenericName=Dictionary Client
+_Comment=A client program to query different dictionaries.
+Icon=xfce4-dict
+Exec=xfce4-dict
+Terminal=false
+StartupNotify=true
+Categories=Utility;Dictionary;GTK;
Added: xfce4-dict/trunk/xfce4-dict.svg
===================================================================
--- xfce4-dict/trunk/xfce4-dict.svg (rev 0)
+++ xfce4-dict/trunk/xfce4-dict.svg 2008-03-27 19:36:43 UTC (rev 4117)
@@ -0,0 +1,355 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48"
+ height="48"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.43+devel"
+ version="1.0"
+ sodipodi:docbase="/home/jimmac/src/cvs/gnome/gnome-icon-theme/scalable/apps"
+ sodipodi:docname="accessories-dictionary.svg"
+ inkscape:export-filename="/home/ulisse/Desktop/accessories-dictionary.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4">
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient2309">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop2311" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0;"
+ offset="1"
+ id="stop2313" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient2301">
+ <stop
+ style="stop-color:#790000;stop-opacity:1"
+ offset="0"
+ id="stop2303" />
+ <stop
+ style="stop-color:#b03636;stop-opacity:1"
+ offset="1"
+ id="stop2305" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient2286">
+ <stop
+ style="stop-color:#555753"
+ offset="0"
+ id="stop2288" />
+ <stop
+ style="stop-color:#555753;stop-opacity:0"
+ offset="1"
+ id="stop2290" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient2276">
+ <stop
+ style="stop-color:#babdb6;stop-opacity:1;"
+ offset="0"
+ id="stop2278" />
+ <stop
+ style="stop-color:#8f9488;stop-opacity:1"
+ offset="1"
+ id="stop2280" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient2258">
+ <stop
+ style="stop-color:#ffa4a4;stop-opacity:1"
+ offset="0"
+ id="stop2260" />
+ <stop
+ style="stop-color:#a40000"
+ offset="1"
+ id="stop2262" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient2235">
+ <stop
+ style="stop-color:#cccccc;stop-opacity:1"
+ offset="0"
+ id="stop2237" />
+ <stop
+ style="stop-color:#9b9b9b;stop-opacity:1"
+ offset="1"
+ id="stop2239" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient2229">
+ <stop
+ style="stop-color:#888a85"
+ offset="0"
+ id="stop2231" />
+ <stop
+ style="stop-color:#d3d7cf;stop-opacity:0;"
+ offset="1"
+ id="stop2233" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient2221"
+ inkscape:collect="always">
+ <stop
+ id="stop2223"
+ offset="0"
+ style="stop-color:#babdb6" />
+ <stop
+ id="stop2225"
+ offset="1"
+ style="stop-color:#d3d7cf;stop-opacity:0;" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient2184">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="0"
+ id="stop2186" />
+ <stop
+ style="stop-color:#e3e3e3;stop-opacity:1"
+ offset="1"
+ id="stop2188" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2229"
+ id="linearGradient2211"
+ x1="24"
+ y1="19.505583"
+ x2="19.982143"
+ y2="19.550226"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(-1,0,0,1,48,0)" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2221"
+ id="linearGradient2219"
+ x1="24"
+ y1="19.996655"
+ x2="32"
+ y2="19.90625"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(-1,0,0,1,48,0)" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2184"
+ id="linearGradient2245"
+ gradientUnits="userSpaceOnUse"
+ x1="15.714286"
+ y1="16.82852"
+ x2="36.482143"
+ y2="20.667807" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2235"
+ id="linearGradient2247"
+ gradientUnits="userSpaceOnUse"
+ x1="19.940901"
+ y1="10.918805"
+ x2="24"
+ y2="22.750927" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2258"
+ id="linearGradient2264"
+ x1="32.794643"
+ y1="21.696428"
+ x2="34.79464"
+ y2="32.321426"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2276"
+ id="linearGradient2282"
+ x1="37.535713"
+ y1="34.196426"
+ x2="9.9285688"
+ y2="20.089285"
+ gradientUnits="userSpaceOnUse" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2286"
+ id="radialGradient2292"
+ cx="24"
+ cy="36.75"
+ fx="24"
+ fy="36.75"
+ r="22.5"
+ gradientTransform="matrix(1,0,0,0.3,-3.16587e-17,25.725)"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2301"
+ id="linearGradient2307"
+ x1="23.955357"
+ y1="10.008928"
+ x2="29.214285"
+ y2="30.276785"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2309"
+ id="linearGradient2315"
+ x1="6.7230334"
+ y1="37.683041"
+ x2="37.804565"
+ y2="29.096745"
+ gradientUnits="userSpaceOnUse" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#a8a8a8"
+ borderopacity="1"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="7.919596"
+ inkscape:cx="41.482905"
+ inkscape:cy="24.425816"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ inkscape:showpageshadow="false"
+ inkscape:grid-bbox="true"
+ showgrid="true"
+ inkscape:grid-points="true"
+ gridspacingx="0.5px"
+ gridspacingy="0.5px"
+ gridempspacing="2"
+ inkscape:window-width="872"
+ inkscape:window-height="694"
+ inkscape:window-x="0"
+ inkscape:window-y="25"
+ fill="#75507b" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>Ulisse Perusin</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:title>Dictionary</dc:title>
+ <dc:subject>
+ <rdf:Bag>
+ <rdf:li>dictionary</rdf:li>
+ <rdf:li>translation</rdf:li>
+ </rdf:Bag>
+ </dc:subject>
+ <cc:license
+ rdf:resource="http://creativecommons.org/licenses/GPL/2.0/" />
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/licenses/GPL/2.0/">
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Reproduction" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Distribution" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/Notice" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/ShareAlike" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/SourceCode" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Livello 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <path
+ sodipodi:type="arc"
+ style="opacity:0.50196078;color:#000000;fill:url(#radialGradient2292);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:17.85;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
+ id="path2284"
+ sodipodi:cx="24"
+ sodipodi:cy="36.75"
+ sodipodi:rx="22.5"
+ sodipodi:ry="6.75"
+ d="M 46.5 36.75 A 22.5 6.75 0 1 1 1.5,36.75 A 22.5 6.75 0 1 1 46.5 36.75 z"
+ transform="matrix(1.066667,0,0,0.962963,-1.600001,1.111111)" />
+ <path
+ style="color:#000000;fill:#523856;fill-opacity:1;fill-rule:nonzero;stroke:#3e263b;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:17.85;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
+ d="M 4.5,11.5 L 43.5,11.5 L 47.5,38.5 L 29,38.5 L 28,37.5 C 26,39 22,39 20,37.5 L 19,38.5 L 0.5,38.5 L 4.5,11.5 z "
+ id="rect1304"
+ sodipodi:nodetypes="ccccccccc" />
+ <path
+ sodipodi:type="inkscape:offset"
+ inkscape:radius="-0.91809106"
+ inkscape:original="M 4.5 11.5 L 0.5 38.5 L 19 38.5 L 20 37.5 C 22 39 26 39 28 37.5 L 29 38.5 L 47.5 38.5 L 43.5 11.5 L 4.5 11.5 z "
+ xlink:href="#rect1304"
+ style="opacity:0.13333333;color:#000000;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:17.85;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
+ id="path2274"
+ inkscape:href="#rect1304"
+ d="M 5.28125,12.40625 L 1.5625,37.59375 L 18.59375,37.59375 L 19.34375,36.84375 C 19.667151,36.507336 20.191452,36.467006 20.5625,36.75 C 21.327469,37.323727 22.653015,37.71875 24,37.71875 C 25.346985,37.71875 26.672531,37.323727 27.4375,36.75 C 27.808548,36.467006 28.332849,36.507336 28.65625,36.84375 L 29.40625,37.59375 L 46.4375,37.59375 L 42.71875,12.40625 L 5.28125,12.40625 z " />
+ <path
+ style="fill:url(#linearGradient2282);fill-opacity:1.0;fill-rule:evenodd;stroke:#888a85;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 2,36.5 C 7.6666667,36.5 16,35 19,36.5 C 22,34 26,34 29,36.5 C 32,35 41,36.5 46,36.5 L 45.5,34 C 38.5,31.5 29,28.5 24,33 C 19,28.5 9.5,31.5 2.5,34 L 2,36.5 z "
+ id="path2180"
+ sodipodi:nodetypes="cccccccc" />
+ <path
+ sodipodi:type="inkscape:offset"
+ inkscape:radius="-1.0582203"
+ inkscape:original="M 14 30.875 C 10.125 31.375 6 32.75 2.5 34 L 2 36.5 C 7.6666667 36.5 16 35 19 36.5 C 22 34 26 34 29 36.5 C 32 35 41 36.5 46 36.5 L 45.5 34 C 38.5 31.5 29 28.5 24 33 C 21.5 30.75 17.875 30.375 14 30.875 z "
+ xlink:href="#path2180"
+ style="opacity:0.30196078;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient2315);stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path2266"
+ inkscape:href="#path2180"
+ d="M 14.375,31.9375 C 10.963293,32.392394 7.260823,33.622273 3.90625,34.8125 L 3.8125,35.34375 C 6.2979599,35.262594 9.0476285,35.037732 11.6875,34.875 C 14.462294,34.703951 16.881256,34.711661 18.78125,35.40625 C 20.133116,34.409774 21.661646,33.894157 23.21875,33.75 C 21.042747,31.830616 17.941674,31.461944 14.375,31.9375 z M 28.625,31.9375 C 27.145571,32.213473 25.86037,32.798142 24.78125,33.75 C 26.338354,33.894157 27.866884,34.409774 29.21875,35.40625 C 31.163554,34.697135 33.704549,34.703523 36.5625,34.875 C 39.261382,35.036933 41.920385,35.260963 44.1875,35.34375 L 44.09375,34.8125 C 40.739177,33.622273 37.036707,32.392394 33.625,31.9375 C 31.827105,31.697781 30.128781,31.656984 28.625,31.9375 z " />
+ <path
+ style="fill:url(#linearGradient2245);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient2247);stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 2.5,34 C 9,31.5 20,29 24,33 C 28,29 39,31.5 45.5,34 L 42.5,10.5 C 37,8 27.5,6 24,9 C 20,6 12,8 5.5,10.5 L 2.5,34 z "
+ id="path2182"
+ sodipodi:nodetypes="ccccccc" />
+ <path
+ style="color:#000000;fill:url(#linearGradient2219);fill-opacity:1.0;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:17.85;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
+ d="M 24,9.5 C 22,8 19.5,7.5 16,8 L 16,30.5 C 18,29.5 22,30.5 24,32.5 L 24,9.5 z "
+ id="rect2192"
+ sodipodi:nodetypes="ccccc" />
+ <path
+ style="color:#000000;fill:url(#linearGradient2211);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dashoffset:17.85;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
+ d="M 24,9.5 C 25.221264,8.803878 26.327771,7.9069322 28,8 L 29,30.5 C 27.5,30 25.5,31.5 24,32.5 L 24,9.5 z "
+ id="path2195"
+ sodipodi:nodetypes="ccccc" />
+ <path
+ sodipodi:type="inkscape:offset"
+ inkscape:radius="-0.92850536"
+ inkscape:original="M 20.34375 7.625 C 16.101562 7.0390625 10.375 8.625 5.5 10.5 L 2.5 34 C 9 31.5 20 29 24 33 C 28 29 39 31.5 45.5 34 L 42.5 10.5 C 37 8 27.5 6 24 9 C 23 8.25 21.757812 7.8203125 20.34375 7.625 z "
+ xlink:href="#path2182"
+ style="opacity:0.65098039;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path2243"
+ inkscape:href="#path2182"
+ d="M 17.03125,8.375 C 14.611845,8.6563261 11.827815,9.5624782 8.78125,10.71875 L 4.25,32.59375 C 7.5567067,31.338728 11.345145,30.271354 14.90625,29.9375 C 16.969491,29.744071 18.927893,29.768608 20.625,30.125 C 21.963283,30.406039 23.09173,31.003906 24,31.8125 C 24.90827,31.003906 26.036717,30.406039 27.375,30.125 C 29.072107,29.768608 31.030509,29.744071 33.09375,29.9375 C 36.654855,30.271354 40.443293,31.338728 43.75,32.59375 L 39.1875,10.6875 C 36.612085,9.5579242 33.750698,8.6570052 31.15625,8.375 C 28.420939,8.0776836 26.053467,8.4675643 24.59375,9.71875 C 24.262671,9.9972426 23.783138,10.010203 23.4375,9.75 C 21.660341,8.417131 19.571761,8.0795918 17.03125,8.375 z " />
+ <path
+ style="fill:url(#linearGradient2264);fill-opacity:1.0;fill-rule:evenodd;stroke:url(#linearGradient2307);stroke-width:1;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
+ d="M 24.455357,8.7321429 C 24.5,20.5 34,20 33.5,30.5 L 32.5,34.5 L 34,34 L 35,35 L 35.5,31 C 36,20 24.544643,19.089286 24.5,8.5 L 24.455357,8.7321429 z "
+ id="path2227"
+ sodipodi:nodetypes="cccccccc" />
+ </g>
+</svg>
More information about the Goodies-commits
mailing list