aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-03-02 19:19:39 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-03-02 19:19:39 +0800
commitd932fda48b3724f516fa5012b80c329644d72bdf (patch)
treea9b50d4dd3902ad79230b9b14e70b4034d590344
parentda08b761fb9afadf60b4705ec8a310f83f031188 (diff)
downloadgsoc2013-evolution-d932fda48b3724f516fa5012b80c329644d72bdf.tar
gsoc2013-evolution-d932fda48b3724f516fa5012b80c329644d72bdf.tar.gz
gsoc2013-evolution-d932fda48b3724f516fa5012b80c329644d72bdf.tar.bz2
gsoc2013-evolution-d932fda48b3724f516fa5012b80c329644d72bdf.tar.lz
gsoc2013-evolution-d932fda48b3724f516fa5012b80c329644d72bdf.tar.xz
gsoc2013-evolution-d932fda48b3724f516fa5012b80c329644d72bdf.tar.zst
gsoc2013-evolution-d932fda48b3724f516fa5012b80c329644d72bdf.zip
Bonobization of the message composer, part 1.
svn path=/trunk/; revision=2012
-rw-r--r--composer/ChangeLog23
-rw-r--r--composer/Makefile.am4
-rw-r--r--composer/e-msg-composer.c139
-rw-r--r--composer/e-msg-composer.h18
-rw-r--r--composer/main.c38
5 files changed, 187 insertions, 35 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 19fefb02fa..2da82bcf3d 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,5 +1,28 @@
2000-03-02 Ettore Perazzoli <ettore@helixcode.com>
+ * e-msg-composer.c (e_msg_composer_new): Precondition:
+ gtk_main_level() greater than zero.
+ (e_msg_composer_construct): Likewise.
+ (create_menus): New function. Set up menus through
+ BonoboUIHandler.
+ (e_msg_composer_construct): Use it.
+
+ * main.c (main): Initialize Bonobo.
+
+ * e-msg-composer.c (init): Initialize `uih' and `editor' to NULL.
+ Do not init `text' and `text_scrolled_window' anymore.
+ (destroy): Unref `uih'.
+ (e_msg_composer_construct): Create a new BonoboUIHandler and put
+ it into `uih'.
+ (create_editor): New helper function.
+ (e_msg_composer_construct): Use it to set up the editor.
+
+ * e-msg-composer.h: New member `uih' in `EMsgComposer'. Removed
+ members `text', `text_scrolled_window'. New member `editor'.
+
+ * Makefile.am (INCLUDES): Add `$(BONOBO_GNOME_CFLAGS)'.
+ (evolution_msg_composer_LDADD): Add `$(BONOBO_GNOME_LIBS)'.
+
* e-msg-composer.c (glade_connect): Removed.
(setup_signals): Removed.
(e_msg_composer_construct): Do not use libglade to set the toolbar
diff --git a/composer/Makefile.am b/composer/Makefile.am
index 052c530789..f0499650c4 100644
--- a/composer/Makefile.am
+++ b/composer/Makefile.am
@@ -9,7 +9,8 @@ INCLUDES = \
-I$(top_builddir) \
-I$(top_srcdir)/camel \
-I$(top_builddir)/camel \
- $(GNOME_INCLUDEDIR)
+ $(GNOME_INCLUDEDIR) \
+ $(BONOBO_GNOME_CFLAGS)
CPPFLAGS = \
-DE_GLADEDIR=\"$(gladedir)\"
@@ -34,6 +35,7 @@ evolution_msg_composer_SOURCES = \
evolution_msg_composer_LDADD = \
$(top_builddir)/camel/libcamel.la \
+ $(BONOBO_GNOME_LIBS) \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
$(INTLLIBS) \
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index f9a6471686..91383783f8 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -35,7 +35,11 @@
#endif
#include <gnome.h>
+#include <libgnorba/gnorba.h>
+#include <bonobo.h>
+
#include <glade/glade.h>
+
#include <camel/camel.h>
#include "e-msg-composer.h"
@@ -59,6 +63,25 @@ static guint signals[LAST_SIGNAL] = { 0 };
static GnomeAppClass *parent_class = NULL;
+static GtkWidget *
+create_editor (EMsgComposer *composer)
+{
+ GtkWidget *control;
+ Bonobo_UIHandler corba_uih;
+
+ corba_uih = bonobo_object_corba_objref (BONOBO_OBJECT (composer->uih));
+
+ /* FIXME: Hardcoded value sucks! */
+ control = bonobo_widget_new_control ("control:html-editor", corba_uih);
+ if (control == NULL) {
+ g_warning ("Cannot get the `control:html-editor' component.");
+ return NULL;
+ }
+
+ return control;
+}
+
+
static void
free_string_list (GList *list)
{
@@ -81,7 +104,6 @@ build_message (EMsgComposer *composer)
CamelMimeMessage *new;
CamelMimeBodyPart *body_part;
CamelMultipart *multipart;
- gchar *text;
new = camel_mime_message_new_with_session (NULL);
@@ -91,9 +113,11 @@ build_message (EMsgComposer *composer)
multipart = camel_multipart_new ();
body_part = camel_mime_body_part_new ();
+#if 0
text = gtk_editable_get_chars (GTK_EDITABLE (composer->text), 0, -1);
camel_mime_part_set_text (CAMEL_MIME_PART (body_part), text);
camel_multipart_add_part (multipart, body_part);
+#endif
e_msg_composer_attachment_bar_to_multipart
(E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar),
@@ -274,6 +298,75 @@ attachment_bar_changed (EMsgComposerAttachmentBar *bar,
}
+/* Menu bar implementation. */
+
+static GnomeUIInfo file_tree[] = {
+ GNOMEUIINFO_MENU_OPEN_ITEM (NULL, NULL),
+ GNOMEUIINFO_MENU_SAVE_ITEM (NULL, NULL),
+ GNOMEUIINFO_MENU_SAVE_AS_ITEM (NULL, NULL),
+ GNOMEUIINFO_ITEM_NONE (N_("Save in _folder..."), N_("Save the message in a specified folder"), NULL),
+ GNOMEUIINFO_SEPARATOR,
+ GNOMEUIINFO_ITEM_STOCK (N_("Send"), N_("Send the message"), NULL, GNOME_STOCK_MENU_MAIL_SND),
+ GNOMEUIINFO_SEPARATOR,
+ GNOMEUIINFO_MENU_EXIT_ITEM (NULL, NULL),
+ GNOMEUIINFO_END
+};
+
+static GnomeUIInfo view_tree[] = {
+ GNOMEUIINFO_ITEM_STOCK (N_("View _attachments"), N_("View/hide attachments"), NULL, GNOME_STOCK_MENU_ATTACH),
+ GNOMEUIINFO_END
+};
+
+static GnomeUIInfo menubar_info[] = {
+ GNOMEUIINFO_MENU_FILE_TREE (file_tree),
+ GNOMEUIINFO_MENU_VIEW_TREE (view_tree),
+ GNOMEUIINFO_END
+};
+
+static void
+create_menubar (EMsgComposer *composer)
+{
+ BonoboUIHandler *uih;
+ BonoboUIHandlerMenuItem *list;
+
+ uih = composer->uih;
+
+ bonobo_ui_handler_create_menubar (uih);
+
+ list = bonobo_ui_handler_menu_parse_uiinfo_list (menubar_info);
+ bonobo_ui_handler_menu_add_list (uih, "/", list);
+}
+
+
+/* Toolbar implementation. */
+
+static GnomeUIInfo toolbar_info[] = {
+ GNOMEUIINFO_ITEM_STOCK (N_("Send"), N_("Send this message"), NULL, GNOME_STOCK_PIXMAP_MAIL_SND),
+ GNOMEUIINFO_SEPARATOR,
+ GNOMEUIINFO_ITEM_STOCK (N_("Cut"), N_("Cut selected region into the clipboard"), NULL, GNOME_STOCK_PIXMAP_CUT),
+ GNOMEUIINFO_ITEM_STOCK (N_("Copy"), N_("Copy selected region into the clipboard"), NULL, GNOME_STOCK_PIXMAP_COPY),
+ GNOMEUIINFO_ITEM_STOCK (N_("Paste"), N_("Paste selected region into the clipboard"), NULL, GNOME_STOCK_PIXMAP_PASTE),
+ GNOMEUIINFO_ITEM_STOCK (N_("Undo"), N_("Undo last operation"), NULL, GNOME_STOCK_PIXMAP_UNDO),
+ GNOMEUIINFO_SEPARATOR,
+ GNOMEUIINFO_ITEM_STOCK (N_("Attach"), N_("Attach a file"), NULL, GNOME_STOCK_PIXMAP_ATTACH),
+ GNOMEUIINFO_END
+};
+
+static void
+create_toolbar (EMsgComposer *composer)
+{
+ BonoboUIHandler *uih;
+ BonoboUIHandlerToolbarItem *list;
+
+ uih = composer->uih;
+
+ bonobo_ui_handler_create_toolbar (uih, "Toolbar");
+
+ list = bonobo_ui_handler_toolbar_parse_uiinfo_list (toolbar_info);
+ bonobo_ui_handler_toolbar_add_list (uih, "/Toolbar", list);
+}
+
+
/* GtkObject methods. */
static void
@@ -283,6 +376,11 @@ destroy (GtkObject *object)
composer = E_MSG_COMPOSER (object);
+ bonobo_object_unref (BONOBO_OBJECT (composer->uih));
+
+ /* FIXME? I assume the Bonobo widget will get destroyed
+ normally? */
+
if (composer->address_dialog != NULL)
gtk_widget_destroy (composer->address_dialog);
@@ -324,10 +422,11 @@ class_init (EMsgComposerClass *klass)
static void
init (EMsgComposer *composer)
{
+ composer->uih = NULL;
+
composer->hdrs = NULL;
- composer->text = NULL;
- composer->text_scrolled_window = NULL;
+ composer->editor = NULL;
composer->address_dialog = NULL;
@@ -371,34 +470,30 @@ e_msg_composer_construct (EMsgComposer *composer)
{
GtkWidget *vbox;
+ g_return_if_fail (gtk_main_level () > 0);
+
gtk_window_set_default_size (GTK_WINDOW (composer),
DEFAULT_WIDTH, DEFAULT_HEIGHT);
gnome_app_construct (GNOME_APP (composer), "e-msg-composer",
"Compose a message");
+ composer->uih = bonobo_ui_handler_new ();
+ bonobo_ui_handler_set_app (composer->uih, GNOME_APP (composer));
+
vbox = gtk_vbox_new (FALSE, 0);
composer->hdrs = e_msg_composer_hdrs_new ();
gtk_box_pack_start (GTK_BOX (vbox), composer->hdrs, FALSE, TRUE, 0);
gtk_widget_show (composer->hdrs);
- /* GtkText for message body editing, wrapped into a
- GtkScrolledWindow. */
+ /* Editor component. */
- composer->text_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy
- (GTK_SCROLLED_WINDOW (composer->text_scrolled_window),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- composer->text = gtk_text_new (NULL, NULL);
- gtk_text_set_word_wrap (GTK_TEXT (composer->text), FALSE);
- gtk_text_set_editable (GTK_TEXT (composer->text), TRUE);
- gtk_container_add (GTK_CONTAINER (composer->text_scrolled_window),
- composer->text);
- gtk_widget_show (composer->text);
- gtk_box_pack_start (GTK_BOX (vbox), composer->text_scrolled_window,
- TRUE, TRUE, 0);
- gtk_widget_show (composer->text_scrolled_window);
+ composer->editor = create_editor (composer);
+
+ gtk_widget_show (composer->editor);
+ gtk_box_pack_start (GTK_BOX (vbox), composer->editor, TRUE, TRUE, 0);
+ gtk_widget_show (composer->editor);
/* Attachment editor, wrapped into a GtkScrolledWindow. We don't
show it for now. */
@@ -420,12 +515,16 @@ e_msg_composer_construct (EMsgComposer *composer)
gtk_widget_show (vbox);
e_msg_composer_show_attachments (composer, FALSE);
+
+ create_menubar (composer);
+ create_toolbar (composer);
}
/**
* e_msg_composer_new:
*
- * Create a new message composer widget.
+ * Create a new message composer widget. This function must be called
+ * within the GTK+ main loop, or it will fail.
*
* Return value: A pointer to the newly created widget
**/
@@ -433,6 +532,8 @@ GtkWidget *
e_msg_composer_new (void)
{
GtkWidget *new;
+
+ g_return_val_if_fail (gtk_main_level () > 0, NULL);
new = gtk_type_new (e_msg_composer_get_type ());
e_msg_composer_construct (E_MSG_COMPOSER (new));
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 14b820d079..5109918dc8 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -25,7 +25,7 @@
#define ___E_MSG_COMPOSER_H__
#include <gnome.h>
-#include <glade/glade.h>
+#include <bonobo.h>
#include "e-msg-composer-attachment-bar.h"
#include "e-msg-composer-hdrs.h"
@@ -49,10 +49,11 @@ typedef struct _EMsgComposerClass EMsgComposerClass;
struct _EMsgComposer {
GnomeApp parent;
+ BonoboUIHandler *uih;
+
GtkWidget *hdrs;
- GtkWidget *text;
- GtkWidget *text_scrolled_window;
+ GtkWidget *editor;
GtkWidget *attachment_bar;
GtkWidget *attachment_scrolled_window;
@@ -70,11 +71,12 @@ struct _EMsgComposerClass {
};
-GtkType e_msg_composer_get_type (void);
-void e_msg_composer_construct (EMsgComposer *composer);
-GtkWidget *e_msg_composer_new (void);
-void e_msg_composer_show_attachments (EMsgComposer *composer, gboolean show);
-CamelMimeMessage *e_msg_composer_get_message (EMsgComposer *composer);
+GtkType e_msg_composer_get_type (void);
+void e_msg_composer_construct (EMsgComposer *composer);
+GtkWidget *e_msg_composer_new (void);
+void e_msg_composer_show_attachments (EMsgComposer *composer,
+ gboolean show);
+CamelMimeMessage *e_msg_composer_get_message (EMsgComposer *composer);
#ifdef __cplusplus
}
diff --git a/composer/main.c b/composer/main.c
index 8fbf01b5e8..9a29e95666 100644
--- a/composer/main.c
+++ b/composer/main.c
@@ -1,6 +1,10 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
#include <gnome.h>
+#include <libgnorba/gnorba.h>
+#include <bonobo.h>
+
+#include <glade/glade.h>
#include <camel/camel-data-wrapper.h>
#include <camel/camel-stream-fs.h>
@@ -32,21 +36,41 @@ send_cb (EMsgComposer *composer,
#endif
}
+static guint
+create_composer (void)
+{
+ GtkWidget *composer;
+
+ composer = e_msg_composer_new ();
+ gtk_widget_show (composer);
+
+ gtk_signal_connect (GTK_OBJECT (composer), "send", GTK_SIGNAL_FUNC (send_cb), NULL);
+
+ return FALSE;
+}
+
int
main (int argc, char **argv)
{
- GtkWidget *composer;
+ CORBA_Environment ev;
+ CORBA_ORB orb;
+
+ CORBA_exception_init (&ev);
+ gnome_CORBA_init ("evolution-test-msg-composer", "0.0", &argc, argv, 0, &ev);
+ CORBA_exception_free (&ev);
+
+ orb = gnome_CORBA_ORB ();
- gnome_init ("test", "0.0", argc, argv);
glade_gnome_init ();
- composer = e_msg_composer_new ();
- gtk_widget_show (composer);
+ if (bonobo_init (orb, NULL, NULL) == FALSE)
+ g_error ("Could not initialize Bonobo\n");
- gtk_signal_connect (GTK_OBJECT (composer), "send",
- GTK_SIGNAL_FUNC (send_cb), NULL);
+ /* We can't make any CORBA calls unless we're in the main loop. So we
+ delay creating the container here. */
+ gtk_idle_add ((GtkFunction) create_composer, NULL);
- gtk_main ();
+ bonobo_main ();
return 0;
}