Re: [gtk-list] Updating a CList in gtk+ 1.2.4
- From: Havoc Pennington <hp redhat com>
- To: gtk-list <gtk-list redhat com>
- Subject: Re: [gtk-list] Updating a CList in gtk+ 1.2.4
- Date: Sat, 28 Aug 1999 13:04:49 -0400 (EDT)
Hi,
Here are all the changes from 1.2.1 to 1.2.4, created via:
cvs diff -u -r GTK_1_2_1 -r GTK_1_2_4 gtkclist.c
I don't see what the problem is, maybe someone else will be able to figure
it out.
Havoc
Index: gtkclist.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkclist.c,v
retrieving revision 1.156.2.4
retrieving revision 1.156.2.10
diff -u -u -r1.156.2.4 -r1.156.2.10
--- gtkclist.c 1999/03/21 23:57:07 1.156.2.4
+++ gtkclist.c 1999/06/09 09:07:23 1.156.2.10
@@ -134,8 +134,7 @@
/* Signals */
-enum
-{
+enum {
SELECT_ROW,
UNSELECT_ROW,
ROW_MOVE,
@@ -155,8 +154,7 @@
LAST_SIGNAL
};
-enum
-{
+enum {
SYNC_REMOVE,
SYNC_INSERT
};
@@ -169,7 +167,8 @@
ARG_ROW_HEIGHT,
ARG_TITLES_ACTIVE,
ARG_REORDERABLE,
- ARG_USE_DRAG_ICONS
+ ARG_USE_DRAG_ICONS,
+ ARG_SORT_TYPE
};
/* GtkCList Methods */
@@ -446,6 +445,10 @@
static gint column_title_passive_func (GtkWidget *widget,
GdkEvent *event,
gpointer data);
+static void drag_dest_cell (GtkCList *clist,
+ gint x,
+ gint y,
+ GtkCListDestInfo *dest_info);
@@ -521,7 +524,10 @@
GTK_TYPE_BOOL,
GTK_ARG_READWRITE,
ARG_USE_DRAG_ICONS);
-
+ gtk_object_add_arg_type ("GtkCList::sort_type",
+ GTK_TYPE_SORT_TYPE,
+ GTK_ARG_READWRITE,
+ ARG_SORT_TYPE);
object_class->set_arg = gtk_clist_set_arg;
object_class->get_arg = gtk_clist_get_arg;
object_class->destroy = gtk_clist_destroy;
@@ -850,7 +856,8 @@
case ARG_USE_DRAG_ICONS:
gtk_clist_set_use_drag_icons (clist, GTK_VALUE_BOOL (*arg));
break;
- default:
+ case ARG_SORT_TYPE:
+ gtk_clist_set_sort_type (clist, GTK_VALUE_ENUM (*arg));
break;
}
}
@@ -896,6 +903,9 @@
case ARG_USE_DRAG_ICONS:
GTK_VALUE_BOOL (*arg) = GTK_CLIST_USE_DRAG_ICONS (clist);
break;
+ case ARG_SORT_TYPE:
+ GTK_VALUE_ENUM (*arg) = clist->sort_type;
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -2732,8 +2742,7 @@
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
row, -1, NULL);
- /* reset the row end pointer if we're removing at the
- * end of the list */
+ /* reset the row end pointer if we're removing at the end of the list */
clist->rows--;
if (clist->row_list == list)
clist->row_list = g_list_next (list);
@@ -3866,8 +3875,11 @@
GPOINTER_TO_INT (work->data), -1, NULL);
for (work = clist->undo_unselection; work; work = work->next)
- gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
- GPOINTER_TO_INT (work->data), -1, NULL);
+ {
+ g_print ("unselect %d\n",GPOINTER_TO_INT (work->data));
+ gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
+ GPOINTER_TO_INT (work->data), -1, NULL);
+ }
if (GTK_WIDGET_HAS_FOCUS(clist) && clist->focus_row != clist->undo_anchor)
{
@@ -4023,9 +4035,9 @@
}
}
}
-
- for (list = g_list_reverse (clist->undo_unselection); list;
- list = list->next)
+
+ clist->undo_unselection = g_list_reverse (clist->undo_unselection);
+ for (list = clist->undo_unselection; list; list = list->next)
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
GPOINTER_TO_INT (list->data), -1, event);
@@ -4504,7 +4516,8 @@
/* We'll use this gc to do scrolling as well */
gdk_gc_set_exposures (clist->fg_gc, TRUE);
- values.foreground = widget->style->white;
+ values.foreground = (widget->style->white.pixel==0 ?
+ widget->style->black:widget->style->white);
values.function = GDK_XOR;
values.subwindow_mode = GDK_INCLUDE_INFERIORS;
clist->xor_gc = gdk_gc_new_with_values (widget->window,
@@ -4748,7 +4761,7 @@
(2 * widget->style->klass->ythickness) +
clist->column_title_area.height);
- gdk_window_clear_area (clist->clist_window, 0, 0, -1, -1);
+ gdk_window_clear_area (clist->clist_window, 0, 0, 0, 0);
draw_rows (clist, NULL);
for (i = 0; i < clist->columns; i++)
@@ -5156,6 +5169,7 @@
{
case GTK_SELECTION_EXTENDED:
if (!(event->state & GDK_SHIFT_MASK) ||
+ !GTK_WIDGET_CAN_FOCUS (widget) ||
event->x < 0 || event->x >= clist->clist_window_width ||
event->y < 0 || event->y >= clist->clist_window_height)
GTK_CLIST_CLASS_FW (clist)->resync_selection
@@ -5940,8 +5954,8 @@
}
if (!area)
- gdk_window_clear_area (clist->clist_window,
- 0, ROW_TOP_YPIXEL (clist, i), -1, -1);
+ gdk_window_clear_area (clist->clist_window, 0,
+ ROW_TOP_YPIXEL (clist, i), 0, 0);
}
static void
@@ -6041,7 +6055,8 @@
clist->vadjustment->lower = 0;
clist->vadjustment->upper = LIST_HEIGHT (clist);
- if (clist->clist_window_height - clist->voffset > LIST_HEIGHT (clist))
+ if (clist->clist_window_height - clist->voffset > LIST_HEIGHT (clist) ||
+ (clist->voffset + (gint)clist->vadjustment->value) != 0)
{
clist->vadjustment->value = MAX (0, (LIST_HEIGHT (clist) -
clist->clist_window_height));
@@ -6059,7 +6074,8 @@
clist->hadjustment->lower = 0;
clist->hadjustment->upper = LIST_WIDTH (clist);
- if (clist->clist_window_width - clist->hoffset > LIST_WIDTH (clist))
+ if (clist->clist_window_width - clist->hoffset > LIST_WIDTH (clist) ||
+ (clist->hoffset + (gint)clist->hadjustment->value) != 0)
{
clist->hadjustment->value = MAX (0, (LIST_WIDTH (clist) -
clist->clist_window_width));
@@ -7410,6 +7426,62 @@
}
static void
+drag_dest_cell (GtkCList *clist,
+ gint x,
+ gint y,
+ GtkCListDestInfo *dest_info)
+{
+ GtkWidget *widget;
+
+ widget = GTK_WIDGET (clist);
+
+ dest_info->insert_pos = GTK_CLIST_DRAG_NONE;
+
+ y -= (GTK_CONTAINER (clist)->border_width +
+ widget->style->klass->ythickness +
+ clist->column_title_area.height);
+
+ dest_info->cell.row = ROW_FROM_YPIXEL (clist, y);
+ if (dest_info->cell.row >= clist->rows)
+ {
+ dest_info->cell.row = clist->rows - 1;
+ y = ROW_TOP_YPIXEL (clist, dest_info->cell.row) + clist->row_height;
+ }
+ if (dest_info->cell.row < -1)
+ dest_info->cell.row = -1;
+
+ x -= GTK_CONTAINER (widget)->border_width + widget->style->klass->xthickness;
+ dest_info->cell.column = COLUMN_FROM_XPIXEL (clist, x);
+
+ if (dest_info->cell.row >= 0)
+ {
+ gint y_delta;
+ gint h = 0;
+
+ y_delta = y - ROW_TOP_YPIXEL (clist, dest_info->cell.row);
+
+ if (GTK_CLIST_DRAW_DRAG_RECT(clist))
+ {
+ dest_info->insert_pos = GTK_CLIST_DRAG_INTO;
+ h = clist->row_height / 4;
+ }
+ else if (GTK_CLIST_DRAW_DRAG_LINE(clist))
+ {
+ dest_info->insert_pos = GTK_CLIST_DRAG_BEFORE;
+ h = clist->row_height / 2;
+ }
+
+ if (GTK_CLIST_DRAW_DRAG_LINE(clist))
+ {
+ if (y_delta < h)
+ dest_info->insert_pos = GTK_CLIST_DRAG_BEFORE;
+ else if (clist->row_height - y_delta < h)
+ dest_info->insert_pos = GTK_CLIST_DRAG_AFTER;
+ }
+ }
+}
+
+static void
gtk_clist_drag_begin (GtkWidget *widget,
GdkDragContext *context)
{
@@ -7526,56 +7598,14 @@
guint time)
{
GtkCList *clist;
- gint row, column;
+ GtkCListDestInfo new_info;
GtkCListDestInfo *dest_info;
- gint h = 0;
- gint insert_pos = GTK_CLIST_DRAG_NONE;
- gint y_delta;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_CLIST (widget), FALSE);
clist = GTK_CLIST (widget);
- y -= (GTK_CONTAINER (widget)->border_width +
- widget->style->klass->ythickness + clist->column_title_area.height);
- row = ROW_FROM_YPIXEL (clist, y);
-
- if (row >= clist->rows)
- {
- row = clist->rows - 1;
- y = ROW_TOP_YPIXEL (clist, row) + clist->row_height;
- }
- if (row < -1)
- row = -1;
-
- x -= GTK_CONTAINER (widget)->border_width + widget->style->klass->xthickness;
- column = COLUMN_FROM_XPIXEL (clist, x);
-
- if (row >= 0)
- {
- y_delta = y - ROW_TOP_YPIXEL (clist, row);
-
- if (GTK_CLIST_DRAW_DRAG_RECT(clist))
- {
- insert_pos = GTK_CLIST_DRAG_INTO;
- h = clist->row_height / 4;
- }
- else if (GTK_CLIST_DRAW_DRAG_LINE(clist))
- {
- insert_pos = GTK_CLIST_DRAG_BEFORE;
- h = clist->row_height / 2;
- }
-
- if (GTK_CLIST_DRAW_DRAG_LINE(clist))
- {
- if (y_delta < h)
- insert_pos = GTK_CLIST_DRAG_BEFORE;
- else if (clist->row_height - y_delta < h)
- insert_pos = GTK_CLIST_DRAG_AFTER;
- }
- }
-
dest_info = g_dataset_get_data (context, "gtk-clist-drag-dest");
if (!dest_info)
@@ -7590,6 +7620,8 @@
drag_dest_info_destroy);
}
+ drag_dest_cell (clist, x, y, &new_info);
+
if (GTK_CLIST_REORDERABLE (clist))
{
GList *list;
@@ -7606,12 +7638,12 @@
if (list)
{
if (gtk_drag_get_source_widget (context) != widget ||
- insert_pos == GTK_CLIST_DRAG_NONE ||
- row == clist->click_cell.row ||
- (row == clist->click_cell.row - 1 &&
- insert_pos == GTK_CLIST_DRAG_AFTER) ||
- (row == clist->click_cell.row + 1 &&
- insert_pos == GTK_CLIST_DRAG_BEFORE))
+ new_info.insert_pos == GTK_CLIST_DRAG_NONE ||
+ new_info.cell.row == clist->click_cell.row ||
+ (new_info.cell.row == clist->click_cell.row - 1 &&
+ new_info.insert_pos == GTK_CLIST_DRAG_AFTER) ||
+ (new_info.cell.row == clist->click_cell.row + 1 &&
+ new_info.insert_pos == GTK_CLIST_DRAG_BEFORE))
{
if (dest_info->cell.row < 0)
{
@@ -7621,9 +7653,9 @@
return TRUE;
}
- if (row != dest_info->cell.row ||
- (row == dest_info->cell.row &&
- dest_info->insert_pos != insert_pos))
+ if (new_info.cell.row != dest_info->cell.row ||
+ (new_info.cell.row == dest_info->cell.row &&
+ dest_info->insert_pos != new_info.insert_pos))
{
if (dest_info->cell.row >= 0)
GTK_CLIST_CLASS_FW (clist)->draw_drag_highlight
@@ -7631,9 +7663,9 @@
dest_info->cell.row)->data,
dest_info->cell.row, dest_info->insert_pos);
- dest_info->insert_pos = insert_pos;
- dest_info->cell.row = row;
- dest_info->cell.column = column;
+ dest_info->insert_pos = new_info.insert_pos;
+ dest_info->cell.row = new_info.cell.row;
+ dest_info->cell.column = new_info.cell.column;
GTK_CLIST_CLASS_FW (clist)->draw_drag_highlight
(clist, g_list_nth (clist->row_list,
@@ -7646,9 +7678,9 @@
}
}
- dest_info->insert_pos = insert_pos;
- dest_info->cell.row = row;
- dest_info->cell.column = column;
+ dest_info->insert_pos = new_info.insert_pos;
+ dest_info->cell.row = new_info.cell.row;
+ dest_info->cell.column = new_info.cell.column;
return TRUE;
}
@@ -7706,22 +7738,21 @@
selection_data->length == sizeof (GtkCListCellInfo))
{
GtkCListCellInfo *source_info;
- GtkCListDestInfo *dest_info;
source_info = (GtkCListCellInfo *)(selection_data->data);
- dest_info = g_dataset_get_data (context, "gtk-clist-drag-dest");
-
- if (dest_info && source_info)
+ if (source_info)
{
- if (dest_info->insert_pos == GTK_CLIST_DRAG_AFTER)
- dest_info->cell.row++;
- if (source_info->row < dest_info->cell.row)
- dest_info->cell.row--;
-
- if (dest_info->cell.row != source_info->row)
- gtk_clist_row_move (GTK_CLIST (widget),
- source_info->row,
- dest_info->cell.row);
+ GtkCListDestInfo dest_info;
+
+ drag_dest_cell (clist, x, y, &dest_info);
+
+ if (dest_info.insert_pos == GTK_CLIST_DRAG_AFTER)
+ dest_info.cell.row++;
+ if (source_info->row < dest_info.cell.row)
+ dest_info.cell.row--;
+ if (dest_info.cell.row != source_info->row)
+ gtk_clist_row_move (clist, source_info->row, dest_info.cell.row);
+
g_dataset_remove_data (context, "gtk-clist-drag-dest");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]