Closed super7ramp closed 2 years ago
Thanks for the investigation! Feel free to create such well-researched, patch-heavy issues directly as draft PRs if it works for you.
The following patch fixes the sizing issue but is a bit awkward - plus I doubt the result would look nice for HiDPI monitors:
It's not going to support moving the window to another display, but should be fine for single-resolution setup. That's what the PX()
macro does.
I agree it's awkward hack, but I don't think we can do any better yet — we'd need to extend wxIconLocation with support for wxBitmapBundle
to allow representing differently sized icons.
We could also - and it's no less of a hack - manipulate fullname
to get desired size. There's going to be either "scalable" or "256x256" or such in the path in your case, and we could replace it with "16x16" or "32x32". I tried looking into that, but apparently wxGTK won't even retrieve the icon in the version I have on the distro I have.
Notice that GTK+ uses a global setting called gtk-menu-images to determine if the images should be shown in the menus at all. If it is off (which is the case in e.g. Gnome 2.28 by default), no images will be shown, consistently with the native behaviour.
The bigger question, before applying these patches, is what should the right behavior be here? Should Poedit be using icons or not? gtk-menu-images
and GtkImageMenuItem
are deprecated and the guideline is to decide in application code on showing icons or not:
You should consider using icons in menu items only sparingly, and for “objects” (or “nouns”) elements only, like bookmarks, files, and links; “actions” (or “verbs”) should not have icons.
So we can use icons for files, the question is whether we should, and whether we should bypass gtk-menu-images
(as would arguably be truly native GTK+3 behavior).
Feel free to create such well-researched, patch-heavy issues directly as draft PRs if it works for you.
Thanks, noted.
(Although here, I might have been too eager to show patches: As you rightly pointed out, it should be decided first whether these icons should be displayed or not on GTK >=3.)
The bigger question, before applying these patches, is what should the right behavior be here? Should Poedit be using icons or not?
I agree that's the important question.
Here are some arguments for both possible answers:
Arguments in favor of answer "Yes":
Arguments in favor of answer "No":
/usr/share/icons/Adwaita/512x512/mimetypes/text-x-generic.png
), so under this environment icon doesn't help easily spot different file types in the list.and whether we should bypass gtk-menu-images (as would arguably be truly native GTK+3 behavior).
I tend to think that letting the application choose the right behaviour and bypass deprecated gtk-menu-images would be the way to go with GTK >=3. With GTK4, Gtk.ImageMenuItem
doesn't exist anymore so it would be inevitable.
we'd need to extend wxIconLocation with support for
wxBitmapBundle
to allow representing differently sized icons.
I've been playing with wxBitmapBundle
and it looks better than resizing the image:
With icon resizing | With wxBitmapBundle |
---|---|
Although:
wxBitmapBundle
support.wxBitmapBundle
I guess it's OK for wxMSW to set the bitmap after the item has been appended but it doesn't work with wxGTK 2.
It was actually broken on wxMSW too, just in a more subtle and less deterministic way.
Here are some arguments for both possible answers:
Sorry for being unclear: what I'm after is knowing what the right thing is in GNOME's point of view. And I know, the first answer would be "all of this UI is completely wrong" - modern GNOME apps don't have recent files menu, they don't have menu mostly and the HIG doesn't talk about such mundane things.
But pragmatically, I don't have the resources to redo Poedit's UI on Linux to be like GNOME. Given that, I'm not sure how to approach the recent files menu.
The only "official" argument - for "no icons" - that I could find is gedit. It has a toolbar button for opening files and clicking the downarrow on it shows a list of recently edited files - as plain list, with no icons (and not looking like any other popup menu either). I didn't have any luck finding other GNOME apps with recent files.
I did also check GIMP and Inkscape and they both have Open Recent menu and use icons.
I tend to think that letting the application choose the right behaviour and bypass deprecated gtk-menu-images would be the way to go with GTK >=3. With GTK4, Gtk.ImageMenuItem doesn't exist anymore so it would be inevitable.
It's GtkImageMenuItem that is deprecated (as an artifact of dealing of too-icon-rich-menus of the past), not the concept of using icons. So yes, the question extends to whether it's worth doing anything for GTK4 or not.
I didn't have any luck finding other GNOME apps with recent files.
Here are some other examples I could find.
With icons:
Without icons (even if gtk-menu-images=1)
Also there are some applications without a recent files menu but with a recent file access on their welcome screen only. It might be an alternative given that Poedit has a welcome screen and RecentFilesCtrl
that plays this role on non-wxGTK platforms.
With icons:
Without icons:
With icons: Glade (UI Designer) Vinagre (Remote Desktop Viewer)
Thanks. These two projects are sufficiently GNOME-associated, I think, to consider them as relevant. And if they use icons, so should we. I applied your changes until there's a better way with wx.
Thanks a lot!
Environment
Bug
Icons of items in "Recent files" menu are not displayed under wxGTK.
The following message is printed twice for each time in "Recent files" menu when Poedit is launched from command line [^1].
I believe this is due to the current usage of
wxMenuItem::SetBitmap
inMyHistory::DoAddFile
; method is called after the item has been appended to the menu:This is not compliant with the documentation:
I guess it's OK for wxMSW to set the bitmap after the item has been appended but it doesn't work with wxGTK [^2].
Proposed patch
The following patch fixes the issue:
Although it reveals that the sizing of the icon is wrong (under wxGTK):
The following patch fixes the sizing issue but is a bit awkward - plus I doubt the result would look nice for HiDPI monitors:
Steps to reproduce
gtk-menu-images=1
to~/.config/gtk-3.0/settings.ini
[^3].Note: If you have already opened po file in the past and your "Recent files" menu is already populated, then you can skip steps 2 to 4.
Actual result
Note: The assertion error is printed even if
gtk-menu-images=0
.Expected Result
[^1]: The assertion error is raised with wxGTK >= 3.1.6 and is due to changes of https://github.com/wxWidgets/wxWidgets/pull/22087.
[^2]: It looks like one could replace
menuItem = gtk_menu_item_new_with_label("");
atsrc/gtk/menu.cpp#L1037
bymenuItem = gtk_image_menu_item_new_with_label("");
in order not to require the bitmap to be set before the item is appended to the menu. However, asGtkImageMenuItem
is deprecated and aswxMenuItem::SetBitmap
documents the usage I haven't investigated further.[^3]: As described in
wxMenuItem::SetBitmap
documentation, default GTK behaviour has been not to show any images in menu for some time - which would explain why this issue hasn't been spotted earlier: