Merge lp:~rodrigo-moya/ubuntuone-client/add-contacts-fixes into lp:ubuntuone-client

Proposed by Rodrigo Moya
Status: Merged
Approved by: Rodrigo Moya
Approved revision: 531
Merged at revision: 532
Proposed branch: lp:~rodrigo-moya/ubuntuone-client/add-contacts-fixes
Merge into: lp:ubuntuone-client
Diff against target: 306 lines (+198/-37)
5 files modified
nautilus/Makefile.am (+4/-0)
nautilus/add-contact-dialog.c (+134/-0)
nautilus/add-contact-dialog.h (+50/-0)
nautilus/u1-contacts-picker.c (+9/-36)
po/POTFILES.in (+1/-1)
To merge this branch: bzr merge lp:~rodrigo-moya/ubuntuone-client/add-contacts-fixes
Reviewer Review Type Date Requested Status
dobey (community) Needs Fixing
Rick McBride (community) Approve
Roman Yepishev (community) Approve
Review via email: mp+26600@code.launchpad.net

Commit message

Several fixes in adding contacts logic

Description of the change

Several fixes in adding contacts logic

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

Tested & it works the way it should according to bug reports.

review: Approve
Revision history for this message
Rick McBride (rmcbride) wrote :

+1

review: Approve
Revision history for this message
dobey (dobey) wrote :

The following files contain translations and are currently not in use. Please
consider adding these to the POTFILES.in file, located in the po/ directory.

nautilus/add-contact-dialog.c

review: Needs Fixing
531. By Rodrigo Moya

