Skip to content

Conversation

@GuessWhatBBQ
Copy link
Contributor

@GuessWhatBBQ GuessWhatBBQ commented Jan 23, 2021

This solves/satisfies the feature request in #543 by creating another config variable called text_icon_padding which defaults to 0, but when set with a pixel value adds that to the regular h_padding to create the desired effect.

Testing is required to see if it breaks any of the regular padding behavior.

@codecov-io
Copy link

codecov-io commented Jan 23, 2021

Codecov Report

Merging #810 (75d3004) into master (77bfbc4) will increase coverage by 0.01%.
The diff coverage is 10.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #810      +/-   ##
==========================================
+ Coverage   59.48%   59.50%   +0.01%     
==========================================
  Files          36       36              
  Lines        5798     5798              
==========================================
+ Hits         3449     3450       +1     
+ Misses       2349     2348       -1     
Flag Coverage Δ
unittests 59.50% <10.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/draw.c 0.00% <0.00%> (ø)
src/settings.c 58.92% <100.00%> (+0.13%) ⬆️
src/x11/screen.c 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77bfbc4...75d3004. Read the comment docs.

@GuessWhatBBQ GuessWhatBBQ marked this pull request as ready for review January 23, 2021 10:14
@GuessWhatBBQ GuessWhatBBQ changed the title Adding a config parameter that adds extra space between the notification icon and text Adding a config variable that adds extra space between the notification icon and text Jan 23, 2021
@GuessWhatBBQ
Copy link
Contributor Author

It would also be nice if the config file allowed more fine tuned control of padding in general. For example adding padding to text and icons separately and also specify the direction of the padding (top/bottom/left/right)

@fwsmit
Copy link
Member

fwsmit commented Jan 23, 2021

The PR looks good. I haven't tested it yet, though. Could you add some documentation in dunst.pod about the new setting?

This solves/satisfies the feature request in #543 by creating another config variable called text_icon_padding which defaults to 0, but when set with a pixel value adds that to the regular h_padding to create the desired effect.

As currently worded in dunstrc, it seems like the text_icon_padding replaces the horizontal padding. I think that's the most intuitive for users. Could you consider implementing it that way, instead of adding to h_padding?

It would also be nice if the config file allowed more fine tuned control of padding in general. For example adding padding to text and icons separately and also specify the direction of the padding (top/bottom/left/right)

It's worth thinking about, but we should be careful making the config too long or complicated.

@GuessWhatBBQ
Copy link
Contributor Author

I see what you mean about the wording.

But just so we're clear, lets say this is the behavior without any text_icon_padding

h_padding=3
text_icon_padding=0

_________________________
|---00000---IamAmessa---|
|---00000---ge       ---|
|---00000---Summary  ---|
|---00000---Body     ---|
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

0 = Icon
- = Guaranteed padding regardless of message size


According to you it should be like this

h_padding=3
text_icon_padding=2

_________________________
|---00000--IamAmessag---|
|---00000--e         ---|
|---00000--Summary   ---|
|---00000--Body      ---|
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

Compared to what my PR does right now:

h_padding=3
text_icon_padding=2

_________________________
|---00000-----IamAmes---|
|---00000-----sage   ---|
|---00000-----Summary---|
|---00000-----Body   ---|
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾

The think an implementation like the first one would require a bit more work, but I'm concerned about whether this is truly the desired effect.

@fwsmit
Copy link
Member

fwsmit commented Jan 23, 2021

I don't know what's most intuitive to users, but text_icon_padding suggests to me that it's the distance between the text and the icon.
About implementation, it's not much harder. You can just subtract the horizontal padding after getting the config value (make sure to check if it's zero before that though). It's a little less clean, but it makes documenting it easier.

@GuessWhatBBQ
Copy link
Contributor Author

I think that should do it

dunstrc Outdated
# Padding between text and icon.
text_icon_padding = 0


Copy link
Member

Choose a reason for hiding this comment

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

One newline too many

src/draw.c Outdated
width -= cairo_image_surface_get_width(cl->icon) + settings.text_icon_padding;
}
else {
width -= cairo_image_surface_get_width(cl->icon) + settings.h_padding;
Copy link
Member

Choose a reason for hiding this comment

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

You could simplify this by adding a function get_text_icon_padding() which returns either h_padding or text_icon_padding. By adding that, you don't need if's here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've thought about that. Honestly the entire file could use a lot more modularization

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the drawing code is pretty rough (and untested)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That modularization could also allow the fine tuning controls I mentioned before

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it would be good to do that. It's probably best to first modularize it, then add tests and lastly add some fine tuning controls.

@fwsmit
Copy link
Member

fwsmit commented Jan 25, 2021

Thank you for taking the time to change it. After these comments, it should be good.

Copy link
Member

@tsipinakis tsipinakis left a comment

Choose a reason for hiding this comment

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

Some code style issues, lets keep things consistent. Code looks good but I haven't tested it yet, I'll do that tomorrow.

There's also a binary file that made its way in there src/settings.h.gch, please remove it :).

@fwsmit
Copy link
Member

fwsmit commented Jan 26, 2021

LGTM, thank you!

Copy link
Member

@tsipinakis tsipinakis left a comment

Choose a reason for hiding this comment

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

LGTM. However, from the quick tests I did the looks of the increased padding looked weird to me. I'm curious about the usecase here (perhaps it just doesn't suit my config?).

That issue has 5 upvotes so I'll merge this either way.

@GuessWhatBBQ
Copy link
Contributor Author

I set my h_padding to 0 because I dont like the icon getting smaller. This has the added side effect of making the icon and text almost touch and that looks weird to me. So that's why the added gap is required like this.

2021-01-27-084550_456x84_scrot

@fwsmit
Copy link
Member

fwsmit commented Jan 27, 2021

Makes sense. I'll merge it so I can fix more conflicts in #799.

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.

4 participants