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: 169 lines (+87/-37)
3 files modified
lib/CMakeLists.txt (+1/-0)
lib/Widgets/Welcome.vala (+10/-37)
lib/Widgets/WelcomeButton.vala (+76/-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 Approve
Review via email: mp+245043@code.launchpad.net

This proposal has been superseded by a proposal from 2014-12-24.

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.
820. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

821. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

822. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

Revision history for this message
Corentin Noël (tintou) wrote :

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 :

Also please remove the
using Gtk;

823. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

Revision history for this message
Artem Anufrij (artem-anufrij) wrote :
Revision history for this message
Corentin Noël (tintou) wrote :

Now it's perfect!

review: Approve
824. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

825. By Launchpad Translations on behalf of elementary-pantheon

Launchpad automatic translations update.

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

Subscribers

People subscribed via source and target branches