[california/wip/726809-rename: 2/3] That was easy.
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/726809-rename: 2/3] That was easy.
- Date: Thu, 1 May 2014 04:16:10 +0000 (UTC)
commit b49b76ef1835c705742f8fdadb33235f330eb096
Author: Jim Nelson <jim yorba org>
Date: Wed Apr 30 21:08:08 2014 -0700
That was easy.
src/manager/manager-calendar-list-item.vala | 48 +++++++++-----------------
1 files changed, 17 insertions(+), 31 deletions(-)
---
diff --git a/src/manager/manager-calendar-list-item.vala b/src/manager/manager-calendar-list-item.vala
index 08af2b7..0478dcd 100644
--- a/src/manager/manager-calendar-list-item.vala
+++ b/src/manager/manager-calendar-list-item.vala
@@ -36,8 +36,7 @@ internal class CalendarListItem : Gtk.Grid {
[GtkChild]
private Gtk.ColorButton color_button;
- private Toolkit.Popup? title_entry_popup = null;
- private Gtk.Entry? title_entry = null;
+ private Toolkit.EditableLabel? editable_label = null;
public CalendarListItem(Backing.CalendarSource source) {
this.source = source;
@@ -81,51 +80,38 @@ internal class CalendarListItem : Gtk.Grid {
return true;
}
- // Replaces title with a Gtk.Entry for the title that allows for the user to rename the calendar
- // ... if Enter is pressed, the name is accepted, Escape and clicking off of it is considered a
- // cancel
- private void activate_title_entry() {
- assert(title_entry_popup == null);
+ private void activate_editable_label() {
+ assert(editable_label == null);
- title_entry = new Gtk.Entry();
- title_entry.text = source.title;
- title_entry.width_chars = title_label.width_chars;
+ editable_label = new Toolkit.EditableLabel(title_label);
+ editable_label.accepted.connect(on_title_edit_accepted);
+ editable_label.dismissed.connect(remove_editable_label);
- title_entry_popup = new Toolkit.Popup(title_label, Toolkit.Popup.Position.VERTICAL_CENTER);
- title_entry_popup.margin = 0;
- title_entry_popup.add(title_entry);
- title_entry_popup.dismissed.connect(remove_title_entry);
-
- // Enter accepts
- title_entry.activate.connect(on_title_entry_accepted);
-
- title_entry_popup.show_all();
+ editable_label.show_all();
}
- private void remove_title_entry() {
- assert(title_entry_popup != null);
+ private void remove_editable_label() {
+ assert(editable_label != null);
- title_entry_popup.destroy();
- title_entry_popup = null;
- title_entry = null;
+ editable_label.destroy();
+ editable_label = null;
}
private bool on_title_button_release(Gdk.EventButton event) {
// if already accepting input or not selected, don't activate text entry for rename (but
// allow signal to propagate further)
- if (title_entry != null || !is_selected)
+ if (editable_label != null || !is_selected)
return false;
- activate_title_entry();
+ activate_editable_label();
+ // don't propagate
return true;
}
- private void on_title_entry_accepted() {
- if (!String.is_empty(title_entry.text))
- source.title = title_entry.text;
-
- title_entry_popup.dismiss();
+ private void on_title_edit_accepted(string text) {
+ if (!String.is_empty(text))
+ source.title = text;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]