Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Feb 12, 2024
1 parent 188891c commit 043cda6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 46 deletions.
5 changes: 2 additions & 3 deletions src/Views/FiltersView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,8 @@ public class Display.FiltersView : Gtk.Box {
}

construct {
var context = get_style_context ();
context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_class (color);
get_style_context ().add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
add_css_class (color);

valign = CENTER;
}
Expand Down
10 changes: 6 additions & 4 deletions src/Widgets/DisplayWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public class Display.DisplayWidget : Gtk.Widget {
if (refresh_combobox.active == -1) refresh_combobox.set_active (0);

if (use_switch.active) {
get_style_context ().remove_class ("disabled");
remove_css_class ("disabled");
} else {
add_css_class ("disabled");
}
Expand Down Expand Up @@ -567,9 +567,11 @@ public class Display.DisplayWidget : Gtk.Widget {
use_switch.sensitive = !is_primary;
}

public void get_preferred_size (out Gtk.Requisition minimum_size, out Gtk.Requisition natural_size) {
minimum_size.height = (int)(real_height * window_ratio);
minimum_size.width = (int)(real_width * window_ratio);
public new void get_preferred_size (out Gtk.Requisition minimum_size, out Gtk.Requisition natural_size) {
minimum_size = Gtk.Requisition () {
height = (int)(real_height * window_ratio),
width = (int)(real_width * window_ratio)
};

natural_size = minimum_size;
}
Expand Down
75 changes: 36 additions & 39 deletions src/Widgets/DisplaysOverlay.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class Display.DisplaysOverlay : Gtk.Box {
private Gtk.Overlay overlay;
private bool scanning = false;
private double current_ratio = 1.0f;
private int current_allocated_width = 0;
private int current_allocated_height = 0;
private int current_width = 0;
private int current_height = 0;
private int default_x_margin = 0;
private int default_y_margin = 0;

Expand Down Expand Up @@ -87,7 +87,7 @@ public class Display.DisplaysOverlay : Gtk.Box {

private bool on_get_child_position (Gtk.Widget widget, out Gdk.Rectangle allocation) {
allocation = Gdk.Rectangle ();
if (current_allocated_width != get_allocated_width () || current_allocated_height != get_allocated_height ()) {
if (current_width != get_width () || current_height != get_height ()) {
calculate_ratio ();
}

Expand Down Expand Up @@ -177,52 +177,49 @@ public class Display.DisplaysOverlay : Gtk.Box {
max_height = int.max (max_height, y + height);
}

current_allocated_width = get_allocated_width ();
current_allocated_height = get_allocated_height ();
current_width = get_width ();
current_height = get_height ();
current_ratio = double.min (
(double) (get_allocated_width () - 24) / (double) added_width,
(double) (get_allocated_height () - 24) / (double) added_height
(double) (get_width () - 24) / (double) added_width,
(double) (get_height () - 24) / (double) added_height
);
default_x_margin = (int) ((get_allocated_width () - max_width * current_ratio) / 2);
default_y_margin = (int) ((get_allocated_height () - max_height * current_ratio) / 2);
default_x_margin = (int) ((get_width () - max_width * current_ratio) / 2);
default_y_margin = (int) ((get_height () - max_height * current_ratio) / 2);
}

private void add_output (Display.VirtualMonitor virtual_monitor) {
var display_widget = new DisplayWidget (virtual_monitor);
current_allocated_width = 0;
current_allocated_height = 0;
current_width = 0;
current_height = 0;
overlay.add_overlay (display_widget);
display_widgets.append (display_widget);

var color_number = (display_widgets.length () - 2) % 7;

var colored_css = COLORED_STYLE_CSS.printf (colors[color_number], text_colors[color_number]);

var provider = new Gtk.CssProvider ();
try {
var color_number = (display_widgets.length () - 2) % 7;

var colored_css = COLORED_STYLE_CSS.printf (colors[color_number], text_colors[color_number]);
provider.load_from_data (colored_css.data);

var context = display_widget.get_style_context ();
context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_class ("colored");

// context = display_widget.display_window.get_style_context ();
// context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
// context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
// context.add_class ("colored");

context = display_widget.primary_image.get_style_context ();
context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_class ("colored");

context = display_widget.toggle_settings.get_style_context ();
context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_class ("colored");
} catch (GLib.Error e) {
critical (e.message);
}
provider.load_from_data (colored_css.data);

var context = display_widget.get_style_context ();
context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_class ("colored");

// context = display_widget.display_window.get_style_context ();
// context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
// context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
// context.add_class ("colored");

context = display_widget.primary_image.get_style_context ();
context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_class ("colored");

context = display_widget.toggle_settings.get_style_context ();
context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
context.add_class ("colored");

display_widget.set_as_primary.connect (() => set_as_primary (display_widget.virtual_monitor));

Expand Down

0 comments on commit 043cda6

Please sign in to comment.