mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Prepare to disable a GTK2 workaround
This commit is contained in:
parent
2a2862c0f1
commit
671df91744
1 changed files with 25 additions and 22 deletions
|
|
@ -35,6 +35,9 @@ interface
|
|||
without alpha channel under GTK2, so bitmaps looks ugly.
|
||||
If this problem will be fixed then GTK2 specific code could be dropped.
|
||||
}
|
||||
{$IF DEFINED(LCLGTK2) AND DEFINED(UNIX) AND NOT (DEFINED(DARWIN) OR DEFINED(HAIKU))}
|
||||
{$DEFINE GTK2_FIX}
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Graphics, syncobjs, uFileSorting, DCStringHashListUtf8,
|
||||
|
|
@ -50,7 +53,7 @@ uses
|
|||
, CocoaUtils, uMyDarwin
|
||||
{$ELSEIF NOT DEFINED(HAIKU)}
|
||||
, Math, Contnrs, uGio, uXdg
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
, gtk2
|
||||
{$ELSE}
|
||||
, uUnixIconTheme
|
||||
|
|
@ -125,7 +128,7 @@ type
|
|||
Maps file extension to MIME icon name(s).
|
||||
}
|
||||
FExtToMimeIconName: TFPDataHashTable;
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
FIconTheme: PGtkIconTheme;
|
||||
{$ELSE}
|
||||
FIconTheme: TIconTheme;
|
||||
|
|
@ -363,7 +366,7 @@ uses
|
|||
GraphType, LCLIntf, LCLType, LCLProc, Forms, uGlobsPaths, WcxPlugin,
|
||||
DCStrUtils, uDCUtils, uFileSystemFileSource, uReSample, uDebug,
|
||||
IntfGraphics, DCOSUtils, DCClassesUtf8, LazUTF8, uGraphics, uHash, uSysFolders
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
, uPixMapGtk, gdk2pixbuf, gdk2, glib2
|
||||
{$ENDIF}
|
||||
{$IFDEF MSWINDOWS}
|
||||
|
|
@ -442,7 +445,7 @@ end;
|
|||
{ TPixMapManager.LoadBitmapFromFile }
|
||||
function TPixMapManager.LoadBitmapFromFile(AIconFileName: String; out ABitmap: Graphics.TBitmap): Boolean;
|
||||
var
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
pbPicture : PGdkPixbuf;
|
||||
{$ELSE}
|
||||
Picture: TPicture;
|
||||
|
|
@ -450,7 +453,7 @@ var
|
|||
begin
|
||||
Result:= False;
|
||||
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
pbPicture := gdk_pixbuf_new_from_file(PChar(AIconFileName), nil);
|
||||
if pbPicture <> nil then
|
||||
begin
|
||||
|
|
@ -640,7 +643,7 @@ end;
|
|||
function TPixMapManager.CheckAddPixmap(AIconName: String; AIconSize : Integer): PtrInt;
|
||||
var
|
||||
fileIndex: PtrInt;
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
pbPicture : PGdkPixbuf;
|
||||
{$ELSE}
|
||||
bmpBitmap: Graphics.TBitmap;
|
||||
|
|
@ -662,7 +665,7 @@ begin
|
|||
fileIndex := FPixmapsFileNames.Find(AIconName);
|
||||
if fileIndex < 0 then
|
||||
begin
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
if not mbFileExists(AIconName) then
|
||||
begin
|
||||
DCDebug(Format('Warning: pixmap [%s] not exists!', [AIconName]));
|
||||
|
|
@ -717,7 +720,7 @@ var
|
|||
DirList: array of string;
|
||||
begin
|
||||
{$IF DEFINED(UNIX) AND NOT (DEFINED(DARWIN) OR DEFINED(HAIKU))}
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
// get current gtk theme
|
||||
FIconTheme:= gtk_icon_theme_get_for_screen(gdk_screen_get_default);
|
||||
{ // load custom theme
|
||||
|
|
@ -742,7 +745,7 @@ end;
|
|||
procedure TPixMapManager.DestroyIconTheme;
|
||||
begin
|
||||
{$IF DEFINED(UNIX) AND NOT (DEFINED(DARWIN) OR DEFINED(HAIKU))}
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
FIconTheme:= nil;
|
||||
{$ELSE}
|
||||
if Assigned(FIconTheme) then
|
||||
|
|
@ -788,7 +791,7 @@ begin
|
|||
finally
|
||||
ABitmap.Free;
|
||||
end;
|
||||
{$IF DEFINED(LCLGTK2)}
|
||||
{$IF DEFINED(GTK2_FIX)}
|
||||
Result := FPixmapList.Add(ImageToPixBuf(Target));
|
||||
AIcon.Free;
|
||||
{$ELSE}
|
||||
|
|
@ -1176,7 +1179,7 @@ end;
|
|||
function TPixMapManager.CheckAddThemePixmapLocked(AIconName: String; AIconSize: Integer): PtrInt;
|
||||
var
|
||||
fileIndex: PtrInt;
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
pbPicture: PGdkPixbuf = nil;
|
||||
sIconFileName: String;
|
||||
{$ELSE}
|
||||
|
|
@ -1188,7 +1191,7 @@ begin
|
|||
fileIndex := FThemePixmapsFileNames.Find(AIconName);
|
||||
if fileIndex < 0 then
|
||||
begin
|
||||
{$IF DEFINED(LCLGTK2) AND DEFINED(UNIX) AND NOT DEFINED(DARWIN)}
|
||||
{$IF DEFINED(GTK2_FIX) AND DEFINED(UNIX) AND NOT DEFINED(DARWIN)}
|
||||
if gShowIcons > sim_standart then
|
||||
begin
|
||||
pbPicture:= gtk_icon_theme_load_icon(FIconTheme, Pgchar(AIconName),
|
||||
|
|
@ -1229,12 +1232,12 @@ function TPixMapManager.AddDefaultThemePixmap(const AIconName: String;
|
|||
AIconSize: Integer): PtrInt;
|
||||
var
|
||||
bmpBitmap: Pointer;
|
||||
{$IF DEFINED(LCLGTK2)}
|
||||
{$IF DEFINED(GTK2_FIX)}
|
||||
sIconFileName: String;
|
||||
{$ENDIF}
|
||||
begin
|
||||
if AIconSize = 0 then AIconSize := gIconsSize;
|
||||
{$IF DEFINED(LCLGTK2)}
|
||||
{$IF DEFINED(GTK2_FIX)}
|
||||
sIconFileName := FDCIconTheme.FindIcon(AIconName, AIconSize);
|
||||
if Length(sIconFileName) = 0 then Exit(-1);
|
||||
bmpBitmap := gdk_pixbuf_new_from_file_at_size(PChar(sIconFileName), AIconSize, AIconSize, nil);
|
||||
|
|
@ -1267,7 +1270,7 @@ begin
|
|||
end;
|
||||
|
||||
function TPixMapManager.LoadIconThemeBitmapLocked(AIconName: String; AIconSize: Integer): Graphics.TBitmap;
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
var
|
||||
pbPicture: PGdkPixbuf = nil;
|
||||
{$ENDIF}
|
||||
|
|
@ -1279,7 +1282,7 @@ begin
|
|||
// Try to load icon from system theme
|
||||
if gShowIcons > sim_standart then
|
||||
begin
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
pbPicture:= gtk_icon_theme_load_icon(FIconTheme, Pgchar(PChar(AIconName)),
|
||||
AIconSize, GTK_ICON_LOOKUP_USE_BUILTIN, nil);
|
||||
if pbPicture <> nil then
|
||||
|
|
@ -1354,7 +1357,7 @@ begin
|
|||
if Result >= 0 then
|
||||
AResult:= FPixmapsFileNames.List[Result]^.Data
|
||||
else begin
|
||||
{$IF DEFINED(LCLGTK2)}
|
||||
{$IF DEFINED(GTK2_FIX)}
|
||||
AResult := gdk_pixbuf_new_from_file_at_size(PChar(AFileName), gIconsSize, gIconsSize, nil);
|
||||
if (AResult = nil) then Exit(ADefaultIcon);
|
||||
Result := FPixmapList.Add(AResult);
|
||||
|
|
@ -1649,7 +1652,7 @@ begin
|
|||
begin
|
||||
for I := 0 to FPixmapList.Count - 1 do
|
||||
if Assigned(FPixmapList.Items[I]) then
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
g_object_unref(PGdkPixbuf(FPixmapList.Items[I]));
|
||||
{$ELSE}
|
||||
Graphics.TBitmap(FPixmapList.Items[I]).Free;
|
||||
|
|
@ -1715,7 +1718,7 @@ begin
|
|||
if gShowIcons > sim_standart then
|
||||
begin
|
||||
LoadMimeIconNames; // For use with GetMimeIcon
|
||||
{$IFNDEF LCLGTK2}
|
||||
{$IFNDEF GTK2_FIX}
|
||||
FIconTheme.Load; // Load system icon theme.
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
|
@ -1907,7 +1910,7 @@ begin
|
|||
|
||||
if PixmapFromList then
|
||||
begin
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
Result:= PixBufToBitmap(PGdkPixbuf(PPixmap));
|
||||
{$ELSE}
|
||||
// Make a new copy.
|
||||
|
|
@ -1971,7 +1974,7 @@ var
|
|||
hicn: HICON;
|
||||
cx, cy: Integer;
|
||||
{$ENDIF}
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
pbPicture : PGdkPixbuf;
|
||||
iPixbufWidth : Integer;
|
||||
iPixbufHeight : Integer;
|
||||
|
|
@ -1995,7 +1998,7 @@ begin
|
|||
|
||||
if PixmapFromList then
|
||||
begin
|
||||
{$IFDEF LCLGTK2}
|
||||
{$IFDEF GTK2_FIX}
|
||||
pbPicture := PGdkPixbuf(PPixmap);
|
||||
iPixbufWidth := gdk_pixbuf_get_width(pbPicture);
|
||||
iPixbufHeight := gdk_pixbuf_get_height(pbPicture);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue