Merge lp:~elementary-apps/granite/sidebar-gobject-construction into lp:~elementary-apps/granite/sidebar-widget

Proposed by Danielle Foré
Status: Work in progress
Proposed branch: lp:~elementary-apps/granite/sidebar-gobject-construction
Merge into: lp:~elementary-apps/granite/sidebar-widget
Diff against target: 117 lines (+38/-27)
2 files modified
lib/Widgets/Sidebar/SidebarExpandableRow.vala (+13/-11)
lib/Widgets/Sidebar/SidebarHeader.vala (+25/-16)
To merge this branch: bzr merge lp:~elementary-apps/granite/sidebar-gobject-construction
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+304956@code.launchpad.net

Commit message

Use GObject style construction

To post a comment you must log in.

Unmerged revisions

990. By Danielle Foré

gobject style construction for expandable row and header

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Widgets/Sidebar/SidebarExpandableRow.vala'
2--- lib/Widgets/Sidebar/SidebarExpandableRow.vala 2016-09-04 18:50:52 +0000
3+++ lib/Widgets/Sidebar/SidebarExpandableRow.vala 2016-09-05 22:42:54 +0000
4@@ -27,15 +27,6 @@
5 public signal void row_activated (Gtk.ListBoxRow child);
6
7 public SidebarExpandableRow () {
8- children = new Gtk.ListBox ();
9-
10- revealer = new Gtk.Revealer ();
11- revealer.reveal_child = true;
12- revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN;
13- revealer.add (children);
14-
15- disclosure_triangle = new Gtk.Image.from_icon_name ("pan-down-symbolic", Gtk.IconSize.BUTTON);
16-
17 revealer.notify["reveal-child"].connect (() => {
18 if (revealer.reveal_child) {
19 disclosure_triangle.icon_name = "pan-down-symbolic";
20@@ -44,13 +35,24 @@
21 }
22 });
23
24- orientation = Gtk.Orientation.VERTICAL;
25-
26 children.row_activated.connect ((row) => {
27 row_activated (row);
28 });
29 }
30
31+ construct {
32+ children = new Gtk.ListBox ();
33+
34+ revealer = new Gtk.Revealer ();
35+ revealer.reveal_child = true;
36+ revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN;
37+ revealer.add (children);
38+
39+ disclosure_triangle = new Gtk.Image.from_icon_name ("pan-down-symbolic", Gtk.IconSize.BUTTON);
40+
41+ orientation = Gtk.Orientation.VERTICAL;
42+ }
43+
44 public void toggle_reveal_children () {
45 if (revealer.reveal_child) {
46 revealer.reveal_child = false;
47
48=== modified file 'lib/Widgets/Sidebar/SidebarHeader.vala'
49--- lib/Widgets/Sidebar/SidebarHeader.vala 2016-08-28 16:56:22 +0000
50+++ lib/Widgets/Sidebar/SidebarHeader.vala 2016-09-05 22:42:54 +0000
51@@ -20,13 +20,36 @@
52
53 namespace Granite.Widgets {
54 public class SidebarHeader : SidebarExpandableRow {
55+ public string label { get; construct; }
56+
57+ private Gtk.Button header;
58+ private Gtk.Revealer header_revealer;
59+
60 public SidebarHeader (string label) {
61+ Object (label: label);
62+
63+ header.clicked.connect (() => {
64+ toggle_reveal_children ();
65+ });
66+
67+ header.enter_notify_event.connect (() => {
68+ header_revealer.reveal_child = true;
69+ return false;
70+ });
71+
72+ header.leave_notify_event.connect (() => {
73+ header_revealer.reveal_child = false;
74+ return false;
75+ });
76+ }
77+
78+ construct {
79 var header_label = new Gtk.Label (label);
80 header_label.get_style_context ().add_class ("h4");
81 header_label.halign = Gtk.Align.START;
82 header_label.hexpand = true;
83
84- var header_revealer = new Gtk.Revealer ();
85+ header_revealer = new Gtk.Revealer ();
86 header_revealer.transition_type = Gtk.RevealerTransitionType.CROSSFADE;
87 header_revealer.add (disclosure_triangle);
88
89@@ -34,27 +57,13 @@
90 header_layout.add (header_label);
91 header_layout.add (header_revealer);
92
93- var header = new Gtk.Button ();
94+ header = new Gtk.Button ();
95 header.get_style_context ().add_class ("list-row");
96 header.get_style_context ().remove_class ("button");
97 header.add (header_layout);
98
99 add (header);
100 add (revealer);
101-
102- header.clicked.connect (() => {
103- toggle_reveal_children ();
104- });
105-
106- header.enter_notify_event.connect (() => {
107- header_revealer.reveal_child = true;
108- return false;
109- });
110-
111- header.leave_notify_event.connect (() => {
112- header_revealer.reveal_child = false;
113- return false;
114- });
115 }
116 }
117 }

Subscribers

People subscribed via source and target branches

to all changes: