GTkClist Patch Submission (modified)



>you can't expect hackers to browse the web for applying a patch ...
>(sad, but true)
>you will get better feedback if you post the patch IN the mail body
>(nor even attached)

By trying to avoid breaching etiquette, it appears that I have breached
etiquette.  Here's a repost with the patch included:

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.  Bad phrasing?  Just wait, I've got more!  An 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
tested it pretty well, and cannot get it to fail.

This is the first submission, so I know that I'll get hammered a little.
That's fine.  I appreciate it, as a matter of fact.  I don't like the idea of
some unknown yahoo adding code to a base Gtk widget any more than you do.
We'll call this the "What Am I Doing Wrong" release, even though it appears
to work fine.

The patch is here:

--- gtk/gtkclist_orig.c Sun Jul 30 23:04:43 2000
+++ gtk/gtkclist.c      Sun Jul 30 23:29:13 2000
@@ -4951,7 +4951,7 @@
       if (get_selection_info (clist, x, y, &row, &column))
        {
          gint old_row = clist->focus_row;
-
+         
          if (clist->focus_row == -1)
            old_row = row;
 
@@ -5105,6 +5105,15 @@
       {
        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->freeze_count=8;
+         return FALSE;
+        }
+
+
        if (gdk_pointer_grab (clist->column[i].window, FALSE,
                              GDK_POINTER_MOTION_HINT_MASK |
                              GDK_BUTTON1_MOTION_MASK |
@@ -5140,7 +5149,7 @@
 {
   GtkCList *clist;
   gint button_actions;
-
+  
   g_return_val_if_fail (widget != NULL, FALSE);
   g_return_val_if_fail (GTK_IS_CLIST (widget), FALSE);
   g_return_val_if_fail (event != NULL, FALSE);
@@ -5172,18 +5181,22 @@
       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);
-       }
-
-      width = new_column_width (clist, i, &x);
-      gtk_clist_set_column_width (clist, i, width);
+      if (clist->freeze_count!=8){
+        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);
+      }else
+        clist->freeze_count=0;
+       
       return FALSE;
     }




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