Re: [evolution-patches] Patch to make the composer remember its size (for trunk and evolution-1-4-branch)
- From: Jeffrey Stedfast <fejj ximian com>
- To: Ettore Perazzoli <ettore ximian com>
- Cc: evolution-patches ximian com
- Subject: Re: [evolution-patches] Patch to make the composer remember its size (for trunk and evolution-1-4-branch)
- Date: Mon, 22 Sep 2003 16:50:33 -0400
looks good, but does the idle id variable name have to be so verbose?
:-)
Jeff
On Mon, 2003-09-22 at 16:27, Ettore Perazzoli wrote:
> On Fri, 2003-09-19 at 11:15, Jeffrey Stedfast wrote:
> > the patch looks good except for one possible niggle, which is that
> > setting a new gconf value on each size-allocate event might cause too
> > much corba traffic. I mention this because the same setup for pane
> > resizing in the mailer made it feel slow due to all the gconf updates
> > and stuff.
>
> Yeah, good point. It didn't look like it was a problem on my system,
> but I fixed it so it sets the values in an idle handler anyways.
>
> New patch attached. In addition to updating the setting in an idle
> handler, it also overrides ::size_allocated instead of connecting to the
> signal.
>
> (Why is the code connecting to its own signals in the first place? I
> blindly copied that initially, but it looks like method override would
> be better, since we are subclassing in the first place.)
>
> -- Ettore
>
> ______________________________________________________________________
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
> retrieving revision 1.544.2.14
> diff -u -p -r1.544.2.14 ChangeLog
> --- ChangeLog 15 Sep 2003 18:29:22 -0000 1.544.2.14
> +++ ChangeLog 22 Sep 2003 20:26:08 -0000
> @@ -1,3 +1,24 @@
> +2003-09-18 Ettore Perazzoli <ettore ximian com>
> +
> + * e-msg-composer.c (DEFAULT_WIDTH): Removed.
> + (DEFAULT_HEIGHT): Removed.
> + (save_default_size_settings): New function to store the default
> + width/height settings into GConf.
> + (idle_save_default_size_settings_cb): New callback to store the
> + default width/height settings in the idle loop.
> + (composer_dispose): Save default width/height settings, and remove
> + a pending idle handler.
> + (size_allocate): Override implementation for
> + GtkWidget::size_allocate.
> + (class_init): Install it.
> + (msg_composer_key_pressed): Renamed from composer_key_pressed()
> + for consistency.
> + (create_composer): Set the window's default size from the GConf
> + settings.
> +
> + * e-msg-composer.h: New member save_default_size_settings_idle_id
> + in struct EMsgComposer.
> +
> 2003-09-15 Ettore Perazzoli <ettore ximian com>
>
> * e-msg-composer-hdrs.c (header_new_recipient): Make the entry
> Index: e-msg-composer.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/composer/e-msg-composer.c,v
> retrieving revision 1.395.2.7
> diff -u -p -r1.395.2.7 e-msg-composer.c
> --- e-msg-composer.c 29 Aug 2003 05:57:25 -0000 1.395.2.7
> +++ e-msg-composer.c 22 Sep 2003 20:26:09 -0000
> @@ -107,9 +107,6 @@
> #define d(x) x
>
>
> -#define DEFAULT_WIDTH 600
> -#define DEFAULT_HEIGHT 500
> -
> enum {
> SEND,
> SAVE_DRAFT,
> @@ -162,6 +159,19 @@ static void handle_multipart_signed (EMs
> static void set_editor_signature (EMsgComposer *composer);
>
>
> +static void
> +save_default_size_settings (EMsgComposer *composer)
> +{
> + GtkAllocation *allocation = &(GTK_WIDGET (composer)->allocation);
> + GConfClient *gconf = gconf_client_get_default ();
> +
> + gconf_client_set_int (gconf, "/apps/evolution/mail/composer/view/default_width", allocation->width, NULL);
> + gconf_client_set_int (gconf, "/apps/evolution/mail/composer/view/default_height", allocation->height, NULL);
> +
> + g_object_unref (gconf);
> +}
> +
> +
> static GByteArray *
> get_text (Bonobo_PersistStream persist, char *format)
> {
> @@ -196,7 +206,8 @@ get_text (Bonobo_PersistStream persist,
> static CamelMimePartEncodingType
> best_encoding (GByteArray *buf, const char *charset)
> {
> - char *in, *out, outbuf[256], *ch;
> + const char *in;
> + char *out, outbuf[256], *ch;
> size_t inlen, outlen;
> int status, count = 0;
> iconv_t cd;
> @@ -2386,6 +2397,14 @@ from_changed_cb (EMsgComposerHdrs *hdrs,
> e_msg_composer_show_sig_file (composer);
> }
>
> +static int
> +idle_save_default_size_settings_cb (EMsgComposer *composer)
> +{
> + save_default_size_settings (composer);
> + composer->save_default_size_settings_idle_id = 0;
> + return FALSE;
> +}
> +
>
> /* GObject methods. */
>
> @@ -2425,6 +2444,14 @@ composer_finalise (GObject *object)
> static void
> composer_dispose(GObject *object)
> {
> + EMsgComposer *composer = E_MSG_COMPOSER (object);
> +
> + save_default_size_settings (composer);
> + if (composer->save_default_size_settings_idle_id != 0) {
> + g_source_remove (composer->save_default_size_settings_idle_id);
> + composer->save_default_size_settings_idle_id = 0;
> + }
> +
> /* When destroy() is called, the contents of the window
> * (including the remote editor control) will already have
> * been destroyed, so we have to do this here.
> @@ -2512,6 +2539,19 @@ delete_event (GtkWidget *widget,
> }
>
> static void
> +size_allocate (GtkWidget *widget,
> + GtkAllocation *allocation)
> +{
> + EMsgComposer *composer = E_MSG_COMPOSER (widget);
> +
> + if (composer->save_default_size_settings_idle_id == 0)
> + composer->save_default_size_settings_idle_id = g_idle_add ((GSourceFunc) idle_save_default_size_settings_cb,
> + composer);
> +
> + (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
> +}
> +
> +static void
> message_rfc822_dnd (EMsgComposer *composer, CamelStream *stream)
> {
> CamelMimeParser *mp;
> @@ -2633,6 +2673,7 @@ class_init (EMsgComposerClass *klass)
> gobject_class->dispose = composer_dispose;
> object_class->destroy = destroy;
> widget_class->delete_event = delete_event;
> + widget_class->size_allocate = size_allocate;
>
> parent_class = g_type_class_ref(bonobo_window_get_type ());
>
> @@ -2822,8 +2863,9 @@ msg_composer_destroy_notify (void *data)
> all_composers = g_slist_remove (all_composers, composer);
> }
>
> +
> static int
> -composer_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
> +msg_composer_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
> {
> if (event->keyval == GDK_Escape) {
> do_exit (E_MSG_COMPOSER (widget));
> @@ -2906,22 +2948,26 @@ create_composer (int visible_mask)
> Bonobo_Unknown editor_server;
> CORBA_Environment ev;
> GConfClient *gconf;
> + int default_width, default_height;
> int vis;
>
> + gconf = gconf_client_get_default ();
> +
> composer = g_object_new (E_TYPE_MSG_COMPOSER, "win_name", _("Compose a message"), NULL);
> gtk_window_set_title ((GtkWindow *) composer, _("Compose a message"));
>
> all_composers = g_slist_prepend (all_composers, composer);
>
> - g_signal_connect (composer, "key-press-event",
> - G_CALLBACK (composer_key_pressed),
> + g_signal_connect (composer, "key_press_event",
> + G_CALLBACK (msg_composer_key_pressed),
> NULL);
> g_signal_connect (composer, "destroy",
> G_CALLBACK (msg_composer_destroy_notify),
> NULL);
> -
> - gtk_window_set_default_size (GTK_WINDOW (composer),
> - DEFAULT_WIDTH, DEFAULT_HEIGHT);
> +
> + default_width = gconf_client_get_int (gconf, "/apps/evolution/mail/composer/view/default_width", NULL);
> + default_height = gconf_client_get_int (gconf, "/apps/evolution/mail/composer/view/default_height", NULL);
> + gtk_window_set_default_size (GTK_WINDOW (composer), default_width, default_height);
> gnome_window_icon_set_from_file (GTK_WINDOW (composer), EVOLUTION_IMAGESDIR
> "/compose-message.png");
>
> @@ -2945,6 +2991,7 @@ create_composer (int visible_mask)
> SELECT_NAMES_OAFIID,
> "IDL:Bonobo/Control:1.0");
> gtk_object_destroy (GTK_OBJECT (composer));
> + g_object_unref (gconf);
> return NULL;
> }
>
> @@ -2975,6 +3022,7 @@ create_composer (int visible_mask)
> GNOME_GTKHTML_EDITOR_CONTROL_ID,
> "IDL:Bonobo/Control:1.0");
> gtk_object_destroy (GTK_OBJECT (composer));
> + g_object_unref (gconf);
> return NULL;
> }
>
> @@ -2983,12 +3031,10 @@ create_composer (int visible_mask)
> "FormatHTML", TC_CORBA_boolean, composer->send_html,
> NULL);
>
> - gconf = gconf_client_get_default ();
> composer_settings_update (gconf, 0, NULL, composer);
> gconf_client_add_dir (gconf, "/apps/evolution/mail/composer", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
> composer->notify_id = gconf_client_notify_add (gconf, "/apps/evolution/mail/composer",
> composer_settings_update, composer, NULL, NULL);
> - g_object_unref (gconf);
>
> editor_server = bonobo_widget_get_objref (BONOBO_WIDGET (composer->editor));
>
> @@ -3040,6 +3086,7 @@ create_composer (int visible_mask)
> GNOME_GTKHTML_EDITOR_CONTROL_ID,
> "IDL:GNOME/GtkHTML/Editor/Engine:1.0");
> gtk_object_destroy (GTK_OBJECT (composer));
> + g_object_unref (gconf);
> return NULL;
> }
>
> @@ -3052,6 +3099,7 @@ create_composer (int visible_mask)
>
> autosave_manager_register (am, composer);
>
> + g_object_unref (gconf);
> return composer;
> }
>
> Index: e-msg-composer.h
> ===================================================================
> RCS file: /cvs/gnome/evolution/composer/e-msg-composer.h,v
> retrieving revision 1.83
> diff -u -p -r1.83 e-msg-composer.h
> --- e-msg-composer.h 20 May 2003 18:26:09 -0000 1.83
> +++ e-msg-composer.h 22 Sep 2003 20:26:09 -0000
> @@ -106,6 +106,8 @@ struct _EMsgComposer {
> CamelMimeMessage *redirect;
>
> guint notify_id;
> +
> + guint save_default_size_settings_idle_id;
> };
>
> struct _EMsgComposerClass {
--
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com - www.ximian.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]