Merge lp:~philip.scott/pantheon-photos/editable-title into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by Felipe Escoto
Status: Merged
Approved by: Danielle Foré
Approved revision: 3037
Merged at revision: 3038
Proposed branch: lp:~philip.scott/pantheon-photos/editable-title
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 184 lines (+131/-5)
3 files modified
src/CMakeLists.txt (+2/-1)
src/sidebar/EditableTitle.vala (+125/-0)
src/sidebar/metadata/LibraryProperties.vala (+4/-4)
To merge this branch: bzr merge lp:~philip.scott/pantheon-photos/editable-title
Reviewer Review Type Date Requested Status
Danielle Foré Approve
Review via email: mp+310114@code.launchpad.net

Commit message

LibraryProperties: Change title entry for an EditableTitle

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

I would like to have:
* The whole label be activatable
* save on focus out

I think without those it feels a little awkward

review: Needs Fixing
Revision history for this message
Felipe Escoto (philip.scott) wrote :

I kinda disagree on the save on focus out. I feel like having that confirmation is good either with clicking the button, or by pressing enter

But it does feel a lot less awkward with the whole label being clickable

3035. By Felipe Escoto

Editable label on Library Details

Revision history for this message
Danielle Foré (danrabbit) wrote :

It appears that clicking the icon focuses the entry automatically, but clicking the label does not

3036. By Felipe Escoto

Grab focus and refactoring

Revision history for this message
Danielle Foré (danrabbit) wrote :

I think you might have made a small oops :p

Revision history for this message
Danielle Foré (danrabbit) :
3037. By Felipe Escoto

Fixed my oops

Revision history for this message
Felipe Escoto (philip.scott) :
Revision history for this message
Danielle Foré (danrabbit) wrote :

