Skip to content

feat(widgets): add CircularProgressBar widget#417

Open
randomboi404 wants to merge 5 commits intoignis-sh:mainfrom
randomboi404:patch-2
Open

feat(widgets): add CircularProgressBar widget#417
randomboi404 wants to merge 5 commits intoignis-sh:mainfrom
randomboi404:patch-2

Conversation

@randomboi404
Copy link
Copy Markdown

  • Implemented CircularProgressBar as a GTK DrawingArea-based widget subclass
  • Includes factory function for easy creation TODO:
    Add support to edit properties using css. (As of now, css/scss does NOT work.)

- Implemented CircularProgressBar as a GTK DrawingArea-based widget subclass
- Includes factory function for easy creation
TODO:
Add support to edit properties using css. (As of now, css/scss does NOT work.)
@randomboi404
Copy link
Copy Markdown
Author

Done!

@randomboi404
Copy link
Copy Markdown
Author

All done!

self._track_color = track_color

BaseWidget.__init__(self, **kwargs)
self.set_size_request(size[0], size[1])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are already height_request and width_request properties

Comment on lines +50 to +61
value: float = 1.0,
min_value: float = 0.0,
child: Gtk.Widget | None = None,
max_value: float = 1.0,
start_angle: float = 0.0,
end_angle: float = 360.0,
line_width: int = 4,
line_style: Literal["none", "butt", "round", "square"] | cairo.LineCap = "round",
pie: bool = False,
invert: bool = False,
size: tuple[int, int] = (100, 100),
track_color: RGBA | None = None,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we shouldn't define them in constructor arguments, because they are GObject properties and can be handled by **kwargs automatically. The constructor should explicitly define arguments only for read-only properties, that can be set only during the widget initialization. By the way, I don't see track_color to be a GObject property, did you forget to add it?

The default values can be set below:

self._value: float = 1.0
self._min_value: float = 1.0
self._child: Gtk.Widget | None = None
# and so on...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bind-able values would be good too

Comment on lines +72 to +73
self.start_angle = start_angle
self.end_angle = end_angle
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should start with the underscore, otherwise it sets the value through the GObject setter which triggers queue_draw() additional two times

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.

3 participants