summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2017-09-14 01:53:28 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2017-09-14 01:53:28 +0200
commit62908b8fd58e60a65c5758a94c99fc806be08a56 (patch)
tree0a76d7eeec202777b898f4f7780acc484e7a0081
parente665b7a27a83f8427415bea899b00db9c8814e5b (diff)
downloadgnome-contacts-wip/nielsdg/types-rewrite.tar.gz
Cleanup: remove custom type entry.wip/nielsdg/types-rewrite
In reality, we want to support custom types (see bug 765226 [1]), but the code for that was basically removed in commit 331f5ba. For now, we remove that code so we can do a better job at cleaning up things. Note: in the future, we should probably use Gtk.Combobox.with_entry() instead. [1] https://bugzilla.gnome.org/show_bug.cgi?id=765226<Paste>
-rw-r--r--src/contacts-types.vala77
1 files changed, 2 insertions, 75 deletions
diff --git a/src/contacts-types.vala b/src/contacts-types.vala
index 4cef86a..a606e9b 100644
--- a/src/contacts-types.vala
+++ b/src/contacts-types.vala
@@ -35,8 +35,6 @@ public class Contacts.TypeSet : Object {
public bool in_store;
}
- // Dummy Data to mark the "Custom..." store entry
- private static Data custom_dummy = new Data ();
// Dummy Data to mark the "Other..." store entry
private static Data other_dummy = new Data ();
@@ -250,7 +248,6 @@ public class Contacts.TypeSet : Object {
store.get (iter, 0, out display_name, 1, out data);
assert (display_name != null); // Not separator
- assert (data != custom_dummy); // Not custom...
if (data == null) { // A custom label
details.parameters.set ("type", "OTHER");
@@ -270,12 +267,6 @@ public class Contacts.TypeSet : Object {
details.parameters.set ("type", "PREF");
}
- public bool is_custom (TreeIter iter) {
- Data data;
- store.get (iter, 1, out data);
- return data == custom_dummy;
- }
-
private static TypeSet _general;
private const InitData[] general_data = {
// List most specific first, always in upper case
@@ -370,9 +361,7 @@ public class Contacts.TypeSet : Object {
public class Contacts.TypeCombo : Grid {
TypeSet type_set;
ComboBox combo;
- Entry entry;
TreeIter last_active;
- bool custom_mode;
bool in_manual_change;
public bool modified;
@@ -396,63 +385,8 @@ public class Contacts.TypeCombo : Grid {
return s == null;
});
- entry = new Entry ();
- entry.get_style_context ().add_class ("contacts-entry");
- entry.set_halign (Align.FILL);
- entry.set_hexpand (true);
- // Make the default entry small so we don't unnecessarily
- // expand the labels (it'll be expanded a bit anyway)
- entry.width_chars = 4;
-
- this.add (entry);
-
- combo.set_no_show_all (true);
- entry.set_no_show_all (true);
-
- combo.show ();
-
combo.changed.connect (combo_changed);
- entry.focus_out_event.connect (entry_focus_out_event);
- entry.activate.connect (entry_activate);
- entry.key_release_event.connect (entry_key_release);
- }
-
- private void finish_custom () {
- if (!custom_mode)
- return;
-
- custom_mode = false;
- var text = entry.get_text ();
-
- if (text != "") {
- TreeIter iter;
- type_set.add_custom_label (text, out iter);
-
- last_active = iter;
- combo.set_active_iter (iter);
- } else {
- combo.set_active_iter (last_active);
- }
-
combo.show ();
- entry.hide ();
- }
-
- private void entry_activate () {
- finish_custom ();
- }
-
- private bool entry_key_release (Gdk.EventKey event) {
- if (event.keyval == Gdk.Key.Escape) {
- entry.set_text ("");
- finish_custom ();
- }
- return true;
- }
-
- private bool entry_focus_out_event (Gdk.EventFocus event) {
- finish_custom ();
- return false;
}
private void combo_changed (ComboBox combo) {
@@ -462,15 +396,8 @@ public class Contacts.TypeCombo : Grid {
modified = true;
TreeIter iter;
if (combo.get_active_iter (out iter)) {
- if (type_set.is_custom (iter)) {
- custom_mode = true;
- entry.show ();
- entry.grab_focus ();
- combo.hide ();
- } else {
- last_active = iter;
- this.changed ();
- }
+ last_active = iter;
+ this.changed ();
}
}