Skip to content

Gtk.StyleContext, Gtk.StyleClass avoid and replace where possible #2552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: jeremypw/gtk4-skeleton
Choose a base branch
from

Conversation

jeremypw
Copy link
Collaborator

Simple avoidance/replacement of stylecontext use.

Style providers added to display instead of widgets. May need changes to css files and css names later.

Rendering will be addressed separately.

@jeremypw jeremypw mentioned this pull request Mar 19, 2025
3 tasks
@jeremypw jeremypw added the Gtk4 Issues that involve Gtk4 code label Jun 9, 2025
@jeremypw jeremypw added the Status: Blocked Cannot proceed until another issue is fixed label Jun 9, 2025
@jeremypw
Copy link
Collaborator Author

Some of these changes could be done in Gtk3?

@jeremypw jeremypw added this to the 8.0.0 milestone Jun 13, 2025
// info_bar.get_content_area ().add (info_label);

info_bar.add_css_class (Granite.STYLE_CLASS_FRAME);
// info_bar.get_content_area ()add (info_label);
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

notify["scale-factor"].connect (() => {
breadcrumb_icons.scale = scale_factor;
});
// notify["scale-factor"].connect (() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

weak Gtk.StyleContext style_context = get_style_context ();
// var padding = style_context.get_padding (style_context.get_state ());
// w += (l - 1) * (MINIMUM_BREADCRUMB_WIDTH + padding.left + padding.right);
w += (l - 1) * (MINIMUM_BREADCRUMB_WIDTH);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The commented-out code was summing two padding values. Is it okay that we’re no longer doing that?

if (breadcrumb_icons.scale != scale) {
breadcrumb_icons.scale = scale;
int scale = get_scale_factor ();
// if (breadcrumb_icons.scale != scale) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

}
set_element_icons (protocol, elements);
}
// string protocol = "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

@@ -236,8 +235,8 @@ public class Files.View.Chrome.BreadcrumbElement : Object {
if (is_rtl) {
if (icon_to_draw == null) {
if (room_for_text) {
button_context.render_layout (cr, x - width,
y_half_height - text_half_height, layout);
// button_context.render_layout (cr, x - width,
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

@@ -261,8 +260,8 @@ public class Files.View.Chrome.BreadcrumbElement : Object {

if (icon_to_draw == null) {
if (room_for_text) {
button_context.render_layout (cr, x,
y_half_height - text_half_height, layout);
// button_context.render_layout (cr, x,
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

@@ -275,8 +274,8 @@ public class Files.View.Chrome.BreadcrumbElement : Object {
cr.restore ();
}
if (text_is_displayed && room_for_text && x > 0) {
button_context.render_layout (cr, x + iw,
y_half_height - text_half_height, layout);
// button_context.render_layout (cr, x + iw,
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

button_context.render_frame (cr, -height / 2, -height / 2, height, height);
button_context.restore ();
// button_context.save ();
// button_context.add_class ("noradius-button");
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

button_context.add_class ("noradius-button");
button_context.render_frame (cr, -height / 2, -height / 2, height, height);
button_context.restore ();
// button_context.save ();
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

@@ -332,7 +331,7 @@ public class Files.View.Chrome.BreadcrumbElement : Object {
x += half_height;
}

button_context.restore ();
// button_context.restore ();
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

}
// set {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

// var style_context = get_style_context ();
// style_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
// style_context.add_class ("nohover");
// add_css_class ("nohover");
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

@@ -237,7 +238,7 @@ public class Files.Plugins.CTags : Files.Plugins.Base {
// return true;
// }

// if (Gtk.StateFlags.DIR_RTL in get_style_context ().get_state ()) {
// if (Gtk.TextDirection.RTL in get_direction ())
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

@@ -3281,13 +3280,13 @@ namespace Files {
public virtual bool on_view_draw (Cairo.Context cr) {
/* If folder is empty, draw the empty message in the middle of the view
* otherwise pass on event */
var style_context = get_style_context ();
// var style_context = get_style_context ();
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a commented out code here.

Copy link
Collaborator

@leonardo-lemos leonardo-lemos left a comment

Choose a reason for hiding this comment

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

Code looks good but there's a lot of commented-out code and a one comment.

@jeremypw
Copy link
Collaborator Author

@leonardo-lemos Sorry, this should have been set to draft really. As it is being merged into an intermediate gtk4 branch it is expected that some of the gtk3 code will have been commented out temporarily as each PR is only intended to address one aspect of porting - in this case style classes. in order to make easier to review.

As the Gtk3 version is still changing and the preparation phase is not finished these PRs are probably premature anyway.

@jeremypw jeremypw marked this pull request as draft June 14, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gtk4 Issues that involve Gtk4 code Status: Blocked Cannot proceed until another issue is fixed
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants