diff options
22 files changed, 320 insertions, 286 deletions
@@ -1,3 +1,67 @@ +2001-04-02 Ramiro Estrugo <ramiro@eazel.com> + + reviewed by: Gene Ragan <gzr@eazel.com> + + * acconfig.h: + * configure.in: + Add a NAUTILUS_SOURCE_DIRECTORY that contains the location of the + nautilus source code, so that some checks can work without having + to do 'make install' + + * components/services/install-view/nautilus-service-install-view.c: + (nautilus_service_install_view_initialize_class): + Initialize preferences so that smooth widgets and other nautilus + specific preferences work. + + * components/services/summary/nautilus-summary-view.c: + (nautilus_summary_view_initialize_class): + Initialize preferences so that smooth widgets and other nautilus + specific preferences work. + + * libnautilus-extensions/Makefile.am: + Remove macros that arent needed any more. + + * libnautilus-extensions/nautilus-entry.h: + * libnautilus-extensions/nautilus-entry.c: + (nautilus_entry_initialize), (obscure_cursor), + (nautilus_entry_key_press), (nautilus_entry_motion_notify), + (nautilus_entry_set_text), (nautilus_entry_insert_text), + (nautilus_entry_delete_text), (nautilus_entry_initialize_class), + (nautilus_entry_set_special_tab_handling): + Make all the attributes private. + + * libnautilus-extensions/nautilus-font-manager.c: + (at_exit_handler), (nautilus_free_static_storage_at_exit), + (gnome_vfs_init_if_needed), (font_description_table_add), + (font_description_table_new), (directory_contains_file), + (ensure_local_font_table), + (nautilus_font_manager_get_default_font), + (nautilus_font_manager_get_default_bold_font), + (nautilus_self_check_font_manager): + Remove dependency on nautilus-file-utilities. Update for new + machanism for finding data in the source directory so that checks + work even when Nautilus has not undergone 'make install.' + + * libnautilus-extensions/nautilus-global-preferences.c: + (smooth_graphics_mode_changed_callback), + (nautilus_global_preferences_initialize): + Keep track of preferences smooth graphics mode changes and call + the new smooth widget api for changing the smoothness of all + tracked widgets. + + * libnautilus-extensions/nautilus-scalable-font.c: + Remove a rogue unused #include. + + * libnautilus-extensions/nautilus-smooth-widget.h: + * libnautilus-extensions/nautilus-smooth-widget.c: + (nautilus_smooth_widget_global_set_is_smooth), + (nautilus_smooth_widget_register): + Dont use preferences to track global smoothness changes. Add a + function to that instead. + + * src/nautilus-location-bar.c: (nautilus_location_bar_initialize): + Update for privatized NautilusEntry attributes. + 2001-04-02 John Sullivan <sullivan@eazel.com> reviewed by: Darin Adler <darin@eazel.com> diff --git a/acconfig.h b/acconfig.h index fc3b04c93..952c6fcea 100644 --- a/acconfig.h +++ b/acconfig.h @@ -1,4 +1,5 @@ #undef NAUTILUS_BUILD_MESSAGE +#undef NAUTILUS_SOURCE_DIRECTORY #undef EAZEL_BUILD_TIMESTAMP #undef EAZEL_SERVICES #undef ENABLE_NLS diff --git a/components/services/install-view/nautilus-service-install-view.c b/components/services/install-view/nautilus-service-install-view.c index cc3c37c5d..52189a97e 100644 --- a/components/services/install-view/nautilus-service-install-view.c +++ b/components/services/install-view/nautilus-service-install-view.c @@ -47,7 +47,7 @@ #include <libnautilus-extensions/nautilus-password-dialog.h> #include <libnautilus-extensions/nautilus-stock-dialogs.h> #include <libnautilus-extensions/nautilus-viewport.h> -#include <libnautilus-extensions/nautilus-preferences.h> +#include <libnautilus-extensions/nautilus-global-preferences.h> #include <libnautilus-extensions/nautilus-clickable-image.h> #include <stdio.h> #include <fcntl.h> @@ -140,6 +140,8 @@ nautilus_service_install_view_initialize_class (NautilusServiceInstallViewClass parent_class = gtk_type_class (gtk_event_box_get_type ()); object_class->destroy = nautilus_service_install_view_destroy; object_class->finalize = nautilus_service_install_view_finalize; + + nautilus_global_preferences_initialize (); } static void diff --git a/components/services/summary/nautilus-summary-view.c b/components/services/summary/nautilus-summary-view.c index 159648dc6..0041f0989 100644 --- a/components/services/summary/nautilus-summary-view.c +++ b/components/services/summary/nautilus-summary-view.c @@ -42,22 +42,22 @@ #include "../inventory/eazel-inventory.h" #endif -#include <libnautilus-extensions/nautilus-clickable-image.h> #include <libnautilus-extensions/nautilus-background.h> #include <libnautilus-extensions/nautilus-bonobo-extensions.h> +#include <libnautilus-extensions/nautilus-clickable-image.h> #include <libnautilus-extensions/nautilus-file-utilities.h> #include <libnautilus-extensions/nautilus-gdk-extensions.h> #include <libnautilus-extensions/nautilus-glib-extensions.h> +#include <libnautilus-extensions/nautilus-global-preferences.h> #include <libnautilus-extensions/nautilus-gnome-extensions.h> #include <libnautilus-extensions/nautilus-gtk-extensions.h> #include <libnautilus-extensions/nautilus-gtk-macros.h> +#include <libnautilus-extensions/nautilus-label.h> #include <libnautilus-extensions/nautilus-stock-dialogs.h> #include <libnautilus-extensions/nautilus-string.h> #include <libnautilus-extensions/nautilus-tabs.h> -#include <libnautilus-extensions/nautilus-label.h> #include <libnautilus-extensions/nautilus-viewport.h> - #include <liboaf/liboaf.h> #include <libtrilobite/trilobite-redirect.h> #include <libtrilobite/eazelproxy.h> @@ -787,6 +787,7 @@ nautilus_summary_view_initialize_class (NautilusSummaryViewClass *klass) parent_class = gtk_type_class (gtk_event_box_get_type ()); object_class->destroy = nautilus_summary_view_destroy; + nautilus_global_preferences_initialize (); } static void diff --git a/configure.in b/configure.in index d03f9c19d..b40c43bd3 100644 --- a/configure.in +++ b/configure.in @@ -991,6 +991,9 @@ fi AC_DEFINE_UNQUOTED(NAUTILUS_BUILD_MESSAGE, "$NAUTILUS_BUILD_MESSAGE") +NAUTILUS_SOURCE_DIRECTORY=`(cd $srcdir && pwd)` +AC_DEFINE_UNQUOTED(NAUTILUS_SOURCE_DIRECTORY, "$NAUTILUS_SOURCE_DIRECTORY") + dnl dnl Define the build timestamp if given in the environment. dnl @@ -1186,7 +1189,7 @@ echo "FREETYPE2_LIBS : $FREETYPE2_LIBS" dnl <= Snapshot things => echo "EAZEL_BUILD_TIMESTAMP : $EAZEL_BUILD_TIMESTAMP" echo "NAUTILUS_BUILD_MESSAGE : $NAUTILUS_BUILD_MESSAGE" -echo "NAUTILUS_BUILD_LOCATION : $NAUTILUS_BUILD_LOCATION" +echo "NAUTILUS_SOURCE_DIRECTORY : $NAUTILUS_SOURCE_DIRECTORY" echo "HAVE_APPLETS : $HAVE_APPLETS" dnl <= End of configuration summary => diff --git a/libnautilus-extensions/Makefile.am b/libnautilus-extensions/Makefile.am index 30bb99b77..637d404d1 100644 --- a/libnautilus-extensions/Makefile.am +++ b/libnautilus-extensions/Makefile.am @@ -21,7 +21,6 @@ INCLUDES = \ -D_REENTRANT \ -DDATADIR=\""$(datadir)"\" \ -DNAUTILUS_DATADIR=\""$(datadir)/nautilus"\" \ - -DSOURCE_DATADIR=\""$(top_srcdir)/data"\" \ $(NULL) dependency_static_libs = \ diff --git a/libnautilus-extensions/nautilus-entry.c b/libnautilus-extensions/nautilus-entry.c index 4d4a684ff..0f406709d 100644 --- a/libnautilus-extensions/nautilus-entry.c +++ b/libnautilus-extensions/nautilus-entry.c @@ -39,6 +39,9 @@ struct NautilusEntryDetails { gboolean use_emacs_shortcuts; + gboolean user_edit; + gboolean special_tab_handling; + gboolean cursor_obscured; }; enum { @@ -74,7 +77,7 @@ nautilus_entry_initialize (NautilusEntry *entry) widget = GTK_WIDGET (entry); entry->details = g_new0 (NautilusEntryDetails, 1); - entry->user_edit = TRUE; + entry->details->user_edit = TRUE; /* Allow pointer motion events so we can expose an obscured cursor if necessary */ gtk_widget_set_events (widget, gtk_widget_get_events (widget) | GDK_POINTER_MOTION_MASK); @@ -123,11 +126,11 @@ nautilus_entry_destroy (GtkObject *object) static void obscure_cursor (NautilusEntry *entry) { - if (entry->cursor_obscured) { + if (entry->details->cursor_obscured) { return; } - entry->cursor_obscured = TRUE; + entry->details->cursor_obscured = TRUE; nautilus_gdk_window_set_invisible_cursor (GTK_ENTRY (entry)->text_area); } @@ -154,7 +157,7 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event) * should position the insertion point at the end of * the selection. */ - if (entry->special_tab_handling && editable->has_selection) { + if (entry->details->special_tab_handling && editable->has_selection) { position = strlen (gtk_entry_get_text (GTK_ENTRY (editable))); gtk_entry_select_region (GTK_ENTRY (editable), position, position); return TRUE; @@ -206,11 +209,11 @@ nautilus_entry_motion_notify (GtkWidget *widget, GdkEventMotion *event) /* Reset cursor to I-Beam */ entry = NAUTILUS_ENTRY (widget); - if (entry->cursor_obscured) { + if (entry->details->cursor_obscured) { cursor = gdk_cursor_new (GDK_XTERM); gdk_window_set_cursor (GTK_ENTRY (entry)->text_area, cursor); gdk_cursor_destroy (cursor); - entry->cursor_obscured = FALSE; + entry->details->cursor_obscured = FALSE; } old_start_pos = GTK_EDITABLE (widget)->selection_start_pos; @@ -295,9 +298,9 @@ nautilus_entry_set_text (NautilusEntry *entry, const gchar *text) { g_return_if_fail (NAUTILUS_IS_ENTRY (entry)); - entry->user_edit = FALSE; + entry->details->user_edit = FALSE; gtk_entry_set_text (GTK_ENTRY (entry), text); - entry->user_edit = TRUE; + entry->details->user_edit = TRUE; gtk_signal_emit (GTK_OBJECT (entry), signals[SELECTION_CHANGED]); } @@ -354,7 +357,7 @@ nautilus_entry_insert_text (GtkEditable *editable, const gchar *text, entry = NAUTILUS_ENTRY(editable); /* Fire off user changed signals */ - if (entry->user_edit) { + if (entry->details->user_edit) { gtk_signal_emit (GTK_OBJECT (editable), signals[USER_CHANGED]); } @@ -372,7 +375,7 @@ nautilus_entry_delete_text (GtkEditable *editable, int start_pos, int end_pos) entry = NAUTILUS_ENTRY (editable); /* Fire off user changed signals */ - if (entry->user_edit) { + if (entry->details->user_edit) { gtk_signal_emit (GTK_OBJECT (editable), signals[USER_CHANGED]); } @@ -446,3 +449,12 @@ nautilus_entry_initialize_class (NautilusEntryClass *class) GTK_TYPE_NONE, 0); gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } + +void +nautilus_entry_set_special_tab_handling (NautilusEntry *entry, + gboolean special_tab_handling) +{ + g_return_if_fail (NAUTILUS_IS_ENTRY (entry)); + + entry->details->special_tab_handling = special_tab_handling; +} diff --git a/libnautilus-extensions/nautilus-entry.h b/libnautilus-extensions/nautilus-entry.h index 085f066c7..dc94d2711 100644 --- a/libnautilus-extensions/nautilus-entry.h +++ b/libnautilus-extensions/nautilus-entry.h @@ -48,11 +48,6 @@ typedef struct NautilusEntryDetails NautilusEntryDetails; typedef struct { GtkEntry parent; NautilusEntryDetails *details; - - /* FIXME: should be in details struct */ - gboolean user_edit; - gboolean special_tab_handling; - gboolean cursor_obscured; } NautilusEntry; typedef struct { @@ -62,13 +57,15 @@ typedef struct { void (*selection_changed) (NautilusEntry *entry); } NautilusEntryClass; -GtkType nautilus_entry_get_type (void); -GtkWidget *nautilus_entry_new (void); -GtkWidget *nautilus_entry_new_with_max_length (guint16 max); -void nautilus_entry_set_text (NautilusEntry *entry, - const char *text); -void nautilus_entry_select_all (NautilusEntry *entry); -void nautilus_entry_select_all_at_idle (NautilusEntry *entry); +GtkType nautilus_entry_get_type (void); +GtkWidget *nautilus_entry_new (void); +GtkWidget *nautilus_entry_new_with_max_length (guint16 max); +void nautilus_entry_set_text (NautilusEntry *entry, + const char *text); +void nautilus_entry_select_all (NautilusEntry *entry); +void nautilus_entry_select_all_at_idle (NautilusEntry *entry); +void nautilus_entry_set_special_tab_handling (NautilusEntry *entry, + gboolean special_tab_handling); END_GNOME_DECLS diff --git a/libnautilus-extensions/nautilus-font-manager.c b/libnautilus-extensions/nautilus-font-manager.c index b9b0f71c8..dc6937d99 100644 --- a/libnautilus-extensions/nautilus-font-manager.c +++ b/libnautilus-extensions/nautilus-font-manager.c @@ -26,7 +26,6 @@ #include <config.h> #include "nautilus-font-manager.h" -#include "nautilus-file-utilities.h" #include "nautilus-glib-extensions.h" #include "nautilus-lib-self-check-functions.h" #include "nautilus-string-list.h" @@ -59,6 +58,10 @@ #define POSTSCRIPT_FONT_MIME_TYPE "application/x-font-type1" #define TRUE_TYPE_FONT_MIME_TYPE "application/x-font-ttf" +#define SOURCE_FONT_DIRECTORY NAUTILUS_SOURCE_DIRECTORY "/data/fonts/urw" +#define DEFAULT_FONT "n019003l.pfb" +#define DEFAULT_BOLD_FONT "n019004l.pfb" + /* These font families are black listed, because they * arent useful at all to display "normal" text - at * least in the context of Nautilus. @@ -397,7 +400,7 @@ font_description_table_add (FontDescriptionTable *table, xlfd_delimeter++; } - font_file_full_path = nautilus_make_path (table->directory, font_file_name); + font_file_full_path = g_strdup_printf ("%s/%s", table->directory, font_file_name); font_type = font_get_font_type (font_file_full_path, postscript_font_list, true_type_font_list); @@ -589,7 +592,7 @@ font_description_table_new (const char *font_directory, g_return_val_if_fail (string_is_valid (font_directory), NULL); g_return_val_if_fail (g_file_test (font_directory, G_FILE_TEST_ISDIR), NULL); - description_file = nautilus_make_path (font_directory, FONTS_DIR_FILE_NAME); + description_file = g_strdup_printf ("%s/%s", font_directory, FONTS_DIR_FILE_NAME); description_contents = file_as_string (description_file); /* Error reading file, report errors by returning NULL. */ @@ -638,12 +641,12 @@ font_description_table_new (const char *font_directory, /* Assign the alias file if found */ if (directory_contains_file (font_directory, FONTS_ALIAS_FILE_NAME)) { - table->fonts_alias_file = nautilus_make_path (font_directory, FONTS_ALIAS_FILE_NAME); + table->fonts_alias_file = g_strdup_printf ("%s/%s", font_directory, FONTS_ALIAS_FILE_NAME); } /* Assign the alias scale if found */ if (directory_contains_file (font_directory, FONTS_SCALE_FILE_NAME)) { - table->fonts_scale_file = nautilus_make_path (font_directory, FONTS_SCALE_FILE_NAME); + table->fonts_scale_file = g_strdup_printf ("%s/%s", font_directory, FONTS_SCALE_FILE_NAME); } g_free (description_contents); @@ -925,7 +928,7 @@ directory_contains_file (const char *directory, g_return_val_if_fail (string_is_valid (directory), FALSE); g_return_val_if_fail (string_is_valid (file_name), FALSE); - path = nautilus_make_path (directory, file_name); + path = g_strdup_printf ("%s/%s", directory, file_name); result = g_file_exists (path); g_free (path); @@ -1088,23 +1091,27 @@ free_font_tables (void) static void ensure_local_font_table (void) { - char *user_directory; char *user_font_dir; if (global_font_table != NULL) { return; } - /* Populate the default font table if needed */ - font_manager_collect_font_tables (DEFAULT_FONT_DIRECTORY, &global_font_table); + /* Populate the default font table if needed. Use the installed fonts + * if available. Otherwise use the ones in the source tree itself, so that + * checks will work even if Nautilus has not undergone 'make install.' + */ + if (g_file_exists (DEFAULT_FONT_DIRECTORY "/" DEFAULT_FONT)) { + font_manager_collect_font_tables (DEFAULT_FONT_DIRECTORY, &global_font_table); + } else { + font_manager_collect_font_tables (SOURCE_FONT_DIRECTORY, &global_font_table); + } /* Populate the user font table if needed */ - user_directory = nautilus_get_user_directory (); - user_font_dir = nautilus_make_path (user_directory, USER_FONT_DIRECTORY_NAME); + user_font_dir = g_strdup_printf ("%s/.nautilus/%s", g_get_home_dir (), USER_FONT_DIRECTORY_NAME); if (g_file_test (user_font_dir, G_FILE_TEST_ISDIR)) { font_manager_collect_font_tables (user_font_dir, &global_font_table); } - g_free (user_directory); g_free (user_font_dir); /* Populate the system font table if needed - using the font server's configuration */ @@ -1153,24 +1160,18 @@ nautilus_font_manager_for_each_font (NautilusFontManagerCallback callback, } } +/* Return the default font. It will be found either in place where nautilus + * gets installed (via 'make install') or the source directory if nautilus + * has not undergone 'make install' + */ char * nautilus_font_manager_get_default_font (void) { guint i; - /* FIXME bugzilla.eazel.com 7343: - * We want this to work in the case where nautilus has - * not undergone 'make install'. In order to do that - * we need to find out our fully qualified pwd - - * probably using a configure.on NAUTILUS_PWD=`pwd` - * hack of some kind. For now, commenting this out - * to make checks work in tinderbox again. - */ static const char *default_fonts[] = { - DEFAULT_FONT_DIRECTORY "/n019003l.pfb", - /* SOURCE_DATADIR "/fonts/urw/n019003l.pfb", */ - "/usr/share/fonts/default/Type1/n019003l.pfb", - "/usr/X11R6/lib/X11/fonts/Type1/lcdxsr.pfa" + DEFAULT_FONT_DIRECTORY "/" DEFAULT_FONT, + SOURCE_FONT_DIRECTORY "/" DEFAULT_FONT }; for (i = 0; i < NAUTILUS_N_ELEMENTS (default_fonts); i++) { @@ -1182,15 +1183,18 @@ nautilus_font_manager_get_default_font (void) return NULL; } +/* Return the default vold font. It will be found either in place where nautilus + * gets installed (via 'make install') or the source directory if nautilus + * has not undergone 'make install' + */ char * nautilus_font_manager_get_default_bold_font (void) { guint i; static const char *default_bold_fonts[] = { - DEFAULT_FONT_DIRECTORY "/n019004l.pfb", - "/usr/share/fonts/default/Type1/n019003l.pfb", - /* SOURCE_DATADIR "/fonts/urw/n019004l.pfb", */ + DEFAULT_FONT_DIRECTORY "/" DEFAULT_BOLD_FONT, + SOURCE_FONT_DIRECTORY "/" DEFAULT_BOLD_FONT }; for (i = 0; i < NAUTILUS_N_ELEMENTS (default_bold_fonts); i++) { @@ -1314,6 +1318,11 @@ nautilus_font_manager_weight_is_bold (const char *weight) #if !defined (NAUTILUS_OMIT_SELF_CHECK) +#define TEST_FONT1 SOURCE_FONT_DIRECTORY "/" "n019003l.pfb" +#define TEST_FONT2 SOURCE_FONT_DIRECTORY "/" "n019004l.pfb" +#define TEST_FONT3 SOURCE_FONT_DIRECTORY "/" "n019023l.pfb" +#define TEST_FONT4 SOURCE_FONT_DIRECTORY "/" "n019024l.pfb" + static char * call_chop_off_comments (const char *input) { @@ -1323,40 +1332,13 @@ call_chop_off_comments (const char *input) return test_copy; } -static char * -get_test_font_dir (void) -{ - char *test_font_dir; - char *uri; - char *base_uri; - char *relative_part; - char *current_dir; - - current_dir = g_get_current_dir (); - - base_uri = g_strdup_printf ("file://%s/", current_dir); - relative_part = g_strdup_printf ("%s/%s", SOURCE_DATADIR, "/fonts/urw"); - - uri = nautilus_uri_make_full_from_relative (base_uri, relative_part); - - test_font_dir = g_strdup (uri + strlen ("file://")); - - g_free (base_uri); - g_free (relative_part); - g_free (uri); - g_free (current_dir); - - return test_font_dir; -} - void nautilus_self_check_font_manager (void) { FontDescriptionTable *table; const FontDescription *description; GList *font_table_list = NULL; - char *test_font_dir; - char *font_name_table[4]; + char *original_current_dir; /* chop_off_comments() */ NAUTILUS_CHECK_STRING_RESULT (call_chop_off_comments ("foo bar"), "foo bar"); @@ -1367,34 +1349,29 @@ nautilus_self_check_font_manager (void) NAUTILUS_CHECK_STRING_RESULT (call_chop_off_comments ("\\#foo bar"), "\\#foo bar"); NAUTILUS_CHECK_STRING_RESULT (call_chop_off_comments ("\\##foo bar"), "\\#"); - test_font_dir = get_test_font_dir (); + original_current_dir = g_get_current_dir (); - g_return_if_fail (g_file_exists (test_font_dir)); + g_return_if_fail (g_file_exists (SOURCE_FONT_DIRECTORY)); - font_name_table[0] = g_strdup_printf ("%s/%s", test_font_dir, "n019003l.pfb"); - font_name_table[1] = g_strdup_printf ("%s/%s", test_font_dir, "n019004l.pfb"); - font_name_table[2] = g_strdup_printf ("%s/%s", test_font_dir, "n019023l.pfb"); - font_name_table[3] = g_strdup_printf ("%s/%s", test_font_dir, "n019024l.pfb"); + g_return_if_fail (g_file_exists (TEST_FONT1)); + g_return_if_fail (g_file_exists (TEST_FONT2)); + g_return_if_fail (g_file_exists (TEST_FONT3)); + g_return_if_fail (g_file_exists (TEST_FONT4)); - g_return_if_fail (g_file_exists (font_name_table[0])); - g_return_if_fail (g_file_exists (font_name_table[1])); - g_return_if_fail (g_file_exists (font_name_table[2])); - g_return_if_fail (g_file_exists (font_name_table[3])); - - font_manager_collect_font_tables (test_font_dir, &font_table_list); + font_manager_collect_font_tables (SOURCE_FONT_DIRECTORY, &font_table_list); g_return_if_fail (font_table_list != NULL); g_return_if_fail (g_list_nth_data (font_table_list, 0) != NULL); table = g_list_nth_data (font_table_list, 0); NAUTILUS_CHECK_INTEGER_RESULT (font_description_table_get_length (table), 4); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 0), font_name_table[0]); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 1), font_name_table[1]); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 2), font_name_table[2]); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 3), font_name_table[3]); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 0), TEST_FONT1); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 1), TEST_FONT2); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 2), TEST_FONT3); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 3), TEST_FONT4); description = font_description_table_peek_nth (table, 0); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[0]); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT1); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "medium"); @@ -1403,7 +1380,7 @@ nautilus_self_check_font_manager (void) NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); description = font_description_table_peek_nth (table, 1); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[1]); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT2); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "bold"); @@ -1412,7 +1389,7 @@ nautilus_self_check_font_manager (void) NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); description = font_description_table_peek_nth (table, 2); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[2]); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT3); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "medium"); @@ -1421,7 +1398,7 @@ nautilus_self_check_font_manager (void) NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); description = font_description_table_peek_nth (table, 3); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[3]); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT4); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "bold"); @@ -1429,12 +1406,6 @@ nautilus_self_check_font_manager (void) NAUTILUS_CHECK_STRING_RESULT (font_description_get_set_width (description), "normal"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); - g_free (font_name_table[0]); - g_free (font_name_table[1]); - g_free (font_name_table[2]); - g_free (font_name_table[3]); - g_free (test_font_dir); - font_table_list_free (font_table_list); } diff --git a/libnautilus-extensions/nautilus-global-preferences.c b/libnautilus-extensions/nautilus-global-preferences.c index 431e92619..400f72ca8 100644 --- a/libnautilus-extensions/nautilus-global-preferences.c +++ b/libnautilus-extensions/nautilus-global-preferences.c @@ -39,6 +39,7 @@ #include "nautilus-stock-dialogs.h" #include "nautilus-view-identifier.h" #include "nautilus-sidebar-functions.h" +#include "nautilus-smooth-widget.h" #include <gconf/gconf.h> #include <gconf/gconf-client.h> #include <libgnome/gnome-i18n.h> @@ -1535,6 +1536,17 @@ nautilus_global_preferences_get_default_smooth_bold_font (void) return global_preferences_get_smooth_bold_font (default_smooth_font_auto_value); } +/* Let the smooth widget machinery know about smoothness changes */ +static void +smooth_graphics_mode_changed_callback (gpointer callback_data) +{ + gboolean is_smooth; + + is_smooth = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE); + + nautilus_smooth_widget_global_set_is_smooth (is_smooth); +} + void nautilus_global_preferences_initialize (void) { @@ -1554,4 +1566,13 @@ nautilus_global_preferences_initialize (void) &icon_view_smooth_font_auto_value); nautilus_preferences_add_auto_string (NAUTILUS_PREFERENCES_DEFAULT_SMOOTH_FONT, &default_smooth_font_auto_value); + + nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, + smooth_graphics_mode_changed_callback, + NULL); + + /* Keep track of smooth graphics mode changes in order to notify the smooth + * widget machinery. + */ + smooth_graphics_mode_changed_callback (NULL); } diff --git a/libnautilus-extensions/nautilus-scalable-font.c b/libnautilus-extensions/nautilus-scalable-font.c index 7b4739fd3..9cf671595 100644 --- a/libnautilus-extensions/nautilus-scalable-font.c +++ b/libnautilus-extensions/nautilus-scalable-font.c @@ -31,7 +31,6 @@ #include "nautilus-glyph.h" #include "nautilus-gtk-macros.h" #include "nautilus-lib-self-check-functions.h" -#include "nautilus-global-preferences.h" #include "nautilus-string.h" #include <librsvg/rsvg-ft.h> #include <libgnome/gnome-util.h> diff --git a/libnautilus-extensions/nautilus-smooth-widget.c b/libnautilus-extensions/nautilus-smooth-widget.c index 4b6229422..75ba2c20b 100644 --- a/libnautilus-extensions/nautilus-smooth-widget.c +++ b/libnautilus-extensions/nautilus-smooth-widget.c @@ -25,7 +25,6 @@ #include <config.h> #include "nautilus-smooth-widget.h" -#include "nautilus-global-preferences.h" #include "nautilus-gdk-extensions.h" #include "nautilus-art-gtk-extensions.h" @@ -78,13 +77,11 @@ static void smooth_widget_paint_tile_and_content_transparent (GtkWi NautilusSmoothCompositeCallback composite_callback, gpointer callback_data); -/* We maintain a global list of smooth widgets. We then monitor changes in - * the Nautilus "smooth_graphics" preference. When this preference changes, - * we iterate through the global list of smooth widgets and toggle their - * is_smooth attribute. +/* We maintain a global list of smooth widgets. The smoothness of all these + * widgets can then be changed with nautilus_smooth_widget_global_set_is_smooth(). * * We do this so that labels and images will repect the "smooth_graphics" - * preferences without any intervention from the users of these two widgets. + * automatically without any intervention from the users of these two widgets. */ static GList *smooth_widget_list = NULL; @@ -134,12 +131,6 @@ smooth_widget_set_is_smooth (GtkWidget *widget, gboolean is_smooth) gtk_signal_emit_by_name (GTK_OBJECT (widget), "set_is_smooth", is_smooth); } -static gboolean -preferences_get_is_smooth (void) -{ - return nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE); -} - static void smooth_widget_destroy (GtkWidget *widget, gpointer callback_data) { @@ -148,17 +139,17 @@ smooth_widget_destroy (GtkWidget *widget, gpointer callback_data) smooth_widget_list = g_list_remove (smooth_widget_list, widget); } -static void -smooth_graphics_mode_changed_callback (gpointer callback_data) +static gboolean global_is_smooth = TRUE; + +void +nautilus_smooth_widget_global_set_is_smooth (gboolean is_smooth) { - gboolean is_smooth; - GList *iterator; + GList *node; - is_smooth = preferences_get_is_smooth (); - - for (iterator = smooth_widget_list; iterator; iterator = iterator->next) { - smooth_widget_set_is_smooth (GTK_WIDGET (iterator->data), - is_smooth); + global_is_smooth = is_smooth; + + for (node = smooth_widget_list; node != NULL; node = node->next) { + smooth_widget_set_is_smooth (GTK_WIDGET (node->data), global_is_smooth); } } @@ -167,17 +158,15 @@ smooth_graphics_mode_changed_callback (gpointer callback_data) * @widget: A smooth widget. * * Register a smooth widget. For the life time of the widget, its - * 'is_smooth' attribute will be toggled to match the value of - * the Nautilus "smooth_graphics" boolean preference. + * 'is_smooth' attribute will be toggled when + * nautilus_smooth_widget_global_set_is_smooth() is called. */ void nautilus_smooth_widget_register (GtkWidget *widget) { - static gboolean preferences_callback_registered = FALSE; - g_return_if_fail (widget_is_smooth (widget)); - smooth_widget_set_is_smooth (widget, preferences_get_is_smooth ()); + smooth_widget_set_is_smooth (widget, global_is_smooth); if (smooth_widget_list == NULL) { g_atexit (smooth_widget_list_free); @@ -190,15 +179,6 @@ nautilus_smooth_widget_register (GtkWidget *widget) "destroy", GTK_SIGNAL_FUNC (smooth_widget_destroy), NULL); - - /* Add a preference callback. This happens only once */ - if (preferences_callback_registered == FALSE) { - preferences_callback_registered = TRUE; - - nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, - smooth_graphics_mode_changed_callback, - NULL); - } } /* Return the origin point for the widget given vertical diff --git a/libnautilus-extensions/nautilus-smooth-widget.h b/libnautilus-extensions/nautilus-smooth-widget.h index 7661a586f..d92fc0515 100644 --- a/libnautilus-extensions/nautilus-smooth-widget.h +++ b/libnautilus-extensions/nautilus-smooth-widget.h @@ -112,6 +112,8 @@ NautilusDimensions nautilus_smooth_widget_get_preferred_dimensions (const GtkWid int tile_height); void nautilus_smooth_widget_register_type (GtkType type); +void nautilus_smooth_widget_global_set_is_smooth (gboolean is_smooth); + END_GNOME_DECLS #endif /* NAUTILUS_SMOOTH_WIDGET_H */ diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am index 30bb99b77..637d404d1 100644 --- a/libnautilus-private/Makefile.am +++ b/libnautilus-private/Makefile.am @@ -21,7 +21,6 @@ INCLUDES = \ -D_REENTRANT \ -DDATADIR=\""$(datadir)"\" \ -DNAUTILUS_DATADIR=\""$(datadir)/nautilus"\" \ - -DSOURCE_DATADIR=\""$(top_srcdir)/data"\" \ $(NULL) dependency_static_libs = \ diff --git a/libnautilus-private/nautilus-entry.c b/libnautilus-private/nautilus-entry.c index 4d4a684ff..0f406709d 100644 --- a/libnautilus-private/nautilus-entry.c +++ b/libnautilus-private/nautilus-entry.c @@ -39,6 +39,9 @@ struct NautilusEntryDetails { gboolean use_emacs_shortcuts; + gboolean user_edit; + gboolean special_tab_handling; + gboolean cursor_obscured; }; enum { @@ -74,7 +77,7 @@ nautilus_entry_initialize (NautilusEntry *entry) widget = GTK_WIDGET (entry); entry->details = g_new0 (NautilusEntryDetails, 1); - entry->user_edit = TRUE; + entry->details->user_edit = TRUE; /* Allow pointer motion events so we can expose an obscured cursor if necessary */ gtk_widget_set_events (widget, gtk_widget_get_events (widget) | GDK_POINTER_MOTION_MASK); @@ -123,11 +126,11 @@ nautilus_entry_destroy (GtkObject *object) static void obscure_cursor (NautilusEntry *entry) { - if (entry->cursor_obscured) { + if (entry->details->cursor_obscured) { return; } - entry->cursor_obscured = TRUE; + entry->details->cursor_obscured = TRUE; nautilus_gdk_window_set_invisible_cursor (GTK_ENTRY (entry)->text_area); } @@ -154,7 +157,7 @@ nautilus_entry_key_press (GtkWidget *widget, GdkEventKey *event) * should position the insertion point at the end of * the selection. */ - if (entry->special_tab_handling && editable->has_selection) { + if (entry->details->special_tab_handling && editable->has_selection) { position = strlen (gtk_entry_get_text (GTK_ENTRY (editable))); gtk_entry_select_region (GTK_ENTRY (editable), position, position); return TRUE; @@ -206,11 +209,11 @@ nautilus_entry_motion_notify (GtkWidget *widget, GdkEventMotion *event) /* Reset cursor to I-Beam */ entry = NAUTILUS_ENTRY (widget); - if (entry->cursor_obscured) { + if (entry->details->cursor_obscured) { cursor = gdk_cursor_new (GDK_XTERM); gdk_window_set_cursor (GTK_ENTRY (entry)->text_area, cursor); gdk_cursor_destroy (cursor); - entry->cursor_obscured = FALSE; + entry->details->cursor_obscured = FALSE; } old_start_pos = GTK_EDITABLE (widget)->selection_start_pos; @@ -295,9 +298,9 @@ nautilus_entry_set_text (NautilusEntry *entry, const gchar *text) { g_return_if_fail (NAUTILUS_IS_ENTRY (entry)); - entry->user_edit = FALSE; + entry->details->user_edit = FALSE; gtk_entry_set_text (GTK_ENTRY (entry), text); - entry->user_edit = TRUE; + entry->details->user_edit = TRUE; gtk_signal_emit (GTK_OBJECT (entry), signals[SELECTION_CHANGED]); } @@ -354,7 +357,7 @@ nautilus_entry_insert_text (GtkEditable *editable, const gchar *text, entry = NAUTILUS_ENTRY(editable); /* Fire off user changed signals */ - if (entry->user_edit) { + if (entry->details->user_edit) { gtk_signal_emit (GTK_OBJECT (editable), signals[USER_CHANGED]); } @@ -372,7 +375,7 @@ nautilus_entry_delete_text (GtkEditable *editable, int start_pos, int end_pos) entry = NAUTILUS_ENTRY (editable); /* Fire off user changed signals */ - if (entry->user_edit) { + if (entry->details->user_edit) { gtk_signal_emit (GTK_OBJECT (editable), signals[USER_CHANGED]); } @@ -446,3 +449,12 @@ nautilus_entry_initialize_class (NautilusEntryClass *class) GTK_TYPE_NONE, 0); gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); } + +void +nautilus_entry_set_special_tab_handling (NautilusEntry *entry, + gboolean special_tab_handling) +{ + g_return_if_fail (NAUTILUS_IS_ENTRY (entry)); + + entry->details->special_tab_handling = special_tab_handling; +} diff --git a/libnautilus-private/nautilus-entry.h b/libnautilus-private/nautilus-entry.h index 085f066c7..dc94d2711 100644 --- a/libnautilus-private/nautilus-entry.h +++ b/libnautilus-private/nautilus-entry.h @@ -48,11 +48,6 @@ typedef struct NautilusEntryDetails NautilusEntryDetails; typedef struct { GtkEntry parent; NautilusEntryDetails *details; - - /* FIXME: should be in details struct */ - gboolean user_edit; - gboolean special_tab_handling; - gboolean cursor_obscured; } NautilusEntry; typedef struct { @@ -62,13 +57,15 @@ typedef struct { void (*selection_changed) (NautilusEntry *entry); } NautilusEntryClass; -GtkType nautilus_entry_get_type (void); -GtkWidget *nautilus_entry_new (void); -GtkWidget *nautilus_entry_new_with_max_length (guint16 max); -void nautilus_entry_set_text (NautilusEntry *entry, - const char *text); -void nautilus_entry_select_all (NautilusEntry *entry); -void nautilus_entry_select_all_at_idle (NautilusEntry *entry); +GtkType nautilus_entry_get_type (void); +GtkWidget *nautilus_entry_new (void); +GtkWidget *nautilus_entry_new_with_max_length (guint16 max); +void nautilus_entry_set_text (NautilusEntry *entry, + const char *text); +void nautilus_entry_select_all (NautilusEntry *entry); +void nautilus_entry_select_all_at_idle (NautilusEntry *entry); +void nautilus_entry_set_special_tab_handling (NautilusEntry *entry, + gboolean special_tab_handling); END_GNOME_DECLS diff --git a/libnautilus-private/nautilus-font-manager.c b/libnautilus-private/nautilus-font-manager.c index b9b0f71c8..dc6937d99 100644 --- a/libnautilus-private/nautilus-font-manager.c +++ b/libnautilus-private/nautilus-font-manager.c @@ -26,7 +26,6 @@ #include <config.h> #include "nautilus-font-manager.h" -#include "nautilus-file-utilities.h" #include "nautilus-glib-extensions.h" #include "nautilus-lib-self-check-functions.h" #include "nautilus-string-list.h" @@ -59,6 +58,10 @@ #define POSTSCRIPT_FONT_MIME_TYPE "application/x-font-type1" #define TRUE_TYPE_FONT_MIME_TYPE "application/x-font-ttf" +#define SOURCE_FONT_DIRECTORY NAUTILUS_SOURCE_DIRECTORY "/data/fonts/urw" +#define DEFAULT_FONT "n019003l.pfb" +#define DEFAULT_BOLD_FONT "n019004l.pfb" + /* These font families are black listed, because they * arent useful at all to display "normal" text - at * least in the context of Nautilus. @@ -397,7 +400,7 @@ font_description_table_add (FontDescriptionTable *table, xlfd_delimeter++; } - font_file_full_path = nautilus_make_path (table->directory, font_file_name); + font_file_full_path = g_strdup_printf ("%s/%s", table->directory, font_file_name); font_type = font_get_font_type (font_file_full_path, postscript_font_list, true_type_font_list); @@ -589,7 +592,7 @@ font_description_table_new (const char *font_directory, g_return_val_if_fail (string_is_valid (font_directory), NULL); g_return_val_if_fail (g_file_test (font_directory, G_FILE_TEST_ISDIR), NULL); - description_file = nautilus_make_path (font_directory, FONTS_DIR_FILE_NAME); + description_file = g_strdup_printf ("%s/%s", font_directory, FONTS_DIR_FILE_NAME); description_contents = file_as_string (description_file); /* Error reading file, report errors by returning NULL. */ @@ -638,12 +641,12 @@ font_description_table_new (const char *font_directory, /* Assign the alias file if found */ if (directory_contains_file (font_directory, FONTS_ALIAS_FILE_NAME)) { - table->fonts_alias_file = nautilus_make_path (font_directory, FONTS_ALIAS_FILE_NAME); + table->fonts_alias_file = g_strdup_printf ("%s/%s", font_directory, FONTS_ALIAS_FILE_NAME); } /* Assign the alias scale if found */ if (directory_contains_file (font_directory, FONTS_SCALE_FILE_NAME)) { - table->fonts_scale_file = nautilus_make_path (font_directory, FONTS_SCALE_FILE_NAME); + table->fonts_scale_file = g_strdup_printf ("%s/%s", font_directory, FONTS_SCALE_FILE_NAME); } g_free (description_contents); @@ -925,7 +928,7 @@ directory_contains_file (const char *directory, g_return_val_if_fail (string_is_valid (directory), FALSE); g_return_val_if_fail (string_is_valid (file_name), FALSE); - path = nautilus_make_path (directory, file_name); + path = g_strdup_printf ("%s/%s", directory, file_name); result = g_file_exists (path); g_free (path); @@ -1088,23 +1091,27 @@ free_font_tables (void) static void ensure_local_font_table (void) { - char *user_directory; char *user_font_dir; if (global_font_table != NULL) { return; } - /* Populate the default font table if needed */ - font_manager_collect_font_tables (DEFAULT_FONT_DIRECTORY, &global_font_table); + /* Populate the default font table if needed. Use the installed fonts + * if available. Otherwise use the ones in the source tree itself, so that + * checks will work even if Nautilus has not undergone 'make install.' + */ + if (g_file_exists (DEFAULT_FONT_DIRECTORY "/" DEFAULT_FONT)) { + font_manager_collect_font_tables (DEFAULT_FONT_DIRECTORY, &global_font_table); + } else { + font_manager_collect_font_tables (SOURCE_FONT_DIRECTORY, &global_font_table); + } /* Populate the user font table if needed */ - user_directory = nautilus_get_user_directory (); - user_font_dir = nautilus_make_path (user_directory, USER_FONT_DIRECTORY_NAME); + user_font_dir = g_strdup_printf ("%s/.nautilus/%s", g_get_home_dir (), USER_FONT_DIRECTORY_NAME); if (g_file_test (user_font_dir, G_FILE_TEST_ISDIR)) { font_manager_collect_font_tables (user_font_dir, &global_font_table); } - g_free (user_directory); g_free (user_font_dir); /* Populate the system font table if needed - using the font server's configuration */ @@ -1153,24 +1160,18 @@ nautilus_font_manager_for_each_font (NautilusFontManagerCallback callback, } } +/* Return the default font. It will be found either in place where nautilus + * gets installed (via 'make install') or the source directory if nautilus + * has not undergone 'make install' + */ char * nautilus_font_manager_get_default_font (void) { guint i; - /* FIXME bugzilla.eazel.com 7343: - * We want this to work in the case where nautilus has - * not undergone 'make install'. In order to do that - * we need to find out our fully qualified pwd - - * probably using a configure.on NAUTILUS_PWD=`pwd` - * hack of some kind. For now, commenting this out - * to make checks work in tinderbox again. - */ static const char *default_fonts[] = { - DEFAULT_FONT_DIRECTORY "/n019003l.pfb", - /* SOURCE_DATADIR "/fonts/urw/n019003l.pfb", */ - "/usr/share/fonts/default/Type1/n019003l.pfb", - "/usr/X11R6/lib/X11/fonts/Type1/lcdxsr.pfa" + DEFAULT_FONT_DIRECTORY "/" DEFAULT_FONT, + SOURCE_FONT_DIRECTORY "/" DEFAULT_FONT }; for (i = 0; i < NAUTILUS_N_ELEMENTS (default_fonts); i++) { @@ -1182,15 +1183,18 @@ nautilus_font_manager_get_default_font (void) return NULL; } +/* Return the default vold font. It will be found either in place where nautilus + * gets installed (via 'make install') or the source directory if nautilus + * has not undergone 'make install' + */ char * nautilus_font_manager_get_default_bold_font (void) { guint i; static const char *default_bold_fonts[] = { - DEFAULT_FONT_DIRECTORY "/n019004l.pfb", - "/usr/share/fonts/default/Type1/n019003l.pfb", - /* SOURCE_DATADIR "/fonts/urw/n019004l.pfb", */ + DEFAULT_FONT_DIRECTORY "/" DEFAULT_BOLD_FONT, + SOURCE_FONT_DIRECTORY "/" DEFAULT_BOLD_FONT }; for (i = 0; i < NAUTILUS_N_ELEMENTS (default_bold_fonts); i++) { @@ -1314,6 +1318,11 @@ nautilus_font_manager_weight_is_bold (const char *weight) #if !defined (NAUTILUS_OMIT_SELF_CHECK) +#define TEST_FONT1 SOURCE_FONT_DIRECTORY "/" "n019003l.pfb" +#define TEST_FONT2 SOURCE_FONT_DIRECTORY "/" "n019004l.pfb" +#define TEST_FONT3 SOURCE_FONT_DIRECTORY "/" "n019023l.pfb" +#define TEST_FONT4 SOURCE_FONT_DIRECTORY "/" "n019024l.pfb" + static char * call_chop_off_comments (const char *input) { @@ -1323,40 +1332,13 @@ call_chop_off_comments (const char *input) return test_copy; } -static char * -get_test_font_dir (void) -{ - char *test_font_dir; - char *uri; - char *base_uri; - char *relative_part; - char *current_dir; - - current_dir = g_get_current_dir (); - - base_uri = g_strdup_printf ("file://%s/", current_dir); - relative_part = g_strdup_printf ("%s/%s", SOURCE_DATADIR, "/fonts/urw"); - - uri = nautilus_uri_make_full_from_relative (base_uri, relative_part); - - test_font_dir = g_strdup (uri + strlen ("file://")); - - g_free (base_uri); - g_free (relative_part); - g_free (uri); - g_free (current_dir); - - return test_font_dir; -} - void nautilus_self_check_font_manager (void) { FontDescriptionTable *table; const FontDescription *description; GList *font_table_list = NULL; - char *test_font_dir; - char *font_name_table[4]; + char *original_current_dir; /* chop_off_comments() */ NAUTILUS_CHECK_STRING_RESULT (call_chop_off_comments ("foo bar"), "foo bar"); @@ -1367,34 +1349,29 @@ nautilus_self_check_font_manager (void) NAUTILUS_CHECK_STRING_RESULT (call_chop_off_comments ("\\#foo bar"), "\\#foo bar"); NAUTILUS_CHECK_STRING_RESULT (call_chop_off_comments ("\\##foo bar"), "\\#"); - test_font_dir = get_test_font_dir (); + original_current_dir = g_get_current_dir (); - g_return_if_fail (g_file_exists (test_font_dir)); + g_return_if_fail (g_file_exists (SOURCE_FONT_DIRECTORY)); - font_name_table[0] = g_strdup_printf ("%s/%s", test_font_dir, "n019003l.pfb"); - font_name_table[1] = g_strdup_printf ("%s/%s", test_font_dir, "n019004l.pfb"); - font_name_table[2] = g_strdup_printf ("%s/%s", test_font_dir, "n019023l.pfb"); - font_name_table[3] = g_strdup_printf ("%s/%s", test_font_dir, "n019024l.pfb"); + g_return_if_fail (g_file_exists (TEST_FONT1)); + g_return_if_fail (g_file_exists (TEST_FONT2)); + g_return_if_fail (g_file_exists (TEST_FONT3)); + g_return_if_fail (g_file_exists (TEST_FONT4)); - g_return_if_fail (g_file_exists (font_name_table[0])); - g_return_if_fail (g_file_exists (font_name_table[1])); - g_return_if_fail (g_file_exists (font_name_table[2])); - g_return_if_fail (g_file_exists (font_name_table[3])); - - font_manager_collect_font_tables (test_font_dir, &font_table_list); + font_manager_collect_font_tables (SOURCE_FONT_DIRECTORY, &font_table_list); g_return_if_fail (font_table_list != NULL); g_return_if_fail (g_list_nth_data (font_table_list, 0) != NULL); table = g_list_nth_data (font_table_list, 0); NAUTILUS_CHECK_INTEGER_RESULT (font_description_table_get_length (table), 4); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 0), font_name_table[0]); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 1), font_name_table[1]); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 2), font_name_table[2]); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 3), font_name_table[3]); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 0), TEST_FONT1); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 1), TEST_FONT2); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 2), TEST_FONT3); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 3), TEST_FONT4); description = font_description_table_peek_nth (table, 0); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[0]); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT1); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "medium"); @@ -1403,7 +1380,7 @@ nautilus_self_check_font_manager (void) NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); description = font_description_table_peek_nth (table, 1); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[1]); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT2); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "bold"); @@ -1412,7 +1389,7 @@ nautilus_self_check_font_manager (void) NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); description = font_description_table_peek_nth (table, 2); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[2]); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT3); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "medium"); @@ -1421,7 +1398,7 @@ nautilus_self_check_font_manager (void) NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); description = font_description_table_peek_nth (table, 3); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[3]); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT4); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "bold"); @@ -1429,12 +1406,6 @@ nautilus_self_check_font_manager (void) NAUTILUS_CHECK_STRING_RESULT (font_description_get_set_width (description), "normal"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); - g_free (font_name_table[0]); - g_free (font_name_table[1]); - g_free (font_name_table[2]); - g_free (font_name_table[3]); - g_free (test_font_dir); - font_table_list_free (font_table_list); } diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c index 431e92619..400f72ca8 100644 --- a/libnautilus-private/nautilus-global-preferences.c +++ b/libnautilus-private/nautilus-global-preferences.c @@ -39,6 +39,7 @@ #include "nautilus-stock-dialogs.h" #include "nautilus-view-identifier.h" #include "nautilus-sidebar-functions.h" +#include "nautilus-smooth-widget.h" #include <gconf/gconf.h> #include <gconf/gconf-client.h> #include <libgnome/gnome-i18n.h> @@ -1535,6 +1536,17 @@ nautilus_global_preferences_get_default_smooth_bold_font (void) return global_preferences_get_smooth_bold_font (default_smooth_font_auto_value); } +/* Let the smooth widget machinery know about smoothness changes */ +static void +smooth_graphics_mode_changed_callback (gpointer callback_data) +{ + gboolean is_smooth; + + is_smooth = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE); + + nautilus_smooth_widget_global_set_is_smooth (is_smooth); +} + void nautilus_global_preferences_initialize (void) { @@ -1554,4 +1566,13 @@ nautilus_global_preferences_initialize (void) &icon_view_smooth_font_auto_value); nautilus_preferences_add_auto_string (NAUTILUS_PREFERENCES_DEFAULT_SMOOTH_FONT, &default_smooth_font_auto_value); + + nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, + smooth_graphics_mode_changed_callback, + NULL); + + /* Keep track of smooth graphics mode changes in order to notify the smooth + * widget machinery. + */ + smooth_graphics_mode_changed_callback (NULL); } diff --git a/libnautilus-private/nautilus-scalable-font.c b/libnautilus-private/nautilus-scalable-font.c index 7b4739fd3..9cf671595 100644 --- a/libnautilus-private/nautilus-scalable-font.c +++ b/libnautilus-private/nautilus-scalable-font.c @@ -31,7 +31,6 @@ #include "nautilus-glyph.h" #include "nautilus-gtk-macros.h" #include "nautilus-lib-self-check-functions.h" -#include "nautilus-global-preferences.h" #include "nautilus-string.h" #include <librsvg/rsvg-ft.h> #include <libgnome/gnome-util.h> diff --git a/libnautilus-private/nautilus-smooth-widget.c b/libnautilus-private/nautilus-smooth-widget.c index 4b6229422..75ba2c20b 100644 --- a/libnautilus-private/nautilus-smooth-widget.c +++ b/libnautilus-private/nautilus-smooth-widget.c @@ -25,7 +25,6 @@ #include <config.h> #include "nautilus-smooth-widget.h" -#include "nautilus-global-preferences.h" #include "nautilus-gdk-extensions.h" #include "nautilus-art-gtk-extensions.h" @@ -78,13 +77,11 @@ static void smooth_widget_paint_tile_and_content_transparent (GtkWi NautilusSmoothCompositeCallback composite_callback, gpointer callback_data); -/* We maintain a global list of smooth widgets. We then monitor changes in - * the Nautilus "smooth_graphics" preference. When this preference changes, - * we iterate through the global list of smooth widgets and toggle their - * is_smooth attribute. +/* We maintain a global list of smooth widgets. The smoothness of all these + * widgets can then be changed with nautilus_smooth_widget_global_set_is_smooth(). * * We do this so that labels and images will repect the "smooth_graphics" - * preferences without any intervention from the users of these two widgets. + * automatically without any intervention from the users of these two widgets. */ static GList *smooth_widget_list = NULL; @@ -134,12 +131,6 @@ smooth_widget_set_is_smooth (GtkWidget *widget, gboolean is_smooth) gtk_signal_emit_by_name (GTK_OBJECT (widget), "set_is_smooth", is_smooth); } -static gboolean -preferences_get_is_smooth (void) -{ - return nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE); -} - static void smooth_widget_destroy (GtkWidget *widget, gpointer callback_data) { @@ -148,17 +139,17 @@ smooth_widget_destroy (GtkWidget *widget, gpointer callback_data) smooth_widget_list = g_list_remove (smooth_widget_list, widget); } -static void -smooth_graphics_mode_changed_callback (gpointer callback_data) +static gboolean global_is_smooth = TRUE; + +void +nautilus_smooth_widget_global_set_is_smooth (gboolean is_smooth) { - gboolean is_smooth; - GList *iterator; + GList *node; - is_smooth = preferences_get_is_smooth (); - - for (iterator = smooth_widget_list; iterator; iterator = iterator->next) { - smooth_widget_set_is_smooth (GTK_WIDGET (iterator->data), - is_smooth); + global_is_smooth = is_smooth; + + for (node = smooth_widget_list; node != NULL; node = node->next) { + smooth_widget_set_is_smooth (GTK_WIDGET (node->data), global_is_smooth); } } @@ -167,17 +158,15 @@ smooth_graphics_mode_changed_callback (gpointer callback_data) * @widget: A smooth widget. * * Register a smooth widget. For the life time of the widget, its - * 'is_smooth' attribute will be toggled to match the value of - * the Nautilus "smooth_graphics" boolean preference. + * 'is_smooth' attribute will be toggled when + * nautilus_smooth_widget_global_set_is_smooth() is called. */ void nautilus_smooth_widget_register (GtkWidget *widget) { - static gboolean preferences_callback_registered = FALSE; - g_return_if_fail (widget_is_smooth (widget)); - smooth_widget_set_is_smooth (widget, preferences_get_is_smooth ()); + smooth_widget_set_is_smooth (widget, global_is_smooth); if (smooth_widget_list == NULL) { g_atexit (smooth_widget_list_free); @@ -190,15 +179,6 @@ nautilus_smooth_widget_register (GtkWidget *widget) "destroy", GTK_SIGNAL_FUNC (smooth_widget_destroy), NULL); - - /* Add a preference callback. This happens only once */ - if (preferences_callback_registered == FALSE) { - preferences_callback_registered = TRUE; - - nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, - smooth_graphics_mode_changed_callback, - NULL); - } } /* Return the origin point for the widget given vertical diff --git a/libnautilus-private/nautilus-smooth-widget.h b/libnautilus-private/nautilus-smooth-widget.h index 7661a586f..d92fc0515 100644 --- a/libnautilus-private/nautilus-smooth-widget.h +++ b/libnautilus-private/nautilus-smooth-widget.h @@ -112,6 +112,8 @@ NautilusDimensions nautilus_smooth_widget_get_preferred_dimensions (const GtkWid int tile_height); void nautilus_smooth_widget_register_type (GtkType type); +void nautilus_smooth_widget_global_set_is_smooth (gboolean is_smooth); + END_GNOME_DECLS #endif /* NAUTILUS_SMOOTH_WIDGET_H */ diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c index 9ebf51859..9bfb038a7 100644 --- a/src/nautilus-location-bar.c +++ b/src/nautilus-location-bar.c @@ -640,7 +640,8 @@ nautilus_location_bar_initialize (NautilusLocationBar *bar) GNOME_PAD_SMALL); entry = nautilus_entry_new (); - NAUTILUS_ENTRY (entry)->special_tab_handling = TRUE; + + nautilus_entry_set_special_tab_handling (NAUTILUS_ENTRY (entry), TRUE); gtk_signal_connect_object (GTK_OBJECT (entry), "activate", nautilus_navigation_bar_location_changed, GTK_OBJECT (bar)); |