/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * e-reflow-model.c * Copyright 2000, 2001, Ximian, Inc. * * Authors: * Chris Lahey * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License, version 2, as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library 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 #include "e-reflow-model.h" #include #include "gal/util/e-util.h" #define ERM_CLASS(e) ((EReflowModelClass *)((GtkObject *)e)->klass) #define PARENT_TYPE gtk_object_get_type () #define d(x) d(static gint depth = 0;) static GtkObjectClass *e_reflow_model_parent_class; enum { MODEL_CHANGED, MODEL_ITEMS_INSERTED, MODEL_ITEM_CHANGED, LAST_SIGNAL }; static guint e_reflow_model_signals [LAST_SIGNAL] = { 0, }; /** * e_reflow_model_set_width: * @e_reflow_model: The e-reflow-model to operate on * @width: The new value for the width of each item. */ void e_reflow_model_set_width (EReflowModel *e_reflow_model, int width) { g_return_if_fail (e_reflow_model != NULL); g_return_if_fail (E_IS_REFLOW_MODEL (e_reflow_model)); ERM_CLASS (e_reflow_model)->set_width (e_reflow_model, width); } /** * e_reflow_model_count: * @e_reflow_model: The e-reflow-model to operate on * * Returns: the number of items in the reflow model. */ int e_reflow_model_count (EReflowModel *e_reflow_model) { g_return_val_if_fail (e_reflow_model != NULL, 0); g_return_val_if_fail (E_IS_REFLOW_MODEL (e_reflow_model), 0); return ERM_CLASS (e_reflow_model)->count (e_reflow_model); } /** * e_reflow_model_height: * @e_reflow_model: The e-reflow-model to operate on * @n: The item number to get the height of. * @parent: The parent GnomeCanvasItem. * * Returns: the height of the nth item. */ int e_reflow_model_height (EReflowModel *e_reflow_model, int n, GnomeCanvasGroup *parent) { g_return_val_if_fail (e_reflow_model != NULL, 0); g_return_val_if_fail (E_IS_REFLOW_MODEL (e_reflow_model), 0); return ERM_CLASS (e_reflow_model)->height (e_reflow_model, n, parent); } /** * e_reflow_model_incarnate: * @e_reflow_model: The e-reflow-model to operate on * @n: The item to create. * @parent: The parent GnomeCanvasItem to create a child of. * * Create a GnomeCanvasItem to represent the nth piece of data. * * Returns: the new GnomeCanvasItem. */ GnomeCanvasItem * e_reflow_model_incarnate (EReflowModel *e_reflow_model, int n, GnomeCanvasGroup *parent) { g_return_val_if_fail (e_reflow_model != NULL, NULL); g_return_val_if_fail (E_IS_REFLOW_MODEL (e_reflow_model), NULL); return ERM_CLASS (e_reflow_model)->incarnate (e_reflow_model, n, parent); } /** * e_reflow_model_compare: * @e_reflow_model: The e-reflow-model to operate on * @n1: The first item to compare * @n2: The second item to compare * * Compares item n1 and item n2 to see which should come first. * * Returns: strcmp like semantics for the comparison value. */ int e_reflow_model_compare (EReflowModel *e_reflow_model, int n1, int n2) { #if 0 g_return_val_if_fail (e_reflow_model != NULL, 0); g_return_val_if_fail (E_IS_REFLOW_MODEL (e_reflow_model), 0); #endif return ERM_CLASS (e_reflow_model)->compare (e_reflow_model, n1, n2); } /** * e_reflow_model_reincarnate: * @e_reflow_model: The e-reflow-model to operate on * @n: The item to create. * @item: The item to reuse. * * Update item to represent the nth piece of data. */ void e_reflow_model_reincarnate (EReflowModel *e_reflow_model, int n, GnomeCanvasItem *item) { g_return_if_fail (e_reflow_model != NULL); g_return_if_fail (E_IS_REFLOW_MODEL (e_reflow_model)); ERM_CLASS (e_reflow_model)->reincarnate (e_reflow_model, n, item); } static void e_reflow_model_class_init (GtkObjectClass *object_class) { EReflowModelClass *klass = E_REFLOW_MODEL_CLASS(object_class); e_reflow_model_parent_class = gtk_type_class (PARENT_TYPE); e_reflow_model_signals [MODEL_CHANGED] = gtk_signal_new ("model_changed", GTK_RUN_LAST, E_OBJECT_CLASS_TYPE (object_class), GTK_SIGNAL_OFFSET (EReflowModelClass, model_changed), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); e_reflow_model_signals [MODEL_ITEMS_INSERTED] = gtk_signal_new ("model_items_inserted", GTK_RUN_LAST, E_OBJECT_CLASS_TYPE (object_class), GTK_SIGNAL_OFFSET (EReflowModelClass, model_items_inserted), gtk_marshal_NONE__INT_INT, GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); e_reflow_model_signals [MODEL_ITEM_CHANGED] = gtk_signal_new ("model_item_changed", GTK_RUN_LAST, E_OBJECT_CLASS_TYPE (object_class), GTK_SIGNAL_OFFSET (EReflowModelClass, model_item_changed), gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT); E_OBJECT_CLASS_ADD_SIGNALS (object_class, e_reflow_model_signals, LAST_SIGNAL); klass->set_width = NULL; klass->count = NULL; klass->height = NULL; klass->incarnate = NULL; klass->reincarnate = NULL; klass->model_changed = NULL; klass->model_items_inserted = NULL; klass->model_item_changed = NULL; } guint e_reflow_model_get_type (void) { static guint type = 0; if (!type) { GtkTypeInfo info = { "EReflowModel", sizeof (EReflowModel), sizeof (EReflowModelClass), (GtkClassInitFunc) e_reflow_model_class_init, NULL, /* reserved_1 */ NULL, /* reserved_2 */ NULL, (GtkClassInitFunc) NULL, }; type = gtk_type_unique (PARENT_TYPE, &info); } return type; } #if d(!)0 static void print_tabs (void) { int i; for (i = 0; i < depth; i++) g_print("\t"); } #endif /** * e_reflow_model_changed: * @e_reflow_model: the reflow model to notify of the change * * Use this function to notify any views of this reflow model that * the contents of the reflow model have changed. This will emit * the signal "model_changed" on the @e_reflow_model object. * * It is preferable to use the e_reflow_model_item_changed() signal to * notify of smaller changes than to invalidate the entire model, as * the views might have ways of caching the information they render * from the model. */ void e_reflow_model_changed (EReflowModel *e_reflow_model) { g_return_if_fail (e_reflow_model != NULL); g_return_if_fail (E_IS_REFLOW_MODEL (e_reflow_model)); d(print_tabs()); d(g_print("Emitting model_changed on model 0x%p.\n", e_reflow_model)); d(depth++); gtk_signal_emit (GTK_OBJECT (e_reflow_model), e_reflow_model_signals [MODEL_CHANGED]); d(depth--); } /** * e_reflow_model_items_inserted: * @e_reflow_model: The model changed. * @position: The position the items were insert in. * @count: The number of items inserted. * * Use this function to notify any views of the reflow model that a number of items have been inserted. **/ void e_reflow_model_items_inserted (EReflowModel *e_reflow_model, int position, int count) { g_return_if_fail (e_reflow_model != NULL); g_return_if_fail (E_IS_REFLOW_MODEL (e_reflow_model)); d(print_tabs()); d(g_print("Emitting items_inserted on model 0x%p, position=%d, count=%d.\n", e_reflow_model, position, count)); d(depth++); gtk_signal_emit (GTK_OBJECT (e_reflow_model), e_reflow_model_signals [MODEL_ITEMS_INSERTED], position, count); d(depth--); } /** * e_reflow_model_item_changed: * @e_reflow_model: the reflow model to notify of the change * @item: the item that was changed in the model. * * Use this function to notify any views of the reflow model that the * contents of item @item have changed in model such that the height * has changed or the item needs to be reincarnated. This function * will emit the "model_item_changed" signal on the @e_reflow_model * object */ void e_reflow_model_item_changed (EReflowModel *e_reflow_model, int n) { g_return_if_fail (e_reflow_model != NULL); g_return_if_fail (E_IS_REFLOW_MODEL (e_reflow_model)); d(print_tabs()); d(g_print("Emitting item_changed on model 0x%p, n=%d.\n", e_reflow_model, n)); d(depth++); gtk_signal_emit (GTK_OBJECT (e_reflow_model), e_reflow_model_signals [MODEL_ITEM_CHANGED], n); d(depth--); } 10-removal&id=abc15cd5f74df466087b5bd4ddee26c0c36bf976'>Chase SeaMonkey's update to 1.1.7.thierry2007-12-042-4/+4 * Update to KDE 3.5.8lofi2007-10-304-8/+98 * Migration from bison 1.x to 2.xade2007-10-171-1/+2 * A theme for pluxml.miwi2007-10-107-0/+74 * Update to 4.0.3. This version fixes a bug, that could cause an endless loopbsam2007-10-041-3/+3 * . update to 4.0.2;bsam2007-10-031-3/+3 * A theme for pluxml.alepulver2007-10-036-0/+60 * Switch autoconf dependencies from 2.53 or 2.59 to 2.61.linimon2007-09-301-2/+2 * - Chase x11-toolkits/pmw renamed to x11-toolkits/py-Pmwrafan2007-09-021-1/+2 * force commit for missed file.tabthorpe2007-08-231-0/+15 * - Update to 0.1.20tabthorpe2007-08-236-63/+24 * Pluxml is a tiny tool to generate blog based on php and xml.thierry2007-08-2213-0/+241 * Upgrade Seamonkey's french language pack to 1.1.4.thierry2007-08-112-4/+4 * Upgrade fr-seamonkey-flp to 1.1.3.thierry2007-08-013-6/+9 * Update to the autotools new world order.ade2007-07-281-2/+3 * This port is a language translation file for devel/eric4.bsam2007-07-263-0/+16 * Those ports will be added soon to the ports tree with more adequate names.bsam2007-07-263-16/+0 * Now we use USE_FORTRAN=yes to use FORTRAN compiler.maho2007-07-141-4/+1 * Now we use USE_FORTRAN=yes to use FORTRAN compiler.maho2007-07-141-4/+1 * Update to KDE 3.5.7 / KOffice 1.6.3lofi2007-07-0415-25/+122 * Chase Aster's version.thierry2007-07-011-3/+3 * Upgrade to 8.7-1.thierry2007-07-013-138/+270 * Upgrade to 9.1.0-1.thierry2007-07-013-121/+1031 * Upgrade to 1.12.0-1.thierry2007-07-013-213/+871 * A sweeping commit: unbreak "make index" if WITH_BASH=YES is defined.bsam2007-06-062-8/+0 * BROKEN with gcc 4.2kris2007-05-271-1/+7 * - Welcome X.org 7.2 \o/.flz2007-05-2020-13/+20 * Chase Grace's move to $LOCALBASE.thierry2007-04-252-6/+6 * Eric is a full featured Python and Ruby editor and IDE, written in python.bsam2007-04-243-0/+16 * - Remove FreeBSD 4.X support from unmaintained ports in categories startinggabor2007-04-161-12/+0 * - Remove old Perl support from unmaintained ports in categories startinggabor2007-04-031-9/+3 * Fix my previous commit: -fdefault-integer-8 and -fdefault-real-8 shouldthierry2007-03-261-5/+7 * Trying to unbreak on 64 bits platforms by forcing integers to INTEGER*8.thierry2007-03-221-5/+5 * - Mark BROKEN on != i386thierry2007-03-151-4/+6 * Update to KDE 3.5.6 / KOffice 1.6.2lofi2007-03-1413-39/+194 * - Bump shlib version to libnetsnmp.so.10 and bump $PORTREVISION.kuriyama2007-02-281-2/+2 * Upgrade Seamonkey's FLP to 1.1.thierry2007-02-073-7/+10 * Fix build after gfortran migration.thierry2007-02-042-16/+16 * Fix plist: since the gfortran migration, some tests are no more installed.thierry2007-01-262-10/+2 * Update to 7.0.9. Various security vulnerabilities have been fixed.hrs2007-01-182-4/+4 * Should not use WITH_FORTRAN.maho2007-01-181-1/+0 * * Migrate to gfortran.maho2007-01-172-28/+28 * forgot to commit. a build fix for gfortran.maho2007-01-171-0/+11 * * Migrate to gfortran.maho2007-01-171-13/+12 * - Fix handling of the rc.d scriptgabor2007-01-143-9/+3 * Update to 9.0.0-2.thierry2007-01-122-4/+4 * 2006-12-01 comms/vpb-driver: leaves files behind on deinstallmiwi2007-01-065-64/+0 * Upgrade seamonkey-flp to 1.0.7.thierry2006-12-302-4/+4 * - Update to 0.1.15miwi2006-12-302-6/+6 * The new tarball has been uploaded to the official site, no need tothierry2006-12-281-3/+1 * - Chase Code_Aster upgrade;thierry2006-12-262-2/+3 * Upgrade to 8.5-1.thierry2006-12-263-63/+135 * Upgrade to 9.0.0-1.thierry2006-12-265-95/+477 * Upgrade to 1.11.0-1.thierry2006-12-263-104/+123 * Update to KDE 3.5.5 / KOffice 1.6.1lofi2006-12-2013-30/+49