Repository navigation
Expand file tree
/
Copy pathMessageDialog.vala
More file actions
94 lines (87 loc) · 2.94 KB
/
Copy pathMessageDialog.vala
File metadata and controls
94 lines (87 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* ev3devKit - ev3dev toolkit for LEGO MINDSTORMS EV3
*
* Copyright 2014 David Lechner <david@lechnology.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
/* MessageDialog.vala - Dialog that displays message to user */
using Grx;
namespace Ev3devKit.Ui {
/**
* A dialog for displaying a message.
*
* The dialog contains a title and message separated by a horizontal line.
*/
public class MessageDialog : Ev3devKit.Ui.Dialog {
Scroll vscroll;
Label title_label;
construct {
var content_vbox = new Box.vertical ();
add (content_vbox);
title_label = new Label () {
vertical_align = WidgetAlign.START,
padding = 3,
border_bottom = 1
};
content_vbox.add (title_label);
vscroll = new Scroll.vertical () {
can_focus = false,
margin_bottom = 9
};
content_vbox.add (vscroll);
}
/**
* Creates a new message dialog.
*
* @param title The title text.
* @param message The message text.
*/
public MessageDialog (string title, string message) {
vscroll.add (new Label (message));
title_label.text = title;
}
/**
* Creates a new message dialog with the given widget as content.
*
* @param title The title text.
* @param content The content widget.
*/
public MessageDialog.with_content (string title, Widget content) {
vscroll.add (content);
title_label.text = title;
}
/**
* Default handler for the key_pressed signal.
*/
public override bool key_pressed (uint key_code) {
switch (key_code) {
case Key.UP:
vscroll.scroll_backward ();
break;
case Key.DOWN:
vscroll.scroll_forward ();
break;
case Key.RETURN:
return base.key_pressed (Key.BACK_SPACE);
default:
return base.key_pressed (key_code);
}
Signal.stop_emission_by_name (this, "key-pressed");
return true;
}
}
}