Commit 29f16cc6 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

New files. Implement GtkTreeModelMapping.

2001-02-16  Alexander Larsson  <alexl@redhat.com>

	* gtk/gtktreemodelmapping.[ch]:
	New files. Implement GtkTreeModelMapping.

	* gtk/Makefile.am:
	Add gtktreemodelmapping.[ch].

	* gtk/gtk.h:
	Add gtktreemodelmapping.h

	* gtk/treestoretest.c:
	Test the GtkTreeModelMapping
parent 1c31afa0
2001-02-16 Alexander Larsson <alexl@redhat.com>
* gtk/gtktreemodelmapping.[ch]:
New files. Implement GtkTreeModelMapping.
* gtk/Makefile.am:
Add gtktreemodelmapping.[ch].
* gtk/gtk.h:
Add gtktreemodelmapping.h
* gtk/treestoretest.c:
Test the GtkTreeModelMapping
Tue Feb 13 13:16:09 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/panes.c (create_pane_options): If we're going to
......
2001-02-16 Alexander Larsson <alexl@redhat.com>
* gtk/gtktreemodelmapping.[ch]:
New files. Implement GtkTreeModelMapping.
* gtk/Makefile.am:
Add gtktreemodelmapping.[ch].
* gtk/gtk.h:
Add gtktreemodelmapping.h
* gtk/treestoretest.c:
Test the GtkTreeModelMapping
Tue Feb 13 13:16:09 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/panes.c (create_pane_options): If we're going to
......
2001-02-16 Alexander Larsson <alexl@redhat.com>
* gtk/gtktreemodelmapping.[ch]:
New files. Implement GtkTreeModelMapping.
* gtk/Makefile.am:
Add gtktreemodelmapping.[ch].
* gtk/gtk.h:
Add gtktreemodelmapping.h
* gtk/treestoretest.c:
Test the GtkTreeModelMapping
Tue Feb 13 13:16:09 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/panes.c (create_pane_options): If we're going to
......
2001-02-16 Alexander Larsson <alexl@redhat.com>
* gtk/gtktreemodelmapping.[ch]:
New files. Implement GtkTreeModelMapping.
* gtk/Makefile.am:
Add gtktreemodelmapping.[ch].
* gtk/gtk.h:
Add gtktreemodelmapping.h
* gtk/treestoretest.c:
Test the GtkTreeModelMapping
Tue Feb 13 13:16:09 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/panes.c (create_pane_options): If we're going to
......
2001-02-16 Alexander Larsson <alexl@redhat.com>
* gtk/gtktreemodelmapping.[ch]:
New files. Implement GtkTreeModelMapping.
* gtk/Makefile.am:
Add gtktreemodelmapping.[ch].
* gtk/gtk.h:
Add gtktreemodelmapping.h
* gtk/treestoretest.c:
Test the GtkTreeModelMapping
Tue Feb 13 13:16:09 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/panes.c (create_pane_options): If we're going to
......
2001-02-16 Alexander Larsson <alexl@redhat.com>
* gtk/gtktreemodelmapping.[ch]:
New files. Implement GtkTreeModelMapping.
* gtk/Makefile.am:
Add gtktreemodelmapping.[ch].
* gtk/gtk.h:
Add gtktreemodelmapping.h
* gtk/treestoretest.c:
Test the GtkTreeModelMapping
Tue Feb 13 13:16:09 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/panes.c (create_pane_options): If we're going to
......
2001-02-16 Alexander Larsson <alexl@redhat.com>
* gtk/gtktreemodelmapping.[ch]:
New files. Implement GtkTreeModelMapping.
* gtk/Makefile.am:
Add gtktreemodelmapping.[ch].
* gtk/gtk.h:
Add gtktreemodelmapping.h
* gtk/treestoretest.c:
Test the GtkTreeModelMapping
Tue Feb 13 13:16:09 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/panes.c (create_pane_options): If we're going to
......
......@@ -175,6 +175,7 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
gtktreemodel.h \
gtktreemodelsimple.h \
gtktreemodelsort.h \
gtktreemodelmapping.h \
gtktreeselection.h \
gtktreesortable.h \
gtktreestore.h \
......@@ -342,6 +343,7 @@ gtk_c_sources = @STRIP_BEGIN@ \
gtktreemodel.c \
gtktreemodelsimple.c \
gtktreemodelsort.c \
gtktreemodelmapping.c \
gtktreeselection.c \
gtktreestore.c \
gtktreeview.c \
......
......@@ -144,6 +144,7 @@
#include <gtk/gtktreemodel.h>
#include <gtk/gtktreemodelsimple.h>
#include <gtk/gtktreemodelsort.h>
#include <gtk/gtktreemodelmapping.h>
#include <gtk/gtktreeselection.h>
#include <gtk/gtktreestore.h>
#include <gtk/gtktreeview.h>
......
This diff is collapsed.
/* gtktreemodelmapping.h
* Copyright (C) 2000 Red Hat, Inc., Alexander Larsson <alexl@redhat.com>
*
* 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 __GTK_TREE_MODEL_MAPPING_H__
#define __GTK_TREE_MODEL_MAPPING_H__
#include <gtk/gtktreemodel.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GTK_TYPE_TREE_MODEL_MAPPING (gtk_tree_model_mapping_get_type ())
#define GTK_TREE_MODEL_MAPPING(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TREE_MODEL_MAPPING, GtkTreeModelMapping))
#define GTK_TREE_MODEL_MAPPING_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TREE_MODEL_MAPPING, GtkTreeModelMappingClass))
#define GTK_IS_TREE_MODEL_MAPPING(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TREE_MODEL_MAPPING))
#define GTK_IS_TREE_MODEL_MAPPING_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GTK_TYPE_TREE_MODEL_MAPPING))
typedef struct _GtkTreeModelMapping GtkTreeModelMapping;
typedef struct _GtkTreeModelMappingClass GtkTreeModelMappingClass;
typedef struct _GtkTreeModelMappingMap GtkTreeModelMappingMap;
typedef void (* GValueMapFunc) (const GValue *a,
GValue *b,
gpointer user_data);
struct _GtkTreeModelMappingMap
{
gint src_column;
GType col_type;
GValueMapFunc map_func;
gpointer user_data;
};
struct _GtkTreeModelMapping
{
GtkObject parent;
/* < private > */
GtkTreeModel *child_model;
gint n_columns;
GtkTreeModelMappingMap *column_maps;
};
struct _GtkTreeModelMappingClass
{
GtkObjectClass parent_class;
/* signals */
/* Will be moved into the GtkTreeModelIface eventually */
void (* changed) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* inserted) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* child_toggled) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* deleted) (GtkTreeModel *tree_model,
GtkTreePath *path);
};
GtkType gtk_tree_model_mapping_get_type (void);
GtkTreeModel *gtk_tree_model_mapping_new (void);
GtkTreeModel *gtk_tree_model_mapping_new_with_model (GtkTreeModel *child_model);
void gtk_tree_model_mapping_set_n_columns (GtkTreeModelMapping *tree_model_mapping,
gint n_columns);
void gtk_tree_model_mapping_set_column_mapping (GtkTreeModelMapping *tree_model_mapping,
gint column,
gint src_column,
GType col_type,
GValueMapFunc map_func,
gpointer user_data);
void gtk_tree_model_mapping_set_model (GtkTreeModelMapping *tree_model_mapping,
GtkTreeModel *child_model);
GtkTreeModel *gtk_tree_model_mapping_get_model (GtkTreeModelMapping *tree_model);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_TREE_MODEL_MAPPING_H__ */
......@@ -201,7 +201,20 @@ iter_append (GtkWidget *button, GtkTreeView *tree_view)
}
static void
make_window (gboolean use_sort)
uppercase_value (const GValue *src, GValue *dest, gpointer data)
{
gchar *str;
g_value_init (dest, G_TYPE_STRING);
str = g_strdup (g_value_get_string (src));
if (str)
g_strup (str);
g_value_set_string (dest, str);
g_free (str);
}
static void
make_window (gint view_type)
{
GtkWidget *window;
GtkWidget *vbox;
......@@ -215,26 +228,61 @@ make_window (gboolean use_sort)
/* Make the Widgets/Objects */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
if (use_sort)
gtk_window_set_title (GTK_WINDOW (window), "Sorted list");
else
gtk_window_set_title (GTK_WINDOW (window), "Unsorted list");
switch (view_type)
{
case 0:
gtk_window_set_title (GTK_WINDOW (window), "Unsorted list");
break;
case 1:
gtk_window_set_title (GTK_WINDOW (window), "Sorted list");
break;
case 2:
gtk_window_set_title (GTK_WINDOW (window), "Uppercase flipped list");
break;
}
vbox = gtk_vbox_new (FALSE, 8);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 350);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
if (use_sort)
{
GtkTreeModel *sort_model;
sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (base_model),
NULL, 1);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (sort_model));
}
else
switch (view_type)
{
case 0:
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (base_model));
break;
case 1:
{
GtkTreeModel *sort_model;
sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (base_model),
NULL, 1);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (sort_model));
}
break;
case 2:
{
GtkTreeModel *map_model;
map_model = gtk_tree_model_mapping_new_with_model (GTK_TREE_MODEL (base_model));
gtk_tree_model_mapping_set_n_columns (GTK_TREE_MODEL_MAPPING (map_model), 2);
gtk_tree_model_mapping_set_column_mapping (GTK_TREE_MODEL_MAPPING (map_model),
0,
1,
G_TYPE_STRING,
uppercase_value,
NULL);
gtk_tree_model_mapping_set_column_mapping (GTK_TREE_MODEL_MAPPING (map_model),
1,
0,
G_TYPE_STRING,
uppercase_value,
NULL);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (map_model));
}
break;
}
selection = GTK_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)));
......@@ -305,7 +353,7 @@ make_window (gboolean use_sort)
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
/* A few to start */
if (!use_sort)
if (view_type == 0)
{
iter_append (NULL, GTK_TREE_VIEW (tree_view));
iter_append (NULL, GTK_TREE_VIEW (tree_view));
......@@ -326,10 +374,12 @@ main (int argc, char *argv[])
base_model = gtk_tree_store_new_with_types (2, G_TYPE_STRING, G_TYPE_STRING);
/* FIXME: reverse this */
make_window (FALSE);
make_window (TRUE);
make_window (0);
make_window (1);
make_window (2);
gtk_main ();
return 0;
}
......@@ -201,7 +201,20 @@ iter_append (GtkWidget *button, GtkTreeView *tree_view)
}
static void
make_window (gboolean use_sort)
uppercase_value (const GValue *src, GValue *dest, gpointer data)
{
gchar *str;
g_value_init (dest, G_TYPE_STRING);
str = g_strdup (g_value_get_string (src));
if (str)
g_strup (str);
g_value_set_string (dest, str);
g_free (str);
}
static void
make_window (gint view_type)
{
GtkWidget *window;
GtkWidget *vbox;
......@@ -215,26 +228,61 @@ make_window (gboolean use_sort)
/* Make the Widgets/Objects */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
if (use_sort)
gtk_window_set_title (GTK_WINDOW (window), "Sorted list");
else
gtk_window_set_title (GTK_WINDOW (window), "Unsorted list");
switch (view_type)
{
case 0:
gtk_window_set_title (GTK_WINDOW (window), "Unsorted list");
break;
case 1:
gtk_window_set_title (GTK_WINDOW (window), "Sorted list");
break;
case 2:
gtk_window_set_title (GTK_WINDOW (window), "Uppercase flipped list");
break;
}
vbox = gtk_vbox_new (FALSE, 8);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 350);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
if (use_sort)
{
GtkTreeModel *sort_model;
sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (base_model),
NULL, 1);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (sort_model));
}
else
switch (view_type)
{
case 0:
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (base_model));
break;
case 1:
{
GtkTreeModel *sort_model;
sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (base_model),
NULL, 1);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (sort_model));
}
break;
case 2:
{
GtkTreeModel *map_model;
map_model = gtk_tree_model_mapping_new_with_model (GTK_TREE_MODEL (base_model));
gtk_tree_model_mapping_set_n_columns (GTK_TREE_MODEL_MAPPING (map_model), 2);
gtk_tree_model_mapping_set_column_mapping (GTK_TREE_MODEL_MAPPING (map_model),
0,
1,
G_TYPE_STRING,
uppercase_value,
NULL);
gtk_tree_model_mapping_set_column_mapping (GTK_TREE_MODEL_MAPPING (map_model),
1,
0,
G_TYPE_STRING,
uppercase_value,
NULL);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (map_model));
}
break;
}
selection = GTK_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)));
......@@ -305,7 +353,7 @@ make_window (gboolean use_sort)
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
/* A few to start */
if (!use_sort)
if (view_type == 0)
{
iter_append (NULL, GTK_TREE_VIEW (tree_view));
iter_append (NULL, GTK_TREE_VIEW (tree_view));
......@@ -326,10 +374,12 @@ main (int argc, char *argv[])
base_model = gtk_tree_store_new_with_types (2, G_TYPE_STRING, G_TYPE_STRING);
/* FIXME: reverse this */
make_window (FALSE);
make_window (TRUE);
make_window (0);
make_window (1);
make_window (2);
gtk_main ();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment