gtranslator r3451 - in branches/GOBJECT_WORK: . plugins plugins/alternate-language plugins/charmap plugins/dictionary plugins/glossary plugins/open-tran src
- From: icq svn gnome org
- To: svn-commits-list gnome org
- Subject: gtranslator r3451 - in branches/GOBJECT_WORK: . plugins plugins/alternate-language plugins/charmap plugins/dictionary plugins/glossary plugins/open-tran src
- Date: Mon, 21 Jan 2008 15:10:43 +0000 (GMT)
Author: icq
Date: Mon Jan 21 15:10:42 2008
New Revision: 3451
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3451&view=rev
Log:
2008-01-21 Ignacio Casal Quinteiro <nacho resa gmail com>
* plugins:
* Makefile.am:
* configure.ac:
Added new plugins.
* plugins:
* dictionary:
* glossary:
* alternate-language:
* charmap:
* open-tran:
* Makefile.am:
Added all this plugins.
* src:
* Makfile.am:
* window.c: Added get_all_tab func and removed old
plugins load system.
Added:
branches/GOBJECT_WORK/plugins/
branches/GOBJECT_WORK/plugins/ChangeLog
branches/GOBJECT_WORK/plugins/Makefile.am
branches/GOBJECT_WORK/plugins/alternate-language/
branches/GOBJECT_WORK/plugins/alternate-language/Makefile.am
branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-panel.c
branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-panel.h
branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-plugin.c
branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-plugin.h
branches/GOBJECT_WORK/plugins/alternate-language/alternate-language.gtranslator-plugin.desktop.in
branches/GOBJECT_WORK/plugins/charmap/
branches/GOBJECT_WORK/plugins/charmap/Makefile.am
branches/GOBJECT_WORK/plugins/charmap/charmap-panel.c
branches/GOBJECT_WORK/plugins/charmap/charmap-panel.h
branches/GOBJECT_WORK/plugins/charmap/charmap-plugin.c
branches/GOBJECT_WORK/plugins/charmap/charmap-plugin.h
branches/GOBJECT_WORK/plugins/charmap/charmap.gtranslator-plugin.desktop.in
branches/GOBJECT_WORK/plugins/charmap/update-from-gedit.sh (contents, props changed)
branches/GOBJECT_WORK/plugins/dictionary/
branches/GOBJECT_WORK/plugins/dictionary/Makefile.am
branches/GOBJECT_WORK/plugins/dictionary/dict-panel.c
branches/GOBJECT_WORK/plugins/dictionary/dict-panel.h
branches/GOBJECT_WORK/plugins/dictionary/dict.gtranslator-plugin.desktop.in
branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.c
branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.h
branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.c
branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.h
branches/GOBJECT_WORK/plugins/glossary/
branches/GOBJECT_WORK/plugins/glossary/glossary-panel.c
branches/GOBJECT_WORK/plugins/glossary/glossary-panel.h
branches/GOBJECT_WORK/plugins/open-tran/
branches/GOBJECT_WORK/plugins/open-tran/Makefile.am
branches/GOBJECT_WORK/plugins/open-tran/debian.png (contents, props changed)
branches/GOBJECT_WORK/plugins/open-tran/gnome.png (contents, props changed)
branches/GOBJECT_WORK/plugins/open-tran/kde.ico (contents, props changed)
branches/GOBJECT_WORK/plugins/open-tran/mozilla.png (contents, props changed)
branches/GOBJECT_WORK/plugins/open-tran/open-tran-panel.c
branches/GOBJECT_WORK/plugins/open-tran/open-tran-panel.h
branches/GOBJECT_WORK/plugins/open-tran/open-tran-plugin.c
branches/GOBJECT_WORK/plugins/open-tran/open-tran-plugin.h
branches/GOBJECT_WORK/plugins/open-tran/open-tran.gtranslator-plugin.desktop.in
branches/GOBJECT_WORK/plugins/open-tran/open-tran.png (contents, props changed)
Modified:
branches/GOBJECT_WORK/ChangeLog
branches/GOBJECT_WORK/Makefile.am
branches/GOBJECT_WORK/configure.ac
branches/GOBJECT_WORK/src/ChangeLog
branches/GOBJECT_WORK/src/Makefile.am
branches/GOBJECT_WORK/src/window.c
Modified: branches/GOBJECT_WORK/Makefile.am
==============================================================================
--- branches/GOBJECT_WORK/Makefile.am (original)
+++ branches/GOBJECT_WORK/Makefile.am Mon Jan 21 15:10:42 2008
@@ -1,6 +1,6 @@
## the main Makefile.am
-SUBDIRS = data doc help man src po
+SUBDIRS = data doc help man src plugins po
EXTRA_DIST= \
DEPENDS \
Modified: branches/GOBJECT_WORK/configure.ac
==============================================================================
--- branches/GOBJECT_WORK/configure.ac (original)
+++ branches/GOBJECT_WORK/configure.ac Mon Jan 21 15:10:42 2008
@@ -88,7 +88,6 @@
AC_SUBST(LIBXML_REQUIRED)
AC_SUBST(LIBGLADE_REQUIRED)
AC_SUBST(SOURCEVIEW_REQUIRED)
-AC_SUBST(LIBGUCHARMAP_REQUIRED)
AC_SUBST(GDICT_REQUIRED)
AC_SUBST(GTKSPELL_OPTIONAL)
@@ -99,7 +98,6 @@
libxml-2.0 >= $LIBXML_REQUIRED
libglade-2.0 >= $LIBGLADE_REQUIRED
gtksourceview-2.0 >= $SOURCEVIEW_REQUIRED
-gucharmap >= $LIBGUCHARMAP_REQUIRED
])
AC_SUBST(GTRANSLATOR_CFLAGS)
@@ -158,6 +156,74 @@
AC_SUBST(GTKSPELL_CFLAGS)
AC_SUBST(GTKSPELL_LIBS)
+dnl Check for libsoup, needed for Open-tran
+if test "x$enable_opentran" != "xno"; then
+ PKG_CHECK_MODULES(SOUP, \
+ libsoup-2.2,
+ have_libsoup=yes,
+ have_libsoup=no)
+ if test x"$have_libsoup" = "xno"; then
+ PKG_CHECK_MODULES(SOUP,
+ libsoup-2.4,
+ have_libsoup=yes,
+ have_libsoup=no)
+ fi
+ if test x"$have_libsoup" = "xyes"; then
+ AC_DEFINE(HAVE_LIBSOUP, 1, [Define if libsoup support is enabled])
+ fi
+fi
+
+AM_CONDITIONAL(USE_LIBSOUP, test x"$have_libsoup" = "xyes")
+
+# ================================================================
+# gdict
+# ================================================================
+have_gdict=no
+AC_ARG_WITH(dictionary,
+ AC_HELP_STRING([--with-dictionary],
+ [Build with dictionary support]),,
+ with_dictionary=auto)
+
+if test x"$with_dictionary" != "xno"
+then
+ PKG_CHECK_MODULES([DICTIONARY], [
+ gdict-1.0 >= $GDICT_REQUIRED
+ ], have_gdict=yes, have_gdict=no)
+
+ if test x"$have_gdict" = "xyes"
+ then
+ AC_DEFINE([HAVE_DICTIONARY], 1, [Have gdict])
+ fi
+
+fi
+
+AM_CONDITIONAL(USE_DICTIONARY, test x"$have_gdict" = "xyes")
+
+# ================================================================
+# gcharmap
+# ================================================================
+have_gucharmap=no
+AC_ARG_WITH(charmap,
+ AC_HELP_STRING([--with-charmap],
+ [Build with charmap support]),,
+ with_charmap=auto)
+
+if test x"$with_charmap" != "xno"
+then
+ PKG_CHECK_MODULES([GUCHARMAP], [
+ gucharmap >= $LIBGUCHARMAP_REQUIRED
+ ], have_gucharmap=yes, have_gucharmap=no)
+
+ if test x"$have_gucharmap" = "xyes"
+ then
+ AC_DEFINE([HAVE_CHARMAP], 1, [Have gucharmap])
+ fi
+
+fi
+
+AM_CONDITIONAL(USE_CHARMAP, test x"$have_gucharmap" = "xyes")
+
+
dnl -------------------------------------------------------------------
dnl Enable debug builds.
dnl -------------------------------------------------------------------
@@ -199,11 +265,14 @@
man/Makefile
man/gtranslator.1
po/Makefile.in
+plugins/Makefile
+plugins/alternate-language/Makefile
+plugins/charmap/Makefile
+plugins/open-tran/Makefile
+plugins/dictionary/Makefile
src/Makefile
src/dialogs/Makefile
src/toolbareditor/Makefile
-src/charmap/Makefile
-src/alternatelanguage/Makefile
src/plugin-system/Makefile
])
Added: branches/GOBJECT_WORK/plugins/Makefile.am
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/Makefile.am Mon Jan 21 15:10:42 2008
@@ -0,0 +1,14 @@
+SUBDIRS = \
+ alternate-language
+
+if USE_CHARMAP
+SUBDIRS += charmap
+endif
+
+if USE_LIBSOUP
+SUBDIRS += open-tran
+endif
+
+if USE_DICTIONARY
+SUBDIRS += dictionary
+endif
Added: branches/GOBJECT_WORK/plugins/alternate-language/Makefile.am
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/alternate-language/Makefile.am Mon Jan 21 15:10:42 2008
@@ -0,0 +1,40 @@
+# Alternate language plugin
+plugindir = $(libdir)/gtranslator/plugins
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/plugin-system \
+ -I$(top_srcdir)/src/dialogs \
+ $(GTRANSLATOR_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED_CFLAGS) \
+ -DGTR_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
+
+plugin_LTLIBRARIES = \
+ libalternatelang.la
+
+libalternatelang_la_SOURCES = \
+ alternate-language-panel.h \
+ alternate-language-panel.c \
+ alternate-language-plugin.c \
+ alternate-language-plugin.h
+
+
+libalternatelang_la_LDFLAGS = \
+ $(PLUGIN_LIBTOOL_FLAGS) \
+ $(GTRANSLATOR_LIBS)
+
+# Plugin Info
+
+plugin_in_files = alternate-language.gtranslator-plugin.desktop.in
+
+%.gtranslator.plugin: %.gtranslator-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA = $(plugin_in_files:.gtranslator-plugin.desktop.in=.gtranslator.plugin)
+
+EXTRA_DIST = $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
+
Added: branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-panel.c
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-panel.c Mon Jan 21 15:10:42 2008
@@ -0,0 +1,299 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "alternate-language-panel.h"
+#include "file-dialogs.h"
+#include "msg.h"
+#include "plugin.h"
+#include "po.h"
+#include "tab.h"
+
+#include <string.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#define GTR_ALTERNATE_LANG_PANEL_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
+ (object), \
+ GTR_TYPE_ALTERNATE_LANG_PANEL, \
+ GtranslatorAlternateLangPanelPrivate))
+
+GTR_PLUGIN_DEFINE_TYPE(GtranslatorAlternateLangPanel, gtranslator_alternate_lang_panel, GTK_TYPE_VBOX)
+
+
+struct _GtranslatorAlternateLangPanelPrivate
+{
+ GtkWidget *open_button;
+ GtkWidget *close_button;
+ GtkWidget *textview;
+
+ GtranslatorPo *po;
+ GtranslatorMsg *first;
+};
+
+static void
+gtranslator_alternate_lang_panel_set_text(GtranslatorAlternateLangPanel *panel,
+ const gchar *text)
+{
+ GtkTextBuffer *buf;
+
+ buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(panel->priv->textview));
+
+ gtk_text_buffer_set_text(buf, text, -1);
+}
+
+static void
+search_message(GtranslatorAlternateLangPanel *panel,
+ GtranslatorMsg *msg)
+{
+ GList *messages;
+ GList *l;
+ const gchar *msgid = gtranslator_msg_get_msgid(msg);
+ const gchar *string;
+
+ messages = gtranslator_po_get_messages(panel->priv->po);
+ l = messages;
+ do
+ {
+ string = gtranslator_msg_get_msgid(l->data);
+ if(g_utf8_collate(string, msgid) == 0)
+ {
+ gtranslator_alternate_lang_panel_set_text(panel,
+ gtranslator_msg_get_msgstr(l->data));
+ return;
+ }
+ } while ((l = g_list_next(l)));
+
+ gtranslator_alternate_lang_panel_set_text(panel,
+ _("Message not found"));
+}
+
+static void
+showed_message_cb(GtranslatorTab *tab,
+ GtranslatorMsg *msg,
+ GtranslatorAlternateLangPanel *panel)
+{
+ if(panel->priv->po == NULL)
+ {
+ panel->priv->first = msg;
+ return;
+ }
+ search_message(panel, msg);
+}
+
+static void
+open_file(GtkWidget *dialog,
+ GtranslatorAlternateLangPanel *panel)
+{
+ GError *error = NULL;
+ gchar *po_file = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
+
+
+ panel->priv->po = gtranslator_po_new();
+ gtranslator_po_parse(panel->priv->po, po_file, &error);
+
+ if(error != NULL)
+ {
+ /*
+ * We have to show the error in a dialog
+ */
+ gtk_message_dialog_new(NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ error->message);
+ g_error_free(error);
+ }
+
+ search_message(panel, panel->priv->first);
+ gtk_widget_set_sensitive(panel->priv->textview, TRUE);
+
+ g_free(po_file);
+
+ gtk_widget_destroy(dialog);
+}
+
+
+static void
+gtranslator_file_chooser_analyse(gpointer dialog,
+ GtranslatorAlternateLangPanel *panel)
+{
+ gint reply;
+
+ reply = gtk_dialog_run(GTK_DIALOG (dialog));
+ switch (reply){
+ case GTK_RESPONSE_ACCEPT:
+ open_file(GTK_WIDGET(dialog),
+ panel);
+ break;
+ case GTK_RESPONSE_CANCEL:
+ gtk_widget_hide(GTK_WIDGET(dialog));
+ break;
+ case GTK_RESPONSE_DELETE_EVENT:
+ gtk_widget_hide(GTK_WIDGET(dialog));
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+open_button_clicked_cb(GtkWidget *open_button,
+ GtranslatorAlternateLangPanel *panel)
+{
+ GtkWindow *dialog = NULL;
+
+ if(dialog != NULL) {
+ gtk_window_present(GTK_WINDOW(dialog));
+ return;
+ }
+
+ /*
+ * I need a way here to get the window
+ */
+ dialog = gtranslator_file_chooser_new (NULL,
+ FILESEL_OPEN,
+ _("Open file for alternate language"));
+
+ gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
+
+ gtranslator_file_chooser_analyse((gpointer) dialog, panel);
+}
+
+static void
+close_button_clicked_cb(GtkWidget *close_button,
+ GtranslatorAlternateLangPanel *panel)
+{
+ if(panel->priv->po != NULL)
+ {
+ gtranslator_alternate_lang_panel_set_text(panel, _("File closed"));
+
+ gtk_widget_set_sensitive(panel->priv->textview, FALSE);
+
+ g_object_unref(panel->priv->po);
+
+ panel->priv->po = NULL;
+ }
+}
+
+static void
+gtranslator_alternate_lang_panel_draw (GtranslatorAlternateLangPanel *panel)
+{
+ GtkWidget *buttonbox;
+ GtkWidget *scroll;
+
+ /*
+ * Button box
+ */
+ buttonbox = gtk_hbutton_box_new();
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_START);
+ gtk_widget_show(buttonbox);
+
+ panel->priv->open_button = gtk_button_new_from_stock(GTK_STOCK_OPEN);
+ g_signal_connect(panel->priv->open_button,
+ "clicked",
+ G_CALLBACK(open_button_clicked_cb),
+ panel);
+ gtk_widget_show(panel->priv->open_button);
+
+ panel->priv->close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+ g_signal_connect(panel->priv->close_button,
+ "clicked",
+ G_CALLBACK(close_button_clicked_cb),
+ panel);
+ gtk_widget_show(panel->priv->close_button);
+
+ gtk_box_pack_start(GTK_BOX(buttonbox),
+ panel->priv->open_button,
+ TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(buttonbox),
+ panel->priv->close_button,
+ TRUE, TRUE, 0);
+
+ gtk_box_pack_start(GTK_BOX(panel), buttonbox, FALSE, TRUE, 0);
+
+ /*
+ * Text view
+ */
+ scroll = gtk_scrolled_window_new(NULL, NULL);
+ gtk_widget_show(scroll);
+
+ panel->priv->textview = gtk_text_view_new();
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(panel->priv->textview),
+ GTK_WRAP_WORD);
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(panel->priv->textview),
+ FALSE);
+ gtranslator_alternate_lang_panel_set_text(panel, _("There isn't any file loaded"));
+ gtk_widget_set_sensitive(panel->priv->textview, FALSE);
+ gtk_widget_show(panel->priv->textview);
+
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll),
+ panel->priv->textview);
+
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+
+ gtk_box_pack_start(GTK_BOX(panel), scroll,
+ TRUE, TRUE, 0);
+}
+
+static void
+gtranslator_alternate_lang_panel_init (GtranslatorAlternateLangPanel *panel)
+{
+ panel->priv = GTR_ALTERNATE_LANG_PANEL_GET_PRIVATE (panel);
+
+ gtranslator_alternate_lang_panel_draw(panel);
+
+ panel->priv->po = NULL;
+}
+
+static void
+gtranslator_alternate_lang_panel_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gtranslator_alternate_lang_panel_parent_class)->finalize (object);
+}
+
+static void
+gtranslator_alternate_lang_panel_class_init (GtranslatorAlternateLangPanelClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtranslatorAlternateLangPanelPrivate));
+
+ object_class->finalize = gtranslator_alternate_lang_panel_finalize;
+}
+
+/***************************** Public funcs ***********************************/
+
+GtkWidget *
+gtranslator_alternate_lang_panel_new (GtkWidget *tab)
+{
+ GtranslatorAlternateLangPanel *panel;
+ panel = g_object_new (GTR_TYPE_ALTERNATE_LANG_PANEL, NULL);
+
+ g_signal_connect(tab, "showed-message",
+ G_CALLBACK(showed_message_cb),
+ panel);
+
+ return GTK_WIDGET(panel);
+}
Added: branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-panel.h
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-panel.h Mon Jan 21 15:10:42 2008
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __ALTERNATE_LANG_PANEL_H__
+#define __ALTERNATE_LANG_PANEL_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_ALTERNATE_LANG_PANEL (gtranslator_alternate_lang_panel_get_type ())
+#define GTR_ALTERNATE_LANG_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_ALTERNATE_LANG_PANEL, GtranslatorAlternateLangPanel))
+#define GTR_ALTERNATE_LANG_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_ALTERNATE_LANG_PANEL, GtranslatorAlternateLangPanelClass))
+#define GTR_IS_ALTERNATE_LANG_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_ALTERNATE_LANG_PANEL))
+#define GTR_IS_ALTERNATE_LANG_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_ALTERNATE_LANG_PANEL))
+#define GTR_ALTERNATE_LANG_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_ALTERNATE_LANG_PANEL, GtranslatorAlternateLangPanelClass))
+
+/* Private structure type */
+typedef struct _GtranslatorAlternateLangPanelPrivate GtranslatorAlternateLangPanelPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtranslatorAlternateLangPanel GtranslatorAlternateLangPanel;
+
+struct _GtranslatorAlternateLangPanel
+{
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorAlternateLangPanelPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtranslatorAlternateLangPanelClass GtranslatorAlternateLangPanelClass;
+
+struct _GtranslatorAlternateLangPanelClass
+{
+ GtkVBoxClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gtranslator_alternate_lang_panel_get_type (void) G_GNUC_CONST;
+GType gtranslator_alternate_lang_panel_register_type (GTypeModule * module);
+GtkWidget *gtranslator_alternate_lang_panel_new (GtkWidget *tab);
+
+G_END_DECLS
+
+#endif /* __ALTERNATE_LANG_PANEL_H__ */
Added: branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-plugin.c
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-plugin.c Mon Jan 21 15:10:42 2008
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANPOILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "alternate-language-plugin.h"
+#include "alternate-language-panel.h"
+#include "notebook.h"
+#include "window.h"
+#include "panel.h"
+
+#include <glib/gi18n-lib.h>
+
+#define WINDOW_DATA_KEY "GtranslatorAlternateLangPluginWindowData"
+
+#define GTR_MESSAGE_TABLE_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
+ GTR_TYPE_MESSAGE_TABLE, \
+ GtranslatorAlternateLangPluginPrivate))
+
+GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorAlternateLangPlugin, gtranslator_alternate_lang_plugin,
+ gtranslator_alternate_lang_panel_register_type (module);
+)
+
+
+static void
+gtranslator_alternate_lang_plugin_init (GtranslatorAlternateLangPlugin *message_table)
+{
+}
+
+static void
+gtranslator_alternate_lang_plugin_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gtranslator_alternate_lang_plugin_parent_class)->finalize (object);
+}
+
+
+static void
+create_alternate_lang_plugin_panel (GtkNotebook *notebook,
+ GtkWidget *child,
+ guint page_num,
+ GtranslatorWindow *window)
+{
+ GtkWidget *alternatelang;
+ GtkWidget *image;
+ GtranslatorPo *po;
+ GtranslatorPanel *panel;
+
+ po = gtranslator_tab_get_po(GTR_TAB(child));
+
+ g_return_if_fail(po != NULL);
+
+ alternatelang = gtranslator_alternate_lang_panel_new(child);
+
+ panel = gtranslator_tab_get_panel(GTR_TAB(child));
+
+ image = gtk_image_new_from_stock(GTK_STOCK_INDEX,
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+
+ gtranslator_panel_add_item(panel,
+ alternatelang,
+ _("Alternate Language"),
+ image);
+
+ g_object_set_data(G_OBJECT(child),
+ WINDOW_DATA_KEY,
+ alternatelang);
+}
+
+static void
+impl_activate (GtranslatorPlugin *plugin,
+ GtranslatorWindow *window)
+{
+ GtranslatorNotebook *notebook;
+ GList *tabs = NULL;
+
+ notebook = gtranslator_window_get_notebook(window);
+
+ g_signal_connect(GTK_NOTEBOOK(notebook),
+ "page-added",
+ G_CALLBACK(create_alternate_lang_plugin_panel), window);
+
+ tabs = gtranslator_window_get_all_tabs(window);
+
+ if(tabs == NULL)
+ return;
+ do{
+ create_alternate_lang_plugin_panel(GTK_NOTEBOOK(notebook),
+ tabs->data,
+ 0, window);
+ }while((tabs = g_list_next(tabs)));
+
+}
+
+static void
+impl_deactivate(GtranslatorPlugin *plugin,
+ GtranslatorWindow *window)
+{
+ GtranslatorPanel *panel;
+ GtranslatorNotebook *notebook;
+ GtkWidget *alternatelang;
+ GList *tabs;
+
+ tabs = gtranslator_window_get_all_tabs(window);
+ notebook = gtranslator_window_get_notebook(window);
+
+ if(tabs == NULL)
+ return;
+ do{
+ alternatelang = g_object_get_data(G_OBJECT(tabs->data), WINDOW_DATA_KEY);
+ panel = gtranslator_tab_get_panel (GTR_TAB(tabs->data));
+ gtranslator_panel_remove_item (panel, alternatelang);
+
+ g_object_set_data (G_OBJECT (tabs->data), WINDOW_DATA_KEY, NULL);
+
+ }while((tabs = g_list_next(tabs)));
+
+ g_signal_handlers_disconnect_by_func(notebook,
+ create_alternate_lang_plugin_panel,
+ window);
+}
+
+static void
+gtranslator_alternate_lang_plugin_class_init (GtranslatorAlternateLangPluginClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+
+ object_class->finalize = gtranslator_alternate_lang_plugin_finalize;
+
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+}
Added: branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-plugin.h
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/alternate-language/alternate-language-plugin.h Mon Jan 21 15:10:42 2008
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANPOILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Based on Gedit alternate_lang plugin
+ */
+
+#ifndef __GTR_ALTERNATE_LANG_PLUGIN_H__
+#define __GTR_ALTERNATE_LANG_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "plugin.h"
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_ALTERNATE_LANG_PLUGIN (gtranslator_alternate_lang_get_type ())
+#define GTR_ALTERNATE_LANG_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_MESSAGEALTERNATE_LANG_PLUGIN, GtranslatorAlternateLangPlugin))
+#define GTR_ALTERNATE_LANG_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_ALTERNATE_LANG_PLUGIN, GtranslatorAlternateLangPluginClass))
+#define GTR_IS_ALTERNATE_LANG_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_ALTERNATE_LANG_PLUGIN))
+#define GTR_IS_ALTERNATE_LANG_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_ALTERNATE_LANG_PLUGIN))
+#define GTR_ALTERNATE_LANG_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_ALTERNATE_LANG_PLUGIN_PLUGIN, GtranslatorAlternateLangPluginClass))
+
+/* Private structure type */
+typedef struct _GtranslatorAlternateLangPluginPrivate GtranslatorAlternateLangPluginPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtranslatorAlternateLangPlugin GtranslatorAlternateLangPlugin;
+
+struct _GtranslatorAlternateLangPlugin
+{
+ GtranslatorPlugin parent_instance;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtranslatorAlternateLangPluginClass GtranslatorAlternateLangPluginClass;
+
+struct _GtranslatorAlternateLangPluginClass
+{
+ GtranslatorPluginClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gtranslator_alternate_lang_plugin_get_type (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GTR_ALTERNATE_LANG_PLUGIN_H__ */
Added: branches/GOBJECT_WORK/plugins/alternate-language/alternate-language.gtranslator-plugin.desktop.in
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/alternate-language/alternate-language.gtranslator-plugin.desktop.in Mon Jan 21 15:10:42 2008
@@ -0,0 +1,8 @@
+[Gtranslator Plugin]
+Module=alternatelang
+IAge=2
+_Name=Alternate Language
+_Description=Load an alternate language.
+Authors=Ignacio Casal Quinteiro <nacho resa gmail com>
+Copyright=Copyright @ 2008 Ignacio Casal Quinteiro
+Website=http://gtranslator.sf.net
Added: branches/GOBJECT_WORK/plugins/charmap/Makefile.am
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/charmap/Makefile.am Mon Jan 21 15:10:42 2008
@@ -0,0 +1,38 @@
+# Charmap Panel plugin
+plugindir = $(libdir)/gtranslator/plugins
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/plugin-system \
+ $(GTRANSLATOR_CFLAGS) \
+ $(GUCHARMAP_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED_CFLAGS) \
+ -DGTR_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
+
+plugin_LTLIBRARIES = libcharmap.la
+
+libcharmap_la_SOURCES = \
+ charmap-plugin.h \
+ charmap-plugin.c \
+ charmap-panel.h \
+ charmap-panel.c
+
+libcharmap_la_LDFLAGS = \
+ $(PLUGIN_LIBTOOL_FLAGS) \
+ $(GTRANSLATOR_LIBS) \
+ $(GUCHARMAP_LIBS)
+
+# Plugin Info
+
+plugin_in_files = charmap.gtranslator-plugin.desktop.in
+
+%.gtranslator.plugin: %.gtranslator-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA = $(plugin_in_files:.gtranslator-plugin.desktop.in=.gtranslator.plugin)
+
+EXTRA_DIST = $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
Added: branches/GOBJECT_WORK/plugins/charmap/charmap-panel.c
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/charmap/charmap-panel.c Mon Jan 21 15:10:42 2008
@@ -0,0 +1,111 @@
+/*
+ * gtranslator-charmap-panel.c
+ *
+ * Copyright (C) 2006 Steve FrÃcinaux
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "plugin.h"
+#include "charmap-panel.h"
+#include <gucharmap/gucharmap-script-chapters.h>
+
+#define GTR_CHARMAP_PANEL_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
+ (object), \
+ GTR_TYPE_CHARMAP_PANEL, \
+ GtranslatorCharmapPanelPrivate))
+
+struct _GtranslatorCharmapPanelPrivate
+{
+ GtkWidget *table;
+ GtkWidget *chapters;
+};
+
+GTR_PLUGIN_DEFINE_TYPE(GtranslatorCharmapPanel, gtranslator_charmap_panel, GTK_TYPE_VBOX)
+
+static void
+on_chapter_changed (GucharmapChapters *chapters,
+ GtranslatorCharmapPanel *panel)
+{
+ gucharmap_table_set_codepoint_list (GUCHARMAP_TABLE (panel->priv->table),
+ gucharmap_chapters_get_codepoint_list (chapters));
+}
+
+static void
+gtranslator_charmap_panel_init (GtranslatorCharmapPanel *panel)
+{
+ GucharmapCodepointList *codepoint_list;
+ GtkPaned *paned;
+
+ panel->priv = GTR_CHARMAP_PANEL_GET_PRIVATE (panel);
+
+ panel->priv->chapters = gucharmap_script_chapters_new ();
+
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (GUCHARMAP_CHAPTERS (panel->priv->chapters)->tree_view),
+ FALSE);
+
+ codepoint_list = gucharmap_chapters_get_codepoint_list
+ (GUCHARMAP_CHAPTERS (panel->priv->chapters));
+
+ panel->priv->table = gucharmap_table_new ();
+
+ gucharmap_table_set_codepoint_list (GUCHARMAP_TABLE (panel->priv->table),
+ codepoint_list);
+
+ paned = GTK_PANED (gtk_vpaned_new ());
+ gtk_paned_pack1 (paned, panel->priv->chapters, FALSE, TRUE);
+ gtk_paned_pack2 (paned, panel->priv->table, TRUE, TRUE);
+ gtk_paned_set_position (paned, 150);
+
+ gtk_box_pack_start (GTK_BOX (panel), GTK_WIDGET (paned), TRUE, TRUE, 0);
+
+ g_signal_connect (panel->priv->chapters,
+ "changed",
+ G_CALLBACK (on_chapter_changed),
+ panel);
+}
+
+static void
+gtranslator_charmap_panel_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gtranslator_charmap_panel_parent_class)->finalize (object);
+}
+
+static void
+gtranslator_charmap_panel_class_init (GtranslatorCharmapPanelClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtranslatorCharmapPanelPrivate));
+
+ object_class->finalize = gtranslator_charmap_panel_finalize;
+}
+
+GtkWidget *
+gtranslator_charmap_panel_new (void)
+{
+ return GTK_WIDGET (g_object_new (GTR_TYPE_CHARMAP_PANEL, NULL));
+}
+
+GucharmapTable *
+gtranslator_charmap_panel_get_table (GtranslatorCharmapPanel *panel)
+{
+ return GUCHARMAP_TABLE (panel->priv->table);
+}
+
Added: branches/GOBJECT_WORK/plugins/charmap/charmap-panel.h
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/charmap/charmap-panel.h Mon Jan 21 15:10:42 2008
@@ -0,0 +1,79 @@
+/*
+ * charmap-panel.h
+ * This file is part of gtranslator
+ *
+ * Copyright (C) 2006 - Steve FrÃcinaux
+ *
+ * gtranslator 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.
+ *
+ * gtranslator 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 gtranslator; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GTR_CHARMAP_PANEL_H__
+#define __GTR_CHARMAP_PANEL_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <gucharmap/gucharmap-table.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_CHARMAP_PANEL (gtranslator_charmap_panel_get_type ())
+#define GTR_CHARMAP_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_CHARMAP_PANEL, GtranslatorCharmapPanel))
+#define GTR_CHARMAP_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_CHARMAP_PANEL, GtranslatorCharmapPanelClass))
+#define GTR_IS_CHARMAP_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_CHARMAP_PANEL))
+#define GTR_IS_CHARMAP_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_CHARMAP_PANEL))
+#define GTR_CHARMAP_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_CHARMAP_PANEL, GtranslatorCharmapPanelClass))
+
+/* Private structure type */
+typedef struct _GtranslatorCharmapPanelPrivate GtranslatorCharmapPanelPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtranslatorCharmapPanel GtranslatorCharmapPanel;
+
+struct _GtranslatorCharmapPanel
+{
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorCharmapPanelPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtranslatorCharmapPanelClass GtranslatorCharmapPanelClass;
+
+struct _GtranslatorCharmapPanelClass
+{
+ GtkVBoxClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gtranslator_charmap_panel_get_type (void) G_GNUC_CONST;
+GType gtranslator_charmap_panel_register_type (GTypeModule * module);
+GtkWidget *gtranslator_charmap_panel_new (void);
+GucharmapTable *gtranslator_charmap_panel_get_table (GtranslatorCharmapPanel *panel);
+
+G_END_DECLS
+
+#endif /* __CHARMAP_PANEL_H__ */
Added: branches/GOBJECT_WORK/plugins/charmap/charmap-plugin.c
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/charmap/charmap-plugin.c Mon Jan 21 15:10:42 2008
@@ -0,0 +1,294 @@
+/*
+ * gtranslator-charmap-plugin.c - Character map side-pane for gtranslator
+ *
+ * Copyright (C) 2006 Steve FrÃcinaux
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "charmap-plugin.h"
+#include "charmap-panel.h"
+
+#include <glib/gi18n-lib.h>
+#include "window.h"
+#include "panel.h"
+#include <gucharmap/gucharmap-table.h>
+#include <gucharmap/gucharmap-unicode-info.h>
+
+#define WINDOW_DATA_KEY "GtranslatorCharmapPluginWindowData"
+
+#define GTR_CHARMAP_PLUGIN_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
+ GTR_TYPE_CHARMAP_PLUGIN, \
+ GtranslatorCharmapPluginPrivate))
+
+typedef struct
+{
+ GtkWidget *panel;
+ guint context_id;
+} WindowData;
+
+GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorCharmapPlugin, gtranslator_charmap_plugin,
+ gtranslator_charmap_panel_register_type (module);
+)
+
+static void
+gtranslator_charmap_plugin_init (GtranslatorCharmapPlugin *plugin)
+{
+ //gtranslator_debug_message (DEBUG_PLUGINS, "GtranslatorCharmapPlugin initializing");
+}
+
+static void
+gtranslator_charmap_plugin_finalize (GObject *object)
+{
+ //gtranslator_debug_message (DEBUG_PLUGINS, "GtranslatorCharmapPlugin finalizing");
+
+ G_OBJECT_CLASS (gtranslator_charmap_plugin_parent_class)->finalize (object);
+}
+
+static void
+free_window_data (WindowData *data)
+{
+ g_return_if_fail (data != NULL);
+
+ g_free (data);
+}
+
+static void
+on_table_status_message (GucharmapTable *chartable,
+ const gchar *message,
+ GtranslatorWindow *window)
+{
+ GtkStatusbar *statusbar;
+ WindowData *data;
+
+ statusbar = GTK_STATUSBAR (gtranslator_window_get_statusbar (window));
+ data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ gtk_statusbar_pop (statusbar, data->context_id);
+
+ if (message)
+ gtk_statusbar_push (statusbar, data->context_id, message);
+}
+
+void
+on_table_set_active_char (GucharmapTable *chartable,
+ gunichar wc,
+ GtranslatorWindow *window)
+{
+ GString *gs;
+ const gchar **temps;
+ gint i;
+
+ gs = g_string_new (NULL);
+ g_string_append_printf (gs, "U+%4.4X %s", wc,
+ gucharmap_get_unicode_name (wc));
+
+ temps = gucharmap_get_nameslist_equals (wc);
+ if (temps)
+ {
+ g_string_append_printf (gs, " = %s", temps[0]);
+ for (i = 1; temps[i]; i++)
+ g_string_append_printf (gs, "; %s", temps[i]);
+ g_free (temps);
+ }
+
+ temps = gucharmap_get_nameslist_stars (wc);
+ if (temps)
+ {
+ g_string_append_printf (gs, " \342\200\242 %s", temps[0]);
+ for (i = 1; temps[i]; i++)
+ g_string_append_printf (gs, "; %s", temps[i]);
+ g_free (temps);
+ }
+
+ on_table_status_message (chartable, gs->str, window);
+ g_string_free (gs, TRUE);
+}
+
+static gboolean
+on_table_focus_out_event (GtkWidget *drawing_area,
+ GdkEventFocus *event,
+ GtranslatorWindow *window)
+{
+ GucharmapTable *chartable;
+ WindowData *data;
+
+ data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_val_if_fail (data != NULL, FALSE);
+
+ chartable = gtranslator_charmap_panel_get_table
+ (GTR_CHARMAP_PANEL (data->panel));
+
+ on_table_status_message (chartable, NULL, window);
+ return FALSE;
+}
+
+static void
+on_table_activate (GucharmapTable *chartable,
+ gunichar wc,
+ GtranslatorWindow *window)
+{
+ GtkTextView *view;
+ GtkTextBuffer *document;
+ GtkTextIter start, end;
+ gchar buffer[6];
+ gchar length;
+
+ g_return_if_fail (gucharmap_unichar_validate (wc));
+
+ view = GTK_TEXT_VIEW (gtranslator_window_get_active_view (window));
+
+ if (!view || !gtk_text_view_get_editable (view))
+ return;
+
+ document = gtk_text_view_get_buffer (view);
+
+ g_return_if_fail (document != NULL);
+
+ length = g_unichar_to_utf8 (wc, buffer);
+
+ gtk_text_buffer_begin_user_action (document);
+
+ gtk_text_buffer_get_selection_bounds (document, &start, &end);
+
+ gtk_text_buffer_delete_interactive (document, &start, &end, TRUE);
+ if (gtk_text_iter_editable (&start, TRUE))
+ gtk_text_buffer_insert (document, &start, buffer, length);
+
+ gtk_text_buffer_end_user_action (document);
+}
+
+static GtkWidget *
+create_charmap_panel (GtranslatorWindow *window)
+{
+ GtkWidget *panel;
+ GucharmapTable *table;
+
+ panel = gtranslator_charmap_panel_new ();
+ table = gtranslator_charmap_panel_get_table (GTR_CHARMAP_PANEL (panel));
+
+ g_signal_connect (table,
+ "status-message",
+ G_CALLBACK (on_table_status_message),
+ window);
+
+ g_signal_connect (table,
+ "set-active-char",
+ G_CALLBACK (on_table_set_active_char),
+ window);
+
+ /* Note: GucharmapTable does not provide focus-out-event ... */
+ g_signal_connect (table->drawing_area,
+ "focus-out-event",
+ G_CALLBACK (on_table_focus_out_event),
+ window);
+
+ g_signal_connect (table,
+ "activate",
+ G_CALLBACK (on_table_activate),
+ window);
+
+ gtk_widget_show_all (panel);
+
+ return panel;
+}
+
+static void
+impl_activate (GtranslatorPlugin *plugin,
+ GtranslatorWindow *window)
+{
+ GtranslatorPanel *panel;
+ GtkWidget *image;
+ GtkIconTheme *theme;
+ GtkStatusbar *statusbar;
+ WindowData *data;
+
+ //gtranslator_debug (DEBUG_PLUGINS);
+
+ panel = gtranslator_window_get_side_panel (window);
+
+ data = g_new (WindowData, 1);
+
+ theme = gtk_icon_theme_get_default ();
+
+ if (gtk_icon_theme_has_icon (theme, "accessories-character-map"))
+ image = gtk_image_new_from_icon_name ("accessories-character-map",
+ GTK_ICON_SIZE_MENU);
+ else
+ image = gtk_image_new_from_icon_name ("gucharmap",
+ GTK_ICON_SIZE_MENU);
+
+ data->panel = create_charmap_panel (window);
+
+ gtranslator_panel_add_item (panel,
+ data->panel,
+ _("Character Map"),
+ image);
+
+ gtk_object_sink (GTK_OBJECT (image));
+
+ statusbar = GTK_STATUSBAR (gtranslator_window_get_statusbar (window));
+ data->context_id = gtk_statusbar_get_context_id (statusbar,
+ "Character Description");
+
+ g_object_set_data_full (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ data,
+ (GDestroyNotify) free_window_data);
+}
+
+static void
+impl_deactivate (GtranslatorPlugin *plugin,
+ GtranslatorWindow *window)
+{
+ GtranslatorPanel *panel;
+ GucharmapTable *chartable;
+ WindowData *data;
+
+ //gtranslator_debug (DEBUG_PLUGINS);
+
+ data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ chartable = gtranslator_charmap_panel_get_table
+ (GTR_CHARMAP_PANEL (data->panel));
+ on_table_status_message (chartable, NULL, window);
+
+ panel = gtranslator_window_get_side_panel (window);
+ gtranslator_panel_remove_item (panel, data->panel);
+
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+}
+
+static void
+gtranslator_charmap_plugin_class_init (GtranslatorCharmapPluginClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+
+ object_class->finalize = gtranslator_charmap_plugin_finalize;
+
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+}
Added: branches/GOBJECT_WORK/plugins/charmap/charmap-plugin.h
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/charmap/charmap-plugin.h Mon Jan 21 15:10:42 2008
@@ -0,0 +1,75 @@
+/*
+ * gtranslator-charmap-plugin.h - Character map side-pane for gtranslator
+ *
+ * Copyright (C) 2006 Steve FrÃcinaux
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id: gtranslator-charmap-plugin.h 137 2006-04-23 15:13:27Z sfre $
+ */
+
+#ifndef __GTR_CHARMAP_PLUGIN_H__
+#define __GTR_CHARMAP_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "plugin.h"
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_CHARMAP_PLUGIN (gtranslator_charmap_plugin_get_type ())
+#define GTR_CHARMAP_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_CHARMAP_PLUGIN, GtranslatorCharmapPlugin))
+#define GTR_CHARMAP_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_CHARMAP_PLUGIN, GtranslatorCharmapPluginClass))
+#define GTR_IS_CHARMAP_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_CHARMAP_PLUGIN))
+#define GTR_IS_CHARMAP_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_CHARMAP_PLUGIN))
+#define GTR_CHARMAP_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_CHARMAP_PLUGIN, GtranslatorCharmapPluginClass))
+
+/* Private structure type */
+typedef struct _GtranslatorCharmapPluginPrivate GtranslatorCharmapPluginPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtranslatorCharmapPlugin GtranslatorCharmapPlugin;
+
+struct _GtranslatorCharmapPlugin
+{
+ GtranslatorPlugin parent_instance;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtranslatorCharmapPluginClass GtranslatorCharmapPluginClass;
+
+struct _GtranslatorCharmapPluginClass
+{
+ GtranslatorPluginClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gtranslator_charmap_plugin_get_type (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GTR_CHARMAP_PLUGIN_H__ */
Added: branches/GOBJECT_WORK/plugins/charmap/charmap.gtranslator-plugin.desktop.in
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/charmap/charmap.gtranslator-plugin.desktop.in Mon Jan 21 15:10:42 2008
@@ -0,0 +1,9 @@
+[Gtranslator Plugin]
+Module=charmap
+IAge=2
+_Name=Character Map
+_Description=Insert special characters just by clicking on them.
+Icon=gucharmap
+Authors=Steve FrÃcinaux <steve istique net>
+Copyright=Copyright @ 2006 Steve FrÃcinaux
+Website=http://www.gtranslator.org
Added: branches/GOBJECT_WORK/plugins/charmap/update-from-gedit.sh
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/charmap/update-from-gedit.sh Mon Jan 21 15:10:42 2008
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+#I don't know why but you have to change #include <gtk/gtkdialog.h>
+#in message-area.h to #<gtk/gtk.h>
+
+SVN_URI=http://svn.gnome.org/svn/gedit-plugins/trunk/plugins/charmap
+FILES="gedit-charmap-panel.h \
+ gedit-charmap-panel.c \
+ gedit-charmap-plugin.h \
+ gedit-charmap-plugin.c \
+ charmap.gedit-plugin.desktop.in"
+
+echo "Obtaining latest version of the sources"
+for FILE in $FILES
+do
+ svn export $SVN_URI/$FILE
+done
+
+sed_it () {
+ sed \
+ -e 's/gedit-panel.h/panel.h/g' \
+ -e 's/gedit-window.h/window.h/g' \
+ -e 's/#include "gedit-debug.h"/\/\/#include "gedit-debug.h"/g' \
+ -e 's/gedit/gtranslator/g' \
+ -e 's/Gedit/Gtranslator/g' \
+ -e 's/GEDIT/GTR/g' \
+ $1
+}
+
+sed_it gedit-charmap-panel.h > charmap-panel.h
+sed_it gedit-charmap-panel.c > charmap-panel.c
+sed_it gedit-charmap-plugin.h > charmap-plugin.h
+sed_it gedit-charmap-plugin.c > charmap-plugin.c
+sed_it charmap.gedit-plugin.desktop.in > charmap.gtranslator-plugin.desktop.in
+
+rm gedit-charmap-panel.h
+rm gedit-charmap-panel.c
+rm gedit-charmap-plugin.h
+rm gedit-charmap-plugin.c
+rm charmap.gedit-plugin.desktop.in
+
Added: branches/GOBJECT_WORK/plugins/dictionary/Makefile.am
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/dictionary/Makefile.am Mon Jan 21 15:10:42 2008
@@ -0,0 +1,42 @@
+# Dictionary Panel plugin
+plugindir = $(libdir)/gtranslator/plugins
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/plugin-system \
+ -I$(top_srcdir)/src/toolbareditor \
+ $(GTRANSLATOR_CFLAGS) \
+ $(DICTIONARY_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED_CFLAGS) \
+ -DGTR_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
+
+plugin_LTLIBRARIES = libdict.la
+
+libdict_la_SOURCES = \
+ dict-panel.h \
+ dict-panel.c \
+ gdict-sidebar.c \
+ gdict-sidebar.h \
+ dictionary-plugin.h \
+ dictionary-plugin.c
+
+
+libdict_la_LDFLAGS = \
+ $(PLUGIN_LIBTOOL_FLAGS) \
+ $(GTRANSLATOR_LIBS) \
+ $(DICTIONARY_LIBS)
+
+# Plugin Info
+
+plugin_in_files = dict.gtranslator-plugin.desktop.in
+
+%.gtranslator.plugin: %.gtranslator-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA = $(plugin_in_files:.gtranslator-plugin.desktop.in=.gtranslator.plugin)
+
+EXTRA_DIST = $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
Added: branches/GOBJECT_WORK/plugins/dictionary/dict-panel.c
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/dictionary/dict-panel.c Mon Jan 21 15:10:42 2008
@@ -0,0 +1,702 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "dict-panel.h"
+#include "gdict-sidebar.h"
+
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <gdict/gdict.h>
+#include <gconf/gconf-client.h>
+#include <gtranslator/plugin.h>
+
+#define GTR_DICT_PANEL_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
+ (object), \
+ GTR_TYPE_DICT_PANEL, \
+ GtranslatorDictPanelPrivate))
+
+#define GDICT_GCONF_DIR "/apps/gnome-dictionary"
+#define GDICT_GCONF_DATABASE_KEY GDICT_GCONF_DIR "/database"
+#define GDICT_GCONF_STRATEGY_KEY GDICT_GCONF_DIR "/strategy"
+#define GDICT_DEFAULT_SOURCE_NAME "Default"
+#define GDICT_GCONF_SOURCE_KEY GDICT_GCONF_DIR "/source-name"
+
+#define PANEL_KEY "/apps/gtranslator/plugins/dictionary"
+
+/* sidebar pages logical ids */
+#define GDICT_SIDEBAR_SPELLER_PAGE "speller"
+#define GDICT_SIDEBAR_DATABASES_PAGE "db-chooser"
+#define GDICT_SIDEBAR_STRATEGIES_PAGE "strat-chooser"
+
+GTR_PLUGIN_DEFINE_TYPE(GtranslatorDictPanel, gtranslator_dict_panel, GTK_TYPE_VBOX)
+
+struct _GtranslatorDictPanelPrivate
+{
+ GtkPaned *paned;
+
+ GtkTooltips *tooltips;
+
+ GConfClient *gconf_client;
+ guint notify_id;
+
+ gchar *database;
+ gchar *strategy;
+ gchar *source_name;
+
+ gchar *word;
+ GdictContext *context;
+ guint lookup_start_id;
+ guint lookup_end_id;
+ guint error_id;
+
+ GdictSourceLoader *loader;
+
+ GtkWidget *speller;
+ GtkWidget *db_chooser;
+ GtkWidget *strat_chooser;
+ GtkWidget *entry;
+ GtkWidget *button;
+ GtkWidget *defbox;
+ GtkWidget *sidebar;
+};
+
+
+static gchar *
+gdict_get_data_dir (void)
+{
+ gchar *retval;
+
+ retval = g_build_filename (g_get_home_dir (),
+ ".gnome2",
+ "gnome-dictionary",
+ NULL);
+
+ return retval;
+}
+
+static gchar *
+gdict_gconf_get_string_with_default (GConfClient *client,
+ const gchar *key,
+ const gchar *def)
+{
+ gchar *val;
+
+ val = gconf_client_get_string (client, key, NULL);
+ return val ? val : g_strdup (def);
+}
+
+static void
+clear_cb (GtkWidget *widget,
+ GtranslatorDictPanel *panel)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), "");
+
+ if (!priv->defbox)
+ return;
+
+ gdict_defbox_clear (GDICT_DEFBOX (priv->defbox));
+}
+
+static void
+gtranslator_dict_panel_entry_activate_cb (GtkWidget *widget,
+ GtranslatorDictPanel *panel)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ const gchar *text;
+
+ text = gtk_entry_get_text (GTK_ENTRY(priv->entry));
+
+ if (!text)
+ return;
+
+ g_free (priv->word);
+ priv->word = g_strdup(text);
+
+ gdict_defbox_lookup (GDICT_DEFBOX (priv->defbox), priv->word);
+}
+
+static void
+gtranslator_dict_panel_set_database (GtranslatorDictPanel *panel,
+ const gchar *database)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+
+ g_free (priv->database);
+
+ if (database)
+ priv->database = g_strdup (database);
+ else
+ priv->database = gdict_gconf_get_string_with_default (priv->gconf_client,
+ GDICT_GCONF_DATABASE_KEY,
+ GDICT_DEFAULT_DATABASE);
+ if (priv->defbox)
+ gdict_defbox_set_database (GDICT_DEFBOX (priv->defbox),
+ priv->database);
+}
+
+static void
+gtranslator_dict_panel_set_strategy (GtranslatorDictPanel *panel,
+ const gchar *strategy)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+
+ g_free (priv->strategy);
+
+ if (strategy)
+ priv->strategy = g_strdup (strategy);
+ else
+ priv->strategy = gdict_gconf_get_string_with_default (priv->gconf_client,
+ GDICT_GCONF_STRATEGY_KEY,
+ GDICT_DEFAULT_STRATEGY);
+}
+
+static GdictContext *
+get_context_from_loader (GtranslatorDictPanel *panel)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ GdictSource *source;
+ GdictContext *retval;
+
+ if (!priv->source_name)
+ priv->source_name = g_strdup (GDICT_DEFAULT_SOURCE_NAME);
+
+ source = gdict_source_loader_get_source (priv->loader,
+ priv->source_name);
+ if (!source)
+ {
+ gchar *detail;
+
+ detail = g_strdup_printf (_("No dictionary source available with name '%s'"),
+ priv->source_name);
+
+ g_warning(_("Unable to find dictionary source"));
+ g_free (detail);
+
+ return NULL;
+ }
+
+ gtranslator_dict_panel_set_database (panel, gdict_source_get_database (source));
+ gtranslator_dict_panel_set_strategy (panel, gdict_source_get_strategy (source));
+
+ retval = gdict_source_get_context (source);
+ if (!retval)
+ {
+ gchar *detail;
+
+ detail = g_strdup_printf (_("No context available for source '%s'"),
+ gdict_source_get_description (source));
+
+ /*gdict_show_error_dialog (NULL,
+ _("Unable to create a context"),
+ detail);*/
+ g_warning(_("Unable to create a context"));
+
+ g_free (detail);
+ g_object_unref (source);
+
+ return NULL;
+ }
+
+ g_object_unref (source);
+
+ return retval;
+}
+
+static void
+gtranslator_dict_panel_set_context (GtranslatorDictPanel *panel,
+ GdictContext *context)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+
+ if (priv->context)
+ {
+ g_signal_handler_disconnect (priv->context, priv->lookup_start_id);
+ g_signal_handler_disconnect (priv->context, priv->lookup_end_id);
+ g_signal_handler_disconnect (priv->context, priv->error_id);
+
+ priv->lookup_start_id = 0;
+ priv->lookup_end_id = 0;
+ priv->error_id = 0;
+
+ g_object_unref (priv->context);
+ priv->context = NULL;
+ }
+
+ if (priv->defbox)
+ gdict_defbox_set_context (GDICT_DEFBOX (priv->defbox), context);
+
+ if (!context)
+ return;
+
+ /* attach our callbacks */
+ /* priv->lookup_start_id = g_signal_connect (context, "lookup-start",
+ G_CALLBACK (gdict_applet_lookup_start_cb),
+ panel);
+ priv->lookup_end_id = g_signal_connect (context, "lookup-end",
+ G_CALLBACK (gdict_applet_lookup_end_cb),
+ panel);*/
+ /*priv->error_id = g_signal_connect (context, "error",
+ G_CALLBACK (gdict_applet_error_cb),
+ panel);*/
+
+ priv->context = context;
+}
+
+static void
+gtranslator_dict_panel_set_source_name (GtranslatorDictPanel *panel,
+ const gchar *source_name)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ GdictContext *context;
+
+ g_free (priv->source_name);
+
+ if (source_name)
+ priv->source_name = g_strdup (source_name);
+ else
+ priv->source_name = gdict_gconf_get_string_with_default (priv->gconf_client,
+ GDICT_GCONF_SOURCE_KEY,
+ GDICT_DEFAULT_SOURCE_NAME);
+
+ context = get_context_from_loader (panel);
+ gtranslator_dict_panel_set_context (panel, context);
+}
+
+static void
+strategy_activated_cb (GdictStrategyChooser *chooser,
+ const gchar *strat_name,
+ const gchar *strat_desc,
+ GtranslatorDictPanel *panel)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ gtranslator_dict_panel_set_strategy (panel, strat_name);
+/*
+ if (window->status)
+ {
+ gchar *message;
+
+ message = g_strdup_printf (_("Strategy `%s' selected"), strat_desc);
+ gtk_statusbar_push (GTK_STATUSBAR (window->status), 0, message);
+ g_free (message);
+ }*/
+}
+
+static void
+database_activated_cb (GdictDatabaseChooser *chooser,
+ const gchar *db_name,
+ const gchar *db_desc,
+ GtranslatorDictPanel *panel)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ gtranslator_dict_panel_set_database (panel, db_name);
+ /*
+ if (window->status)
+ {
+ gchar *message;
+
+ message = g_strdup_printf (_("Database `%s' selected"), db_desc);
+ gtk_statusbar_push (GTK_STATUSBAR (window->status), 0, message);
+ g_free (message);
+ }*/
+}
+
+static void
+gtranslator_dict_panel_set_word (GtranslatorDictPanel *panel,
+ const gchar *word,
+ const gchar *database)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ gchar *title;
+
+ g_free (priv->word);
+ priv->word = NULL;
+
+ if (word && word[0] != '\0')
+ priv->word = g_strdup (word);
+ else
+ return;
+
+ if (!database || database[0] == '\0')
+ database = priv->database;
+
+ if (priv->defbox)
+ {
+ gdict_defbox_set_database (GDICT_DEFBOX (priv->defbox), database);
+ gdict_defbox_lookup (GDICT_DEFBOX (priv->defbox), word);
+ }
+}
+
+static void
+speller_word_activated_cb (GdictSpeller *speller,
+ const gchar *word,
+ const gchar *db_name,
+ GtranslatorDictPanel *panel)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), word);
+
+ gtranslator_dict_panel_set_word (panel, word, db_name);
+ /*
+ if (window->status)
+ {
+ gchar *message;
+
+ message = g_strdup_printf (_("Word `%s' selected"), word);
+ gtk_statusbar_push (GTK_STATUSBAR (window->status), 0, message);
+ g_free (message);
+ }*/
+}
+
+
+
+static void
+sidebar_page_changed_cb (GdictSidebar *sidebar,
+ GtranslatorDictPanel *panel)
+{
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+ const gchar *page_id;
+ const gchar *message;
+
+ page_id = gdict_sidebar_current_page (sidebar);
+
+ switch (page_id[0])
+ {
+ case 's':
+ {
+ switch (page_id[1])
+ {
+ case 'p': /* speller */
+ message = _("Double-click on the word to look up");
+ if (priv->word)
+ gdict_speller_match (GDICT_SPELLER (priv->speller),
+ priv->word);
+ break;
+ case 't': /* strat-chooser */
+ message = _("Double-click on the matching strategy to use");
+
+ gdict_strategy_chooser_refresh (GDICT_STRATEGY_CHOOSER (priv->strat_chooser));
+ break;
+ default:
+ message = NULL;
+ }
+ }
+ break;
+ case 'd': /* db-chooser */
+ message = _("Double-click on the database to use");
+
+ gdict_database_chooser_refresh (GDICT_DATABASE_CHOOSER (priv->db_chooser));
+ break;
+ default:
+ message = NULL;
+ break;
+ }
+
+ /*if (message && window->status)
+ gtk_statusbar_push (GTK_STATUSBAR (window->status), 0, message);*/
+}
+
+static void
+store_position(GObject *gobject,
+ GParamSpec *arg1,
+ gpointer user_data)
+{
+ GtkPaned *paned = GTK_PANED(gobject);
+ GConfClient *client;
+ gint position;
+
+ client = gconf_client_get_default();
+ position = gtk_paned_get_position(paned);
+ gconf_client_set_int(client, PANEL_KEY "/panel_position", position, NULL);
+
+ g_object_unref(client);
+}
+
+static void
+gtranslator_dict_panel_link_clicked(GtkWidget *defbox,
+ const gchar *link_text,
+ GtranslatorDictPanel *panel)
+{
+ if (!link_text)
+ return;
+
+ g_free (panel->priv->word);
+ panel->priv->word = g_strdup(link_text);
+
+ gtk_entry_set_text(GTK_ENTRY(panel->priv->entry), link_text);
+
+ gdict_defbox_lookup (GDICT_DEFBOX (defbox), panel->priv->word);
+}
+
+static void
+gtranslator_dict_panel_draw (GtranslatorDictPanel *panel)
+{
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
+ gtk_widget_show (vbox);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ /*
+ * Look up Button
+ */
+ panel->priv->button = gtk_button_new_with_mnemonic (_("Look _up:"));
+ g_signal_connect(panel->priv->button, "clicked",
+ G_CALLBACK (gtranslator_dict_panel_entry_activate_cb),
+ panel);
+ gtk_button_set_relief (GTK_BUTTON (panel->priv->button), GTK_RELIEF_NONE);
+ gtk_box_pack_start (GTK_BOX (hbox), panel->priv->button, FALSE, FALSE, 0);
+ gtk_widget_show(panel->priv->button);
+
+ /*
+ * Entry
+ */
+ panel->priv->entry = gtk_entry_new ();
+ if (panel->priv->word)
+ gtk_entry_set_text (GTK_ENTRY (panel->priv->entry), panel->priv->word);
+
+ g_signal_connect (panel->priv->entry, "activate",
+ G_CALLBACK (gtranslator_dict_panel_entry_activate_cb),
+ panel);
+ gtk_box_pack_start (GTK_BOX (hbox), panel->priv->entry, TRUE, TRUE, 0);
+ gtk_widget_show (panel->priv->entry);
+
+
+ /*
+ * Defbox
+ */
+ panel->priv->defbox = gdict_defbox_new ();
+ if (panel->priv->context)
+ gdict_defbox_set_context (GDICT_DEFBOX (panel->priv->defbox),
+ panel->priv->context);
+ g_signal_connect(panel->priv->defbox, "link-clicked",
+ G_CALLBACK(gtranslator_dict_panel_link_clicked), panel);
+
+ gtk_container_add (GTK_CONTAINER (vbox), panel->priv->defbox);
+ gtk_widget_show (panel->priv->defbox);
+
+ panel->priv->sidebar = gdict_sidebar_new ();
+ g_signal_connect (panel->priv->sidebar, "page-changed",
+ G_CALLBACK (sidebar_page_changed_cb),
+ panel);
+
+ /*
+ * Paned
+ */
+ panel->priv->paned = GTK_PANED(gtk_vpaned_new());
+ gtk_box_pack_start (GTK_BOX (panel), GTK_WIDGET(panel->priv->paned), TRUE, TRUE, 0);
+ gtk_paned_pack1 (panel->priv->paned, vbox, FALSE, TRUE);
+ gtk_paned_pack2 (panel->priv->paned, panel->priv->sidebar, TRUE, TRUE);
+ gtk_widget_show (GTK_WIDGET(panel->priv->paned));
+
+ g_signal_connect(panel->priv->paned, "notify::position",
+ G_CALLBACK(store_position), NULL);
+
+
+ /*
+ * Speller
+ */
+ panel->priv->speller = gdict_speller_new ();
+ if (panel->priv->context)
+ gdict_speller_set_context (GDICT_SPELLER (panel->priv->speller),
+ panel->priv->context);
+ g_signal_connect (panel->priv->speller, "word-activated",
+ G_CALLBACK (speller_word_activated_cb),
+ panel);
+
+ gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
+ GDICT_SIDEBAR_SPELLER_PAGE,
+ _("Similar words"),
+ panel->priv->speller);
+ gtk_widget_show (panel->priv->speller);
+
+ /*
+ * db chooser
+ */
+ panel->priv->db_chooser = gdict_database_chooser_new ();
+ if (panel->priv->context)
+ gdict_database_chooser_set_context (GDICT_DATABASE_CHOOSER (panel->priv->db_chooser),
+ panel->priv->context);
+ g_signal_connect (panel->priv->db_chooser, "database-activated",
+ G_CALLBACK (database_activated_cb),
+ panel);
+ gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
+ GDICT_SIDEBAR_DATABASES_PAGE,
+ _("Available dictionaries"),
+ panel->priv->db_chooser);
+ gtk_widget_show (panel->priv->db_chooser);
+
+ /*
+ * Strategy chooser
+ */
+ panel->priv->strat_chooser = gdict_strategy_chooser_new ();
+ if (panel->priv->context)
+ gdict_strategy_chooser_set_context (GDICT_STRATEGY_CHOOSER (panel->priv->strat_chooser),
+ panel->priv->context);
+ g_signal_connect (panel->priv->strat_chooser, "strategy-activated",
+ G_CALLBACK (strategy_activated_cb),
+ panel);
+ gdict_sidebar_add_page (GDICT_SIDEBAR (panel->priv->sidebar),
+ GDICT_SIDEBAR_STRATEGIES_PAGE,
+ _("Available strategies"),
+ panel->priv->strat_chooser);
+ gtk_widget_show (panel->priv->strat_chooser);
+
+ gtk_widget_show (panel->priv->sidebar);
+
+
+}
+
+static void
+gtranslator_dict_panel_gconf_notify_cb (GConfClient *client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer user_data)
+{
+ GtranslatorDictPanel *panel = GTR_DICT_PANEL (user_data);
+ GtranslatorDictPanelPrivate *priv = panel->priv;
+
+ if (strcmp (entry->key, GDICT_GCONF_SOURCE_KEY) == 0)
+ {
+ if (entry->value && (entry->value->type == GCONF_VALUE_STRING))
+ gtranslator_dict_panel_set_source_name (panel, gconf_value_get_string (entry->value));
+ else
+ gtranslator_dict_panel_set_source_name (panel, GDICT_DEFAULT_SOURCE_NAME);
+ }
+ else if (strcmp (entry->key, GDICT_GCONF_DATABASE_KEY) == 0)
+ {
+ if (entry->value && (entry->value->type == GCONF_VALUE_STRING))
+ gtranslator_dict_panel_set_database (panel, gconf_value_get_string (entry->value));
+ else
+ gtranslator_dict_panel_set_database (panel, GDICT_DEFAULT_DATABASE);
+ }
+ else if (strcmp (entry->key, GDICT_GCONF_STRATEGY_KEY) == 0)
+ {
+ if (entry->value && (entry->value->type == GCONF_VALUE_STRING))
+ gtranslator_dict_panel_set_strategy (panel, gconf_value_get_string (entry->value));
+ else
+ gtranslator_dict_panel_set_strategy (panel, GDICT_DEFAULT_STRATEGY);
+ }
+}
+
+static void
+gtranslator_dict_panel_init(GtranslatorDictPanel *panel)
+{
+ gchar * data_dir;
+ GtranslatorDictPanelPrivate *priv;
+ GError *gconf_error;
+
+ panel->priv = GTR_DICT_PANEL_GET_PRIVATE (panel);
+ priv = panel->priv;
+
+ if (!priv->loader)
+ panel->priv->loader = gdict_source_loader_new ();
+
+ /* add our data dir inside $HOME to the loader's search paths */
+ data_dir = gdict_get_data_dir ();
+ gdict_source_loader_add_search_path (priv->loader, data_dir);
+ g_free (data_dir);
+
+
+
+ /* get the default gconf client */
+ if (!priv->gconf_client)
+ priv->gconf_client = gconf_client_get_default ();
+
+ gconf_error = NULL;
+ gconf_client_add_dir (priv->gconf_client,
+ GDICT_GCONF_DIR,
+ GCONF_CLIENT_PRELOAD_ONELEVEL,
+ &gconf_error);
+ if (gconf_error)
+ {
+ /*gdict_show_gerror_dialog (NULL,
+ _("Unable to connect to GConf"),
+ gconf_error);*/
+ gconf_error = NULL;
+ }
+
+ priv->notify_id = gconf_client_notify_add (priv->gconf_client,
+ GDICT_GCONF_DIR,
+ gtranslator_dict_panel_gconf_notify_cb,
+ panel, NULL,
+ &gconf_error);
+ if (gconf_error)
+ {
+ /*gdict_show_gerror_dialog (NULL,
+ _("Unable to get notification for preferences"),
+ gconf_error);*/
+
+ gconf_error = NULL;
+ }
+
+ /* force retrieval of the configuration from GConf */
+ gtranslator_dict_panel_set_source_name (panel, NULL);
+
+ /* Draw widgets */
+ gtranslator_dict_panel_draw(panel);
+}
+
+static void
+gtranslator_dict_panel_finalize (GObject *object)
+{
+ GtranslatorDictPanel *panel = GTR_DICT_PANEL (object);
+
+ g_free (panel->priv->source_name);
+ g_free (panel->priv->word);
+ g_free (panel->priv->database);
+ g_free (panel->priv->strategy);
+
+ G_OBJECT_CLASS (gtranslator_dict_panel_parent_class)->finalize (object);
+}
+
+static void
+gtranslator_dict_panel_class_init (GtranslatorDictPanelClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtranslatorDictPanelPrivate));
+
+ gobject_class->finalize = gtranslator_dict_panel_finalize;
+
+}
+
+GtkWidget *
+gtranslator_dict_panel_new (void)
+{
+ return GTK_WIDGET (g_object_new (GTR_TYPE_DICT_PANEL, NULL));
+}
+
+void
+gtranslator_dict_panel_set_position(GtranslatorDictPanel *panel,
+ gint pos)
+{
+ gtk_paned_set_position(panel->priv->paned, pos);
+}
+
Added: branches/GOBJECT_WORK/plugins/dictionary/dict-panel.h
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/dictionary/dict-panel.h Mon Jan 21 15:10:42 2008
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __DICT_PANEL_H__
+#define __DICT_PANEL_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_DICT_PANEL (gtranslator_dict_panel_get_type ())
+#define GTR_DICT_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_DICT_PANEL, GtranslatorDictPanel))
+#define GTR_DICT_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_DICT_PANEL, GtranslatorDictPanelClass))
+#define GTR_IS_DICT_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_DICT_PANEL))
+#define GTR_IS_DICT_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_DICT_PANEL))
+#define GTR_DICT_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_DICT_PANEL, GtranslatorDictPanelClass))
+
+/* Private structure type */
+typedef struct _GtranslatorDictPanelPrivate GtranslatorDictPanelPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtranslatorDictPanel GtranslatorDictPanel;
+
+struct _GtranslatorDictPanel
+{
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorDictPanelPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtranslatorDictPanelClass GtranslatorDictPanelClass;
+
+struct _GtranslatorDictPanelClass
+{
+ GtkVBoxClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gtranslator_dict_panel_get_type (void) G_GNUC_CONST;
+
+GType gtranslator_dict_panel_register_type (GTypeModule * module);
+
+GtkWidget * gtranslator_dict_panel_new (void);
+
+void gtranslator_dict_panel_set_position (GtranslatorDictPanel *panel,
+ gint pos);
+
+G_END_DECLS
+
+#endif /* __DICT_PANEL_H__ */
Added: branches/GOBJECT_WORK/plugins/dictionary/dict.gtranslator-plugin.desktop.in
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/dictionary/dict.gtranslator-plugin.desktop.in Mon Jan 21 15:10:42 2008
@@ -0,0 +1,9 @@
+[Gtranslator Plugin]
+Module=dict
+IAge=2
+_Name=Dictionary
+_Description=Look up words in a dictionary.
+Icon=gdict
+Authors=Ignacio Casal <nacho resa gmail com>
+Copyright=Copyright @ 2007 Ignacio Casal
+Website=http://gtranslator.sf.net
Added: branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.c
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.c Mon Jan 21 15:10:42 2008
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "dictionary-plugin.h"
+#include "dict-panel.h"
+
+#include <glib/gi18n-lib.h>
+#include <gconf/gconf-client.h>
+//#include <gtranslator/gtranslator-debug.h>
+#include <gtranslator/window.h>
+#include <gtranslator/panel.h>
+
+
+#define WINDOW_DATA_KEY "GtranslatorDictPluginWindowData"
+#define PANEL_KEY "/apps/gtranslator/plugins/dictionary"
+
+#define GTR_DICT_PLUGIN_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
+ GTR_TYPE_DICT_PLUGIN, \
+ GtranslatorDictPluginPrivate))
+
+typedef struct
+{
+ GtkWidget *panel;
+ guint context_id;
+} WindowData;
+
+GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorDictPlugin, gtranslator_dict_plugin,
+ gtranslator_dict_panel_register_type (module);
+)
+
+static void
+gtranslator_dict_plugin_init (GtranslatorDictPlugin *plugin)
+{
+ //gtranslator_debug_message (DEBUG_PLUGINS, "GtranslatorDictPlugin initializing");
+}
+
+static void
+gtranslator_dict_plugin_finalize (GObject *object)
+{
+ //gtranslator_debug_message (DEBUG_PLUGINS, "GtranslatorDictPlugin finalizing");
+
+ G_OBJECT_CLASS (gtranslator_dict_plugin_parent_class)->finalize (object);
+}
+
+static void
+free_window_data (WindowData *data)
+{
+ g_return_if_fail (data != NULL);
+
+ g_object_unref (data->panel);
+ g_free (data);
+}
+
+
+static GtkWidget *
+create_dict_panel (GtranslatorWindow *window)
+{
+ GtkWidget *panel;
+
+ panel = gtranslator_dict_panel_new ();
+
+ gtk_widget_show_all (panel);
+
+ return panel;
+}
+
+static void
+restore_position(GtranslatorDictPanel *panel)
+{
+ GConfClient *client;
+ gint position;
+
+ client = gconf_client_get_default();
+ position = gconf_client_get_int(client, PANEL_KEY "/panel_position", NULL);
+ gtranslator_dict_panel_set_position(panel, position);
+
+ g_object_unref(client);
+}
+
+static void
+impl_activate (GtranslatorPlugin *plugin,
+ GtranslatorWindow *window)
+{
+ GtranslatorPanel *panel;
+ GtkWidget *image;
+ GtkIconTheme *theme;
+ GtkStatusbar *statusbar;
+ WindowData *data;
+
+ //gtranslator_debug (DEBUG_PLUGINS);
+
+ panel = gtranslator_window_get_side_panel (window);
+
+ data = g_new (WindowData, 1);
+
+ theme = gtk_icon_theme_get_default ();
+
+ if (gtk_icon_theme_has_icon (theme, "accessories-dictionary"))
+ image = gtk_image_new_from_icon_name ("accessories-dictionary",
+ GTK_ICON_SIZE_MENU);
+ else
+ image = gtk_image_new_from_icon_name ("gdict",
+ GTK_ICON_SIZE_MENU);
+
+ data->panel = create_dict_panel (window);
+
+ restore_position(GTR_DICT_PANEL(data->panel));
+
+ gtranslator_panel_add_item (panel,
+ data->panel,
+ _("Dictionary"),
+ image);
+
+ gtk_object_sink (GTK_OBJECT (image));
+
+ g_object_set_data_full (G_OBJECT (window),
+ WINDOW_DATA_KEY,
+ data,
+ (GDestroyNotify) free_window_data);
+}
+
+static void
+impl_deactivate (GtranslatorPlugin *plugin,
+ GtranslatorWindow *window)
+{
+ GtranslatorPanel *panel;
+ WindowData *data;
+
+ //gtranslator_debug (DEBUG_PLUGINS);
+
+ data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ panel = gtranslator_window_get_side_panel (window);
+
+ gtranslator_panel_remove_item (panel, data->panel);
+
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+}
+
+static void
+gtranslator_dict_plugin_class_init (GtranslatorDictPluginClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+
+ object_class->finalize = gtranslator_dict_plugin_finalize;
+
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+}
Added: branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.h
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/dictionary/dictionary-plugin.h Mon Jan 21 15:10:42 2008
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTR_Dict_PLUGIN_H__
+#define __GTR_Dict_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtranslator/plugin.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_DICT_PLUGIN (gtranslator_dict_plugin_get_type ())
+#define GTR_DICT_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_DICT_PLUGIN, GtranslatorDictPlugin))
+#define GTR_DICT_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_Dict_PLUGIN, GtranslatorDictPluginClass))
+#define GTR_IS_DICT_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_Dict_PLUGIN))
+#define GTR_IS_DICT_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_Dict_PLUGIN))
+#define GTR_Dict_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_Dict_PLUGIN, GtranslatorDictPluginClass))
+
+/* Private structure type */
+typedef struct _GtranslatorDictPluginPrivate GtranslatorDictPluginPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtranslatorDictPlugin GtranslatorDictPlugin;
+
+struct _GtranslatorDictPlugin
+{
+ GtranslatorPlugin parent_instance;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtranslatorDictPluginClass GtranslatorDictPluginClass;
+
+struct _GtranslatorDictPluginClass
+{
+ GtranslatorPluginClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gtranslator_Dict_plugin_get_type (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GTR_Dict_PLUGIN_H__ */
Added: branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.c
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.c Mon Jan 21 15:10:42 2008
@@ -0,0 +1,525 @@
+/* gdict-sidebar.c - sidebar widget
+ *
+ * Copyright (C) 2006 Emmanuele Bassi <ebassi gmail com>
+ * 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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., 59 Temple Place - Suite 330,
+ *
+ * Based on the equivalent widget from Evince
+ * by Jonathan Blandford,
+ * Copyright (C) 2004 Red Hat, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+#include <gtk/gtkbindings.h>
+#include <glib/gi18n.h>
+
+#include "gdict-sidebar.h"
+
+typedef struct
+{
+ guint index;
+
+ gchar *id;
+ gchar *name;
+
+ GtkWidget *child;
+ GtkWidget *menu_item;
+} SidebarPage;
+
+#define GDICT_SIDEBAR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GDICT_TYPE_SIDEBAR, GdictSidebarPrivate))
+
+struct _GdictSidebarPrivate
+{
+ GHashTable *pages_by_id;
+ GSList *pages;
+
+ GtkWidget *hbox;
+ GtkWidget *notebook;
+ GtkWidget *menu;
+ GtkWidget *label;
+ GtkWidget *select_button;
+};
+
+enum
+{
+ PAGE_CHANGED,
+ CLOSED,
+
+ LAST_SIGNAL
+};
+
+static guint sidebar_signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (GdictSidebar, gdict_sidebar, GTK_TYPE_VBOX);
+
+#define SIDEBAR_PAGE_ID (sidebar_page_id_quark ())
+static GQuark
+sidebar_page_id_quark (void)
+{
+ return g_quark_from_static_string ("gdict-sidebar-page-id");
+}
+
+SidebarPage *
+sidebar_page_new (const gchar *id,
+ const gchar *name,
+ GtkWidget *widget)
+{
+ SidebarPage *page;
+
+ page = g_slice_new (SidebarPage);
+
+ page->id = g_strdup (id);
+ page->name = g_strdup (name);
+ page->child = widget;
+ page->index = -1;
+ page->menu_item = NULL;
+
+ return page;
+}
+
+void
+sidebar_page_free (SidebarPage *page)
+{
+ if (G_LIKELY (page))
+ {
+ g_free (page->name);
+ g_free (page->id);
+
+ g_slice_free (SidebarPage, page);
+ }
+}
+
+static void
+gdict_sidebar_finalize (GObject *object)
+{
+ GdictSidebar *sidebar = GDICT_SIDEBAR (object);
+ GdictSidebarPrivate *priv = sidebar->priv;
+
+ if (priv->pages_by_id)
+ g_hash_table_destroy (priv->pages_by_id);
+
+ if (priv->pages)
+ {
+ g_slist_foreach (priv->pages, (GFunc) sidebar_page_free, NULL);
+ g_slist_free (priv->pages);
+ }
+
+ G_OBJECT_CLASS (gdict_sidebar_parent_class)->finalize (object);
+}
+
+static void
+gdict_sidebar_dispose (GObject *object)
+{
+ GdictSidebar *sidebar = GDICT_SIDEBAR (object);
+
+ if (sidebar->priv->menu)
+ {
+ gtk_menu_detach (GTK_MENU (sidebar->priv->menu));
+ sidebar->priv->menu = NULL;
+ }
+
+ G_OBJECT_CLASS (gdict_sidebar_parent_class)->dispose (object);
+}
+
+static void
+gdict_sidebar_menu_position_function (GtkMenu *menu,
+ gint *x,
+ gint *y,
+ gboolean *push_in,
+ gpointer user_data)
+{
+ GtkWidget *widget;
+
+ g_assert (GTK_IS_BUTTON (user_data));
+
+ widget = GTK_WIDGET (user_data);
+
+ gdk_window_get_origin (widget->window, x, y);
+
+ *x += widget->allocation.x;
+ *y += widget->allocation.y + widget->allocation.height;
+
+ *push_in = FALSE;
+}
+
+static gboolean
+gdict_sidebar_select_button_press_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ GdictSidebar *sidebar = GDICT_SIDEBAR (user_data);
+
+ if (event->button == 1)
+ {
+ GtkRequisition req;
+ gint width;
+
+ width = widget->allocation.width;
+ gtk_widget_set_size_request (sidebar->priv->menu, -1, -1);
+ gtk_widget_size_request (sidebar->priv->menu, &req);
+ gtk_widget_set_size_request (sidebar->priv->menu,
+ MAX (width, req.width), -1);
+ gtk_widget_grab_focus (widget);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+ gtk_menu_popup (GTK_MENU (sidebar->priv->menu),
+ NULL, NULL,
+ gdict_sidebar_menu_position_function, widget,
+ event->button, event->time);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+gdict_sidebar_select_key_press_cb (GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer user_data)
+{
+ GdictSidebar *sidebar = GDICT_SIDEBAR (user_data);
+
+ if (event->keyval == GDK_space ||
+ event->keyval == GDK_KP_Space ||
+ event->keyval == GDK_Return ||
+ event->keyval == GDK_KP_Enter)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+ gtk_menu_popup (GTK_MENU (sidebar->priv->menu),
+ NULL, NULL,
+ gdict_sidebar_menu_position_function, widget,
+ 1, event->time);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+static void
+gdict_sidebar_menu_deactivate_cb (GtkWidget *widget,
+ gpointer user_data)
+{
+ GdictSidebar *sidebar = GDICT_SIDEBAR (user_data);
+ GdictSidebarPrivate *priv = sidebar->priv;
+ GtkToggleButton *select_button = GTK_TOGGLE_BUTTON (priv->select_button);
+
+ gtk_toggle_button_set_active (select_button, FALSE);
+}
+
+static void
+gdict_sidebar_menu_detach_cb (GtkWidget *widget,
+ GtkMenu *menu)
+{
+ GdictSidebar *sidebar = GDICT_SIDEBAR (widget);
+
+ sidebar->priv->menu = NULL;
+}
+
+static void
+gdict_sidebar_menu_item_activate (GtkWidget *widget,
+ gpointer user_data)
+{
+ GdictSidebar *sidebar = GDICT_SIDEBAR (user_data);
+ GdictSidebarPrivate *priv = sidebar->priv;
+ GtkWidget *menu_item;
+ const gchar *id;
+ SidebarPage *page;
+ gint current_index;
+
+ menu_item = gtk_menu_get_active (GTK_MENU (priv->menu));
+ id = g_object_get_qdata (G_OBJECT (menu_item), SIDEBAR_PAGE_ID);
+ g_assert (id != NULL);
+
+ page = g_hash_table_lookup (priv->pages_by_id, id);
+ g_assert (page != NULL);
+
+ current_index = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
+ if (current_index == page->index)
+ return;
+
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
+ page->index);
+ gtk_label_set_text (GTK_LABEL (priv->label), page->name);
+
+ g_signal_emit (sidebar, sidebar_signals[PAGE_CHANGED], 0);
+}
+
+static void
+gdict_sidebar_class_init (GdictSidebarClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = gdict_sidebar_finalize;
+ gobject_class->dispose = gdict_sidebar_dispose;
+
+ sidebar_signals[PAGE_CHANGED] =
+ g_signal_new ("page-changed",
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdictSidebarClass, page_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+ sidebar_signals[CLOSED] =
+ g_signal_new ("closed",
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdictSidebarClass, closed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ g_type_class_add_private (gobject_class, sizeof (GdictSidebarPrivate));
+}
+
+static void
+gdict_sidebar_init (GdictSidebar *sidebar)
+{
+ GdictSidebarPrivate *priv;
+ GtkWidget *hbox;
+ GtkWidget *select_hbox;
+ GtkWidget *select_button;
+ GtkWidget *arrow;
+
+ sidebar->priv = priv = GDICT_SIDEBAR_GET_PRIVATE (sidebar);
+
+ /* we store all the pages inside the list, but we keep
+ * a pointer inside the hash table for faster look up
+ * times; what's inside the table will be destroyed with
+ * the list, so there's no need to supply the destroy
+ * functions for keys and values.
+ */
+ priv->pages = NULL;
+ priv->pages_by_id = g_hash_table_new (g_str_hash, g_str_equal);
+
+ /* top option menu */
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (sidebar), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+ priv->hbox = hbox;
+
+ select_button = gtk_toggle_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (select_button), GTK_RELIEF_NONE);
+ g_signal_connect (select_button, "button-press-event",
+ G_CALLBACK (gdict_sidebar_select_button_press_cb),
+ sidebar);
+ g_signal_connect (select_button, "key-press-event",
+ G_CALLBACK (gdict_sidebar_select_key_press_cb),
+ sidebar);
+ priv->select_button = select_button;
+
+ select_hbox = gtk_hbox_new (FALSE, 0);
+
+ priv->label = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (select_hbox), priv->label, FALSE, FALSE, 0);
+ gtk_widget_show (priv->label);
+
+ arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
+ gtk_box_pack_end (GTK_BOX (select_hbox), arrow, FALSE, FALSE, 0);
+ gtk_widget_show (arrow);
+
+ gtk_container_add (GTK_CONTAINER (select_button), select_hbox);
+ gtk_widget_show (select_hbox);
+
+ gtk_box_pack_start (GTK_BOX (hbox), select_button, TRUE, TRUE, 0);
+ gtk_widget_show (select_button);
+
+ sidebar->priv->menu = gtk_menu_new ();
+ g_signal_connect (sidebar->priv->menu, "deactivate",
+ G_CALLBACK (gdict_sidebar_menu_deactivate_cb),
+ sidebar);
+ gtk_menu_attach_to_widget (GTK_MENU (sidebar->priv->menu),
+ GTK_WIDGET (sidebar),
+ gdict_sidebar_menu_detach_cb);
+ gtk_widget_show (sidebar->priv->menu);
+
+ sidebar->priv->notebook = gtk_notebook_new ();
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (sidebar->priv->notebook), FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (sidebar->priv->notebook), FALSE);
+ gtk_box_pack_start (GTK_BOX (sidebar), sidebar->priv->notebook, TRUE, TRUE, 6);
+ gtk_widget_show (sidebar->priv->notebook);
+}
+
+/*
+ * Public API
+ */
+
+GtkWidget *
+gdict_sidebar_new (void)
+{
+ return g_object_new (GDICT_TYPE_SIDEBAR, NULL);
+}
+
+void
+gdict_sidebar_add_page (GdictSidebar *sidebar,
+ const gchar *page_id,
+ const gchar *page_name,
+ GtkWidget *page_widget)
+{
+ GdictSidebarPrivate *priv;
+ SidebarPage *page;
+ GtkWidget *menu_item;
+
+ g_return_if_fail (GDICT_IS_SIDEBAR (sidebar));
+ g_return_if_fail (page_id != NULL);
+ g_return_if_fail (page_name != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (page_widget));
+
+ priv = sidebar->priv;
+
+ if (g_hash_table_lookup (priv->pages_by_id, page_id))
+ {
+ g_warning ("Attempting to add a page to the sidebar with "
+ "id `%s', but there already is a page with the "
+ "same id. Aborting...",
+ page_id);
+ return;
+ }
+
+ /* add the page inside the page list */
+ page = sidebar_page_new (page_id, page_name, page_widget);
+
+ priv->pages = g_slist_append (priv->pages, page);
+ g_hash_table_insert (priv->pages_by_id, page->id, page);
+
+ page->index = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
+ page_widget,
+ NULL);
+
+ /* add the menu item for the page */
+ menu_item = gtk_image_menu_item_new_with_label (page_name);
+ g_object_set_qdata_full (G_OBJECT (menu_item),
+ SIDEBAR_PAGE_ID,
+ g_strdup (page_id),
+ (GDestroyNotify) g_free);
+ g_signal_connect (menu_item, "activate",
+ G_CALLBACK (gdict_sidebar_menu_item_activate),
+ sidebar);
+ gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), menu_item);
+ gtk_widget_show (menu_item);
+ page->menu_item = menu_item;
+
+ gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->menu), menu_item);
+ gtk_label_set_text (GTK_LABEL (priv->label), page_name);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page->index);
+}
+
+void
+gdict_sidebar_remove_page (GdictSidebar *sidebar,
+ const gchar *page_id)
+{
+ GdictSidebarPrivate *priv;
+ SidebarPage *page;
+ GtkWidget *menu_item;
+ GList *children, *l;
+
+ g_return_if_fail (GDICT_IS_SIDEBAR (sidebar));
+ g_return_if_fail (page_id != NULL);
+
+ priv = sidebar->priv;
+
+ if ((page = g_hash_table_lookup (priv->pages_by_id, page_id)) == NULL)
+ {
+ g_warning ("Attempting to remove a page from the sidebar with "
+ "id `%s', but there is no page with this id. Aborting...",
+ page_id);
+ return;
+ }
+
+ children = gtk_container_get_children (GTK_CONTAINER (priv->menu));
+ for (l = children; l != NULL; l = l->next)
+ {
+ GtkWidget *menu_item = l->data;
+
+ if (menu_item == page->menu_item)
+ {
+ gtk_container_remove (GTK_CONTAINER (priv->menu), menu_item);
+ break;
+ }
+ }
+ g_list_free (children);
+
+ gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), page->index);
+
+ g_hash_table_remove (priv->pages_by_id, page->id);
+ priv->pages = g_slist_remove (priv->pages, page);
+
+ sidebar_page_free (page);
+
+ /* select the first page, if present */
+ page = priv->pages->data;
+ if (page)
+ {
+ gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->menu), page->menu_item);
+ gtk_label_set_text (GTK_LABEL (priv->label), page->name);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page->index);
+ }
+ else
+ gtk_widget_hide (GTK_WIDGET (sidebar));
+}
+
+void
+gdict_sidebar_view_page (GdictSidebar *sidebar,
+ const gchar *page_id)
+{
+ GdictSidebarPrivate *priv;
+ SidebarPage *page;
+
+ g_return_if_fail (GDICT_IS_SIDEBAR (sidebar));
+ g_return_if_fail (page_id != NULL);
+
+ priv = sidebar->priv;
+ page = g_hash_table_lookup (priv->pages_by_id, page_id);
+ if (!page)
+ return;
+
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
+ page->index);
+ gtk_label_set_text (GTK_LABEL (priv->label), page->name);
+ gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->menu), page->menu_item);
+}
+
+G_CONST_RETURN gchar *
+gdict_sidebar_current_page (GdictSidebar *sidebar)
+{
+ GdictSidebarPrivate *priv;
+ gint index;
+ SidebarPage *page;
+
+ g_return_val_if_fail (GDICT_IS_SIDEBAR (sidebar), NULL);
+
+ priv = sidebar->priv;
+
+ index = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
+ page = g_slist_nth_data (priv->pages, index);
+ g_assert (page != NULL);
+
+ return page->id;
+}
Added: branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.h
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/dictionary/gdict-sidebar.h Mon Jan 21 15:10:42 2008
@@ -0,0 +1,73 @@
+/* gdict-sidebar.h - sidebar widget
+ *
+ * Copyright (C) 2006 Emmanuele Bassi <ebassi gmail com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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., 59 Temple Place - Suite 330,
+ *
+ * Based on the equivalent widget from Evince
+ * by Jonathan Blandford,
+ * Copyright (C) 2004 Red Hat, Inc.
+ */
+
+#ifndef __GDICT_SIDEBAR_H__
+#define __GDICT_SIDEBAR_H__
+
+#include <gtk/gtkvbox.h>
+
+#define GDICT_TYPE_SIDEBAR (gdict_sidebar_get_type ())
+#define GDICT_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDICT_TYPE_SIDEBAR, GdictSidebar))
+#define GDICT_IS_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDICT_TYPE_SIDEBAR))
+#define GDICT_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDICT_TYPE_SIDEBAR, GdictSidebarClass))
+#define GDICT_IS_SIDEBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDICT_TYPE_SIDEBAR))
+#define GDICT_SIDEBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDICT_TYPE_SIDEBAR, GdictSidebarClass))
+
+typedef struct _GdictSidebar GdictSidebar;
+typedef struct _GdictSidebarPrivate GdictSidebarPrivate;
+typedef struct _GdictSidebarClass GdictSidebarClass;
+
+struct _GdictSidebar
+{
+ GtkVBox parent_instance;
+
+ GdictSidebarPrivate *priv;
+};
+
+struct _GdictSidebarClass
+{
+ GtkVBoxClass parent_class;
+
+ void (*page_changed) (GdictSidebar *sidebar);
+ void (*closed) (GdictSidebar *sidebar);
+
+ void (*_gdict_padding_1) (void);
+ void (*_gdict_padding_2) (void);
+ void (*_gdict_padding_3) (void);
+ void (*_gdict_padding_4) (void);
+};
+
+GType gdict_sidebar_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gdict_sidebar_new (void);
+void gdict_sidebar_add_page (GdictSidebar *sidebar,
+ const gchar *page_id,
+ const gchar *page_name,
+ GtkWidget *page_widget);
+void gdict_sidebar_remove_page (GdictSidebar *sidebar,
+ const gchar *page_id);
+void gdict_sidebar_view_page (GdictSidebar *sidebar,
+ const gchar *page_id);
+G_CONST_RETURN gchar *gdict_sidebar_current_page (GdictSidebar *sidebar);
+
+#endif /* __GDICT_SIDEBAR_H__ */
Added: branches/GOBJECT_WORK/plugins/glossary/glossary-panel.c
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/glossary/glossary-panel.c Mon Jan 21 15:10:42 2008
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "glossary-panel.h"
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlmemory.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define GTR_GLOSSARY_PANEL_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
+ (object), \
+ GTR_TYPE_GLOSSARY_PANEL, \
+ GtranslatorGlossaryPanelPrivate))
+
+G_DEFINE_TYPE(GtranslatorGlossaryPanel, gtranslator_glossary_panel, GTK_TYPE_VBOX)
+
+#define XML_FILE_NAME "glossary.xml"
+
+/*
+ * TreeItem structure
+ */
+typedef struct _TreeItem TreeItem;
+struct _TreeItem
+{
+ gchar *word;
+ gchar *description;
+ GList *children;
+};
+
+enum
+{
+ WORD_COLUMN,
+ DESCRIPTION_COLUMN,
+ N_COLUMNS
+};
+
+struct _GtranslatorGlossaryPanelPrivate
+{
+ GtkWidget *tree;
+ GtkWidget *search_entry;
+ GtkWidget *add_button;
+ xmlDocPtr *doc;
+ GList *elements;
+};
+
+typedef struct person {
+ xmlChar *name;
+ xmlChar *email;
+ xmlChar *company;
+ xmlChar *organisation;
+ xmlChar *smail;
+ xmlChar *webPage;
+ xmlChar *phone;
+} person, *personPtr;
+
+/*
+ * And the code needed to parse it
+ */
+static personPtr
+parsePerson(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
+ personPtr ret = NULL;
+
+ /*
+ * allocate the struct
+ */
+ ret = (personPtr) malloc(sizeof(person));
+ if (ret == NULL) {
+ fprintf(stderr,"out of memory\n");
+ return(NULL);
+ }
+ memset(ret, 0, sizeof(person));
+
+ /* We don't care what the top level element name is */
+ /* COMPAT xmlChildrenNode is a macro unifying libxml1 and libxml2 names */
+ cur = cur->xmlChildrenNode;
+ while (cur != NULL) {
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Person")) &&
+ (cur->ns == ns))
+ ret->name = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Email")) &&
+ (cur->ns == ns))
+ ret->email = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+ cur = cur->next;
+ }
+
+ return(ret);
+}
+
+static void
+process_node(xmlNode *root_node)
+{
+ GtranslatorGlossaryPanelPrivate *priv;
+
+ xmlNodePtr cur_node;
+
+ cur_node = cur_node->xmlChildrenNode;
+
+}
+
+static gboolean
+gtranslator_glossary_panel_load_items(GtranslatorGlossaryPanel *panel)
+{
+ GtranslatorGlossaryPanelPrivate *priv = panel->priv;
+
+ return FALSE;
+}
+
+static void
+gtranslator_glossary_panel_draw (GtranslatorGlossaryPanel *panel)
+{
+ GtranslatorGlossaryPanelPrivate *priv = panel->priv;
+
+ priv->tree = gtk_tree_view_new();
+}
+
+static void
+gtranslator_glossary_panel_init (GtranslatorGlossaryPanel *panel)
+{
+ panel->priv = GTR_GLOSSARY_PANEL_GET_PRIVATE (panel);
+
+
+}
+
+static void
+gtranslator_glossary_panel_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gtranslator_glossary_panel_parent_class)->finalize (object);
+}
+
+static void
+gtranslator_glossary_panel_class_init (GtranslatorGlossaryPanelClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtranslatorGlossaryPanelPrivate));
+
+ object_class->finalize = gtranslator_glossary_panel_finalize;
+}
+
+GtkWidget *
+gtranslator_glossary_panel_new (void)
+{
+ return GTK_WIDGET (g_object_new (GTR_TYPE_GLOSSARY_PANEL, NULL));
+}
+
Added: branches/GOBJECT_WORK/plugins/glossary/glossary-panel.h
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/glossary/glossary-panel.h Mon Jan 21 15:10:42 2008
@@ -0,0 +1,78 @@
+/*
+ * glossary-panel.h
+ * This file is part of gtranslator
+ *
+ * Copyright (C) 2006 - Steve FrÃcinaux
+ * 2007 - Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * gtranslator 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.
+ *
+ * gtranslator 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 gtranslator; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GLOSSARY_PANEL_H__
+#define __GLOSSARY_PANEL_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_GLOSSARY_PANEL (gtranslator_glossary_panel_get_type ())
+#define GTR_GLOSSARY_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_GLOSSARY_PANEL, GtranslatorGlossaryPanel))
+#define GTR_GLOSSARY_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_GLOSSARY_PANEL, GtranslatorGlossaryPanelClass))
+#define GTR_IS_GLOSSARY_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_GLOSSARY_PANEL))
+#define GTR_IS_GLOSSARY_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_GLOSSARY_PANEL))
+#define GTR_GLOSSARY_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_GLOSSARY_PANEL, GtranslatorGlossaryPanelClass))
+
+/* Private structure type */
+typedef struct _GtranslatorGlossaryPanelPrivate GtranslatorGlossaryPanelPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtranslatorGlossaryPanel GtranslatorGlossaryPanel;
+
+struct _GtranslatorGlossaryPanel
+{
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorGlossaryPanelPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtranslatorGlossaryPanelClass GtranslatorGlossaryPanelClass;
+
+struct _GtranslatorGlossaryPanelClass
+{
+ GtkVBoxClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gtranslator_glossary_panel_get_type (void) G_GNUC_CONST;
+GType gtranslator_glossary_panel_register_type (GTypeModule * module);
+GtkWidget *gtranslator_glossary_panel_new (void);
+
+G_END_DECLS
+
+#endif /* __GLOSSARY_PANEL_H__ */
Added: branches/GOBJECT_WORK/plugins/open-tran/Makefile.am
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/open-tran/Makefile.am Mon Jan 21 15:10:42 2008
@@ -0,0 +1,49 @@
+# Open-tran Panel plugin
+plugindir = $(libdir)/gtranslator/plugins
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/plugin-system \
+ -I$(top_srcdir)/src/toolbareditor \
+ -DPIXMAPSDIR=\""$(datadir)"/pixmaps/gtranslator\" \
+ $(GTRANSLATOR_CFLAGS) \
+ $(SOUP_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED_CFLAGS) \
+ -DGTR_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
+
+plugin_LTLIBRARIES = libopentran.la
+
+libopentran_la_SOURCES = \
+ open-tran-panel.c \
+ open-tran-panel.h\
+ open-tran-plugin.c \
+ open-tran-plugin.h
+
+libopentran_la_LDFLAGS = \
+ $(PLUGIN_LIBTOOL_FLAGS) \
+ $(GTRANSLATOR_LIBS) \
+ $(SOUP_LIBS)
+
+pixmaps_dir = $(datadir)/pixmaps/gtranslator
+pixmaps__DATA = \
+ gnome.png \
+ kde.ico \
+ mozilla.png \
+ debian.png \
+ open-tran.png
+
+# Plugin Info
+
+plugin_in_files = open-tran.gtranslator-plugin.desktop.in
+
+%.gtranslator.plugin: %.gtranslator-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA = $(plugin_in_files:.gtranslator-plugin.desktop.in=.gtranslator.plugin)
+
+EXTRA_DIST = $(pixmaps__DATA) $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
+
Added: branches/GOBJECT_WORK/plugins/open-tran/debian.png
==============================================================================
Binary file. No diff available.
Added: branches/GOBJECT_WORK/plugins/open-tran/gnome.png
==============================================================================
Binary file. No diff available.
Added: branches/GOBJECT_WORK/plugins/open-tran/kde.ico
==============================================================================
Binary file. No diff available.
Added: branches/GOBJECT_WORK/plugins/open-tran/mozilla.png
==============================================================================
Binary file. No diff available.
Added: branches/GOBJECT_WORK/plugins/open-tran/open-tran-panel.c
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/open-tran/open-tran-panel.c Mon Jan 21 15:10:42 2008
@@ -0,0 +1,506 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANPOILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "open-tran-panel.h"
+#include "application.h"
+#include "window.h"
+#include "header.h"
+#include "plugin.h"
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <libsoup/soup.h>
+#include <libsoup/soup-xmlrpc-message.h>
+#include <libsoup/soup-xmlrpc-response.h>
+
+#define GTR_OPEN_TRAN_PANEL_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
+ (object), \
+ GTR_TYPE_OPEN_TRAN_PANEL, \
+ GtranslatorOpenTranPanelPrivate))
+
+#define GNOME_ICON PIXMAPSDIR"/gnome.png"
+#define KDE_ICON PIXMAPSDIR"/kde.ico"
+#define MOZILLA_ICON PIXMAPSDIR"/mozilla.png"
+#define DEBIAN_ICON PIXMAPSDIR"/debian.png"
+
+GTR_PLUGIN_DEFINE_TYPE(GtranslatorOpenTranPanel, gtranslator_open_tran_panel, GTK_TYPE_VBOX)
+
+struct _GtranslatorOpenTranPanelPrivate
+{
+ GtkWidget *treeview;
+ GtkListStore *store;
+
+ GtkWidget *entry;
+ GtkWidget *lang_code;
+
+ SoupSession *session;
+
+ GtranslatorWindow *window;
+
+ gchar *text;
+};
+
+enum
+{
+ ICON_COLUMN,
+ TEXT_COLUMN,
+ N_COLUMNS
+};
+
+
+static void
+dialog_response_cb(GtkWidget *dialog,
+ gint response,
+ gpointer useless)
+{
+ switch(response)
+ {
+ case GTK_RESPONSE_CLOSE: gtk_widget_destroy(dialog);
+ break;
+ }
+}
+
+static void
+show_error_dialog (GtranslatorWindow *parent,
+ const gchar *message_format,
+ ...)
+{
+ gchar *msg = NULL;
+ va_list args;
+ GtkWidget *dialog;
+
+ va_start (args, message_format);
+ msg = g_strdup_vprintf (message_format, args);
+ va_end (args);
+
+ dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ msg);
+ g_free(msg);
+
+ g_signal_connect(dialog, "response",
+ G_CALLBACK(dialog_response_cb), NULL);
+ gtk_widget_show(dialog);
+}
+
+static GdkPixbuf *
+create_pixbuf(const gchar *path)
+{
+ GdkPixbuf *icon;
+ GError *error = NULL;
+
+ icon = gdk_pixbuf_new_from_file(path, &error);
+
+ if (error)
+ {
+ g_warning ("Could not load icon: %s\n", error->message);
+ g_error_free(error);
+ return NULL;
+ }
+
+ return icon;
+}
+
+static void
+print_struct_to_tree_view(gpointer value,
+ GtranslatorOpenTranPanel *panel)
+{
+ gchar *str;
+ GdkPixbuf *icon;
+ GtkTreeIter iter;
+
+ /*
+ * Text value
+ */
+ if (soup_xmlrpc_value_get_string (value, &str))
+ {
+ /*
+ * We have to parse the first character of str:
+ * G - Gnome
+ * K - KDE
+ * M - Mozilla
+ * D - Debian Installer
+ * F - Frysian dictionary
+ */
+ switch(*str)
+ {
+ case 'G': icon = create_pixbuf(GNOME_ICON);
+ break;
+ case 'K': icon = create_pixbuf(KDE_ICON);
+ break;
+ case 'M': icon = create_pixbuf(MOZILLA_ICON);
+ break;
+ case 'D': icon = create_pixbuf(DEBIAN_ICON);
+ break;
+ default: icon = NULL;
+ break;
+ }
+
+ gtk_list_store_append(panel->priv->store, &iter);
+ gtk_list_store_set(panel->priv->store, &iter,
+ ICON_COLUMN, icon,
+ TEXT_COLUMN, panel->priv->text,
+ -1);
+ }
+}
+
+/*
+ * To see the protocol spec:
+ * http://bugzilla.gnome.org/show_bug.cgi?id=506469
+ */
+static void
+print_struct_field (gpointer key,
+ gpointer value,
+ gpointer data)
+{
+ GtranslatorOpenTranPanel *panel = GTR_OPEN_TRAN_PANEL(data);
+ gchar *str;
+ SoupXmlrpcValue *result;
+ SoupXmlrpcValueArrayIterator *ar_iter;
+ GHashTable *hash;
+ GList *values;
+
+ /*
+ * Text value
+ */
+ if (soup_xmlrpc_value_get_string (value, &str))
+ {
+ panel->priv->text = str;
+ }
+
+ /*
+ * Now we have to detect the type of the text (Gnome, Kde...)
+ */
+ if (soup_xmlrpc_value_array_get_iterator (value, &ar_iter))
+ {
+ if(!soup_xmlrpc_value_array_iterator_get_value(ar_iter, &result))
+ {
+ show_error_dialog(panel->priv->window,
+ _("WRONG! Can't get result element 1\n"));
+ return;
+ }
+ if (!soup_xmlrpc_value_get_struct (result, &hash)) {
+ show_error_dialog(panel->priv->window,
+ _("WRONG! Result element 1 is not a struct"));
+ return;
+ }
+
+ values = g_hash_table_get_values(hash);
+ if((values = g_list_next(values)))
+ print_struct_to_tree_view(values->data, panel);
+ }
+}
+
+static void
+got_response (SoupMessage *msg,
+ gpointer data)
+{
+ GtranslatorOpenTranPanel *panel = GTR_OPEN_TRAN_PANEL(data);
+ SoupXmlrpcResponse *response;
+ SoupXmlrpcValue *value;
+ GHashTable *hash;
+ SoupXmlrpcValueArrayIterator *iter;
+ SoupXmlrpcValue *result;
+ GtkTreeIter treeiter;
+ gint i;
+
+ if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
+ show_error_dialog(panel->priv->window,
+ _("Error: %d %s\n"),
+ msg->status_code,
+ msg->reason_phrase);
+ return;
+ }
+
+ response = soup_xmlrpc_message_parse_response (SOUP_XMLRPC_MESSAGE (msg));
+ if (!response) {
+ show_error_dialog(panel->priv->window,
+ /*
+ * Translators: XMLRPC is the name of the protocol
+ */
+ _("Could not parse XMLRPC response\n"));
+ return;
+ }
+
+ value = soup_xmlrpc_response_get_value (response);
+ if (!value) {
+ show_error_dialog(panel->priv->window,
+ /*
+ * Translators: XMLRPC is the name of the protocol
+ */
+ _("No response value in XMLRPC response\n"));
+ return;
+ }
+
+ if (!soup_xmlrpc_value_array_get_iterator (value, &iter)) {
+ show_error_dialog(panel->priv->window,
+ /*
+ * Translators: XMLRPC is the name of the protocol
+ */
+ _("Could not extract result from XMLRPC response\n"));
+ return;
+ }
+
+ i = 0;
+ while(iter)
+ {
+ if(!soup_xmlrpc_value_array_iterator_get_value(iter, &result))
+ {
+ show_error_dialog(panel->priv->window,
+ _("WRONG! Can't get result element %d\n"), i + 1);
+ g_object_unref (response);
+ return;
+ }
+ if (!soup_xmlrpc_value_get_struct (result, &hash)) {
+ show_error_dialog(panel->priv->window,
+ _("WRONG! Result element %d is not a struct"), i + 1);
+ g_object_unref (response);
+ return;
+ }
+
+ g_hash_table_foreach(hash, print_struct_field, data);
+ iter = soup_xmlrpc_value_array_iterator_next(iter);
+ i++;
+ }
+
+ g_object_unref (response);
+
+ /*
+ * We have to check we didn't found any text
+ */
+ if(!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(panel->priv->store),
+ &treeiter))
+ {
+ gtk_list_store_append(panel->priv->store, &treeiter);
+ gtk_list_store_set(panel->priv->store, &treeiter,
+ ICON_COLUMN, NULL,
+ TEXT_COLUMN, _("Phrase not found"),
+ -1);
+ }
+}
+
+static void
+open_connection(GtranslatorOpenTranPanel *panel,
+ const gchar *text,
+ const gchar *lang_code)
+{
+ SoupUri *proxy = NULL; //This can be useful in a future
+ SoupXmlrpcMessage *msg;
+ const gchar *uri = "http://open-tran.eu/RPC2";
+
+ panel->priv->session = soup_session_async_new_with_options (
+ SOUP_SESSION_PROXY_URI, proxy,
+ NULL);
+
+ msg = soup_xmlrpc_message_new (uri);
+ if (!msg) {
+ show_error_dialog(panel->priv->window,
+ _("Could not create web service request to '%s'\n"), uri);
+ return;
+ }
+
+ soup_xmlrpc_message_start_call (msg, "suggest");
+ soup_xmlrpc_message_start_param (msg);
+ soup_xmlrpc_message_write_string (msg, text);
+ soup_xmlrpc_message_write_string (msg, lang_code);
+ soup_xmlrpc_message_end_param (msg);
+ soup_xmlrpc_message_end_call (msg);
+
+ soup_xmlrpc_message_persist (msg);
+ soup_session_queue_message (panel->priv->session, SOUP_MESSAGE (msg),
+ got_response, panel);
+}
+
+static void
+entry_activate_cb (GtkEntry *entry,
+ GtranslatorOpenTranPanel *panel)
+{
+ const gchar *entry_text = NULL;
+ const gchar *lang_code = NULL;
+
+ gtk_list_store_clear(panel->priv->store);
+
+ entry_text = gtk_entry_get_text(GTK_ENTRY(panel->priv->entry));
+ if(!entry_text)
+ {
+ show_error_dialog(panel->priv->window,
+ _("You have to provide a phrase to search"));
+ return;
+ }
+
+ lang_code = gtk_entry_get_text(GTK_ENTRY(panel->priv->lang_code));
+ if(!lang_code)
+ {
+ show_error_dialog(panel->priv->window,
+ _("You have to provide a language code"));
+ return;
+ }
+
+ open_connection(panel, entry_text, lang_code);
+}
+
+static void
+gtranslator_open_tran_panel_draw_treeview (GtranslatorOpenTranPanel *panel)
+{
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ GtranslatorOpenTranPanelPrivate *priv = panel->priv;
+
+ priv->store = gtk_list_store_new(N_COLUMNS,
+ GDK_TYPE_PIXBUF,
+ G_TYPE_STRING);
+
+ priv->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(priv->store));
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(priv->treeview),
+ FALSE);
+
+ /*
+ * Icon column
+ */
+ column = gtk_tree_view_column_new();
+
+ renderer = gtk_cell_renderer_pixbuf_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Type"),
+ renderer, "pixbuf",
+ ICON_COLUMN, NULL);
+ gtk_tree_view_column_set_resizable(column, FALSE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW(priv->treeview), column);
+
+ /*
+ * Text column
+ */
+ column = gtk_tree_view_column_new();
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(_("Open-Tran.eu"),
+ renderer,
+ "text", TEXT_COLUMN,
+ NULL);
+
+ gtk_tree_view_column_set_resizable(column, FALSE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW(priv->treeview), column);
+}
+
+static void
+gtranslator_open_tran_panel_draw (GtranslatorOpenTranPanel *panel)
+{
+ GtkWidget *scrolledwindow;
+ GtkWidget *button;
+ GtkWidget *label;
+ GtkWidget *hbox;
+
+ /*
+ * Set up the scrolling window for the extracted comments display
+ */
+ scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
+ GTK_SHADOW_IN);
+ gtk_box_pack_start(GTK_BOX(panel), scrolledwindow, TRUE, TRUE, 0);
+
+ /*
+ * TreeView
+ */
+ gtranslator_open_tran_panel_draw_treeview (panel);
+ gtk_container_add(GTK_CONTAINER(scrolledwindow),
+ panel->priv->treeview);
+
+ /*
+ * Entry
+ */
+ hbox = gtk_hbox_new(FALSE, 6);
+
+ button = gtk_button_new_with_label(_("Look for:"));
+ gtk_button_set_relief(GTK_BUTTON(button),
+ GTK_RELIEF_NONE);
+ g_signal_connect(button, "clicked",
+ G_CALLBACK(entry_activate_cb), panel);
+
+ gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+
+ panel->priv->entry = gtk_entry_new();
+ gtk_box_pack_start(GTK_BOX(hbox), panel->priv->entry, TRUE, TRUE, 0);
+ g_signal_connect(panel->priv->entry, "activate",
+ G_CALLBACK(entry_activate_cb), panel);
+
+ gtk_box_pack_start(GTK_BOX(panel), hbox, FALSE, TRUE, 0);
+
+ /*
+ * Language code
+ */
+ hbox = gtk_hbox_new(FALSE, 6);
+
+ label = gtk_label_new(_("Lang code:"));
+ gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+
+ panel->priv->lang_code = gtk_entry_new();
+ gtk_widget_set_tooltip_text(panel->priv->lang_code,
+ _("For example: gl"));
+ gtk_box_pack_start(GTK_BOX(hbox), panel->priv->lang_code, TRUE, TRUE, 0);
+ g_signal_connect(panel->priv->lang_code, "activate",
+ G_CALLBACK(entry_activate_cb), panel);
+
+ gtk_box_pack_start(GTK_BOX(panel), hbox, FALSE, TRUE, 0);
+}
+
+static void
+gtranslator_open_tran_panel_init (GtranslatorOpenTranPanel *panel)
+{
+
+ panel->priv = GTR_OPEN_TRAN_PANEL_GET_PRIVATE (panel);
+
+ gtranslator_open_tran_panel_draw(panel);
+}
+
+static void
+gtranslator_open_tran_panel_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gtranslator_open_tran_panel_parent_class)->finalize (object);
+}
+
+static void
+gtranslator_open_tran_panel_class_init (GtranslatorOpenTranPanelClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GtranslatorOpenTranPanelPrivate));
+
+ object_class->finalize = gtranslator_open_tran_panel_finalize;
+}
+
+GtkWidget *
+gtranslator_open_tran_panel_new (GtranslatorWindow *window)
+{
+ GtranslatorOpenTranPanel *panel;
+
+ panel = g_object_new (GTR_TYPE_OPEN_TRAN_PANEL, NULL);
+
+ panel->priv->window = window;
+
+ return GTK_WIDGET(panel);
+}
+
Added: branches/GOBJECT_WORK/plugins/open-tran/open-tran-panel.h
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/open-tran/open-tran-panel.h Mon Jan 21 15:10:42 2008
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANPOILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __OPEN_TRAN_PANEL_H__
+#define __OPEN_TRAN_PANEL_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include "window.h"
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_OPEN_TRAN_PANEL (gtranslator_open_tran_panel_get_type ())
+#define GTR_OPEN_TRAN_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_OPEN_TRAN_PANEL, GtranslatorOpenTranPanel))
+#define GTR_OPEN_TRAN_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_OPEN_TRAN_PANEL, GtranslatorOpenTranPanelClass))
+#define GTR_IS_OPEN_TRAN_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_OPEN_TRAN_PANEL))
+#define GTR_IS_OPEN_TRAN_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_OPEN_TRAN_PANEL))
+#define GTR_OPEN_TRAN_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_OPEN_TRAN_PANEL, GtranslatorOpenTranPanelClass))
+
+/* Private structure type */
+typedef struct _GtranslatorOpenTranPanelPrivate GtranslatorOpenTranPanelPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtranslatorOpenTranPanel GtranslatorOpenTranPanel;
+
+struct _GtranslatorOpenTranPanel
+{
+ GtkVBox parent_instance;
+
+ /*< private > */
+ GtranslatorOpenTranPanelPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtranslatorOpenTranPanelClass GtranslatorOpenTranPanelClass;
+
+struct _GtranslatorOpenTranPanelClass
+{
+ GtkVBoxClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gtranslator_open_tran_panel_get_type (void) G_GNUC_CONST;
+GType gtranslator_open_tran_panel_register_type (GTypeModule * module);
+GtkWidget *gtranslator_open_tran_panel_new (GtranslatorWindow *window);
+
+G_END_DECLS
+
+#endif /* __OPEN_TRAN_PANEL_H__ */
Added: branches/GOBJECT_WORK/plugins/open-tran/open-tran-plugin.c
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/open-tran/open-tran-plugin.c Mon Jan 21 15:10:42 2008
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANPOILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "open-tran-plugin.h"
+#include "open-tran-panel.h"
+
+#include <glib/gi18n-lib.h>
+#include "window.h"
+#include "panel.h"
+
+#define OPEN_TRAN_PLUGIN_ICON PIXMAPSDIR"/open-tran.png"
+
+#define GTR_OPEN_TRAN_PLUGIN_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
+ GTR_TYPE_OPEN_TRAN_PLUGIN, \
+ GtranslatorOpenTranPluginPrivate))
+
+typedef struct
+{
+ GtkWidget *panel;
+ guint context_id;
+} WindowData;
+
+GTR_PLUGIN_REGISTER_TYPE_WITH_CODE (GtranslatorOpenTranPlugin, gtranslator_open_tran_plugin,
+ gtranslator_open_tran_panel_register_type (module);
+)
+
+static void
+gtranslator_open_tran_plugin_init (GtranslatorOpenTranPlugin *plugin)
+{
+ //gtranslator_debug_message (DEBUG_PLUGINS, "GtranslatorOpenTranPlugin initializing");
+}
+
+static void
+gtranslator_open_tran_plugin_finalize (GObject *object)
+{
+ //gtranslator_debug_message (DEBUG_PLUGINS, "GtranslatorOpenTranPlugin finalizing");
+
+ G_OBJECT_CLASS (gtranslator_open_tran_plugin_parent_class)->finalize (object);
+}
+
+
+static void
+impl_activate (GtranslatorPlugin *plugin,
+ GtranslatorWindow *window)
+{
+ GtranslatorPanel *panel;
+ GtkWidget *image = NULL;
+ GtkWidget *opentran;
+ GdkPixbuf *pixbuf;
+ GtkIconSet *iconset;
+ GError *error = NULL;
+
+ panel = gtranslator_window_get_side_panel (window);
+
+ pixbuf = gdk_pixbuf_new_from_file(OPEN_TRAN_PLUGIN_ICON, &error);
+
+ if (error)
+ {
+ g_warning ("Could not load icon: %s\n", error->message);
+ g_error_free(error);
+ pixbuf = NULL;
+ }
+
+ if(pixbuf)
+ {
+ iconset = gtk_icon_set_new_from_pixbuf(pixbuf);
+
+ image = gtk_image_new_from_icon_set(iconset,
+ GTK_ICON_SIZE_MENU);
+ }
+
+ opentran = gtranslator_open_tran_panel_new(window);
+
+ gtranslator_panel_add_item (panel,
+ opentran,
+ _("Open-Tran"),
+ image);
+
+ gtk_object_sink (GTK_OBJECT (image));
+
+ gtk_widget_show_all(opentran);
+}
+
+static void
+impl_deactivate (GtranslatorPlugin *plugin,
+ GtranslatorWindow *window)
+{
+ GtranslatorPanel *panel;
+
+
+
+ //gtranslator_debug (DEBUG_PLUGINS);
+
+ /*data = (WindowData *) g_object_get_data (G_OBJECT (window),
+ WINDOW_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ chartable = gtranslator_open_tran_panel_get_table
+ (GTR_OPEN_TRAN_PANEL (data->panel));
+ on_table_status_message (chartable, NULL, window);
+
+ panel = gtranslator_window_get_side_panel (window);
+ gtranslator_panel_remove_item (panel, data->panel);
+
+ g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);*/
+}
+
+static void
+gtranslator_open_tran_plugin_class_init (GtranslatorOpenTranPluginClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtranslatorPluginClass *plugin_class = GTR_PLUGIN_CLASS (klass);
+
+ object_class->finalize = gtranslator_open_tran_plugin_finalize;
+
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+}
Added: branches/GOBJECT_WORK/plugins/open-tran/open-tran-plugin.h
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/open-tran/open-tran-plugin.h Mon Jan 21 15:10:42 2008
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
+ *
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANPOILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __GTR_OPEN_TRAN_PLUGIN_H__
+#define __GTR_OPEN_TRAN_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "plugin.h"
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_OPEN_TRAN_PLUGIN (gtranslator_open_tran_plugin_get_type ())
+#define GTR_OPEN_TRAN_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_OPEN_TRAN_PLUGIN, GtranslatorOpenTranPlugin))
+#define GTR_OPEN_TRAN_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_OPEN_TRAN_PLUGIN, GtranslatorOpenTranPluginClass))
+#define GTR_IS_OPEN_TRAN_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_OPEN_TRAN_PLUGIN))
+#define GTR_IS_OPEN_TRAN_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_OPEN_TRAN_PLUGIN))
+#define GTR_OPEN_TRAN_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_OPEN_TRAN_PLUGIN, GtranslatorOpenTranPluginClass))
+
+/* Private structure type */
+typedef struct _GtranslatorOpenTranPluginPrivate GtranslatorOpenTranPluginPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtranslatorOpenTranPlugin GtranslatorOpenTranPlugin;
+
+struct _GtranslatorOpenTranPlugin
+{
+ GtranslatorPlugin parent_instance;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtranslatorOpenTranPluginClass GtranslatorOpenTranPluginClass;
+
+struct _GtranslatorOpenTranPluginClass
+{
+ GtranslatorPluginClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType gtranslator_open_tran_plugin_get_type (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gtranslator_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GTR_OPEN_TRAN_PLUGIN_H__ */
Added: branches/GOBJECT_WORK/plugins/open-tran/open-tran.gtranslator-plugin.desktop.in
==============================================================================
--- (empty file)
+++ branches/GOBJECT_WORK/plugins/open-tran/open-tran.gtranslator-plugin.desktop.in Mon Jan 21 15:10:42 2008
@@ -0,0 +1,8 @@
+[Gtranslator Plugin]
+Module=opentran
+IAge=2
+_Name=Open Tran
+_Description=Look for word in Open tran memory translation data base.
+Authors=Ignacio Casal Quinteiro <nacho resa gmail com>
+Copyright=Copyright @ 2008 Ignacio Casal Quinteiro
+Website=http://gtranslator.sf.net
Added: branches/GOBJECT_WORK/plugins/open-tran/open-tran.png
==============================================================================
Binary file. No diff available.
Modified: branches/GOBJECT_WORK/src/Makefile.am
==============================================================================
--- branches/GOBJECT_WORK/src/Makefile.am (original)
+++ branches/GOBJECT_WORK/src/Makefile.am Mon Jan 21 15:10:42 2008
@@ -4,8 +4,6 @@
SUBDIRS = toolbareditor \
dialogs \
- charmap \
- alternatelanguage \
plugin-system
noinst_LTLIBRARIES = libgtranslator.la
@@ -15,8 +13,6 @@
-I$(includedir) \
-I$(top_srcdir)/src/dialogs \
-I$(top_srcdir)/src/toolbareditor \
- -I$(top_srcdir)/src/charmap \
- -I$(top_srcdir)/src/alternatelanguage \
-I$(top_srcdir)/src/plugin-system \
-DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \
-DPREFIX=\""$(prefix)"\" \
@@ -119,8 +115,6 @@
$(GTRANSLATOR_LIBS) \
dialogs/libdialogs.la \
toolbareditor/libtoolbareditor.la \
- charmap/libcharmap.la \
- alternatelanguage/libalternatelang.la \
plugin-system/libpluginsystem.la
#gtranslator_auto_learn_SOURCES = \
Modified: branches/GOBJECT_WORK/src/window.c
==============================================================================
--- branches/GOBJECT_WORK/src/window.c (original)
+++ branches/GOBJECT_WORK/src/window.c Mon Jan 21 15:10:42 2008
@@ -21,10 +21,7 @@
#endif
#include "actions.h"
-#include "alternate-language.h"
#include "application.h"
-#include "charmap.h"
-//#include "dictionary.h"
#include "header.h"
#include "msg.h"
#include "notebook.h"
@@ -993,6 +990,7 @@
if (gtranslator_prefs_manager_get_side_pane_visible ())
gtk_widget_show(priv->sidebar);
+
/*
* notebook
*/
@@ -1049,6 +1047,8 @@
gtranslator_window_init (GtranslatorWindow *window)
{
GtkTargetList *tl;
+ gint active_page;
+
window->priv = GTR_WINDOW_GET_PRIVATE (window);
window->priv->destroy_has_run = FALSE;
@@ -1084,21 +1084,17 @@
"drag_data_received",
G_CALLBACK (drag_data_received_cb),
NULL);
-
- /* Charmap panel */
- impl_activate(window);
-
- /* Dictionary panel */
- //dictionary_activate(window);
-
- /* Alterante language */
- alternate_lang_activate(window);
/*
* Plugins
*/
gtranslator_plugins_engine_update_plugins_ui (gtranslator_plugins_engine_get_default (),
window, TRUE);
+
+ /*We have to active the right tab after plugins load*/
+ active_page = gtranslator_prefs_manager_get_side_panel_active_page ();
+ _gtranslator_panel_set_active_item_by_id (GTR_PANEL (window->priv->sidebar),
+ active_page);
}
static void
@@ -1118,10 +1114,6 @@
priv->action_group = NULL;
}
- /* Deactivate Panels */
- //impl_deactivate(window);
-//dictionary_deactivate(window);
-
G_OBJECT_CLASS (gtranslator_window_parent_class)->dispose (object);
}
@@ -1222,6 +1214,25 @@
return gtranslator_notebook_get_page(GTR_NOTEBOOK(window->priv->notebook));
}
+GList *
+gtranslator_window_get_all_tabs(GtranslatorWindow *window)
+{
+ gint num_pages;
+ gint i = 0;
+ GList *toret = NULL;
+
+ num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->priv->notebook));
+
+ while(i < num_pages)
+ {
+ toret = g_list_append(toret,
+ gtk_notebook_get_nth_page(GTK_NOTEBOOK(window->priv->notebook),i));
+ i++;
+ }
+
+ return toret;
+}
+
GtranslatorHeader *
gtranslator_window_get_header_from_active_tab(GtranslatorWindow *window)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]