[Goodies-commits] r3777 - in xfce4-dict-plugin/trunk: . panel-plugin po
Enrico Troeger
enrico at xfce.org
Fri Jan 4 17:53:38 CET 2008
Author: enrico
Date: 2008-01-04 16:53:38 +0000 (Fri, 04 Jan 2008)
New Revision: 3777
Added:
xfce4-dict-plugin/trunk/panel-plugin/xfce4-popup-dict.c
xfce4-dict-plugin/trunk/panel-plugin/xfce4-popup-dict.h
Modified:
xfce4-dict-plugin/trunk/ChangeLog
xfce4-dict-plugin/trunk/README
xfce4-dict-plugin/trunk/panel-plugin/Makefile.am
xfce4-dict-plugin/trunk/panel-plugin/aspell.c
xfce4-dict-plugin/trunk/panel-plugin/dict.c
xfce4-dict-plugin/trunk/panel-plugin/dict.h
xfce4-dict-plugin/trunk/po/POTFILES.in
Log:
* Add xfce4-popup-dict command to show the main window and/or grad the input focus to the text field in the panel.
* Change year in copyright notes to 2008.
Modified: xfce4-dict-plugin/trunk/ChangeLog
===================================================================
--- xfce4-dict-plugin/trunk/ChangeLog 2008-01-04 13:16:52 UTC (rev 3776)
+++ xfce4-dict-plugin/trunk/ChangeLog 2008-01-04 16:53:38 UTC (rev 3777)
@@ -1,3 +1,10 @@
+2008-01-04 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+
+ * Add xfce4-popup-dict command to show the main window and/or grad the input
+ focus to the text field in the panel.
+ * Change year in copyright notes to 2008.
+
+
2007-12-18 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* Remove wrong additional space before colons.
Modified: xfce4-dict-plugin/trunk/README
===================================================================
--- xfce4-dict-plugin/trunk/README 2008-01-04 13:16:52 UTC (rev 3776)
+++ xfce4-dict-plugin/trunk/README 2008-01-04 16:53:38 UTC (rev 3777)
@@ -1,4 +1,4 @@
-xfce4-dict-plugin - A plugin to query a Dict server
+xfce4-dict-plugin - A plugin to query a Dict server and other dictionary sources
With this plugin you can query a dictionary server(see RFC 2229) to search for the
translation or explanation of a word. You can also choose a dictionary offered by the
@@ -14,7 +14,22 @@
This plugin was mainly tested with the server "dict.org" but should work with any other
servers which implement the DICT protocol defined in RFC 2229.
-ToDo:
-- support user authentification
-- keep dictionary list in memory
-- support the MATCH command
+Searching web-based dictionary services like dict.leo.org or other ones is also supported
+by passing the search word as a URL argument and opening the URL in your webbrowser. The URL
+can be configured in the preferences dialog.
+
+It is also possible to verify the spelling of word using aspell. To get this working you need
+to have the aspell binary in your binary search path and at least one dictionary working. If you
+have multiple aspell dictionaries installed, you can select the one to use in the preferences
+dialog.
+
+Together with the plugin itself, a little tool named "xfce4-popup-dict" is installed which can
+be used to open the plugin's main window from the command line or from any other program.
+It can also be used to bind the dict plugin actions to a keyboard shortcut. You can add a new
+keyboard command with the Keyboard settings plugin in Xfce's settings manager and assign
+xfce4-popup-dict as the action command.
+It accepts the arguments -t and --text-field to grab the focus to the text entry field in the
+panel (if shown, it does nothing if not). If called without any arguments, it simply shows the
+plugin's main window.
+To get a list of available command line options you can also pass -h and --help as command line
+options.
Modified: xfce4-dict-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-dict-plugin/trunk/panel-plugin/Makefile.am 2008-01-04 13:16:52 UTC (rev 3776)
+++ xfce4-dict-plugin/trunk/panel-plugin/Makefile.am 2008-01-04 16:53:38 UTC (rev 3777)
@@ -1,6 +1,22 @@
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 \
Modified: xfce4-dict-plugin/trunk/panel-plugin/aspell.c
===================================================================
--- xfce4-dict-plugin/trunk/panel-plugin/aspell.c 2008-01-04 13:16:52 UTC (rev 3776)
+++ xfce4-dict-plugin/trunk/panel-plugin/aspell.c 2008-01-04 16:53:38 UTC (rev 3777)
@@ -1,6 +1,6 @@
/* $Id$
*
- * Copyright © 2007 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ * 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
Modified: xfce4-dict-plugin/trunk/panel-plugin/dict.c
===================================================================
--- xfce4-dict-plugin/trunk/panel-plugin/dict.c 2008-01-04 13:16:52 UTC (rev 3776)
+++ xfce4-dict-plugin/trunk/panel-plugin/dict.c 2008-01-04 16:53:38 UTC (rev 3777)
@@ -1,6 +1,6 @@
/* $Id$
*
- * Copyright © 2006-2007 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ * 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
@@ -40,6 +40,7 @@
#include <string.h>
#include "dict.h"
+#include "xfce4-popup-dict.h"
#include "inline-icon.h"
#define BUF_SIZE 256
@@ -50,6 +51,7 @@
static void dict_properties_dialog(XfcePanelPlugin *plugin, DictData *dd);
static void dict_construct(XfcePanelPlugin *plugin);
static void dict_write_rc_file(XfcePanelPlugin *plugin, DictData *dd);
+static void dict_panel_button_clicked(GtkWidget *button, DictData *dd);
/* internal functions */
@@ -133,6 +135,62 @@
}
+/* Handle user messages (xfce4-popup-dict) */
+static gboolean dict_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_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_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_message_received), dd);
+
+ return TRUE;
+}
+
+
static GdkPixbuf *dict_load_and_scale(const guint8 *data, int dstw, int dsth)
{
GdkPixbuf *pb, *pb_scaled;
@@ -1444,7 +1502,7 @@
info = xfce_about_info_new("xfce4-dict-plugin", VERSION,
_("A plugin to query a Dict server."),
- XFCE_COPYRIGHT_TEXT("2006-2007", "Enrico Tröger"),
+ 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"));
@@ -1485,7 +1543,7 @@
const gchar *panel_text = gtk_entry_get_text(GTK_ENTRY(dd->panel_entry));
dict_show_main_window(dd);
- if (strcmp("", panel_text) != 0)
+ if (NZV(panel_text))
{
dict_search_word(dd, panel_text);
gtk_entry_set_text(GTK_ENTRY(dd->main_entry), panel_text);
@@ -1574,6 +1632,7 @@
gtk_container_add(GTK_CONTAINER(plugin), hbox);
xfce_panel_plugin_add_action_widget(plugin, dd->panel_button);
+ dict_set_selection(dd);
/* DnD stuff */
gtk_drag_dest_set(GTK_WIDGET(dd->panel_button), GTK_DEST_DEFAULT_ALL,
Modified: xfce4-dict-plugin/trunk/panel-plugin/dict.h
===================================================================
--- xfce4-dict-plugin/trunk/panel-plugin/dict.h 2008-01-04 13:16:52 UTC (rev 3776)
+++ xfce4-dict-plugin/trunk/panel-plugin/dict.h 2008-01-04 16:53:38 UTC (rev 3777)
@@ -1,6 +1,6 @@
/* $Id$
*
- * Copyright © 2007 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+ * 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
Added: xfce4-dict-plugin/trunk/panel-plugin/xfce4-popup-dict.c
===================================================================
--- xfce4-dict-plugin/trunk/panel-plugin/xfce4-popup-dict.c (rev 0)
+++ xfce4-dict-plugin/trunk/panel-plugin/xfce4-popup-dict.c 2008-01-04 16:53:38 UTC (rev 3777)
@@ -0,0 +1,118 @@
+/* $Id$
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ (c) 2008 Enrico Tröger
+
+ (c) 2006 Darren Salt
+
+ Derived from xfdesktop's xfce4-popup-menu
+ (c) 2002-2006 Olivier Fourdan
+
+ */
+
+#include <stdio.h>
+#include <gtk/gtk.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gdk/gdkx.h>
+#include <X11/Xlib.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif
+
+#include "xfce4-popup-dict.h"
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+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;
+}
+
+
+int main(int argc, char *argv[])
+{
+ GdkEventClient gev;
+ GtkWidget *win;
+ Window id;
+
+#ifdef ENABLE_NLS
+ bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ textdomain(GETTEXT_PACKAGE);
+#endif
+
+ gtk_init(&argc, &argv);
+
+ 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;
+ 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);
+ }
+
+ if (xfce4_check_is_running(win, &id))
+ gdk_event_send_client_message((GdkEvent*) &gev, (GdkNativeWindow) id);
+ else
+ g_warning("Can't find the xfce4-dict-plugin to popup.\n");
+
+ gdk_flush();
+ gtk_widget_destroy(win);
+
+ return 0;
+}
Property changes on: xfce4-dict-plugin/trunk/panel-plugin/xfce4-popup-dict.c
___________________________________________________________________
Name: svn:keywords
+ Id Author Date Revision
Added: xfce4-dict-plugin/trunk/panel-plugin/xfce4-popup-dict.h
===================================================================
--- xfce4-dict-plugin/trunk/panel-plugin/xfce4-popup-dict.h (rev 0)
+++ xfce4-dict-plugin/trunk/panel-plugin/xfce4-popup-dict.h 2008-01-04 16:53:38 UTC (rev 3777)
@@ -0,0 +1,45 @@
+/* $Id$
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ (c) 2008 Enrico Tröger
+
+ (c) 2006 Darren Salt
+
+ Derived from xfdesktop panel-plugin/xfce4-popup-menu.h
+ (c) 2002-2006 Olivier Fourdan
+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef INC_XFCE4_DICT_POPUP_MENU_H
+#define INC_XFCE4_DICT_POPUP_MENU_H
+
+#ifndef XFCE_DICT_WINDOW_MESSAGE
+#define XFCE_DICT_WINDOW_MESSAGE "xfce4-dict-popup"
+#endif /* XFCE_DICT_WINDOW_MESSAGE */
+
+#ifndef XFCE_DICT_TEXTFIELD_MESSAGE
+#define XFCE_DICT_TEXTFIELD_MESSAGE "xfce4-dict-atptr"
+#endif /* XFCE_DICT_TEXTFIELD_MESSAGE */
+
+#ifndef XFCE_DICT_SELECTION
+#define XFCE_DICT_SELECTION "XFCE_DICT_SEL"
+#endif /* XFCE_DICT_SELECTION */
+
+#endif /* INC_XFCE4_DICT_POPUP_MENU_H */
Property changes on: xfce4-dict-plugin/trunk/panel-plugin/xfce4-popup-dict.h
___________________________________________________________________
Name: svn:keywords
+ Id Author Date Revision
Modified: xfce4-dict-plugin/trunk/po/POTFILES.in
===================================================================
--- xfce4-dict-plugin/trunk/po/POTFILES.in 2008-01-04 13:16:52 UTC (rev 3776)
+++ xfce4-dict-plugin/trunk/po/POTFILES.in 2008-01-04 16:53:38 UTC (rev 3777)
@@ -1,2 +1,3 @@
panel-plugin/dict.c
+panel-plugin/xfce4-popup-dict.c
panel-plugin/dict.desktop.in.in
More information about the Goodies-commits
mailing list