-
-
Notifications
You must be signed in to change notification settings - Fork 50
AliasDialog: use ListStore #1082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ebbc8de
AliasDialog: use ListStore
danirabbit 479e4d1
Merge branch 'master' into danirabbit/aliasdialog-liststore
danirabbit 377aa3c
Update AliasDialog.vala
danirabbit defcaf4
Merge branch 'master' into danirabbit/aliasdialog-liststore
danirabbit 162642c
Merge branch 'master' into danirabbit/aliasdialog-liststore
danirabbit 8008ac8
Merge branch 'master' into danirabbit/aliasdialog-liststore
danirabbit 092cde2
Fix add alias
danirabbit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,8 @@ public class Mail.AliasDialog : Granite.Dialog { | |
| public string account_uid { get; construct; } | ||
|
|
||
| private HashTable<string, string?> aliases; | ||
| private Gtk.ListBox list; | ||
| private ListStore alias_list; | ||
| private Gtk.ListBox list_box; | ||
| private Granite.Widgets.Toast toast; | ||
| private string primary_name; | ||
|
|
||
|
|
@@ -51,16 +52,19 @@ public class Mail.AliasDialog : Granite.Dialog { | |
| placeholder.add (placeholder_description); | ||
| placeholder.show_all (); | ||
|
|
||
| list = new Gtk.ListBox () { | ||
| alias_list = new ListStore (typeof (Alias)); | ||
|
|
||
| list_box = new Gtk.ListBox () { | ||
| vexpand = true, | ||
| hexpand = true, | ||
| selection_mode = NONE | ||
| }; | ||
| list.set_filter_func ((Gtk.ListBoxFilterFunc) filter_func); | ||
| list.set_placeholder (placeholder); | ||
| list_box.bind_model (alias_list, (obj) => (Alias) obj); | ||
| list_box.set_filter_func ((Gtk.ListBoxFilterFunc) filter_func); | ||
| list_box.set_placeholder (placeholder); | ||
|
|
||
| var scrolled_window = new Gtk.ScrolledWindow (null, null) { | ||
| child = list, | ||
| child = list_box, | ||
| hscrollbar_policy = NEVER | ||
| }; | ||
|
|
||
|
|
@@ -111,26 +115,26 @@ public class Mail.AliasDialog : Granite.Dialog { | |
| var extension = (E.SourceMailIdentity) identity_source.get_extension (E.SOURCE_EXTENSION_MAIL_IDENTITY); | ||
| primary_name = extension.name; | ||
|
|
||
| populate_list (); | ||
| populate_list_box (); | ||
|
|
||
| add_button.clicked.connect (() => create_new_alias ()); | ||
|
|
||
| toast.default_action.connect (() => { | ||
| foreach (var child in list.get_children ()) { | ||
| if (child is Alias) { | ||
| ((Alias) child).undo_delete (); | ||
| } | ||
| for (int i = 0; i < alias_list.n_items; i++) { | ||
| ((Alias) alias_list.get_item (i)).undo_delete (); | ||
| } | ||
|
|
||
| list.invalidate_filter (); | ||
| list_box.invalidate_filter (); | ||
| }); | ||
|
|
||
| response.connect (destroy); | ||
|
|
||
| delete_event.connect (() => { | ||
| foreach (var child in list.get_children ()) { | ||
| if (child is Alias && ((Alias) child).is_deleted) { | ||
| aliases.remove (((Alias) child).address); | ||
| for (int i = 0; i < alias_list.n_items; i++) { | ||
| var alias = (Alias) alias_list.get_item (i); | ||
| if (alias.is_deleted) { | ||
| alias_list.remove (i); | ||
| aliases.remove (alias.address); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -144,7 +148,7 @@ public class Mail.AliasDialog : Granite.Dialog { | |
| return !alias.is_deleted; | ||
| } | ||
|
|
||
| private void populate_list () { | ||
| private void populate_list_box () { | ||
| aliases = Mail.Backend.Session.get_default ().get_aliases_for_account_uid (account_uid); | ||
|
|
||
| if (aliases == null) { | ||
|
|
@@ -173,19 +177,23 @@ public class Mail.AliasDialog : Granite.Dialog { | |
| }); | ||
|
|
||
| alias.start_delete.connect (() => { | ||
| list.invalidate_filter (); | ||
| list_box.invalidate_filter (); | ||
|
|
||
| toast.title = _("'%s' deleted").printf (alias.alias_name != "" ? alias.alias_name : alias.address); | ||
| toast.send_notification (); | ||
| }); | ||
|
|
||
| alias.finish_delete.connect (() => { | ||
| list.remove (alias); | ||
| uint pos = -1; | ||
| if (alias_list.find (alias, out pos)) { | ||
| alias_list.remove (pos); | ||
| }; | ||
|
|
||
| aliases.remove (alias.address); | ||
| write_aliases (); | ||
| }); | ||
|
|
||
| list.add (alias); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to replace this with somthing! |
||
| alias_list.append (alias); | ||
| } | ||
|
|
||
| private void write_aliases () { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think filter functions are ignored when there is a bound model.