[evolution-patches] Patch for GtkHTML and Composer, take two
- From: Federico Mena Quintero <federico ximian com>
- To: evolution-patches ximian com
- Subject: [evolution-patches] Patch for GtkHTML and Composer, take two
- Date: Tue, 02 Sep 2003 11:34:29 -0500
Hi,
[Dang, I sent this to evolution-hackers, not -patches...]
I'm re-sending these patches so they won't be forgotten. Libbonoboui is
fixed and released now, so we can do in-process menu merging reliably.
GtkHTML's editor control and the Evolution composer do not merge/unmerge
their menu items appropriately, and this patch fixes it.
The most visible bug that gets fixed with this is when you hit
Edit/Paste while on the subject line, and the clipboard contents get
pasted in the message body.
OK to commit?
Federico
Index: composer/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.557
diff -u -r1.557 ChangeLog
--- composer/ChangeLog 23 Jul 2003 18:13:57 -0000 1.557
+++ composer/ChangeLog 24 Jul 2003 03:01:00 -0000
@@ -1,3 +1,20 @@
+2003-07-23 Federico Mena Quintero <federico ximian com>
+
+ * e-msg-composer.h (EMsgComposer): Added an entry_uic field for a
+ BonoboUIComponent for the non-control entries (e.g. the Subject
+ line).
+
+ * e-msg-composer.c (create_composer): Set autoactivate to true on
+ the HTML control's BonoboControlFrame.
+ (setup_ui): Create the composer->entry_uic.
+ (destroy): Free the composer->entry_uic.
+ (entry_verbs): New array of verbs for the non-control entries.
+ Moved the Edit* verbs to here, as they should not be part of the
+ main set.
+ (composer_entry_focus_in_event_cb): Load
+ evolution-composer-entries.xml here for the non-control entries' UI.
+ (composer_entry_focus_out_event_cb): Remove the menu items.
+
2003-07-17 Michel Dänzer <michel daenzer net>
* e-msg-composer.c (autosave_manager_query_load_orphans): Set
Index: composer/e-msg-composer.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
retrieving revision 1.404
diff -u -r1.404 e-msg-composer.c
--- composer/e-msg-composer.c 23 Jul 2003 18:13:57 -0000 1.404
+++ composer/e-msg-composer.c 24 Jul 2003 03:01:01 -0000
@@ -1943,11 +1943,6 @@
BONOBO_UI_VERB ("FileSend", menu_file_send_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 ("SelectAll", menu_edit_select_all_cb),
-
BONOBO_UI_VERB ("DeleteAll", menu_edit_delete_all_cb),
BONOBO_UI_VERB_END
@@ -2210,6 +2205,10 @@
mail_config_signature_register_client ((MailConfigSignatureClient) sig_event_client, composer);
bonobo_ui_component_thaw (composer->uic, NULL);
+
+ /* Create the UIComponent for the non-control entries */
+
+ composer->entry_uic = bonobo_ui_component_new_default ();
}
@@ -2451,6 +2450,11 @@
bonobo_object_unref (BONOBO_OBJECT (composer->uic));
composer->uic = NULL;
}
+
+ if (composer->entry_uic) {
+ bonobo_object_unref (BONOBO_OBJECT (composer->entry_uic));
+ composer->entry_uic = NULL;
+ }
/* FIXME? I assume the Bonobo widget will get destroyed
normally? */
@@ -2839,15 +2843,36 @@
return FALSE; /* Not handled. */
}
+/* Verbs for non-control entries */
+static BonoboUIVerb entry_verbs [] = {
+ 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 ("EditSelectAll", menu_edit_select_all_cb),
+ BONOBO_UI_VERB_END
+};
/* 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;
-
+ BonoboUIContainer *container;
+
composer->focused_entry = widget;
- bonobo_ui_component_add_verb_list_with_data (composer->uic, verbs, composer);
+
+ container = bonobo_window_get_ui_container (BONOBO_WINDOW (composer));
+ bonobo_ui_component_set_container (composer->entry_uic, bonobo_object_corba_objref (BONOBO_OBJECT (container)), NULL);
+
+ bonobo_ui_component_add_verb_list_with_data (composer->entry_uic, entry_verbs, composer);
+
+ bonobo_ui_component_freeze (composer->entry_uic, NULL);
+
+ bonobo_ui_util_set_ui (composer->entry_uic, PREFIX,
+ EVOLUTION_UIDIR "/evolution-composer-entries.xml",
+ "evolution-composer-entries", NULL);
+
+ bonobo_ui_component_thaw (composer->entry_uic, NULL);
return FALSE;
}
@@ -2859,6 +2884,9 @@
g_assert (composer->focused_entry == widget);
composer->focused_entry = NULL;
+
+ bonobo_ui_component_rm (composer->entry_uic, "/", NULL);
+ bonobo_ui_component_unset_container (composer->entry_uic, NULL);
return FALSE;
}
@@ -2872,12 +2900,12 @@
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);
+ 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);
+ 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);
}
static void
@@ -2911,6 +2939,7 @@
CORBA_Environment ev;
GConfClient *gconf;
int vis;
+ BonoboControlFrame *control_frame;
composer = g_object_new (E_TYPE_MSG_COMPOSER, "win_name", _("Compose a message"), NULL);
gtk_window_set_title ((GtkWindow *) composer, _("Compose a message"));
@@ -2981,6 +3010,9 @@
gtk_object_destroy (GTK_OBJECT (composer));
return NULL;
}
+
+ control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (composer->editor));
+ bonobo_control_frame_set_autoactivate (control_frame, TRUE);
/* let the editor know which mode we are in */
bonobo_widget_set_property (BONOBO_WIDGET (composer->editor),
Index: composer/e-msg-composer.h
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer.h,v
retrieving revision 1.83
diff -u -r1.83 e-msg-composer.h
--- composer/e-msg-composer.h 20 May 2003 18:26:09 -0000 1.83
+++ composer/e-msg-composer.h 24 Jul 2003 03:01:01 -0000
@@ -54,7 +54,11 @@
struct _EMsgComposer {
BonoboWindow parent;
+ /* Main UIComponent */
BonoboUIComponent *uic;
+
+ /* UIComponent for the non-control GtkEntries */
+ BonoboUIComponent *entry_uic;
GtkWidget *hdrs;
GPtrArray *extra_hdr_names, *extra_hdr_values;
Index: components/html-editor/ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/ChangeLog,v
retrieving revision 1.413
diff -u -r1.413 ChangeLog
--- components/html-editor/ChangeLog 21 Jul 2003 06:47:13 -0000 1.413
+++ components/html-editor/ChangeLog 24 Jul 2003 02:23:32 -0000
@@ -1,3 +1,18 @@
+2003-07-23 Federico Mena Quintero <federico ximian com>
+
+ * menubar.c (menubar_setup): Save the signal ID that we connect.
+ (menubar_detach): New function, disconnects the appropriate
+ signals and removes our menu items.
+
+ * control-data.c (gtk_html_control_data_destroy): Disconnect the
+ menubar signal handler if it is present.
+
+ * editor-control-factory.c (activate_cb): In the deactivate case,
+ call menubar_detach(). Also, set the sensitivity of the
+ EditSpellCheck verb here.
+ (set_frame_cb): Don't set up the menubar here, nor the sensitivity
+ of the EditSpellCheck verb.
+
2003-07-18 Antonio Xu <antonio xu sun com>
* image.c : (get_sample_html) : change some no sense text.
Index: components/html-editor/control-data.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/control-data.c,v
retrieving revision 1.21
diff -u -r1.21 control-data.c
--- components/html-editor/control-data.c 13 Jun 2003 21:45:01 -0000 1.21
+++ components/html-editor/control-data.c 24 Jul 2003 02:23:32 -0000
@@ -79,5 +79,10 @@
if (cd->languages)
CORBA_free (cd->languages);
+ if (cd->menubar_style_changed_id) {
+ g_signal_handler_disconnect (cd->html, cd->menubar_style_changed_id);
+ cd->menubar_style_changed_id = 0;
+ }
+
g_free (cd);
}
Index: components/html-editor/control-data.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/control-data.h,v
retrieving revision 1.25
diff -u -r1.25 control-data.h
--- components/html-editor/control-data.h 14 Nov 2002 14:27:04 -0000 1.25
+++ components/html-editor/control-data.h 24 Jul 2003 02:23:32 -0000
@@ -107,6 +107,9 @@
GtkWidget *file_dialog;
gboolean file_html;
+
+ /* Signal handler IDs that the menubar requires */
+ gulong menubar_style_changed_id;
};
GtkHTMLControlData * gtk_html_control_data_new (GtkHTML *html, GtkWidget *vbox);
Index: components/html-editor/editor-control-factory.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/editor-control-factory.c,v
retrieving revision 1.134
diff -u -r1.134 editor-control-factory.c
--- components/html-editor/editor-control-factory.c 14 Jul 2003 22:16:55 -0000 1.134
+++ components/html-editor/editor-control-factory.c 24 Jul 2003 02:23:32 -0000
@@ -99,27 +99,36 @@
gboolean active,
GtkHTMLControlData *cd)
{
- Bonobo_UIContainer remote_ui_container;
BonoboUIComponent *ui_component;
- printf ("ACTIVATE\n");
+ ui_component = bonobo_control_get_ui_component (control);
if (active) {
+ Bonobo_UIContainer remote_ui_container;
+
+ cd->uic = ui_component;
+
remote_ui_container = bonobo_control_get_remote_ui_container (control, NULL);
- cd->uic = ui_component = bonobo_control_get_ui_component (control);
bonobo_ui_component_set_container (ui_component, remote_ui_container, NULL);
bonobo_object_release_unref (remote_ui_container, NULL);
menubar_setup (ui_component, cd);
- }
+
+ if (!spell_has_control ()) {
+ cd->has_spell_control = FALSE;
+ bonobo_ui_component_set_prop (ui_component, "/commands/EditSpellCheck", "sensitive", "0", NULL);
+ } else {
+ cd->has_spell_control = TRUE;
+ bonobo_ui_component_set_prop (ui_component, "/commands/EditSpellCheck", "sensitive", "1", NULL);
+ }
+ } else
+ menubar_detach (ui_component, cd);
}
static void
set_frame_cb (BonoboControl *control,
gpointer data)
{
- Bonobo_UIContainer remote_ui_container;
- BonoboUIComponent *ui_component;
GtkHTMLControlData *control_data;
GtkWidget *toolbar;
GtkWidget *scrolled_window;
@@ -134,10 +143,7 @@
return;
CORBA_Object_release (frame, NULL);
-
- remote_ui_container = bonobo_control_get_remote_ui_container (control, NULL);
- control_data->uic = ui_component = bonobo_control_get_ui_component (control);
- bonobo_ui_component_set_container (ui_component, remote_ui_container, NULL);
+ control_data->uic = bonobo_control_get_ui_component (control);
/* Setup the tool bar. */
@@ -152,19 +158,7 @@
gtk_box_pack_start (GTK_BOX (control_data->vbox), scrolled_window, TRUE, TRUE, 0);
- /* Setup the menu bar. */
-
- menubar_setup (ui_component, control_data);
-
- if (!spell_has_control ()) {
- control_data->has_spell_control = FALSE;
- bonobo_ui_component_set_prop (ui_component, "/commands/EditSpellCheck", "sensitive", "0", NULL);
- } else
- control_data->has_spell_control = TRUE;
-
gtk_html_set_editor_api (GTK_HTML (control_data->html), editor_api, control_data);
-
- bonobo_object_release_unref (remote_ui_container, NULL);
}
static gint
Index: components/html-editor/menubar.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/menubar.c,v
retrieving revision 1.91
diff -u -r1.91 menubar.c
--- components/html-editor/menubar.c 5 Jun 2003 21:32:32 -0000 1.91
+++ components/html-editor/menubar.c 24 Jul 2003 02:23:32 -0000
@@ -707,5 +707,17 @@
g_free (domain);
menubar_paragraph_style_changed_cb (cd->html, gtk_html_get_paragraph_style (cd->html), cd);
- g_signal_connect (cd->html, "current_paragraph_style_changed", G_CALLBACK (menubar_paragraph_style_changed_cb), cd);
+ cd->menubar_style_changed_id = g_signal_connect (cd->html, "current_paragraph_style_changed",
+ G_CALLBACK (menubar_paragraph_style_changed_cb), cd);
+}
+
+void
+menubar_detach (BonoboUIComponent *uic,
+ GtkHTMLControlData *cd)
+{
+ g_signal_handler_disconnect (cd->html, cd->menubar_style_changed_id);
+ cd->menubar_style_changed_id = 0;
+
+ bonobo_ui_component_rm (uic, "/", NULL);
+ bonobo_ui_component_unset_container (uic, NULL);
}
Index: components/html-editor/menubar.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/components/html-editor/menubar.h,v
retrieving revision 1.6
diff -u -r1.6 menubar.h
--- components/html-editor/menubar.h 17 Dec 2001 18:34:12 -0000 1.6
+++ components/html-editor/menubar.h 24 Jul 2003 02:23:32 -0000
@@ -29,6 +29,8 @@
void menubar_setup (BonoboUIComponent *uic,
GtkHTMLControlData *cd);
+void menubar_detach (BonoboUIComponent *uic,
+ GtkHTMLControlData *cd);
void menubar_update_format (GtkHTMLControlData *cd);
void menubar_set_languages (GtkHTMLControlData *cd,
const gchar *lstr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]