LGTM. I'm happy

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2016-09-24 19:18:52 +0000
+++ src/CMakeLists.txt 2016-11-06 03:45:29 +0000
@@ -175,6 +175,7 @@
175 sidebar/Entry.vala175 sidebar/Entry.vala
176 sidebar/Sidebar.vala176 sidebar/Sidebar.vala
177 sidebar/Tree.vala177 sidebar/Tree.vala
178 sidebar/EditableTitle.vala
178179
179 sidebar/metadata/BasicProperties.vala180 sidebar/metadata/BasicProperties.vala
180 sidebar/metadata/ExtendedProperties.vala181 sidebar/metadata/ExtendedProperties.vala
@@ -217,7 +218,7 @@
217218
218include_directories (${CMAKE_SOURCE_DIR}/vapi)219include_directories (${CMAKE_SOURCE_DIR}/vapi)
219add_executable (${EXEC_NAME} ${VALA_C} ${PLUGIN_VALA_C} ${CONFIG_FILE})220add_executable (${EXEC_NAME} ${VALA_C} ${PLUGIN_VALA_C} ${CONFIG_FILE})
220target_link_libraries (${EXEC_NAME} ${DEPS_LIBRARIES}) 221target_link_libraries (${EXEC_NAME} ${DEPS_LIBRARIES})
221222
222install (TARGETS ${EXEC_NAME} RUNTIME DESTINATION bin)223install (TARGETS ${EXEC_NAME} RUNTIME DESTINATION bin)
223224
224225
=== added file 'src/sidebar/EditableTitle.vala'
--- src/sidebar/EditableTitle.vala 1970-01-01 00:00:00 +0000
+++ src/sidebar/EditableTitle.vala 2016-11-06 03:45:29 +0000
@@ -0,0 +1,125 @@
1/*-
2 * Copyright (c) 2016 Pantheon Developers (https://launchpad.net/pantheon-photos)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Authored by: Corentin Noël <corentin@elementary.io>
20 */
21
22public class EditableTitle : Gtk.EventBox {
23 public signal void changed (string new_title);
24 private Gtk.Label title;
25 private Gtk.Entry entry;
26 private Gtk.Stack stack;
27 private Gtk.Grid grid;
28
29 public string text {
30 get {
31 return title.label;
32 }
33
34 set {
35 title.label = value;
36 }
37 }
38
39 private bool editing {
40 set {
41 if (value) {
42 entry.text = title.label;
43 stack.set_visible_child (entry);
44 entry.grab_focus ();
45 } else {
46 if (entry.text.strip () != "" && title.label != entry.text) {
47 title.label = entry.text;
48 changed (entry.text);
49 }
50
51 stack.set_visible_child (grid);
52 }
53 }
54 }
55
56 public EditableTitle (string? title_name) {
57 valign = Gtk.Align.CENTER;
58 events |= Gdk.EventMask.ENTER_NOTIFY_MASK;
59 events |= Gdk.EventMask.LEAVE_NOTIFY_MASK;
60 events |= Gdk.EventMask.BUTTON_PRESS_MASK;
61
62 title = new Gtk.Label (title_name);
63 title.ellipsize = Pango.EllipsizeMode.END;
64 title.hexpand = true;
65 ((Gtk.Misc) title).xalign = 0;
66
67 var edit_button = new Gtk.Button ();
68 edit_button.image = new Gtk.Image.from_icon_name ("edit-symbolic", Gtk.IconSize.MENU);
69 edit_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
70 var button_revealer = new Gtk.Revealer ();
71 button_revealer.valign = Gtk.Align.CENTER;
72 button_revealer.transition_type = Gtk.RevealerTransitionType.CROSSFADE;
73 button_revealer.add (edit_button);
74
75 grid = new Gtk.Grid ();
76 grid.valign = Gtk.Align.CENTER;
77 grid.column_spacing = 12;
78 grid.add (title);
79 grid.add (button_revealer);
80
81 entry = new Gtk.Entry ();
82 entry.secondary_icon_name = "go-jump-symbolic";
83
84 stack = new Gtk.Stack ();
85 stack.transition_type = Gtk.StackTransitionType.CROSSFADE;
86 stack.add (grid);
87 stack.add (entry);
88 add (stack);
89
90 enter_notify_event.connect ((event) => {
91 if (event.detail != Gdk.NotifyType.INFERIOR) {
92 button_revealer.set_reveal_child (true);
93 }
94
95 return false;
96 });
97
98 leave_notify_event.connect ((event) => {
99 if (event.detail != Gdk.NotifyType.INFERIOR) {
100 button_revealer.set_reveal_child (false);
101 }
102
103 return false;
104 });
105
106 button_press_event.connect ((event) => {
107 editing = true;
108 return false;
109 });
110
111 edit_button.clicked.connect (() => {
112 editing = true;
113 });
114
115 entry.activate.connect (() => {
116 editing = false;
117 });
118
119 entry.icon_release.connect ((p0, p1) => {
120 if (p0 == Gtk.EntryIconPosition.SECONDARY) {
121 editing = false;
122 }
123 });
124 }
125}
0126
=== modified file 'src/sidebar/metadata/LibraryProperties.vala'
--- src/sidebar/metadata/LibraryProperties.vala 2016-09-19 21:18:06 +0000
+++ src/sidebar/metadata/LibraryProperties.vala 2016-11-06 03:45:29 +0000
@@ -7,7 +7,7 @@
7private class LibraryProperties : Properties {7private class LibraryProperties : Properties {
8 private MediaSource? media_source;8 private MediaSource? media_source;
9 private string comment;9 private string comment;
10 private Gtk.Entry title_entry;10 private EditableTitle title_entry;
11 private Gtk.Entry tags_entry;11 private Gtk.Entry tags_entry;
12 private PlaceHolderTextView comment_entry;12 private PlaceHolderTextView comment_entry;
13 private bool is_media;13 private bool is_media;
@@ -66,9 +66,9 @@
66 base.internal_update_properties (page);66 base.internal_update_properties (page);
6767
68 if (is_media) {68 if (is_media) {
69 title_entry = new Gtk.Entry ();69 title_entry = new EditableTitle (null);
70 if (title != null)70 if (title != null)
71 title_entry.set_text (title);71 title_entry.text = title;
72 title_entry.changed.connect (title_entry_changed);72 title_entry.changed.connect (title_entry_changed);
73 add_entry_line (_("Title"), title_entry);73 add_entry_line (_("Title"), title_entry);
7474
@@ -124,7 +124,7 @@
124 }124 }
125125
126 private void title_entry_changed () {126 private void title_entry_changed () {
127 title = title_entry.get_text ();127 title = title_entry.text;
128 }128 }
129129
130 private void tags_entry_changed () {130 private void tags_entry_changed () {

Subscribers

People subscribed via source and target branches

to all changes: