More work - Federico

This commit is contained in:
Arturo Espinosa 1999-10-11 23:45:10 +00:00
parent bfd3af2884
commit ea5eab0a88
15 changed files with 944 additions and 113 deletions

View file

@ -11,12 +11,20 @@ eog_SOURCES = \
commands.h \
cursors.c \
cursors.h \
gnome-icon-list-model.c \
gnome-icon-list-model.h \
gnome-list-item-factory.c \
gnome-list-item-factory.h \
gnome-list-model.c \
gnome-list-model.h \
gnome-list-selection-model.c \
gnome-list-selection-model.h \
gnome-list-view.c \
gnome-list-view.h \
gnome-position-list-model.c \
gnome-position-list-model.h \
gnome-wrap-list.c \
gnome-wrap-list.h \
gtkscrollframe.c \
gtkscrollframe.h \
image.h \

148
src/gnome-icon-list-model.c Normal file
View file

@ -0,0 +1,148 @@
/* GNOME libraries - abstract icon list model
*
* Copyright (C) 1999 The Free Software Foundation
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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 <config.h>
#include <gtk/gtksignal.h>
#include "gnome-icon-list-model.h"
/* Signal IDs */
enum {
GET_ICON,
LAST_SIGNAL
};
static void gnome_icon_list_model_class_init (GnomeIconListModelClass *class);
static void marshal_get_icon (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args);
static guint ilm_signals[LAST_SIGNAL];
/**
* gnome_icon_list_model_get_type:
* @void:
*
* Registers the &GnomeIconListModel class if necessary, and returns the type ID
* associated to it.
*
* Return value: The type ID of the &GnomeIconListModel class.
**/
GtkType
gnome_icon_list_model_get_type (void)
{
static GtkType ilm_type = 0;
if (!ilm_type) {
static const GtkTypeInfo ilm_info = {
"GnomeIconListModel",
sizeof (GnomeIconListModel),
sizeof (GnomeIconListModelClass),
(GtkClassInitFunc) gnome_icon_list_model_class_init,
(GtkObjectInitFunc) NULL,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
};
ilm_type = gtk_type_unique (gnome_list_model_get_type (), &ilm_info);
}
return ilm_type;
}
/* Class initialization function for the abstract icon list model */
static void
gnome_icon_list_model_class_init (GnomeIconListModelClass *class)
{
GtkObjectClass *object_class;
object_class = (GtkObjectClass *) class;
ilm_signals[GET_ICON] =
gtk_signal_new ("get_icon",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GnomeIconListModelClass, get_icon),
marshal_get_icon,
GTK_TYPE_NONE, 3,
GTK_TYPE_UINT,
GTK_TYPE_POINTER,
GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, ilm_signals, LAST_SIGNAL);
}
/* Marshalers */
typedef void (* GetIconFunc) (GtkObject *object, guint n, gpointer pixbuf, gpointer caption,
gpointer data);
static void
marshal_get_icon (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args)
{
GetIconFunc rfunc;
rfunc = (GetIconFunc) func;
(* rfunc) (object, GTK_VALUE_UINT (args[0]), GTK_VALUE_POINTER (args[1]),
GTK_VALUE_POINTER (args[2]), data);
}
/* Exported functions */
/**
* gnome_icon_list_model_get_icon:
* @model: An icon list model.
* @n: Index of item to query.
* @pixbuf: Return value for the icon's image.
* @caption: Return value for the icon's caption.
*
* Queries the image and caption data for an icon in an icon list model.
**/
void
gnome_icon_list_model_get_icon (GnomeIconListModel *model, guint n,
GdkPixBuf **pixbuf, const char **caption)
{
GdkPixBuf *p;
const char *c;
g_return_if_fail (model != NULL);
g_return_if_fail (GNOME_IS_ICON_LIST_MODEL (model));
p = NULL;
c = NULL;
gtk_signal_emit (GTK_OBJECT (model), ilm_signals[GET_ICON],
n, &p, &c);
if (pixbuf)
*pixbuf = p;
if (caption)
*caption = c;
}

View file

@ -0,0 +1,70 @@
/* GNOME libraries - abstract icon list model
*
* Copyright (C) 1999 The Free Software Foundation
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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.
*/
#ifndef GNOME_ICON_LIST_MODEL_H
#define GNOME_ICON_LIST_MODEL_H
#include <libgnome/gnome-defs.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "gnome-list-model.h"
BEGIN_GNOME_DECLS
#define GNOME_TYPE_ICON_LIST_MODEL (gnome_icon_list_model_get_type ())
#define GNOME_ICON_LIST_MODEL(obj) (GTK_CHECK_CAST ((obj), \
GNOME_TYPE_ICON_LIST_MODEL, GnomeIconListModel))
#define GNOME_ICON_LIST_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), \
GNOME_TYPE_ICON_LIST_MODEL, GnomeIconListModelClass))
#define GNOME_IS_ICON_LIST_MODEL(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_ICON_LIST_MODEL))
#define GNOME_IS_ICON_LIST_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), \
GNOME_TYPE_ICON_LIST_MODEL))
typedef struct _GnomeIconListModel GnomeIconListModel;
typedef struct _GnomeIconListModelClass GnomeIconListModelClass;
struct _GnomeIconListModel {
GnomeListModel list_model;
};
struct _GnomeIconListModelClass {
GnomeListModelClass parent_class;
/* Query signals */
void (* get_icon) (GnomeIconListModel *model, guint n,
GdkPixBuf **pixbuf, const char **caption);
};
GtkType gnome_icon_list_model_get_type (void);
void gnome_icon_list_model_get_icon (GnomeIconListModel *model, guint n,
GdkPixBuf **pixbuf, const char **caption);
END_GNOME_DECLS
#endif

View file

@ -4,19 +4,20 @@
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* 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 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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,
* 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 General Public License for more details.
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
* 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 <config.h>

View file

@ -4,19 +4,20 @@
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* 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 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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,
* 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 General Public License for more details.
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
* 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.
*/
#ifndef GNOME_LIST_ITEM_FACTORY_H

View file

@ -4,19 +4,20 @@
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* 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 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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,
* 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 General Public License for more details.
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
* 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 <config.h>

View file

@ -4,19 +4,20 @@
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* 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 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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,
* 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 General Public License for more details.
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
* 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.
*/
#ifndef GNOME_LIST_MODEL_H

View file

@ -4,28 +4,42 @@
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* 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 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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,
* 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 General Public License for more details.
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
* 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 <config.h>
#include <gtk/gtksignal.h>
#include "gnome-list-selection-model.h"
/* Private part of the GnomeListSelectionModel structure */
typedef struct {
/* Whether multiple changes are being done to the selection state */
guint is_adjusting : 1;
} LSMPrivate;
/* Signal IDs */
enum {
CLEAR,
SET_INTERVAL,
ADD_INTERVAL,
REMOVE_INTERVAL,
IS_SELECTED,
GET_MIN_SELECTED,
GET_MAX_SELECTED,
@ -33,22 +47,27 @@ enum {
};
static void gnome_list_selection_model_class_init (GnomeListSelectionModelClass *class);
static void gnome_list_selection_model_init (GnomeListSelectionModel *model);
static void gnome_list_selection_model_destroy (GtkObject *object);
static void marshal_interval (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args);
static void marshal_is_selected (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args);
static void marshal_get_minmax_selected (GtkObject *object, GtkSignalFunc func, gpointer data,
GtkArg *args);
static GnomeListModelClass *parent_class;
static guint lsm_signals[LAST_SIGNAL];
/**
* gnome_list_selection_model_get_type:
* @void:
*
* @void:
*
* Registers the &GnomeListSelectionModel class if necessary, and returns the
* type ID associated to it.
*
*
* Return value: The type ID of the &GnomeListSelectionModel class.
**/
GtkType
@ -62,7 +81,7 @@ gnome_list_selection_model_get_type (void)
sizeof (GnomeListSelectionModel),
sizeof (GnomeListSelectionModelClass),
(GtkClassInitFunc) gnome_list_selection_model_class_init,
(GtkObjectInitFunc) NULL,
(GtkObjectInitFunc) gnome_list_selection_model_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
@ -82,6 +101,42 @@ gnome_list_selection_model_class_init (GnomeListSelectionModelClass *class)
object_class = (GtkObjectClass *) class;
parent_class = gtk_type_class (gnome_list_model_get_type ());
lsm_signals[CLEAR] =
gtk_signal_new ("clear",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GnomeListSelectionModelClass, clear),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
lsm_signals[SET_INTERVAL] =
gtk_signal_new ("set_interval",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GnomeListSelectionModelClass, set_interval),
marshal_interval,
GTK_TYPE_NONE, 2,
GTK_TYPE_UINT,
GTK_TYPE_UINT);
lsm_signals[ADD_INTERVAL] =
gtk_signal_new ("add_interval",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GnomeListSelectionModelClass, add_interval),
marshal_interval,
GTK_TYPE_NONE, 2,
GTK_TYPE_UINT,
GTK_TYPE_UINT);
lsm_signals[REMOVE_INTERVAL] =
gtk_signal_new ("remove_interval",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GnomeListSelectionModelClass, remove_interval),
marshal_interval,
GTK_TYPE_NONE, 2,
GTK_TYPE_UINT,
GTK_TYPE_UINT);
lsm_signals[IS_SELECTED] =
gtk_signal_new ("is_selected",
GTK_RUN_LAST,
@ -106,12 +161,54 @@ gnome_list_selection_model_class_init (GnomeListSelectionModelClass *class)
GTK_TYPE_INT, 0);
gtk_object_class_add_signals (object_class, lsm_signals, LAST_SIGNAL);
object_class->destroy = gnome_list_selection_model_destroy;
}
/* Object initialization function for the abstract list selection model */
static void
gnome_list_selection_model_init (GnomeListSelectionModel *model)
{
LSMPrivate *priv;
priv = g_new0 (LSMPrivate, 1);
model->priv = priv;
}
/* Destroy handler for the abstract list selection model */
static void
gnome_list_selection_model_destroy (GtkObject *object)
{
GnomeListSelectionModel *model;
LSMPrivate *priv;
g_return_if_fail (object != NULL);
g_return_if_fail (GNOME_IS_LIST_SELECTION_MODEL (object));
model = GNOME_LIST_SELECTION_MODEL (object);
priv = model->priv;
g_free (priv);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
/* Marshalers */
typedef void (* IntervalFunc) (GtkObject *object, guint start, guint length, gpointer data);
static void
marshal_interval (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args)
{
IntervalFunc rfunc;
rfunc = (IntervalFunc) func;
(* rfunc) (object, GTK_VALUE_UINT (args[0]), GTK_VALUE_UINT (args[1]), data);
}
typedef gboolean (* IsSelectedFunc) (GtkObject *object, guint n, gpointer data);
static void
@ -131,7 +228,7 @@ static void
marshal_get_minmax_selected (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args)
{
GetMinMaxSelectedFunc rfunc;
gint retval;
gint *retval;
retval = GTK_RETLOC_INT (args[0]);
rfunc = (GetMinMaxSelectedFunc) func;
@ -146,9 +243,9 @@ marshal_get_minmax_selected (GtkObject *object, GtkSignalFunc func, gpointer dat
* gnome_list_selection_model_is_selected:
* @model: A list selection model.
* @n: Index of item to query.
*
*
* Queries whether a particular item in a list selection model is selected.
*
*
* Return value: TRUE if the specified item is selected, FALSE otherwise.
**/
gboolean
@ -158,7 +255,7 @@ gnome_list_selection_model_is_selected (GnomeListSelectionModel *model, guint n)
g_return_val_if_fail (model != NULL, FALSE);
g_return_val_if_fail (GNOME_IS_LIST_SELECTION_MODEL (model), FALSE);
g_return_val_if_fail (n < gnome_list_model_get_length (GNOME_LIST_MODEL (model)));
g_return_val_if_fail (n < gnome_list_model_get_length (GNOME_LIST_MODEL (model)), FALSE);
retval = FALSE;
gtk_signal_emit (GTK_OBJECT (model), lsm_signals[IS_SELECTED], n, &retval);
@ -168,9 +265,9 @@ gnome_list_selection_model_is_selected (GnomeListSelectionModel *model, guint n)
/**
* gnome_list_selection_model_get_min_selected:
* @model: A list selection model.
*
*
* Queries the first selected index of the items in a list selection model.
*
*
* Return value: The first selected index or -1 if the selection is empty.
**/
gint
@ -189,9 +286,9 @@ gnome_list_selection_model_get_min_selected (GnomeListSelectionModel *model)
/**
* gnome_list_selection_model_get_max_selected:
* @model: A list selection model.
*
*
* Queries the last selected index of the items in a list selection model.
*
*
* Return value: The last selected index or -1 if the selection is empty.
**/
gint
@ -206,3 +303,116 @@ gnome_list_selection_model_get_max_selected (GnomeListSelectionModel *model)
gtk_signal_emit (GTK_OBJECT (model), lsm_signals[GET_MAX_SELECTED], &retval);
return retval;
}
/**
* gnome_list_selection_model_set_is_adjusting:
* @model: A list selection model.
* @is_adjusting: New value of the is_adjusting property.
*
* A list selection model can be said to be adjusting if multiple changes are
* being made to the selection status, for example, if the user is rubberbanding
* with the mouse and items are being changed continuously. Clients can use
* this flag to determine when to actually update their state based on the
* selection value; if it is TRUE, they may prefer to wait until the selection
* status obtains its final value.
**/
void
gnome_list_selection_model_set_is_adjusting (GnomeListSelectionModel *model, gboolean is_adjusting)
{
LSMPrivate *priv;
g_return_if_fail (model != NULL);
g_return_if_fail (GNOME_IS_LIST_SELECTION_MODEL (model));
priv = model->priv;
priv->is_adjusting = is_adjusting ? TRUE : FALSE;
}
/**
* gnome_list_selection_model_get_is_adjusting:
* @model: A list selection model.
*
* Queries whether a list selection model's status is being changed
* continuously.
*
* Return value: TRUE if clients can ignore changes to the selection status,
* since they may be transitory, or FALSE if they should consider the selection
* status to be final.
**/
gboolean
gnome_list_selection_model_get_is_adjusting (GnomeListSelectionModel *model)
{
LSMPrivate *priv;
g_return_val_if_fail (model != NULL, FALSE);
g_return_val_if_fail (GNOME_IS_LIST_SELECTION_MODEL (model), FALSE);
priv = model->priv;
return priv->is_adjusting;
}
/**
* gnome_list_selection_model_clear:
* @model: A list selection model.
*
* Tells a list selection model to unselect all the items.
**/
void
gnome_list_selection_model_clear (GnomeListSelectionModel *model)
{
g_return_if_fail (model != NULL);
g_return_if_fail (GNOME_IS_LIST_SELECTION_MODEL (model));
gtk_signal_emit (GTK_OBJECT (model), lsm_signals[CLEAR]);
}
/**
* gnome_list_selection_model_set_interval:
* @model: A list selection model.
* @start: First item to select.
* @length: Number of items to select.
*
* Changes the selection of a list selection model to the specified interval.
**/
void
gnome_list_selection_model_set_interval (GnomeListSelectionModel *model, guint start, guint length)
{
g_return_if_fail (model != NULL);
g_return_if_fail (GNOME_IS_LIST_SELECTION_MODEL (model));
gtk_signal_emit (GTK_OBJECT (model), lsm_signals[SET_INTERVAL], start, length);
}
/**
* gnome_list_selection_model_add_interval:
* @model: A list selection model.
* @start: First item to add to the selection.
* @length: Number of items to add to the selection.
*
* Adds the specified interval to the selection in a list selection model.
**/
void
gnome_list_selection_model_add_interval (GnomeListSelectionModel *model, guint start, guint length)
{
g_return_if_fail (model != NULL);
g_return_if_fail (GNOME_IS_LIST_SELECTION_MODEL (model));
gtk_signal_emit (GTK_OBJECT (model), lsm_signals[ADD_INTERVAL], start, length);
}
/**
* gnome_list_selection_model_remove_interval:
* @model: A list selection model.
* @start: First item to remove from the selection.
* @length: Number of items to remove from the selection.
*
* Removes the specified interval from the selection in a list selection model.
**/
void
gnome_list_selection_model_remove_interval (GnomeListSelectionModel *model, guint start, guint length)
{
g_return_if_fail (model != NULL);
g_return_if_fail (GNOME_IS_LIST_SELECTION_MODEL (model));
gtk_signal_emit (GTK_OBJECT (model), lsm_signals[REMOVE_INTERVAL], start, length);
}

View file

@ -4,19 +4,20 @@
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* 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 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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,
* 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 General Public License for more details.
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
* 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.
*/
#ifndef GNOME_LIST_SELECTION_MODEL_H
@ -47,11 +48,21 @@ typedef struct _GnomeListSelectionModelClass GnomeListSelectionModelClass;
struct _GnomeListSelectionModel {
GnomeListModel list_model;
/* Private data */
gpointer priv;
};
struct _GnomeListSelectionModelClass {
GnomeListModelClass parent_class;
/* Mutation signals */
void (* clear) (GnomeListSelectionModel *model);
void (* set_interval) (GnomeListSelectionModel *model, guint start, guint length);
void (* add_interval) (GnomeListSelectionModel *model, guint start, guint length);
void (* remove_interval) (GnomeListSelectionModel *model, guint start, guint length);
/* Query signals */
gboolean (* is_selected) (GnomeListSelectionModel *model, guint n);
@ -66,6 +77,18 @@ gboolean gnome_list_selection_model_is_selected (GnomeListSelectionModel *model,
gint gnome_list_selection_model_get_min_selected (GnomeListSelectionModel *model);
gint gnome_list_selection_model_get_max_selected (GnomeListSelectionModel *model);
void gnome_list_selection_model_set_is_adjusting (GnomeListSelectionModel *model,
gboolean is_adjusting);
gboolean gnome_list_selection_model_get_is_adjusting (GnomeListSelectionModel *model);
void gnome_list_selection_model_clear (GnomeListSelectionModel *model);
void gnome_list_selection_model_set_interval (GnomeListSelectionModel *model,
guint start, guint length);
void gnome_list_selection_model_add_interval (GnomeListSelectionModel *model,
guint start, guint length);
void gnome_list_selection_model_remove_interval (GnomeListSelectionModel *model,
guint start, guint length);
END_GNOME_DECLS

View file

@ -4,19 +4,20 @@
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* 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 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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,
* 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 General Public License for more details.
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
* 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 <config.h>
@ -31,6 +32,9 @@ typedef struct {
/* The model we are displaying */
GnomeListModel *model;
/* Selection model we are using */
GnomeListSelectionModel *sel_model;
/* The list item factory */
GnomeListItemFactory *factory;
} ListViewPrivate;
@ -40,6 +44,7 @@ typedef struct {
/* Signal IDs */
enum {
SET_MODEL,
SET_SELECTION_MODEL,
SET_LIST_ITEM_FACTORY,
LAST_SIGNAL
};
@ -49,6 +54,7 @@ static void gnome_list_view_init (GnomeListView *view);
static void gnome_list_view_destroy (GtkObject *object);
static void set_model (GnomeListView *view, GnomeListModel *model);
static void set_selection_model (GnomeListView *view, GnomeListSelectionModel *sel_model);
static void set_list_item_factory (GnomeListView *view, GnomeListItemFactory *factory);
static GtkContainerClass *parent_class;
@ -107,6 +113,14 @@ gnome_list_view_class_init (GnomeListViewClass *class)
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
GNOME_TYPE_LIST_MODEL);
list_view_signals[SET_SELECTION_MODEL] =
gtk_signal_new ("set_selection_model",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GnomeListViewClass, set_selection_model),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
GNOME_TYPE_LIST_SELECTION_MODEL);
list_view_signals[SET_LIST_ITEM_FACTORY] =
gtk_signal_new ("set_list_item_factory",
GTK_RUN_FIRST,
@ -121,6 +135,7 @@ gnome_list_view_class_init (GnomeListViewClass *class)
object_class->destroy = gnome_list_view_destroy;
class->set_model = set_model;
class->set_selection_model = set_selection_model;
class->set_list_item_factory = set_list_item_factory;
}
@ -150,6 +165,9 @@ gnome_list_view_destroy (GtkObject *object)
if (priv->model)
gtk_object_unref (GTK_OBJECT (priv->model));
if (priv->sel_model)
gtk_object_unref (GTK_OBJECT (priv->sel_model));
if (priv->factory)
gtk_object_unref (GTK_OBJECT (priv->factory));
@ -190,6 +208,33 @@ set_model (GnomeListView *view, GnomeListModel *model)
/* FIXME: update view */
}
/* Set_selection_model handler for the abstract list view */
static void
set_selection_model (GnomeListView *view, GnomeListSelectionModel *sel_model)
{
ListViewPrivate *priv;
g_return_if_fail (view != NULL);
g_return_if_fail (GNOME_IS_LIST_VIEW (view));
if (sel_model)
g_return_if_fail (GNOME_IS_LIST_SELECTION_MODEL (sel_model));
priv = view->priv;
if (sel_model == priv->sel_model)
return;
if (sel_model)
gtk_object_ref (GTK_OBJECT (sel_model));
if (priv->sel_model)
gtk_object_unref (GTK_OBJECT (priv->sel_model));
priv->sel_model = sel_model;
/* FIXME: update view */
}
/* Set_list_item_factory handler for the abstract list view */
static void
set_list_item_factory (GnomeListView *view, GnomeListItemFactory *factory)
@ -227,7 +272,7 @@ set_list_item_factory (GnomeListView *view, GnomeListItemFactory *factory)
*
* Queries the list model that a list view is displaying.
*
* Return value: the list model.
* Return value: The list model.
**/
GnomeListModel *
gnome_list_view_get_model (GnomeListView *view)
@ -242,6 +287,46 @@ gnome_list_view_get_model (GnomeListView *view)
return priv->model;
}
/**
* gnome_list_view_set_selection_model:
* @view: A list view.
* @sel_model: A list selection model.
*
* Sets the list selection model for a list view.
**/
void
gnome_list_view_set_selection_model (GnomeListView *view, GnomeListSelectionModel *sel_model)
{
g_return_if_fail (view != NULL);
g_return_if_fail (GNOME_IS_LIST_VIEW (view));
if (sel_model)
g_return_if_fail (GNOME_IS_LIST_SELECTION_MODEL (sel_model));
gtk_signal_emit (GTK_OBJECT (view), list_view_signals[SET_SELECTION_MODEL],
sel_model);
}
/**
* gnome_list_view_get_selection_model:
* @view: A list view.
*
* Queries the list selection model that a list view is using.
*
* Return value: The list selection model.
**/
GnomeListSelectionModel *
gnome_list_view_get_selection_model (GnomeListView *view)
{
ListViewPrivate *priv;
g_return_val_if_fail (view != NULL, NULL);
g_return_val_if_fail (GNOME_IS_LIST_VIEW (view), NULL);
priv = view->priv;
return priv->sel_model;
}
/**
* gnome_list_view_get_list_item_factory:
* @view: A list view.

View file

@ -4,19 +4,20 @@
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* 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 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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,
* 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 General Public License for more details.
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
* 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.
*/
#ifndef GNOME_LIST_VIEW_H
@ -25,6 +26,7 @@
#include <libgnome/gnome-defs.h>
#include "gnome-list-item-factory.h"
#include "gnome-list-model.h"
#include "gnome-list-selection-model.h"
BEGIN_GNOME_DECLS
@ -55,6 +57,7 @@ struct _GnomeListViewClass {
GtkContainerClass parent_class;
void (* set_model) (GnomeListView *view, GnomeListModel *model);
void (* set_selection_model) (GnomeListView *view, GnomeListSelectionModel *sel_model);
void (* set_list_item_factory) (GnomeListView *view, GnomeListItemFactory *factory);
};
@ -62,6 +65,10 @@ struct _GnomeListViewClass {
GtkType gnome_list_view_get_type (void);
GnomeListModel *gnome_list_view_get_model (GnomeListView *view);
void gnome_list_view_set_selection_model (GnomeListView *view, GnomeListSelectionModel *sel_model);
GnomeListSelectionModel *gnome_list_view_get_selection_model (GnomeListView *view);
GnomeListItemFactory *gnome_list_view_get_list_item_factory (GnomeListView *view);

View file

@ -0,0 +1,144 @@
/* GNOME libraries - abstract position list model
*
* Copyright (C) 1999 The Free Software Foundation
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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 <config.h>
#include <gtk/gtksignal.h>
#include "gnome-position-list-model.h"
/* Signal IDs */
enum {
GET_POSITION,
LAST_SIGNAL
};
static void gnome_position_list_model_class_init (GnomePositionListModelClass *class);
static void marshal_get_position (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args);
static guint plm_signals[LAST_SIGNAL];
/**
* gnome_position_list_model_get_type:
* @void:
*
* Registers the &GnomePositionListModel class if necessary, and returns the
* type ID associated to it.
*
* Return value: The type ID of the &GnomePositionListModel class.
**/
GtkType
gnome_position_list_model_get_type (void)
{
static GtkType plm_type = 0;
if (!plm_type) {
static const GtkTypeInfo plm_info = {
"GnomePositionListModel",
sizeof (GnomePositionListModel),
sizeof (GnomePositionListModelClass),
(GtkClassInitFunc) gnome_position_list_model_class_init,
(GtkObjectInitFunc) NULL,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
};
plm_type = gtk_type_unique (gnome_list_model_get_type (), &plm_info);
}
return plm_type;
}
/* Class initialization function for the abstract position list model */
static void
gnome_position_list_model_class_init (GnomePositionListModelClass *class)
{
GtkObjectClass *object_class;
object_class = (GtkObjectClass *) class;
plm_signals[GET_POSITION] =
gtk_signal_new ("get_position",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GnomePositionListModelClass, get_position),
marshal_get_position,
GTK_TYPE_NONE, 3,
GTK_TYPE_UINT,
GTK_TYPE_POINTER,
GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, plm_signals, LAST_SIGNAL);
}
/* Marshalers */
typedef void (* GetPositionFunc) (GtkObject *object, guint n, gpointer x, gpointer y, gpointer data);
static void
marshal_get_position (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args)
{
GetPositionFunc rfunc;
rfunc = (GetPositionFunc) func;
(* rfunc) (object, GTK_VALUE_UINT (args[0]), GTK_VALUE_POINTER (args[1]),
GTK_VALUE_POINTER (args[2]), data);
}
/* Exported functions */
/**
* gnome_position_list_model_get_position:
* @model: A position list model.
* @n: Index of item to query.
* @x: Return value for the X coordinate.
* @y: Return value for the Y coordinate.
*
* Queries the coordinate data for a position in a position list model.
**/
void
gnome_position_list_model_get_position (GnomePositionListModel *model, guint n,
gint *x, gint *y)
{
gint rx, ry;
g_return_if_fail (model != NULL);
g_return_if_fail (GNOME_IS_POSITION_LIST_MODEL (model));
rx = ry = 0;
gtk_signal_emit (GTK_OBJECT (model), plm_signals[GET_POSITION], n, &rx, &ry);
if (x)
*x = rx;
if (y)
*y = ry;
}

View file

@ -0,0 +1,69 @@
/* GNOME libraries - abstract position list model
*
* Copyright (C) 1999 The Free Software Foundation
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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.
*/
#ifndef GNOME_POSITION_LIST_MODEL_H
#define GNOME_POSITION_LIST_MODEL_H
#include <libgnome/gnome-defs.h>
#include "gnome-list-model.h"
BEGIN_GNOME_DECLS
#define GNOME_TYPE_POSITION_LIST_MODEL (gnome_position_list_model_get_type ())
#define GNOME_POSITION_LIST_MODEL(obj) (GTK_CHECK_CAST ((obj), \
GNOME_TYPE_POSITION_LIST_MODEL, \
GnomePositionListModel))
#define GNOME_POSITION_LIST_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), \
GNOME_TYPE_POSITION_LIST_MODEL, \
GnomePositionListModelClass))
#define GNOME_IS_POSITION_LIST_MODEL(obj) (GTK_CHECK_TYPE ((obj), \
GNOME_TYPE_POSITION_LIST_MODEL))
#define GNOME_IS_POSITION_LIST_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), \
GNOME_TYPE_POSITION_LIST_MODEL))
typedef struct _GnomePositionListModel GnomePositionListModel;
typedef struct _GnomePositionListModelClass GnomePositionListModelClass;
struct _GnomePositionListModel {
GnomeListModel list_model;
};
struct _GnomePositionListModelClass {
GnomeListModelClass parent_class;
/* Query signals */
void (* get_position) (GnomePositionListModel *model, guint n, gint *x, gint *y);
};
GtkType gnome_position_list_model_get_type (void);
void gnome_position_list_model_get_position (GnomePositionListModel *model, guint n,
gint *x, gint *y);
#endif

View file

@ -4,19 +4,20 @@
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* 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 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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,
* 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 General Public License for more details.
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
* 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 <config.h>
@ -29,6 +30,9 @@ typedef struct {
/* Layout mode */
GnomeWrapListMode mode;
/* Position list model */
GnomePositionListModel *pos_model;
/* Width and height of items */
int item_width;
int item_height;
@ -173,6 +177,60 @@ gnome_wrap_list_get_mode (GnomeWrapList *wlist)
return priv->mode;
}
/**
* gnome_wrap_list_set_position_model:
* @wlist: A wrapped list view.
* @pos_model: A position list model.
*
* sets the position list model for a wrapped list view.
**/
void
gnome_wrap_list_set_position_model (GnomeWrapList *wlist, GnomePositionListModel *pos_model)
{
WrapListPrivate *priv;
g_return_if_fail (wlist != NULL);
g_return_if_fail (GNOME_IS_WRAP_LIST (wlist));
if (pos_model)
g_return_if_fail (GNOME_IS_POSITION_LIST_MODEL (pos_model));
priv = wlist->priv;
if (pos_model == priv->pos_model)
return;
if (pos_model)
gtk_object_ref (GTK_OBJECT (pos_model));
if (priv->pos_model)
gtk_object_unref (GTK_OBJECT (priv->pos_model));
priv->pos_model = pos_model;
/* FIXME: update if necessary */
}
/**
* gnome_wrap_list_get_position_model:
* @wlist: A wrapped list view.
*
* Queries the position list model that a wrapped list view is using.
*
* Return value: The position list model.
**/
GnomePositionListModel *
gnome_wrap_list_get_position_model (GnomeWrapList *wlist)
{
WrapListPrivate *priv;
g_return_val_if_fail (wlist != NULL, NULL);
g_return_val_if_fail (GNOME_IS_WRAP_LIST (wlist), NULL);
priv = wlist->priv;
return priv->pos_model;
}
/**
* gnome_wrap_list_set_item_size:
* @wlist: A wrapped list view.

View file

@ -4,19 +4,20 @@
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* 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 of the License, or
* (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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,
* 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 General Public License for more details.
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
* 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.
*/
#ifndef GNOME_WRAP_LIST_H
@ -24,6 +25,7 @@
#include <libgnome/gnome-defs.h>
#include "gnome-list-view.h"
#include "gnome-position-list-model.h"
BEGIN_GNOME_DECLS
@ -65,6 +67,9 @@ GtkType gnome_wrap_list_get_type (void);
void gnome_wrap_list_set_mode (GnomeWrapList *wlist, GnomeWrapListMode mode);
GnomeWrapListMode gnome_wrap_list_get_mode (GnomeWrapList *wlist);
void gnome_wrap_list_set_position_model (GnomeWrapList *wlist, GnomePositionListModel *pos_model);
GnomePositionListModel *gnome_wrap_list_get_position_model (GnomeWrapList *wlist);
void gnome_wrap_list_set_item_size (GnomeWrapList *wlist, int width, int height);
void gnome_wrap_list_get_item_size (GnomeWrapList *wlist, int *width, int *height);