Skip to content

Commit 6dd5e1a

Browse files
committed
Retrieve sizes from entries before resize
Fixes: #13
1 parent 2f86c0c commit 6dd5e1a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/Window.vala

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ namespace Resizer {
2424
// public class Window : Gtk.ApplicationWindow {
2525

2626
private Settings settings = new Settings (Constants.PROJECT_NAME);
27+
private Gtk.SpinButton width_entry;
28+
private Gtk.SpinButton height_entry;
2729

2830
public Window () {
2931
Object (border_width: 6,
@@ -39,24 +41,18 @@ namespace Resizer {
3941
var width_label = new Gtk.Label (_("Width:"));
4042
width_label.halign = Gtk.Align.START;
4143

42-
var width_entry = new Gtk.SpinButton.with_range (1, 10000, 1000);
44+
width_entry = new Gtk.SpinButton.with_range (1, 10000, 1000);
4345
width_entry.hexpand = true;
4446
width_entry.set_activates_default (true);
4547
settings.bind ("width", width_entry, "value", GLib.SettingsBindFlags.DEFAULT);
46-
width_entry.value_changed.connect (() => {
47-
Resizer.maxWidth = width_entry.get_value_as_int ();
48-
});
4948

5049
var height_label = new Gtk.Label (_("Height:"));
5150
height_label.halign = Gtk.Align.START;
5251

53-
var height_entry = new Gtk.SpinButton.with_range (1, 10000, 1000);
52+
height_entry = new Gtk.SpinButton.with_range (1, 10000, 1000);
5453
height_entry.hexpand = true;
5554
height_entry.set_activates_default (true);
5655
settings.bind ("height", height_entry, "value", GLib.SettingsBindFlags.DEFAULT);
57-
height_entry.value_changed.connect (() => {
58-
Resizer.maxHeight = height_entry.get_value_as_int ();
59-
});
6056

6157
var grid = new Gtk.Grid ();
6258
grid.column_spacing = 12;
@@ -86,6 +82,8 @@ namespace Resizer {
8682
private void on_response (Gtk.Dialog source, int response_id) {
8783
switch (response_id) {
8884
case Gtk.ResponseType.APPLY:
85+
Resizer.maxWidth = width_entry.get_value_as_int ();
86+
Resizer.maxHeight = height_entry.get_value_as_int ();
8987
Resizer.create_resized_image();
9088
destroy ();
9189
break;

0 commit comments

Comments
 (0)