+/* testtreeview.c
+ * Copyright (C) 2001 Red Hat, Inc
+ * Author: Jonathan Blandford
+ *
+ * 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.
+ */
+
+#undef GTK_DISABLE_DEPRECATED
#include <string.h>
#include "prop-editor.h"
#include <gtk/gtk.h>
-
+#include <stdlib.h>
/* Don't copy this bad example; inline RGB data is always a better
* idea than inline XPMs.
g_type_name (G_TYPE_FROM_INSTANCE (model)));
}
+static void
+edited_callback (GtkCellRendererText *renderer,
+ const gchar *path_string,
+ const gchar *new_text,
+ GtkTreeView *tree_view)
+{
+ GtkTreeModel *model = NULL;
+ GtkTreeModelSort *sort_model = NULL;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ guint value = atoi (new_text);
+
+ g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
+
+ model = gtk_tree_view_get_model (tree_view);
+
+ if (GTK_IS_TREE_MODEL_SORT (model))
+ {
+ sort_model = GTK_TREE_MODEL_SORT (model);
+ model = gtk_tree_model_sort_get_model (sort_model);
+ }
+
+ if (model == NULL)
+ return;
+
+ if (sort_model)
+ {
+ g_warning ("FIXME implement conversion from TreeModelSort iter to child model iter");
+ return;
+ }
+
+ path = gtk_tree_path_new_from_string (path_string);
+ if (!gtk_tree_model_get_iter (model,
+ &iter, path))
+ {
+ g_warning ("%s: bad path?", G_STRLOC);
+ return;
+ }
+ gtk_tree_path_free (path);
+
+ if (GTK_IS_LIST_STORE (model))
+ {
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &iter,
+ 4,
+ value,
+ -1);
+ }
+ else if (GTK_IS_TREE_STORE (model))
+ {
+ gtk_tree_store_set (GTK_TREE_STORE (model),
+ &iter,
+ 4,
+ value,
+ -1);
+ }
+ else
+ g_warning ("don't know how to actually toggle value for model type %s",
+ g_type_name (G_TYPE_FROM_INSTANCE (model)));
+}
static ColumnsType current_column_type = COLUMNS_LOTS;
GtkCellRenderer *rend;
GdkPixbuf *pixbuf;
GtkWidget *image;
-
+ GtkObject *adjustment;
+
current_column_type = type;
col = gtk_tree_view_get_column (tree_view, 0);
/* you could also set this per-row by tying it to a column
* in the model of course.
*/
- g_object_set (G_OBJECT (rend), "radio", TRUE, NULL);
+ g_object_set (rend, "radio", TRUE, NULL);
g_signal_connect (rend, "toggled",
G_CALLBACK (toggled_callback), tree_view);
setup_column (col);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);
-
-#if 0
- rend = gtk_cell_renderer_text_new ();
-
+ rend = gtk_cell_renderer_spin_new ();
+
+ adjustment = gtk_adjustment_new (0, 0, 10000, 100, 100, 100);
+ g_object_set (rend, "editable", TRUE, NULL);
+ g_object_set (rend, "adjustment", adjustment, NULL);
+
+ g_signal_connect (rend, "edited",
+ G_CALLBACK (edited_callback), tree_view);
+
col = gtk_tree_view_column_new_with_attributes ("Column 5",
rend,
- "text", 3,
+ "text", 4,
NULL);
setup_column (col);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), col);
+#if 0
rend = gtk_cell_renderer_text_new ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
+ gtk_window_set_default_size (GTK_WINDOW (window), 430, 400);
table = gtk_table_new (3, 1, FALSE);
if (!model_types_type)
{
- static const GTypeInfo model_types_info =
+ const GTypeInfo model_types_info =
{
sizeof (GtkTreeModelTypesClass),
NULL, /* base_init */
(GInstanceInitFunc) gtk_tree_model_types_init
};
- static const GInterfaceInfo tree_model_info =
+ const GInterfaceInfo tree_model_info =
{
(GInterfaceInitFunc) gtk_tree_model_types_tree_model_init,
NULL,
{
GtkTreeModelTypes *retval;
- retval = GTK_TREE_MODEL_TYPES (g_object_new (GTK_TYPE_MODEL_TYPES, NULL));
+ retval = g_object_new (GTK_TYPE_MODEL_TYPES, NULL);
return retval;
}
g_value_init (value, G_TYPE_STRING);
- str = g_strdup_printf ("%ld", type);
+ str = g_strdup_printf ("%ld", (long int) type);
g_value_set_string (value, str);
g_free (str);
}
if (parent == G_TYPE_INVALID)
{
if (type > G_TYPE_FUNDAMENTAL_MAX)
- g_warning ("no parent for %ld %s\n", type, g_type_name (type));
+ g_warning ("no parent for %ld %s\n",
+ (long int) type,
+ g_type_name (type));
return FALSE;
}
else
* Automated testing
*/
+#if 0
+
static void
treestore_torture_recurse (GtkTreeStore *store,
GtkTreeIter *root,
}
}
+#endif
+
static void
run_automated_tests (void)
{