Re: [evolution-patches] Ask user to make evolution default mail app bug #127526 (Mail)





don't call gconf_init here. it should already be initialised by here surely? left over from prototype i guess?


Makes sense, removed it.

+       client = gconf_client_get_default ();
+
+ val = gconf_client_get (client, "/apps/evolution/mail/prompts/default_mailer", NULL);
+       if (val)
+               prompt = gconf_value_get_bool (val);
+       else
+               prompt = TRUE;


I would just use gconf_client_get_bool. Let the schema provide the default; this also lets administrators override the default.


Using gconf_client_get_bool isn't such a good idea, because it returns FALSE if the key is unset (atleast I think it does). And it will be unset the first time we launch evolution, so we got no idea if we should show the dialog or not.

+ val = gconf_client_get (client, "/desktop/gnome/url-handlers/mailto", NULL);
+       if (val) {
+               mailapp = (gchar *) gconf_value_get_string(val);
+               if (strcmp (mailapp, "evolution") == 0)
+                       prompt = FALSE;
+               g_free (mailapp);
+       } else
+               prompt = TRUE;

again i would just use gconf_client_get_string here.
If it is NULL or if it isn't evolution, then prompt == true

I can't see a difference, that's exactly what I do, if the key is unset prompt = TRUE, if not we check if it's evolution. I can't set prompt
to true if mailapp == evolution since default_mailer could be set to false.

And btw, the gchar * typecast is there because I couldn't figure out how
to add glib.h properly.

+
+       if (prompt == TRUE)
+ if (em_utils_prompt_user (NULL, "/apps/evolution/mail/prompts/default_mailer", + "mail:check-default-mail-app", NULL))


you can combine this if into a single expression, makes it a bit more readable to me (less indenting).

if (prompt
   && em_utils_prompt_user( ...))

done

Btw, what's the proper way to make patches?
When I use cvs diff -up, I get a bunch of unnecessary lines in the beginning, like this:
? .ChangeLog.swp
? .mail-component.c.swp
? default_mailer.diff
? mail-component.c-backup
? mail-component.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
......

Niklas


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3434
diff -u -p -r1.3434 ChangeLog
--- ChangeLog	16 Aug 2004 03:31:21 -0000	1.3434
+++ ChangeLog	19 Aug 2004 10:15:33 -0000
@@ -1,3 +1,13 @@
+2004-08-19 Niklas Nylund <ninylund abo fi>
+
+	Fix for bug #12752
+
+	* mail-component.c: Added check_default_mail_app(void)
+	* mail-component.c (mail_component_init): Calls check_default_mail_app()
+	* mail-errors.xml: Added "ask-set-mail-app" error, check_default_mail_app() uses it.
+	* evolution-mail.schemas.in.in: Added /schemas/apps/evolution/mail/prompts/default_mailer bool
+	key. This is used in check_default_mail_app in.
+
 2004-08-13  Not Zed  <NotZed Ximian com>
 
 	* em-utils.c (em_utils_message_to_html): don't include the
Index: evolution-mail.schemas.in.in
===================================================================
RCS file: /cvs/gnome/evolution/mail/evolution-mail.schemas.in.in,v
retrieving revision 1.17
diff -u -p -r1.17 evolution-mail.schemas.in.in
--- evolution-mail.schemas.in.in	10 May 2004 19:35:38 -0000	1.17
+++ evolution-mail.schemas.in.in	19 Aug 2004 10:15:34 -0000
@@ -646,6 +646,21 @@
       </locale>
     </schema>
 
+    <schema>
+      <key>/schemas/apps/evolution/mail/prompts/default_mailer</key>
+      <applyto>/apps/evolution/mail/prompts/default_mailer</applyto>
+      <owner>evolution-mail</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+         <short>Should Evolution check if it's set as default mail application</short>
+         <long>
+	 Should a Yes/No dialog box appear when Evolution launches asking if the
+	 user wants Evolution to be the default mail application.
+         </long>
+      </locale>
+    </schema>
+
     <!-- Trash settings -->
 
     <schema>
Index: mail-component.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-component.c,v
retrieving revision 1.95
diff -u -p -r1.95 mail-component.c
--- mail-component.c	26 Jul 2004 06:41:39 -0000	1.95
+++ mail-component.c	19 Aug 2004 10:15:34 -0000
@@ -829,6 +829,40 @@ mail_component_class_init (MailComponent
 	epv->upgradeFromVersion      = impl_upgradeFromVersion;
 }
 
+static void 
+check_default_mail_app (void) 
+{
+	GConfClient *client;
+	GConfValue *val;
+	gboolean prompt;
+	gchar *mailapp;
+	
+	client = gconf_client_get_default ();
+
+	val = gconf_client_get (client, "/apps/evolution/mail/prompts/default_mailer", NULL);
+	if (val) 
+		prompt = gconf_value_get_bool (val);
+	else
+		prompt = TRUE;
+
+	val = gconf_client_get (client, "/desktop/gnome/url-handlers/mailto", NULL);
+	if (val) {
+		mailapp = (gchar *) gconf_value_get_string(val);
+		if (strcmp (mailapp, "evolution") == 0)
+			prompt = FALSE;
+
+		g_free (mailapp);
+	} else 
+		prompt = TRUE;
+
+	if (prompt && em_utils_prompt_user (NULL, "/apps/evolution/mail/prompts/default_mailer", 
+					    "mail:ask-set-mail-app", NULL)) 
+			gconf_client_set_string (client, "/desktop/gnome/url-handlers/mailto", 
+					         "evolution", NULL);
+
+	g_object_unref (client);
+}
+
 static void
 mail_component_init (MailComponent *component)
 {
@@ -857,6 +891,8 @@ mail_component_init (MailComponent *comp
 	
 	offline = mail_offline_handler_new();
 	bonobo_object_add_interface((BonoboObject *)component, (BonoboObject *)offline);
+
+	check_default_mail_app();
 }
 
 /* Public API.  */
Index: mail-errors.xml
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-errors.xml,v
retrieving revision 1.4
diff -u -p -r1.4 mail-errors.xml
--- mail-errors.xml	29 Jul 2004 06:47:31 -0000	1.4
+++ mail-errors.xml	19 Aug 2004 10:15:34 -0000
@@ -315,5 +315,14 @@ You can choose to ignore this folder, ov
  <primary>Could not connect to {0}. Groupwise account setup is incomplete. You may need to setup  the account again</primary>
 </error>
 
+ <error id="ask-set-mail-app" type="question" default="GTK_RESPONSE_YES">
+  <primary>Evolution is not your current mail application.</primary>
+  <secondary>Evolution can change your GNOME settings to use Evolution as the system mail application.
+  
+Would you like change your default mail application to Evolution?</secondary>
+  <button stock="gtk-no" response="GTK_RESPONSE_NO"/>
+  <button stock="gtk-yes" response="GTK_RESPONSE_YES"/>
+ </error>
+
 </error-list>
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]