Merge lp:~tintou/granite/granite-gobject into lp:~elementary-pantheon/granite/granite

Proposed by Corentin Noël
Status: Merged
Approved by: Corentin Noël
Approved revision: 852
Merged at revision: 852
Proposed branch: lp:~tintou/granite/granite-gobject
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 127 lines (+38/-29)
2 files modified
lib/Widgets/Welcome.vala (+7/-2)
lib/Widgets/WelcomeButton.vala (+31/-27)
To merge this branch: bzr merge lp:~tintou/granite/granite-gobject
Reviewer Review Type Date Requested Status
Rico Tzschichholz Approve
Review via email: mp+257016@code.launchpad.net

Commit message

Use GObject style for creating the Welcome widget.
Style changes to the WelcomeButton.

Description of the change

Use GObject style for creating the Welcome widget.
Style changes to the WelcomeButton.

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

Can confirm that the code change from relief none to flat css style doesn't break anything.

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

This is not gobject-style-construction and wont work as expected for your use-case (Gtk.Bbuilder) afaics. Keep the constructor above construct.

lp:~tintou/granite/granite-gobject updated
852. By Corentin Noël

[Welcome] Use GObject-style construction.

Revision history for this message
Rico Tzschichholz (ricotz) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Widgets/Welcome.vala'
2--- lib/Widgets/Welcome.vala 2015-03-25 22:30:35 +0000
3+++ lib/Widgets/Welcome.vala 2015-04-22 20:58:50 +0000
4@@ -67,6 +67,7 @@
5
6 private Gtk.Label title_label;
7 private Gtk.Label subtitle_label;
8+
9 /**
10 * Makes new Welcome Page
11 *
12@@ -74,6 +75,10 @@
13 * @param subtitle_text subtitle text for new Welcome Page
14 */
15 public Welcome (string title_text, string subtitle_text) {
16+ Object (title: title_text, subtitle: subtitle_text);
17+ }
18+
19+ construct {
20 Gtk.Box content = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
21
22 // Box properties
23@@ -83,13 +88,13 @@
24 content.pack_start (new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0), true, true, 0);
25
26 // Labels
27- title_label = new Gtk.Label (title_text);
28+ title_label = new Gtk.Label (null);
29 title_label.get_style_context ().add_class ("h1");
30
31 title_label.set_justify (Gtk.Justification.CENTER);
32 content.pack_start (title_label, false, true, 0);
33
34- subtitle_label = new Gtk.Label (subtitle_text);
35+ subtitle_label = new Gtk.Label (null);
36 subtitle_label.get_style_context ().add_class ("h2");
37
38 subtitle_label.set_line_wrap (true);
39
40=== modified file 'lib/Widgets/WelcomeButton.vala'
41--- lib/Widgets/WelcomeButton.vala 2015-03-25 22:30:35 +0000
42+++ lib/Widgets/WelcomeButton.vala 2015-04-22 20:58:50 +0000
43@@ -23,6 +23,8 @@
44
45 Gtk.Label button_title;
46 Gtk.Label button_description;
47+ Gtk.Image? _icon;
48+ Gtk.Grid button_grid;
49
50 /**
51 * Title property of the Welcome Button
52@@ -49,46 +51,48 @@
53 *
54 * @since 0.3
55 */
56- public Gtk.Image? icon { get; private set; }
57+ public Gtk.Image? icon {
58+ get { return _icon; }
59+ set {
60+ if (_icon != null) {
61+ _icon.destroy ();
62+ }
63+ _icon = value;
64+ if (_icon != null) {
65+ _icon.set_pixel_size (48);
66+ _icon.halign = Gtk.Align.CENTER;
67+ _icon.valign = Gtk.Align.CENTER;
68+ button_grid.attach (_icon, 0, 0, 1, 2);
69+ }
70+ }
71+ }
72
73 public WelcomeButton (Gtk.Image? image, string option_text, string description_text) {
74- icon = image;
75+ Object (title: option_text, description: description_text, icon: image);
76+ }
77
78+ construct {
79 // Title label
80- button_title = new Gtk.Label (option_text);
81+ button_title = new Gtk.Label (null);
82 button_title.get_style_context ().add_class ("h3");
83 button_title.halign = Gtk.Align.START;
84- button_title.valign = Gtk.Align.CENTER;
85+ button_title.valign = Gtk.Align.END;
86
87 // Description label
88- button_description = new Gtk.Label (description_text);
89+ button_description = new Gtk.Label (null);
90 button_description.halign = Gtk.Align.START;
91- button_description.valign = Gtk.Align.CENTER;
92+ button_description.valign = Gtk.Align.START;
93 button_description.set_line_wrap (true);
94 button_description.set_line_wrap_mode (Pango.WrapMode.WORD);
95
96- this.set_relief (Gtk.ReliefStyle.NONE);
97+ get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
98
99 // Button contents wrapper
100- var button_contents = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 7);
101-
102- // Add left image
103- if (icon != null) {
104- icon.set_pixel_size (48);
105- button_contents.pack_start (icon, false, true, 8);
106- }
107-
108- // Add right text wrapper
109- var text_wrapper = new Gtk.Box (Gtk.Orientation.VERTICAL, 3);
110- // top spacing
111- text_wrapper.pack_start (new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0), true, true, 0);
112- text_wrapper.pack_start (button_title, false, false, 0);
113- text_wrapper.pack_start (button_description, false, false, 0);
114- // bottom spacing
115- text_wrapper.pack_end (new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0), true, true, 0);
116-
117- button_contents.pack_start (text_wrapper, false, true, 8);
118-
119- this.add (button_contents);
120+ button_grid = new Gtk.Grid ();
121+ button_grid.column_spacing = 12;
122+
123+ button_grid.attach (button_title, 1, 0, 1, 1);
124+ button_grid.attach (button_description, 1, 1, 1, 1);
125+ this.add (button_grid);
126 }
127 }

Subscribers

People subscribed via source and target branches