Skip to content

Icon for debugger in the toolbar#16661

Merged
Ducasse merged 3 commits intopharo-project:Pharo13from
badetitou:16594-Icon-for-debugger-in-the-toolbar
Jun 13, 2024
Merged

Icon for debugger in the toolbar#16661
Ducasse merged 3 commits intopharo-project:Pharo13from
badetitou:16594-Icon-for-debugger-in-the-toolbar

Conversation

@badetitou
Copy link
Copy Markdown
Member

@badetitou badetitou commented May 15, 2024

In the past, we were use to have the icon of the window in the toolbar.

Issue summary

For instance, in Pharo 10, we had the icon for the debugger (see screenshot)
image

But, in Pharo12. we lose this icon (see second screenshot)
image

This PR aims to add it back as presented in the last screenshot
image

Fix detail

To fix the issue. I first discovered that TaskbarItemMorph is created from a TaskbarTask, but the model of TaskbarItemMorph is the actual window morph and not the TaskbarTask object. However, the window might not have all the correct information such as the correct icon. However, the TaskbarTask has a reference to the window morph, the label of the TaskbarItemMorph, the correct label, and the state of the window morph.
So, I concluded that TaskbarTask is the perfect object for being the model of the TaskbarItemMorph. I thus modify the code to make TaskbarTask the model of TaskbarItemMorph.
Then, I fixed the methods of TaskbarTask and TaskbarItemMorph in a way that they call the correct method and tada.

On my computer, I have the correct icon, I have pre-visualisation of windows, and I can open/close windows. I also have the correct label color with minimized and maximized windows in the taskbar.

I do not know where to had tests for this kind of feature, but I can have a look if someone has idea (I dunno if it was tested)

fix #16594

@Rinzwind
Copy link
Copy Markdown
Contributor

The icons seem to have gone missing due to the changes in commit b25824e010604f57 and Spec commit 1e0ba07e672b77af: #initializeFor: on TaskbarItemMorph was changed to send #taskbarIconName instead of #taskbarIcon, and the implementation of #taskbarIcon on SystemWindow was replaced by an implementation of #taskbarIconName that sends the same message, but the implementation of #taskbarIcon on SpWindowPresenter was not replaced by an implementation of #taskbarIconName. Implementing #taskbarIconName on SpWindowPresenter as follows restores the icon for a debugger (it’s only a partial fix as it ignores the send of #windowIcon in #taskbarIcon for which there is no equivalent #windowIconName yet):

taskbarIconName

	^ self presenter
		ifNil: [ super taskbarIconName ]
		ifNotNil: #taskbarIconName

Note that the change to #initializeFor: on TaskbarItemMorph in this pull request reverses the use of the FormSet for the icon introduced in pull request #16316.

@badetitou
Copy link
Copy Markdown
Member Author

Thanks for the explanation.

Do you think TaskbarTask should not be the model of the TaskbarItemMorph?
Maybe we could modify TaskbarTask by changing the icon attribute by iconName, and so keeping the usage of FormSet?

@Rinzwind
Copy link
Copy Markdown
Contributor

I would suggest to maybe first fix the missing #taskbarIconName on SpWindowPresenter and to then check whether it would still make sense to change the model passed to the TaskbarItemMorph.

A change in commit 09f40b6 that is not so clear to me is the removal of the send of #taskbarButtonFor: from #taskbarButtonFor: on TaskbarTask which seems to not take into account that there are other implementations of #taskbarButtonFor: besides the one on SystemWindow. The implementation of #performAction: on TaskbarItemMorph seems to be a copy of the one inherited from PluggableButtonMorph with model replaced by model morph, that may need to be abstracted better.

@badetitou
Copy link
Copy Markdown
Member Author

I try to do this in an image based on the code of #taskbarIcon. But it does not fix the issue.

I would suggest to maybe first fix the missing #taskbarIconName on SpWindowPresenter and to then check whether it would still make sense to change the model passed to the TaskbarItemMorph.

I agree that model morph is strange and we should find a better solution

"Answer the icon for the receiver in a task bar
or nil for the default."

^self class taskbarIconName
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only default formatting

@badetitou
Copy link
Copy Markdown
Member Author

I updated the code to use only iconName instead of icon and so to use a iconSetForm.

@Ducasse
Copy link
Copy Markdown
Member

Ducasse commented Jun 13, 2024

So I imagine that now I can merge?

@Ducasse Ducasse merged commit fdbc7bf into pharo-project:Pharo13 Jun 13, 2024
demarey added a commit that referenced this pull request Jun 14, 2024
…ger-in-the-toolbar"

This reverts commit fdbc7bf, reversing
changes made to ba35433.
@Rinzwind
Copy link
Copy Markdown
Contributor

@badetitou: Regarding your third comment, I’m not quite sure what you tried and why that wouldn’t have worked. Try implementing the following on SpWindowPresenter in Pharo 13 build 97:

windowIconName

	^ self windowIcon ifNotNil: [ :form |
		Smalltalk ui icons icons keyAtValue: form ifAbsent: [ #notFound ] ]

taskbarIconName

	^ self windowIconName ifNil: [
		self presenter
			ifNil: [ super taskbarIconName ]
			ifNotNil: #taskbarIconName ]

This implementation of #windowIconName is a hack (not to be committed!). I’m assuming that, following the changes in commit b25824e010 and Spec commit 1e0ba07e67, the idea is that #windowIcon: should be reworked to #windowIconName: so that #windowIconName would just be an accessor.

One case in which this won’t work is the icon created in #iconForWindow on IceTipGitHubRepositoryPanel. That could be solved by adding it to the ThemeIcons as is done in #iconName for StRewriterMatchToolPresenter. But that seems like a hack as well, it would be better to have those two icons added to the icon pack.

@Rinzwind
Copy link
Copy Markdown
Contributor

I opened a pull request to add the two icons to the icon pack: pharo-icon-packs pull request #13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Icon for debugger in the toolbar

3 participants