Skip to content

Commit da02b6f

Browse files
authored
PixelPicker: cleanup (#2180)
1 parent b80927a commit da02b6f

File tree

1 file changed

+59
-72
lines changed

1 file changed

+59
-72
lines changed

src/Widgets/PixelPicker.vala

Lines changed: 59 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,79 @@
1-
//
2-
// Copyright (C) 2020 elementary, Inc. (https://elementary.io)
3-
//
4-
// This program is free software: you can redistribute it and/or modify
5-
// it under the terms of the GNU General Public License as published by
6-
// the Free Software Foundation, either version 3 of the License, or
7-
// (at your option) any later version.
8-
//
9-
// This program is distributed in the hope that it will be useful,
10-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
// GNU General Public License for more details.
13-
//
14-
// You should have received a copy of the GNU General Public License
15-
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
//
17-
18-
namespace Gala {
19-
public class PixelPicker : Clutter.Actor {
20-
public signal void closed ();
21-
22-
public WindowManager wm { get; construct; }
23-
public bool cancelled { get; private set; }
24-
public Graphene.Point point { get; private set; }
25-
26-
private ModalProxy? modal_proxy;
27-
28-
public PixelPicker (WindowManager wm) {
29-
Object (wm: wm);
30-
}
1+
/*
2+
* SPDX-License-Identifier: GPL-3.0-or-later
3+
* SPDX-FileCopyrightText: 2020 elementary, Inc. (https://elementary.io)
4+
*/
315

32-
construct {
33-
point.init (0, 0);
34-
visible = true;
35-
reactive = true;
6+
public class Gala.PixelPicker : Clutter.Actor {
7+
public signal void closed ();
368

37-
int screen_width, screen_height;
38-
wm.get_display ().get_size (out screen_width, out screen_height);
39-
width = screen_width;
40-
height = screen_height;
41-
}
9+
public WindowManager wm { get; construct; }
10+
public bool cancelled { get; private set; }
11+
public Graphene.Point point { get; private set; }
12+
13+
private ModalProxy? modal_proxy;
14+
15+
public PixelPicker (WindowManager wm) {
16+
Object (wm: wm);
17+
}
18+
19+
construct {
20+
point.init (0, 0);
21+
visible = true;
22+
reactive = true;
23+
24+
int screen_width, screen_height;
25+
wm.get_display ().get_size (out screen_width, out screen_height);
26+
width = screen_width;
27+
height = screen_height;
28+
}
4229

4330
#if HAS_MUTTER45
44-
public override bool key_press_event (Clutter.Event e) {
31+
public override bool key_press_event (Clutter.Event e) {
4532
#else
46-
public override bool key_press_event (Clutter.KeyEvent e) {
33+
public override bool key_press_event (Clutter.KeyEvent e) {
4734
#endif
48-
if (e.get_key_symbol () == Clutter.Key.Escape) {
49-
close ();
50-
cancelled = true;
51-
closed ();
52-
return true;
53-
}
54-
55-
return false;
35+
if (e.get_key_symbol () == Clutter.Key.Escape) {
36+
cancelled = true;
37+
close ();
38+
39+
return true;
5640
}
5741

42+
return false;
43+
}
44+
5845
#if HAS_MUTTER45
59-
public override bool button_release_event (Clutter.Event e) {
46+
public override bool button_release_event (Clutter.Event e) {
6047
#else
61-
public override bool button_release_event (Clutter.ButtonEvent e) {
48+
public override bool button_release_event (Clutter.ButtonEvent e) {
6249
#endif
63-
if (e.get_button () != Clutter.Button.PRIMARY) {
64-
return true;
65-
}
50+
if (e.get_button () != Clutter.Button.PRIMARY) {
51+
return true;
52+
}
6653

67-
float x, y;
68-
e.get_coords (out x, out y);
69-
point = Graphene.Point () { x = x, y = y };
54+
float x, y;
55+
e.get_coords (out x, out y);
56+
point = Graphene.Point () { x = x, y = y };
7057

71-
close ();
72-
this.hide ();
58+
hide ();
59+
close ();
7360

74-
closed ();
75-
return true;
76-
}
61+
return true;
62+
}
7763

78-
public void close () {
79-
wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
80-
if (modal_proxy != null) {
81-
wm.pop_modal (modal_proxy);
82-
}
64+
private void close () {
65+
wm.get_display ().set_cursor (Meta.Cursor.DEFAULT);
66+
if (modal_proxy != null) {
67+
wm.pop_modal (modal_proxy);
8368
}
8469

85-
public void start_selection () {
86-
wm.get_display ().set_cursor (Meta.Cursor.CROSSHAIR);
87-
grab_key_focus ();
70+
closed ();
71+
}
8872

89-
modal_proxy = wm.push_modal (this);
90-
}
73+
public void start_selection () {
74+
wm.get_display ().set_cursor (Meta.Cursor.CROSSHAIR);
75+
grab_key_focus ();
76+
77+
modal_proxy = wm.push_modal (this);
9178
}
9279
}

0 commit comments

Comments
 (0)