Patch: some improvements for gtkmozembed ui module



	Hi,

	This patch should improve a bit the behavior of mozembed (build and
runtime).
	* No we detect the required home of the mozilla engine. We also set a
profile path using the prgname.
	* We use gtkmozembed api to set the mozilla preferences, dropping the
mozilla-preferences file. This way we depend on nothing from mozilla
apis here.
	* Added support for detecting gtkembedmoz.pc (sometimes it's used
instead of gtkmozembed.pc).
	* Now we build with mozembed support in maemo.
	* Removed mozembed calls from TnyMain.
	* Set gtkmozembed chrome mask to remove scroll bars.

	
-- 
Jose Dapena Paz <jdapena igalia com>
Igalia
Index: m4/moz.m4
===================================================================
--- m4/moz.m4	(revisión: 2828)
+++ m4/moz.m4	(copia de trabajo)
@@ -24,19 +24,22 @@
 AC_MSG_RESULT($mozilla_nss)
 
 mozilla_xpcom="no"
+mozilla_home="no"
 AC_MSG_CHECKING(Mozilla XPCOM pkg-config module name)
 mozilla_xpcom_pcs="xpcom mozilla-xpcom firefox-xpcom xulrunner-xpcom microb-engine-xpcom"
 for pc in $mozilla_xpcom_pcs; do
         if $PKG_CONFIG --exists $pc; then
                 mozilla_xpcom=$pc
+		mozilla_home="`$PKG_CONFIG --variable=libdir $pc`"
                 break;
         fi
 done
 AC_MSG_RESULT($mozilla_xpcom)
+AC_MSG_RESULT($mozilla_home)
 
 mozilla_gtkmozembed="no"
 AC_MSG_CHECKING(Mozilla gtkmozembed pkg-config module name)
-mozilla_gtkmozembed_pcs="gtkmozembed mozilla-gtkmozembed firefox-gtkmozembed xulrunner-gtkmozembed microb-engine-gtkmozembed"
+mozilla_gtkmozembed_pcs="gtkmozembed mozilla-gtkmozembed firefox-gtkmozembed xulrunner-gtkmozembed microb-engine-gtkembedmoz gtkembedmoz"
 for pc in $mozilla_gtkmozembed_pcs; do
         if $PKG_CONFIG --exists $pc; then
                 mozilla_gtkmozembed=$pc
Index: debian/rules.maemo
===================================================================
--- debian/rules.maemo	(revisión: 2828)
+++ debian/rules.maemo	(copia de trabajo)
@@ -31,7 +31,7 @@
 	if [ ! -x configure ]; then ./autogen.sh --with-platform=maemo --with-ssl=nss; fi
 	dh_testdir
 	# Add here commands to configure the package.
-	CFLAGS="$(CFLAGS) -fPIC" ./configure --with-platform=maemo --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --with-ssl=nss --sysconfdir=/etc --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info
+	CFLAGS="$(CFLAGS) -fPIC" ./configure --with-platform=maemo --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --with-ssl=nss --sysconfdir=/etc --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --with-html-component=mozembed
 
 
 build: build-stamp
@@ -94,7 +94,7 @@
 #	dh_installinfo
 #	dh_installman
 	dh_link
-	dh_strip --keep-debug --dbg-package=libtinymail-1.0-0 --dbg-package=libtinymail-camel-1.0-0 --dbg-package=libtinymailui-1.0-0 --dbg-package=libtinymailui-gtk-1.0-0 --dbg-package=libtinymail-maemo-1.0-0 --dbg-package=libtinymail-gnomevfs-1.0-0
+	dh_strip --keep-debug --dbg-package=libtinymail-1.0-0 --dbg-package=libtinymail-camel-1.0-0 --dbg-package=libtinymailui-1.0-0 --dbg-package=libtinymailui-gtk-1.0-0 --dbg-package=libtinymail-maemo-1.0-0 --dbg-package=libtinymail-gnomevfs-1.0-0 --dbg-package=libtinymail-mozembed-1.0-0
 	dh_compress
 	dh_fixperms
 #	dh_perl
Index: debian/control.maemo1
===================================================================
--- debian/control.maemo1	(revisión: 2828)
+++ debian/control.maemo1	(copia de trabajo)
@@ -2,7 +2,7 @@
 Section: libs 
 Priority: optional
 Maintainer: Oystein Gisnas <oystein gisnas net>
-Build-Depends: debhelper (>=4), cdbs, dpkg-dev (>= 1.13.18), libglib2.0-dev (>= 2.6), libgtk2.0-dev, libosso-gnomevfs2-dev, libgconf2-dev, libosso-dev, libconic0-dev, gnome-common, gtk-doc-tools, microb-engine-dev 
+Build-Depends: debhelper (>=4), cdbs, dpkg-dev (>= 1.13.18), libglib2.0-dev (>= 2.6), libgtk2.0-dev, libosso-gnomevfs2-dev, libgconf2-dev, libosso-dev, libconic0-dev, gnome-common, gtk-doc-tools, microb-engine-dev, libgtkmozembed-dev 
 Standards-Version: 3.7.2
 
 Package: libtinymail-1.0-0
@@ -223,3 +223,26 @@
  .
  This package contains the debug symbol files for libtinymail-gnomevfs.
 
+Package: libtinymailui-mozembed-1.0-0
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: memory-effective framework for accessing e-mail - Camel library
+ Tinymail is a development framework for accessing E-mail services using
+ devices with few memory resources.
+ .
+ It supports local mail storage (Maildir,mh,spool & mbox), IMAP, Exchange
+ and NNTP. It can be used to send messages over SMTP and by using sendmail.
+ .
+ This package contains the library for rendering HTML.
+
+Package: libtinymailui-mozembed-1.0-0-dev
+Architecture: any
+Depends: libtinymailui-mozembed-1.0-0 (= ${binary:Version})
+Description: memory-effective framework for accessing e-mail - development files
+ Tinymail is a development framework for accessing E-mail services using
+ devices with few memory resources.
+ .
+ It supports local mail storage (Maildir,mh,spool & mbox), IMAP, Exchange
+ and NNTP. It can be used to send messages over SMTP and by using sendmail.
+ .
+ This package contains the development files for libtinymailui-mozembed.
Index: tests/c-demo/tny-main.c
===================================================================
--- tests/c-demo/tny-main.c	(revisión: 2828)
+++ tests/c-demo/tny-main.c	(copia de trabajo)
@@ -46,11 +46,6 @@
 #include <libgnomevfs/gnome-vfs-utils.h>
 #endif
 
-#ifdef MOZEMBED
-#include <nspr.h>
-#include <prthread.h>
-#endif
-
 /**
  * main:
  * @argc: Amount of arguments
@@ -137,9 +132,5 @@
 
 	gdk_threads_leave ();
 
-#ifdef MOZEMBED
-	PR_ProcessExit ((PRIntn)(long)0);
-#endif
-
 	return 0;
 }
Index: configure.ac
===================================================================
--- configure.ac	(revisión: 2828)
+++ configure.ac	(copia de trabajo)
@@ -60,7 +60,7 @@
 build_gnome=true
 build_uigtk=true
 build_demoui=true
-build_mozembed=true
+build_mozembed=false
 build_webkit=false
 build_gtkhtml=false
 build_doxygen=false
@@ -87,7 +87,6 @@
         build_mozembed=false
         build_gnome=false
 	build_maemo=true
-        with_html_component=none
 	build_uigtk=true
 	build_demoui=true
 	PLATFORM=2
@@ -375,26 +374,25 @@
 
   AC_TNY_MOZ_CHECK
 
-  if test x$mozilla_nspr = xno; then
-    AC_MSG_ERROR("You need Mozilla's NSPR") 
-  fi
-  if test x$mozilla_nss = xno; then
-    AC_MSG_ERROR("You need Mozilla's NSS")
-  fi
   if test x$mozilla_xpcom = xno; then
-    AC_MSG_ERROR("You need Mozilla's XPCOM")
+   AC_MSG_ERROR("You need Mozilla's XPCOM")
   fi
+
   if test x$mozilla_gtkmozembed = xno; then
    AC_MSG_ERROR("You need Mozilla's GtkMozEmbed")
   fi
 
-  extraplatpkgs="$mozilla_nspr $mozilla_nss $mozilla_xpcom $mozilla_gtkmozembed"
+  extraplatpkgs="$mozilla_xpcom $mozilla_gtkmozembed"
   extratnypkgs="$extratnypkgs $extraplatpkgs"
   PKG_CHECK_MODULES(LIBTINYMAILUI_MOZEMBED, $extraplatpkgs glib-2.0 >= 2.8 gobject-2.0 gtk+-2.0 $extragtkpkgs)
+  MOZILLA_HOME="$mozilla_home"
+  AC_DEFINE_UNQUOTED(MOZILLA_HOME,"$mozilla_home",["The path of the mozilla engine"])
 else
   LIBTINYMAILUI_MOZEMBED_CFLAGS=
   LIBTINYMAILUI_MOZEMBED_LIBS=
+  MOZILLA_HOME=
 fi
+AC_SUBST([MOZILLA_HOME])
 
 dnl ### libtinymail-gnome-desktop, a GNOME platform library implementation ##
 if test x$PLATFORMDIR = xlibtinymail-gnome-desktop; then
Index: libtinymailui-mozembed/mozilla-preferences.cpp
===================================================================
--- libtinymailui-mozembed/mozilla-preferences.cpp	(revisión: 2828)
+++ libtinymailui-mozembed/mozilla-preferences.cpp	(copia de trabajo)
@@ -1,83 +0,0 @@
-/* libtinymailui-mozembed - The Tiny Mail UI library for Gtk+
-* Copyright (C) 2006-2007 Philip Van Hoof <pvanhoof gnome org>
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with self library; if not, write to the
-* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-* Boston, MA 02111-1307, USA.
-*/
-
-#include <config.h>
-
-#include "mozilla-preferences.h"
-
-#include <stdlib.h>
-#include <nsIServiceManager.h>
-#include <nsComponentManagerUtils.h>
-#include <pref/nsIPref.h>
-#include <nsCOMPtr.h>
-
-
-extern "C" gboolean
-_mozilla_preference_set (const char *preference_name, const char *new_value)
-{
-    g_return_val_if_fail (preference_name != NULL, FALSE);
-    g_return_val_if_fail (new_value != NULL, FALSE);
-    
-    nsCOMPtr<nsIPref> pref = do_CreateInstance (NS_PREF_CONTRACTID);
-    
-    if (pref)
-    {
-	nsresult rv = pref->SetCharPref (preference_name, new_value);
-	
-	return NS_SUCCEEDED (rv) ? TRUE : FALSE;
-    }
-    
-    return FALSE;
-}
-
-extern "C" gboolean
-_mozilla_preference_set_boolean (const char *preference_name, gboolean new_boolean_value)
-{
-    g_return_val_if_fail (preference_name != NULL, FALSE);
-    
-    nsCOMPtr<nsIPref> pref = do_CreateInstance (NS_PREF_CONTRACTID);
-    
-    if (pref)
-    {
-	nsresult rv = pref->SetBoolPref (preference_name,
-					 new_boolean_value ? PR_TRUE : PR_FALSE);
-	
-	return NS_SUCCEEDED (rv) ? TRUE : FALSE;
-    }
-    
-    return FALSE;
-}
-
-extern "C" gboolean
-_mozilla_preference_set_int (const char *preference_name, gint new_int_value)
-{
-    g_return_val_if_fail (preference_name != NULL, FALSE);
-    
-    nsCOMPtr<nsIPref> pref = do_CreateInstance (NS_PREF_CONTRACTID);
-    
-    if (pref)
-    {
-	nsresult rv = pref->SetIntPref (preference_name, new_int_value);
-	
-	return NS_SUCCEEDED (rv) ? TRUE : FALSE;
-    }
-    
-    return FALSE;
-}
-
Index: libtinymailui-mozembed/Makefile.am
===================================================================
--- libtinymailui-mozembed/Makefile.am	(revisión: 2828)
+++ libtinymailui-mozembed/Makefile.am	(copia de trabajo)
@@ -20,9 +20,7 @@
 	$(libtinymailui_mozembed_1_0_headers) \
 	tny-moz-embed-html-mime-part-view.c \
 	tny-moz-embed-msg-view.c \
