mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 16:56:01 +02:00
fixed some gtk2 intf mem leaks, clean ups
git-svn-id: trunk@6788 -
This commit is contained in:
parent
ba5ffc3f0e
commit
81a07bf019
@ -1520,8 +1520,9 @@ begin
|
||||
While FileList^ <> nil do
|
||||
begin
|
||||
fileInfo := FileList^;
|
||||
CurFilename:=AnsiString(fileInfo);
|
||||
CurFilename:=fileInfo; // convert PChar to AnsiString (not typecast)
|
||||
if (CurFilename<>'') and (Files.IndexOf(CurFilename)<0) then begin
|
||||
CurFilename:=DirName+fileInfo;
|
||||
Result:=CheckOpenedFilename(CurFilename);
|
||||
if not Result then exit;
|
||||
Files.Add(CurFilename);
|
||||
@ -1829,7 +1830,8 @@ begin
|
||||
if (Data=nil) or (BEvent=nil) or (Column=0) or (Row=0) then ;
|
||||
theDialog:=TCommonDialog(GetLCLObject(Widget));
|
||||
if (theDialog is TOpenDialog) then begin
|
||||
if (bevent <> nil) and (bevent^.thetype = GDK_2BUTTON_PRESS) and (PGtkFileSelection(theDialog.Handle)^.dir_list = widget) then begin
|
||||
if (bevent <> nil) and (gdk_event_get_type(bevent) = GDK_2BUTTON_PRESS)
|
||||
and (PGtkFileSelection(theDialog.Handle)^.dir_list = widget) then begin
|
||||
MenuWidget := gtk_object_get_data(PGtkObject(theDialog.Handle), 'LCLFilterMenu');
|
||||
if MenuWidget <> nil then begin
|
||||
AFilterEntry := gtk_object_get_data(PGtkObject(gtk_menu_get_active(PGtkMenu(MenuWidget))), 'LCLIsFilterMenuItem');
|
||||
@ -2977,6 +2979,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.265 2005/02/16 23:56:51 mattias
|
||||
fixed some gtk2 intf mem leaks, clean ups
|
||||
|
||||
Revision 1.264 2005/02/16 23:31:16 mattias
|
||||
fixed define templates quotes
|
||||
|
||||
|
@ -275,11 +275,12 @@ end;
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TGtkListStoreStringList.RemoveItemCallbacks(Index: integer);
|
||||
var
|
||||
ListItem: TGtkTreeIter;
|
||||
//var
|
||||
// ListItem: TGtkTreeIter;
|
||||
begin
|
||||
UpdateItemCache;
|
||||
ListItem:=FCachedItems[Index];
|
||||
debugln('TGtkListStoreStringList.RemoveItemCallbacks TODO');
|
||||
//ListItem:=FCachedItems[Index];
|
||||
{gtk_object_set_data(PGtkObject(ListItem),GtkListItemLCLListTag,nil);
|
||||
gtk_object_set_data(PGtkObject(ListItem),GtkListItemGtkListTag,nil);}
|
||||
end;
|
||||
@ -310,20 +311,22 @@ begin
|
||||
ReAllocMem(FCachedItems,SizeOf(TGtkTreeIter)*FCachedCount);
|
||||
if FGtkListStore<>nil then
|
||||
For I := 0 to FCachedCount - 1 do
|
||||
gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(FGtkListStore), @FCachedItems[i], nil, I);
|
||||
gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(FGtkListStore),
|
||||
@FCachedItems[i], nil, I);
|
||||
Exclude(FStates,glsItemCacheNeedsUpdate);
|
||||
end;
|
||||
|
||||
procedure TGtkListStoreStringList.PutObject(Index: Integer; AnObject: TObject);
|
||||
var
|
||||
ListItem : TGtkTreeIter;
|
||||
//var
|
||||
// ListItem : TGtkTreeIter;
|
||||
begin
|
||||
if (Index < 0) or (Index >= Count) then
|
||||
RaiseException('TGtkListStoreStringList.PutObject Out of bounds.')
|
||||
else if FGtkListStore<>nil then begin
|
||||
UpdateItemCache;
|
||||
ListItem:=FCachedItems[Index];
|
||||
{if ListItem <> nil then begin
|
||||
debugln('TGtkListStoreStringList.PutObject TODO');
|
||||
{ListItem:=FCachedItems[Index];
|
||||
if ListItem <> nil then begin
|
||||
gtk_object_set_data(PGtkObject(ListItem),'LCLStringsObject',AnObject);
|
||||
end;}
|
||||
end;
|
||||
@ -599,6 +602,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.41 2005/02/16 23:56:51 mattias
|
||||
fixed some gtk2 intf mem leaks, clean ups
|
||||
|
||||
Revision 1.40 2005/02/08 18:31:56 mattias
|
||||
further completions for gtk2 listbox and listview
|
||||
|
||||
|
@ -202,15 +202,10 @@ function TGtk2WidgetSet.CreateComponent(Sender : TObject): THandle;
|
||||
var
|
||||
Caption : ansistring; // the caption of "Sender"
|
||||
StrTemp : PChar; // same as "caption" but as PChar
|
||||
TempWidget,
|
||||
TempWidget2 : PGTKWidget; // pointer to gtk-widget (local use when neccessary)
|
||||
p : pointer; // ptr to the newly created GtkWidget
|
||||
TempWidget: PGtkWidget;
|
||||
p: PGtkWidget; // ptr to the newly created GtkWidget
|
||||
CompStyle, // componentstyle (type) of GtkWidget which will be created
|
||||
TempInt : Integer; // local use when neccessary
|
||||
// - for csBitBtn
|
||||
Box : Pointer; // currently only used for TCustomBitBtn
|
||||
pixmapwid : pGtkWidget; // currently only used for TCustomBitBtn
|
||||
label1 : pgtkwidget; // currently only used for TCustomBitBtn
|
||||
SetupProps : boolean;
|
||||
liststore : PGtkListStore;
|
||||
renderer : PGtkCellRenderer;
|
||||
@ -289,7 +284,7 @@ begin
|
||||
begin
|
||||
P := gtk_scrolled_window_new(nil, nil);
|
||||
TempWidget := gtk_text_view_new();
|
||||
gtk_container_add(p, TempWidget);
|
||||
gtk_container_add(PGtkContainer(p), TempWidget);
|
||||
|
||||
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(p)^.hscrollbar, GTK_CAN_FOCUS);
|
||||
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(p)^.vscrollbar, GTK_CAN_FOCUS);
|
||||
@ -323,45 +318,45 @@ end;
|
||||
|
||||
function TGtk2WidgetSet.CreateListView(ListViewObject: TObject): PGtkWidget;
|
||||
var
|
||||
GtkTreeView: PGtkWidget;
|
||||
ListStore: PGtkListStore;
|
||||
nColumns: Integer;
|
||||
ListView: TCustomListView;
|
||||
GTypeArray: PGType;
|
||||
i: Integer;
|
||||
renderer: PGtkCellRenderer;
|
||||
Column: PGtkTreeViewColumn;
|
||||
procedure RefreshItems(const ListStore: PGtkListStore);
|
||||
var
|
||||
Iter: TGtkTreeIter;
|
||||
Str: String;
|
||||
ColCount: Integer;
|
||||
i, x: Integer;
|
||||
Item: TListItem;
|
||||
begin
|
||||
gtk_list_store_clear(ListStore);
|
||||
for i := 0 to ListView.Items.Count-1 do begin
|
||||
Item := ListView.Items.Item[i];
|
||||
GtkTreeView: PGtkWidget;
|
||||
ListStore: PGtkListStore;
|
||||
nColumns: Integer;
|
||||
ListView: TCustomListView;
|
||||
GTypeArray: PGType;
|
||||
i: Integer;
|
||||
renderer: PGtkCellRenderer;
|
||||
Column: PGtkTreeViewColumn;
|
||||
|
||||
// Figure out how many columns are needed
|
||||
if not(ListView.ViewStyle = vsReport) then begin
|
||||
gtk_list_store_append(ListStore, @Iter);
|
||||
gtk_list_store_set(ListStore, @Iter,[1, PChar(Item.Caption),-1]);
|
||||
end
|
||||
else begin
|
||||
ColCount := ListView.Columns.Count;
|
||||
if ColCount > (1 + Item.SubItems.Count) then
|
||||
ColCount := 1 + Item.SubItems.Count;
|
||||
if ColCount < 0 then ColCount := 1;
|
||||
gtk_list_store_append(ListStore, @Iter);
|
||||
gtk_list_store_set(ListStore, @Iter,[1, PChar(Item.Caption),-1]);
|
||||
for x := 1 to ColCount-1 do begin
|
||||
gtk_list_store_set(ListStore, @Iter, [X+1, PChar(Item.SubItems.Strings[X-1]), -1]);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
procedure RefreshItems(const ListStore: PGtkListStore);
|
||||
var
|
||||
Iter: TGtkTreeIter;
|
||||
ColCount: Integer;
|
||||
i, x: Integer;
|
||||
Item: TListItem;
|
||||
begin
|
||||
gtk_list_store_clear(ListStore);
|
||||
for i := 0 to ListView.Items.Count-1 do begin
|
||||
Item := ListView.Items.Item[i];
|
||||
|
||||
end;
|
||||
// Figure out how many columns are needed
|
||||
if not(ListView.ViewStyle = vsReport) then begin
|
||||
gtk_list_store_append(ListStore, @Iter);
|
||||
gtk_list_store_set(ListStore, @Iter,[1, PChar(Item.Caption),-1]);
|
||||
end
|
||||
else begin
|
||||
ColCount := ListView.Columns.Count;
|
||||
if ColCount > (1 + Item.SubItems.Count) then
|
||||
ColCount := 1 + Item.SubItems.Count;
|
||||
if ColCount < 0 then ColCount := 1;
|
||||
gtk_list_store_append(ListStore, @Iter);
|
||||
gtk_list_store_set(ListStore, @Iter,[1, PChar(Item.Caption),-1]);
|
||||
for x := 1 to ColCount-1 do begin
|
||||
gtk_list_store_set(ListStore, @Iter, [X+1, PChar(Item.SubItems.Strings[X-1]), -1]);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
Result := gtk_scrolled_window_new(nil, nil);
|
||||
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(Result)^.hscrollbar, GTK_CAN_FOCUS);
|
||||
@ -386,7 +381,7 @@ begin
|
||||
for i := 1 to nColumns do begin
|
||||
GTypeArray[i] := G_TYPE_STRING;
|
||||
end;
|
||||
GTypeArray[nColumns+1] := -1;
|
||||
GTypeArray[nColumns+1] := 0; // -1;
|
||||
ListStore := gtk_list_store_newv(nColumns, GTypeArray);
|
||||
ReAllocMem(GTypeArray, 0);
|
||||
|
||||
@ -1504,6 +1499,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.24 2005/02/16 23:56:51 mattias
|
||||
fixed some gtk2 intf mem leaks, clean ups
|
||||
|
||||
Revision 1.23 2005/02/08 18:31:56 mattias
|
||||
further completions for gtk2 listbox and listview
|
||||
|
||||
|
@ -120,13 +120,13 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if (FamilyName = '') or (AnsiCompareText(FamilyName,'*')=0) then begin
|
||||
if (FamilyName = '') or (CompareText(FamilyName,'*')=0) then begin
|
||||
FamilyName := StrPas(lfFaceName);
|
||||
if AnsiCompareText(FamilyName,'default')=0 then begin
|
||||
if CompareText(FamilyName,'default')=0 then begin
|
||||
LoadDefaultFont;
|
||||
exit;
|
||||
end;
|
||||
FullString := AnsiString(FamilyName);
|
||||
FullString := FamilyName;
|
||||
if IsFontNameXLogicalFontDesc(LongFontName) then
|
||||
if Abs(lfHeight)=0 then
|
||||
FullString := FullString + ' 12'
|
||||
@ -134,22 +134,39 @@ begin
|
||||
FullString := FullString + ' ' + IntToStr(Abs(lfHeight));
|
||||
end
|
||||
else begin
|
||||
FullString := AnsiString(FamilyName);
|
||||
FullString := FamilyName;
|
||||
if IsFontNameXLogicalFontDesc(LongFontName) then
|
||||
if (PointSize = '') or (AnsiCompareText(PointSize,'*')=0) then
|
||||
if (PointSize = '') or (CompareText(PointSize,'*')=0) then
|
||||
FullString := FullString + ' 12'
|
||||
else
|
||||
FullString := FullString + ' ' + IntToStr(StrToInt(PointSize) div 10);
|
||||
end;
|
||||
|
||||
if FontNameRegistry='' then ;
|
||||
if Foundry='' then ;
|
||||
if WeightName='' then ;
|
||||
if Slant='' then ;
|
||||
if SetwidthName='' then ;
|
||||
if AddStyleName='' then ;
|
||||
if PixelSize='' then ;
|
||||
if ResolutionX='' then ;
|
||||
if ResolutionY='' then ;
|
||||
if Spacing='' then ;
|
||||
if AverageWidth='' then ;
|
||||
if CharSetCoding='' then ;
|
||||
if CharSetRegistry='' then ;
|
||||
|
||||
GdiObject^.GDIFontObject := pango_font_description_from_string(PChar(FullString));
|
||||
GdiObject^.GDIFontObject :=
|
||||
pango_font_description_from_string(PChar(FullString));
|
||||
If lfWeight <> FW_DONTCARE then
|
||||
pango_font_description_set_weight(GdiObject^.GDIFontObject, lfWeight);
|
||||
|
||||
if lfItalic = 0 then
|
||||
pango_font_description_set_style(GdiObject^.GDIFontObject,PANGO_STYLE_NORMAL)
|
||||
pango_font_description_set_style(GdiObject^.GDIFontObject,
|
||||
PANGO_STYLE_NORMAL)
|
||||
else
|
||||
pango_font_description_set_style(GdiObject^.GDIFontObject,PANGO_STYLE_ITALIC);
|
||||
pango_font_description_set_style(GdiObject^.GDIFontObject,
|
||||
PANGO_STYLE_ITALIC);
|
||||
|
||||
GdiObject^.StrikeOut := lfStrikeOut <> 0;
|
||||
GdiObject^.Underline := lfUnderline <> 0;
|
||||
@ -450,14 +467,14 @@ begin
|
||||
If (AttrList = nil) then
|
||||
AttrList := pango_attr_list_new();
|
||||
|
||||
If CurrentFont^.Underline then
|
||||
If Underline then
|
||||
Attr := pango_attr_underline_new(PANGO_UNDERLINE_SINGLE)
|
||||
else
|
||||
Attr := pango_attr_underline_new(PANGO_UNDERLINE_NONE);
|
||||
|
||||
pango_attr_list_change(AttrList,Attr);
|
||||
|
||||
Attr := pango_attr_strikethrough_new(CurrentFont^.StrikeOut);
|
||||
Attr := pango_attr_strikethrough_new(StrikeOut);
|
||||
pango_attr_list_change(AttrList,Attr);
|
||||
|
||||
if (Options and ETO_CLIPPED) <> 0 then
|
||||
@ -795,6 +812,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.13 2005/02/16 23:56:51 mattias
|
||||
fixed some gtk2 intf mem leaks, clean ups
|
||||
|
||||
Revision 1.12 2005/01/23 11:43:38 mattias
|
||||
fixed expandingtabs in synedit painting
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user