Skip to content
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

Port to GTK4 #92

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ asresources = gnome.compile_resources(
c_name: 'as'
)

wingpanel_dep = dependency('wingpanel')
wingpanel_dep = dependency('wingpanel', version: '>=4.0.0')
wingpanel_indicatorsdir = wingpanel_dep.get_pkgconfig_variable('indicatorsdir', define_variable: ['libdir', libdir])

config_data = configuration_data()
Expand All @@ -42,8 +42,8 @@ shared_module(
dependencies: [
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('granite', version: '>=6.0.0'),
dependency('gtk+-3.0'),
dependency('granite-7'),
dependency('gtk4'),
wingpanel_dep
],
install: true,
Expand Down
21 changes: 11 additions & 10 deletions src/Indicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,28 @@ public class Nightlight.Indicator : Wingpanel.Indicator {

public override Gtk.Widget get_display_widget () {
if (indicator_icon == null) {
weak Gtk.IconTheme default_theme = Gtk.IconTheme.get_default ();
weak Gtk.IconTheme default_theme = Gtk.IconTheme.get_for_display (Gdk.Display.get_default ());
default_theme.add_resource_path ("/io/elementary/wingpanel/nightlight");

indicator_icon = new Gtk.Spinner ();

var click_gesture = new Gtk.GestureClick () {
button = Gdk.BUTTON_MIDDLE,
};

click_gesture.released.connect ((n, x, y) => {
NightLight.Manager.get_instance ().toggle_snooze ();
});

indicator_icon.add_controller (click_gesture);

var provider = new Gtk.CssProvider ();
provider.load_from_resource ("io/elementary/wingpanel/nightlight/indicator.css");

style_context = indicator_icon.get_style_context ();
style_context.add_class ("night-light-icon");
style_context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

indicator_icon.button_press_event.connect ((e) => {
if (e.button == Gdk.BUTTON_MIDDLE) {
NightLight.Manager.get_instance ().toggle_snooze ();
return Gdk.EVENT_STOP;
}

return Gdk.EVENT_PROPAGATE;
});

var nightlight_manager = NightLight.Manager.get_instance ();
nightlight_manager.notify["snoozed"].connect (() => {
var snoozed = nightlight_manager.snoozed;
Expand Down
30 changes: 14 additions & 16 deletions src/Widgets/PopoverWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* Boston, MA 02110-1301 USA
*/

public class Nightlight.Widgets.PopoverWidget : Gtk.Grid {
public class Nightlight.Widgets.PopoverWidget : Gtk.Box {
public unowned Nightlight.Indicator indicator { get; construct set; }
public unowned Settings settings { get; construct set; }

private Granite.SwitchModelButton toggle_switch;
private Gtk.Grid scale_grid;
private Gtk.Box scale_box;
private Gtk.Image image;
private Gtk.Scale temp_scale;
private const int TEMP_CHANGE_DELAY_MS = 300;
Expand All @@ -39,7 +39,7 @@ public class Nightlight.Widgets.PopoverWidget : Gtk.Grid {

public bool snoozed {
set {
scale_grid.sensitive = !value;
scale_box.sensitive = !value;
toggle_switch.active = value;

if (value) {
Expand Down Expand Up @@ -81,27 +81,25 @@ public class Nightlight.Widgets.PopoverWidget : Gtk.Grid {
temp_scale.width_request = 200;
temp_scale.get_style_context ().add_class ("warmth");

scale_grid = new Gtk.Grid ();
scale_grid.column_spacing = 6;
scale_grid.margin_start = 6;
scale_grid.margin_end = 12;
scale_grid.add (image);
scale_grid.add (temp_scale);
scale_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
scale_box.margin_start = 6;
scale_box.margin_end = 12;
scale_box.append (image);
scale_box.append (temp_scale);

var scale_sep = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) {
margin_top = 3,
margin_bottom = 3
};

var settings_button = new Gtk.ModelButton ();
settings_button.text = _("Night Light Settings…");
var settings_button = new Gtk.Button.with_label (_("Night Light Settings…"));
settings_button.clicked.connect (show_settings);

add (toggle_switch);
add (toggle_sep);
add (scale_grid);
add (scale_sep);
add (settings_button);
append (toggle_switch);
append (toggle_sep);
append (scale_box);
append (scale_sep);
append (settings_button);

snoozed = NightLight.Manager.get_instance ().snoozed;

Expand Down