gtk: use generic SetLabelCaption method to set TabControl tabs captions

git-svn-id: trunk@20044 -
This commit is contained in:
paul 2009-05-19 08:12:04 +00:00
parent 9cd36bc5d4
commit a2c07aa8cf
2 changed files with 11 additions and 27 deletions

View File

@ -60,12 +60,17 @@ procedure TGtk1WidgetSet.SetLabelCaption(const ALabel: PGtkLabel; const ACaption
const ASignal: PChar = nil);
var
Caption, Pattern: String;
CurText: PChar;
AccelKey: Char;
begin
Caption := ACaption;
LabelFromAmpersands(Caption, Pattern, AccelKey);
gtk_label_set_text(ALabel, PChar(Caption));
gtk_label_set_pattern(ALabel, PChar(Pattern));
gtk_label_get(ALabel, @CurText);
if Caption <> StrPas(CurText) then
begin
gtk_label_set_text(ALabel, PChar(Caption));
gtk_label_set_pattern(ALabel, PChar(Pattern));
end;
if AComponent = nil then Exit;
if ASignalWidget = nil then Exit;

View File

@ -4303,34 +4303,13 @@ var
procedure UpdateTabLabel;
var
TheCaption, TheLabel: PChar;
CaptionStr, Pattern: String;
AccelKey: Char;
ACaption: String;
begin
CaptionStr := ThePage.Caption;
LabelFromAmpersands(CaptionStr, Pattern, AccelKey);
TheCaption := PChar(CaptionStr);
if TheCaption = nil then
TheCaption := #0;
gtk_label_get(PGtkLabel(TabLabelWidget), @TheLabel);
// uneeded pattern updates cause bugs: #0011306
if CaptionStr <> StrPas(TheLabel) then
begin
gtk_label_set_text(PGtkLabel(TabLabelWidget), PChar(TheCaption));
{$ifdef gtk1}
gtk_label_set_pattern(PGtkLabel(TabLabelWidget), PChar(Pattern));
{$endif gtk1}
end;
ACaption := ThePage.Caption;
GTKWidgetSet.SetLabelCaption(PGtkLabel(TabLabelWidget), ACaption);
if MenuLabelWidget <> nil then
begin
gtk_label_set_text(PGtkLabel(MenuLabelWidget), TheCaption);
{$ifdef gtk1}
gtk_label_set_pattern(PGtkLabel(MenuLabelWidget), PChar(Pattern));
{$endif gtk1}
end;
GTKWidgetSet.SetLabelCaption(PGtkLabel(MenuLabelWidget), ACaption);
end;
procedure UpdateTabCloseBtn;