/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* ETableTextModel - Text item model for evolution. * Copyright (C) 2000 Helix Code, Inc. * * Author: Chris Lahey * * 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 */ #include #include #include "e-table-text-model.h" static void e_table_text_model_class_init (ETableTextModelClass *class); static void e_table_text_model_init (ETableTextModel *model); static void e_table_text_model_destroy (GtkObject *object); static gchar *e_table_text_model_get_text (ETextModel *model); static void e_table_text_model_set_text (ETextModel *model, gchar *text); static void e_table_text_model_insert (ETextModel *model, gint postion, gchar *text); static void e_table_text_model_insert_length (ETextModel *model, gint postion, gchar *text, gint length); static void e_table_text_model_delete (ETextModel *model, gint postion, gint length); static GtkObject *parent_class; /** * e_table_text_model_get_type: * @void: * * Registers the &ETableTextModel class if necessary, and returns the type ID * associated to it. * * Return value: The type ID of the &ETableTextModel class. **/ GtkType e_table_text_model_get_type (void) { static GtkType model_type = 0; if (!model_type) { GtkTypeInfo model_info = { "ETableTextModel", sizeof (ETableTextModel), sizeof (ETableTextModelClass), (GtkClassInitFunc) e_table_text_model_class_init, (GtkObjectInitFunc) e_table_text_model_init, NULL, /* reserved_1 */ NULL, /* reserved_2 */ (GtkClassInitFunc) NULL }; model_type = gtk_type_unique (e_text_model_get_type (), &model_info); } return model_type; } /* Class initialization function for the text item */ static void e_table_text_model_class_init (ETableTextModelClass *klass) { GtkObjectClass *object_class; ETextModelClass *model_class; object_class = (GtkObjectClass *) klass; model_class = (ETextModelClass *) klass; parent_class = gtk_type_class (e_text_model_get_type ()); model_class->get_text = e_table_text_model_get_text; model_class->set_text = e_table_text_model_set_text; model_class->insert = e_table_text_model_insert; model_class->insert_length = e_table_text_model_insert_length; model_class->delete = e_table_text_model_delete; object_class->destroy = e_table_text_model_destroy; } /* Object initialization function for the text item */ static void e_table_text_model_init (ETableTextModel *model) { model->model = NULL; model->row = 0; model->model_col = 0; model->cell_changed_signal_id = 0; model->row_changed_signal_id = 0; } /* Destroy handler for the text item */ static void e_table_text_model_destroy (GtkObject *object) { ETableTextModel *model; g_return_if_fail (object != NULL); g_return_if_fail (E_IS_TABLE_TEXT_MODEL (object)); model = E_TABLE_TEXT_MODEL (object); if (model->model) g_assert (GTK_IS_OBJECT (model->model)); if (model->cell_changed_signal_id) gtk_signal_disconnect (GTK_OBJECT(model->model), model->cell_changed_signal_id); if (model->row_changed_signal_id) gtk_signal_disconnect (GTK_OBJECT(model->model), model->row_changed_signal_id); if (model->model) gtk_object_unref (GTK_OBJECT(model->model)); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } static gchar * e_table_text_model_get_text (ETextModel *text_model) { ETableTextModel *model = E_TABLE_TEXT_MODEL(text_model); if (model->model) return (gchar *)e_table_model_value_at (model->model, model->model_col, model->row); else return ""; } static void e_table_text_model_set_text (ETextModel *text_model, gchar *text) { ETableTextModel *model = E_TABLE_TEXT_MODEL(text_model); if (model->model) e_table_model_set_value_at (model->model, model->model_col, model->row, (void *) text); } static void e_table_text_model_insert (ETextModel *text_model, gint position, gchar *text) { ETableTextModel *model = E_TABLE_TEXT_MODEL(text_model); if (model->model){ gchar *temp = (gchar *)e_table_model_value_at (model->model, model->model_col, model->row); temp = g_strdup_printf ("%.*s%s%s", position, temp, text, temp + position); e_table_model_set_value_at (model->model, model->model_col, model->row, temp); g_free (temp); } } static void e_table_text_model_insert_length (ETextModel *text_model, gint position, gchar *text, gint length) { ETableTextModel *model = E_TABLE_TEXT_MODEL(text_model); if (model->model){ gchar *temp = (gchar *)e_table_model_value_at (model->model, model->model_col, model->row); temp = g_strdup_printf ("%.*s%.*s%s", position, temp, length, text, temp + position); e_table_model_set_value_at (model->model, model->model_col, model->row, temp); g_free (temp); } } static void e_table_text_model_delete (ETextModel *text_model, gint position, gint length) { ETableTextModel *model = E_TABLE_TEXT_MODEL(text_model); if (model->model){ gchar *temp = (gchar *)e_table_model_value_at (model->model, model->model_col, model->row); temp = g_strdup_printf ("%.*s%s", position, temp, temp + position + length); e_table_model_set_value_at (model->model, model->model_col, model->row, temp); g_free (temp); } } static void cell_changed (ETableModel *table_model, int model_col, int row, ETableTextModel *model) { if (model->model_col == model_col && model->row == row) e_text_model_changed (E_TEXT_MODEL(model)); } static void row_changed (ETableModel *table_model, int row, ETableTextModel *model) { if (model->row == row) e_text_model_changed (E_TEXT_MODEL(model)); } ETableTextModel * e_table_text_model_new (ETableModel *table_model, int row, int model_col) { ETableTextModel *model = gtk_type_new (e_table_text_model_get_type ()); model->model = table_model; if (model->model){ gtk_object_ref (GTK_OBJECT(model->model)); model->cell_changed_signal_id = gtk_signal_connect (GTK_OBJECT(model->model), "model_cell_changed", GTK_SIGNAL_FUNC(cell_changed), model); model->row_changed_signal_id = gtk_signal_connect (GTK_OBJECT(model->model), "model_row_changed", GTK_SIGNAL_FUNC(row_changed), model); } model->row = row; model->model_col = model_col; return model; } 835e298'>root/net/mpd
Commit message (Expand)AuthorAgeFilesLines
* Reassign ports from archie@ back to pool at his request.linimon2006-11-261-1/+1
* - Fix @dirrm %%DOCSDIR%% linesem2006-04-181-1/+1
* Remove the FreeBSD KEYWORD from all rc.d scripts where it appears.dougb2006-02-211-1/+0
* Some fixes to the rc.d startup script.archie2006-02-201-2/+2
* SHA256ifyedwin2006-01-231-0/+2
* Now that new style rc.d scripts are being run as part of thedougb2006-01-072-2/+2
* Pacify distfile survey by following redirects on URLs.linimon2005-10-131-1/+1
* Bump PORTREVISION after bug fix.archie2005-10-021-1/+1
* Fix segfault on AMD64.archie2005-10-023-0/+125
* Make this port rcNG compliant.archie2005-02-153-35/+31
* Pass COPTS to make.archie2004-11-051-8/+4
* Revert revision 1.38; putting back USE_OPENSSL=yes solved that problem.archie2004-08-081-2/+2
* Implement ports/70073.archie2004-08-072-59/+59
* Put back USE_OPENSSL=yes.archie2004-08-061-1/+2
* Bump PORTREVISION for previous commit.archie2004-08-051-0/+1
* Fix incorrect default config file directory.archie2004-08-051-2/+2
* Try to make things work rationally with either OpenSSL (base or ports).archie2004-08-031-1/+11
* Use DIST_SUBDIR= to avoid conflict with "audio/musicpd" port.archie2004-07-052-1/+2
* Limit to 24 lines.archie2004-07-051-2/+1
* Update to version 3.18; this also fixes build failure on -current.archie2004-05-053-20/+2
* Create /usr/local/etc/rc.d if it doesn't already exist.archie2004-04-161-0/+4
* Include patch that fixes ports/62477.archie2004-04-142-0/+18
* Update to version 3.17.archie2004-03-122-2/+2
* Upgrade to version 3.16.archie2004-01-063-3/+4
* Add sample startup script.archie2003-11-233-0/+42
* Update to version 3.15.archie2003-11-102-2/+2
* Fix build when openssl is not installed on the system already.archie2003-09-041-0/+3
* Update to version 3.14.archie2003-08-114-3/+6
* Clear moonlight beckons.ade2003-03-072-1/+1
* Update to version 3.13.archie2003-03-062-2/+2
* Oops, used the wrong MD5 checksum in previous checkin (five minutes ago).archie2003-02-111-1/+1
* Update to version 3.12. This fixes a bug in 3.11 in client-sidearchie2003-02-112-2/+2
* Update to version 3.11.archie2003-02-064-2/+5
* Update to version 3.10.archie2002-10-243-2/+4
* Update to version 3.9.archie2002-09-052-2/+2
* Upgrade to version 3.8.archie2002-05-042-2/+2
* Remove patches left over from the old mpd port.archie2002-04-022-35/+0
* The original "net/mpd" port is obsolete. Update it to make it equivalentarchie2002-03-305-14/+11
* Add NO_LATEST_LINK=.archie2001-11-081-0/+1
* Move the stragler's www.freebsd.org/~user distfiles to the officalobrien2000-06-291-1/+2
* Update master site.archie2000-05-111-1/+1