GtkCList patch



Hi.
	gtk_clist_set_pixmap and gtk_clist_set_pixtext requires to use a mask,
when this is not necesary in most cases. This patch is to allow the mask
argument in these functions to be NULL. If this is the case, it will not
_ref/unref the bitmap mask and will not set the clip_mask to the gc
before drawing the pixmap.

	If you want to test it, you can change in testgtk the line:

   gtk_clist_set_pixtext (GTK_CLIST (data), row, 3, "Testing", 5,
pixmap, mask); 

	to:

   gtk_clist_set_pixtext (GTK_CLIST (data), row, 3, "Testing", 5,
pixmap, NULL); 

	testgtk needs the mask to look right, I sugest the change only to test
this patch, not to be permanent. 

	I hope you find this useful and someone add it to the CVS tree.

	Bye.

P.D.: The patch is against gtkclist.c in the CVS tree today wednesday
11.
-- 
+--------------------------+---------------------------+
|David Abilleira Freijeiro | Pontevedra, España        |
+--------------------------+---------------------------+
|http://members.xoom.com/odaf   (mailto:odaf@nexo.es)  |
|    (UNED, Mis Programas, Linux, Programación, etc.)  |
+------------------------------------------------------+
--- /home/odaf/cvs/gtk+/gtk/gtkclist.c	Wed Feb 11 09:51:37 1998
+++ gtkclist.c	Wed Feb 11 13:27:42 1998
@@ -972,7 +972,9 @@
   clist_row = (g_list_nth (clist->row_list, row))->data;
   
   gdk_pixmap_ref (pixmap);
-  gdk_pixmap_ref (mask);
+  
+  if (mask) gdk_pixmap_ref (mask);
+  
   cell_set_pixmap (clist, clist_row, column, pixmap, mask);
 
   /* redraw the list if it's not frozen */
@@ -1005,9 +1007,11 @@
     return 0;
 
   if (pixmap)
+  {
     *pixmap = GTK_CELL_PIXMAP (clist_row->cell[column])->pixmap;
-  if (mask)
+    // mask can be NULL
     *mask = GTK_CELL_PIXMAP (clist_row->cell[column])->mask;
+  }
 
   return 1;
 }
@@ -1033,7 +1037,7 @@
   clist_row = (g_list_nth (clist->row_list, row))->data;
   
   gdk_pixmap_ref (pixmap);
-  gdk_pixmap_ref (mask);
+  if (mask) gdk_pixmap_ref (mask);
   cell_set_pixtext (clist, clist_row, column, text, spacing, pixmap, mask);
 
   /* redraw the list if it's not frozen */
@@ -1073,8 +1077,9 @@
     *spacing = GTK_CELL_PIXTEXT (clist_row->cell[column])->spacing;
   if (pixmap)
     *pixmap = GTK_CELL_PIXTEXT (clist_row->cell[column])->pixmap;
-  if (mask)
-    *mask = GTK_CELL_PIXTEXT (clist_row->cell[column])->mask;
+
+  // mask can be NULL
+  *mask = GTK_CELL_PIXTEXT (clist_row->cell[column])->mask;
 
   return 1;
 }
@@ -2518,9 +2523,11 @@
 	  ydest = (clip_rectangle.y + (clip_rectangle.height / 2)) - height / 2 +
 	    clist_row->cell[i].vertical;
 
-	  gdk_gc_set_clip_mask (fg_gc, GTK_CELL_PIXMAP (clist_row->cell[i])->mask);
-	  gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
-
+          if (GTK_CELL_PIXMAP (clist_row->cell[i])->mask)
+          {
+              gdk_gc_set_clip_mask (fg_gc, GTK_CELL_PIXMAP (clist_row->cell[i])->mask);
+              gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
+          }
 	  gdk_draw_pixmap (clist->clist_window,
 			   fg_gc,
 			   GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap,
@@ -2529,8 +2536,11 @@
 			   ydest,
 			   pixmap_width, height);
 
-	  gdk_gc_set_clip_origin (fg_gc, 0, 0);
-	  gdk_gc_set_clip_mask (fg_gc, NULL);
+          if (GTK_CELL_PIXMAP (clist_row->cell[i])->mask)
+          {
+              gdk_gc_set_clip_origin (fg_gc, 0, 0);
+              gdk_gc_set_clip_mask (fg_gc, NULL);
+          }
 	  break;
 
 	case GTK_CELL_PIXTEXT:
@@ -2541,9 +2551,12 @@
 	  ydest = (clip_rectangle.y + (clip_rectangle.height / 2)) - height / 2 +
 	    clist_row->cell[i].vertical;
 
-	  gdk_gc_set_clip_mask (fg_gc, GTK_CELL_PIXTEXT (clist_row->cell[i])->mask);
-	  gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
-
+          if (GTK_CELL_PIXTEXT (clist_row->cell[i])->mask)
+          {
+              gdk_gc_set_clip_mask (fg_gc, GTK_CELL_PIXTEXT (clist_row->cell[i])->mask);
+              gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
+          }
+              
 	  gdk_draw_pixmap (clist->clist_window,
 			   fg_gc,
 			   GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
@@ -3464,13 +3477,15 @@
       
     case GTK_CELL_PIXMAP:
       gdk_pixmap_unref (GTK_CELL_PIXMAP (clist_row->cell[column])->pixmap);
-      gdk_bitmap_unref (GTK_CELL_PIXMAP (clist_row->cell[column])->mask);
+      if (GTK_CELL_PIXMAP (clist_row->cell[column])->mask)
+          gdk_bitmap_unref (GTK_CELL_PIXMAP (clist_row->cell[column])->mask);
       break;
       
     case GTK_CELL_PIXTEXT:
       g_free (GTK_CELL_PIXTEXT (clist_row->cell[column])->text);
       gdk_pixmap_unref (GTK_CELL_PIXTEXT (clist_row->cell[column])->pixmap);
-      gdk_bitmap_unref (GTK_CELL_PIXTEXT (clist_row->cell[column])->mask);
+      if (GTK_CELL_PIXTEXT (clist_row->cell[column])->mask)
+          gdk_bitmap_unref (GTK_CELL_PIXTEXT (clist_row->cell[column])->mask);
       break;
 
     case GTK_CELL_WIDGET:
@@ -3508,10 +3523,11 @@
 {
   cell_empty (clist, clist_row, column);
 
-  if (pixmap && mask)
+  if (pixmap)
     {
       clist_row->cell[column].type = GTK_CELL_PIXMAP;
       GTK_CELL_PIXMAP (clist_row->cell[column])->pixmap = pixmap;
+      // We set the mask even if it is NULL
       GTK_CELL_PIXMAP (clist_row->cell[column])->mask = mask;
     }
 }
@@ -3527,7 +3543,7 @@
 {
   cell_empty (clist, clist_row, column);
 
-  if (text && pixmap && mask)
+  if (text && pixmap)
     {
       clist_row->cell[column].type = GTK_CELL_PIXTEXT;
       GTK_CELL_PIXTEXT (clist_row->cell[column])->text = g_strdup (text);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]