gtranslator r3783 - in trunk: . plugins/charmap
- From: icq svn gnome org
- To: svn-commits-list gnome org
- Subject: gtranslator r3783 - in trunk: . plugins/charmap
- Date: Tue, 23 Sep 2008 10:47:50 +0000 (UTC)
Author: icq
Date: Tue Sep 23 10:47:50 2008
New Revision: 3783
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3783&view=rev
Log:
2008-09-23 Ignacio Casal Quinteiro <nacho resa gmail com>
* configure.ac:
* plugins/charmap/charmap-panel.c
(on_chapter_view_selection_changed),
(gtranslator_charmap_panel_init),
(gtranslator_charmap_panel_get_chartable):
* plugins/charmap/charmap-panel.h:
* plugins/charmap/charmap-plugin.c (free_window_data),
(on_table_status_message):
Updated charmap plugin to support gucharmap 2.23.
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/plugins/charmap/charmap-panel.c
trunk/plugins/charmap/charmap-panel.h
trunk/plugins/charmap/charmap-plugin.c
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Tue Sep 23 10:47:50 2008
@@ -80,7 +80,6 @@
LIBGLADE_REQUIRED=2.6.0
SOURCEVIEW_REQUIRED=2.0.0
GDL_REQUIRED=0.6.0
-LIBGUCHARMAP_OPTIONAL=1.6.0
GDICT_OPTIONAL=0.11.0
GTKSPELL_OPTIONAL=2.0.2
SVN_MAJOR=1
@@ -236,25 +235,20 @@
AM_CONDITIONAL(USE_DICTIONARY, test x"$have_gdict" = "xyes")
# ================================================================
-# gcharmap
+# gucharmap
# ================================================================
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_OPTIONAL
- ], have_gucharmap=yes, have_gucharmap=no)
-
- if test x"$have_gucharmap" = "xyes"
- then
- AC_DEFINE([HAVE_CHARMAP], 1, [Have gucharmap])
- fi
+GUCHARMAP2_OPTIONAL=2.23.0
+GUCHARMAP_OPTIONAL=1.6.0
+PKG_CHECK_MODULES([GUCHARMAP],[gucharmap-2 >= $GUCHARMAP2_OPTIONAL],
+ [have_gucharmap=yes have_gucharmap_2=yes],[have_gucharmap_2=no])
+if test "$have_gucharmap_2" = "no"; then
+ PKG_CHECK_MODULES([GUCHARMAP], [gucharmap >= $GUCHARMAP_OPTIONAL],
+ [have_gucharmap=yes],[have_gucharmap=no])
+fi
+if test "$have_gucharmap_2" = "yes"; then
+ AC_DEFINE([HAVE_GUCHARMAP_2],[1],[Define if gucharmap API is version 2])
fi
AM_CONDITIONAL(USE_CHARMAP, test x"$have_gucharmap" = "xyes")
@@ -521,7 +515,7 @@
echo "Building charmap plugin: ...............................YES"
else
echo "Building charmap plugin: ...............................NO"
- echo " Requires gucharmap >= $LIBGUCHARMAP_OPTIONAL=1.6.0"
+ echo " Requires gucharmap >= $GUCHARMAP_OPTIONAL"
fi
if [ test x"$have_libsoup" = "xyes" ]; then
Modified: trunk/plugins/charmap/charmap-panel.c
==============================================================================
--- trunk/plugins/charmap/charmap-panel.c (original)
+++ trunk/plugins/charmap/charmap-panel.c Tue Sep 23 10:47:50 2008
@@ -24,7 +24,12 @@
#include "plugin.h"
#include "charmap-panel.h"
+
+#ifdef HAVE_GUCHARMAP_2
+#include <gucharmap/gucharmap.h>
+#else
#include <gucharmap/gucharmap-script-chapters.h>
+#endif
#define GTR_CHARMAP_PANEL_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
(object), \
@@ -33,12 +38,36 @@
struct _GtranslatorCharmapPanelPrivate
{
+#ifdef HAVE_GUCHARMAP_2
+ GucharmapChaptersView *chapters_view;
+ GucharmapChartable *chartable;
+#else
GtkWidget *table;
GtkWidget *chapters;
+#endif
};
GTR_PLUGIN_DEFINE_TYPE(GtranslatorCharmapPanel, gtranslator_charmap_panel, GTK_TYPE_VBOX)
+#ifdef HAVE_GUCHARMAP_2
+static void
+on_chapter_view_selection_changed (GtkTreeSelection *selection,
+ GtranslatorCharmapPanel *panel)
+{
+ GtranslatorCharmapPanelPrivate *priv = panel->priv;
+ GucharmapCodepointList *codepoint_list;
+ GtkTreeIter iter;
+
+ if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
+ return;
+
+ codepoint_list = gucharmap_chapters_view_get_codepoint_list (priv->chapters_view);
+ gucharmap_chartable_set_codepoint_list (priv->chartable, codepoint_list);
+ g_object_unref (codepoint_list);
+}
+
+#else
+
static void
on_chapter_changed (GucharmapChapters *chapters,
GtranslatorCharmapPanel *panel)
@@ -46,39 +75,90 @@
gucharmap_table_set_codepoint_list (GUCHARMAP_TABLE (panel->priv->table),
gucharmap_chapters_get_codepoint_list (chapters));
}
+#endif /* HAVE_GUCHARMAP_2 */
static void
gtranslator_charmap_panel_init (GtranslatorCharmapPanel *panel)
{
- GucharmapCodepointList *codepoint_list;
+ GtranslatorCharmapPanelPrivate *priv;
GtkPaned *paned;
+#ifdef HAVE_GUCHARMAP_2
+ GtkWidget *scrolled_window, *view, *chartable;
+ GtkTreeSelection *selection;
+ GucharmapChaptersModel *model;
+#elif
+ GucharmapCodepointList *codepoint_list;
+#endif
+
+ priv = panel->priv = GTR_CHARMAP_PANEL_GET_PRIVATE (panel);
+
+ paned = GTK_PANED (gtk_vpaned_new ());
+
+#ifdef HAVE_GUCHARMAP_2
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_SHADOW_ETCHED_IN);
+
+ view = gucharmap_chapters_view_new ();
+ priv->chapters_view = GUCHARMAP_CHAPTERS_VIEW (view);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
+
+ model = gucharmap_script_chapters_model_new ();
+ gucharmap_chapters_view_set_model (priv->chapters_view, model);
+ g_object_unref (model);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (on_chapter_view_selection_changed), panel);
+
+ gtk_container_add (GTK_CONTAINER (scrolled_window), view);
+ gtk_widget_show (view);
+
+ gtk_paned_pack1 (paned, scrolled_window, FALSE, TRUE);
+ gtk_widget_show (scrolled_window);
+
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_SHADOW_ETCHED_IN);
+
+ chartable = gucharmap_chartable_new ();
+ priv->chartable = GUCHARMAP_CHARTABLE (chartable);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), chartable);
+ gtk_widget_show (chartable);
+
+ gtk_paned_pack2 (paned, scrolled_window, TRUE, TRUE);
+ gtk_widget_show (scrolled_window);
+
+ gucharmap_chapters_view_select_locale (priv->chapters_view);
+#else
+ priv->chapters = gucharmap_script_chapters_new ();
+ g_signal_connect (priv->chapters,
+ "changed",
+ G_CALLBACK (on_chapter_changed),
+ panel);
- 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),
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (GUCHARMAP_CHAPTERS (priv->chapters)->tree_view),
FALSE);
codepoint_list = gucharmap_chapters_get_codepoint_list
- (GUCHARMAP_CHAPTERS (panel->priv->chapters));
+ (GUCHARMAP_CHAPTERS (priv->chapters));
- panel->priv->table = gucharmap_table_new ();
+ priv->table = gucharmap_table_new ();
- gucharmap_table_set_codepoint_list (GUCHARMAP_TABLE (panel->priv->table),
+ gucharmap_table_set_codepoint_list (GUCHARMAP_TABLE (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_pack1 (paned, priv->chapters, FALSE, TRUE);
+ gtk_paned_pack2 (paned, priv->table, TRUE, TRUE);
+#endif /* HAVE_GUCHARMAP_2 */
+
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
@@ -103,9 +183,16 @@
return GTK_WIDGET (g_object_new (GTR_TYPE_CHARMAP_PANEL, NULL));
}
+#ifdef HAVE_GUCHARMAP_2
+GucharmapChartable *
+gtranslator_charmap_panel_get_chartable (GtranslatorCharmapPanel *panel)
+{
+ return panel->priv->chartable;
+}
+#else
GucharmapTable *
gtranslator_charmap_panel_get_table (GtranslatorCharmapPanel *panel)
{
return GUCHARMAP_TABLE (panel->priv->table);
}
-
+#endif
Modified: trunk/plugins/charmap/charmap-panel.h
==============================================================================
--- trunk/plugins/charmap/charmap-panel.h (original)
+++ trunk/plugins/charmap/charmap-panel.h Tue Sep 23 10:47:50 2008
@@ -26,7 +26,12 @@
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
+
+#ifdef HAVE_GUCHARMAP_2
+#include <gucharmap/gucharmap.h>
+#else
#include <gucharmap/gucharmap-table.h>
+#endif
G_BEGIN_DECLS
@@ -72,7 +77,12 @@
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);
+
+#ifdef HAVE_GUCHARMAP_2
+GucharmapChartable *gtranslator_charmap_panel_get_chartable (GtranslatorCharmapPanel *panel);
+#else
+GucharmapTable *gtranslator_charmap_panel_get_table (GtranslatorCharmapPanel *panel);
+#endif
G_END_DECLS
Modified: trunk/plugins/charmap/charmap-plugin.c
==============================================================================
--- trunk/plugins/charmap/charmap-plugin.c (original)
+++ trunk/plugins/charmap/charmap-plugin.c Tue Sep 23 10:47:50 2008
@@ -26,11 +26,17 @@
#include "charmap-panel.h"
#include <glib/gi18n-lib.h>
+#include "debug.h"
#include "application.h"
#include "statusbar.h"
#include "window.h"
+
+#ifdef HAVE_GUCHARMAP_2
+#include <gucharmap/gucharmap.h>
+#else
#include <gucharmap/gucharmap-table.h>
#include <gucharmap/gucharmap-unicode-info.h>
+#endif
#define WINDOW_DATA_KEY "GtranslatorCharmapPluginWindowData"
@@ -66,13 +72,15 @@
static void
free_window_data (WindowData *data)
{
- g_return_if_fail (data != NULL);
-
- g_free (data);
+ g_slice_free (WindowData, data);
}
static void
+#ifdef HAVE_GUCHARMAP_2
+on_table_status_message (GucharmapChartable *chartable,
+#else
on_table_status_message (GucharmapTable *chartable,
+#endif
const gchar *message,
GtranslatorWindow *window)
{
@@ -91,13 +99,24 @@
}
static void
+#ifdef HAVE_GUCHARMAP_2
+on_table_sync_active_char (GucharmapChartable *chartable,
+ GParamSpec *psepc,
+ GtranslatorWindow *window)
+#else
on_table_set_active_char (GucharmapTable *chartable,
gunichar wc,
GtranslatorWindow *window)
+#endif
{
GString *gs;
const gchar **temps;
gint i;
+#ifdef HAVE_GUCHARMAP_2
+ gunichar wc;
+
+ wc = gucharmap_chartable_get_active_character (chartable);
+#endif
gs = g_string_new (NULL);
g_string_append_printf (gs, "U+%4.4X %s", wc,
@@ -130,30 +149,50 @@
GdkEventFocus *event,
GtranslatorWindow *window)
{
+#ifdef HAVE_GUCHARMAP_2
+ GucharmapChartable *chartable;
+#else
GucharmapTable *chartable;
+#endif
WindowData *data;
data = (WindowData *) g_object_get_data (G_OBJECT (window),
WINDOW_DATA_KEY);
g_return_val_if_fail (data != NULL, FALSE);
+#ifdef HAVE_GUCHARMAP_2
+ chartable = gtranslator_charmap_panel_get_chartable
+ (GTR_CHARMAP_PANEL (data->panel));
+#else
chartable = gtranslator_charmap_panel_get_table
(GTR_CHARMAP_PANEL (data->panel));
+#endif
on_table_status_message (chartable, NULL, window);
return FALSE;
}
+#ifdef HAVE_GUCHARMAP_2
+static void
+on_table_activate (GucharmapChartable *chartable,
+ GtranslatorWindow *window)
+#else
static void
on_table_activate (GucharmapTable *chartable,
gunichar wc,
GtranslatorWindow *window)
+#endif
{
GtkTextView *view;
GtkTextBuffer *document;
GtkTextIter start, end;
gchar buffer[6];
gchar length;
+#ifdef HAVE_GUCHARMAP_2
+ gunichar wc;
+
+ wc = gucharmap_chartable_get_active_character (chartable);
+#endif
g_return_if_fail (gucharmap_unichar_validate (wc));
@@ -183,31 +222,57 @@
create_charmap_panel (GtranslatorWindow *window)
{
GtkWidget *panel;
+#ifdef HAVE_GUCHARMAP_2
+ GucharmapChartable *chartable;
+#else
GucharmapTable *table;
+#endif
panel = gtranslator_charmap_panel_new ();
+
+#ifdef HAVE_GUCHARMAP_2
+ chartable = gtranslator_charmap_panel_get_chartable (GTR_CHARMAP_PANEL (panel));
+#else
table = gtranslator_charmap_panel_get_table (GTR_CHARMAP_PANEL (panel));
+#endif
- g_signal_connect (table,
+#ifdef HAVE_GUCHARMAP_2
+ g_signal_connect (chartable,
+ "notify::active-character",
+ G_CALLBACK (on_table_sync_active_char),
+ window);
+ g_signal_connect (chartable,
+ "focus-out-event",
+ G_CALLBACK (on_table_focus_out_event),
+ window);
+ g_signal_connect (chartable,
"status-message",
G_CALLBACK (on_table_status_message),
window);
+ g_signal_connect (chartable,
+ "activate",
+ G_CALLBACK (on_table_activate),
+ window);
+#else
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,
+ "status-message",
+ G_CALLBACK (on_table_status_message),
+ window);
g_signal_connect (table,
"activate",
G_CALLBACK (on_table_activate),
window);
+#endif /* HAVE_GUCHARMAP_2 */
gtk_widget_show_all (panel);
@@ -221,8 +286,6 @@
GtranslatorStatusbar *statusbar;
WindowData *data;
- //gtranslator_debug (DEBUG_PLUGINS);
-
data = g_new (WindowData, 1);
gtranslator_application_register_icon (GTR_APP, "gucharmap.ico",
@@ -251,22 +314,30 @@
impl_deactivate (GtranslatorPlugin *plugin,
GtranslatorWindow *window)
{
- GucharmapTable *chartable;
WindowData *data;
-
- //gtranslator_debug (DEBUG_PLUGINS);
+#ifdef HAVE_GUCHARMAP_2
+ GucharmapChartable *chartable;
+#else
+ GucharmapTable *chartable;
+#endif
data = (WindowData *) g_object_get_data (G_OBJECT (window),
WINDOW_DATA_KEY);
g_return_if_fail (data != NULL);
+#ifdef HAVE_GUCHARMAP_2
+ chartable = gtranslator_charmap_panel_get_chartable
+ (GTR_CHARMAP_PANEL (data->panel));
+#else
chartable = gtranslator_charmap_panel_get_table
(GTR_CHARMAP_PANEL (data->panel));
+#endif
on_table_status_message (chartable, NULL, window);
gtranslator_window_remove_widget (window, data->panel);
g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
+
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]