Merge lp:~rodrigo-moya/ubuntuone-client/fix-614047 into lp:ubuntuone-client

Proposed by Rodrigo Moya
Status: Merged
Approved by: Manuel de la Peña
Approved revision: 668
Merged at revision: 676
Proposed branch: lp:~rodrigo-moya/ubuntuone-client/fix-614047
Merge into: lp:ubuntuone-client
Diff against target: 122 lines (+48/-3)
1 file modified
nautilus/contacts-view.c (+48/-3)
To merge this branch: bzr merge lp:~rodrigo-moya/ubuntuone-client/fix-614047
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Roman Yepishev (community) fieldtest Approve
Review via email: mp+34312@code.launchpad.net

Commit message

Draw a separator between recently used contacts and the rest

Description of the change

Draw a separator between recently used contacts and the rest

To post a comment you must log in.
Revision history for this message
Roman Yepishev (rye) wrote :

How can this be tested?

review: Needs Information (fieldtest)
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

> How can this be tested?

Run nautilus/test-contacts-picker, select some contacts and press OK. Then run it again, and see the contacts you previously selected displayed at the top, and then a separator and then the rest of the contacts in alphabetical order

Revision history for this message
Roman Yepishev (rye) wrote :

I see the separator :)
http://ubuntuone.com/p/Ehd/

review: Approve (fieldtest)
Revision history for this message
Manuel de la Peña (mandel) wrote :

+1 I got a new separator :D

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nautilus/contacts-view.c'
2--- nautilus/contacts-view.c 2010-07-20 15:10:34 +0000
3+++ nautilus/contacts-view.c 2010-09-01 15:04:40 +0000
4@@ -38,6 +38,7 @@
5 #define CONTACTS_VIEW_COLUMN_MARKUP 1
6 #define CONTACTS_VIEW_COLUMN_EMAIL 2
7 #define CONTACTS_VIEW_COLUMN_PIXBUF 3
8+#define CONTACTS_VIEW_COLUMN_RECENT 4
9
10 typedef struct {
11 gchar *name;
12@@ -200,6 +201,7 @@
13 EContactPhoto *photo = NULL;
14 GtkTreeModel *model;
15 GdkPixbuf *pixbuf;
16+ gboolean new_is_recent;
17
18 /* Get the pixbuf for this contact */
19 if (contact != NULL) {
20@@ -250,6 +252,8 @@
21 model = gtk_tree_view_get_model (GTK_TREE_VIEW (cv->contacts_list));
22 #endif
23
24+ new_is_recent = g_hash_table_lookup (cv->recently_used, name) != NULL;
25+
26 if (gtk_tree_model_get_iter_first (model, &current_row)) {
27 gchar *current_name;
28 gboolean added = FALSE;
29@@ -261,13 +265,12 @@
30 #endif
31
32 do {
33- gboolean new_is_recent, current_is_recent, insert_before = FALSE;
34+ gboolean current_is_recent, insert_before = FALSE;
35
36 gtk_tree_model_get (model, &current_row,
37 CONTACTS_VIEW_COLUMN_NAME, &current_name,
38 -1);
39
40- new_is_recent = g_hash_table_lookup (cv->recently_used, name) != NULL;
41 current_is_recent = g_hash_table_lookup (cv->recently_used, current_name) != NULL;
42
43 if (g_hash_table_lookup (selection_hash, current_name) != NULL)
44@@ -300,6 +303,7 @@
45 CONTACTS_VIEW_COLUMN_MARKUP, markedup_name,
46 CONTACTS_VIEW_COLUMN_EMAIL, email,
47 CONTACTS_VIEW_COLUMN_PIXBUF, pixbuf,
48+ CONTACTS_VIEW_COLUMN_RECENT, new_is_recent,
49 -1);
50 }
51
52@@ -386,6 +390,7 @@
53 CONTACTS_VIEW_COLUMN_MARKUP, contact_markedup_name,
54 CONTACTS_VIEW_COLUMN_EMAIL, contact_email,
55 CONTACTS_VIEW_COLUMN_PIXBUF, pixbuf,
56+ CONTACTS_VIEW_COLUMN_RECENT, TRUE,
57 -1);
58
59 #ifdef BUILD_GRID_VIEW
60@@ -493,6 +498,38 @@
61 }
62 }
63
64+static gboolean
65+row_separator_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
66+{
67+ gboolean current_is_recent, other_is_recent;
68+ GtkTreePath *path;
69+ gboolean result = FALSE;
70+ ContactsView *cv = CONTACTS_VIEW (user_data);
71+
72+ gtk_tree_model_get (model, iter,
73+ CONTACTS_VIEW_COLUMN_RECENT, &current_is_recent,
74+ -1);
75+
76+ path = gtk_tree_model_get_path (model, iter);
77+ if (path != NULL) {
78+ if (gtk_tree_path_prev (path)) {
79+ GtkTreeIter previous;
80+
81+ if (gtk_tree_model_get_iter (model, &previous, path)) {
82+ gtk_tree_model_get (model, &previous,
83+ CONTACTS_VIEW_COLUMN_RECENT, &other_is_recent,
84+ -1);
85+ if (other_is_recent && !current_is_recent)
86+ result = TRUE;
87+ }
88+ }
89+
90+ gtk_tree_path_free (path);
91+ }
92+
93+ return result;
94+}
95+
96 static void
97 contacts_view_init (ContactsView *cv)
98 {
99@@ -524,7 +561,12 @@
100 GTK_POLICY_AUTOMATIC);
101
102 /* Create the contacts list */
103- model = GTK_TREE_MODEL (gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, NULL));
104+ model = GTK_TREE_MODEL (gtk_list_store_new (5, G_TYPE_STRING,
105+ G_TYPE_STRING,
106+ G_TYPE_STRING,
107+ GDK_TYPE_PIXBUF,
108+ G_TYPE_BOOLEAN,
109+ NULL));
110
111 #ifdef BUILD_GRID_VIEW
112 cv->contacts_list = gtk_icon_view_new_with_model (model);
113@@ -538,6 +580,9 @@
114 G_CALLBACK (selection_changed_cb), cv);
115 #else
116 cv->contacts_list = gtk_tree_view_new_with_model (model);
117+ gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (cv->contacts_list),
118+ (GtkTreeViewRowSeparatorFunc) row_separator_func,
119+ cv, NULL);
120 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (cv->contacts_list), FALSE);
121 gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (cv->contacts_list), -1,
122 "Avatar",

Subscribers

People subscribed via source and target branches