aboutsummaryrefslogtreecommitdiffstats
path: root/composer/e-msg-composer.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2003-04-02 07:41:14 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2003-04-02 07:41:14 +0800
commitd95c0f5a3c25b3d72637a39f7e906a2781fecee6 (patch)
treefe46842264ab7a1008d6f6d0d9ff72682b4db6c7 /composer/e-msg-composer.c
parented7fed7a01595482f246c532b1daa0d6e8e73332 (diff)
downloadgsoc2013-evolution-d95c0f5a3c25b3d72637a39f7e906a2781fecee6.tar.gz
gsoc2013-evolution-d95c0f5a3c25b3d72637a39f7e906a2781fecee6.tar.zst
gsoc2013-evolution-d95c0f5a3c25b3d72637a39f7e906a2781fecee6.zip
Keep track of which entry widget has focus.
2003-04-01 Jeffrey Stedfast <fejj@ximian.com> * e-msg-composer.c (composer_entry_focus_in_event_cb): Keep track of which entry widget has focus. (composer_entry_focus_out_event_cb): Same. (control_entry_focus_in_event_cb): Same idea, but since this is in another component, tell that component that its widget has focus so it can merge bonoboui cut/copy/paste (and anything else) menus. (control_entry_focus_out_event_cb): Same. (setup_cut_copy_paste): Connect to the focus-in and focus-out events for all the entry widgets and the html editor. (menu_edit_cut_cb): New callback function since the composer will now own the Cut/Copy/Paste menu items sometimes (depending on which widget is in focus... confused yet? good). * e-msg-composer-hdrs.c (from_changed): Update the Reply-To entry to be a normal GtkEntry. (create_headers): Same. (e_msg_composer_hdrs_set_reply_to): Here too. (e_msg_composer_hdrs_get_reply_to): And finally here. svn path=/trunk/; revision=20623
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r--composer/e-msg-composer.c145
1 files changed, 138 insertions, 7 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 7da1a5d453..3c0a33cdda 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -1661,6 +1661,51 @@ menu_file_add_attachment_cb (BonoboUIComponent *uic,
}
static void
+menu_edit_cut_cb (BonoboUIComponent *uic, void *data, const char *path)
+{
+ EMsgComposer *composer = data;
+
+ g_return_if_fail (composer->focused_entry != NULL);
+
+ if (GTK_IS_ENTRY (composer->focused_entry)) {
+ gtk_editable_cut_clipboard (GTK_EDITABLE (composer->focused_entry));
+ } else {
+ /* happy happy joy joy, an EEntry. */
+ g_assert_not_reached ();
+ }
+}
+
+static void
+menu_edit_copy_cb (BonoboUIComponent *uic, void *data, const char *path)
+{
+ EMsgComposer *composer = data;
+
+ g_return_if_fail (composer->focused_entry != NULL);
+
+ if (GTK_IS_ENTRY (composer->focused_entry)) {
+ gtk_editable_copy_clipboard (GTK_EDITABLE (composer->focused_entry));
+ } else {
+ /* happy happy joy joy, an EEntry. */
+ g_assert_not_reached ();
+ }
+}
+
+static void
+menu_edit_paste_cb (BonoboUIComponent *uic, void *data, const char *path)
+{
+ EMsgComposer *composer = data;
+
+ g_return_if_fail (composer->focused_entry != NULL);
+
+ if (GTK_IS_ENTRY (composer->focused_entry)) {
+ gtk_editable_paste_clipboard (GTK_EDITABLE (composer->focused_entry));
+ } else {
+ /* happy happy joy joy, an EEntry. */
+ g_assert_not_reached ();
+ }
+}
+
+static void
menu_edit_delete_all_cb (BonoboUIComponent *uic, void *data, const char *path)
{
CORBA_Environment ev;
@@ -1851,17 +1896,21 @@ menu_changed_charset_cb (BonoboUIComponent *component,
static BonoboUIVerb verbs [] = {
- BONOBO_UI_VERB ("FileOpen", menu_file_open_cb),
- BONOBO_UI_VERB ("FileSave", menu_file_save_cb),
+ BONOBO_UI_VERB ("FileOpen", menu_file_open_cb),
+ BONOBO_UI_VERB ("FileSave", menu_file_save_cb),
BONOBO_UI_VERB ("FileSaveAs", menu_file_save_as_cb),
BONOBO_UI_VERB ("FileSaveDraft", menu_file_save_draft_cb),
- BONOBO_UI_VERB ("FileClose", menu_file_close_cb),
+ BONOBO_UI_VERB ("FileClose", menu_file_close_cb),
- BONOBO_UI_VERB ("FileAttach", menu_file_add_attachment_cb),
+ BONOBO_UI_VERB ("FileAttach", menu_file_add_attachment_cb),
- BONOBO_UI_VERB ("FileSend", menu_file_send_cb),
+ BONOBO_UI_VERB ("FileSend", menu_file_send_cb),
- BONOBO_UI_VERB ("DeleteAll", menu_edit_delete_all_cb),
+ BONOBO_UI_VERB ("EditCut", menu_edit_cut_cb),
+ BONOBO_UI_VERB ("EditCopy", menu_edit_copy_cb),
+ BONOBO_UI_VERB ("EditPaste", menu_edit_paste_cb),
+
+ BONOBO_UI_VERB ("DeleteAll", menu_edit_delete_all_cb),
BONOBO_UI_VERB_END
};
@@ -2579,6 +2628,8 @@ init (EMsgComposer *composer)
composer->extra_hdr_names = g_ptr_array_new ();
composer->extra_hdr_values = g_ptr_array_new ();
+ composer->focused_entry = NULL;
+
composer->editor = NULL;
composer->address_dialog = NULL;
@@ -2746,6 +2797,84 @@ composer_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
return FALSE; /* Not handled. */
}
+
+/* All this snot is so that Cut/Copy/Paste work. */
+static gboolean
+composer_entry_focus_in_event_cb (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+ EMsgComposer *composer = user_data;
+
+ composer->focused_entry = widget;
+
+ return FALSE;
+}
+
+static gboolean
+composer_entry_focus_out_event_cb (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+ EMsgComposer *composer = user_data;
+
+ g_assert (composer->focused_entry == widget);
+ composer->focused_entry = NULL;
+
+ return FALSE;
+}
+
+static gboolean
+control_entry_focus_in_event_cb (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+ EMsgComposer *composer = user_data;
+
+ g_assert (composer->focused_entry == NULL);
+
+ bonobo_control_frame_control_activate (bonobo_widget_get_control_frame (BONOBO_WIDGET (widget)));
+
+ return FALSE;
+}
+
+static gboolean
+control_entry_focus_out_event_cb (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+ EMsgComposer *composer = user_data;
+
+ g_assert (composer->focused_entry == NULL);
+
+ bonobo_control_frame_control_deactivate (bonobo_widget_get_control_frame (BONOBO_WIDGET (widget)));
+
+ return FALSE;
+}
+
+static void
+setup_cut_copy_paste (EMsgComposer *composer)
+{
+ EMsgComposerHdrs *hdrs;
+ GtkWidget *entry;
+
+ hdrs = (EMsgComposerHdrs *) composer->hdrs;
+
+ entry = e_msg_composer_hdrs_get_subject_entry (hdrs);
+ g_signal_connect (entry, "focus-in-event", G_CALLBACK (composer_entry_focus_in_event_cb), composer);
+ g_signal_connect (entry, "focus-out-event", G_CALLBACK (composer_entry_focus_out_event_cb), composer);
+
+ entry = e_msg_composer_hdrs_get_reply_to_entry (hdrs);
+ g_signal_connect (entry, "focus-in-event", G_CALLBACK (composer_entry_focus_in_event_cb), composer);
+ g_signal_connect (entry, "focus-out-event", G_CALLBACK (composer_entry_focus_out_event_cb), composer);
+
+ entry = e_msg_composer_hdrs_get_to_entry (hdrs);
+ g_signal_connect (entry, "focus-in-event", G_CALLBACK (control_entry_focus_in_event_cb), composer);
+ g_signal_connect (entry, "focus-out-event", G_CALLBACK (control_entry_focus_out_event_cb), composer);
+
+ entry = e_msg_composer_hdrs_get_cc_entry (hdrs);
+ g_signal_connect (entry, "focus-in-event", G_CALLBACK (control_entry_focus_in_event_cb), composer);
+ g_signal_connect (entry, "focus-out-event", G_CALLBACK (control_entry_focus_out_event_cb), composer);
+
+ entry = e_msg_composer_hdrs_get_bcc_entry (hdrs);
+ g_signal_connect (entry, "focus-in-event", G_CALLBACK (control_entry_focus_in_event_cb), composer);
+ g_signal_connect (entry, "focus-out-event", G_CALLBACK (control_entry_focus_out_event_cb), composer);
+
+ /* FIXME: do the same for the gtkhtml editor */
+}
+
static EMsgComposer *
create_composer (int visible_mask)
{
@@ -2880,7 +3009,9 @@ create_composer (int visible_mask)
gtk_object_destroy (GTK_OBJECT (composer));
return NULL;
}
-
+
+ setup_cut_copy_paste (composer);
+
g_signal_connect (composer, "map", (GCallback) map_default_cb, NULL);
if (am == NULL)