summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Larsson <alexl@redhat.com>2001-09-04 15:37:11 +0000
committerAlexander Larsson <alexl@src.gnome.org>2001-09-04 15:37:11 +0000
commitc113f3a2d1a3b3669c82167e0a32f496257fcb35 (patch)
tree584dc3243a6034905f116e3e61c301933c649f3f
parent7426a6f728612a1239e634bbe85623ee8ef535c8 (diff)
downloadnautilus-c113f3a2d1a3b3669c82167e0a32f496257fcb35.tar.gz
Merge some stuff from the redhat-outstanding-patches branch
2001-09-03 Alex Larsson <alexl@redhat.com> Merge some stuff from the redhat-outstanding-patches branch * components/mozilla/nautilus-mozilla-embed-extensions.cpp (mozilla_get_document_title): add this from Galeon * components/mozilla/nautilus-mozilla-embed-extensions.cpp (mozilla_unicode_to_locale): copy code from Galeon to use Mozilla conversion features to convert unicode to locale encoding * components/mozilla/nautilus-mozilla-content-view.c (mozilla_title_changed_callback): set title in locale encoding * libnautilus-private/nautilus-directory-metafile.c (get_metafile): print error and exit if we fail to open the metafile factory; somewhat cleaner than segfaulting. * libnautilus-private/nautilus-file.c: Cache user information to avoid many getpwuid calls etc. * src/nautilus-complex-search-bar.c (load_find_them_pixmap_widget): Don't leak pixmap and mask. * libnautilus-private/nautilus-icon-container.c (lay_down_icons_tblr): 64bit clean. Use sizeof (int *), not sizeof (int). * Makefile.am, nautilus-help.desktop.in: Add a help icon that uses Nautilus * components/help/help-method.c (help_name_to_local_path): handle ghelp:toc to go to the default page gnome-help-browser used to go to. kind of a lame hack, but so is this whole vfs module ;-)
-rw-r--r--ChangeLog35
-rw-r--r--Makefile.am7
-rw-r--r--components/help/help-method.c73
-rw-r--r--components/mozilla/nautilus-mozilla-content-view.c2
-rw-r--r--components/mozilla/nautilus-mozilla-embed-extensions.cpp70
-rw-r--r--components/mozilla/nautilus-mozilla-embed-extensions.h2
-rw-r--r--libnautilus-private/nautilus-directory-metafile.c69
-rw-r--r--libnautilus-private/nautilus-file.c73
-rw-r--r--libnautilus-private/nautilus-icon-container.c2
-rw-r--r--nautilus-help.desktop.in7
-rw-r--r--src/nautilus-complex-search-bar.c8
11 files changed, 299 insertions, 49 deletions
diff --git a/ChangeLog b/ChangeLog
index 90d5a0deb..8c167bc63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2001-09-03 Alex Larsson <alexl@redhat.com>
+
+ Merge some stuff from the redhat-outstanding-patches branch
+
+ * components/mozilla/nautilus-mozilla-embed-extensions.cpp
+ (mozilla_get_document_title): add this from Galeon
+
+ * components/mozilla/nautilus-mozilla-embed-extensions.cpp
+ (mozilla_unicode_to_locale): copy code from Galeon to use Mozilla
+ conversion features to convert unicode to locale encoding
+
+ * components/mozilla/nautilus-mozilla-content-view.c
+ (mozilla_title_changed_callback): set title in locale encoding
+
+ * libnautilus-private/nautilus-directory-metafile.c
+ (get_metafile): print error and exit if we fail to open the
+ metafile factory; somewhat cleaner than segfaulting.
+
+ * libnautilus-private/nautilus-file.c:
+ Cache user information to avoid many getpwuid calls etc.
+
+ * src/nautilus-complex-search-bar.c (load_find_them_pixmap_widget):
+ Don't leak pixmap and mask.
+
+ * libnautilus-private/nautilus-icon-container.c (lay_down_icons_tblr):
+ 64bit clean. Use sizeof (int *), not sizeof (int).
+
+
+ * Makefile.am, nautilus-help.desktop.in: Add a help icon that uses
+ Nautilus
+
+ * components/help/help-method.c (help_name_to_local_path):
+ handle ghelp:toc to go to the default page gnome-help-browser used
+ to go to. kind of a lame hack, but so is this whole vfs module ;-)
+
2001-09-01 Maciej Stachowiak <mjs@noisehavoc.org>
* libnautilus-private/nautilus-authn-manager.h,
diff --git a/Makefile.am b/Makefile.am
index 44b70792a..52fa50a8f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@ include $(top_srcdir)/Makefile.shared
@XML_I18N_MERGE_DESKTOP_RULE@
-DESKTOP_IN_FILES=nautilus.desktop.in
+DESKTOP_IN_FILES=nautilus.desktop.in nautilus-help.desktop.in
DESKTOP_FILES=$(DESKTOP_IN_FILES:.desktop.in=.desktop)
if HAVE_APPLETS
@@ -39,6 +39,8 @@ EXTRA_DIST= \
nautilus-clean.sh \
nautilus.desktop \
nautilus.desktop.in \
+ nautilus-help.desktop \
+ nautilus-help.desktop.in \
nautilus-launch-icon.png \
nautilusConf.sh.in \
nautilus-config.in \
@@ -60,7 +62,8 @@ appicon_DATA = nautilus-launch-icon.png
Applicationsdir = $(datadir)/gnome/apps/Applications
Applications_DATA = $(DESKTOP_FILES)
-
+Toplevelmenudir = $(datadir)/gnome/apps
+Toplevelmenu_DATA = nautilus-help.desktop
## [The following is shamelessly copied from gnome-vfs.]
diff --git a/components/help/help-method.c b/components/help/help-method.c
index 9398e027d..5b03da6e5 100644
--- a/components/help/help-method.c
+++ b/components/help/help-method.c
@@ -383,52 +383,71 @@ help_name_to_local_path (const char *old_uri)
GList *language_list;
char *new_uri_with_extension;
char *old_help;
+ gboolean is_toc;
+ is_toc = FALSE;
+
base_name = file_from_path (old_uri);
if (base_name == NULL || base_name[0] == '\0') {
g_free (base_name);
return NULL;
}
+ is_toc = strcmp (old_uri, "toc") == 0;
+
new_uri_with_extension = NULL;
new_uri = NULL;
-
+
language_list = gnome_i18n_get_language_list ("LC_MESSAGES");
while (!new_uri_with_extension && language_list) {
const char *lang;
lang = language_list->data;
- buf = g_strdup_printf ("gnome/help/%s/%s/%s", base_name, lang, old_uri);
+ if (is_toc)
+ buf = g_strdup_printf ("gnome/help/help-browser/%s/default-page.html",
+ lang);
+ else
+ buf = g_strdup_printf ("gnome/help/%s/%s/%s", base_name, lang, old_uri);
+
new_uri = gnome_unconditional_datadir_file (buf);
g_free (buf);
- new_uri_with_extension = g_strconcat (new_uri, ".xml", NULL);
- /* FIXME: Should we use g_file_test instead? */
- if (!g_file_exists (new_uri_with_extension)) {
- /* XML file doesn't exist - now try SGML */
- g_free (new_uri_with_extension);
-
- new_uri_with_extension = g_strconcat (new_uri, ".sgml", NULL);
- if (!g_file_exists (new_uri_with_extension)) {
+ if (is_toc) {
+ if (g_file_exists (new_uri)) {
+ new_uri_with_extension = new_uri;
+ new_uri = NULL;
+ }
+ } else {
+ new_uri_with_extension = g_strconcat (new_uri, ".xml", NULL);
+ /* FIXME: Should we use g_file_test instead? */
+ if (!g_file_exists (new_uri_with_extension)) {
+ /* XML file doesn't exist - now try SGML */
+ g_free (new_uri_with_extension);
+
+ new_uri_with_extension = g_strconcat (new_uri, ".sgml", NULL);
+ if (!g_file_exists (new_uri_with_extension)) {
/* SGML file doesn't exist - fallback to SGML */
- g_free (new_uri_with_extension);
-
- old_help = g_strdup_printf ("gnome/help/%s/%s/index.html", base_name, lang);
- new_uri_with_extension = gnome_unconditional_datadir_file (old_help);
- g_free (old_help);
-
- if (!g_file_exists (new_uri_with_extension)) {
- /* HTML file doesn't exist - next language */
- g_free (new_uri_with_extension);
- new_uri_with_extension = NULL;
- }
- }
- }
- g_free (new_uri);
- new_uri = NULL;
- language_list = language_list->next;
- }
+ g_free (new_uri_with_extension);
+
+ old_help = g_strdup_printf ("gnome/help/%s/%s/index.html", base_name, lang);
+ new_uri_with_extension = gnome_unconditional_datadir_file (old_help);
+ g_free (old_help);
+
+ if (!g_file_exists (new_uri_with_extension)) {
+ /* HTML file doesn't exist - next language */
+ g_free (new_uri_with_extension);
+ new_uri_with_extension = NULL;
+ }
+ }
+ }
+ }
+
+ g_free (new_uri);
+ new_uri = NULL;
+ language_list = language_list->next;
+ }
+
return new_uri_with_extension;
}
diff --git a/components/mozilla/nautilus-mozilla-content-view.c b/components/mozilla/nautilus-mozilla-content-view.c
index c918c14e8..ec43d9b9e 100644
--- a/components/mozilla/nautilus-mozilla-content-view.c
+++ b/components/mozilla/nautilus-mozilla-content-view.c
@@ -809,7 +809,7 @@ mozilla_title_changed_callback (GtkMozEmbed *mozilla, gpointer user_data)
g_assert (GTK_MOZ_EMBED (mozilla) == view->details->mozilla);
- new_title = gtk_moz_embed_get_title (view->details->mozilla);
+ new_title = mozilla_get_document_title (view->details->mozilla);
DEBUG_MSG (("=%s : new title='%s'\n", __FUNCTION__, new_title));
diff --git a/components/mozilla/nautilus-mozilla-embed-extensions.cpp b/components/mozilla/nautilus-mozilla-embed-extensions.cpp
index a64517718..497fbb021 100644
--- a/components/mozilla/nautilus-mozilla-embed-extensions.cpp
+++ b/components/mozilla/nautilus-mozilla-embed-extensions.cpp
@@ -42,6 +42,7 @@
#include "nsIMarkupDocumentViewer.h"
#include "nsICharsetConverterManager.h"
#include "nsICharsetConverterManager2.h"
+#include "nsIPlatformCharset.h"
#include <vector>
#include <string>
@@ -326,3 +327,72 @@ convert_ns_string_to_c_string (const nsString & ns_string)
return c_string;
}
+
+/* This is from Galeon */
+static gchar *
+mozilla_unicode_to_locale (const PRUnichar *uniStr)
+{
+ PRInt32 sSize,dSize;
+ gchar *output;
+ nsAutoString platformCharset;
+ nsresult rv;
+
+ /* sanity */
+ if (uniStr == NULL) {
+ return NULL;
+ }
+
+ nsCOMPtr<nsIPlatformCharset> svc;
+ nsCOMPtr<nsICharsetConverterManager> ccm;
+ nsCOMPtr<nsIUnicodeEncoder> encoder;
+ const nsString str (uniStr);
+
+ svc = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
+ if (NS_SUCCEEDED(rv)) {
+ rv = svc->GetCharset(kPlatformCharsetSel_Menu,
+ platformCharset);
+ }
+ if (NS_SUCCEEDED(rv)) {
+ ccm = do_GetService (NS_CHARSETCONVERTERMANAGER_CONTRACTID,
+ &rv);
+ }
+ if (NS_SUCCEEDED(rv)) {
+ rv = ccm->GetUnicodeEncoder(&platformCharset,
+ getter_AddRefs(encoder));
+ }
+ if (NS_SUCCEEDED(rv)) {
+ sSize = str.Length ();
+ encoder->GetMaxLength (str.get(), sSize, &dSize);
+ if (dSize) {
+ output = g_new0 (gchar, dSize + 1);
+ encoder->Convert (str.get(), &sSize, output, &dSize);
+ encoder->Finish (output, &dSize);
+ encoder->Reset ();
+ return output;
+ }
+ }
+ /* return empty string, if something fail */
+ output = g_new0 (gchar, 1);
+ *output = '\0';
+ return output;
+}
+
+char *
+mozilla_get_document_title (const GtkMozEmbed *mozilla_embed)
+{
+ PRUnichar *unicode_title;
+ gchar *title;
+
+ /* get the title in unicode */
+ unicode_title = gtk_moz_embed_get_title_unichar ((GtkMozEmbed *) mozilla_embed);
+
+ /* attempt conversion */
+ title = mozilla_unicode_to_locale (unicode_title);
+
+ /* free unicode version */
+ g_free (unicode_title);
+
+ /* return it */
+ return title;
+}
+
diff --git a/components/mozilla/nautilus-mozilla-embed-extensions.h b/components/mozilla/nautilus-mozilla-embed-extensions.h
index 9bec61619..fc36712a6 100644
--- a/components/mozilla/nautilus-mozilla-embed-extensions.h
+++ b/components/mozilla/nautilus-mozilla-embed-extensions.h
@@ -50,6 +50,8 @@ char * mozilla_charset_encoding_group_get_translated (const GtkMozEmbed *m
const char *encoding);
int mozilla_charset_get_encoding_group_index (const GtkMozEmbed *mozilla_embed,
const char *encoding_group);
+char * mozilla_get_document_title (const GtkMozEmbed *mozilla_embed);
+
#ifdef __cplusplus
}
diff --git a/libnautilus-private/nautilus-directory-metafile.c b/libnautilus-private/nautilus-directory-metafile.c
index 414f7ba83..db6b369ef 100644
--- a/libnautilus-private/nautilus-directory-metafile.c
+++ b/libnautilus-private/nautilus-directory-metafile.c
@@ -51,6 +51,52 @@ free_factory (void)
bonobo_object_release_unref (factory, NULL);
}
+
+static void
+die_on_failed_activation (const char *server_name,
+ CORBA_Environment *ev)
+{
+ /* This isn't supposed to happen. So do some core-dumping action,
+ * and don't bother translating the error message.
+ */
+ const char *extra;
+
+ extra = NULL;
+
+ switch (ev->_major) {
+ case CORBA_NO_EXCEPTION:
+ break;
+
+ case CORBA_SYSTEM_EXCEPTION:
+ extra = CORBA_exception_id (ev);
+ break;
+
+ case CORBA_USER_EXCEPTION:
+ {
+ const gchar* id = CORBA_exception_id (ev);
+
+ if (strcmp (id, "IDL:OAF/GeneralError:1.0") == 0) {
+ OAF_GeneralError* ge = CORBA_exception_value (ev);
+
+ extra = ge->description;
+ } else {
+ extra = id;
+ }
+ }
+ break;
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ g_error ("Failed to activate the server %s; this may indicate a broken\n"
+ "Nautilus or OAF installation, or may reflect a bug in something,\n"
+ "or may mean that your PATH or LD_LIBRARY_PATH or the like is\n"
+ "incorrect. Nautilus will dump core and exit.\n"
+ "Details: '%s'", server_name, extra);
+}
+
static Nautilus_MetafileFactory
get_factory (void)
{
@@ -58,7 +104,19 @@ get_factory (void)
if (factory == CORBA_OBJECT_NIL) {
if (get_factory_from_oaf) {
- factory = oaf_activate_from_id (METAFILE_FACTORY_IID, 0, NULL, NULL);
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ factory = oaf_activate_from_id (METAFILE_FACTORY_IID, 0,
+ NULL, &ev);
+
+ if (factory == CORBA_OBJECT_NIL) {
+ die_on_failed_activation ("Nautilus_MetafileFactory",
+ &ev);
+ }
+
+ CORBA_exception_free (&ev);
} else {
instance = nautilus_metafile_factory_get_instance ();
factory = bonobo_object_dup_ref (bonobo_object_corba_objref (BONOBO_OBJECT (instance)), NULL);
@@ -83,12 +141,19 @@ get_metafile (NautilusDirectory *directory)
directory->details->metafile_corba_object = Nautilus_MetafileFactory_open (get_factory (), uri, &ev);
- /* FIXME bugzilla.eazel.com 6664: examine ev for errors */
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_error ("%s: CORBA error opening MetafileFactory: %s\n",
+ g_get_prgname (),
+ CORBA_exception_id (&ev));
+ }
+
CORBA_exception_free (&ev);
g_free (uri);
}
+ g_assert (directory->details->metafile_corba_object != CORBA_OBJECT_NIL);
+
return bonobo_object_dup_ref (directory->details->metafile_corba_object, NULL);
}
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index f8d67d36f..bd8a1ec48 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -59,6 +59,10 @@
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/time.h>
+
+/* Time in seconds to cache getpwuid results */
+#define GETPWUID_CACHE_TIME (5*60)
#undef NAUTILUS_FILE_DEBUG_REF
@@ -560,6 +564,48 @@ get_file_for_parent_directory (NautilusFile *file)
return result;
}
+struct NautilusUserInfo {
+ uid_t user_id;
+
+ gboolean has_primary_group;
+ gid_t primary_group;
+
+ int num_supplementary_groups;
+ gid_t supplementary_groups[NGROUPS_MAX];
+};
+
+/* Returns a pointer to the cached info, does not need freeing */
+static struct NautilusUserInfo *
+nautilus_file_get_user_info (void)
+{
+ static struct timeval cached_time;
+ static struct NautilusUserInfo info;
+ static gboolean has_cached_info = FALSE;
+ struct passwd *password_info;
+ struct timeval now;
+
+ gettimeofday (&now, NULL);
+
+ if (!has_cached_info ||
+ ((now.tv_sec - cached_time.tv_sec) > GETPWUID_CACHE_TIME)) {
+ cached_time = now;
+ has_cached_info = TRUE;
+
+ info.user_id = geteuid ();
+
+ info.has_primary_group = FALSE;
+ /* No need to free result of getpwuid. */
+ password_info = getpwuid (info.user_id);
+ if (password_info) {
+ info.has_primary_group = TRUE;
+ info.primary_group = password_info->pw_gid;
+ }
+ info.num_supplementary_groups = getgroups (NGROUPS_MAX, info.supplementary_groups);
+ }
+
+ return &info;
+}
+
/**
* nautilus_file_denies_access_permission:
*
@@ -582,10 +628,7 @@ nautilus_file_denies_access_permission (NautilusFile *file,
GnomeVFSFilePermissions group_permission,
GnomeVFSFilePermissions other_permission)
{
- uid_t user_id;
- struct passwd *password_info;
- gid_t supplementary_groups[NGROUPS_MAX];
- int num_supplementary_groups;
+ struct NautilusUserInfo *user_info;
int i;
g_assert (NAUTILUS_IS_FILE (file));
@@ -602,11 +645,14 @@ nautilus_file_denies_access_permission (NautilusFile *file,
return FALSE;
}
- /* Check the user. */
- user_id = geteuid ();
+ /* This is called often. Cache the user information for five minutes */
+ user_info = nautilus_file_get_user_info ();
+
+ /* Check the user. */
+
/* Root is not forbidden to do anything. */
- if (user_id == 0) {
+ if (user_info->user_id == 0) {
return FALSE;
}
@@ -615,26 +661,23 @@ nautilus_file_denies_access_permission (NautilusFile *file,
* Can we trust the uid in the file info? Might
* there be garbage there? What will it do for non-local files?
*/
- if (user_id == (uid_t) file->details->info->uid) {
+ if (user_info->user_id == (uid_t) file->details->info->uid) {
return (file->details->info->permissions & owner_permission) == 0;
}
- /* No need to free result of getpwuid. */
- password_info = getpwuid (user_id);
/* Group member's access is governed by the group bits. */
/* FIXME bugzilla.eazel.com 644:
* Can we trust the gid in the file info? Might
* there be garbage there? What will it do for non-local files?
*/
- if (password_info != NULL
- && password_info->pw_gid == (gid_t) file->details->info->gid) {
+ if (user_info->has_primary_group
+ && user_info->primary_group == (gid_t) file->details->info->gid) {
return (file->details->info->permissions & group_permission) == 0;
}
/* Check supplementary groups */
- num_supplementary_groups = getgroups (NGROUPS_MAX, supplementary_groups);
- for (i = 0; i < num_supplementary_groups; i++) {
- if ((gid_t) file->details->info->gid == supplementary_groups[i]) {
+ for (i = 0; i < user_info->num_supplementary_groups; i++) {
+ if ((gid_t) file->details->info->gid == user_info->supplementary_groups[i]) {
return (file->details->info->permissions & group_permission) == 0;
}
}
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index ae9559278..b09e43869 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -1069,7 +1069,7 @@ lay_down_icons_tblr (NautilusIconContainer *container, GList *icons)
g_assert (grid_memory);
/* Allocate room for the pointers to the rows */
- icon_grid = malloc (num_rows * sizeof (int));
+ icon_grid = malloc (num_rows * sizeof (int *));
g_assert (icon_grid);
/* Point to array pointers */
diff --git a/nautilus-help.desktop.in b/nautilus-help.desktop.in
new file mode 100644
index 000000000..f2679f8c4
--- /dev/null
+++ b/nautilus-help.desktop.in
@@ -0,0 +1,7 @@
+[Desktop Entry]
+_Name=Help
+_Comment=Documentation
+Exec=nautilus --no-default-window --no-desktop ghelp:toc
+Icon=gnome-help.png
+Terminal=0
+Type=Application
diff --git a/src/nautilus-complex-search-bar.c b/src/nautilus-complex-search-bar.c
index 7cbda7baf..229319681 100644
--- a/src/nautilus-complex-search-bar.c
+++ b/src/nautilus-complex-search-bar.c
@@ -453,12 +453,18 @@ load_find_them_pixmap_widget (void)
GdkPixbuf *pixbuf;
GdkPixmap *pixmap;
GdkBitmap *mask;
+ GtkWidget *widget;
pixbuf = gdk_pixbuf_new_from_file (NAUTILUS_PIXMAPDIR "/search.png");
if (pixbuf != NULL) {
gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, EEL_STANDARD_ALPHA_THRESHHOLD);
gdk_pixbuf_unref (pixbuf);
- return gtk_pixmap_new (pixmap, mask);
+ widget = gtk_pixmap_new (pixmap, mask);
+
+ gdk_pixmap_unref (pixmap);
+ gdk_pixmap_unref (mask);
+
+ return widget;
} else {
return NULL;
}