gtranslator r3915 - in trunk: . src
- From: psanxiao svn gnome org
- To: svn-commits-list gnome org
- Subject: gtranslator r3915 - in trunk: . src
- Date: Mon, 12 Jan 2009 15:21:01 +0000 (UTC)
Author: psanxiao
Date: Mon Jan 12 15:21:01 2009
New Revision: 3915
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3915&view=rev
Log:
Patch by Ignacio Casal Quinteiro <nacho resa gmail com>
* configure.ac:
* src/Makefile.am:
* src/draw-spaces.{ch}:
* src/view.c:
(gtranslator_view_enable_visible_whitespace):
Switched to drawing space system of GtkSourceView 2.4.
(Fixes bug #553240).
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/src/Makefile.am
trunk/src/draw-spaces.c
trunk/src/draw-spaces.h
trunk/src/view.c
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Mon Jan 12 15:21:01 2009
@@ -78,7 +78,7 @@
GCONF_REQUIRED=2.18.0
LIBXML_REQUIRED=2.4.12
LIBGLADE_REQUIRED=2.6.0
-SOURCEVIEW_REQUIRED=2.0.0
+SOURCEVIEW_REQUIRED=2.4.0
GDL_REQUIRED=0.6.0
GDICT_OPTIONAL=0.11.0
GTKSPELL_OPTIONAL=2.0.2
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon Jan 12 15:21:01 2009
@@ -78,7 +78,6 @@
libgtranslator_la_SOURCES = \
$(BUILT_SOURCES) \
application.c \
- draw-spaces.c draw-spaces.h \
message-area.c \
message-table.c \
message-table-model.c \
Modified: trunk/src/draw-spaces.c
==============================================================================
--- trunk/src/draw-spaces.c (original)
+++ trunk/src/draw-spaces.c Mon Jan 12 15:21:01 2009
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2007 Ignacio Casal Quinteiro <nacho resa gmail com>
- * 2006 Paolo Borelli
- * 2007 Steve FrÃcinaux
- *
- * Based in gedit draw spaces plugin.
- *
- * 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/>.
- *
- * Based in drawspaces gedit plugin.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "draw-spaces.h"
-
-#include <glib.h>
-#include <gtk/gtk.h>
-
-static void draw_tabs_and_spaces(GtkWidget *view, GdkEventExpose *event,
- GtkTextIter iter, GtkTextIter end);
-
-
-void
-on_event_after(GtkWidget *view,
- GdkEventExpose *event,
- gpointer useless)
-{
- if(event->type != GDK_EXPOSE ||
- event->window != gtk_text_view_get_window(GTK_TEXT_VIEW(view),
- GTK_TEXT_WINDOW_TEXT))
- return;
- gint x, y;
- GtkTextIter start;
- GtkTextIter end;
-
- gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(view), GTK_TEXT_WINDOW_TEXT,
- event->area.x, event->area.y, &x, &y);
- gtk_text_view_get_line_at_y(GTK_TEXT_VIEW(view), &start, y, NULL);
- gtk_text_view_get_line_at_y(GTK_TEXT_VIEW(view), &end, y + event->area.height , NULL);
- gtk_text_iter_forward_to_line_end(&end);
- draw_tabs_and_spaces(view, event, start, end);
-}
-
-static void
-draw_space_at_iter(cairo_t *cr,
- GtkWidget *view,
- GtkTextIter *iter)
-{
- GdkRectangle rect;
- gint x, y;
-
- if (!GTK_IS_TEXT_VIEW(view))
- return;
- gtk_text_view_get_iter_location(GTK_TEXT_VIEW(view), iter, &rect);
- gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(view), GTK_TEXT_WINDOW_TEXT,
- rect.x + rect.width /2,
- rect.y + rect.height * 2/3, &x, &y);
-
- cairo_save(cr);
- cairo_move_to(cr, x, y);
- cairo_arc(cr, x, y, 0.8, 0, 2 * G_PI);
- cairo_restore(cr);
- cairo_stroke(cr);
-}
-
-static void
-draw_nbsp_at_iter(cairo_t *cr,
- GtkTextView *view,
- GtkTextIter *iter)
-{
- GdkRectangle rect;
- gint x, y;
- gtk_text_view_get_iter_location(view, iter, &rect);
- gtk_text_view_buffer_to_window_coords(view, GTK_TEXT_WINDOW_TEXT,
- rect.x,
- rect.y + rect.height / 2, &x, &y);
-
-
- cairo_save(cr);
-
- if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_LTR)
- {
- cairo_move_to(cr, x+2, y-2);
- cairo_rel_line_to(cr, +7, 0);
- cairo_rel_line_to(cr, 0, 4);
- cairo_rel_move_to(cr, -3, 0);
- cairo_rel_line_to(cr, 6, 0);
- cairo_rel_line_to(cr, -3, 4);
- cairo_rel_line_to(cr, -3, -4);
- }else
- {
- cairo_move_to (cr, x-2, y-2);
- cairo_rel_line_to(cr, -7, 0);
- cairo_rel_line_to(cr, 0, 4);
- cairo_rel_move_to(cr, 3, 0);
- cairo_rel_line_to(cr, -6, 0);
- cairo_rel_line_to(cr, 3, 4);
- cairo_rel_line_to(cr, 3, -4);
- }
- cairo_restore(cr);
- cairo_fill(cr);
-
-}
-
-static void
-draw_tab_at_iter(cairo_t *cr,
- GtkTextView *view,
- GtkTextIter *iter)
-{
- GdkRectangle rect;
- gint x, y;
- gtk_text_view_get_iter_location(view, iter, &rect);
- gtk_text_view_buffer_to_window_coords(view, GTK_TEXT_WINDOW_TEXT,
- rect.x,
- rect.y + rect.height * 2/3, &x, &y);
- cairo_save(cr);
- cairo_move_to(cr, x + 4, y);
- cairo_rel_line_to(cr, rect.width -8, 0);
- cairo_rel_line_to(cr, -3, -3);
- cairo_rel_move_to(cr, +3, +3);
- cairo_rel_line_to(cr, -3, +3);
- cairo_restore(cr);
- cairo_stroke(cr);
-}
-
-static void
-draw_tabs_and_spaces(GtkWidget *view, GdkEventExpose *event,
- GtkTextIter iter, GtkTextIter end)
-{
- cairo_t *cr;
- GdkColor color;
- gunichar c;
- cr = gdk_cairo_create(event->window);
- //This color should be configurable
- gdk_color_parse("#444444", &color);
- gdk_cairo_set_source_color(cr, &color);
- cairo_set_line_width(cr, 0.8);
-
- while (gtk_text_iter_compare(&iter, &end) != 0)
- {
- c = gtk_text_iter_get_char(&iter);
- if(c == '\t')//TODO: Color should be set here to have a different color
- //for differents char (This should be themeable
- draw_tab_at_iter(cr, GTK_TEXT_VIEW(view), &iter);
- else if(c == '\040')
- draw_space_at_iter(cr, view, &iter);
- else if(c == '\n')
- draw_nbsp_at_iter(cr, GTK_TEXT_VIEW(view), &iter);
- if(!gtk_text_iter_forward_char(&iter))
- break;
- }
-
- cairo_destroy (cr);
-}
Modified: trunk/src/draw-spaces.h
==============================================================================
--- trunk/src/draw-spaces.h (original)
+++ trunk/src/draw-spaces.h Mon Jan 12 15:21:01 2009
@@ -1,9 +0,0 @@
-#ifndef __DRAW_SPACES__
-#define __DRAW_SPACES__
-
-#include <gtk/gtk.h>
-
-void
-on_event_after(GtkWidget *view, GdkEventExpose *event, gpointer data);
-
-#endif
Modified: trunk/src/view.c
==============================================================================
--- trunk/src/view.c (original)
+++ trunk/src/view.c Mon Jan 12 15:21:01 2009
@@ -27,7 +27,6 @@
#include <string.h>
-#include "draw-spaces.h"
#include "prefs-manager.h"
#include "utils.h"
#include "view.h"
@@ -265,21 +264,16 @@
* Enables special chars for white spaces including \n and \t
**/
void
-gtranslator_view_enable_visible_whitespace(GtranslatorView *view,
- gboolean enable)
+gtranslator_view_enable_visible_whitespace (GtranslatorView *view,
+ gboolean enable)
{
- g_return_if_fail(GTR_IS_VIEW(view));
+ g_return_if_fail (GTR_IS_VIEW (view));
- if(enable)
- g_signal_connect(view, "event-after",
- G_CALLBACK(on_event_after), NULL);
+ if (enable)
+ gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (view),
+ GTK_SOURCE_DRAW_SPACES_ALL);
else
- g_signal_handlers_disconnect_by_func(view,
- G_CALLBACK(on_event_after),
- NULL);
-
- /*It's neccessary redraw the widget when you connect or disconnect the signal*/
- gtk_widget_queue_draw (GTK_WIDGET (view));
+ gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (view), 0);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]