-	tny-moz-embed-stream.c \
-	mozilla-preferences.cpp \
-	mozilla-preferences.h
+	tny-moz-embed-stream.c
 
 libtinymailui_mozembed_1_0_la_LIBADD = 	\
 	$(LIBTINYMAILUI_MOZEMBED_LIBS)	\
Index: libtinymailui-mozembed/tny-moz-embed-html-mime-part-view.c
===================================================================
--- libtinymailui-mozembed/tny-moz-embed-html-mime-part-view.c	(revisión: 2828)
+++ libtinymailui-mozembed/tny-moz-embed-html-mime-part-view.c	(copia de trabajo)
@@ -21,8 +21,6 @@
 #include <config.h>
 #include <glib/gi18n-lib.h>
 
-#include "mozilla-preferences.h"
-
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdio.h>
@@ -33,6 +31,8 @@
 #include <string.h>
 #include <gtk/gtk.h>
 
+#include <gtkmozembed_common.h>
+
 #include <tny-moz-embed-html-mime-part-view.h>
 #include <tny-moz-embed-stream.h>
 
@@ -142,7 +142,7 @@
 
 	priv->part = NULL;
 	gtk_moz_embed_set_chrome_mask (GTK_MOZ_EMBED (self), 
-			GTK_MOZ_EMBED_FLAG_DEFAULTCHROME|GTK_MOZ_EMBED_FLAG_SCROLLBARSON);
+			GTK_MOZ_EMBED_FLAG_DEFAULTCHROME | GTK_MOZ_EMBED_FLAG_WINDOWRESIZEON);
 
 	g_signal_connect (G_OBJECT (self), "new_window",
 		G_CALLBACK (new_window_cb), self);
@@ -183,6 +183,13 @@
 tny_moz_embed_html_mime_part_view_class_init (TnyMozEmbedHtmlMimePartViewClass *class)
 {
 	GObjectClass *object_class;
+	gint int_value;
+	gboolean bool_value;
+	const gchar *home_path;
+	const gchar *full_path;
+	const gchar *prgname;
+	gchar *profile_path;
+	gchar *useragent;
 
 	parent_class = g_type_class_peek_parent (class);
 	object_class = (GObjectClass*) class;
@@ -191,15 +198,33 @@
 
 	g_type_class_add_private (object_class, sizeof (TnyMozEmbedHtmlMimePartViewPriv));
 
+	gtk_moz_embed_set_path (MOZILLA_HOME);
+
+	home_path = getenv ("HOME");
+	if (!home_path)
+		home_path = g_get_home_dir ();
+	prgname = g_get_prgname ();
+	if (!prgname)
+		prgname = "tinymail";
+	full_path = g_strdup_printf("%s/%s", home_path, ".tinymail");
+	profile_path = g_strconcat ("mozembed-", prgname, NULL);
+	gtk_moz_embed_set_profile_path (full_path, profile_path);
+	g_free (profile_path);
+
 	gtk_moz_embed_push_startup ();
 
-	_mozilla_preference_set_int ("permissions.default.image", 2);
-	_mozilla_preference_set_int ("permissions.default.script", 2);
-	_mozilla_preference_set_boolean ("security.checkloaduri", FALSE);
-	_mozilla_preference_set ("general.useragent.misc", "Tinymail/" VERSION);
-	_mozilla_preference_set ("network.proxy.no_proxies_on", "localhost");
+	int_value = 2;
+	gtk_moz_embed_common_set_pref (GTK_TYPE_INT, "permissions.default.image", &int_value);
+	gtk_moz_embed_common_set_pref (GTK_TYPE_INT, "permissions.default.script", &int_value);
 
+	bool_value = FALSE;
+	gtk_moz_embed_common_set_pref (GTK_TYPE_BOOL, "security.checkloaduri", &bool_value);
 
+	useragent = g_strconcat (prgname, "/", VERSION, NULL);
+	gtk_moz_embed_common_set_pref (GTK_TYPE_STRING, "general.useragent.misc", useragent);
+	g_free (useragent);
+	gtk_moz_embed_common_set_pref (GTK_TYPE_STRING, "network.proxy.no_proxies_on", "localhost");
+
 	return;
 }
 
