diff --git a/src/Views/FiltersView.vala b/src/Views/FiltersView.vala index 5e59ac13..7d4e776c 100644 --- a/src/Views/FiltersView.vala +++ b/src/Views/FiltersView.vala @@ -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; } diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index 2e716917..d567efc4 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -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"); } @@ -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; } diff --git a/src/Widgets/DisplaysOverlay.vala b/src/Widgets/DisplaysOverlay.vala index e2e932ee..c71628fe 100644 --- a/src/Widgets/DisplaysOverlay.vala +++ b/src/Widgets/DisplaysOverlay.vala @@ -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; @@ -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 (); } @@ -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));