[maemo-commits] [maemo-commits] r9409 - in projects/haf/trunk/sapwood: . demos demos/images

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Jan 29 14:28:54 EET 2007
Author: tko
Date: 2007-01-29 14:28:50 +0200 (Mon, 29 Jan 2007)
New Revision: 9409

Added:
   projects/haf/trunk/sapwood/demos/images/treeview-active-alone.png
   projects/haf/trunk/sapwood/demos/images/treeview-active-left.png
   projects/haf/trunk/sapwood/demos/images/treeview-active-middle.png
   projects/haf/trunk/sapwood/demos/images/treeview-active-right.png
   projects/haf/trunk/sapwood/demos/images/treeview-active.png
   projects/haf/trunk/sapwood/demos/images/treeview-normal.png
   projects/haf/trunk/sapwood/demos/images/treeview-passive.png
   projects/haf/trunk/sapwood/demos/images/treeview-selected.png
   projects/haf/trunk/sapwood/demos/treeview.c
   projects/haf/trunk/sapwood/demos/treeview.gtkrc
Modified:
   projects/haf/trunk/sapwood/ChangeLog
   projects/haf/trunk/sapwood/demos/Makefile.am
Log:
Example for treeview active / passive focus theming

2007-01-29  Tommi Komulainen  <tommi.komulainen at nokia.com>

	* demos/Makefile.am
	* demos/treeview.c
	* demos/treeview.gtkrc
	* demos/images/treeview-*.png: Example for treeview active / passive
	focus theming


Modified: projects/haf/trunk/sapwood/ChangeLog
===================================================================
--- projects/haf/trunk/sapwood/ChangeLog	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/ChangeLog	2007-01-29 12:28:50 UTC (rev 9409)
@@ -1,5 +1,13 @@
 2007-01-29  Tommi Komulainen  <tommi.komulainen at nokia.com>
 
+	* demos/Makefile.am
+	* demos/treeview.c
+	* demos/treeview.gtkrc
+	* demos/images/treeview-*.png: Example for treeview active / passive
+	focus theming
+
+2007-01-29  Tommi Komulainen  <tommi.komulainen at nokia.com>
+
 	* src/sapwood-draw.c (maybe_check_cursor_position)
 	(draw_flat_box): When painting a treeview check if painting the cursor
 	row, and adjust matching rules accordingly for active/passive focus

Modified: projects/haf/trunk/sapwood/demos/Makefile.am
===================================================================
--- projects/haf/trunk/sapwood/demos/Makefile.am	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/demos/Makefile.am	2007-01-29 12:28:50 UTC (rev 9409)
@@ -1,7 +1,9 @@
 INCLUDES = $(GTK_CFLAGS)
 LDADD = $(GTK_LIBS)
 
-noinst_PROGRAMS = buttonbox
+noinst_PROGRAMS = \
+	buttonbox \
+	treeview
 
 CLEANFILES = engines
 MAINTAINERCLEANFILES = Makefile.in
@@ -14,4 +16,14 @@
 	images/hbbox-tb.png \
 	images/hbbox-tlb.png \
 	images/hbbox-tlbr.png \
+	treeview.c \
+	treeview.gtkrc \
+	images/treeview-active.png \
+	images/treeview-active-alone.png \
+	images/treeview-active-left.png \
+	images/treeview-active-middle.png \
+	images/treeview-active-right.png \
+	images/treeview-normal.png \
+	images/treeview-passive.png \
+	images/treeview-selected.png \
 	run-demo

Added: projects/haf/trunk/sapwood/demos/images/treeview-active-alone.png
===================================================================
--- projects/haf/trunk/sapwood/demos/images/treeview-active-alone.png	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/demos/images/treeview-active-alone.png	2007-01-29 12:28:50 UTC (rev 9409)
@@ -0,0 +1,3 @@
+‰PNG
+
+   
IHDR         
±²   	pHYs     šœ   tIME×%,Ôod   tEXtComment Created with GIMPW   &IDAT×eб
 0ƒ ÿÿì޲t2˜Pt²w ?—U<DéKÓ    IEND®B`‚
\ No newline at end of file

Added: projects/haf/trunk/sapwood/demos/images/treeview-active-left.png
===================================================================
--- projects/haf/trunk/sapwood/demos/images/treeview-active-left.png	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/demos/images/treeview-active-left.png	2007-01-29 12:28:50 UTC (rev 9409)
@@ -0,0 +1,3 @@
+‰PNG
+
+   
IHDR         Áõ   	pHYs     šœ   tIME×!OÕny   tEXtComment Created with GIMPW   !IDAT×Uȱ
 0À0ÓÿS'+QUpÄß{ÃoóÌG4    IEND®B`‚
\ No newline at end of file

Added: projects/haf/trunk/sapwood/demos/images/treeview-active-middle.png
===================================================================
--- projects/haf/trunk/sapwood/demos/images/treeview-active-middle.png	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/demos/images/treeview-active-middle.png	2007-01-29 12:28:50 UTC (rev 9409)
@@ -0,0 +1,3 @@
+‰PNG
+
+   
IHDR         RÝe‚   	pHYs     šœ   tIME×_   tEXtComment Created with GIMPW   IDAT×c```øÏôŸþ  EXoþ    IEND®B`‚
\ No newline at end of file

Added: projects/haf/trunk/sapwood/demos/images/treeview-active-right.png
===================================================================
--- projects/haf/trunk/sapwood/demos/images/treeview-active-right.png	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/demos/images/treeview-active-right.png	2007-01-29 12:28:50 UTC (rev 9409)
@@ -0,0 +1,3 @@
+‰PNG
+
+   
IHDR         €qV¢   	pHYs     šœ   tIME×+¯ ‡g   tEXtComment Created with GIMPW   %IDAT×5˱   „°¼ûgE†*pÂ6°†óQý¾ç¸f
ÿ@!xd    IEND®B`‚
\ No newline at end of file

Added: projects/haf/trunk/sapwood/demos/images/treeview-active.png
===================================================================
--- projects/haf/trunk/sapwood/demos/images/treeview-active.png	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/demos/images/treeview-active.png	2007-01-29 12:28:50 UTC (rev 9409)
@@ -0,0 +1,3 @@
+‰PNG
+
+   
IHDR         wSÞ   	pHYs     šœ   tIME×3!|f{—   tEXtComment Created with GIMPW   IDAT×cøÏÀ   ݍ°    IEND®B`‚
\ No newline at end of file

Added: projects/haf/trunk/sapwood/demos/images/treeview-normal.png
===================================================================
--- projects/haf/trunk/sapwood/demos/images/treeview-normal.png	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/demos/images/treeview-normal.png	2007-01-29 12:28:50 UTC (rev 9409)
@@ -0,0 +1,3 @@
+‰PNG
+
+   
IHDR         wSÞ   	pHYs     šœ   tIME×2/‚ÅgÑ   tEXtComment Created with GIMPW   IDAT×cøÿÿ? þþÜÌYç    IEND®B`‚
\ No newline at end of file

Added: projects/haf/trunk/sapwood/demos/images/treeview-passive.png
===================================================================
--- projects/haf/trunk/sapwood/demos/images/treeview-passive.png	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/demos/images/treeview-passive.png	2007-01-29 12:28:50 UTC (rev 9409)
@@ -0,0 +1,3 @@
+‰PNG
+
+   
IHDR         wSÞ   	pHYs     šœ   tIME×vDG   tEXtComment Created with GIMPW   IDAT×c8ob 
8¶³KÂ    IEND®B`‚
\ No newline at end of file

Added: projects/haf/trunk/sapwood/demos/images/treeview-selected.png
===================================================================
--- projects/haf/trunk/sapwood/demos/images/treeview-selected.png	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/demos/images/treeview-selected.png	2007-01-29 12:28:50 UTC (rev 9409)
@@ -0,0 +1,3 @@
+‰PNG
+
+   
IHDR         wSÞ   	pHYs     šœ   tIME×3-¸{­   tEXtComment Created with GIMPW   IDAT×c`øÏ   ª*ž'    IEND®B`‚
\ No newline at end of file

Added: projects/haf/trunk/sapwood/demos/treeview.c
===================================================================
--- projects/haf/trunk/sapwood/demos/treeview.c	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/demos/treeview.c	2007-01-29 12:28:50 UTC (rev 9409)
@@ -0,0 +1,86 @@
+/*
+ * This file is part of sapwood
+ *
+ * Copyright (C) 2007 Nokia Corporation. 
+ *
+ * Contact: Tommi Komulainen <tommi.komulainen at nokia.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.
+ */
+#include <gtk/gtk.h>
+
+static GtkWidget *
+create_treeview (int n_columns)
+{
+  GtkWidget *treeview;
+  GtkListStore *store;
+  GtkTreeIter iter;
+  GtkTreeSelection *selection;
+  int i;
+
+  store = gtk_list_store_new (1, G_TYPE_STRING);
+  for (i = 0; i < 10; i++)
+    {
+      char buf[128];
+      g_snprintf (buf, sizeof(buf), "Row %d", i+1);
+      gtk_list_store_insert_with_values (store, &iter, -1, 0, buf, -1);
+    }
+
+  treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
+  g_object_unref (store);
+
+  while (n_columns-- > 0)
+    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
+						 -1, "",
+						 gtk_cell_renderer_text_new (),
+						 "text", 0,
+						 NULL);
+
+  gtk_tree_view_set_rubber_banding (GTK_TREE_VIEW (treeview), TRUE);
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+  gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+
+  return treeview;
+}
+
+int
+main (int argc, char **argv)
+{
+  GtkWidget *window;
+  GtkWidget *treeview;
+  GtkWidget *box;
+
+  gtk_rc_add_default_file ("treeview.gtkrc");
+  gtk_init (&argc, &argv);
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  box = gtk_vbox_new (TRUE, 6);
+
+  gtk_container_add (GTK_CONTAINER (window), box);
+  gtk_container_add (GTK_CONTAINER (box), treeview=create_treeview (1));
+  gtk_widget_set_name (treeview, "treeview-without-row-endings");
+  gtk_container_add (GTK_CONTAINER (box), treeview=create_treeview (1));
+  gtk_widget_set_name (treeview, "treeview-with-row-endings");
+  gtk_container_add (GTK_CONTAINER (box), treeview=create_treeview (3));
+  gtk_widget_set_name (treeview, "treeview-with-row-endings");
+
+  gtk_widget_show_all (window);
+
+  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+  gtk_main ();
+
+  return 0;
+}

Added: projects/haf/trunk/sapwood/demos/treeview.gtkrc
===================================================================
--- projects/haf/trunk/sapwood/demos/treeview.gtkrc	2007-01-29 12:24:00 UTC (rev 9408)
+++ projects/haf/trunk/sapwood/demos/treeview.gtkrc	2007-01-29 12:28:50 UTC (rev 9409)
@@ -0,0 +1,151 @@
+#vim: set sts=2 sw=2 ft=gtkrc expandtab:
+pixmap_path "images"
+style "treeview" {
+  engine "sapwood" {
+    image { # selection
+      function = FLAT_BOX
+      state    = SELECTED
+      file     = "treeview-selected.png"
+    }
+    image { # passive focus
+      function = FLAT_BOX
+      state    = ACTIVE
+      shadow   = OUT
+      file     = "treeview-passive.png"
+    }
+    image { # active focus
+      function = FLAT_BOX
+      state    = ACTIVE
+      file     = "treeview-active.png"
+    }
+    image { # normal row background (fallback)
+      function = FLAT_BOX
+      file     = "treeview-normal.png"
+    }
+
+    image { # disable the default focus rectangle
+      function = FOCUS
+    }
+  }
+}
+class "GtkTreeView" style "treeview"
+
+
+# More complicated example about row-ending-details
+# 
+# It's going to get *really* repetitive if you want to take advantage of the
+# possibilities. This is just the bare minimum to have only the active focus
+# look reasonable. 
+style "treeview-with-row-endings" {
+  GtkTreeView::row-ending-details = 1
+  engine "sapwood" {
+    #image {
+    #  function = FLAT_BOX
+    #  detail = %s / %s_start / %s_middle / %s_end
+    #  
+    #  (start, middle, end used only when row-ending-details = 1)
+    #
+    #  %s = "cell_odd_ruled_sorted"
+    #     | "cell_even_ruled_sorted"
+    #     | "cell_odd_ruled"
+    #     | "cell_even_ruled"
+    #     | "cell_odd_sorted"
+    #     | "cell_even_sorted"
+    #     | "cell_odd"
+    #     | "cell_even"
+    #}
+
+    # selection #######################################################
+    image {
+      function = FLAT_BOX
+      state    = SELECTED
+      file     = "treeview-selected.png"
+    }
+    # passive focus ###################################################
+    image {
+      function = FLAT_BOX
+      state    = ACTIVE
+      shadow   = OUT
+      file     = "treeview-passive.png"
+    }
+    # active focus alone ##############################################
+    image {
+      function = FLAT_BOX
+      state    = ACTIVE
+      detail   = "cell_even"
+
+      file     = "treeview-active-alone.png"
+      border   = { 2, 2, 2, 2 }
+    }
+    image {
+      function = FLAT_BOX
+      state    = ACTIVE
+      detail   = "cell_odd"	# <-- the only difference to above
+
+      file     = "treeview-active-alone.png"
+      border   = { 2, 2, 2, 2 }
+    }
+    # active focus left ###############################################
+    image {
+      function = FLAT_BOX
+      state    = ACTIVE
+      detail   = "cell_odd_start"
+
+      file     = "treeview-active-left.png"
+      border   = { 2, 0, 2, 2 }
+    }
+    image {
+      function = FLAT_BOX
+      state    = ACTIVE
+      detail   = "cell_even_start"
+
+      file     = "treeview-active-left.png"
+      border   = { 2, 0, 2, 2 }
+    }
+    # active focus middle #############################################
+    image {
+      function = FLAT_BOX
+      state    = ACTIVE
+      detail   = "cell_even_middle"
+
+      file     = "treeview-active-middle.png"
+      border   = { 0, 0, 1, 1 }
+    }
+    image {
+      function = FLAT_BOX
+      state    = ACTIVE
+      detail   = "cell_odd_middle"
+
+      file     = "treeview-active-middle.png"
+      border   = { 0, 0, 1, 1 }
+    }
+    # active focus right ##############################################
+    image {
+      function = FLAT_BOX
+      state    = ACTIVE
+      detail   = "cell_odd_end"
+
+      file     = "treeview-active-right.png"
+      border   = { 0, 2, 2, 2 }
+    }
+    image {
+      function = FLAT_BOX
+      state    = ACTIVE
+      detail   = "cell_even_end"
+
+      file     = "treeview-active-right.png"
+      border   = { 0, 2, 2, 2 }
+    }
+    # normal row background (fallback) ################################
+    image {
+      function = FLAT_BOX
+      file     = "treeview-normal.png"
+    }
+
+    image { # disable the default focus rectangle
+      function = FOCUS
+    }
+  }
+}
+
+widget "*.treeview-with-row-endings" style "treeview-with-row-endings"


More information about the maemo-commits mailing list