Index: libtinymailui-mozembed/mozilla-preferences.h
===================================================================
--- libtinymailui-mozembed/mozilla-preferences.h	(revisión: 2828)
+++ libtinymailui-mozembed/mozilla-preferences.h	(copia de trabajo)
@@ -1,33 +0,0 @@
-#ifndef MOZILLA_PREFERENCES_H
-#define MOZILLA_PREFERENCES_H
-
-/* libtinymailui-mozembed - The Tiny Mail UI library for Gtk+
- * Copyright (C) 2006-2007 Philip Van Hoof <pvanhoof gnome org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with self library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-gboolean _mozilla_preference_set (const char *preference_name, const char *new_value);
-gboolean _mozilla_preference_set_boolean (const char *preference_name, gboolean new_boolean_value);
-gboolean _mozilla_preference_set_int (const char *preference_name, gint new_int_value);
-
-G_END_DECLS
-
-#endif
Index: ChangeLog
===================================================================
--- ChangeLog	(revisión: 2828)
+++ ChangeLog	(copia de trabajo)
@@ -1,3 +1,22 @@
+2007-10-10  Jose Dapena Paz  <jdapena igalia com>
+
+	* m4/moz.m4: add support for gtkmozembed library using gtkembedmoz.pc.
+	Also export mozilla_home.
+	* debian/rules.maemo: compile with mozembed support.
+	* debian/control.maemo1: compile with mozembed support.
+	* tests/c-demo/tny-main.c: remove mozilla calls in main.
+	* configure.ac: some fixes for html module detection. Use mozilla home.
+	Now we only use detection of xpcom for being sure we've got an engine
+	path.
+	* Removed libtinymailui-mozembed/mozilla-preferences.{cpp,h}, as we now
+	use gtk moz embed api to set preferences.
+	* libtinymalui-mozembed/Makefile.am: removed mozilla preferences from
+	build.
+	* libtinymailui-mozembed/tny-moz-embed-html-mime-part-view.c:
+	Now we use gtk moz embed to set preferences. We also set properly the
+	component path (mozilla home from used engine), and the profile path
+	(using the progname). We set a default chrome without scrollbars.
+
 2007-10-08  Philip Van Hoof  <pvanhoof gnome org>
 
 	* Merged camel-mime-utils.c with uptream Camel
Index: config.h.in
===================================================================
--- config.h.in	(revisión: 2828)
+++ config.h.in	(copia de trabajo)
@@ -54,6 +54,9 @@
 /* "Whether to hack the TnyMaemoConicDevice to somewhat work in sbox" */
 #undef MAEMO_CONIC_DUMMY
 
+/* "The path of the mozilla engine" */
+#undef MOZILLA_HOME
+
 /* Name of package */
 #undef PACKAGE
 


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