GTkClist Patch Submission (second edition)
- From: Matthew <matthew mattshouse com>
- To: gtk-devel-list gnome org
- Subject: GTkClist Patch Submission (second edition)
- Date: Tue, 1 Aug 2000 12:30:37 -0500
This is a revised version of the gtkclist patch that I posted yesterday. I
would like to thank all of the people that offered suggestions to improve the
patch. I would also like to thank the people that mercilessly flamed me. They
certainly made me pay closer attention to detail. :-) No more magic numbers,
"bad" coding style, etc.
<PATCH DESCRIPTION>
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.
</PATCH DESCRIPTION>
<PATCH>
diff -ru /incoming/gtk+-1.3.1/gtk/gtkclist.c gtk+-1.3.1/gtk/gtkclist.c
--- /incoming/gtk+-1.3.1/gtk/gtkclist.c Sun Jul 2 17:30:53 2000
+++ gtk+-1.3.1/gtk/gtkclist.c Tue Aug 1 12:27:42 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,25 @@
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->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);
+ }
+ else
+ {
+ clist->release_resize = 1;
+ }
+
return FALSE;
}
diff -ru /incoming/gtk+-1.3.1/gtk/gtkclist.h gtk+-1.3.1/gtk/gtkclist.h
--- /incoming/gtk+-1.3.1/gtk/gtkclist.h Thu Jun 1 22:13:58 2000
+++ gtk+-1.3.1/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;
</PATCH>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]