gtk2: remove hacks around TListBox.ItemIndex

git-svn-id: trunk@13967 -
This commit is contained in:
paul 2008-02-03 12:48:36 +00:00
parent 1df101d12e
commit 64c7e1a1a5
2 changed files with 5 additions and 49 deletions

View File

@ -510,11 +510,6 @@ end;
procedure TGtkListStoreStringList.Delete(Index : integer);
var
ListItem: TGtkTreeIter;
Path: PGtkTreePath;
Widget: PGtkTreeView;
Selection: PGtkTreeSelection;
OldItemIndex: Integer;
Column: PGtkTreeViewColumn;
begin
if not (glsItemCacheNeedsUpdate in FStates) then
ListItem := FCachedItems[Index]
@ -522,33 +517,6 @@ begin
gtk_tree_model_iter_nth_child(FGtkListStore, @ListItem, nil, Index);
//gtk_list_store_g
Widget := PGtkTreeView(GetWidgetInfo(Pointer(FOwner.Handle), True)^.CoreWidget);
Selection := gtk_tree_view_get_selection(Widget);
gtk_tree_view_get_cursor(Widget, Path, Column);
if Path <> nil then
OldItemIndex := gtk_tree_path_get_indices(Path)^
else
OldItemIndex := -1;
if (gtk_tree_selection_get_mode(Selection) <> GTK_SELECTION_SINGLE) and (OldItemIndex = Index) then
begin
if Index > 0 then
dec(Index);
if gtk_tree_row_reference_valid(Widget^.priv^.cursor) then
begin
gtk_tree_row_reference_free(Widget^.priv^.cursor);
Widget^.priv^.cursor := nil;
end;
Path := gtk_tree_path_new_from_indices(Index, -1);
Widget^.priv^.cursor := gtk_tree_row_reference_new_proxy(G_OBJECT(Widget), FGtkListStore, Path);
gtk_tree_path_free(Path);
end;
gtk_list_store_remove(FGtkListStore, @ListItem);
IncreaseChangeStamp;

View File

@ -420,7 +420,6 @@ class procedure TGtk2WSCustomListBox.SetItemIndex(
const ACustomListBox: TCustomListBox; const AIndex: integer);
var
Widget: PGtkWidget;
ListStoreModel: PGtkTreeModel;
Selection: PGtkTreeSelection;
Path: PGtkTreePath;
@ -441,7 +440,6 @@ begin
if not GtkWidgetIsA(Widget, gtk_tree_view_get_type) then
raise Exception.Create('');
ListStoreModel := gtk_tree_view_get_model(PGtkTreeView(Widget));
Selection := gtk_tree_view_get_selection(PGtkTreeView(Widget));
if (AIndex < 0) then
@ -452,24 +450,14 @@ begin
else
Path := gtk_tree_path_new_from_indices(AIndex, -1);
// if singleselection mode then selection = itemindex
if Path <> nil then
gtk_tree_view_set_cursor(PGtkTreeView(Widget), Path, nil, False)
else
if gtk_tree_selection_get_mode(Selection) = GTK_SELECTION_SINGLE then
begin
// if singleselection mode then selection = itemindex
if Path <> nil then
gtk_tree_view_set_cursor(PGtkTreeView(Widget), Path, nil, False)
else
begin
ClearCursor;
gtk_tree_selection_unselect_all(Selection);
end;
end
else
if Path <> nil then
begin
ClearCursor;
// hack to prevent clearing of selection while gtk_tree_view_set_cursor
// it works bad with latest gtk (2.12)
PGtkTreeView(Widget)^.priv^.cursor := gtk_tree_row_reference_new_proxy(G_OBJECT(Widget), ListStoreModel, Path);
gtk_tree_selection_unselect_all(Selection);
end;
if Path <> nil then