GTkClist Patch Submission (third edition)



Owen, Timj, gtk hackers.

I created a patch against the 1.3.1 gtkclist.c that impliments the column
autosizing functionality in Gnumeric.  Basically, if you double click
between two title buttons the column will resize itself to the size of the
largest column entry.  

Example:

Fire up Gnumeric
enter aaaaaaaaaaaaaaa into A1
enter aaaaaaaaaaaaaaa into B1
Double click between the A and B title buttons.
Column A resized to the length of aaaaaaaaaaaaaaa

That's what this patch gives to the clist.  It's very small and
simple.  I've been testing it on a couple machines for over a month and
everything is holding together well.  I'm calling it stable at this point.

Thanks,
Matthew
orasoft.org


diff -ru /incoming/gtk+-1.3.1/gtk/gtkclist.c gtk/gtkclist.c
--- /incoming/gtk+-1.3.1/gtk/gtkclist.c	Sun Jul  2 17:30:53 2000
+++ gtk/gtkclist.c	Tue Aug  1 00:21:19 2000
@@ -4938,7 +4938,8 @@
   clist = GTK_CLIST (widget);
 
   button_actions = clist->button_actions[event->button - 1];
-
+  clist->release_resize = 1;
+  
   if (button_actions == GTK_BUTTON_IGNORED)
     return FALSE;
 
@@ -5105,6 +5106,16 @@
       {
 	gpointer drag_data;
 
+        if (event->type==GDK_2BUTTON_PRESS) 
+	  {
+	    gint width;
+            width = gtk_clist_optimal_column_width (clist, i);
+	    gtk_clist_set_column_width (clist, i, width);
+	    clist->release_resize = 0;
+	    remove_grab (clist);
+	    return FALSE;
+          }
+
 	if (gdk_pointer_grab (clist->column[i].window, FALSE,
 			      GDK_POINTER_MOTION_HINT_MASK |
 			      GDK_BUTTON1_MOTION_MASK |
@@ -5172,18 +5183,26 @@
       gtk_grab_remove (widget);
       gdk_pointer_ungrab (event->time);
 
-      if (clist->x_drag >= 0)
-	draw_xor_line (clist);
-
-      if (GTK_CLIST_ADD_MODE(clist))
-	{
-	  gdk_gc_set_line_attributes (clist->xor_gc, 1,
-				      GDK_LINE_ON_OFF_DASH, 0, 0);
-	  gdk_gc_set_dashes (clist->xor_gc, 0, "\4\4", 2);
-	}
+      if (clist->release_resize)
+        {
+          if (clist->x_drag >= 0)
+	    draw_xor_line (clist);
+       
+          if (GTK_CLIST_ADD_MODE(clist))
+	    {
+	      gdk_gc_set_line_attributes (clist->xor_gc, 1,
+	  			          GDK_LINE_ON_OFF_DASH, 0, 0);
+	      gdk_gc_set_dashes (clist->xor_gc, 0, "\4\4", 2);
+	    }
 
-      width = new_column_width (clist, i, &x);
-      gtk_clist_set_column_width (clist, i, width);
+          width = new_column_width (clist, i, &x);
+          gtk_clist_set_column_width (clist, i, width);
+        }
+      else
+        {
+          clist->release_resize = 1;
+        }
+	
       return FALSE;
     }
 
diff -ru /incoming/gtk+-1.3.1/gtk/gtkclist.h gtk/gtkclist.h
--- /incoming/gtk+-1.3.1/gtk/gtkclist.h	Thu Jun  1 22:13:58 2000
+++ gtk/gtkclist.h	Tue Aug  1 00:22:13 2000
@@ -203,6 +203,9 @@
 
   guint8 drag_button;
 
+  /* button_release resize flag */
+  guint8 release_resize;
+
   /* dnd */
   GtkCListCellInfo click_cell;






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