diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-09-18 11:43:20 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-09-18 11:43:20 +0800 |
commit | 37d47c916dd0d8d53f277862a297aa23feb8ff13 (patch) | |
tree | 8a0f1b3dc651ad004eea1b8de793f2fbada90d85 /widgets/e-text | |
parent | 645f6e47ea513495f428f9299c5e4ec89dac9891 (diff) | |
download | gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar.gz gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar.bz2 gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar.lz gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar.xz gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.tar.zst gsoc2013-evolution-37d47c916dd0d8d53f277862a297aa23feb8ff13.zip |
Added check for gnome-app-lib. Removed directories that have been moved to
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* configure.in: Added check for gnome-app-lib. Removed
directories that have been moved to gal.
From addressbook/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* backend/ebook/Makefile.am, contact-editor/Makefile.am,
ename/Makefile.am, gui/component/Makefile.am,
gui/widgets/Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and
$(EXTRA_GNOME_LIBS). Removed unneeded libraries.
* backend/ebook/e-card.c, backend/pas/pas-backend-file.c,
contact-editor/e-contact-editor-address.c,
contact-editor/e-contact-editor-categories.c,
contact-editor/e-contact-editor-categories.h,
contact-editor/e-contact-editor-fullname.c,
contact-editor/e-contact-editor.c,
contact-editor/e-contact-save-as.c, ename/e-address-western.c,
ename/test-ename-western-gtk.c,
gui/component/addressbook-factory.c, gui/component/addressbook.c,
gui/component/e-cardlist-model.h, gui/component/e-ldap-storage.c,
gui/component/select-names/e-select-names-bonobo.c,
gui/component/select-names/e-select-names-manager.c,
gui/component/select-names/e-select-names-model.c,
gui/component/select-names/e-select-names-table-model.c,
gui/component/select-names/e-select-names-table-model.h,
gui/component/select-names/e-select-names-text-model.h,
gui/component/select-names/e-select-names.c,
gui/component/select-names/e-select-names.h,
gui/search/e-addressbook-search-dialog.c,
gui/widgets/e-addressbook-model.h,
gui/widgets/e-addressbook-view.c, gui/widgets/e-minicard-label.c,
gui/widgets/e-minicard-view-widget.c,
gui/widgets/e-minicard-view-widget.h,
gui/widgets/e-minicard-view.c, gui/widgets/e-minicard-view.h,
gui/widgets/e-minicard-widget.h, gui/widgets/e-minicard.c,
gui/widgets/test-minicard-label.c, gui/widgets/test-reflow.c,
printing/e-contact-print.c: Fixed the #include lines to deal
properly with gal.
From calendar/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* gui/Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and
$(EXTRA_GNOME_LIBS). Removed unneeded libraries.
* gui/calendar-model.h, gui/e-calendar-table.c, gui/e-day-view.c,
gui/e-week-view-event-item.c, gui/e-week-view.c,
gui/event-editor.c, gui/gncal-todo.c, gui/gnome-cal.c, gui/main.c,
gui/print.c, gui/dialogs/task-editor.c: Fixed the #include lines
to deal properly with gal.
* gui/check-filled.xpm: New file since we can't include it from
e-table anymore.
From camel/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* camel-folder-search.c, camel-folder-search.h,
camel-remote-store.c, providers/imap/camel-imap-folder.c,
providers/imap/camel-imap-store.c: Fixed the #include lines to
deal properly with gal.
From composer/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and
$(EXTRA_GNOME_LIBS). Removed unneeded libraries.
* e-msg-composer-address-dialog.c, e-msg-composer-address-entry.c,
e-msg-composer-attachment.c, e-msg-composer-hdrs.c,
e-msg-composer.c: Fixed the #include lines to deal properly with
gal.
From e-util/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* Makefile.am: Removed all the files moved to gal.
* e-dialog-widgets.c: Fixed the #include lines to deal properly
with gal.
* e-gui-utils.c, e-gui-utils.h: Removed all of the functionality
that was moved to gal.
* e-canvas-utils.c, e-canvas-utils.h, e-canvas-vbox.c,
e-canvas-vbox.h, e-canvas.c, e-canvas.h, e-cursors.c, e-cursors.h,
e-font.c, e-font.h, e-popup-menu.c, e-popup-menu.h, e-printable.c,
e-printable.h, e-unicode.c, e-unicode.h, e-util.c, e-util.h,
e-xml-utils.c, e-xml-utils.h: Moved to gal.
From filter/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* filter-editor.c, filter-filter.c, filter-folder.c,
filter-input.c, filter-message-search.c, filter-option.c,
filter-rule.c, score-editor.c, vfolder-editor.c, vfolder-rule.c:
Fixed the #include lines to deal properly with gal.
From mail/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and
$(EXTRA_GNOME_LIBS). Removed unneeded libraries.
* component-factory.c, folder-browser-factory.c, folder-browser.c,
mail-callbacks.c, mail-config-gui.c, mail-display.c,
mail-display.h, main.c, message-list.c, message-list.h: Fixed the
#include lines to deal properly with gal.
From po/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* POTFILES.in: Removed files that have been moved to gal.
From shell/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and
$(EXTRA_GNOME_LIBS). Removed unneeded libraries.
* e-component-registry.c, e-corba-storage-registry.c,
e-corba-storage.c, e-folder-type-registry.c, e-folder.c,
e-local-folder.c, e-local-storage.c,
e-shell-folder-creation-dialog.c,
e-shell-folder-selection-dialog.c, e-shell-folder-title-bar.c,
e-shell-view.c, e-shell.c, e-shortcuts-view.c, e-shortcuts.c,
e-storage-set-view.c, e-storage-set-view.h, e-storage-set.c,
e-storage.c, evolution-local-storage.c, evolution-session.c,
evolution-shell-client.c, evolution-shell-component-client.c,
evolution-shell-component.c, evolution-shell-view.c,
evolution-storage-listener.c, evolution-storage.c, main.c: Fixed
the #include lines to deal properly with gal.
From widgets/meeting-time-sel/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and
$(EXTRA_GNOME_LIBS). Removed unneeded libraries.
* e-meeting-time-sel-list-item.c, e-meeting-time-sel.c,
e-meeting-time-sel.h: Fixed the #include lines to deal properly
with gal.
If you've read this far, you deserve a prize. The first email in my
mailbox with the subject "What a commit message!" (and your physical
mailing address somewhere in the message) will receive a free Helix
Code T-shirt mailed to anywhere within the continental United States.
I cannot be held responsible for problems with email systems anywhere.
This is supposed to be for fun, so please don't make a fuss if
something goes wrong and your mail doesn't reach me. Find my email
elsewhere in this message, and if it's been more than a few days,
you're probably too late.
From widgets/misc/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and
$(EXTRA_GNOME_LIBS). Removed unneeded libraries.
* e-calendar-item.c, e-calendar.c, e-calendar.h, e-title-bar.c:
Fixed the #include lines to deal properly with gal.
* e-scroll-frame.c, e-scroll-frame.h: Moved to gal.
From widgets/shortcut-bar/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and
$(EXTRA_GNOME_LIBS). Removed unneeded libraries.
* e-icon-bar.c, e-icon-bar.h, e-shortcut-bar.c,
e-shortcut-model.c, test-shortcut-bar.c: Fixed the #include lines
to deal properly with gal.
From widgets/ChangeLog:
2000-09-18 Christopher James Lahey <clahey@helixcode.com>
* Makefile.am: Removed directories that have been moved to gal.
* e-paned/.cvsignore, e-paned/Makefile.am, e-paned/e-hpaned.c,
e-paned/e-hpaned.h, e-paned/e-paned.c, e-paned/e-paned.h,
e-paned/e-vpaned.c, e-paned/e-vpaned.h: Moved to gal.
* e-reflow/.cvsignore, e-reflow/Makefile.am,
e-reflow/e-reflow-sorted.c, e-reflow/e-reflow-sorted.h,
e-reflow/e-reflow.c, e-reflow/e-reflow.h: Moved to gal.
* e-table/.cvsignore, e-table/ChangeLog, e-table/LICENSE,
e-table/Makefile.am, e-table/ROADMAP.e-table, e-table/TODO,
e-table/add-col.xpm, e-table/arrow-down.xpm, e-table/arrow-up.xpm,
e-table/check-empty.xpm, e-table/check-filled.xpm,
e-table/clip.png, e-table/e-cell-checkbox.c,
e-table/e-cell-checkbox.h, e-table/e-cell-string.c,
e-table/e-cell-text.c, e-table/e-cell-text.h,
e-table/e-cell-toggle.c, e-table/e-cell-toggle.h,
e-table/e-cell-tree.c, e-table/e-cell-tree.h, e-table/e-cell.c,
e-table/e-cell.h, e-table/e-table-click-to-add.c,
e-table/e-table-click-to-add.h, e-table/e-table-col-dnd.h,
e-table/e-table-col.c, e-table/e-table-col.h,
e-table/e-table-column-model.h, e-table/e-table-column.c,
e-table/e-table-config.c, e-table/e-table-config.glade,
e-table/e-table-config.glade.h, e-table/e-table-config.h,
e-table/e-table-defines.h, e-table/e-table-example-1.c,
e-table/e-table-example-2.c,
e-table/e-table-field-chooser-dialog.c,
e-table/e-table-field-chooser-dialog.h,
e-table/e-table-field-chooser-item.c,
e-table/e-table-field-chooser-item.h,
e-table/e-table-field-chooser.c,
e-table/e-table-field-chooser.glade,
e-table/e-table-field-chooser.glade.h,
e-table/e-table-field-chooser.h,
e-table/e-table-group-container.c,
e-table/e-table-group-container.h, e-table/e-table-group-leaf.c,
e-table/e-table-group-leaf.h, e-table/e-table-group.c,
e-table/e-table-group.glade, e-table/e-table-group.glade.h,
e-table/e-table-group.h, e-table/e-table-header-item.c,
e-table/e-table-header-item.h, e-table/e-table-header.c,
e-table/e-table-header.h, e-table/e-table-item.c,
e-table/e-table-item.h, e-table/e-table-model.c,
e-table/e-table-model.h, e-table/e-table-one.c,
e-table/e-table-one.h, e-table/e-table-scrolled.c,
e-table/e-table-scrolled.h, e-table/e-table-selection-model.c,
e-table/e-table-selection-model.h, e-table/e-table-simple.c,
e-table/e-table-simple.h, e-table/e-table-size-test.c,
e-table/e-table-sort-info.c, e-table/e-table-sort-info.h,
e-table/e-table-sorted-variable.c,
e-table/e-table-sorted-variable.h, e-table/e-table-sorted.c,
e-table/e-table-sorted.h, e-table/e-table-sorter.c,
e-table/e-table-sorter.h, e-table/e-table-subset-variable.c,
e-table/e-table-subset-variable.h, e-table/e-table-subset.c,
e-table/e-table-subset.h, e-table/e-table-text-model.c,
e-table/e-table-text-model.h, e-table/e-table-tooltip.h,
e-table/e-table-tree.h, e-table/e-table.c, e-table/e-table.h,
e-table/e-tree-example-1.c, e-table/e-tree-example-2.c,
e-table/e-tree-model.c, e-table/e-tree-model.h,
e-table/e-tree-simple.c, e-table/e-tree-simple.h,
e-table/image1.png, e-table/image2.png, e-table/image3.png,
e-table/remove-col.xpm, e-table/sample.table,
e-table/table-test.c, e-table/table-test.h, e-table/test-check.c,
e-table/test-cols.c, e-table/test-table.c: Moved to gal.
* e-text/.cvsignore, e-text/Makefile.am, e-text/e-entry-test.c,
e-text/e-entry.c, e-text/e-entry.h,
e-text/e-text-event-processor-emacs-like.c,
e-text/e-text-event-processor-emacs-like.h,
e-text/e-text-event-processor-types.h,
e-text/e-text-event-processor.c, e-text/e-text-event-processor.h,
e-text/e-text-model.c, e-text/e-text-model.h,
e-text/e-text-test.c, e-text/e-text.c, e-text/e-text.h: Moved to
gal.
i.e.,
...
changed evolution to work with gal.
svn path=/trunk/; revision=5490
Diffstat (limited to 'widgets/e-text')
-rw-r--r-- | widgets/e-text/.cvsignore | 9 | ||||
-rw-r--r-- | widgets/e-text/Makefile.am | 43 | ||||
-rw-r--r-- | widgets/e-text/e-entry-test.c | 79 | ||||
-rw-r--r-- | widgets/e-text/e-entry.c | 408 | ||||
-rw-r--r-- | widgets/e-text/e-entry.h | 39 | ||||
-rw-r--r-- | widgets/e-text/e-text-event-processor-emacs-like.c | 372 | ||||
-rw-r--r-- | widgets/e-text/e-text-event-processor-emacs-like.h | 68 | ||||
-rw-r--r-- | widgets/e-text/e-text-event-processor-types.h | 140 | ||||
-rw-r--r-- | widgets/e-text/e-text-event-processor.c | 103 | ||||
-rw-r--r-- | widgets/e-text/e-text-event-processor.h | 74 | ||||
-rw-r--r-- | widgets/e-text/e-text-model.c | 244 | ||||
-rw-r--r-- | widgets/e-text/e-text-model.h | 72 | ||||
-rw-r--r-- | widgets/e-text/e-text-test.c | 154 | ||||
-rw-r--r-- | widgets/e-text/e-text.c | 3389 | ||||
-rw-r--r-- | widgets/e-text/e-text.h | 227 |
15 files changed, 0 insertions, 5421 deletions
diff --git a/widgets/e-text/.cvsignore b/widgets/e-text/.cvsignore deleted file mode 100644 index ab703bd5e1..0000000000 --- a/widgets/e-text/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -e-text-test -e-entry-test diff --git a/widgets/e-text/Makefile.am b/widgets/e-text/Makefile.am deleted file mode 100644 index b56d735990..0000000000 --- a/widgets/e-text/Makefile.am +++ /dev/null @@ -1,43 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir) \ - $(GNOME_INCLUDEDIR) \ - $(UNICODE_CFLAGS) \ - -DG_LOG_DOMAIN=\"e-text\" - -noinst_LIBRARIES = \ - libetext.a - -libetext_a_SOURCES = \ - e-entry.c \ - e-entry.h \ - e-text-event-processor-emacs-like.c \ - e-text-event-processor-emacs-like.h \ - e-text-event-processor-types.h \ - e-text-event-processor.c \ - e-text-event-processor.h \ - e-text-model.c \ - e-text-model.h \ - e-text.c \ - e-text.h - -noinst_PROGRAMS = \ - e-text-test \ - e-entry-test - -e_text_test_SOURCES = \ - e-text-test.c - -e_text_test_LDADD = \ - libetext.a \ - $(EXTRA_GNOME_LIBS) \ - $(top_builddir)/e-util/libeutil.la - -e_entry_test_SOURCES = \ - e-entry-test.c - -e_entry_test_LDADD = \ - libetext.a \ - $(EXTRA_GNOME_LIBS) \ - $(top_builddir)/e-util/libeutil.la - -e_text_test_LDFLAGS = `gnome-config --libs gdk_pixbuf` diff --git a/widgets/e-text/e-entry-test.c b/widgets/e-text/e-entry-test.c deleted file mode 100644 index 411e8d693c..0000000000 --- a/widgets/e-text/e-entry-test.c +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-minicard.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.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, 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. - */ - - - -#include "config.h" - -#include <gnome.h> -#include "e-entry.h" - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey <clahey@umich.edu>", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Minicard Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the minicard canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *entry; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "EEntry Test", VERSION, argc, argv); - app = gnome_app_new("EEntry Test", NULL); - - entry = e_entry_new(); - gtk_object_set(GTK_OBJECT(entry), - "editable", TRUE, - "use_ellipsis", TRUE, - NULL); - gnome_app_set_contents( GNOME_APP( app ), entry ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/widgets/e-text/e-entry.c b/widgets/e-text/e-entry.c deleted file mode 100644 index cbde382c93..0000000000 --- a/widgets/e-text/e-entry.c +++ /dev/null @@ -1,408 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * E-table.c: A graphical view of a Table. - * - * Author: - * Miguel de Icaza (miguel@helixcode.com) - * Chris Lahey (clahey@helixcode.com) - * - * Copyright 1999, Helix Code, Inc - */ -#include <config.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#ifdef HAVE_ALLOCA_H -#include <alloca.h> -#endif -#include <stdio.h> -#include <libgnomeui/gnome-canvas.h> -#include <gtk/gtksignal.h> -#include <gnome-xml/parser.h> -#include "e-util/e-util.h" -#include "e-util/e-canvas.h" -#include "e-entry.h" -#include "e-util/e-canvas-utils.h" - -#define MIN_ENTRY_WIDTH 150 -#define INNER_BORDER 2 - -#define PARENT_TYPE gtk_table_get_type () - -static GtkObjectClass *parent_class; - -enum { - E_ENTRY_CHANGED, - E_ENTRY_ACTIVATE, - E_ENTRY_LAST_SIGNAL -}; - -static guint e_entry_signals[E_ENTRY_LAST_SIGNAL] = { 0 }; - -/* Object argument IDs */ -enum { - ARG_0, - ARG_MODEL, - ARG_EVENT_PROCESSOR, - ARG_TEXT, - ARG_FONT, - ARG_FONTSET, - ARG_FONT_GDK, - ARG_ANCHOR, - ARG_JUSTIFICATION, - ARG_X_OFFSET, - ARG_Y_OFFSET, - ARG_FILL_COLOR, - ARG_FILL_COLOR_GDK, - ARG_FILL_COLOR_RGBA, - ARG_FILL_STIPPLE, - ARG_EDITABLE, - ARG_USE_ELLIPSIS, - ARG_ELLIPSIS, - ARG_LINE_WRAP, - ARG_BREAK_CHARACTERS, - ARG_MAX_LINES, - ARG_WIDTH, - ARG_HEIGHT -}; - -static void -canvas_size_allocate (GtkWidget *widget, GtkAllocation *alloc, - EEntry *e_entry) -{ - gnome_canvas_set_scroll_region ( - e_entry->canvas, - 0, 0, alloc->width, alloc->height); - gtk_object_set (GTK_OBJECT (e_entry->item), - "clip_width", (double) alloc->width, - "clip_height", (double) alloc->height, - NULL); -} - -static void -canvas_size_request (GtkWidget *widget, GtkRequisition *requisition, - EEntry *e_entry) -{ - g_return_if_fail (widget != NULL); - g_return_if_fail (GNOME_IS_CANVAS (widget)); - g_return_if_fail (requisition != NULL); - - requisition->width = MIN_ENTRY_WIDTH + (widget->style->klass->xthickness + INNER_BORDER) * 2; - requisition->height = (widget->style->font->ascent + - widget->style->font->descent + - (widget->style->klass->ythickness + INNER_BORDER) * 2); -} - -static void -e_entry_init (GtkObject *object) -{ - EEntry *e_entry = E_ENTRY (object); - GtkTable *gtk_table = GTK_TABLE (object); - - e_entry->canvas = GNOME_CANVAS(e_canvas_new()); - gtk_signal_connect(GTK_OBJECT(e_entry->canvas), "size_allocate", - GTK_SIGNAL_FUNC(canvas_size_allocate), e_entry); - gtk_signal_connect(GTK_OBJECT(e_entry->canvas), "size_request", - GTK_SIGNAL_FUNC(canvas_size_request), e_entry); - e_entry->item = E_TEXT(gnome_canvas_item_new(gnome_canvas_root(e_entry->canvas), - e_text_get_type(), - "clip", TRUE, - "fill_clip_rectangle", TRUE, - "anchor", GTK_ANCHOR_NW, - "draw_borders", TRUE, - NULL)); - - gtk_table_attach_defaults(gtk_table, GTK_WIDGET(e_entry->canvas), - 0, 1, 0, 1); - gtk_widget_show(GTK_WIDGET(e_entry->canvas)); -} - -EEntry * -e_entry_construct (EEntry *e_entry) -{ - return e_entry; -} - -GtkWidget * -e_entry_new (void) -{ - EEntry *e_entry; - e_entry = gtk_type_new (e_entry_get_type ()); - e_entry = e_entry_construct (e_entry); - - return GTK_WIDGET (e_entry); -} - -static void -et_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EEntry *ee = E_ENTRY (o); - - switch (arg_id){ - case ARG_MODEL: - gtk_object_get(GTK_OBJECT(ee->item), - "model", >K_VALUE_OBJECT (*arg), - NULL); - break; - - case ARG_EVENT_PROCESSOR: - gtk_object_get(GTK_OBJECT(ee->item), - "event_processor", >K_VALUE_OBJECT (*arg), - NULL); - break; - - case ARG_TEXT: - gtk_object_get(GTK_OBJECT(ee->item), - "text", >K_VALUE_STRING (*arg), - NULL); - break; - - case ARG_FONT_GDK: - gtk_object_get(GTK_OBJECT(ee->item), - "font_gdk", >K_VALUE_BOXED (*arg), - NULL); - break; - - case ARG_JUSTIFICATION: - gtk_object_get(GTK_OBJECT(ee->item), - "justification", >K_VALUE_ENUM (*arg), - NULL); - break; - - case ARG_FILL_COLOR_GDK: - gtk_object_get(GTK_OBJECT(ee->item), - "fill_color_gdk", >K_VALUE_BOXED (*arg), - NULL); - break; - - case ARG_FILL_COLOR_RGBA: - gtk_object_get(GTK_OBJECT(ee->item), - "fill_color_rgba", >K_VALUE_UINT (*arg), - NULL); - break; - - case ARG_FILL_STIPPLE: - gtk_object_get(GTK_OBJECT(ee->item), - "fill_stiple", >K_VALUE_BOXED (*arg), - NULL); - break; - - case ARG_EDITABLE: - gtk_object_get(GTK_OBJECT(ee->item), - "editable", >K_VALUE_BOOL (*arg), - NULL); - break; - - case ARG_USE_ELLIPSIS: - gtk_object_get(GTK_OBJECT(ee->item), - "use_ellipsis", >K_VALUE_BOOL (*arg), - NULL); - break; - - case ARG_ELLIPSIS: - gtk_object_get(GTK_OBJECT(ee->item), - "ellipsis", >K_VALUE_STRING (*arg), - NULL); - break; - - case ARG_LINE_WRAP: - gtk_object_get(GTK_OBJECT(ee->item), - "line_wrap", >K_VALUE_BOOL (*arg), - NULL); - break; - - case ARG_BREAK_CHARACTERS: - gtk_object_get(GTK_OBJECT(ee->item), - "break_characters", >K_VALUE_STRING (*arg), - NULL); - break; - - case ARG_MAX_LINES: - gtk_object_get(GTK_OBJECT(ee->item), - "max_lines", >K_VALUE_INT (*arg), - NULL); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EEntry *ee = E_ENTRY (o); - - switch (arg_id){ - case ARG_MODEL: - gtk_object_set(GTK_OBJECT(ee->item), - "model", GTK_VALUE_OBJECT (*arg), - NULL); - break; - - case ARG_EVENT_PROCESSOR: - gtk_object_set(GTK_OBJECT(ee->item), - "event_processor", GTK_VALUE_OBJECT (*arg), - NULL); - break; - - case ARG_TEXT: - gtk_object_set(GTK_OBJECT(ee->item), - "text", GTK_VALUE_STRING (*arg), - NULL); - break; - - case ARG_FONT: - gtk_object_set(GTK_OBJECT(ee->item), - "font", GTK_VALUE_STRING (*arg), - NULL); - break; - - case ARG_FONTSET: - gtk_object_set(GTK_OBJECT(ee->item), - "fontset", GTK_VALUE_STRING (*arg), - NULL); - break; - - case ARG_FONT_GDK: - gtk_object_set(GTK_OBJECT(ee->item), - "font_gdk", GTK_VALUE_BOXED (*arg), - NULL); - break; - - case ARG_JUSTIFICATION: - gtk_object_set(GTK_OBJECT(ee->item), - "justification", GTK_VALUE_ENUM (*arg), - NULL); - break; - - case ARG_FILL_COLOR: - gtk_object_set(GTK_OBJECT(ee->item), - "fill_color", GTK_VALUE_STRING (*arg), - NULL); - break; - - case ARG_FILL_COLOR_GDK: - gtk_object_set(GTK_OBJECT(ee->item), - "fill_color_gdk", GTK_VALUE_BOXED (*arg), - NULL); - break; - - case ARG_FILL_COLOR_RGBA: - gtk_object_set(GTK_OBJECT(ee->item), - "fill_color_rgba", GTK_VALUE_UINT (*arg), - NULL); - break; - - case ARG_FILL_STIPPLE: - gtk_object_set(GTK_OBJECT(ee->item), - "fill_stiple", GTK_VALUE_BOXED (*arg), - NULL); - break; - - case ARG_EDITABLE: - gtk_object_set(GTK_OBJECT(ee->item), - "editable", GTK_VALUE_BOOL (*arg), - NULL); - break; - - case ARG_USE_ELLIPSIS: - gtk_object_set(GTK_OBJECT(ee->item), - "use_ellipsis", GTK_VALUE_BOOL (*arg), - NULL); - break; - - case ARG_ELLIPSIS: - gtk_object_set(GTK_OBJECT(ee->item), - "ellipsis", GTK_VALUE_STRING (*arg), - NULL); - break; - - case ARG_LINE_WRAP: - gtk_object_set(GTK_OBJECT(ee->item), - "line_wrap", GTK_VALUE_BOOL (*arg), - NULL); - break; - - case ARG_BREAK_CHARACTERS: - gtk_object_set(GTK_OBJECT(ee->item), - "break_characters", GTK_VALUE_STRING (*arg), - NULL); - break; - - case ARG_MAX_LINES: - gtk_object_set(GTK_OBJECT(ee->item), - "max_lines", GTK_VALUE_INT (*arg), - NULL); - break; - } -} - -static void -e_entry_class_init (GtkObjectClass *object_class) -{ - EEntryClass *klass = E_ENTRY_CLASS(object_class); - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->set_arg = et_set_arg; - object_class->get_arg = et_get_arg; - - klass->changed = NULL; - klass->activate = NULL; - - e_entry_signals[E_ENTRY_CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EEntryClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - e_entry_signals[E_ENTRY_ACTIVATE] = - gtk_signal_new ("activate", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EEntryClass, activate), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - - gtk_object_class_add_signals (object_class, e_entry_signals, E_ENTRY_LAST_SIGNAL); - - gtk_object_add_arg_type ("EEntry::model", - GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_MODEL); - gtk_object_add_arg_type ("EEntry::event_processor", - GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_EVENT_PROCESSOR); - gtk_object_add_arg_type ("EEntry::text", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TEXT); - gtk_object_add_arg_type ("EEntry::font", - GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONT); - gtk_object_add_arg_type ("EEntry::fontset", - GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONTSET); - gtk_object_add_arg_type ("EEntry::font_gdk", - GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_FONT_GDK); - gtk_object_add_arg_type ("EEntry::justification", - GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFICATION); - gtk_object_add_arg_type ("EEntry::fill_color", - GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FILL_COLOR); - gtk_object_add_arg_type ("EEntry::fill_color_gdk", - GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_FILL_COLOR_GDK); - gtk_object_add_arg_type ("EEntry::fill_color_rgba", - GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_FILL_COLOR_RGBA); - gtk_object_add_arg_type ("EEntry::fill_stipple", - GTK_TYPE_GDK_WINDOW, GTK_ARG_READWRITE, ARG_FILL_STIPPLE); - gtk_object_add_arg_type ("EEntry::editable", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE); - gtk_object_add_arg_type ("EEntry::use_ellipsis", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_USE_ELLIPSIS); - gtk_object_add_arg_type ("EEntry::ellipsis", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ELLIPSIS); - gtk_object_add_arg_type ("EEntry::line_wrap", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_LINE_WRAP); - gtk_object_add_arg_type ("EEntry::break_characters", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_BREAK_CHARACTERS); - gtk_object_add_arg_type ("EEntry::max_lines", - GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_MAX_LINES); -} - -E_MAKE_TYPE(e_entry, "EEntry", EEntry, e_entry_class_init, e_entry_init, PARENT_TYPE); diff --git a/widgets/e-text/e-entry.h b/widgets/e-text/e-entry.h deleted file mode 100644 index ad349659c3..0000000000 --- a/widgets/e-text/e-entry.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_ENTRY_H_ -#define _E_ENTRY_H_ - -#include <libgnomeui/gnome-canvas.h> -#include <gtk/gtktable.h> -#include <gnome-xml/tree.h> -#include "e-text.h" - -BEGIN_GNOME_DECLS - -#define E_ENTRY_TYPE (e_entry_get_type ()) -#define E_ENTRY(o) (GTK_CHECK_CAST ((o), E_ENTRY_TYPE, EEntry)) -#define E_ENTRY_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_ENTRY_TYPE, EEntryClass)) -#define E_IS_ENTRY(o) (GTK_CHECK_TYPE ((o), E_ENTRY_TYPE)) -#define E_IS_ENTRY_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_ENTRY_TYPE)) - -typedef struct { - GtkTable parent; - - GnomeCanvas *canvas; - EText *item; -} EEntry; - -typedef struct { - GtkTableClass parent_class; - - void (* changed) (EEntry *entry); - void (* activate) (EEntry *entry); -} EEntryClass; - -GtkType e_entry_get_type (void); - -EEntry *e_entry_construct (EEntry *e_entry); -GtkWidget *e_entry_new (void); - -END_GNOME_DECLS - -#endif /* _E_ENTRY_H_ */ diff --git a/widgets/e-text/e-text-event-processor-emacs-like.c b/widgets/e-text/e-text-event-processor-emacs-like.c deleted file mode 100644 index be323d028f..0000000000 --- a/widgets/e-text/e-text-event-processor-emacs-like.c +++ /dev/null @@ -1,372 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-text-event-processor.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <gnome.h> -#include "e-text-event-processor-emacs-like.h" -static void e_text_event_processor_emacs_like_init (ETextEventProcessorEmacsLike *card); -static void e_text_event_processor_emacs_like_class_init (ETextEventProcessorEmacsLikeClass *klass); -static gint e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event); - -static ETextEventProcessorClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0 -}; - -static const ETextEventProcessorCommand control_keys[26] = -{ - { E_TEP_START_OF_LINE, E_TEP_MOVE, 0, "" }, /* a */ - { E_TEP_BACKWARD_CHARACTER, E_TEP_MOVE, 0, "" }, /* b */ - { E_TEP_SELECTION, E_TEP_COPY, 0, "" }, /* c */ - { E_TEP_FORWARD_CHARACTER, E_TEP_DELETE, 0, "" }, /* d */ - { E_TEP_END_OF_LINE, E_TEP_MOVE, 0, "" }, /* e */ - { E_TEP_FORWARD_CHARACTER, E_TEP_MOVE, 0, "" }, /* f */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* g */ - { E_TEP_BACKWARD_CHARACTER, E_TEP_DELETE, 0, "" }, /* h */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* i */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* j */ - { E_TEP_END_OF_LINE, E_TEP_DELETE, 0, "" }, /* k */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* l */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* m */ - { E_TEP_FORWARD_LINE, E_TEP_MOVE, 0, "" }, /* n */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* o */ - { E_TEP_BACKWARD_LINE, E_TEP_MOVE, 0, "" }, /* p */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* q */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* r */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* s */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* t */ - { E_TEP_START_OF_LINE, E_TEP_DELETE, 0, "" }, /* u */ - { E_TEP_SELECTION, E_TEP_PASTE, 0, "" }, /* v */ - { E_TEP_SELECTION, E_TEP_DELETE, 0, "" }, /* w */ - { E_TEP_SELECTION, E_TEP_DELETE, 0, "" }, /* x */ - { E_TEP_SELECTION, E_TEP_PASTE, 0, "" }, /* y */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" } /* z */ -}; - -static const ETextEventProcessorCommand alt_keys[26] = -{ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* a */ - { E_TEP_BACKWARD_WORD, E_TEP_MOVE, 0, "" }, /* b */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* c */ - { E_TEP_FORWARD_WORD, E_TEP_DELETE, 0, "" }, /* d */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* e */ - { E_TEP_FORWARD_WORD, E_TEP_MOVE, 0, "" }, /* f */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* g */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* h */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* i */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* j */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* k */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* l */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* m */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* n */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* o */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* p */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* q */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* r */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* s */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* t */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* u */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* v */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* w */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* x */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" }, /* y */ - { E_TEP_SELECTION, E_TEP_NOP, 0, "" } /* z */ - -}; - -GtkType -e_text_event_processor_emacs_like_get_type (void) -{ - static GtkType text_event_processor_emacs_like_type = 0; - - if (!text_event_processor_emacs_like_type) - { - static const GtkTypeInfo text_event_processor_emacs_like_info = - { - "ETextEventProcessorEmacsLike", - sizeof (ETextEventProcessorEmacsLike), - sizeof (ETextEventProcessorEmacsLikeClass), - (GtkClassInitFunc) e_text_event_processor_emacs_like_class_init, - (GtkObjectInitFunc) e_text_event_processor_emacs_like_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - text_event_processor_emacs_like_type = gtk_type_unique (e_text_event_processor_get_type (), &text_event_processor_emacs_like_info); - } - - return text_event_processor_emacs_like_type; -} - -static void -e_text_event_processor_emacs_like_class_init (ETextEventProcessorEmacsLikeClass *klass) -{ - GtkObjectClass *object_class; - ETextEventProcessorClass *processor_class; - - object_class = (GtkObjectClass*) klass; - processor_class = (ETextEventProcessorClass*) klass; - - parent_class = gtk_type_class (e_text_event_processor_get_type ()); - - processor_class->event = e_text_event_processor_emacs_like_event; -} - -static void -e_text_event_processor_emacs_like_init (ETextEventProcessorEmacsLike *tep) -{ -} - -static gint -e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event) -{ - ETextEventProcessorCommand command; - ETextEventProcessorEmacsLike *tep_el = E_TEXT_EVENT_PROCESSOR_EMACS_LIKE(tep); - command.action = E_TEP_NOP; - switch (event->type) { - case GDK_BUTTON_PRESS: - if (event->button.button == 1) { - command.action = E_TEP_GRAB; - command.time = event->button.time; - gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command); - if (event->button.state & GDK_SHIFT_MASK) - command.action = E_TEP_SELECT; - else - command.action = E_TEP_MOVE; - command.position = E_TEP_VALUE; - command.value = event->button.position; - command.time = event->button.time; - tep_el->mouse_down = TRUE; - } - break; - case GDK_2BUTTON_PRESS: - if (event->button.button == 1) { - command.action = E_TEP_SELECT; - command.position = E_TEP_SELECT_WORD; - command.time = event->button.time; - } - break; - case GDK_3BUTTON_PRESS: - if (event->button.button == 1) { - command.action = E_TEP_SELECT; - command.position = E_TEP_SELECT_ALL; - command.time = event->button.time; - } - break; - case GDK_BUTTON_RELEASE: - if (event->button.button == 1) { - command.action = E_TEP_UNGRAB; - command.time = event->button.time; - gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command); - command.time = event->button.time; - tep_el->mouse_down = FALSE; - command.action = E_TEP_NOP; - } else if (event->button.button == 2) { - command.action = E_TEP_MOVE; - command.position = E_TEP_VALUE; - command.value = event->button.position; - command.time = event->button.time; - gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command); - - command.action = E_TEP_GET_SELECTION; - command.position = E_TEP_SELECTION; - command.value = 0; - command.time = event->button.time; - } - break; - case GDK_MOTION_NOTIFY: - if (tep_el->mouse_down) { - command.action = E_TEP_SELECT; - command.position = E_TEP_VALUE; - command.time = event->motion.time; - command.value = event->motion.position; - } - break; - case GDK_KEY_PRESS: - { - ETextEventProcessorEventKey key = event->key; - command.time = event->key.time; - if (key.state & GDK_SHIFT_MASK) - command.action = E_TEP_SELECT; - else - command.action = E_TEP_MOVE; - switch(key.keyval) { - case GDK_Home: - if (key.state & GDK_CONTROL_MASK) - command.position = E_TEP_START_OF_BUFFER; - else - command.position = E_TEP_START_OF_LINE; - break; - case GDK_End: - if (key.state & GDK_CONTROL_MASK) - command.position = E_TEP_END_OF_BUFFER; - else - command.position = E_TEP_END_OF_LINE; - break; - case GDK_Page_Up: command.position = E_TEP_BACKWARD_PAGE; break; - case GDK_Page_Down: command.position = E_TEP_FORWARD_PAGE; break; - /* CUA has Ctrl-Up/Ctrl-Down as paragraph up down */ - case GDK_Up: command.position = E_TEP_BACKWARD_LINE; break; - case GDK_Down: command.position = E_TEP_FORWARD_LINE; break; - case GDK_Left: - if (key.state & GDK_CONTROL_MASK) - command.position = E_TEP_BACKWARD_WORD; - else - command.position = E_TEP_BACKWARD_CHARACTER; - break; - case GDK_Right: - if (key.state & GDK_CONTROL_MASK) - command.position = E_TEP_FORWARD_WORD; - else - command.position = E_TEP_FORWARD_CHARACTER; - break; - - case GDK_BackSpace: - command.action = E_TEP_DELETE; - if (key.state & GDK_CONTROL_MASK) - command.position = E_TEP_BACKWARD_WORD; - else - command.position = E_TEP_BACKWARD_CHARACTER; - break; - case GDK_Clear: - command.action = E_TEP_DELETE; - command.position = E_TEP_END_OF_LINE; - break; - case GDK_Insert: - if (key.state & GDK_SHIFT_MASK) { - command.action = E_TEP_PASTE; - command.position = E_TEP_SELECTION; - } else if (key.state & GDK_CONTROL_MASK) { - command.action = E_TEP_COPY; - command.position = E_TEP_SELECTION; - } else { - /* gtk_toggle_insert(text) -- IMPLEMENT */ - } - break; - case GDK_Delete: - if (key.state & GDK_CONTROL_MASK){ - command.action = E_TEP_DELETE; - command.position = E_TEP_FORWARD_WORD; - } else if (key.state & GDK_SHIFT_MASK) { - command.action = E_TEP_COPY; - command.position = E_TEP_SELECTION; - gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command); - - command.action = E_TEP_DELETE; - command.position = E_TEP_SELECTION; - } else { - command.action = E_TEP_DELETE; - command.position = E_TEP_FORWARD_CHARACTER; - } - break; - case GDK_Tab: - /* Don't insert literally */ - command.action = E_TEP_NOP; - command.position = E_TEP_SELECTION; - break; - case GDK_Return: - if (key.state & GDK_CONTROL_MASK) { - command.action = E_TEP_ACTIVATE; - command.position = E_TEP_SELECTION; - } else { - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = 1; - command.string = "\n"; - } - break; - case GDK_Escape: - /* Don't insert literally */ - command.action = E_TEP_NOP; - command.position = E_TEP_SELECTION; - break; - - default: - if (key.state & GDK_CONTROL_MASK) { - if ((key.keyval >= 'A') && (key.keyval <= 'Z')) - key.keyval -= 'A' - 'a'; - - if ((key.keyval >= 'a') && (key.keyval <= 'z')) { - command.position = control_keys[(int) (key.keyval - 'a')].position; - if (control_keys[(int) (key.keyval - 'a')].action != E_TEP_MOVE) - command.action = control_keys[(int) (key.keyval - 'a')].action; - command.value = control_keys[(int) (key.keyval - 'a')].value; - command.string = control_keys[(int) (key.keyval - 'a')].string; - } - - if (key.keyval == 'x' || key.keyval == 'w') { - command.action = E_TEP_COPY; - command.position = E_TEP_SELECTION; - gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command); - - command.action = E_TEP_DELETE; - command.position = E_TEP_SELECTION; - } - - break; - } else if (key.state & GDK_MOD1_MASK) { - if ((key.keyval >= 'A') && (key.keyval <= 'Z')) - key.keyval -= 'A' - 'a'; - - if ((key.keyval >= 'a') && (key.keyval <= 'z')) { - command.position = alt_keys[(int) (key.keyval - 'a')].position; - if (alt_keys[(int) (key.keyval - 'a')].action != E_TEP_MOVE) - command.action = alt_keys[(int) (key.keyval - 'a')].action; - command.value = alt_keys[(int) (key.keyval - 'a')].value; - command.string = alt_keys[(int) (key.keyval - 'a')].string; - } - } else if (key.length > 0) { - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.value = strlen(key.string); - command.string = key.string; - - } else { - command.action = E_TEP_NOP; - } - } - break; - case GDK_KEY_RELEASE: - command.time = event->key.time; - command.action = E_TEP_NOP; - break; - default: - command.action = E_TEP_NOP; - break; - } - } - if (command.action != E_TEP_NOP) { - gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command); - return 1; - } - else - return 0; -} - -ETextEventProcessor * -e_text_event_processor_emacs_like_new (void) -{ - ETextEventProcessorEmacsLike *retval = gtk_type_new (e_text_event_processor_emacs_like_get_type ()); - return E_TEXT_EVENT_PROCESSOR (retval); -} - diff --git a/widgets/e-text/e-text-event-processor-emacs-like.h b/widgets/e-text/e-text-event-processor-emacs-like.h deleted file mode 100644 index 651bb552b3..0000000000 --- a/widgets/e-text/e-text-event-processor-emacs-like.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-text-event-processor-emacs-like.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__ -#define __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__ - -#include <gnome.h> -#include "e-text-event-processor.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* ETextEventProcessorEmacsLike - Turns events on a text widget into commands. Uses an emacs-ish interface. - * - */ - -#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE (e_text_event_processor_emacs_like_get_type ()) -#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE(obj) (GTK_CHECK_CAST ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE, ETextEventProcessorEmacsLike)) -#define E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE, ETextEventProcessorEmacsLikeClass)) -#define E_IS_TEXT_EVENT_PROCESSOR_EMACS_LIKE(obj) (GTK_CHECK_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE)) -#define E_IS_TEXT_EVENT_PROCESSOR_EMACS_LIKE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_TYPE)) - - -typedef struct _ETextEventProcessorEmacsLike ETextEventProcessorEmacsLike; -typedef struct _ETextEventProcessorEmacsLikeClass ETextEventProcessorEmacsLikeClass; - -struct _ETextEventProcessorEmacsLike -{ - ETextEventProcessor parent; - - /* object specific fields */ - gboolean mouse_down; -}; - -struct _ETextEventProcessorEmacsLikeClass -{ - ETextEventProcessorClass parent_class; -}; - - -GtkType e_text_event_processor_emacs_like_get_type (void); -ETextEventProcessor *e_text_event_processor_emacs_like_new (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_TEXT_EVENT_PROCESSOR_EMACS_LIKE_H__ */ diff --git a/widgets/e-text/e-text-event-processor-types.h b/widgets/e-text/e-text-event-processor-types.h deleted file mode 100644 index 8f2ffbaf39..0000000000 --- a/widgets/e-text/e-text-event-processor-types.h +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-text-event-processor.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __E_TEXT_EVENT_PROCESSOR_TYPES_H__ -#define __E_TEXT_EVENT_PROCESSOR_TYPES_H__ - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#include <gdk/gdktypes.h> - -typedef enum _ETextEventProcessorCommandPosition ETextEventProcessorCommandPosition; -typedef enum _ETextEventProcessorCommandAction ETextEventProcessorCommandAction; -typedef struct _ETextEventProcessorCommand ETextEventProcessorCommand; - -typedef union _ETextEventProcessorEvent ETextEventProcessorEvent; -typedef struct _ETextEventProcessorEventButton ETextEventProcessorEventButton; -typedef struct _ETextEventProcessorEventKey ETextEventProcessorEventKey; -typedef struct _ETextEventProcessorEventMotion ETextEventProcessorEventMotion; - -enum _ETextEventProcessorCommandPosition { - E_TEP_VALUE, - E_TEP_SELECTION, - - E_TEP_START_OF_BUFFER, - E_TEP_END_OF_BUFFER, - - E_TEP_START_OF_LINE, - E_TEP_END_OF_LINE, - - E_TEP_FORWARD_CHARACTER, - E_TEP_BACKWARD_CHARACTER, - - E_TEP_FORWARD_WORD, - E_TEP_BACKWARD_WORD, - - E_TEP_FORWARD_LINE, - E_TEP_BACKWARD_LINE, - - E_TEP_FORWARD_PARAGRAPH, - E_TEP_BACKWARD_PARAGRAPH, - - E_TEP_FORWARD_PAGE, - E_TEP_BACKWARD_PAGE, - - E_TEP_SELECT_WORD, - E_TEP_SELECT_ALL - -}; - -enum _ETextEventProcessorCommandAction { - E_TEP_MOVE, - E_TEP_SELECT, - E_TEP_DELETE, - E_TEP_INSERT, - - E_TEP_COPY, - E_TEP_PASTE, - E_TEP_GET_SELECTION, - E_TEP_SET_SELECT_BY_WORD, - E_TEP_ACTIVATE, - - E_TEP_GRAB, - E_TEP_UNGRAB, - - E_TEP_NOP -}; - -struct _ETextEventProcessorCommand { - ETextEventProcessorCommandPosition position; - ETextEventProcessorCommandAction action; - int value; - char *string; - guint32 time; -}; - -struct _ETextEventProcessorEventButton { - GdkEventType type; - guint32 time; - guint state; - guint button; - gint position; -}; - -struct _ETextEventProcessorEventKey { - GdkEventType type; - guint32 time; - guint state; - guint keyval; - gint length; - gchar *string; -}; - -struct _ETextEventProcessorEventMotion { - GdkEventType type; - guint32 time; - guint state; - gint position; -}; - -union _ETextEventProcessorEvent { - GdkEventType type; - ETextEventProcessorEventButton button; - ETextEventProcessorEventKey key; - ETextEventProcessorEventMotion motion; -}; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_TEXT_EVENT_PROCESSOR_TYPES_H__ */ diff --git a/widgets/e-text/e-text-event-processor.c b/widgets/e-text/e-text-event-processor.c deleted file mode 100644 index 47f028ca62..0000000000 --- a/widgets/e-text/e-text-event-processor.c +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-text-event-processor.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <gnome.h> -#include "e-text-event-processor.h" -static void e_text_event_processor_init (ETextEventProcessor *card); -static void e_text_event_processor_class_init (ETextEventProcessorClass *klass); - -static GtkObjectClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0 -}; - -enum { - E_TEP_EVENT, - E_TEP_LAST_SIGNAL -}; - -static guint e_tep_signals[E_TEP_LAST_SIGNAL] = { 0 }; - -GtkType -e_text_event_processor_get_type (void) -{ - static GtkType text_event_processor_type = 0; - - if (!text_event_processor_type) - { - static const GtkTypeInfo text_event_processor_info = - { - "ETextEventProcessor", - sizeof (ETextEventProcessor), - sizeof (ETextEventProcessorClass), - (GtkClassInitFunc) e_text_event_processor_class_init, - (GtkObjectInitFunc) e_text_event_processor_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - text_event_processor_type = gtk_type_unique (gtk_object_get_type (), &text_event_processor_info); - } - - return text_event_processor_type; -} - -static void -e_text_event_processor_class_init (ETextEventProcessorClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - parent_class = gtk_type_class (gtk_object_get_type ()); - - e_tep_signals[E_TEP_EVENT] = - gtk_signal_new ("command", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETextEventProcessorClass, command), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - - gtk_object_class_add_signals (object_class, e_tep_signals, E_TEP_LAST_SIGNAL); - - klass->event = NULL; - klass->command = NULL; -} - -static void -e_text_event_processor_init (ETextEventProcessor *tep) -{ -} - -gint -e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event) -{ - if (E_TEXT_EVENT_PROCESSOR_CLASS(GTK_OBJECT(tep)->klass)->event) { - return E_TEXT_EVENT_PROCESSOR_CLASS(GTK_OBJECT(tep)->klass)->event(tep, event); - } else { - return 0; - } -} diff --git a/widgets/e-text/e-text-event-processor.h b/widgets/e-text/e-text-event-processor.h deleted file mode 100644 index 1fc79f3f70..0000000000 --- a/widgets/e-text/e-text-event-processor.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-text-event-processor.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey <clahey@helixcode.com> - * - * This library 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 - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_TEXT_EVENT_PROCESSOR_H__ -#define __E_TEXT_EVENT_PROCESSOR_H__ - -#include <gnome.h> -#include "e-text-event-processor-types.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* ETextEventProcessor - Turns events on a text widget into commands. - * - */ - -#define E_TEXT_EVENT_PROCESSOR_TYPE (e_text_event_processor_get_type ()) -#define E_TEXT_EVENT_PROCESSOR(obj) (GTK_CHECK_CAST ((obj), E_TEXT_EVENT_PROCESSOR_TYPE, ETextEventProcessor)) -#define E_TEXT_EVENT_PROCESSOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TEXT_EVENT_PROCESSOR_TYPE, ETextEventProcessorClass)) -#define E_IS_TEXT_EVENT_PROCESSOR(obj) (GTK_CHECK_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_TYPE)) -#define E_IS_TEXT_EVENT_PROCESSOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TEXT_EVENT_PROCESSOR_TYPE)) - - -typedef struct _ETextEventProcessor ETextEventProcessor; -typedef struct _ETextEventProcessorClass ETextEventProcessorClass; - -struct _ETextEventProcessor -{ - GtkObject parent; - - /* object specific fields */ - -}; - -struct _ETextEventProcessorClass -{ - GtkObjectClass parent_class; - - /* signals */ - void (* command) (ETextEventProcessor *tep, ETextEventProcessorCommand *command); - - /* virtual functions */ - gint (* event) (ETextEventProcessor *tep, ETextEventProcessorEvent *event); -}; - - -GtkType e_text_event_processor_get_type (void); -gint e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcessorEvent *event); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_TEXT_EVENT_PROCESSOR_H__ */ diff --git a/widgets/e-text/e-text-model.c b/widgets/e-text/e-text-model.c deleted file mode 100644 index 6ca650867c..0000000000 --- a/widgets/e-text/e-text-model.c +++ /dev/null @@ -1,244 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* ETextModel - Text item model for evolution. - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Chris Lahey <clahey@umich.edu> - * - * A majority of code taken from: - * - * Text item type for GnomeCanvas widget - * - * GnomeCanvas is basically a port of the Tk toolkit's most excellent - * canvas widget. Tk is copyrighted by the Regents of the University - * of California, Sun Microsystems, and other parties. - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <federico@nuclecu.unam.mx> */ - -#include <config.h> -#include <ctype.h> -#include "e-text-model.h" - -enum { - E_TEXT_MODEL_CHANGED, - E_TEXT_MODEL_LAST_SIGNAL -}; - -static guint e_text_model_signals[E_TEXT_MODEL_LAST_SIGNAL] = { 0 }; - -static void e_text_model_class_init (ETextModelClass *class); -static void e_text_model_init (ETextModel *model); -static void e_text_model_destroy (GtkObject *object); - -static gchar *e_text_model_real_get_text(ETextModel *model); -static void e_text_model_real_set_text(ETextModel *model, gchar *text); -static void e_text_model_real_insert(ETextModel *model, gint postion, gchar *text); -static void e_text_model_real_insert_length(ETextModel *model, gint postion, gchar *text, gint length); -static void e_text_model_real_delete(ETextModel *model, gint postion, gint length); - -static GtkObject *parent_class; - - - -/** - * e_text_model_get_type: - * @void: - * - * Registers the &ETextModel class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ETextModel class. - **/ -GtkType -e_text_model_get_type (void) -{ - static GtkType model_type = 0; - - if (!model_type) { - GtkTypeInfo model_info = { - "ETextModel", - sizeof (ETextModel), - sizeof (ETextModelClass), - (GtkClassInitFunc) e_text_model_class_init, - (GtkObjectInitFunc) e_text_model_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - model_type = gtk_type_unique (gtk_object_get_type (), &model_info); - } - - return model_type; -} - -/* Class initialization function for the text item */ -static void -e_text_model_class_init (ETextModelClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) klass; - - parent_class = gtk_type_class (gtk_object_get_type ()); - - e_text_model_signals[E_TEXT_MODEL_CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETextModelClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, e_text_model_signals, E_TEXT_MODEL_LAST_SIGNAL); - - klass->changed = NULL; - klass->get_text = e_text_model_real_get_text; - klass->set_text = e_text_model_real_set_text; - klass->insert = e_text_model_real_insert; - klass->insert_length = e_text_model_real_insert_length; - klass->delete = e_text_model_real_delete; - - object_class->destroy = e_text_model_destroy; -} - -/* Object initialization function for the text item */ -static void -e_text_model_init (ETextModel *model) -{ - model->text = NULL; -} - -/* Destroy handler for the text item */ -static void -e_text_model_destroy (GtkObject *object) -{ - ETextModel *model; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_TEXT_MODEL (object)); - - model = E_TEXT_MODEL (object); - - if (model->text) - g_free (model->text); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -static gchar * -e_text_model_real_get_text(ETextModel *model) -{ - if (model->text) - return model->text; - else - return ""; -} - -static void -e_text_model_real_set_text(ETextModel *model, gchar *text) -{ - if (model->text) - g_free(model->text); - model->text = g_strdup(text); - e_text_model_changed(model); -} - -static void -e_text_model_real_insert(ETextModel *model, gint position, gchar *text) -{ - gchar *temp = g_strdup_printf("%.*s%s%s", position, model->text, text, model->text + position); - if (model->text) - g_free(model->text); - model->text = temp; - e_text_model_changed(model); -} - -static void -e_text_model_real_insert_length(ETextModel *model, gint position, gchar *text, gint length) -{ - gchar *temp = g_strdup_printf("%.*s%.*s%s", position, model->text, length, text, model->text + position); - if (model->text) - g_free(model->text); - model->text = temp; - e_text_model_changed(model); -} - -static void -e_text_model_real_delete(ETextModel *model, gint position, gint length) -{ - memmove(model->text + position, model->text + position + length, strlen(model->text + position + length) + 1); - e_text_model_changed(model); -} - -void -e_text_model_changed(ETextModel *model) -{ - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_TEXT_MODEL (model)); - - gtk_signal_emit (GTK_OBJECT (model), - e_text_model_signals [E_TEXT_MODEL_CHANGED]); -} - -gchar * -e_text_model_get_text(ETextModel *model) -{ - g_return_val_if_fail (model != NULL, NULL); - g_return_val_if_fail (E_IS_TEXT_MODEL (model), NULL); - - if ( E_TEXT_MODEL_CLASS(GTK_OBJECT(model)->klass)->get_text ) - return E_TEXT_MODEL_CLASS(GTK_OBJECT(model)->klass)->get_text(model); - else - return ""; -} - -void -e_text_model_set_text(ETextModel *model, gchar *text) -{ - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_TEXT_MODEL (model)); - - if ( E_TEXT_MODEL_CLASS(GTK_OBJECT(model)->klass)->set_text ) - E_TEXT_MODEL_CLASS(GTK_OBJECT(model)->klass)->set_text(model, text); -} - -void -e_text_model_insert(ETextModel *model, gint position, gchar *text) -{ - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_TEXT_MODEL (model)); - - if ( E_TEXT_MODEL_CLASS(GTK_OBJECT(model)->klass)->insert ) - E_TEXT_MODEL_CLASS(GTK_OBJECT(model)->klass)->insert(model, position, text); -} - -void -e_text_model_insert_length(ETextModel *model, gint position, gchar *text, gint length) -{ - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_TEXT_MODEL (model)); - - if ( E_TEXT_MODEL_CLASS(GTK_OBJECT(model)->klass)->insert_length ) - E_TEXT_MODEL_CLASS(GTK_OBJECT(model)->klass)->insert_length(model, position, text, length); -} - -void -e_text_model_delete(ETextModel *model, gint position, gint length) -{ - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_TEXT_MODEL (model)); - - if ( E_TEXT_MODEL_CLASS(GTK_OBJECT(model)->klass)->delete ) - E_TEXT_MODEL_CLASS(GTK_OBJECT(model)->klass)->delete(model, position, length); -} - -ETextModel * -e_text_model_new(void) -{ - ETextModel *model = gtk_type_new (e_text_model_get_type ()); - model->text = g_strdup(""); - return model; -} diff --git a/widgets/e-text/e-text-model.h b/widgets/e-text/e-text-model.h deleted file mode 100644 index 5b15ccb117..0000000000 --- a/widgets/e-text/e-text-model.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* ETextModel - Text item for evolution. - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Chris Lahey <clahey@umich.edu> - * - * A majority of code taken from: - * - * Text item type for GnomeCanvas widget - * - * GnomeCanvas is basically a port of the Tk toolkit's most excellent - * canvas widget. Tk is copyrighted by the Regents of the University - * of California, Sun Microsystems, and other parties. - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <federico@nuclecu.unam.mx> */ - -#ifndef E_TEXT_MODEL_H -#define E_TEXT_MODEL_H - -#include <gnome.h> - - -BEGIN_GNOME_DECLS - -#define E_TYPE_TEXT_MODEL (e_text_model_get_type ()) -#define E_TEXT_MODEL(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TEXT_MODEL, ETextModel)) -#define E_TEXT_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_TEXT_MODEL, ETextModelClass)) -#define E_IS_TEXT_MODEL(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_TEXT_MODEL)) -#define E_IS_TEXT_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_TEXT_MODEL)) - -typedef struct _ETextModel ETextModel; -typedef struct _ETextModelClass ETextModelClass; - -struct _ETextModel { - GtkObject item; - - char *text; /* Text to display */ - int length; -}; - -struct _ETextModelClass { - GtkObjectClass parent_class; - - /* Signal */ - void (* changed) (ETextModel *model); - - /* Virtual methods */ - char *(* get_text) (ETextModel *model); - void (* set_text) (ETextModel *model, gchar *text); - void (* insert) (ETextModel *model, gint position, gchar *text); - void (* insert_length) (ETextModel *model, gint position, gchar *text, gint length); - void (* delete) (ETextModel *model, gint position, gint length); -}; - - -/* Standard Gtk function */ -GtkType e_text_model_get_type (void); -ETextModel *e_text_model_new(void); - -void e_text_model_changed(ETextModel *model); -gchar *e_text_model_get_text(ETextModel *model); -void e_text_model_set_text(ETextModel *model, gchar *text); -void e_text_model_insert(ETextModel *model, gint position, gchar *text); -void e_text_model_insert_length(ETextModel *model, gint position, gchar *text, gint length); -void e_text_model_delete(ETextModel *model, gint position, gint length); - - -END_GNOME_DECLS - -#endif diff --git a/widgets/e-text/e-text-test.c b/widgets/e-text/e-text-test.c deleted file mode 100644 index 45fa1fc3d7..0000000000 --- a/widgets/e-text/e-text-test.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - ETextTest: E-Text item test program - Copyright (C)2000: Iain Holmes <ih@csd.abdn.ac.uk> - - This code is licensed under the GPL -*/ - -#include "e-text.h" -#include <gnome.h> -#include "e-util/e-canvas.h" -#include "e-util/e-unicode.h" -GnomeCanvasItem *rect; - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, GnomeCanvasItem *item) -{ - double height; - gnome_canvas_item_set( item, - "width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(item), - "height", &height, - NULL); - height = MAX(height, allocation->height); - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, height ); - gnome_canvas_item_set( rect, - "x2", (double) allocation->width, - "y2", (double) height, - NULL ); -} - -static void -reflow (GtkWidget *canvas, GnomeCanvasItem *item) -{ - double height; - gtk_object_get(GTK_OBJECT(item), - "height", &height, - NULL); - height = MAX(height, canvas->allocation.height); - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, canvas->allocation.width, height ); - gnome_canvas_item_set( rect, - "x2", (double) canvas->allocation.width, - "y2", (double) height, - NULL ); -} - -static void -quit_cb (GtkWidget *widget, - gpointer data) -{ - gtk_main_quit (); -} - -static void -change_text_cb (GtkEntry *entry, - EText *text) -{ - gchar *str; - - str = e_utf8_gtk_entry_get_text (entry); - gnome_canvas_item_set (GNOME_CANVAS_ITEM (text), - "text", str, - NULL); -} - -static void -change_font_cb (GtkEntry *entry, - EText *text) -{ - gchar *font; - - font = gtk_entry_get_text (entry); - gnome_canvas_item_set (GNOME_CANVAS_ITEM (text), - "font", font, - NULL); -} - -int -main (int argc, - char **argv) -{ - GtkWidget *window, *canvas, *scroller, *vbox, *text, *font; - GtkWidget *frame; - GnomeCanvasItem *item; - - gnome_init ("ETextTest", "0.0.1", argc, argv); - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), "EText Test"); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC (quit_cb), NULL); - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - canvas = e_canvas_new (); - gtk_widget_pop_visual (); - gtk_widget_pop_colormap (); - scroller = gtk_scrolled_window_new (NULL, NULL); - vbox = gtk_vbox_new (FALSE, 2); - - gtk_container_add (GTK_CONTAINER (window), vbox); - gtk_box_pack_start (GTK_BOX (vbox), scroller, TRUE, TRUE, 2); - gtk_container_add (GTK_CONTAINER (scroller), canvas); - - frame = gtk_frame_new ("Text"); - text = gtk_entry_new (); - gtk_entry_set_text(GTK_ENTRY(text), "Hello World! This is a really long string to test out the ellipsis stuff."); - gtk_container_add (GTK_CONTAINER (frame), text); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - - frame = gtk_frame_new ("Font"); - font = gtk_entry_new (); - gtk_entry_set_text(GTK_ENTRY(font), "fixed"); - gtk_container_add (GTK_CONTAINER (frame), font); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - - item = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)), - e_text_get_type (), - "text", "Hello World! This is a really long string to test out the ellipsis stuff.", - "font", "fixed", - "fill_color", "black", - "anchor", GTK_ANCHOR_NW, - "clip", TRUE, - "use_ellipsis", TRUE, - "editable", TRUE, - "line_wrap", TRUE, - "max_lines", 2, - "width", 150.0, - NULL); - - gtk_signal_connect (GTK_OBJECT (text), "activate", - GTK_SIGNAL_FUNC (change_text_cb), item); - gtk_signal_connect (GTK_OBJECT (font), "activate", - GTK_SIGNAL_FUNC (change_font_cb), item); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - item ); - gtk_signal_connect( GTK_OBJECT( canvas ), "reflow", - GTK_SIGNAL_FUNC( reflow ), - item ); - gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas), 0.0, 0.0, 400.0, 400.0); - gtk_widget_show_all (window); - gtk_main (); - - return 0; -} diff --git a/widgets/e-text/e-text.c b/widgets/e-text/e-text.c deleted file mode 100644 index cb064c9c40..0000000000 --- a/widgets/e-text/e-text.c +++ /dev/null @@ -1,3389 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* EText - Text item for evolution. - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Chris Lahey <clahey@umich.edu> - * - * A majority of code taken from: - * - * Text item type for GnomeCanvas widget - * - * GnomeCanvas is basically a port of the Tk toolkit's most excellent - * canvas widget. Tk is copyrighted by the Regents of the University - * of California, Sun Microsystems, and other parties. - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <federico@nuclecu.unam.mx> */ - -#include <config.h> -#include <math.h> -#include <ctype.h> -#include "e-text.h" -#include <gdk/gdkx.h> /* for BlackPixel */ -#include <libart_lgpl/art_affine.h> -#include <libart_lgpl/art_rgb.h> -#include <libart_lgpl/art_rgb_bitmap_affine.h> -#include <unicode.h> -#include <gtk/gtkinvisible.h> -#include "e-util/e-canvas.h" -#include "e-util/e-canvas-utils.h" -#include "e-util/e-unicode.h" - -#include "e-text-event-processor-emacs-like.h" - -#define BORDER_INDENT 4 - -enum { - E_TEXT_CHANGED, - E_TEXT_ACTIVATE, - E_TEXT_LAST_SIGNAL -}; - -static guint e_text_signals[E_TEXT_LAST_SIGNAL] = { 0 }; - - - -/* This defines a line of text */ -struct line { - char *text; /* Line's text, it is a pointer into the text->text string */ - int length; /* Line's length IN BYTES */ - int width; /* Line's width in pixels */ - int ellipsis_length; /* Length before adding ellipsis */ -}; - -/* Object argument IDs */ -enum { - ARG_0, - ARG_MODEL, - ARG_EVENT_PROCESSOR, - ARG_TEXT, - ARG_FONT, - ARG_FONTSET, - ARG_FONT_GDK, - ARG_ANCHOR, - ARG_JUSTIFICATION, - ARG_CLIP_WIDTH, - ARG_CLIP_HEIGHT, - ARG_CLIP, - ARG_FILL_CLIP_RECTANGLE, - ARG_X_OFFSET, - ARG_Y_OFFSET, - ARG_FILL_COLOR, - ARG_FILL_COLOR_GDK, - ARG_FILL_COLOR_RGBA, - ARG_FILL_STIPPLE, - ARG_TEXT_WIDTH, - ARG_TEXT_HEIGHT, - ARG_EDITABLE, - ARG_USE_ELLIPSIS, - ARG_ELLIPSIS, - ARG_LINE_WRAP, - ARG_BREAK_CHARACTERS, - ARG_MAX_LINES, - ARG_WIDTH, - ARG_HEIGHT, - ARG_DRAW_BORDERS, -}; - - -enum { - E_SELECTION_PRIMARY, - E_SELECTION_CLIPBOARD -}; -enum { - TARGET_STRING, - TARGET_TEXT, - TARGET_COMPOUND_TEXT -}; - -static void e_text_class_init (ETextClass *class); -static void e_text_init (EText *text); -static void e_text_destroy (GtkObject *object); -static void e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - -static void e_text_reflow (GnomeCanvasItem *item, int flags); -static void e_text_update (GnomeCanvasItem *item, double *affine, - ArtSVP *clip_path, int flags); -static void e_text_realize (GnomeCanvasItem *item); -static void e_text_unrealize (GnomeCanvasItem *item); -static void e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, - int x, int y, int width, int height); -static double e_text_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item); -static void e_text_bounds (GnomeCanvasItem *item, - double *x1, double *y1, double *x2, double *y2); -static void e_text_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf); -static gint e_text_event (GnomeCanvasItem *item, GdkEvent *event); - -static void e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data); - -static void e_text_get_selection(EText *text, GdkAtom selection, guint32 time); -static void e_text_supply_selection (EText *text, guint time, GdkAtom selection, guchar *data, gint length); - -static void e_text_text_model_changed(ETextModel *model, EText *text); - -static void _get_tep(EText *text); - -static GtkWidget *e_text_get_invisible(EText *text); -static void _selection_clear_event (GtkInvisible *invisible, - GdkEventSelection *event, - EText *text); -static void _selection_get (GtkInvisible *invisible, - GtkSelectionData *selection_data, - guint info, - guint time_stamp, - EText *text); -static void _selection_received (GtkInvisible *invisible, - GtkSelectionData *selection_data, - guint time, - EText *text); - -#if 0 -static ETextSuckFont *e_suck_font (GdkFont *font); -static void e_suck_font_free (ETextSuckFont *suckfont); -#endif - -static void e_text_free_lines(EText *text); - -static void calc_height (EText *text); -static void calc_line_widths (EText *text); -static void split_into_lines (EText *text); - -static GnomeCanvasItemClass *parent_class; -static GdkAtom clipboard_atom = GDK_NONE; - - - -/** - * e_text_get_type: - * @void: - * - * Registers the &EText class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &EText class. - **/ -GtkType -e_text_get_type (void) -{ - static GtkType text_type = 0; - - if (!text_type) { - GtkTypeInfo text_info = { - "EText", - sizeof (EText), - sizeof (ETextClass), - (GtkClassInitFunc) e_text_class_init, - (GtkObjectInitFunc) e_text_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - text_type = gtk_type_unique (gnome_canvas_item_get_type (), &text_info); - } - - return text_type; -} - -/* Class initialization function for the text item */ -static void -e_text_class_init (ETextClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass *) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (gnome_canvas_item_get_type ()); - - e_text_signals[E_TEXT_CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETextClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - e_text_signals[E_TEXT_ACTIVATE] = - gtk_signal_new ("activate", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETextClass, activate), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, e_text_signals, E_TEXT_LAST_SIGNAL); - - - gtk_object_add_arg_type ("EText::model", - GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_MODEL); - gtk_object_add_arg_type ("EText::event_processor", - GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_EVENT_PROCESSOR); - gtk_object_add_arg_type ("EText::text", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TEXT); - gtk_object_add_arg_type ("EText::font", - GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONT); - gtk_object_add_arg_type ("EText::fontset", - GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONTSET); - gtk_object_add_arg_type ("EText::font_gdk", - GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_FONT_GDK); - gtk_object_add_arg_type ("EText::anchor", - GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, ARG_ANCHOR); - gtk_object_add_arg_type ("EText::justification", - GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFICATION); - gtk_object_add_arg_type ("EText::clip_width", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_CLIP_WIDTH); - gtk_object_add_arg_type ("EText::clip_height", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_CLIP_HEIGHT); - gtk_object_add_arg_type ("EText::clip", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_CLIP); - gtk_object_add_arg_type ("EText::fill_clip_rectangle", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_FILL_CLIP_RECTANGLE); - gtk_object_add_arg_type ("EText::x_offset", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X_OFFSET); - gtk_object_add_arg_type ("EText::y_offset", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y_OFFSET); - gtk_object_add_arg_type ("EText::fill_color", - GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FILL_COLOR); - gtk_object_add_arg_type ("EText::fill_color_gdk", - GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_FILL_COLOR_GDK); - gtk_object_add_arg_type ("EText::fill_color_rgba", - GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_FILL_COLOR_RGBA); - gtk_object_add_arg_type ("EText::fill_stipple", - GTK_TYPE_GDK_WINDOW, GTK_ARG_READWRITE, ARG_FILL_STIPPLE); - gtk_object_add_arg_type ("EText::text_width", - GTK_TYPE_DOUBLE, GTK_ARG_READABLE, ARG_TEXT_WIDTH); - gtk_object_add_arg_type ("EText::text_height", - GTK_TYPE_DOUBLE, GTK_ARG_READABLE, ARG_TEXT_HEIGHT); - gtk_object_add_arg_type ("EText::editable", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE); - gtk_object_add_arg_type ("EText::use_ellipsis", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_USE_ELLIPSIS); - gtk_object_add_arg_type ("EText::ellipsis", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ELLIPSIS); - gtk_object_add_arg_type ("EText::line_wrap", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_LINE_WRAP); - gtk_object_add_arg_type ("EText::break_characters", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_BREAK_CHARACTERS); - gtk_object_add_arg_type ("EText::max_lines", - GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_MAX_LINES); - gtk_object_add_arg_type ("EText::width", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_WIDTH); - gtk_object_add_arg_type ("EText::height", - GTK_TYPE_DOUBLE, GTK_ARG_READABLE, ARG_HEIGHT); - gtk_object_add_arg_type ("EText::draw_borders", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_DRAW_BORDERS); - - if (!clipboard_atom) - clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); - - - - klass->changed = NULL; - klass->activate = NULL; - - object_class->destroy = e_text_destroy; - object_class->set_arg = e_text_set_arg; - object_class->get_arg = e_text_get_arg; - - item_class->update = e_text_update; - item_class->realize = e_text_realize; - item_class->unrealize = e_text_unrealize; - item_class->draw = e_text_draw; - item_class->point = e_text_point; - item_class->bounds = e_text_bounds; - item_class->render = e_text_render; - item_class->event = e_text_event; -} - -/* Object initialization function for the text item */ -static void -e_text_init (EText *text) -{ - text->text = NULL; - text->model = e_text_model_new(); - gtk_object_ref(GTK_OBJECT(text->model)); - gtk_object_sink(GTK_OBJECT(text->model)); - text->model_changed_signal_id = - gtk_signal_connect(GTK_OBJECT(text->model), - "changed", - GTK_SIGNAL_FUNC(e_text_text_model_changed), - text); - - text->anchor = GTK_ANCHOR_CENTER; - text->justification = GTK_JUSTIFY_LEFT; - text->clip_width = -1.0; - text->clip_height = -1.0; - text->xofs = 0.0; - text->yofs = 0.0; - - text->ellipsis = NULL; - text->use_ellipsis = FALSE; - text->ellipsis_width = 0; - - text->editable = FALSE; - text->editing = FALSE; - text->xofs_edit = 0; - text->yofs_edit = 0; - - text->selection_start = 0; - text->selection_end = 0; - text->select_by_word = FALSE; - - text->timeout_id = 0; - text->timer = NULL; - - text->lastx = 0; - text->lasty = 0; - text->last_state = 0; - - text->scroll_start = 0; - text->show_cursor = TRUE; - text->button_down = FALSE; - - text->tep = NULL; - text->tep_command_id = 0; - - text->has_selection = FALSE; - - text->invisible = NULL; - text->primary_selection = NULL; - text->primary_length = 0; - text->clipboard_selection = NULL; - text->clipboard_length = 0; - - text->pointer_in = FALSE; - text->default_cursor_shown = TRUE; - - text->line_wrap = FALSE; - text->break_characters = NULL; - text->max_lines = -1; - - text->tooltip_timeout = 0; - text->tooltip_count = 0; - - text->dbl_timeout = 0; - text->tpl_timeout = 0; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(text), e_text_reflow); -} - -/* Destroy handler for the text item */ -static void -e_text_destroy (GtkObject *object) -{ - EText *text; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_TEXT (object)); - - text = E_TEXT (object); - - if (text->model_changed_signal_id) - gtk_signal_disconnect(GTK_OBJECT(text->model), - text->model_changed_signal_id); - - if (text->model) - gtk_object_unref(GTK_OBJECT(text->model)); - - if (text->tep_command_id) - gtk_signal_disconnect(GTK_OBJECT(text->tep), - text->tep_command_id); - - if (text->tep) - gtk_object_unref (GTK_OBJECT(text->tep)); - - if (text->invisible) - gtk_object_unref (GTK_OBJECT(text->invisible)); - - if (text->lines) - g_free (text->lines); - - if (text->font) - e_font_unref (text->font); - -#if 0 - if (text->suckfont) - e_suck_font_free (text->suckfont); -#endif - - if (text->stipple) - gdk_bitmap_unref (text->stipple); - - if (text->timeout_id) { - g_source_remove(text->timeout_id); - text->timeout_id = 0; - } - - if (text->timer) { - g_timer_stop(text->timer); - g_timer_destroy(text->timer); - text->timer = NULL; - } - - if ( text->tooltip_timeout ) { - gtk_timeout_remove (text->tooltip_timeout); - text->tooltip_timeout = 0; - } - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -static void -e_text_text_model_changed (ETextModel *model, EText *text) -{ - text->text = e_text_model_get_text(model); - e_text_free_lines(text); - gtk_signal_emit (GTK_OBJECT (text), e_text_signals[E_TEXT_CHANGED]); - text->needs_split_into_lines = 1; - e_canvas_item_request_reflow (GNOME_CANVAS_ITEM(text)); -} - -static void -get_bounds_item_relative (EText *text, double *px1, double *py1, double *px2, double *py2) -{ - GnomeCanvasItem *item; - double x, y; - double clip_x, clip_y; - int old_height; - - item = GNOME_CANVAS_ITEM (text); - - x = 0; - y = 0; - - clip_x = x; - clip_y = y; - - /* Calculate text dimensions */ - - old_height = text->height; - - if (text->text && text->font) - text->height = (e_font_height (text->font)) * text->num_lines; - else - text->height = 0; - - if (old_height != text->height) - e_canvas_item_request_parent_reflow(item); - - /* Anchor text */ - - switch (text->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_W: - case GTK_ANCHOR_SW: - break; - - case GTK_ANCHOR_N: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_S: - x -= text->max_width / 2; - if ( text->clip_width >= 0) - clip_x -= text->clip_width / 2; - else - clip_x -= text->width / 2; - break; - - case GTK_ANCHOR_NE: - case GTK_ANCHOR_E: - case GTK_ANCHOR_SE: - x -= text->max_width; - if (text->clip_width >= 0) - clip_x -= text->clip_width; - else - clip_x -= text->width; - break; - } - - switch (text->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_N: - case GTK_ANCHOR_NE: - break; - - case GTK_ANCHOR_W: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_E: - y -= text->height / 2; - if ( text->clip_height >= 0 ) - clip_y -= text->clip_height / 2; - else - clip_y -= text->height / 2; - break; - - case GTK_ANCHOR_SW: - case GTK_ANCHOR_S: - case GTK_ANCHOR_SE: - y -= text->height; - if ( text->clip_height >= 0 ) - clip_y -= text->clip_height; - else - clip_y -= text->height; - break; - } - - /* Bounds */ - - if (text->clip) { - /* maybe do bbox intersection here? */ - *px1 = clip_x; - *py1 = clip_y; - if (text->clip_width >= 0) - *px2 = clip_x + text->clip_width; - else - *px2 = clip_x + text->width; - - if ( text->clip_height >= 0 ) - *py2 = clip_y + text->clip_height; - else - *py2 = clip_y + text->height; - } else { - *px1 = x; - *py1 = y; - *px2 = x + text->max_width; - *py2 = y + text->height; - } -} - -static void -get_bounds (EText *text, double *px1, double *py1, double *px2, double *py2) -{ - GnomeCanvasItem *item; - double wx, wy, clip_width; - - item = GNOME_CANVAS_ITEM (text); - - /* Get canvas pixel coordinates for text position */ - - wx = 0; - wy = 0; - gnome_canvas_item_i2w (item, &wx, &wy); - gnome_canvas_w2c (item->canvas, wx + text->xofs, wy + text->yofs, &text->cx, &text->cy); - - /* Calculate the width and heights */ - calc_height (text); - calc_line_widths (text); - - if (text->clip_width < 0) - clip_width = text->max_width; - else - clip_width = text->clip_width; - - /* Get canvas pixel coordinates for clip rectangle position */ - gnome_canvas_w2c (item->canvas, wx, wy, &text->clip_cx, &text->clip_cy); - text->clip_cwidth = clip_width * item->canvas->pixels_per_unit; - if ( text->clip_height >= 0 ) - text->clip_cheight = text->clip_height * item->canvas->pixels_per_unit; - else - text->clip_cheight = text->height * item->canvas->pixels_per_unit; - - /* Anchor text */ - - switch (text->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_W: - case GTK_ANCHOR_SW: - break; - - case GTK_ANCHOR_N: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_S: - text->cx -= text->max_width / 2; - text->clip_cx -= text->clip_cwidth / 2; - break; - - case GTK_ANCHOR_NE: - case GTK_ANCHOR_E: - case GTK_ANCHOR_SE: - text->cx -= text->max_width; - text->clip_cx -= text->clip_cwidth; - break; - } - - switch (text->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_N: - case GTK_ANCHOR_NE: - break; - - case GTK_ANCHOR_W: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_E: - text->cy -= text->height / 2; - text->clip_cy -= text->clip_cheight / 2; - break; - - case GTK_ANCHOR_SW: - case GTK_ANCHOR_S: - case GTK_ANCHOR_SE: - text->cy -= text->height; - text->clip_cy -= text->clip_cheight; - break; - } - - /* Bounds */ - - if (text->clip) { - *px1 = text->clip_cx; - *py1 = text->clip_cy; - *px2 = text->clip_cx + text->clip_cwidth; - *py2 = text->clip_cy + text->clip_cheight; - } else { - *px1 = text->cx; - *py1 = text->cy; - *px2 = text->cx + text->max_width; - *py2 = text->cy + text->height; - } -} - -static void -calc_height (EText *text) -{ - GnomeCanvasItem *item; - int old_height; - - item = GNOME_CANVAS_ITEM (text); - - /* Calculate text dimensions */ - - old_height = text->height; - - /* Make sure the text is split into lines first */ - if (text->text && text->num_lines == 0) - split_into_lines (text); - - if (text->text && text->font) - text->height = e_font_height (text->font) * text->num_lines; - else - text->height = 0; - - if (old_height != text->height) - e_canvas_item_request_parent_reflow(item); -} - -static void -calc_ellipsis (EText *text) -{ - if (text->font) - text->ellipsis_width = - e_font_utf8_text_width (text->font, E_FONT_PLAIN, - text->ellipsis ? text->ellipsis : "...", - text->ellipsis ? strlen (text->ellipsis) : 3); -} - -/* Calculates the line widths (in pixels) of the text's splitted lines */ -static void -calc_line_widths (EText *text) -{ - struct line *lines; - int i; - gdouble clip_width; - gchar *p; - - /* Make sure line has been split */ - if (text->text && text->num_lines == 0) - split_into_lines (text); - - lines = text->lines; - text->max_width = 0; - - clip_width = text->clip_width; - if (clip_width >= 0 && text->draw_borders) { - clip_width -= 6; - if (clip_width < 0) - clip_width = 0; - } - - - if (!lines) - return; - - for (i = 0; i < text->num_lines; i++) { - if (lines->length != 0) { - if (text->font) { - lines->width = e_font_utf8_text_width (text->font, E_FONT_PLAIN, - lines->text, lines->length); - lines->ellipsis_length = 0; - } else { - lines->width = 0; - } - - if (text->clip && - text->use_ellipsis && - ! text->editing && - lines->width > clip_width && - clip_width >= 0) { - if (text->font) { - lines->ellipsis_length = 0; - for (p = lines->text; p && *p && (p - lines->text) < lines->length; p = unicode_next_utf8 (p)) { - if (e_font_utf8_text_width (text->font, E_FONT_PLAIN, lines->text, p - lines->text) + - text->ellipsis_width <= clip_width) - lines->ellipsis_length = p - lines->text; - else - break; - } - } - else - lines->ellipsis_length = 0; - lines->width = e_font_utf8_text_width (text->font, E_FONT_PLAIN, lines->text, lines->ellipsis_length) + - text->ellipsis_width; - } - else - lines->ellipsis_length = lines->length; - - if (lines->width > text->max_width) - text->max_width = lines->width; - } - - lines++; - } -} - -static void -e_text_free_lines(EText *text) -{ - if (text->lines) - g_free (text->lines); - - text->lines = NULL; - text->num_lines = 0; -} - -#define IS_BREAKCHAR(text,c) ((text)->break_characters && unicode_strchr ((text)->break_characters, (c))) -/* Splits the text of the text item into lines */ -static void -split_into_lines (EText *text) -{ - char *p, *cp; - struct line *lines; - int len; - int line_num; - char *laststart; - char *lastend; - char *linestart; - double clip_width; - unicode_char_t unival; - - /* Free old array of lines */ - e_text_free_lines(text); - - if (!text->text) - return; - - /* First, count the number of lines */ - - lastend = text->text; - laststart = text->text; - linestart = text->text; - - clip_width = text->clip_width; - if (clip_width >= 0 && text->draw_borders) { - clip_width -= 6; - if (clip_width < 0) - clip_width = 0; - } - - cp = text->text; - - for (p = unicode_get_utf8 (cp, &unival); (unival && p); cp = p, p = unicode_get_utf8 (p, &unival)) { - if (text->line_wrap && (unicode_isspace (unival) || unival == '\n')) { - if (laststart != lastend - && e_font_utf8_text_width(text->font, E_FONT_PLAIN, linestart, cp - linestart) - > clip_width ) { - text->num_lines ++; - linestart = laststart; - laststart = p; - lastend = cp; - } else if (unicode_isspace (unival)) { - laststart = p; - lastend = cp; - } - } else if (text->line_wrap && (IS_BREAKCHAR(text, unival))) { - if (laststart != lastend - && unicode_index_to_offset (linestart, cp - linestart) != 1 - && e_font_utf8_text_width(text->font, E_FONT_PLAIN, linestart, p - linestart) - > clip_width ) { - text->num_lines ++; - linestart = laststart; - laststart = p; - lastend = p; - } else { - laststart = p; - lastend = p; - } - } - if (unival == '\n') { - text->num_lines ++; - lastend = p; - laststart = p; - linestart = p; - } - } - - /* fixme: */ - if (text->line_wrap) { - if ( p - && laststart != lastend - && e_font_utf8_text_width(text->font, E_FONT_PLAIN, linestart, cp - linestart) - > clip_width ) { - text->num_lines ++; - } - } - - text->num_lines++; - - if ( (!text->editing) && text->max_lines != -1 && text->num_lines > text->max_lines ) { - text->num_lines = text->max_lines; - } - - /* Allocate array of lines and calculate split positions */ - - text->lines = lines = g_new0 (struct line, text->num_lines); - len = 0; - line_num = 1; - lastend = text->text; - laststart = text->text; - - cp = text->text; - for (p = unicode_get_utf8 (cp, &unival); p && unival && line_num < text->num_lines; cp = p, p = unicode_get_utf8 (p, &unival)) { - gboolean handled = FALSE; - if (len == 0) - lines->text = cp; - if (text->line_wrap && (unicode_isspace (unival) || unival == '\n')) { - if (e_font_utf8_text_width (text->font, E_FONT_PLAIN, lines->text, cp - lines->text) - > clip_width - && laststart != lastend) { - lines->length = lastend - lines->text; - lines++; - line_num++; - len = cp - laststart; - lines->text = laststart; - laststart = p; - lastend = cp; - } else if (unicode_isspace (unival)) { - laststart = p; - lastend = cp; - len ++; - } - handled = TRUE; - } else if (text->line_wrap && (IS_BREAKCHAR(text, unival))) { - if (laststart != lastend - && unicode_index_to_offset (lines->text, cp - lines->text) != 1 - && e_font_utf8_text_width (text->font, E_FONT_PLAIN, lines->text, p - lines->text) - > clip_width ) { - lines->length = lastend - lines->text; - lines++; - line_num++; - len = p - laststart; - lines->text = laststart; - laststart = p; - lastend = p; - } else { - laststart = p; - lastend = p; - len ++; - } - } - if (line_num >= text->num_lines) - break; - if (unival == '\n') { - lines->length = cp - lines->text; - lines++; - line_num++; - len = 0; - lastend = p; - laststart = p; - handled = TRUE; - } - if (!handled) - len++; - } - - if ( line_num < text->num_lines && text->line_wrap ) { - if (e_font_utf8_text_width(text->font, E_FONT_PLAIN, lines->text, cp - lines->text) - > clip_width - && laststart != lastend ) { - lines->length = lastend - lines->text; - lines++; - line_num++; - len = cp - laststart; - lines->text = laststart; - laststart = p; - lastend = cp; - } - } - - if (len == 0) - lines->text = cp; - lines->length = strlen (lines->text); -} - -/* Convenience function to set the text's GC's foreground color */ -static void -set_text_gc_foreground (EText *text) -{ - GdkColor c; - - if (!text->gc) - return; - - c.pixel = text->pixel; - gdk_gc_set_foreground (text->gc, &c); -} - -/* Sets the stipple pattern for the text */ -static void -set_stipple (EText *text, GdkBitmap *stipple, int reconfigure) -{ - if (text->stipple && !reconfigure) - gdk_bitmap_unref (text->stipple); - - text->stipple = stipple; - if (stipple && !reconfigure) - gdk_bitmap_ref (stipple); - - if (text->gc) { - if (stipple) { - gdk_gc_set_stipple (text->gc, stipple); - gdk_gc_set_fill (text->gc, GDK_STIPPLED); - } else - gdk_gc_set_fill (text->gc, GDK_SOLID); - } -} - -/* Set_arg handler for the text item */ -static void -e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EText *text; - GdkColor color = { 0, 0, 0, 0, }; - GdkColor *pcolor; - gboolean color_changed; - int have_pixel; - - gboolean needs_update = 0; - gboolean needs_reflow = 0; - - item = GNOME_CANVAS_ITEM (object); - text = E_TEXT (object); - - color_changed = FALSE; - have_pixel = FALSE; - - switch (arg_id) { - case ARG_MODEL: - if ( text->model_changed_signal_id ) - gtk_signal_disconnect(GTK_OBJECT(text->model), - text->model_changed_signal_id); - gtk_object_unref(GTK_OBJECT(text->model)); - text->model = E_TEXT_MODEL(GTK_VALUE_OBJECT (*arg)); - gtk_object_ref(GTK_OBJECT(text->model)); - - text->model_changed_signal_id = - gtk_signal_connect(GTK_OBJECT(text->model), - "changed", - GTK_SIGNAL_FUNC(e_text_text_model_changed), - text); - - e_text_free_lines(text); - text->text = e_text_model_get_text(text->model); - - text->needs_split_into_lines = 1; - needs_reflow = 1; - break; - - case ARG_EVENT_PROCESSOR: - if ( text->tep && text->tep_command_id ) - gtk_signal_disconnect(GTK_OBJECT(text->tep), - text->tep_command_id); - if ( text->tep ) - gtk_object_unref(GTK_OBJECT(text->tep)); - text->tep = E_TEXT_EVENT_PROCESSOR(GTK_VALUE_OBJECT (*arg)); - gtk_object_ref(GTK_OBJECT(text->tep)); - text->tep_command_id = - gtk_signal_connect(GTK_OBJECT(text->tep), - "command", - GTK_SIGNAL_FUNC(e_text_command), - text); - break; - - case ARG_TEXT: - text->num_lines = 1; - e_text_model_set_text(text->model, GTK_VALUE_STRING (*arg)); - break; - - case ARG_FONT: - if (text->font) - e_font_unref (text->font); - - text->font = e_font_from_gdk_name (GTK_VALUE_STRING (*arg)); - -#if 0 - if (item->canvas->aa) { - if (text->suckfont) - e_suck_font_free (text->suckfont); - - text->suckfont = e_suck_font (text->font); - } -#endif - - calc_ellipsis (text); - if ( text->line_wrap ) - text->needs_split_into_lines = 1; - else - text->needs_calc_line_widths = 1; - needs_reflow = 1; - break; - - case ARG_FONTSET: - if (text->font) - e_font_unref (text->font); - - text->font = e_font_from_gdk_name (GTK_VALUE_STRING (*arg)); - -#if 0 - if (item->canvas->aa) { - if (text->suckfont) - e_suck_font_free (text->suckfont); - - text->suckfont = e_suck_font (text->font); - } -#endif - - calc_ellipsis (text); - if ( text->line_wrap ) - text->needs_split_into_lines = 1; - else - text->needs_calc_line_widths = 1; - needs_reflow = 1; - break; - - case ARG_FONT_GDK: - if (text->font) - e_font_unref (text->font); - - text->font = e_font_from_gdk_font (GTK_VALUE_BOXED (*arg)); - -#if 0 - if (item->canvas->aa) { - if (text->suckfont) - e_suck_font_free (text->suckfont); - - text->suckfont = e_suck_font (text->font); - } -#endif - - calc_ellipsis (text); - if ( text->line_wrap ) - text->needs_split_into_lines = 1; - else - text->needs_calc_line_widths = 1; - needs_reflow = 1; - break; - - case ARG_ANCHOR: - text->anchor = GTK_VALUE_ENUM (*arg); - text->needs_recalc_bounds = 1; - needs_update = 1; - break; - - case ARG_JUSTIFICATION: - text->justification = GTK_VALUE_ENUM (*arg); - text->needs_redraw = 1; - needs_update = 1; - break; - - case ARG_CLIP_WIDTH: - text->clip_width = fabs (GTK_VALUE_DOUBLE (*arg)); - calc_ellipsis (text); - if ( text->line_wrap ) - text->needs_split_into_lines = 1; - else - text->needs_calc_line_widths = 1; - needs_reflow = 1; - break; - - case ARG_CLIP_HEIGHT: - text->clip_height = fabs (GTK_VALUE_DOUBLE (*arg)); - text->needs_recalc_bounds = 1; - needs_reflow = 1; - break; - - case ARG_CLIP: - text->clip = GTK_VALUE_BOOL (*arg); - calc_ellipsis (text); - if ( text->line_wrap ) - text->needs_split_into_lines = 1; - else - text->needs_calc_line_widths = 1; - needs_reflow = 1; - break; - - case ARG_FILL_CLIP_RECTANGLE: - text->fill_clip_rectangle = GTK_VALUE_BOOL (*arg); - needs_update = 1; - break; - - case ARG_X_OFFSET: - text->xofs = GTK_VALUE_DOUBLE (*arg); - text->needs_recalc_bounds = 1; - needs_update = 1; - break; - - case ARG_Y_OFFSET: - text->yofs = GTK_VALUE_DOUBLE (*arg); - text->needs_recalc_bounds = 1; - needs_update = 1; - break; - - case ARG_FILL_COLOR: - if (GTK_VALUE_STRING (*arg)) - gdk_color_parse (GTK_VALUE_STRING (*arg), &color); - - text->rgba = ((color.red & 0xff00) << 16 | - (color.green & 0xff00) << 8 | - (color.blue & 0xff00) | - 0xff); - color_changed = TRUE; - text->needs_redraw = 1; - needs_update = 1; - break; - - case ARG_FILL_COLOR_GDK: - pcolor = GTK_VALUE_BOXED (*arg); - if (pcolor) { - color = *pcolor; - gdk_color_context_query_color (item->canvas->cc, &color); - have_pixel = TRUE; - } - - text->rgba = ((color.red & 0xff00) << 16 | - (color.green & 0xff00) << 8 | - (color.blue & 0xff00) | - 0xff); - color_changed = TRUE; - text->needs_redraw = 1; - needs_update = 1; - break; - - case ARG_FILL_COLOR_RGBA: - text->rgba = GTK_VALUE_UINT (*arg); - color_changed = TRUE; - text->needs_redraw = 1; - needs_update = 1; - break; - - case ARG_FILL_STIPPLE: - set_stipple (text, GTK_VALUE_BOXED (*arg), FALSE); - text->needs_redraw = 1; - needs_update = 1; - break; - - case ARG_EDITABLE: - text->editable = GTK_VALUE_BOOL (*arg); - text->needs_redraw = 1; - needs_update = 1; - break; - - case ARG_USE_ELLIPSIS: - text->use_ellipsis = GTK_VALUE_BOOL (*arg); - text->needs_calc_line_widths = 1; - needs_reflow = 1; - break; - - case ARG_ELLIPSIS: - if (text->ellipsis) - g_free (text->ellipsis); - - text->ellipsis = g_strdup (GTK_VALUE_STRING (*arg)); - calc_ellipsis (text); - text->needs_calc_line_widths = 1; - needs_reflow = 1; - break; - - case ARG_LINE_WRAP: - text->line_wrap = GTK_VALUE_BOOL (*arg); - text->needs_split_into_lines = 1; - needs_reflow = 1; - break; - - case ARG_BREAK_CHARACTERS: - if ( text->break_characters ) { - g_free(text->break_characters); - text->break_characters = NULL; - } - if ( GTK_VALUE_STRING (*arg) ) - text->break_characters = g_strdup( GTK_VALUE_STRING (*arg) ); - text->needs_split_into_lines = 1; - needs_reflow = 1; - break; - - case ARG_MAX_LINES: - text->max_lines = GTK_VALUE_INT (*arg); - text->needs_split_into_lines = 1; - needs_reflow = 1; - break; - - case ARG_WIDTH: - text->clip_width = fabs (GTK_VALUE_DOUBLE (*arg)); - calc_ellipsis (text); - if ( text->line_wrap ) - text->needs_split_into_lines = 1; - else - text->needs_calc_line_widths = 1; - needs_reflow = 1; - break; - - case ARG_DRAW_BORDERS: - if (text->draw_borders != GTK_VALUE_BOOL (*arg)) { - text->draw_borders = GTK_VALUE_BOOL (*arg); - text->needs_calc_height = 1; - text->needs_redraw = 1; - needs_reflow = 1; - needs_update = 1; - } - break; - - default: - return; - } - - if (color_changed) { - if (have_pixel) - text->pixel = color.pixel; - else - text->pixel = gnome_canvas_get_color_pixel (item->canvas, text->rgba); - - if (!item->canvas->aa) - set_text_gc_foreground (text); - - } - - if ( needs_reflow ) - e_canvas_item_request_reflow (item); - if ( needs_update ) - gnome_canvas_item_request_update (item); -} - -/* Get_arg handler for the text item */ -static void -e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EText *text; - GdkColor *color; - - text = E_TEXT (object); - - switch (arg_id) { - case ARG_MODEL: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(text->model); - break; - - case ARG_EVENT_PROCESSOR: - _get_tep(text); - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(text->tep); - break; - - case ARG_TEXT: - GTK_VALUE_STRING (*arg) = g_strdup (text->text); - break; - - /* fixme: */ - case ARG_FONT_GDK: - GTK_VALUE_BOXED (*arg) = text->font; - break; - - case ARG_ANCHOR: - GTK_VALUE_ENUM (*arg) = text->anchor; - break; - - case ARG_JUSTIFICATION: - GTK_VALUE_ENUM (*arg) = text->justification; - break; - - case ARG_CLIP_WIDTH: - GTK_VALUE_DOUBLE (*arg) = text->clip_width; - break; - - case ARG_CLIP_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = text->clip_height; - break; - - case ARG_CLIP: - GTK_VALUE_BOOL (*arg) = text->clip; - break; - - case ARG_FILL_CLIP_RECTANGLE: - GTK_VALUE_BOOL (*arg) = text->fill_clip_rectangle; - break; - - case ARG_X_OFFSET: - GTK_VALUE_DOUBLE (*arg) = text->xofs; - break; - - case ARG_Y_OFFSET: - GTK_VALUE_DOUBLE (*arg) = text->yofs; - break; - - case ARG_FILL_COLOR_GDK: - color = g_new (GdkColor, 1); - color->pixel = text->pixel; - gdk_color_context_query_color (text->item.canvas->cc, color); - GTK_VALUE_BOXED (*arg) = color; - break; - - case ARG_FILL_COLOR_RGBA: - GTK_VALUE_UINT (*arg) = text->rgba; - break; - - case ARG_FILL_STIPPLE: - GTK_VALUE_BOXED (*arg) = text->stipple; - break; - - case ARG_TEXT_WIDTH: - GTK_VALUE_DOUBLE (*arg) = text->max_width / text->item.canvas->pixels_per_unit; - break; - - case ARG_TEXT_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = text->height / text->item.canvas->pixels_per_unit; - break; - - case ARG_EDITABLE: - GTK_VALUE_BOOL (*arg) = text->editable; - break; - - case ARG_USE_ELLIPSIS: - GTK_VALUE_BOOL (*arg) = text->use_ellipsis; - break; - - case ARG_ELLIPSIS: - GTK_VALUE_STRING (*arg) = g_strdup (text->ellipsis); - break; - - case ARG_LINE_WRAP: - GTK_VALUE_BOOL (*arg) = text->line_wrap; - break; - - case ARG_BREAK_CHARACTERS: - GTK_VALUE_STRING (*arg) = g_strdup (text->break_characters); - break; - - case ARG_MAX_LINES: - GTK_VALUE_INT (*arg) = text->max_lines; - break; - - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = text->clip_width; - break; - - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = text->clip && text->clip_height != -1 ? text->clip_height : text->height / text->item.canvas->pixels_per_unit; - break; - - case ARG_DRAW_BORDERS: - GTK_VALUE_BOOL (*arg) = text->draw_borders; - break; - - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -/* Update handler for the text item */ -static void -e_text_reflow (GnomeCanvasItem *item, int flags) -{ - EText *text; - - text = E_TEXT (item); - - if ( text->needs_split_into_lines ) { - split_into_lines(text); - text->needs_split_into_lines = 0; - text->needs_calc_line_widths = 1; - } - if ( text->needs_calc_line_widths ) { - int x; - int i; - struct line *lines; - gdouble clip_width; - calc_line_widths(text); - text->needs_calc_line_widths = 0; - text->needs_calc_height = 1; - text->needs_redraw = 1; - - lines = text->lines; - if ( !lines ) - return; - - for (lines = text->lines, i = 0; i < text->num_lines ; i++, lines ++) { - if ((lines->text - text->text) > text->selection_end) { - break; - } - } - lines --; - i--; - x = e_font_utf8_text_width(text->font, E_FONT_PLAIN, - lines->text, - text->selection_end - (lines->text - text->text)); - - - if (x < text->xofs_edit) { - text->xofs_edit = x; - } - - clip_width = text->clip_width; - if (clip_width >= 0 && text->draw_borders) { - clip_width -= 6; - if (clip_width < 0) - clip_width = 0; - } - - if (2 + x - clip_width > text->xofs_edit) { - text->xofs_edit = 2 + x - clip_width; - } - - if (e_font_height (text->font) * i < text->yofs_edit) - text->yofs_edit = e_font_height (text->font) * i; - - if (e_font_height (text->font) * (i + 1) - - (text->clip_height != -1 ? text->clip_height : text->height) > text->yofs_edit) - text->yofs_edit = e_font_height (text->font) * (i + 1) - - (text->clip_height != -1 ? text->clip_height : text->height); - } - if ( text->needs_calc_height ) { - calc_height (text); - gnome_canvas_item_request_update(item); - text->needs_calc_height = 0; - text->needs_recalc_bounds = 1; - } -} - -/* Update handler for the text item */ -static void -e_text_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) -{ - EText *text; - double x1, y1, x2, y2; - ArtDRect i_bbox, c_bbox; - int i; - - text = E_TEXT (item); - - if (parent_class->update) - (* parent_class->update) (item, affine, clip_path, flags); - - if ( text->needs_recalc_bounds - || (flags & GNOME_CANVAS_UPDATE_AFFINE)) { - if (!item->canvas->aa) { - set_text_gc_foreground (text); - set_stipple (text, text->stipple, TRUE); - get_bounds (text, &x1, &y1, &x2, &y2); - if ( item->x1 != x1 || - item->x2 != x2 || - item->y1 != y1 || - item->y2 != y2 ) { - gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2); - item->x1 = x1; - item->y1 = y1; - item->x2 = x2; - item->y2 = y2; - text->needs_redraw = 1; - } - } else { - /* aa rendering */ - for (i = 0; i < 6; i++) - text->affine[i] = affine[i]; - get_bounds_item_relative (text, &i_bbox.x0, &i_bbox.y0, &i_bbox.x1, &i_bbox.y1); - art_drect_affine_transform (&c_bbox, &i_bbox, affine); - } - text->needs_recalc_bounds = 0; - } - if ( text->needs_redraw ) { - gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2); - text->needs_redraw = 0; - } -} - -/* Realize handler for the text item */ -static void -e_text_realize (GnomeCanvasItem *item) -{ - EText *text; - - text = E_TEXT (item); - - if (parent_class->realize) - (* parent_class->realize) (item); - - text->gc = gdk_gc_new (item->canvas->layout.bin_window); - - text->i_cursor = gdk_cursor_new (GDK_XTERM); - text->default_cursor = gdk_cursor_new (GDK_LEFT_PTR); - if (text->font == NULL) { - text->font = e_font_from_gdk_font (GTK_WIDGET(item->canvas)->style->font); - } -} - -/* Unrealize handler for the text item */ -static void -e_text_unrealize (GnomeCanvasItem *item) -{ - EText *text; - - text = E_TEXT (item); - - gdk_gc_unref (text->gc); - text->gc = NULL; - - gdk_cursor_destroy (text->i_cursor); - gdk_cursor_destroy (text->default_cursor); - - if (parent_class->unrealize) - (* parent_class->unrealize) (item); -} - -/* Calculates the x position of the specified line of text, based on the text's justification */ -static double -get_line_xpos_item_relative (EText *text, struct line *line) -{ - double x; - - x = 0; - - switch (text->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_W: - case GTK_ANCHOR_SW: - break; - - case GTK_ANCHOR_N: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_S: - x -= text->max_width / 2; - break; - - case GTK_ANCHOR_NE: - case GTK_ANCHOR_E: - case GTK_ANCHOR_SE: - x -= text->max_width; - break; - } - - switch (text->justification) { - case GTK_JUSTIFY_RIGHT: - x += text->max_width - line->width; - break; - - case GTK_JUSTIFY_CENTER: - x += (text->max_width - line->width) * 0.5; - break; - - default: - if (text->draw_borders) - x += BORDER_INDENT; - - /* For GTK_JUSTIFY_LEFT, we don't have to do anything. We do not support - * GTK_JUSTIFY_FILL, yet. - */ - break; - } - - return x; -} - -#if 0 -/* Calculates the y position of the first line of text. */ -static double -get_line_ypos_item_relative (EText *text) -{ - double y; - - y = 0; - - switch (text->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_N: - case GTK_ANCHOR_NE: - break; - - case GTK_ANCHOR_W: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_E: - y -= text->height / 2; - break; - - case GTK_ANCHOR_SW: - case GTK_ANCHOR_S: - case GTK_ANCHOR_SE: - y -= text->height; - break; - } - - return y; -} -#endif - -/* Calculates the x position of the specified line of text, based on the text's justification */ -static int -get_line_xpos (EText *text, struct line *line) -{ - int x; - - x = text->cx; - - switch (text->justification) { - case GTK_JUSTIFY_RIGHT: - x += text->max_width - line->width; - break; - - case GTK_JUSTIFY_CENTER: - x += (text->max_width - line->width) / 2; - break; - - default: - if (text->draw_borders) - x += BORDER_INDENT; - /* For GTK_JUSTIFY_LEFT, we don't have to do anything. We do not support - * GTK_JUSTIFY_FILL, yet. - */ - break; - } - - - return x; -} - -static void -_get_tep(EText *text) -{ - if (!text->tep) { - text->tep = e_text_event_processor_emacs_like_new(); - gtk_object_ref (GTK_OBJECT (text->tep)); - gtk_object_sink (GTK_OBJECT (text->tep)); - text->tep_command_id = - gtk_signal_connect(GTK_OBJECT(text->tep), - "command", - GTK_SIGNAL_FUNC(e_text_command), - (gpointer) text); - } -} - -/* Draw handler for the text item */ -static void -e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, - int x, int y, int width, int height) -{ - EText *text; - GdkRectangle rect, *clip_rect; - struct line *lines; - int i; - int xpos, ypos; - int start_char, end_char; - int sel_start, sel_end; - GdkRectangle sel_rect; - GdkGC *fg_gc; - GnomeCanvas *canvas; - - text = E_TEXT (item); - canvas = GNOME_CANVAS_ITEM(text)->canvas; - - fg_gc = GTK_WIDGET(canvas)->style->fg_gc[text->has_selection ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE]; - - if (text->draw_borders) { - gdouble thisx = 0, thisy = 0; - gdouble thiswidth, thisheight; - GtkWidget *widget = GTK_WIDGET(item->canvas); - - gtk_object_get(GTK_OBJECT(text), - "width", &thiswidth, - "height", &thisheight, - NULL); - gtk_paint_flat_box (widget->style, drawable, - GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE, - NULL, widget, "entry_bg", - 0, 0, thiswidth, thisheight); - if (text->editing) { - thisx += 1; - thisy += 1; - thiswidth -= 2; - thisheight -= 2; - } - gtk_paint_shadow (widget->style, drawable, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - NULL, widget, "entry", - thisx - x, thisy - y, thiswidth, thisheight); - - if (text->editing) { - gtk_paint_focus (widget->style, drawable, - NULL, widget, "entry", - - x, - y, thiswidth + 1, thisheight + 1); - } - } - - if (!text->text || !text->font) - return; - - lines = text->lines; - if ( !lines ) { - text->needs_split_into_lines = 1; - e_canvas_item_request_reflow (item); - } - - clip_rect = NULL; - if (text->clip) { - rect.x = text->clip_cx - x; - rect.y = text->clip_cy - y; - rect.width = text->clip_cwidth; - rect.height = text->clip_cheight; - - gdk_gc_set_clip_rectangle (text->gc, &rect); - gdk_gc_set_clip_rectangle (fg_gc, &rect); - clip_rect = ▭ - } - ypos = text->cy + e_font_ascent (text->font); - if (text->draw_borders) - ypos += BORDER_INDENT; - - if (text->editing) - ypos -= text->yofs_edit; - - if (text->stipple) - gnome_canvas_set_stipple_origin (item->canvas, text->gc); - - for (i = 0; i < text->num_lines; i++) { - xpos = get_line_xpos (text, lines); - if (text->editing) { - xpos -= text->xofs_edit; - start_char = lines->text - text->text; - end_char = start_char + lines->length; - sel_start = text->selection_start; - sel_end = text->selection_end; - if (sel_start > sel_end ) { - sel_start ^= sel_end; - sel_end ^= sel_start; - sel_start ^= sel_end; - } - if ( sel_start < start_char ) - sel_start = start_char; - if ( sel_end > end_char ) - sel_end = end_char; - if ( sel_start < sel_end ) { - sel_rect.x = xpos - x + e_font_utf8_text_width (text->font, E_FONT_PLAIN, - lines->text, - sel_start - start_char); - sel_rect.y = ypos - y - e_font_ascent (text->font); - sel_rect.width = e_font_utf8_text_width (text->font, E_FONT_PLAIN, - lines->text + sel_start - start_char, - sel_end - sel_start); - sel_rect.height = e_font_height (text->font); - gtk_paint_flat_box(GTK_WIDGET(item->canvas)->style, - drawable, - text->has_selection ? - GTK_STATE_SELECTED : - GTK_STATE_ACTIVE, - GTK_SHADOW_NONE, - clip_rect, - GTK_WIDGET(item->canvas), - "text", - sel_rect.x, - sel_rect.y, - sel_rect.width, - sel_rect.height); - e_font_draw_utf8_text (drawable, - text->font, E_FONT_PLAIN, - text->gc, - xpos - x, - ypos - y, - lines->text, - sel_start - start_char); - e_font_draw_utf8_text (drawable, - text->font, E_FONT_PLAIN, - fg_gc, - xpos - x + e_font_utf8_text_width (text->font, E_FONT_PLAIN, - lines->text, - sel_start - start_char), - ypos - y, - lines->text + sel_start - start_char, - sel_end - sel_start); - e_font_draw_utf8_text (drawable, - text->font, E_FONT_PLAIN, - text->gc, - xpos - x + e_font_utf8_text_width (text->font, E_FONT_PLAIN, - lines->text, - sel_end - start_char), - ypos - y, - lines->text + sel_end - start_char, - end_char - sel_end); - } else { - e_font_draw_utf8_text (drawable, - text->font, E_FONT_PLAIN, - text->gc, - xpos - x, - ypos - y, - lines->text, - lines->length); - } - if (text->selection_start == text->selection_end && - text->selection_start >= start_char && - text->selection_start <= end_char && - text->show_cursor) { - gdk_draw_rectangle (drawable, - text->gc, - TRUE, - xpos - x + e_font_utf8_text_width (text->font, E_FONT_PLAIN, - lines->text, - sel_start - start_char), - ypos - y - e_font_ascent (text->font), - 1, - e_font_height (text->font)); - } - } else { - if (text->clip && text->use_ellipsis && lines->ellipsis_length < lines->length) { - e_font_draw_utf8_text (drawable, - text->font, E_FONT_PLAIN, - text->gc, - xpos - x, - ypos - y, - lines->text, - lines->ellipsis_length); - e_font_draw_utf8_text (drawable, - text->font, E_FONT_PLAIN, - text->gc, - xpos - x + lines->width - text->ellipsis_width, - ypos - y, - text->ellipsis ? text->ellipsis : "...", - text->ellipsis ? strlen (text->ellipsis) : 3); - } else - e_font_draw_utf8_text (drawable, - text->font, E_FONT_PLAIN, - text->gc, - xpos - x, - ypos - y, - lines->text, - lines->length); - } - - ypos += e_font_height (text->font); - lines++; - } - - if (text->clip) { - gdk_gc_set_clip_rectangle (text->gc, NULL); - gdk_gc_set_clip_rectangle (fg_gc, NULL); - } -} - -/* Render handler for the text item */ -static void -e_text_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf) -{ -#if 0 - EText *text; - guint32 fg_color; - double xpos, ypos; - struct line *lines; - int i, j; - double affine[6]; - int dx, dy; - ArtPoint start_i, start_c; - - text = E_TEXT (item); - - if (!text->text || !text->font || !text->suckfont) - return; - - suckfont = text->suckfont; - - fg_color = text->rgba; - - gnome_canvas_buf_ensure_buf (buf); - - lines = text->lines; - if ( !lines ) - return; - - start_i.y = get_line_ypos_item_relative (text); - - art_affine_scale (affine, item->canvas->pixels_per_unit, item->canvas->pixels_per_unit); - for (i = 0; i < 6; i++) - affine[i] = text->affine[i]; - - for (i = 0; i < text->num_lines; i++) { - if (lines->length != 0) { - start_i.x = get_line_xpos_item_relative (text, lines); - art_affine_point (&start_c, &start_i, text->affine); - xpos = start_c.x; - ypos = start_c.y; - - for (j = 0; j < lines->length; j++) { - ETextSuckChar *ch; - - ch = &suckfont->chars[(unsigned char)((lines->text)[j])]; - - affine[4] = xpos; - affine[5] = ypos; - art_rgb_bitmap_affine ( - buf->buf, - buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1, - buf->buf_rowstride, - suckfont->bitmap + (ch->bitmap_offset >> 3), - ch->width, - suckfont->bitmap_height, - suckfont->bitmap_width >> 3, - fg_color, - affine, - ART_FILTER_NEAREST, NULL); - - dx = ch->left_sb + ch->width + ch->right_sb; - xpos += dx * affine[0]; - ypos += dx * affine[1]; - } - } - - dy = text->font->ascent + text->font->descent; - start_i.y += dy; - lines++; - } - - buf->is_bg = 0; -#endif -} - -/* Point handler for the text item */ -static double -e_text_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, GnomeCanvasItem **actual_item) -{ - EText *text; - int i; - struct line *lines; - int x1, y1, x2, y2; - int font_height; - int dx, dy; - double dist, best; - - text = E_TEXT (item); - - *actual_item = item; - - /* The idea is to build bounding rectangles for each of the lines of - * text (clipped by the clipping rectangle, if it is activated) and see - * whether the point is inside any of these. If it is, we are done. - * Otherwise, calculate the distance to the nearest rectangle. - */ - - if (text->font) - font_height = e_font_height (text->font); - else - font_height = 0; - - best = 1.0e36; - - lines = text->lines; - - if (text->fill_clip_rectangle) { - double clip_width; - double clip_height; - - /* Calculate the width and heights */ - calc_height (text); - calc_line_widths (text); - - if (text->clip_width < 0) - clip_width = text->max_width; - else - clip_width = text->clip_width; - - /* Get canvas pixel coordinates for clip rectangle position */ - clip_width = clip_width * item->canvas->pixels_per_unit; - if ( text->clip_height >= 0 ) - clip_height = text->clip_height * item->canvas->pixels_per_unit; - else - clip_height = text->height * item->canvas->pixels_per_unit; - - if (cx >= text->clip_cx && - cx <= text->clip_cx + clip_width && - cy >= text->clip_cy && - cy <= text->clip_cy + clip_height) - return 0; - else - return 1; - } - - for (i = 0; i < text->num_lines; i++) { - /* Compute the coordinates of rectangle for the current line, - * clipping if appropriate. - */ - - x1 = get_line_xpos (text, lines); - y1 = text->cy + i * font_height; - x2 = x1 + lines->width; - y2 = y1 + font_height; - - if (text->clip) { - if (x1 < text->clip_cx) - x1 = text->clip_cx; - - if (y1 < text->clip_cy) - y1 = text->clip_cy; - - if ( text->clip_width >= 0 ) { - if (x2 > (text->clip_cx + text->clip_width)) - x2 = text->clip_cx + text->clip_width; - } - - if ( text->clip_height >= 0 ) { - if (y2 > (text->clip_cy + text->clip_height)) - y2 = text->clip_cy + text->clip_height; - } - - if ((x1 >= x2) || (y1 >= y2)) - continue; - } - - /* Calculate distance from point to rectangle */ - - if (cx < x1) - dx = x1 - cx; - else if (cx >= x2) - dx = cx - x2 + 1; - else - dx = 0; - - if (cy < y1) - dy = y1 - cy; - else if (cy >= y2) - dy = cy - y2 + 1; - else - dy = 0; - - if ((dx == 0) && (dy == 0)) - return 0.0; - - dist = sqrt (dx * dx + dy * dy); - if (dist < best) - best = dist; - - /* Next! */ - - lines++; - } - - return best / item->canvas->pixels_per_unit; -} - -/* Bounds handler for the text item */ -static void -e_text_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2) -{ - EText *text; - double width, height; - - text = E_TEXT (item); - - *x1 = 0; - *y1 = 0; - - if (text->clip) { - width = text->clip_width; - if ( text->clip_height >= 0 ) - height = text->clip_height; - else height = text->height; - } else { - width = text->max_width / item->canvas->pixels_per_unit; - height = text->height / item->canvas->pixels_per_unit; - } - - switch (text->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_W: - case GTK_ANCHOR_SW: - break; - - case GTK_ANCHOR_N: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_S: - *x1 -= width / 2.0; - break; - - case GTK_ANCHOR_NE: - case GTK_ANCHOR_E: - case GTK_ANCHOR_SE: - *x1 -= width; - break; - } - - switch (text->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_N: - case GTK_ANCHOR_NE: - break; - - case GTK_ANCHOR_W: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_E: - *y1 -= height / 2.0; - break; - - case GTK_ANCHOR_SW: - case GTK_ANCHOR_S: - case GTK_ANCHOR_SE: - *y1 -= height; - break; - } - - *x2 = *x1 + width; - *y2 = *y1 + height; -} - -static void -_get_xy_from_position (EText *text, gint position, gint *xp, gint *yp) -{ - if ( !text->lines ) - return; - if (xp || yp) { - struct line *lines = NULL; - int x, y; - double xd, yd; - int j; - x = get_line_xpos_item_relative (text, lines); - y = text->yofs; - y -= text->yofs_edit; - for (j = 0, lines = text->lines; j < text->num_lines; lines++, j++) { - if (lines->text > text->text + position) - break; - y += e_font_height (text->font); - } - lines --; - y -= e_font_descent (text->font); - - x += e_font_utf8_text_width (text->font, E_FONT_PLAIN, - lines->text, - position - (lines->text - text->text)); - x -= text->xofs_edit; - - xd = x; yd = y; - gnome_canvas_item_i2w (GNOME_CANVAS_ITEM(text), &xd, &yd); - gnome_canvas_w2c (GNOME_CANVAS_ITEM(text)->canvas, xd, yd, &x, &y); - - if (xp) - *xp = x; - if (yp) - *yp = y; - } -} - -static gint -_get_position_from_xy (EText *text, gint x, gint y) -{ - int i, j; - int ypos = text->yofs; - int xpos; - double xd, yd; - char *p; - unicode_char_t unival; - - struct line *lines; - - xd = x; yd = y; - gnome_canvas_c2w (GNOME_CANVAS_ITEM(text)->canvas, xd, yd, &xd, &yd); - gnome_canvas_item_w2i (GNOME_CANVAS_ITEM(text), &xd, &yd); - x = xd; y = yd; - - y += text->yofs_edit; - - if (text->draw_borders) - ypos += BORDER_INDENT; - - j = 0; - while (y > ypos) { - ypos += e_font_height (text->font); - j ++; - } - j--; - if (j >= text->num_lines) - j = text->num_lines - 1; - if (j < 0) - j = 0; - i = 0; - lines = text->lines; - - if ( !lines ) - return 0; - - lines += j; - x += text->xofs_edit; - xpos = get_line_xpos_item_relative (text, lines); - - for (i = 0, p = lines->text; p && i < lines->length; i++, p = unicode_get_utf8 (p, &unival)) { - int charwidth; - - charwidth = e_font_utf8_char_width (text->font, E_FONT_PLAIN, p); - - xpos += charwidth / 2; - if (xpos > x) { - break; - } - xpos += (charwidth + 1) / 2; - } - - if (!p) return 0; - - return p - text->text; -} - -#define SCROLL_WAIT_TIME 30000 - -static gboolean -_blink_scroll_timeout (gpointer data) -{ - EText *text = E_TEXT(data); - gulong current_time; - gboolean scroll = FALSE; - gboolean redraw = FALSE; - - g_timer_elapsed(text->timer, ¤t_time); - - if (text->scroll_start + SCROLL_WAIT_TIME > 1000000) { - if (current_time > text->scroll_start - (1000000 - SCROLL_WAIT_TIME) && - current_time < text->scroll_start) - scroll = TRUE; - } else { - if (current_time > text->scroll_start + SCROLL_WAIT_TIME || - current_time < text->scroll_start) - scroll = TRUE; - } - if (scroll && text->button_down) { - if (text->lastx - text->clip_cx > text->clip_cwidth && - text->xofs_edit < text->max_width - text->clip_cwidth) { - text->xofs_edit += 4; - if (text->xofs_edit > text->max_width - text->clip_cwidth + 1) - text->xofs_edit = text->max_width - text->clip_cwidth + 1; - redraw = TRUE; - } - if (text->lastx - text->clip_cx < 0 && - text->xofs_edit > 0) { - text->xofs_edit -= 4; - if (text->xofs_edit < 0) - text->xofs_edit = 0; - redraw = TRUE; - } - - if (text->lasty - text->clip_cy > text->clip_cheight && - text->yofs_edit < text->height - text->clip_cheight) { - text->yofs_edit += 4; - if (text->yofs_edit > text->height - text->clip_cheight + 1) - text->yofs_edit = text->height - text->clip_cheight + 1; - redraw = TRUE; - } - if (text->lasty - text->clip_cy < 0 && - text->yofs_edit > 0) { - text->yofs_edit -= 4; - if (text->yofs_edit < 0) - text->yofs_edit = 0; - redraw = TRUE; - } - - if (redraw) { - ETextEventProcessorEvent e_tep_event; - e_tep_event.type = GDK_MOTION_NOTIFY; - e_tep_event.motion.state = text->last_state; - e_tep_event.motion.time = 0; - e_tep_event.motion.position = _get_position_from_xy(text, text->lastx, text->lasty); - _get_tep(text); - e_text_event_processor_handle_event (text->tep, - &e_tep_event); - text->scroll_start = current_time; - } - } - - if (!((current_time / 500000) % 2)) { - if (!text->show_cursor) - redraw = TRUE; - text->show_cursor = TRUE; - } else { - if (text->show_cursor) - redraw = TRUE; - text->show_cursor = FALSE; - } - if (redraw) { - text->needs_redraw = 1; - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text)); - } - return TRUE; -} - -static gboolean -tooltip_event(GtkWidget *tooltip, GdkEvent *event, EText *text) -{ - gint ret_val = FALSE; - switch (event->type) { - case GDK_LEAVE_NOTIFY: - if (text->tooltip_window) { - gtk_widget_destroy (text->tooltip_window); - text->tooltip_window = NULL; - } - break; - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - if (event->type == GDK_BUTTON_RELEASE) { - if (text->tooltip_window) { - gtk_widget_destroy (text->tooltip_window); - text->tooltip_window = NULL; - } - } - /* Forward events to the text item */ - gtk_signal_emit_by_name (GTK_OBJECT (text), "event", event, - &ret_val); - default: - break; - } - return ret_val; -} - -static gboolean -_do_tooltip (gpointer data) -{ - EText *text = E_TEXT (data); - struct line *lines; - GtkWidget *canvas; - int i; - gdouble max_width; - gboolean cut_off; - double i2c[6]; - ArtPoint origin = {0, 0}; - ArtPoint pixel_origin; - int canvas_x, canvas_y; - GnomeCanvasItem *tooltip_text; - double tooltip_width; - double tooltip_height; - double tooltip_x; - double tooltip_y; -#if 0 - double x1, x2, y1, y2; -#endif - GnomeCanvasItem *rect; - - text->tooltip_count = 0; - - lines = text->lines; - - if (text->tooltip_window || text->editing || (!lines)) { - text->tooltip_timeout = 0; - return FALSE; - } - - cut_off = FALSE; - for ( lines = text->lines, i = 0; i < text->num_lines; lines++, i++ ) { - if (lines->length > lines->ellipsis_length) { - cut_off = TRUE; - break; - } - } - if ( ! cut_off ) { - text->tooltip_timeout = 0; - return FALSE; - } - - gnome_canvas_item_i2c_affine(GNOME_CANVAS_ITEM(text), i2c); - art_affine_point (&pixel_origin, &origin, i2c); - - gdk_window_get_origin (GTK_WIDGET(GNOME_CANVAS_ITEM(text)->canvas)->window, &canvas_x, &canvas_y); - pixel_origin.x += canvas_x; - pixel_origin.y += canvas_y; - pixel_origin.x -= (int) gtk_layout_get_hadjustment(GTK_LAYOUT(GNOME_CANVAS_ITEM(text)->canvas))->value; - pixel_origin.y -= (int) gtk_layout_get_vadjustment(GTK_LAYOUT(GNOME_CANVAS_ITEM(text)->canvas))->value; - - text->tooltip_window = gtk_window_new (GTK_WINDOW_POPUP); - gtk_container_set_border_width (GTK_CONTAINER (text->tooltip_window), 1); - - canvas = e_canvas_new (); - - - - - - - - gtk_container_add (GTK_CONTAINER (text->tooltip_window), canvas); - - /* Get the longest line length */ - max_width = 0.0; - for (lines = text->lines, i = 0; i < text->num_lines; lines++, i++) { - gdouble line_width; - - line_width = e_font_utf8_text_width (text->font, E_FONT_PLAIN, lines->text, lines->length); - max_width = MAX (max_width, line_width); - } - - rect = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)), - gnome_canvas_rect_get_type (), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) max_width + 4, - "y2", (double) text->height + 4, - "fill_color", "yellow", - NULL); - - /* fixme: */ - tooltip_text = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)), - e_text_get_type (), - "anchor", GTK_ANCHOR_NW, - "font_gdk", text->font, - "text", text->text, - "editable", FALSE, - "clip_width", text->max_lines != 1 ? text->clip_width : max_width, - "clip_height", text->max_lines != 1 ? -1 : (double)text->height, - "clip", TRUE, - "line_wrap", text->line_wrap, - "justification", text->justification, - NULL); - - - - if (text->draw_borders) - e_canvas_item_move_absolute(tooltip_text, 1 + BORDER_INDENT, 1 + BORDER_INDENT); - else - e_canvas_item_move_absolute(tooltip_text, 1, 1); - - - calc_height(E_TEXT(tooltip_text)); - calc_line_widths(E_TEXT(tooltip_text)); - gnome_canvas_item_set (tooltip_text, - "clip_height", (double) E_TEXT(tooltip_text)->height, - "clip_width", (double) E_TEXT(tooltip_text)->max_width, - NULL); - tooltip_width = E_TEXT(tooltip_text)->max_width; - tooltip_height = E_TEXT(tooltip_text)->height; - tooltip_x = 0; - tooltip_y = 0; - switch(E_TEXT(tooltip_text)->justification) { - case GTK_JUSTIFY_CENTER: - tooltip_x = - tooltip_width / 2; - break; - case GTK_JUSTIFY_RIGHT: - tooltip_x = tooltip_width / 2; - break; - case GTK_JUSTIFY_FILL: - case GTK_JUSTIFY_LEFT: - tooltip_x = 0; - break; - } - switch(E_TEXT(tooltip_text)->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_N: - case GTK_ANCHOR_NE: - break; - - case GTK_ANCHOR_W: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_E: - tooltip_y -= tooltip_height / 2.0; - break; - - case GTK_ANCHOR_SW: - case GTK_ANCHOR_S: - case GTK_ANCHOR_SE: - tooltip_y -= tooltip_height; - break; - } - switch(E_TEXT(tooltip_text)->anchor) { - case GTK_ANCHOR_NW: - case GTK_ANCHOR_W: - case GTK_ANCHOR_SW: - break; - - case GTK_ANCHOR_N: - case GTK_ANCHOR_CENTER: - case GTK_ANCHOR_S: - tooltip_x -= tooltip_width / 2.0; - break; - - case GTK_ANCHOR_NE: - case GTK_ANCHOR_E: - case GTK_ANCHOR_SE: - tooltip_x -= tooltip_width; - break; - } -#if 0 - get_bounds(text, &x1, &y1, &x2, &y2); - if ( x1 < tooltip_x ) { - gnome_canvas_item_move(tooltip_text, tooltip_x - x1, 0); - tooltip_x = x1; - } - if ( y1 < tooltip_y ) { - gnome_canvas_item_move(tooltip_text, 0, tooltip_y - y1); - tooltip_y = y1; - } - if ( x2 > tooltip_x + tooltip_width ) - tooltip_width = x2 - tooltip_x; - if ( y2 > tooltip_y + tooltip_height ) - tooltip_height = y2 - tooltip_y; -#endif - - gnome_canvas_item_set(rect, - "x2", (double) tooltip_width + 4 + (text->draw_borders ? BORDER_INDENT * 2 : 0), - "y2", (double) tooltip_height + 4 + (text->draw_borders ? BORDER_INDENT * 2 : 0), - NULL); - - gtk_widget_set_usize (text->tooltip_window, - tooltip_width + 4 + (text->draw_borders ? BORDER_INDENT * 2 : 0), - tooltip_height + 4 + (text->draw_borders ? BORDER_INDENT * 2 : 0)); - gnome_canvas_set_scroll_region (GNOME_CANVAS(canvas), 0.0, 0.0, - tooltip_width + (text->draw_borders ? BORDER_INDENT * 2 : 0), - (double)tooltip_height + (text->draw_borders ? BORDER_INDENT * 2 : 0)); - gtk_widget_show (canvas); - gtk_widget_realize (text->tooltip_window); - gtk_signal_connect (GTK_OBJECT(text->tooltip_window), "event", - GTK_SIGNAL_FUNC(tooltip_event), text); - - gtk_widget_popup (text->tooltip_window, pixel_origin.x - 2 + tooltip_x, pixel_origin.y - 2 + tooltip_y); - - text->tooltip_timeout = 0; - return FALSE; -} - -static gboolean -_click (gpointer data) -{ - *(gint *)data = 0; - return FALSE; -} - -static gint -e_text_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EText *text = E_TEXT(item); - ETextEventProcessorEvent e_tep_event; - - gint return_val = 0; - - e_tep_event.type = event->type; - switch (event->type) { - case GDK_FOCUS_CHANGE: - if (text->editable) { - GdkEventFocus *focus_event; - focus_event = (GdkEventFocus *) event; - if (focus_event->in) { - if(!text->editing) { - text->editing = TRUE; - if ( text->pointer_in ) { - if ( text->default_cursor_shown && (!text->draw_borders)) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->i_cursor); - text->default_cursor_shown = FALSE; - } - } - text->select_by_word = FALSE; - text->xofs_edit = 0; - text->yofs_edit = 0; - if (text->timeout_id == 0) - text->timeout_id = g_timeout_add(10, _blink_scroll_timeout, text); - text->timer = g_timer_new(); - g_timer_elapsed(text->timer, &(text->scroll_start)); - g_timer_start(text->timer); - } - } else { - text->editing = FALSE; - if ( (!text->default_cursor_shown) && (!text->draw_borders) ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->default_cursor); - text->default_cursor_shown = TRUE; - } - if (text->timeout_id) { - g_source_remove(text->timeout_id); - text->timeout_id = 0; - } - if (text->timer) { - g_timer_stop(text->timer); - g_timer_destroy(text->timer); - text->timer = NULL; - } - } - if ( text->line_wrap ) - text->needs_split_into_lines = 1; - else - text->needs_calc_line_widths = 1; - e_canvas_item_request_reflow (GNOME_CANVAS_ITEM(text)); - } - return_val = 0; - break; - case GDK_KEY_PRESS: /* Fall Through */ - case GDK_KEY_RELEASE: - if (text->editing) { - GdkEventKey key = event->key; - gint ret; - - e_tep_event.key.time = key.time; - e_tep_event.key.state = key.state; - e_tep_event.key.keyval = key.keyval; - - /* This is probably ugly hack, but we have to handle UTF-8 input somehow */ -#if 0 - e_tep_event.key.length = key.length; - e_tep_event.key.string = key.string; -#else - e_tep_event.key.string = e_utf8_from_gtk_event_key (GTK_WIDGET (item->canvas), key.keyval, key.string); - if (e_tep_event.key.string != NULL) { - e_tep_event.key.length = strlen (e_tep_event.key.string); - } else { - e_tep_event.key.length = 0; - } -#endif - _get_tep(text); - ret = e_text_event_processor_handle_event (text->tep, &e_tep_event); - - if (e_tep_event.key.string) g_free (e_tep_event.key.string); - - return ret; - } - else - return 0; - break; - case GDK_BUTTON_PRESS: /* Fall Through */ - case GDK_BUTTON_RELEASE: - if (text->tooltip_timeout) { - gtk_timeout_remove (text->tooltip_timeout); - text->tooltip_timeout = 0; - } - if (text->tooltip_window) { - gtk_widget_destroy (text->tooltip_window); - text->tooltip_window = NULL; - } -#if 0 - if ((!text->editing) - && text->editable - && event->type == GDK_BUTTON_RELEASE - && event->button.button == 1) { - GdkEventButton button = event->button; - - e_canvas_item_grab_focus (item); - - e_tep_event.type = GDK_BUTTON_RELEASE; - e_tep_event.button.time = button.time; - e_tep_event.button.state = button.state; - e_tep_event.button.button = button.button; - e_tep_event.button.position = _get_position_from_xy(text, button.x, button.y); - _get_tep(text); - return_val = e_text_event_processor_handle_event (text->tep, - &e_tep_event); - e_tep_event.type = GDK_BUTTON_RELEASE; - } -#else - if ((!text->editing) - && text->editable - && (event->button.button == 1 || - event->button.button == 2)) { - e_canvas_item_grab_focus (item); - } -#endif - /* Create our own double and triple click events, - as gnome-canvas doesn't forward them to us */ - if (event->type == GDK_BUTTON_PRESS) { - if (text->dbl_timeout == 0 && - text->tpl_timeout == 0) { - text->dbl_timeout = gtk_timeout_add (200, - _click, - &(text->dbl_timeout)); - } else { - if (text->tpl_timeout == 0) { - e_tep_event.type = GDK_2BUTTON_PRESS; - text->tpl_timeout = gtk_timeout_add (200, _click, &(text->tpl_timeout)); - } else { - e_tep_event.type = GDK_3BUTTON_PRESS; - } - } - } - - if (text->editing) { - GdkEventButton button = event->button; - e_tep_event.button.time = button.time; - e_tep_event.button.state = button.state; - e_tep_event.button.button = button.button; - e_tep_event.button.position = _get_position_from_xy(text, button.x, button.y); - _get_tep(text); - return_val = e_text_event_processor_handle_event (text->tep, - &e_tep_event); - if (event->button.button == 1) { - if (event->type == GDK_BUTTON_PRESS) - text->button_down = TRUE; - else - text->button_down = FALSE; - } - text->lastx = button.x; - text->lasty = button.y; - text->last_state = button.state; - } - break; - case GDK_MOTION_NOTIFY: - if (text->editing) { - GdkEventMotion motion = event->motion; - e_tep_event.motion.time = motion.time; - e_tep_event.motion.state = motion.state; - e_tep_event.motion.position = _get_position_from_xy(text, motion.x, motion.y); - _get_tep(text); - return_val = e_text_event_processor_handle_event (text->tep, - &e_tep_event); - text->lastx = motion.x; - text->lasty = motion.y; - text->last_state = motion.state; - } - break; - case GDK_ENTER_NOTIFY: - { - GdkEventCrossing *crossing = (GdkEventCrossing *) event; - double x1, y1, x2, y2; - get_bounds (text, &x1, &y1, &x2, &y2); - if (crossing->x >= x1 && - crossing->y >= y1 && - crossing->x <= x2 && - crossing->y <= y2) { - if ( text->tooltip_count == 0 && text->clip) { - if (!text->tooltip_timeout) - text->tooltip_timeout = gtk_timeout_add (1000, _do_tooltip, text); - } - text->tooltip_count ++; - } - } - - text->pointer_in = TRUE; - if (text->editing || text->draw_borders) { - if ( text->default_cursor_shown ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->i_cursor); - text->default_cursor_shown = FALSE; - } - } - break; - case GDK_LEAVE_NOTIFY: - if (text->tooltip_count > 0) - text->tooltip_count --; - if ( text->tooltip_count == 0 && text->clip) { - if ( text->tooltip_timeout ) { - gtk_timeout_remove (text->tooltip_timeout); - text->tooltip_timeout = 0; - } - } - - text->pointer_in = FALSE; - if (text->editing || text->draw_borders) { - if ( ! text->default_cursor_shown ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->default_cursor); - text->default_cursor_shown = TRUE; - } - } - break; - default: - break; - } - if (return_val) - return return_val; - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->event) - return GNOME_CANVAS_ITEM_CLASS(parent_class)->event(item, event); - else - return 0; -} - -/* fixme: */ - -static int -_get_position(EText *text, ETextEventProcessorCommand *command) -{ - int length; - int x, y; - unicode_char_t unival; - char *p; - - switch (command->position) { - - case E_TEP_VALUE: - return command->value; - - case E_TEP_SELECTION: - return text->selection_end; - - case E_TEP_START_OF_BUFFER: - return 0; - case E_TEP_END_OF_BUFFER: - return unicode_strlen (text->text, -1); - - case E_TEP_START_OF_LINE: - - if (text->selection_end < 1) return 0; - p = unicode_previous_utf8 (text->text, text->text + text->selection_end); - if (p == text->text) return 0; - p = unicode_previous_utf8 (text->text, p); - - while (p && p > text->text) { - if (*p == '\n') return p - text->text + 1; - p = unicode_previous_utf8 (text->text, p); - } - - return 0; - - case E_TEP_END_OF_LINE: - length = strlen(text->text); - if (text->selection_end >= length) return length; - - p = unicode_next_utf8 (text->text + text->selection_end); - - while (*p) { - if (*p == '\n') return p - text->text; - p = unicode_next_utf8 (p); - } - - return p - text->text; - - case E_TEP_FORWARD_CHARACTER: - length = strlen (text->text); - if (text->selection_end >= length) return length; - - p = unicode_next_utf8 (text->text + text->selection_end); - - return p - text->text; - - case E_TEP_BACKWARD_CHARACTER: - if (text->selection_end < 1) return 0; - p = unicode_previous_utf8 (text->text, text->text + text->selection_end); - - if (p == NULL) return 0; - - return p - text->text; - - case E_TEP_FORWARD_WORD: - length = strlen (text->text); - if (text->selection_end >= length) return length; - - p = unicode_next_utf8 (text->text + text->selection_end); - - while (*p) { - unicode_get_utf8 (p, &unival); - if (unicode_isspace (unival)) return p - text->text; - p = unicode_next_utf8 (p); - } - - return p - text->text; - - case E_TEP_BACKWARD_WORD: - - if (text->selection_end < 1) return 0; - p = unicode_previous_utf8 (text->text, text->text + text->selection_end); - if (p == text->text) return 0; - p = unicode_previous_utf8 (text->text, p); - - while (p && p > text->text) { - unicode_get_utf8 (p, &unival); - if (unicode_isspace (unival)) return (unicode_next_utf8 (p) - text->text); - p = unicode_previous_utf8 (text->text, p); - } - - return 0; - - case E_TEP_FORWARD_LINE: - _get_xy_from_position(text, text->selection_end, &x, &y); - y += e_font_height (text->font); - return _get_position_from_xy(text, x, y); - case E_TEP_BACKWARD_LINE: - _get_xy_from_position(text, text->selection_end, &x, &y); - y -= e_font_height (text->font); - return _get_position_from_xy(text, x, y); - - case E_TEP_SELECT_WORD: - - if (text->selection_end < 1) return 0; - p = unicode_previous_utf8 (text->text, text->text + text->selection_end); - if (p == text->text) return 0; - p = unicode_previous_utf8 (text->text, p); - - while (p && p > text->text) { - unicode_get_utf8 (p, &unival); - if (unicode_isspace (unival)) { - p = unicode_next_utf8 (p); - break; - } - p = unicode_previous_utf8 (text->text, p); - } - - if (!p) - text->selection_start = 0; - else - text->selection_start = p - text->text; - - length = strlen (text->text); - if (text->selection_end >= length) return length; - - p = unicode_next_utf8 (text->text + text->selection_end); - - while (*p) { - unicode_get_utf8 (p, &unival); - if (unicode_isspace (unival)) return p - text->text; - p = unicode_next_utf8 (p); - } - - return p - text->text; - - case E_TEP_SELECT_ALL: - text->selection_start = 0; - length = strlen (text->text); - return length; - - case E_TEP_FORWARD_PARAGRAPH: - case E_TEP_BACKWARD_PARAGRAPH: - - case E_TEP_FORWARD_PAGE: - case E_TEP_BACKWARD_PAGE: - return text->selection_end; - default: - return text->selection_end; - } -} - -static void -_delete_selection(EText *text) -{ - if ( text->selection_start < text->selection_end ) { - e_text_model_delete(text->model, text->selection_start, text->selection_end - text->selection_start); - text->selection_end = text->selection_start; - } else { - e_text_model_delete(text->model, text->selection_end, text->selection_start - text->selection_end); - text->selection_start = text->selection_end; - } -} - -static void -_insert(EText *text, char *string, int value) -{ - if (value > 0) { - e_text_model_insert_length(text->model, text->selection_start, string, value); - - text->selection_start += value; - text->selection_end = text->selection_start; - } -} - -static void -e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gpointer data) -{ - EText *text = E_TEXT(data); - int sel_start, sel_end; - switch (command->action) { - case E_TEP_MOVE: - text->selection_start = _get_position(text, command); - text->selection_end = text->selection_start; - if (text->timer) { - g_timer_reset(text->timer); - } - break; - case E_TEP_SELECT: - text->selection_end = _get_position(text, command); - sel_start = MIN(text->selection_start, text->selection_end); - sel_end = MAX(text->selection_start, text->selection_end); - if (sel_start != sel_end) { - e_text_supply_selection (text, command->time, GDK_SELECTION_PRIMARY, - text->text + sel_start, sel_end - sel_start); - } else if (text->timer) { - g_timer_reset(text->timer); - } - break; - case E_TEP_DELETE: - if (text->selection_end == text->selection_start) { - text->selection_end = _get_position(text, command); - } - _delete_selection(text); - if (text->timer) { - g_timer_reset(text->timer); - } - break; - - case E_TEP_INSERT: - if (text->selection_end != text->selection_start) { - _delete_selection(text); - } - _insert(text, command->string, command->value); - if (text->timer) { - g_timer_reset(text->timer); - } - break; - case E_TEP_COPY: - sel_start = MIN(text->selection_start, text->selection_end); - sel_end = MAX(text->selection_start, text->selection_end); - if (sel_start != sel_end) { - e_text_supply_selection (text, command->time, clipboard_atom, - text->text + sel_start, sel_end - sel_start); - } - if (text->timer) { - g_timer_reset(text->timer); - } - break; - case E_TEP_PASTE: - e_text_get_selection (text, clipboard_atom, command->time); - if (text->timer) { - g_timer_reset(text->timer); - } - break; - case E_TEP_GET_SELECTION: - e_text_get_selection (text, GDK_SELECTION_PRIMARY, command->time); - break; - case E_TEP_ACTIVATE: - gtk_signal_emit (GTK_OBJECT (text), e_text_signals[E_TEXT_ACTIVATE]); - if (text->timer) { - g_timer_reset(text->timer); - } - break; - case E_TEP_SET_SELECT_BY_WORD: - text->select_by_word = command->value; - break; - case E_TEP_GRAB: - gnome_canvas_item_grab (GNOME_CANVAS_ITEM(text), - GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, - text->i_cursor, - command->time); - break; - case E_TEP_UNGRAB: - gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM(text), command->time); - break; - case E_TEP_NOP: - break; - } - - if (!text->button_down) { - int x; - int i; - struct line *lines = text->lines; - gdouble clip_width; - if ( !lines ) - return; - - for (lines = text->lines, i = 0; i < text->num_lines ; i++, lines ++) { - if ((lines->text - text->text) > text->selection_end) { - break; - } - } - lines --; - i --; - x = e_font_utf8_text_width(text->font, E_FONT_PLAIN, - lines->text, - text->selection_end - (lines->text - text->text)); - - - if (x < text->xofs_edit) { - text->xofs_edit = x; - } - - clip_width = text->clip_width; - if (clip_width >= 0 && text->draw_borders) { - clip_width -= 6; - if (clip_width < 0) - clip_width = 0; - } - - if (2 + x - clip_width > text->xofs_edit) { - text->xofs_edit = 2 + x - clip_width; - } - - if (e_font_height (text->font) * i < text->yofs_edit) - text->yofs_edit = e_font_height (text->font) * i; - - if (e_font_height (text->font) * (i + 1) - (text->clip_height != -1 ? text->clip_height : text->height) > text->yofs_edit) - text->yofs_edit = e_font_height (text->font) * (i + 1) - (text->clip_height != -1 ? text->clip_height : text->height); - } - - text->needs_redraw = 1; - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text)); -} - -static void _invisible_destroy (GtkInvisible *invisible, - EText *text) -{ - text->invisible = NULL; -} - -static GtkWidget *e_text_get_invisible(EText *text) -{ - GtkWidget *invisible; - if (text->invisible) { - invisible = text->invisible; - } else { - invisible = gtk_invisible_new(); - text->invisible = invisible; - - gtk_selection_add_target (invisible, - GDK_SELECTION_PRIMARY, - GDK_SELECTION_TYPE_STRING, - E_SELECTION_PRIMARY); - gtk_selection_add_target (invisible, - clipboard_atom, - GDK_SELECTION_TYPE_STRING, - E_SELECTION_CLIPBOARD); - - gtk_signal_connect (GTK_OBJECT(invisible), "selection_get", - GTK_SIGNAL_FUNC (_selection_get), - text); - gtk_signal_connect (GTK_OBJECT(invisible), "selection_clear_event", - GTK_SIGNAL_FUNC (_selection_clear_event), - text); - gtk_signal_connect (GTK_OBJECT(invisible), "selection_received", - GTK_SIGNAL_FUNC (_selection_received), - text); - - gtk_signal_connect (GTK_OBJECT(invisible), "destroy", - GTK_SIGNAL_FUNC (_invisible_destroy), - text); - } - return invisible; -} - -static void -_selection_clear_event (GtkInvisible *invisible, - GdkEventSelection *event, - EText *text) -{ - if (event->selection == GDK_SELECTION_PRIMARY) { - g_free (text->primary_selection); - text->primary_selection = NULL; - text->primary_length = 0; - - text->has_selection = FALSE; - text->needs_redraw = 1; - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(text)); - - } else if (event->selection == clipboard_atom) { - g_free (text->clipboard_selection); - text->clipboard_selection = NULL; - text->clipboard_length = 0; - } -} - -static void -_selection_get (GtkInvisible *invisible, - GtkSelectionData *selection_data, - guint info, - guint time_stamp, - EText *text) -{ - switch (info) { - case E_SELECTION_PRIMARY: - gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING, - 8, text->primary_selection, text->primary_length); - break; - case E_SELECTION_CLIPBOARD: - gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING, - 8, text->clipboard_selection, text->clipboard_length); - break; - } -} - -static void -_selection_received (GtkInvisible *invisible, - GtkSelectionData *selection_data, - guint time, - EText *text) -{ - if (selection_data->length < 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) { - return; - } else { - ETextEventProcessorCommand command; - command.action = E_TEP_INSERT; - command.position = E_TEP_SELECTION; - command.string = selection_data->data; - command.value = selection_data->length; - command.time = time; - e_text_command(text->tep, &command, text); - } -} - -static void e_text_supply_selection (EText *text, guint time, GdkAtom selection, guchar *data, gint length) -{ - gboolean successful; - GtkWidget *invisible; - - invisible = e_text_get_invisible(text); - - if (selection == GDK_SELECTION_PRIMARY ) { - if (text->primary_selection) { - g_free (text->primary_selection); - } - text->primary_selection = g_strndup(data, length); - text->primary_length = length; - } else if (selection == clipboard_atom) { - if (text->clipboard_selection) { - g_free (text->clipboard_selection); - } - text->clipboard_selection = g_strndup(data, length); - text->clipboard_length = length; - } - - successful = gtk_selection_owner_set (invisible, - selection, - time); - - if (selection == GDK_SELECTION_PRIMARY) - text->has_selection = successful; -} - -static void -e_text_get_selection(EText *text, GdkAtom selection, guint32 time) -{ - GtkWidget *invisible; - invisible = e_text_get_invisible(text); - gtk_selection_convert(invisible, - selection, - GDK_SELECTION_TYPE_STRING, - time); -} - -#if 0 -static void -e_text_real_copy_clipboard (EText *text) -{ - guint32 time; - gint selection_start_pos; - gint selection_end_pos; - - g_return_if_fail (text != NULL); - g_return_if_fail (E_IS_TEXT (text)); - - time = gtk_text_get_event_time (text); - selection_start_pos = MIN (text->selection_start, text->selection_end); - selection_end_pos = MAX (text->selection_start, text->selection_end); - - if (selection_start_pos != selection_end_pos) - { - if (gtk_selection_owner_set (GTK_WIDGET (text->canvas), - clipboard_atom, - time)) - text->clipboard_text = ""; - } -} - -static void -e_text_real_paste_clipboard (EText *text) -{ - guint32 time; - - g_return_if_fail (text != NULL); - g_return_if_fail (E_IS_TEXT (text)); - - time = e_text_get_event_time (text); - if (text->editable) - gtk_selection_convert (GTK_WIDGET(text->widget), - clipboard_atom, - gdk_atom_intern ("COMPOUND_TEXT", FALSE), time); -} -#endif - - -#if 0 -/* Routines for sucking fonts from the X server */ - -static ETextSuckFont * -e_suck_font (GdkFont *font) -{ - ETextSuckFont *suckfont; - int i; - int x, y; - char text[1]; - int lbearing, rbearing, ch_width, ascent, descent; - GdkPixmap *pixmap; - GdkColor black, white; - GdkImage *image; - GdkGC *gc; - guchar *line; - int width, height; - int black_pixel, pixel; - - if (!font) - return NULL; - - suckfont = g_new (ETextSuckFont, 1); - - height = font->ascent + font->descent; - x = 0; - for (i = 0; i < 256; i++) { - text[0] = i; - gdk_text_extents (font, text, 1, - &lbearing, &rbearing, &ch_width, &ascent, &descent); - suckfont->chars[i].left_sb = lbearing; - suckfont->chars[i].right_sb = ch_width - rbearing; - suckfont->chars[i].width = rbearing - lbearing; - suckfont->chars[i].ascent = ascent; - suckfont->chars[i].descent = descent; - suckfont->chars[i].bitmap_offset = x; - x += (ch_width + 31) & -32; - } - - width = x; - - suckfont->bitmap_width = width; - suckfont->bitmap_height = height; - suckfont->ascent = font->ascent; - - pixmap = gdk_pixmap_new (NULL, suckfont->bitmap_width, - suckfont->bitmap_height, 1); - gc = gdk_gc_new (pixmap); - gdk_gc_set_font (gc, font); - - black_pixel = BlackPixel (gdk_display, DefaultScreen (gdk_display)); - black.pixel = black_pixel; - white.pixel = WhitePixel (gdk_display, DefaultScreen (gdk_display)); - gdk_gc_set_foreground (gc, &white); - gdk_draw_rectangle (pixmap, gc, 1, 0, 0, width, height); - - gdk_gc_set_foreground (gc, &black); - for (i = 0; i < 256; i++) { - text[0] = i; - gdk_draw_text (pixmap, font, gc, - suckfont->chars[i].bitmap_offset - suckfont->chars[i].left_sb, - font->ascent, - text, 1); - } - - /* The handling of the image leaves me with distinct unease. But this - * is more or less copied out of gimp/app/text_tool.c, so it _ought_ to - * work. -RLL - */ - - image = gdk_image_get (pixmap, 0, 0, width, height); - suckfont->bitmap = g_malloc0 ((width >> 3) * height); - - line = suckfont->bitmap; - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - pixel = gdk_image_get_pixel (image, x, y); - if (pixel == black_pixel) - line[x >> 3] |= 128 >> (x & 7); - } - line += width >> 3; - } - - gdk_image_destroy (image); - - /* free the pixmap */ - gdk_pixmap_unref (pixmap); - - /* free the gc */ - gdk_gc_destroy (gc); - - return suckfont; -} - -static void -e_suck_font_free (ETextSuckFont *suckfont) -{ - g_free (suckfont->bitmap); - g_free (suckfont); -} -#endif - - - - - - - diff --git a/widgets/e-text/e-text.h b/widgets/e-text/e-text.h deleted file mode 100644 index 35ab08ad7f..0000000000 --- a/widgets/e-text/e-text.h +++ /dev/null @@ -1,227 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* EText - Text item for evolution. - * Copyright (C) 2000 Helix Code, Inc. - * - * Author: Chris Lahey <clahey@umich.edu> - * - * A majority of code taken from: - * - * Text item type for GnomeCanvas widget - * - * GnomeCanvas is basically a port of the Tk toolkit's most excellent - * canvas widget. Tk is copyrighted by the Regents of the University - * of California, Sun Microsystems, and other parties. - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <federico@nuclecu.unam.mx> */ - -#ifndef E_TEXT_H -#define E_TEXT_H - -#include <gnome.h> -#include "e-util/e-font.h" -#include "e-text-event-processor.h" -#include "e-text-model.h" - - -BEGIN_GNOME_DECLS - - -/* Text item for the canvas. Text items are positioned by an anchor point and an anchor direction. - * - * A clipping rectangle may be specified for the text. The rectangle is anchored at the text's anchor - * point, and is specified by clipping width and height parameters. If the clipping rectangle is - * enabled, it will clip the text. - * - * In addition, x and y offset values may be specified. These specify an offset from the anchor - * position. If used in conjunction with the clipping rectangle, these could be used to implement - * simple scrolling of the text within the clipping rectangle. - * - * The following object arguments are available: - * - * name type read/write description - * ------------------------------------------------------------------------------------------ - * text string RW The string of the text label - * font string W X logical font descriptor - * fontset string W X logical fontset descriptor - * font_gdk GdkFont* RW Pointer to a GdkFont - * anchor GtkAnchorType RW Anchor side for the text - * justification GtkJustification RW Justification for multiline text - * fill_color string W X color specification for text - * fill_color_gdk GdkColor* RW Pointer to an allocated GdkColor - * fill_stipple GdkBitmap* RW Stipple pattern for filling the text - * clip_width double RW Width of clip rectangle - * clip_height double RW Height of clip rectangle - * clip boolean RW Use clipping rectangle? - * fill_clip_rect boolean RW Whether the text item represents itself as being the size of the clipping rectangle. - * x_offset double RW Horizontal offset distance from anchor position - * y_offset double RW Vertical offset distance from anchor position - * text_width double R Used to query the width of the rendered text - * text_height double R Used to query the rendered height of the text - * width double RW A synonym for clip_width - * height double R A synonym for text_height - * - * These are currently ignored in the AA version: - * editable boolean RW Can this item be edited - * use_ellipsis boolean RW Whether to use ellipsises if text gets cut off. Meaningless if clip == false. - * ellipsis string RW The characters to use as ellipsis. NULL = "...". - * line_wrap boolean RW Line wrap when not editing. - * break_characters string RW List of characters to optionally break on. - * max_lines int RW Number of lines possible when doing line wrap. - * draw_borders boolean RW Whether to draw borders. - */ - -#define E_TYPE_TEXT (e_text_get_type ()) -#define E_TEXT(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TEXT, EText)) -#define E_TEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_TEXT, ETextClass)) -#define E_IS_TEXT(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_TEXT)) -#define E_IS_TEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_TEXT)) - - -typedef struct _EText EText; -typedef struct _ETextClass ETextClass; - -#if 0 -typedef struct _ETextSuckFont ETextSuckFont; -typedef struct _ETextSuckChar ETextSuckChar; - -struct _ETextSuckChar { - int left_sb; - int right_sb; - int width; - int ascent; - int descent; - int bitmap_offset; /* in pixels */ -}; - -struct _ETextSuckFont { - guchar *bitmap; - gint bitmap_width; - gint bitmap_height; - gint ascent; - ETextSuckChar chars[256]; -}; -#endif - -struct _EText { - GnomeCanvasItem item; - - ETextModel *model; - gint model_changed_signal_id; - - char *text; /* Text to display */ - gpointer lines; /* Text split into lines (private field) */ - int num_lines; /* Number of lines of text */ - -#if 0 - GdkFont *font; /* Font for text */ -#else - EFont *font; -#endif - GtkAnchorType anchor; /* Anchor side for text */ - GtkJustification justification; /* Justification for text */ - - double clip_width; /* Width of optional clip rectangle */ - double clip_height; /* Height of optional clip rectangle */ - - double xofs, yofs; /* Text offset distance from anchor position */ - - gulong pixel; /* Fill color */ - GdkBitmap *stipple; /* Stipple for text */ - GdkGC *gc; /* GC for drawing text */ - - int cx, cy; /* Top-left canvas coordinates for text */ - int clip_cx, clip_cy; /* Top-left canvas coordinates for clip rectangle */ - int clip_cwidth, clip_cheight; /* Size of clip rectangle in pixels */ - int max_width; /* Maximum width of text lines */ - int width; /* Rendered text width in pixels */ - int height; /* Rendered text height in pixels */ - - guint clip : 1; /* Use clip rectangle? */ - guint fill_clip_rectangle : 1; /* Fill the clipping rectangle. */ - - /* Antialiased specific stuff follows */ -#if 0 - ETextSuckFont *suckfont; /* Sucked font */ -#endif - guint32 rgba; /* RGBA color for text */ - double affine[6]; /* The item -> canvas affine */ - - char *ellipsis; /* The ellipsis characters. NULL = "...". */ - double ellipsis_width; /* The width of the ellipsis. */ - gboolean use_ellipsis; /* Whether to use the ellipsis. */ - - gboolean editable; /* Item is editable */ - gboolean editing; /* Item is currently being edited */ - - int xofs_edit; /* Offset because of editing */ - int yofs_edit; /* Offset because of editing */ - - /* This needs to be reworked a bit once we get line wrapping. */ - int selection_start; /* Start of selection IN BYTES */ - int selection_end; /* End of selection IN BYTES */ - gboolean select_by_word; /* Current selection is by word */ - - /* This section is for drag scrolling and blinking cursor. */ - gint timeout_id; /* Current timeout id for scrolling */ - GTimer *timer; /* Timer for blinking cursor and scrolling */ - - gint lastx, lasty; /* Last x and y motion events */ - gint last_state; /* Last state */ - gulong scroll_start; /* Starting time for scroll (microseconds) */ - - gint show_cursor; /* Is cursor currently shown */ - gboolean button_down; /* Is mouse button 1 down */ - - ETextEventProcessor *tep; /* Text Event Processor */ - gint tep_command_id; - - GtkWidget *invisible; /* For selection handling */ - gboolean has_selection; /* TRUE if we have the selection */ - gchar *primary_selection; /* Primary selection text */ - gint primary_length; /* Primary selection text length */ - gchar *clipboard_selection; /* Clipboard selection text */ - gint clipboard_length; /* Clipboard selection text length*/ - - guint pointer_in : 1; /* Is the pointer currently over us? */ - guint default_cursor_shown : 1; /* Is the default cursor currently shown? */ - guint draw_borders : 1; /* Draw borders? */ - - guint line_wrap : 1; /* Do line wrap */ - gchar *break_characters; /* Characters to optionally break after */ - - gint max_lines; /* Max number of lines (-1 = infinite) */ - - GdkCursor *default_cursor; /* Default cursor (arrow) */ - GdkCursor *i_cursor; /* I beam cursor */ - - gint tooltip_timeout; /* Timeout for the tooltip */ - GtkWidget *tooltip_window; /* GtkWindow for displaying the tooltip */ - gint tooltip_count; /* GDK_ENTER_NOTIFY count. */ - - guint needs_redraw : 1; /* Needs redraw */ - guint needs_recalc_bounds : 1; /* Need recalc_bounds */ - guint needs_calc_height : 1; /* Need calc_height */ - guint needs_calc_line_widths : 1; /* Needs calc_line_widths */ - guint needs_split_into_lines : 1; /* Needs split_into_lines */ - - gint dbl_timeout; /* Double click timeout */ - gint tpl_timeout; /* Triple click timeout */ -}; - -struct _ETextClass { - GnomeCanvasItemClass parent_class; - - void (* changed) (EText *text); - void (* activate) (EText *text); -}; - - -/* Standard Gtk function */ -GtkType e_text_get_type (void); - - -END_GNOME_DECLS - -#endif |