How to get native windows decorations on GTK3 on Windows 7+ and MSYS2

前端 未结 5 1017
旧巷少年郎
旧巷少年郎 2021-02-02 14:43

I am trying to port my application from linux to windows and I have a problem with theming. In linux this works out of a box, just compile it and application is using good theme

相关标签:
5条回答
  • 2021-02-02 15:26

    For people like me who use (activestate) perl, the /share and /etc need to be placed one directory above the perl.exe (say in C:\Perl64 if perl.exe is in C:\Perl64\bin).

    0 讨论(0)
  • 2021-02-02 15:28

    Thera are two sub-problems: missing icons and setting right theme.

    Missing icons

    For missing icons it was enough to copy these icons

    • window-close-symbolic.symbolic.png
    • window-maximize-symbolic.symbolic.png
    • window-minimize-symbolic.symbolic.png

    from: C:\msys64\mingw32\share\icons\Adwaita\22x22\actions

    to: "your executable folder"\share\icons\Adwaita\22x22\actions

    Theme

    Using win32 native theme

    There is actually a built-in native-like theme in GTK3. For using native-like theme just create file "your executable folder"\etc\gtk-3.0\settings.ini with this in it

    [Settings]
    gtk-theme-name=win32
    

    win32 theme is built in into GTK3 and only three icons from previous step seems to be needed.

    On windows 7 this looks as following:

    The problem is, that the decorations looks the same even on Windows 10 (including window decorations).

    From comment from @andlabs : GTK+ 3 uses the uxtheme.dll APIs to get its Windows look and feel, and unfortunately Microsoft has kept those Windows 7-like for window borders. (more in comments)

    You can see Windows 10 Gtk3 application with win32 theme here:

    Using non default theme

    And if you are not happy with default or win32 theme, you can use custom themes (like this Flat-Pat) from the internet. :) In order to do it you need to create config file:

    "your executable folder"\etc\gtk-3.0\settings.ini with this in it

    [Settings]
    gtk-theme-name=Flat-Plat
    

    and you need to copy the theme files to directory in path of your executable

    "your executable folder"\share\themes\Flat-Plat

    in that folder, the index.theme file and gtk-x.x folders should be present. Obviously gtk-theme-name and folder name should match.

    After you run the executable you should be able to get different theme.

    EDIT: So there is a win32 theme built-in, thank you @andlabs

    EDIT2: Added screenshots

    EDIT3: Added Windows 10 screenshot and corrected facts.

    0 讨论(0)
  • 2021-02-02 15:29

    Actually, Gtk+3 been compatible with Windows 10 and you can use the native windows theme by making this your default theme.

    gtk-theme-name = MS-Windows
    
    0 讨论(0)
  • 2021-02-02 15:32

    You can set GTK_CSD=0 environment variable to disable client-side window decorations and enable Windows native decorations, which gets rid of the ugly win7-like titlebar, as well as Adwaita-like one.

    0 讨论(0)
  • 2021-02-02 15:32

    While GTK_CSD=0 is doing a fine job for windows frame icons, it seams that default Drag-And-Drop (DND) icons are missing too.

    Dragging GtkEntry or GtkTreeView contents shows a drag-icon.

    I've prepared a button as drag source under Gtk+-3.24.4. When dragging the button, the mouse cursor disappears and no drag icon is shown.

    When using gtk_drag_source_set_icon_pixbuf(bt, pixbuf), the pixbuf appears as drag icon. But doing it this way is only half the job done, because move/copy indicators are missing on the icon.

    0 讨论(0)
提交回复
热议问题