return 0;
}
+/* returns the GList item for the nth row */
+#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
+ (clist)->row_list_end : \
+ g_list_nth ((clist)->row_list, (row)))
+
+
#define GTK_CLIST_CLASS_FW(_widget_) GTK_CLIST_CLASS (((GtkObject*) (_widget_))->klass)
/* redraw the list if it's not frozen */
if (column < 0 || column >= clist->columns)
return -1;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
return clist_row->cell[column].type;
}
if (column < 0 || column >= clist->columns)
return;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
/* if text is null, then the cell is empty */
GTK_CLIST_CLASS_FW (clist)->set_cell_contents
if (column < 0 || column >= clist->columns)
return 0;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (clist_row->cell[column].type != GTK_CELL_TEXT)
return 0;
if (column < 0 || column >= clist->columns)
return;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
gdk_pixmap_ref (pixmap);
if (column < 0 || column >= clist->columns)
return 0;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (clist_row->cell[column].type != GTK_CELL_PIXMAP)
return 0;
if (column < 0 || column >= clist->columns)
return;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
gdk_pixmap_ref (pixmap);
if (mask) gdk_pixmap_ref (mask);
if (column < 0 || column >= clist->columns)
return 0;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (clist_row->cell[column].type != GTK_CELL_PIXTEXT)
return 0;
if (column < 0 || column >= clist->columns)
return;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (clist->column[column].auto_resize &&
!GTK_CLIST_AUTO_RESIZE_BLOCKED(clist))
was_selected = 0;
/* get the row we're going to delete */
- list = g_list_nth (clist->row_list, row);
+ list = ROW_ELEMENT (clist, row);
g_assert (list != NULL);
clist_row = list->data;
gtk_clist_freeze (clist);
/* unlink source row */
- clist_row = g_list_nth_data (clist->row_list, source_row);
+ clist_row = ROW_ELEMENT (clist, source_row)->data;
if (source_row == clist->rows - 1)
clist->row_list_end = clist->row_list_end->prev;
clist->row_list = g_list_remove (clist->row_list, clist_row);
if (row < 0 || row > (clist->rows - 1))
return;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
+
+ if (clist_row->destroy)
+ clist_row->destroy (clist_row->data);
+
clist_row->data = data;
clist_row->destroy = destroy;
}
if (row < 0 || row > (clist->rows - 1))
return NULL;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
return clist_row->data;
}
if (row < 0 || row >= clist->rows)
return;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (color)
{
if (row < 0 || row >= clist->rows)
return;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (color)
{
if (column < 0 || column >= clist->columns)
return;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (clist_row->cell[column].style == style)
return;
if (row < 0 || row >= clist->rows || column < 0 || column >= clist->columns)
return NULL;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
return clist_row->cell[column].style;
}
if (row < 0 || row >= clist->rows)
return;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (clist_row->style == style)
return;
if (row < 0 || row >= clist->rows)
return NULL;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
return clist_row->style;
}
if (row < 0 || row >= clist->rows)
return;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (selectable == clist_row->selectable)
return;
if (row < 0 || row >= clist->rows)
return FALSE;
- return GTK_CLIST_ROW (g_list_nth (clist->row_list, row))->selectable;
+ return GTK_CLIST_ROW (ROW_ELEMENT (clist, row))->selectable;
}
void
case GTK_SELECTION_EXTENDED:
case GTK_SELECTION_MULTIPLE:
case GTK_SELECTION_SINGLE:
- clist_row = g_list_nth (clist->row_list, row)->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (!clist_row)
return;
{
GList *work;
- work = g_list_nth (clist->row_list, row);
+ work = ROW_ELEMENT (clist, row);
if (!work || !GTK_CLIST_ROW (work)->selectable)
return;
break;
}
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (clist_row->state != GTK_STATE_NORMAL || !clist_row->selectable)
return;
if (row < 0 || row > (clist->rows - 1))
return;
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
if (clist_row->state == GTK_STATE_SELECTED)
{
GList *work;
gint i;
- if (row >= 0 && (work = g_list_nth (clist->row_list, row)))
+ if (row >= 0 && (work = ROW_ELEMENT (clist, row)))
{
if (GTK_CLIST_ROW (work)->state == GTK_STATE_NORMAL &&
GTK_CLIST_ROW (work)->selectable)
clist->undo_selection = clist->selection;
clist->selection = NULL;
clist->selection_end = NULL;
-
+
for (list = clist->undo_selection; list; list = list->next)
{
if ((i = GPOINTER_TO_INT (list->data)) == row ||
clist->selection_mode != GTK_SELECTION_EXTENDED)
return;
- if (clist->anchor >= 0)
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
if (!(clist->undo_selection || clist->undo_unselection))
{
GList *list;
GtkCListRow *clist_row;
- if (clist->anchor < 0)
+ if (clist->selection_mode != GTK_SELECTION_EXTENDED)
+ return;
+
+ if (clist->anchor < 0 || clist->drag_pos < 0)
return;
gtk_clist_freeze (clist);
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
- if ((gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_FOCUS(clist)) ||
- clist->anchor == -1)
+ if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_FOCUS(clist))
return;
-
+
GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
}
clist->focus_row = clist->rows - 1;
}
- if (clist->selection_mode == GTK_SELECTION_BROWSE && clist->anchor != -1)
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
g_list_free (clist->undo_selection);
g_list_free (clist->undo_unselection);
{
remove_grab (clist);
- if (clist->anchor != -1 &&
- clist->selection_mode == GTK_SELECTION_EXTENDED)
- GTK_CLIST_CLASS_FW (widget)->resync_selection (clist, NULL);
+ GTK_CLIST_CLASS_FW (widget)->resync_selection (clist, NULL);
clist->click_cell.row = -1;
clist->click_cell.column = -1;
case GTK_SELECTION_SINGLE:
case GTK_SELECTION_MULTIPLE:
if (event->type != GDK_BUTTON_PRESS)
- gtk_signal_emit (GTK_OBJECT (clist),
- clist_signals[SELECT_ROW],
- row, column, event);
+ {
+ gtk_signal_emit (GTK_OBJECT (clist),
+ clist_signals[SELECT_ROW],
+ row, column, event);
+ clist->anchor = -1;
+ }
else
clist->anchor = row;
break;
/* if the function is passed the pointer to the row instead of null,
* it avoids this expensive lookup */
if (!clist_row)
- clist_row = (g_list_nth (clist->row_list, row))->data;
+ clist_row = ROW_ELEMENT (clist, row)->data;
/* rectangle of the entire row */
row_rectangle.x = 0;
cell_rectangle.width = row_rectangle.width;
cell_rectangle.height = CELL_SPACING;
- /* rectangle used to clip drawing operations, it's y and height
+ /* rectangle used to clip drawing operations, its y and height
* positions only need to be set once, so we set them once here.
* the x and width are set withing the drawing loop below once per
* column */
if (clist->rows == first_row)
first_row--;
- list = g_list_nth (clist->row_list, first_row);
+ list = ROW_ELEMENT (clist, first_row);
i = first_row;
while (list)
{
clist = GTK_CLIST (widget);
- if (clist->anchor != -1 && clist->selection_mode == GTK_SELECTION_EXTENDED)
- GTK_CLIST_CLASS_FW (widget)->resync_selection (clist, (GdkEvent *) event);
+ GTK_CLIST_CLASS_FW (widget)->resync_selection (clist, (GdkEvent *) event);
return FALSE;
}
clist->drag_button = 0;
}
- if (clist->anchor >= 0 &&
- clist->selection_mode == GTK_SELECTION_EXTENDED)
- GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
+ GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);
clist->button_actions[button] = button_actions;
}