aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-07-01 08:41:13 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-07-01 08:41:13 +0800
commitfe0499e1d95e45291b655f1d068430014b5971db (patch)
tree7eb421b701f33b5a82bfd07a286240fa58789766 /mail
parent0d23a1ac2a2dfcc05e6540becf471c42aaa68313 (diff)
downloadgsoc2013-evolution-fe0499e1d95e45291b655f1d068430014b5971db.tar.gz
gsoc2013-evolution-fe0499e1d95e45291b655f1d068430014b5971db.tar.zst
gsoc2013-evolution-fe0499e1d95e45291b655f1d068430014b5971db.zip
Changed to return the created window. (find_socket): Added. Copied from
2001-06-30 Jon Trowbridge <trow@ximian.com> * mail-display.c (make_popup_window): Changed to return the created window. (find_socket): Added. Copied from e-shell-view.c. The fact that I'm copying this bit of code all over isn't cool. (html_button_press_event): Properly destroy the popup window when the widget inside the control is destroyed. * mail-callbacks.c (addrbook_sender): Added. Implements the "Add sender to addressbook" right-click. (Bug #3645) (find_socket): Added. Copied from e-shell-view.c. * folder-browser.c: Added "Add sender to addressbook" to context_menu[]. * mail-display.c: (handle_embedded_address_object): Removed. (on_object_requested): Removed handling for embedded address objects. (Which was obsolete crap.) svn path=/trunk/; revision=10643
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog20
-rw-r--r--mail/folder-browser.c4
-rw-r--r--mail/mail-callbacks.c66
-rw-r--r--mail/mail-callbacks.h1
-rw-r--r--mail/mail-display.c72
5 files changed, 128 insertions, 35 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 2192dd0563..bb2fff2ce7 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,23 @@
+2001-06-30 Jon Trowbridge <trow@ximian.com>
+
+ * mail-display.c (make_popup_window): Changed to return the
+ created window.
+ (find_socket): Added. Copied from e-shell-view.c. The fact
+ that I'm copying this bit of code all over isn't cool.
+ (html_button_press_event): Properly destroy the popup window when
+ the widget inside the control is destroyed.
+
+ * mail-callbacks.c (addrbook_sender): Added. Implements
+ the "Add sender to addressbook" right-click. (Bug #3645)
+ (find_socket): Added. Copied from e-shell-view.c.
+
+ * folder-browser.c: Added "Add sender to addressbook" to
+ context_menu[].
+
+ * mail-display.c: (handle_embedded_address_object): Removed.
+ (on_object_requested): Removed handling for embedded address
+ objects. (Which was obsolete crap.)
+
2001-06-29 Larry Ewing <lewing@ximian.com>
* mail-display.c (html_button_press_event): remove redundant
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index 1b3de3c3e3..3c5d44cc25 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -1219,10 +1219,10 @@ static EPopupMenu context_menu[] = {
SEPARATOR,
- /*{ _("Add Sender to Address Book"), NULL,
+ { N_("Add Sender to Address Book"), NULL,
GTK_SIGNAL_FUNC (addrbook_sender), NULL, 0 },
{ "", NULL,
- GTK_SIGNAL_FUNC (NULL), NULL, 0 },*/
+ GTK_SIGNAL_FUNC (NULL), NULL, 0 },
{ N_("Apply Filters"), NULL,
GTK_SIGNAL_FUNC (apply_filters), NULL, 0 },
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index 62103fb43d..a4d1647515 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -38,6 +38,8 @@
#include <libgnome/gnome-paper.h>
#include <libgnomeprint/gnome-print-master.h>
#include <libgnomeprint/gnome-print-master-preview.h>
+#include <bonobo/bonobo-widget.h>
+#include <bonobo/bonobo-socket.h>
#include <gal/e-table/e-table.h>
#include <gal/widgets/e-gui-utils.h>
#include <filter/filter-editor.h>
@@ -996,6 +998,70 @@ copy_msg (GtkWidget *widget, gpointer user_data)
transfer_msg (widget, user_data, FALSE);
}
+/* Copied from e-shell-view.c */
+static GtkWidget *
+find_socket (GtkContainer *container)
+{
+ GList *children, *tmp;
+
+ children = gtk_container_children (container);
+ while (children) {
+ if (BONOBO_IS_SOCKET (children->data))
+ return children->data;
+ else if (GTK_IS_CONTAINER (children->data)) {
+ GtkWidget *socket = find_socket (children->data);
+ if (socket)
+ return socket;
+ }
+ tmp = children->next;
+ g_list_free_1 (children);
+ children = tmp;
+ }
+ return NULL;
+}
+
+void
+addrbook_sender (GtkWidget *widget, gpointer user_data)
+{
+ FolderBrowser *fb = FOLDER_BROWSER (user_data);
+ CamelMimeMessage *msg = NULL;
+ const CamelInternetAddress *addr;
+ gchar *addr_str;
+ GtkWidget *win;
+ GtkWidget *control;
+ GtkWidget *socket;
+
+ if (fb && fb->mail_display)
+ msg = fb->mail_display->current_message;
+
+ if (msg == NULL)
+ return;
+
+ addr = camel_mime_message_get_from (msg);
+ if (addr == NULL)
+ return;
+
+ addr_str = camel_address_format (CAMEL_ADDRESS (addr));
+
+ win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title (GTK_WINDOW (win), _("Sender"));
+
+ control = bonobo_widget_new_control ("OAFIID:GNOME_Evolution_Addressbook_AddressPopup",
+ CORBA_OBJECT_NIL);
+ bonobo_widget_set_property (BONOBO_WIDGET (control),
+ "email", addr_str,
+ NULL);
+
+ socket = find_socket (GTK_CONTAINER (control));
+ gtk_signal_connect_object (GTK_OBJECT (socket),
+ "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy),
+ GTK_OBJECT (win));
+
+ gtk_container_add (GTK_CONTAINER (win), control);
+ gtk_widget_show_all (win);
+}
+
void
apply_filters (GtkWidget *widget, gpointer user_data)
{
diff --git a/mail/mail-callbacks.h b/mail/mail-callbacks.h
index e96b5d1ff9..6d37bb4819 100644
--- a/mail/mail-callbacks.h
+++ b/mail/mail-callbacks.h
@@ -62,6 +62,7 @@ void delete_msg (GtkWidget *widget, gpointer user_data);
void undelete_msg (GtkWidget *widget, gpointer user_data);
void move_msg (GtkWidget *widget, gpointer user_data);
void copy_msg (GtkWidget *widget, gpointer user_data);
+void addrbook_sender (GtkWidget *widget, gpointer user_data);
void apply_filters (GtkWidget *widget, gpointer user_data);
void print_msg (GtkWidget *widget, gpointer user_data);
void print_preview_msg (GtkWidget *widget, gpointer user_data);
diff --git a/mail/mail-display.c b/mail/mail-display.c
index 816e5b49e8..78fe4f2022 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -25,6 +25,7 @@
#include <bonobo/bonobo-stream-memory.h>
#include <bonobo/bonobo-ui-toolbar-icon.h>
#include <bonobo/bonobo-widget.h>
+#include <bonobo/bonobo-socket.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf/gdk-pixbuf-loader.h>
#include <gal/util/e-util.h>
@@ -640,32 +641,6 @@ get_embedded_for_component (const char *iid, MailDisplay *md)
return embedded;
}
-static void
-handle_embedded_address_object (GtkHTMLEmbedded *eb)
-{
- const gchar *name, *email;
- GtkWidget *w;
-
- w = bonobo_widget_new_control ("OAFIID:GNOME_Evolution_Addressbook_AddressWidget",
- CORBA_OBJECT_NIL);
-
- name = gtk_html_embedded_get_parameter (eb, "name");
- email = gtk_html_embedded_get_parameter (eb, "email");
-
- bonobo_widget_set_property (BONOBO_WIDGET (w),
- "name", name,
- "email", email,
- /* Hackish: this is the bg color defined for the HTML table
- in mail-format.c. If you change it there, you'd better
- change it here as well. */
- "background_rgb", 0xeeeeee,
- NULL);
-
- gtk_widget_show (w);
- gtk_container_add (GTK_CONTAINER (eb), w);
-
- gtk_html_embedded_set_descent (eb, 0);
-}
static gboolean
on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
@@ -686,11 +661,6 @@ on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
cid = eb->classid;
- if (!strcmp (cid, "address")) {
- handle_embedded_address_object (eb);
- return TRUE;
- }
-
if (!strncmp (cid, "popup:", 6))
cid += 6;
if (strncmp (cid, "cid:", 4) != 0)
@@ -1431,7 +1401,7 @@ popup_size_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer user_d
}
-static void
+static GtkWidget *
make_popup_window (GtkWidget *w)
{
PopupInfo *pop = g_new0 (PopupInfo, 1);
@@ -1479,6 +1449,30 @@ make_popup_window (GtkWidget *w)
gtk_widget_show (w);
gtk_widget_show (fr);
gtk_widget_show (pop->win);
+
+ return pop->win;
+}
+
+/* Copied from e-shell-view.c */
+static GtkWidget *
+find_socket (GtkContainer *container)
+{
+ GList *children, *tmp;
+
+ children = gtk_container_children (container);
+ while (children) {
+ if (BONOBO_IS_SOCKET (children->data))
+ return children->data;
+ else if (GTK_IS_CONTAINER (children->data)) {
+ GtkWidget *socket = find_socket (children->data);
+ if (socket)
+ return socket;
+ }
+ tmp = children->next;
+ g_list_free_1 (children);
+ children = tmp;
+ }
+ return NULL;
}
static int
@@ -1491,7 +1485,9 @@ html_button_press_event (GtkWidget *widget, GdkEventButton *event, MailDisplay *
if (event->button == 3) {
HTMLEngine *e;
HTMLPoint *point;
+ GtkWidget *socket;
GtkWidget *popup_thing;
+ GtkWidget *win;
e = GTK_HTML (widget)->engine;
point = html_engine_get_point_at (e, event->x + e->x_offset, event->y + e->y_offset, FALSE);
@@ -1506,10 +1502,20 @@ html_button_press_event (GtkWidget *widget, GdkEventButton *event, MailDisplay *
popup_thing = bonobo_widget_new_control ("OAFIID:GNOME_Evolution_Addressbook_AddressPopup",
CORBA_OBJECT_NIL);
+ socket = find_socket (GTK_CONTAINER (popup_thing));
+
bonobo_widget_set_property (BONOBO_WIDGET (popup_thing),
"email", url+7,
NULL);
- make_popup_window (popup_thing);
+
+ win = make_popup_window (popup_thing);
+ gtk_signal_connect_object (GTK_OBJECT (socket),
+ "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroy),
+ GTK_OBJECT (win));
+
+
+
} else if (url) {