Added missing translatable file

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nautilus/Makefile.am'
--- nautilus/Makefile.am 2010-02-08 09:44:21 +0000
+++ nautilus/Makefile.am 2010-06-03 22:25:40 +0000
@@ -19,6 +19,8 @@
19ubuntuone-nautilus.c: ubuntuone-marshallers.h19ubuntuone-nautilus.c: ubuntuone-marshallers.h
2020
21libnautilus_ubuntuone_la_SOURCES = \21libnautilus_ubuntuone_la_SOURCES = \
22 add-contact-dialog.c \
23 add-contact-dialog.h \
22 contacts-view.c \24 contacts-view.c \
23 contacts-view.h \25 contacts-view.h \
24 u1-contacts-picker.c \26 u1-contacts-picker.c \
@@ -36,6 +38,8 @@
36 $(NAUTILUS_CFLAGS)38 $(NAUTILUS_CFLAGS)
37test_contacts_picker_SOURCES = \39test_contacts_picker_SOURCES = \
38 test-contacts-picker.c \40 test-contacts-picker.c \
41 add-contact-dialog.c \
42 add-contact-dialog.h \
39 contacts-view.c \43 contacts-view.c \
40 contacts-view.h \44 contacts-view.h \
41 u1-contacts-picker.c \45 u1-contacts-picker.c \
4246
=== added file 'nautilus/add-contact-dialog.c'
--- nautilus/add-contact-dialog.c 1970-01-01 00:00:00 +0000
+++ nautilus/add-contact-dialog.c 2010-06-03 22:25:40 +0000
@@ -0,0 +1,134 @@
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright (C) 2009 Canonical Services Ltd (www.canonical.com)
4 *
5 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of version 2 of the GNU Lesser General Public
9 * License as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22#include <string.h>
23#include <glib/gi18n.h>
24#include "add-contact-dialog.h"
25
26G_DEFINE_TYPE(AddContactDialog, add_contact_dialog, GTK_TYPE_DIALOG)
27
28static void
29add_contact_dialog_finalize (GObject *object)
30{
31 G_OBJECT_CLASS (add_contact_dialog_parent_class)->finalize (object);
32}
33
34static void
35add_contact_dialog_class_init (AddContactDialogClass *klass)
36{
37 GObjectClass *object_class = G_OBJECT_CLASS (klass);
38
39 object_class->finalize = add_contact_dialog_finalize;
40}
41
42static void
43entry_changed_cb (GtkEditable *entry, gpointer user_data)
44{
45 const gchar *text_name, *text_email;
46 AddContactDialog *dialog = (AddContactDialog *) user_data;
47
48 text_name = gtk_entry_get_text (GTK_ENTRY (dialog->name_entry));
49 text_email = gtk_entry_get_text (GTK_ENTRY (dialog->email_entry));
50 if (strlen (text_name) > 0 && strlen (text_email) > 0)
51 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE);
52 else
53 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
54}
55
56static void
57entry_activated_cb (GtkEntry *entry, gpointer user_data)
58{
59 const gchar *text_name, *text_email;
60 AddContactDialog *dialog = (AddContactDialog *) user_data;
61
62 text_name = gtk_entry_get_text (GTK_ENTRY (dialog->name_entry));
63 text_email = gtk_entry_get_text (GTK_ENTRY (dialog->email_entry));
64 if (strlen (text_name) > 0 && strlen (text_email) > 0)
65 gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
66}
67
68static void
69add_contact_dialog_init (AddContactDialog *dialog)
70{
71 GtkWidget *table, *label;
72
73 /* Build the dialog */
74 gtk_window_set_title (GTK_WINDOW (dialog), _("Add contact"));
75 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
76 gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
77 gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_ADD, GTK_RESPONSE_OK);
78
79 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
80 gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
81
82 table = gtk_table_new (2, 2, FALSE);
83 gtk_widget_show (table);
84 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
85 table, TRUE, TRUE, 3);
86
87 label = gtk_label_new (_("Contact name"));
88 gtk_widget_show (label);
89 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 3, 3);
90
91 dialog->name_entry = gtk_entry_new ();
92 g_signal_connect (G_OBJECT (dialog->name_entry), "changed", G_CALLBACK (entry_changed_cb), dialog);
93 g_signal_connect (G_OBJECT (dialog->name_entry), "activate", G_CALLBACK (entry_activated_cb), dialog);
94 gtk_widget_show (dialog->name_entry);
95 gtk_table_attach (GTK_TABLE (table), dialog->name_entry, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 3, 3);
96
97 label = gtk_label_new (_("Email address"));
98 gtk_widget_show (label);
99 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 3, 3);
100
101 dialog->email_entry = gtk_entry_new ();
102 g_signal_connect (G_OBJECT (dialog->email_entry), "changed", G_CALLBACK (entry_changed_cb), dialog);
103 g_signal_connect (G_OBJECT (dialog->email_entry), "activate", G_CALLBACK (entry_activated_cb), dialog);
104 gtk_widget_show (dialog->email_entry);
105 gtk_table_attach (GTK_TABLE (table), dialog->email_entry, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 3, 3);
106}
107
108GtkWidget *
109add_contact_dialog_new (GtkWindow *parent, const gchar *initial_text)
110{
111 AddContactDialog *dialog;
112
113 dialog = g_object_new (TYPE_ADD_CONTACT_DIALOG, NULL);
114 if (g_strrstr (initial_text, "@") != NULL)
115 gtk_entry_set_text (GTK_ENTRY (dialog->email_entry), initial_text);
116 else
117 gtk_entry_set_text (GTK_ENTRY (dialog->name_entry), initial_text);
118
119 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
120
121 return dialog;
122}
123
124const gchar *
125add_contact_dialog_get_name_text (AddContactDialog *dialog)
126{
127 return gtk_entry_get_text (GTK_ENTRY (dialog->name_entry));
128}
129
130const gchar *
131add_contact_dialog_get_email_text (AddContactDialog *dialog)
132{
133 return gtk_entry_get_text (GTK_ENTRY (dialog->email_entry));
134}
0135
=== added file 'nautilus/add-contact-dialog.h'
--- nautilus/add-contact-dialog.h 1970-01-01 00:00:00 +0000
+++ nautilus/add-contact-dialog.h 2010-06-03 22:25:40 +0000
@@ -0,0 +1,50 @@
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright (C) 2009 Canonical Services Ltd (www.canonical.com)
4 *
5 * Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of version 2 of the GNU Lesser General Public
9 * License as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22#ifndef __ADD_CONTACT_DIALOG_H__
23#define __ADD_CONTACT_DIALOG_H__
24
25#include <gtk/gtk.h>
26
27#define TYPE_ADD_CONTACT_DIALOG (add_contact_dialog_get_type ())
28#define ADD_CONTACT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ADD_CONTACT_DIALOG, AddContactDialog))
29#define IS_ADD_CONTACT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ADD_CONTACT_DIALOG))
30#define ADD_CONTACT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ADD_CONTACT_DIALOG, AddContactDialogClass))
31#define IS_ADD_CONTACT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ADD_CONTACT_DIALOG))
32#define ADD_CONTACT_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ADD_CONTACT_DIALOG, AddContactDialogClass))
33
34typedef struct {
35 GtkDialog parent;
36
37 GtkWidget *name_entry;
38 GtkWidget *email_entry;
39} AddContactDialog;
40
41typedef struct {
42 GtkDialogClass parent_class;
43} AddContactDialogClass;
44
45GType add_contact_dialog_get_type (void);
46GtkWidget *add_contact_dialog_new (GtkWindow *parent, const gchar *initial_text);
47const gchar *add_contact_dialog_get_name_text (AddContactDialog *dialog);
48const gchar *add_contact_dialog_get_email_text (AddContactDialog *dialog);
49
50#endif
051
=== modified file 'nautilus/u1-contacts-picker.c'
--- nautilus/u1-contacts-picker.c 2010-04-16 11:52:46 +0000
+++ nautilus/u1-contacts-picker.c 2010-06-03 22:25:40 +0000
@@ -21,6 +21,7 @@
2121
22#include <glib/gi18n.h>22#include <glib/gi18n.h>
23#include "u1-contacts-picker.h"23#include "u1-contacts-picker.h"
24#include "add-contact-dialog.h"
24#include "contacts-view.h"25#include "contacts-view.h"
2526
26struct _U1ContactsPickerPrivate {27struct _U1ContactsPickerPrivate {
@@ -83,8 +84,9 @@
83 text = gtk_entry_get_text (GTK_ENTRY (entry));84 text = gtk_entry_get_text (GTK_ENTRY (entry));
84 contacts_view_search (CONTACTS_VIEW (picker->priv->contacts_view), text);85 contacts_view_search (CONTACTS_VIEW (picker->priv->contacts_view), text);
8586
86 /* If no contacts offer the user to add it to the contacts database */87 /* If no contacts, offer the user to add it to the contacts database */
87 if (contacts_view_get_matched_contacts_count (CONTACTS_VIEW (picker->priv->contacts_view)) == 0)88 if (contacts_view_get_matched_contacts_count (CONTACTS_VIEW (picker->priv->contacts_view)) == 0 &&
89 g_strrstr (text, "@") != NULL)
88 gtk_widget_show (picker->priv->add_contact_button);90 gtk_widget_show (picker->priv->add_contact_button);
89 else91 else
90 gtk_widget_hide (picker->priv->add_contact_button);92 gtk_widget_hide (picker->priv->add_contact_button);
@@ -116,48 +118,19 @@
116static void118static void
117add_contact_cb (GtkButton *button, gpointer user_data)119add_contact_cb (GtkButton *button, gpointer user_data)
118{120{
119 GtkWidget *dialog, *table, *label, *name_entry, *email_entry;121 GtkWidget *dialog;
120 const gchar *search_text;122 const gchar *search_text;
121 U1ContactsPicker *picker = (U1ContactsPicker *) user_data;123 U1ContactsPicker *picker = (U1ContactsPicker *) user_data;
122124
123 /* Build the dialog */125 /* Create the dialog */
124 dialog = gtk_dialog_new_with_buttons (_("Add contact"),
125 GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (picker))),
126 GTK_DIALOG_NO_SEPARATOR,
127 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
128 GTK_STOCK_ADD, GTK_RESPONSE_OK,
129 NULL);
130 table = gtk_table_new (2, 2, FALSE);
131 gtk_widget_show (table);
132 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
133 table, TRUE, TRUE, 3);
134
135 label = gtk_label_new (_("Contact name"));
136 gtk_widget_show (label);
137 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 3, 3);
138 name_entry = gtk_entry_new ();
139 gtk_widget_show (name_entry);
140 gtk_table_attach (GTK_TABLE (table), name_entry, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 3, 3);
141
142 label = gtk_label_new (_("Email address"));
143 gtk_widget_show (label);
144 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 3, 3);
145 email_entry = gtk_entry_new ();
146 gtk_widget_show (email_entry);
147 gtk_table_attach (GTK_TABLE (table), email_entry, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 3, 3);
148
149 search_text = gtk_entry_get_text (GTK_ENTRY (picker->priv->search_entry));126 search_text = gtk_entry_get_text (GTK_ENTRY (picker->priv->search_entry));
150 if (g_strrstr (search_text, "@") != NULL)127 dialog = add_contact_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (picker))), search_text);
151 gtk_entry_set_text (GTK_ENTRY (email_entry), search_text);
152 else
153 gtk_entry_set_text (GTK_ENTRY (name_entry), search_text);
154128
155 /* Run the dialog */129 /* Run the dialog */
156 gtk_widget_grab_focus (name_entry);
157 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {130 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
158 contacts_view_add_contact (CONTACTS_VIEW (picker->priv->contacts_view),131 contacts_view_add_contact (CONTACTS_VIEW (picker->priv->contacts_view),
159 gtk_entry_get_text (GTK_ENTRY (name_entry)),132 add_contact_dialog_get_name_text (dialog),
160 gtk_entry_get_text (GTK_ENTRY (email_entry)));133 add_contact_dialog_get_email_text (dialog));
161 gtk_entry_set_text (GTK_ENTRY (picker->priv->search_entry), "");134 gtk_entry_set_text (GTK_ENTRY (picker->priv->search_entry), "");
162 }135 }
163136
164137
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2010-02-09 22:03:08 +0000
+++ po/POTFILES.in 2010-06-03 22:25:40 +0000
@@ -3,7 +3,7 @@
3data/emblem-ubuntuone-unsynchronized.icon.in3data/emblem-ubuntuone-unsynchronized.icon.in
4data/emblem-ubuntuone-uploading.icon.in4data/emblem-ubuntuone-uploading.icon.in
5data/ubuntuone-preferences.desktop.in5data/ubuntuone-preferences.desktop.in
6nautilus/add-contact-dialog.c
6nautilus/ubuntuone-nautilus.c7nautilus/ubuntuone-nautilus.c
7nautilus/contacts-view.c8nautilus/contacts-view.c
8nautilus/u1-contacts-picker.c9nautilus/u1-contacts-picker.c
9

Subscribers

People subscribed via source and target branches