]> Pileus Git - ~andy/gtk/blobdiff - tests/testtreeedit.c
Fixes bug #317999:
[~andy/gtk] / tests / testtreeedit.c
index 8303d39fb92eb489f58268b95a09c79664788c50..3c7f21f06c8c2015ceeaa66e5500274e3a646c70 100644 (file)
@@ -1,25 +1,47 @@
+/* testtreeedit.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.
+ */
+
 #include <config.h>
 #include <gtk/gtk.h>
 
 typedef struct {
   const gchar *string;
   gboolean is_editable;
+  gint progress;
 } ListEntry;
 
 enum {
   STRING_COLUMN,
   IS_EDITABLE_COLUMN,
   PIXBUF_COLUMN,
+  PROGRESS_COLUMN,
   NUM_COLUMNS
 };
 
 static ListEntry model_strings[] =
 {
-  {"A simple string", TRUE },
-  {"Another string!", TRUE },
-  {"Guess what, a third string. This one can't be edited", FALSE },
-  {"And then a fourth string. Neither can this", FALSE },
-  {"Multiline\nFun!", TRUE },
+  {"A simple string", TRUE, 0 },
+  {"Another string!", TRUE, 10 },
+  {"Guess what, a third string. This one can't be edited", FALSE, 47 },
+  {"And then a fourth string. Neither can this", FALSE, 48 },
+  {"Multiline\nFun!", TRUE, 75 },
   { NULL }
 };
 
@@ -39,7 +61,8 @@ create_model (void)
   model = gtk_tree_store_new (NUM_COLUMNS,
                              G_TYPE_STRING,
                              G_TYPE_BOOLEAN,
-                             GDK_TYPE_PIXBUF);
+                             GDK_TYPE_PIXBUF,
+                             G_TYPE_INT);
 
   for (i = 0; model_strings[i].string != NULL; i++)
     {
@@ -49,6 +72,7 @@ create_model (void)
                          STRING_COLUMN, model_strings[i].string,
                          IS_EDITABLE_COLUMN, model_strings[i].is_editable,
                          PIXBUF_COLUMN, foo,
+                         PROGRESS_COLUMN, model_strings[i].progress,
                          -1);
     }
   
@@ -116,6 +140,9 @@ main (gint argc, gchar **argv)
   
   gtk_init (&argc, &argv);
 
+  if (g_getenv ("RTL"))
+    gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
+
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (GTK_WINDOW (window), "GtkTreeView editing sample");
   g_signal_connect (window, "destroy", gtk_main_quit, NULL);
@@ -174,6 +201,14 @@ main (gint argc, gchar **argv)
                                               renderer,
                                               "active", IS_EDITABLE_COLUMN,
                                               NULL);
+
+  renderer = gtk_cell_renderer_progress_new ();
+  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+                                              -1, "Progress",
+                                              renderer,
+                                              "value", PROGRESS_COLUMN,
+                                              NULL);
+
   gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
   
   gtk_window_set_default_size (GTK_WINDOW (window),