Merge lp:~artem-anufrij/granite/change-label-description-after-creating into lp:~elementary-pantheon/granite/granite

Proposed by Artem Anufrij
Status: Superseded
Proposed branch: lp:~artem-anufrij/granite/change-label-description-after-creating
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 205 lines (+112/-37)
4 files modified
demo/GraniteDemo.vala (+8/-0)
lib/CMakeLists.txt (+1/-0)
lib/Widgets/Welcome.vala (+15/-37)
lib/Widgets/WelcomeButton.vala (+88/-0)
To merge this branch: bzr merge lp:~artem-anufrij/granite/change-label-description-after-creating
Reviewer Review Type Date Requested Status
Corentin Noël Pending
elementary Pantheon team abi-wise Pending
Review via email: mp+245454@code.launchpad.net

This proposal supersedes a proposal from 2014-12-24.

This proposal has been superseded by a proposal from 2015-01-29.

Description of the change

Functionality for changing label, description and icon of a welcome screen button after creating them.

To post a comment you must log in.
Revision history for this message
Corentin Noël (tintou) wrote : Posted in a previous version of this proposal

I would prefer a :
    public Granite.Widgets.WelcomeButton get_button_from_index (int index)
in the Welcome widget.

And a :
   public string title { get {…}, set {…} }
   public string description { get {…}, set {…} }
   public Gtk.Image icon { get {…}, private set; }
in the WelcomeButton widget.

Revision history for this message
Corentin Noël (tintou) wrote : Posted in a previous version of this proposal

Also please remove the
using Gtk;

Revision history for this message
Artem Anufrij (artem-anufrij) wrote : Posted in a previous version of this proposal
Revision history for this message
Artem Anufrij (artem-anufrij) wrote : Posted in a previous version of this proposal

Added a click event on welcome screen (DEMO):
https://launchpadlibrarian.net/193361508/Bildschirmfoto%20vom%202014-12-24%2014%3A21%3A54.png

The properties (title, description, icon) were moved on the top of the class.

Revision history for this message
Corentin Noël (tintou) wrote : Posted in a previous version of this proposal

Now it's perfect!

review: Approve
Revision history for this message
Corentin Noël (tintou) wrote : Posted in a previous version of this proposal

In the right request…
Now it's perfect!

review: Approve
Revision history for this message
Corentin Noël (tintou) wrote : Posted in a previous version of this proposal

Can someone confirm that this won't break anything ABI-wise ?

826. By Sergey Zolotarev

Prevent notebook tabs from stealing focus (lp:1395686)

827. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

828. By Cody Garver

Deprecate Granite.ThinPaned in favor of Gtk.Paned

829. By Fabio Zaramella

Wrap long Welcome subtitles and descriptions

830. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

831. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

832. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

833. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

834. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

835. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

836. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

837. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

838. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

839. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

840. By Corentin Noël

[CellRendererExpander] Gtk+ 3.14 now uses Gtk.StateFlags.CHECKED instead of Gtk.StateFlags.ACTIVE.

841. By Cody Garver

CMake: bump minimum version of Gtk to >= 3.14

842. By Corentin Noël

Adds the deprecation annotation to deprecate widgets officially.
[WrapLabel] No need for this widget when Gtk.Label provides wrapping label.
[PopOver] Replaced by Gtk.Popover.

Fixed some deprecations annotations as we deprecate widgets when they are available in Gtk.

843. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

844. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

845. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

846. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

847. By Victor Martinez

ContractorView: Fix error when building with vala 0.28

848. By Artem Anufrij

