diff options
author | Peter Williams <peterw@ximian.com> | 2001-08-15 06:27:42 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2001-08-15 06:27:42 +0800 |
commit | 827e944ea016a75c1d0d94965992b0523903cf9f (patch) | |
tree | 94d3c8b6b4da70acb2eaea42fda32961918118fb /composer/e-msg-composer.c | |
parent | d4a1de64f1d3e2b0b9422aea110de62ffc9860c4 (diff) | |
download | gsoc2013-evolution-827e944ea016a75c1d0d94965992b0523903cf9f.tar gsoc2013-evolution-827e944ea016a75c1d0d94965992b0523903cf9f.tar.gz gsoc2013-evolution-827e944ea016a75c1d0d94965992b0523903cf9f.tar.bz2 gsoc2013-evolution-827e944ea016a75c1d0d94965992b0523903cf9f.tar.lz gsoc2013-evolution-827e944ea016a75c1d0d94965992b0523903cf9f.tar.xz gsoc2013-evolution-827e944ea016a75c1d0d94965992b0523903cf9f.tar.zst gsoc2013-evolution-827e944ea016a75c1d0d94965992b0523903cf9f.zip |
YESS!
2001-07-12 Peter Williams <peterw@ximian.com>
* e-msg-composer.c (map_default_cb): New function. Figure out
which widget gets the default and assign it. Harder to do than
it sounds.
(e_msg_composer_construct): Hook map_default_cb up to the "map"
signal.
(set_focus_to_editor): Removed.
(set_focus_to_editor_idle): Removed.
svn path=/trunk/; revision=12037
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r-- | composer/e-msg-composer.c | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 622c18ecb4..9bc2390fd4 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -62,6 +62,7 @@ #include <glade/glade.h> #include <gal/widgets/e-gui-utils.h> #include <gal/widgets/e-scroll-frame.h> +#include <gal/e-text/e-entry.h> #include <gtkhtml/gtkhtml.h> #include "widgets/misc/e-charset-picker.h" @@ -239,24 +240,6 @@ e_msg_composer_clear_inlined_table (EMsgComposer *composer) g_hash_table_foreach_remove (composer->inline_images, clear_inline_images, NULL); } -static guint -set_focus_to_editor_idle (EMsgComposer *composer) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "grab-focus", &ev); - CORBA_exception_free (&ev); - - return FALSE; -} - -static inline void -set_focus_to_editor (EMsgComposer *composer) -{ - gtk_idle_add (set_focus_to_editor_idle, composer); -} - static void add_inlined_image (gpointer key, gpointer value, gpointer data) { @@ -2271,6 +2254,47 @@ e_msg_composer_get_visible_flags (EMsgComposer *composer) return flags; } + +static void +map_default_cb (EMsgComposer *composer, gpointer user_data) +{ + GtkWidget *to; + BonoboControlFrame *cf; + Bonobo_PropertyBag pb = CORBA_OBJECT_NIL; + char *text; + CORBA_Environment ev; + + /* If the 'To:' field is empty, focus it (This is ridiculously complicated) */ + + to = e_msg_composer_hdrs_get_to_entry (E_MSG_COMPOSER_HDRS (composer->hdrs)); + cf = bonobo_widget_get_control_frame (BONOBO_WIDGET (to)); + pb = bonobo_control_frame_get_control_property_bag (cf, NULL); + text = bonobo_property_bag_client_get_value_string (pb, "text", NULL); + + if (!text || text[0] == '\0') { + bonobo_control_frame_focus_child (cf, GTK_DIR_TAB_FORWARD); + return; + } + + /* If not, check the subject field */ + + text = e_msg_composer_hdrs_get_subject (E_MSG_COMPOSER_HDRS (composer->hdrs)); + + if (!text || text[0] == '\0') { + GtkWidget *widget; + + widget = e_msg_composer_hdrs_get_subject_entry (E_MSG_COMPOSER_HDRS (composer->hdrs)); + gtk_widget_grab_focus (GTK_WIDGET (E_ENTRY (widget)->canvas)); + return; + } + + /* Jump to the editor as a last resort. */ + + CORBA_exception_init (&ev); + GNOME_GtkHTML_Editor_Engine_runCommand (composer->editor_engine, "grab-focus", &ev); + CORBA_exception_free (&ev); +} + /** * e_msg_composer_construct: * @composer: A message composer widget @@ -2369,7 +2393,7 @@ e_msg_composer_construct (EMsgComposer *composer) e_msg_composer_show_attachments (composer, FALSE); prepare_engine (composer); - set_focus_to_editor (composer); + gtk_signal_connect (GTK_OBJECT (composer), "map", map_default_cb, NULL); } static EMsgComposer * |