aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/component/e-address-popup.c119
-rw-r--r--addressbook/gui/component/e-address-popup.h1
2 files changed, 19 insertions, 101 deletions
diff --git a/addressbook/gui/component/e-address-popup.c b/addressbook/gui/component/e-address-popup.c
index 7aebeacf21..134ce1241b 100644
--- a/addressbook/gui/component/e-address-popup.c
+++ b/addressbook/gui/component/e-address-popup.c
@@ -31,6 +31,7 @@
#include <bonobo/bonobo-property-bag.h>
#include <bonobo/bonobo-generic-factory.h>
#include <gal/widgets/e-popup-menu.h>
+#include <gal/widgets/e-unicode.h>
#include <addressbook/backend/ebook/e-book.h>
#include <addressbook/backend/ebook/e-book-util.h>
#include <addressbook/contact-editor/e-contact-editor.h>
@@ -41,11 +42,6 @@ static GtkObjectClass *parent_class;
static EBook *common_book = NULL; /* still sort of lame */
static void e_address_popup_destroy (GtkObject *);
-static void e_address_popup_realize (GtkWidget *);
-static gint e_address_popup_button_press_event (GtkWidget *, GdkEventButton *ev);
-static gint e_address_popup_enter_notify_event (GtkWidget *, GdkEventCrossing *ev);
-static gint e_address_popup_leave_notify_event (GtkWidget *, GdkEventCrossing *ev);
-
static void e_address_popup_query (EAddressPopup *);
@@ -53,16 +49,10 @@ static void
e_address_popup_class_init (EAddressPopupClass *klass)
{
GtkObjectClass *object_class = (GtkObjectClass *) klass;
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = GTK_OBJECT_CLASS (gtk_type_class (gtk_event_box_get_type ()));
object_class->destroy = e_address_popup_destroy;
-
- widget_class->realize = e_address_popup_realize;
- widget_class->button_press_event = e_address_popup_button_press_event;
- widget_class->enter_notify_event = e_address_popup_enter_notify_event;
- widget_class->leave_notify_event = e_address_popup_leave_notify_event;
}
static void
@@ -89,57 +79,6 @@ e_address_popup_destroy (GtkObject *obj)
GTK_OBJECT_CLASS (parent_class)->destroy (obj);
}
-static void
-e_address_popup_realize (GtkWidget *w)
-{
- EAddressPopup *pop = E_ADDRESS_POPUP (w);
-
- if (GTK_WIDGET_CLASS (parent_class)->realize)
- GTK_WIDGET_CLASS (parent_class)->realize (w);
-
- /* Start the death count. */
- pop->leave_timeout_tag = gtk_timeout_add (10000, (GtkFunction) gtk_widget_destroy, pop);
-}
-
-static gint
-e_address_popup_button_press_event (GtkWidget *w, GdkEventButton *ev)
-{
- gtk_widget_destroy (w);
- return FALSE;
-}
-
-static gint
-e_address_popup_enter_notify_event (GtkWidget *w, GdkEventCrossing *ev)
-{
- EAddressPopup *pop = E_ADDRESS_POPUP (w);
-
- if (pop->leave_timeout_tag) {
- gtk_timeout_remove (pop->leave_timeout_tag);
- pop->leave_timeout_tag = 0;
- }
-
- return FALSE;
-}
-
-static gint
-e_address_popup_leave_notify_event (GtkWidget *w, GdkEventCrossing *ev)
-{
- EAddressPopup *pop = E_ADDRESS_POPUP (w);
- const gint slack=5;
- gint x, y;
-
- /* Manually check our "leave" events to avoid weird erroneous leaves
- that seem related to bonobo... */
- gdk_window_get_pointer (w->window, &x, &y, NULL);
- if (slack <= x && x < w->allocation.width-slack && slack <= y && y < w->allocation.height-slack)
- return FALSE;
-
- if (pop->leave_timeout_tag == 0)
- pop->leave_timeout_tag = gtk_timeout_add (1000, (GtkFunction) gtk_widget_destroy, pop);
-
- return FALSE;
-}
-
GtkType
e_address_popup_get_type (void)
{
@@ -199,9 +138,7 @@ e_address_popup_set_name (EAddressPopup *pop, const gchar *name)
pop->name = g_strdup (name);
g_strstrip (pop->name);
- ++pop->set_count;
-
- if (pop->set_count >= 2)
+ if (pop->name && pop->email)
e_address_popup_refresh_names (pop);
}
@@ -214,9 +151,7 @@ e_address_popup_set_email (EAddressPopup *pop, const gchar *email)
pop->email = g_strdup (email);
g_strstrip (pop->email);
- ++pop->set_count;
-
- if (pop->set_count >= 2)
+ if (pop->name && pop->email)
e_address_popup_refresh_names (pop);
}
@@ -278,36 +213,6 @@ e_address_popup_new (void)
return GTK_WIDGET (pop);
}
-static GtkWidget *
-e_address_popup_popup (EAddressPopup *pop)
-{
- GtkWidget *win, *fr;
- gint x, y;
-
- win = gtk_window_new (GTK_WINDOW_POPUP);
- fr = gtk_frame_new (NULL);
- gtk_container_add (GTK_CONTAINER (win), fr);
- gtk_container_add (GTK_CONTAINER (fr), GTK_WIDGET (pop));
-
- gtk_window_set_policy (GTK_WINDOW (win), FALSE, FALSE, FALSE);
-
- gdk_window_get_pointer (NULL, &x, &y, NULL);
- x = MAX (x-10, 0);
- y = MAX (y-10, 0);
- gtk_widget_set_uposition (win, x, y);
-
- gtk_signal_connect_object (GTK_OBJECT (pop),
- "destroy",
- GTK_SIGNAL_FUNC(gtk_widget_destroy),
- GTK_OBJECT (win));
-
- gtk_widget_show (GTK_WIDGET (pop));
- gtk_widget_show (fr);
- gtk_widget_show (win);
-
- return win;
-}
-
static void
found_fields_cb (EBook *book, EBookStatus status, EList *writable_fields, gpointer closure)
{
@@ -351,7 +256,15 @@ e_address_popup_cardify (EAddressPopup *pop, ECard *card)
static void
add_contacts_cb (EAddressPopup *pop)
{
- e_contact_quick_add (pop->name, pop->email, NULL, NULL);
+ if (pop->email && *pop->email) {
+
+ if (pop->name && *pop->name)
+ e_contact_quick_add (pop->name, pop->email, NULL, NULL);
+ else
+ e_contact_quick_add_free_form (pop->email, NULL, NULL);
+
+ }
+
gtk_widget_destroy (GTK_WIDGET (pop));
}
@@ -486,7 +399,13 @@ e_address_popup_factory_new_control (void)
GtkWidget *w;
w = e_address_popup_new ();
- control = bonobo_control_new (e_address_popup_popup (E_ADDRESS_POPUP (w)));
+ control = bonobo_control_new (w);
+ gtk_widget_show (w);
+
+ gtk_signal_connect_object (GTK_OBJECT (w),
+ "destroy",
+ GTK_SIGNAL_FUNC (bonobo_object_unref),
+ GTK_OBJECT (control));
bag = bonobo_property_bag_new (NULL, set_prop, w);
bonobo_property_bag_add (bag, "name", PROPERTY_NAME,
diff --git a/addressbook/gui/component/e-address-popup.h b/addressbook/gui/component/e-address-popup.h
index cac060fb4a..1ecfc773c7 100644
--- a/addressbook/gui/component/e-address-popup.h
+++ b/addressbook/gui/component/e-address-popup.h
@@ -49,7 +49,6 @@ struct _EAddressPopup {
guint leave_timeout_tag;
gboolean grabbed;
- gint set_count;
gchar *name;
gchar *email;