Label and Description label can be changed after creating them.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'demo/GraniteDemo.vala'
2--- demo/GraniteDemo.vala 2014-05-12 02:42:17 +0000
3+++ demo/GraniteDemo.vala 2014-12-30 20:44:41 +0000
4@@ -410,6 +410,14 @@
5 welcome.append_with_image (image, "Open", "Select a file.");
6 welcome.append ("document-save", "Save", "With a much longer description.");
7
8+ welcome.activated.connect ((index) => {
9+ Granite.Widgets.WelcomeButton button = welcome.get_button_from_index (index);
10+
11+ button.title = "You clicked on the button: %d".printf(index);
12+ button.description = "This label, description and icon were changed after creating of this button.";
13+ button.icon.icon_name = "edit";
14+ });
15+
16 return welcome;
17 }
18
19
20=== modified file 'lib/CMakeLists.txt'
21--- lib/CMakeLists.txt 2014-09-04 12:39:00 +0000
22+++ lib/CMakeLists.txt 2014-12-30 20:44:41 +0000
23@@ -32,6 +32,7 @@
24 Widgets/CompositedWindow.vala
25 Widgets/AppMenu.vala
26 Widgets/Welcome.vala
27+ Widgets/WelcomeButton.vala
28 Widgets/ToolButtonWithMenu.vala
29 Widgets/PopOver.vala
30 Widgets/ContractorView.vala
31
32=== modified file 'lib/Widgets/Welcome.vala'
33--- lib/Widgets/Welcome.vala 2014-09-04 12:39:00 +0000
34+++ lib/Widgets/Welcome.vala 2014-12-30 20:44:41 +0000
35@@ -23,7 +23,7 @@
36 /**
37 * This class is for making a first-launch screen easily
38 *
39- * It can be used to create a list of one-time action items that need to be executed in order to setup the app.
40+ * It can be used to create a list of one-time action items that need to be executed in order to setup the app.
41 *
42 * {{../../doc/images/Welcome.png}}
43 */
44@@ -40,7 +40,7 @@
45 * Box for action items
46 */
47 protected Gtk.Box options;
48-
49+
50 /**
51 * This is the title of the welcome widget.
52 */
53@@ -185,41 +185,7 @@
54 */
55 public int append_with_image (Gtk.Image? image, string option_text, string description_text) {
56 // Option label
57- var label = new Gtk.Label (option_text);
58- label.get_style_context ().add_class ("h3");
59- label.halign = Gtk.Align.START;
60- label.valign = Gtk.Align.CENTER;
61-
62- // Description label
63- var description = new Gtk.Label (description_text);
64- description.halign = Gtk.Align.START;
65- description.valign = Gtk.Align.CENTER;
66-
67- // Button
68- var button = new Gtk.Button ();
69- button.set_relief (Gtk.ReliefStyle.NONE);
70-
71- // Button contents wrapper
72- var button_contents = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 7);
73-
74- // Add left image
75- if (image != null) {
76- image.set_pixel_size (48);
77- button_contents.pack_start (image, false, true, 8);
78- }
79-
80- // Add right text wrapper
81- var text_wrapper = new Gtk.Box (Gtk.Orientation.VERTICAL, 3);
82- // top spacing
83- text_wrapper.pack_start (new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0), true, true, 0);
84- text_wrapper.pack_start (label, false, false, 0);
85- text_wrapper.pack_start (description, false, false, 0);
86- // bottom spacing
87- text_wrapper.pack_end (new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0), true, true, 0);
88-
89- button_contents.pack_start (text_wrapper, false, true, 8);
90-
91- button.add (button_contents);
92+ var button = new WelcomeButton (image, option_text, description_text);
93 children.append (button);
94 options.pack_start (button, false, false, 0);
95
96@@ -231,4 +197,16 @@
97
98 return this.children.index (button);
99 }
100+
101+ /**
102+ * Returns a welcome button by index
103+ *
104+ * @param index index of action item to be returned
105+ */
106+ public Granite.Widgets.WelcomeButton get_button_from_index (int index) {
107+ if (index < children.length () && children.nth_data (index) is Gtk.Widget)
108+ return (children.nth_data (index) as WelcomeButton);
109+
110+ return null;
111+ }
112 }
113
114=== added file 'lib/Widgets/WelcomeButton.vala'
115--- lib/Widgets/WelcomeButton.vala 1970-01-01 00:00:00 +0000
116+++ lib/Widgets/WelcomeButton.vala 2014-12-30 20:44:41 +0000
117@@ -0,0 +1,88 @@
118+/*
119+ * Copyright (C) 2014-2014 Granite Developers
120+ *
121+ * This program or library is free software; you can redistribute it
122+ * and/or modify it under the terms of the GNU Lesser General Public
123+ * License as published by the Free Software Foundation; either
124+ * version 3 of the License, or (at your option) any later version.
125+ *
126+ * This library is distributed in the hope that it will be useful,
127+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
128+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
129+ * Lesser General Public License for more details.
130+ *
131+ * You should have received a copy of the GNU Lesser General
132+ * Public License along with this library; if not, write to the
133+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
134+ * Boston, MA 02110-1301 USA.
135+ *
136+ * Authored by: Artem Anufrij <artem.anufrij@live.de>
137+ */
138+
139+public class Granite.Widgets.WelcomeButton : Gtk.Button {
140+
141+ Gtk.Label button_title = new Gtk.Label ("");
142+ Gtk.Label button_description = new Gtk.Label ("");
143+
144+ /**
145+ * Title property of the Welcome Button
146+ *
147+ */
148+ public string title {
149+ get { return button_title.get_text (); }
150+ set { button_title.set_text (value); }
151+ }
152+
153+ /**
154+ * Description property of the Welcome Button
155+ *
156+ */
157+ public string description {
158+ get { return button_description.get_text (); }
159+ set { button_description.set_text (value); }
160+ }
161+
162+ /**
163+ * Image of the Welcome Button
164+ *
165+ */
166+ public Gtk.Image icon { get; private set; }
167+
168+ public WelcomeButton (Gtk.Image? image, string option_text, string description_text) {
169+ icon = image;
170+
171+ button_title.set_text (option_text);
172+ button_title.get_style_context ().add_class ("h3");
173+ button_title.halign = Gtk.Align.START;
174+ button_title.valign = Gtk.Align.CENTER;
175+
176+ // Description label
177+ button_description.set_text (description_text);
178+ button_description.halign = Gtk.Align.START;
179+ button_description.valign = Gtk.Align.CENTER;
180+
181+ this.set_relief (Gtk.ReliefStyle.NONE);
182+
183+ // Button contents wrapper
184+ var button_contents = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 7);
185+
186+ // Add left image
187+ if (icon != null) {
188+ icon.set_pixel_size (48);
189+ button_contents.pack_start (icon, false, true, 8);
190+ }
191+
192+ // Add right text wrapper
193+ var text_wrapper = new Gtk.Box (Gtk.Orientation.VERTICAL, 3);
194+ // top spacing
195+ text_wrapper.pack_start (new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0), true, true, 0);
196+ text_wrapper.pack_start (button_title, false, false, 0);
197+ text_wrapper.pack_start (button_description, false, false, 0);
198+ // bottom spacing
199+ text_wrapper.pack_end (new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0), true, true, 0);
200+
201+ button_contents.pack_start (text_wrapper, false, true, 8);
202+
203+ this.add (button_contents);
204+ }
205+}

Subscribers

People subscribed via source and target branches