Commit a5eedddc authored by Ramiro Estrugo's avatar Ramiro Estrugo Committed by Ramiro Estrugo

reviewed by: <delete if not using a buddy>

2001-03-02  Ramiro Estrugo  <ramiro@eazel.com>

	    reviewed by: <delete if not using a buddy>

	    Bug 2673 - Need to hook up the new font picker to nautilus .

	    * configure.in:
	    Remove an old font setup hack that never really worked.

	    * data/fonts/urw/fonts.dir:
	    Rename the fonts to "Helvetica Default" in order not to clash with
	    system fonts.

	    * libnautilus-extensions/nautilus-font-manager.h:
	    * libnautilus-extensions/nautilus-font-manager.c:
	    (font_description_new): Add a font type parameter.
	    (font_lists_total_num_fonts): New function to count the total
	    number of scalable fonts detetected.
	    (font_description_table_add): Pass in the detected font lists to
	    do reality checks.
	    (font_get_font_type): New function.
	    (font_description_table_get_length),
	    (font_description_table_peek_nth),
	    (font_description_table_get_nth_file_name): Name the parameters
	    more consistently.
	    (font_description_table_for_each): Add font type parameter
	    (font_description_table_new): Rework to not require storing the
	    detected font list.  We now use that only for the duration of the
	    constructor.  Lost the install_font_lists dumbness.
	    (font_server_for_each_font_directory_internal): Use g_warning
	    instead of g_print.
	    (font_ignore_directory): New function to determine whether we
	    should ignore a directory - makes things much faster.
	    (font_manager_collect_font_tables): New function to handle all the
	    work of collecting font directories into tables.
	    (font_server_for_each_callback), (font_table_list_free),
	    (font_table_list_for_each), (free_font_tables),
	    (ensure_at_exit_handler), (ensure_fallback_font_table),
	    (ensure_user_font_table), (ensure_system_font_tables): Add 3
	    tables for fallback, system and users fonts.  These are populated
	    as needed.
	    (nautilus_font_manager_for_each_font): Iterate the 3 font talbles.
	    (nautilus_font_manager_get_fallback_font) : New function to obtain
	    a fallback font quickly without having to check the system.
	    (call_chop_off_comments), (nautilus_self_check_font_manager):
	    Rework the checks to not create a temp directory.  Unfortunately
	    they now only run for me.

	    * libnautilus-extensions/nautilus-font-picker.h:
	    * libnautilus-extensions/nautilus-font-picker.c:
	    (nautilus_font_picker_initialize_class),
	    (nautilus_font_picker_initialize), (nautilus_font_picker_destroy),
	    (font_entry_list_find), (font_picker_update),
	    (font_name_picker_changed_callback),
	    (style_picker_changed_callback), (ignore_font),
	    (font_manager_callback), (style_list_for_each_callback),
	    (font_entry_list_for_each_callback),
	    (nautilus_font_picker_get_selected_font),
	    (nautilus_font_picker_set_selected_font),
	    (nautilus_font_picker_set_title_label):
	    Use the new font manager.

	    * libnautilus-extensions/nautilus-global-preferences.h:
	    * libnautilus-extensions/nautilus-global-preferences.c:
	    (global_preferences_install_descriptions),
	    (global_preferences_install_defaults),
	    (global_preferences_create_dialog), (appearnace_pane_update),
	    (global_preferences_create_font_group),
	    (global_preferences_install_home_location_defaults),
	    (global_preferences_install_font_defaults):
	    Add a new preference for the smooth font.
	    Factor our the default font code to its own function.  Setup the
	    font pickers items to be mutually exclusive according to the
	    smooth graphics mode preference value.

	    * libnautilus-extensions/nautilus-gtk-extensions.h:
	    * libnautilus-extensions/nautilus-gtk-extensions.c:
	    (nautilus_gtk_widget_set_shown):
	    New function to show or hide a widget in one go.

	    * libnautilus-extensions/nautilus-preferences-group.c:
	    (nautilus_preferences_group_update):
	    Dont show the widget if a controlling preference prevents it.

	    * libnautilus-extensions/nautilus-preferences-item.h:
	    * libnautilus-extensions/nautilus-preferences-item.c:
	    (preferences_item_update_smooth_font),
	    (preferences_smooth_font_changed_callback),
	    (preferences_item_create_smooth_font): Add support for a smooth
	    font picker.
	    (preferences_item_destroy), (preferences_item_construct),
	    (nautilus_preferences_item_set_control_preference),
	    (nautilus_preferences_item_set_control_action),
	    (nautilus_preferences_item_get_control_showing): Add support for
	    using a controlling preference which can force the widget to be
	    shown or hidden depending on its value.

	    * libnautilus-extensions/nautilus-preferences-pane.c:
	    (nautilus_preferences_pane_update):
	    Use new gtk extension to show or hide the widget in one go.

	    * libnautilus-extensions/nautilus-scalable-font.h:
	    * libnautilus-extensions/nautilus-scalable-font.c:
	    (font_family_string_map_new): Update fallback font name.
	    (nautilus_scalable_font_new_from_file_name): New function to
	    create a font directly from a font file name.
	    (nautilus_scalable_font_get_default_font): Update fallback font name.
	    (nautilus_scalable_font_get_default_bold_font): New function to
	    get a fallback bold font.
	    Remove some unsed functions.  Remove the font setup hack, the font
	    manager takes care of that now.

	    * libnautilus-extensions/nautilus-string-picker.h:
	    * libnautilus-extensions/nautilus-string-picker.c:
	    (nautilus_string_picker_clear):
	    New function to clear the string picker.

	    * libnautilus-extensions/nautilus-tabs.c:
	    (nautilus_tabs_initialize):
	    Fix the hard coded font name.

	    * src/nautilus-first-time-druid.c: (new_title_label):
	    Fix the hard coded font name.

	    * src/nautilus-sidebar-tabs.c:
	    (nautilus_sidebar_tabs_load_theme_data):
	    Fix the hard coded font name.

	    * test/Makefile.am:
	    * test/test-nautilus-font-manager.c: (font_type_to_string),
	    (font_iterator_callback), (font_table_for_each_callback), (main):
	    * test/test-nautilus-font-picker.c: (font_picker_changed_callback),
	    (main):
	    * test/test-nautilus-glyph-simple.c: (main):
	    * test/test-nautilus-label.c: (main):
	    Update for new font picker and font manager changes.
parent 8eb6d416
2001-03-02 Ramiro Estrugo <ramiro@eazel.com>
reviewed by: <delete if not using a buddy>
Bug 2673 - Need to hook up the new font picker to nautilus .
* configure.in:
Remove an old font setup hack that never really worked.
* data/fonts/urw/fonts.dir:
Rename the fonts to "Helvetica Default" in order not to clash with
system fonts.
* libnautilus-extensions/nautilus-font-manager.h:
* libnautilus-extensions/nautilus-font-manager.c:
(font_description_new): Add a font type parameter.
(font_lists_total_num_fonts): New function to count the total
number of scalable fonts detetected.
(font_description_table_add): Pass in the detected font lists to
do reality checks.
(font_get_font_type): New function.
(font_description_table_get_length),
(font_description_table_peek_nth),
(font_description_table_get_nth_file_name): Name the parameters
more consistently.
(font_description_table_for_each): Add font type parameter
(font_description_table_new): Rework to not require storing the
detected font list. We now use that only for the duration of the
constructor. Lost the install_font_lists dumbness.
(font_server_for_each_font_directory_internal): Use g_warning
instead of g_print.
(font_ignore_directory): New function to determine whether we
should ignore a directory - makes things much faster.
(font_manager_collect_font_tables): New function to handle all the
work of collecting font directories into tables.
(font_server_for_each_callback), (font_table_list_free),
(font_table_list_for_each), (free_font_tables),
(ensure_at_exit_handler), (ensure_fallback_font_table),
(ensure_user_font_table), (ensure_system_font_tables): Add 3
tables for fallback, system and users fonts. These are populated
as needed.
(nautilus_font_manager_for_each_font): Iterate the 3 font talbles.
(nautilus_font_manager_get_fallback_font) : New function to obtain
a fallback font quickly without having to check the system.
(call_chop_off_comments), (nautilus_self_check_font_manager):
Rework the checks to not create a temp directory. Unfortunately
they now only run for me.
* libnautilus-extensions/nautilus-font-picker.h:
* libnautilus-extensions/nautilus-font-picker.c:
(nautilus_font_picker_initialize_class),
(nautilus_font_picker_initialize), (nautilus_font_picker_destroy),
(font_entry_list_find), (font_picker_update),
(font_name_picker_changed_callback),
(style_picker_changed_callback), (ignore_font),
(font_manager_callback), (style_list_for_each_callback),
(font_entry_list_for_each_callback),
(nautilus_font_picker_get_selected_font),
(nautilus_font_picker_set_selected_font),
(nautilus_font_picker_set_title_label):
Use the new font manager.
* libnautilus-extensions/nautilus-global-preferences.h:
* libnautilus-extensions/nautilus-global-preferences.c:
(global_preferences_install_descriptions),
(global_preferences_install_defaults),
(global_preferences_create_dialog), (appearnace_pane_update),
(global_preferences_create_font_group),
(global_preferences_install_home_location_defaults),
(global_preferences_install_font_defaults):
Add a new preference for the smooth font.
Factor our the default font code to its own function. Setup the
font pickers items to be mutually exclusive according to the
smooth graphics mode preference value.
* libnautilus-extensions/nautilus-gtk-extensions.h:
* libnautilus-extensions/nautilus-gtk-extensions.c:
(nautilus_gtk_widget_set_shown):
New function to show or hide a widget in one go.
* libnautilus-extensions/nautilus-preferences-group.c:
(nautilus_preferences_group_update):
Dont show the widget if a controlling preference prevents it.
* libnautilus-extensions/nautilus-preferences-item.h:
* libnautilus-extensions/nautilus-preferences-item.c:
(preferences_item_update_smooth_font),
(preferences_smooth_font_changed_callback),
(preferences_item_create_smooth_font): Add support for a smooth
font picker.
(preferences_item_destroy), (preferences_item_construct),
(nautilus_preferences_item_set_control_preference),
(nautilus_preferences_item_set_control_action),
(nautilus_preferences_item_get_control_showing): Add support for
using a controlling preference which can force the widget to be
shown or hidden depending on its value.
* libnautilus-extensions/nautilus-preferences-pane.c:
(nautilus_preferences_pane_update):
Use new gtk extension to show or hide the widget in one go.
* libnautilus-extensions/nautilus-scalable-font.h:
* libnautilus-extensions/nautilus-scalable-font.c:
(font_family_string_map_new): Update fallback font name.
(nautilus_scalable_font_new_from_file_name): New function to
create a font directly from a font file name.
(nautilus_scalable_font_get_default_font): Update fallback font name.
(nautilus_scalable_font_get_default_bold_font): New function to
get a fallback bold font.
Remove some unsed functions. Remove the font setup hack, the font
manager takes care of that now.
* libnautilus-extensions/nautilus-string-picker.h:
* libnautilus-extensions/nautilus-string-picker.c:
(nautilus_string_picker_clear):
New function to clear the string picker.
* libnautilus-extensions/nautilus-tabs.c:
(nautilus_tabs_initialize):
Fix the hard coded font name.
* src/nautilus-first-time-druid.c: (new_title_label):
Fix the hard coded font name.
* src/nautilus-sidebar-tabs.c:
(nautilus_sidebar_tabs_load_theme_data):
Fix the hard coded font name.
* test/Makefile.am:
* test/test-nautilus-font-manager.c: (font_type_to_string),
(font_iterator_callback), (font_table_for_each_callback), (main):
* test/test-nautilus-font-picker.c: (font_picker_changed_callback),
(main):
* test/test-nautilus-glyph-simple.c: (main):
* test/test-nautilus-label.c: (main):
Update for new font picker and font manager changes.
2001-03-02 Darin Adler <darin@eazel.com>
reviewed by: Arik Devens <arik@eazel.com>
......
......@@ -147,12 +147,6 @@ dnl ====================================
dnl = End profiling support
dnl ====================================
dnl Check for "RedHat-style" font setup
AM_CONDITIONAL(TYPE1_FONT_DIR_EXISTS, test -d /usr/share/fonts/default/Type1)
dnl ====================================
dnl = Check for different mount systems
dnl ====================================
......
4
n019003l.pfb -URW-Helvetica-medium-r-normal--0-0-0-0-p-0-iso8859-1
n019004l.pfb -URW-Helvetica-bold-r-normal--0-0-0-0-p-0-iso8859-1
n019023l.pfb -URW-Helvetica-medium-o-normal--0-0-0-0-p-0-iso8859-1
n019024l.pfb -URW-Helvetica-bold-o-normal--0-0-0-0-p-0-iso8859-1
n019003l.pfb -URW-Helvetica Default-medium-r-normal--0-0-0-0-p-0-iso8859-1
n019004l.pfb -URW-Helvetica Default-bold-r-normal--0-0-0-0-p-0-iso8859-1
n019023l.pfb -URW-Helvetica Default-medium-o-normal--0-0-0-0-p-0-iso8859-1
n019024l.pfb -URW-Helvetica Default-bold-o-normal--0-0-0-0-p-0-iso8859-1
......@@ -19,7 +19,8 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: Ramiro Estrugo <ramiro@eazel.com>
Authors: Pavel Cisler <pavel@eazel.com>,
Ramiro Estrugo <ramiro@eazel.com>
*/
#ifndef NAUTILUS_FONT_MANAGER_H
......@@ -30,20 +31,28 @@
BEGIN_GNOME_DECLS
typedef enum {
NAUTILUS_FONT_POSTSCRIPT = 1,
NAUTILUS_FONT_TRUE_TYPE
} NautilusFontType;
/*
* A callback which can be invoked for each font available in the system.
*/
typedef void (*NautilusFontManagerIterationCallback) (const char *foundry,
const char *family,
const char *weight,
const char *slant,
const char *set_width,
const char *char_set_registry,
const char *char_set_encoding,
gpointer callback_data);
void nautilus_font_manager_for_each_font (NautilusFontManagerIterationCallback callback,
gpointer callback_data);
typedef void (*NautilusFontManagerCallback) (const char *font_file_name,
NautilusFontType font_type,
const char *foundry,
const char *family,
const char *weight,
const char *slant,
const char *set_width,
const char *char_set_registry,
const char *char_set_encoding,
gpointer callback_data);
void nautilus_font_manager_for_each_font (NautilusFontManagerCallback callback,
gpointer callback_data);
char *nautilus_font_manager_get_fallback_font (void);
END_GNOME_DECLS
......
......@@ -25,7 +25,7 @@
#ifndef NAUTILUS_FONT_PICKER_H
#define NAUTILUS_FONT_PICKER_H
#include <gtk/gtkhbox.h>
#include <gtk/gtkvbox.h>
#include <libnautilus-extensions/nautilus-scalable-font.h>
BEGIN_GNOME_DECLS
......@@ -35,42 +35,31 @@ BEGIN_GNOME_DECLS
#define NAUTILUS_FONT_PICKER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_FONT_PICKER, NautilusFontPickerClass))
#define NAUTILUS_IS_FONT_PICKER(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_FONT_PICKER))
typedef struct _NautilusFontPicker NautilusFontPicker;
typedef struct _NautilusFontPickerClass NautilusFontPickerClass;
typedef struct _NautilusFontPickerDetail NautilusFontPickerDetail;
typedef struct NautilusFontPicker NautilusFontPicker;
typedef struct NautilusFontPickerClass NautilusFontPickerClass;
typedef struct NautilusFontPickerDetails NautilusFontPickerDetails;
struct _NautilusFontPicker
struct NautilusFontPicker
{
/* Super Class */
GtkHBox hbox;
GtkVBox vbox;
/* Private stuff */
NautilusFontPickerDetail *detail;
NautilusFontPickerDetails *details;
};
struct _NautilusFontPickerClass
struct NautilusFontPickerClass
{
GtkHBoxClass parent_class;
GtkVBoxClass parent_class;
};
GtkType nautilus_font_picker_get_type (void);
GtkWidget* nautilus_font_picker_new (void);
void nautilus_font_picker_set_show_weights (NautilusFontPicker *font_picker);
void nautilus_font_picker_set_show_slants (NautilusFontPicker *font_picker);
void nautilus_font_picker_set_show_set_widths (NautilusFontPicker *font_picker);
void nautilus_font_picker_set_selected_family (NautilusFontPicker *font_picker,
const char *family);
void nautilus_font_picker_set_selected_weight (NautilusFontPicker *font_picker,
const char *weight);
void nautilus_font_picker_set_selected_slant (NautilusFontPicker *font_picker,
const char *slant);
void nautilus_font_picker_set_selected_set_width (NautilusFontPicker *font_picker,
const char *set_width);
char * nautilus_font_picker_get_selected_family (const NautilusFontPicker *font_picker);
char * nautilus_font_picker_get_selected_weight (const NautilusFontPicker *font_picker);
char * nautilus_font_picker_get_selected_slant (const NautilusFontPicker *font_picker);
char * nautilus_font_picker_get_selected_set_width (const NautilusFontPicker *font_picker);
GtkType nautilus_font_picker_get_type (void);
GtkWidget* nautilus_font_picker_new (void);
char * nautilus_font_picker_get_selected_font (const NautilusFontPicker *font_picker);
void nautilus_font_picker_set_selected_font (NautilusFontPicker *font_picker,
const char *font);
void nautilus_font_picker_set_title_label (NautilusFontPicker *font_picker,
const char *title_label);
END_GNOME_DECLS
#endif /* NAUTILUS_FONT_PICKER_H */
......
......@@ -34,6 +34,7 @@
#include "nautilus-string.h"
#include "nautilus-medusa-support.h"
#include "nautilus-view-identifier.h"
#include "nautilus-font-manager.h"
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
#include <gtk/gtkbox.h>
......@@ -65,11 +66,13 @@ static void global_preferences_install_speed_tradeoff_descriptions (const
const char *description);
static void global_preferences_install_home_location_defaults (void);
static void global_preferences_install_medusa_defaults (void);
static void global_preferences_install_font_defaults (void);
static void global_preferences_install_descriptions (void);
static int compare_view_identifiers (gconstpointer a,
gconstpointer b);
static GtkWidget *global_preferences_create_dialog (void);
static GtkWidget *global_preferences_create_search_pane (NautilusPreferencesBox *preference_box);
static GtkWidget *global_preferences_create_font_group (NautilusPreferencesPane *appearance_pane);
static GtkWidget *global_prefs_dialog = NULL;
......@@ -153,6 +156,8 @@ global_preferences_install_descriptions (void)
nautilus_preferences_set_description (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
_("Use this font family to display file names:"));
nautilus_preferences_set_description (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_SMOOTH_FONT,
_("Use this font family to display file names:"));
nautilus_preferences_set_description (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR,
_("Display toolbar in new windows"));
......@@ -262,10 +267,6 @@ global_preferences_install_defaults (void)
NAUTILUS_USER_LEVEL_INTERMEDIATE,
NAUTILUS_SPEED_TRADEOFF_ALWAYS);
nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
NAUTILUS_USER_LEVEL_NOVICE,
_("helvetica"));
nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_CLICK_POLICY,
NAUTILUS_USER_LEVEL_NOVICE,
NAUTILUS_CLICK_POLICY_DOUBLE);
......@@ -374,6 +375,9 @@ global_preferences_install_defaults (void)
/* Home location */
global_preferences_install_home_location_defaults ();
/* Fonts */
global_preferences_install_font_defaults ();
/* Medusa */
global_preferences_install_medusa_defaults ();
}
......@@ -530,12 +534,11 @@ global_preferences_create_dialog (void)
0,
NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), _("Fonts"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
1,
NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY);
/*
* Fonts
*/
global_preferences_create_font_group (NAUTILUS_PREFERENCES_PANE (appearance_pane));
/*
......@@ -816,6 +819,56 @@ global_preferences_create_search_pane (NautilusPreferencesBox *preference_box)
return search_pane;
}
/*
* We have 2 font picker items, but we only show one depending on
* the value of the SMOOTH_GRAPHICS preference.
*/
static void
appearnace_pane_update (gpointer callback_data)
{
g_return_if_fail (NAUTILUS_IS_PREFERENCES_PANE (callback_data));
nautilus_preferences_pane_update (NAUTILUS_PREFERENCES_PANE (callback_data));
}
static GtkWidget *
global_preferences_create_font_group (NautilusPreferencesPane *appearance_pane)
{
GtkWidget *font_group;
GtkWidget *font_picker_smooth_item;
GtkWidget *font_picker_gdk_item;
font_group =
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), _("Fonts"));
font_picker_gdk_item =
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
1,
NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY);
nautilus_preferences_item_set_control_preference (NAUTILUS_PREFERENCES_ITEM (font_picker_gdk_item),
NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE);
nautilus_preferences_item_set_control_action (NAUTILUS_PREFERENCES_ITEM (font_picker_gdk_item),
NAUTILUS_PREFERENCE_ITEM_HIDE);
font_picker_smooth_item =
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
1,
NAUTILUS_PREFERENCES_DIRECTORY_VIEW_SMOOTH_FONT,
NAUTILUS_PREFERENCE_ITEM_SMOOTH_FONT);
nautilus_preferences_item_set_control_preference (NAUTILUS_PREFERENCES_ITEM (font_picker_gdk_item),
NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE);
nautilus_preferences_item_set_control_action (NAUTILUS_PREFERENCES_ITEM (font_picker_smooth_item),
NAUTILUS_PREFERENCE_ITEM_SHOW);
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE,
appearnace_pane_update,
appearance_pane);
return font_group;
}
/* Make a query to find out what sidebar panels are available. */
static GList *
global_preferences_get_sidebar_panel_view_identifiers (void)
......@@ -1050,6 +1103,24 @@ global_preferences_install_home_location_defaults (void)
g_free (default_intermediate_home_uri);
}
static void
global_preferences_install_font_defaults (void)
{
char *fallback_smooth_font;
nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
NAUTILUS_USER_LEVEL_NOVICE,
_("helvetica"));
/* The default smooth font */
fallback_smooth_font = nautilus_font_manager_get_fallback_font ();
nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_SMOOTH_FONT,
NAUTILUS_USER_LEVEL_NOVICE,
fallback_smooth_font);
g_free (fallback_smooth_font);
}
static void
global_preferences_use_fast_search_changed_callback (gpointer callback_data)
{
......
......@@ -91,6 +91,7 @@ BEGIN_GNOME_DECLS
/* Directory view */
#define NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY "directory-view/font_family"
#define NAUTILUS_PREFERENCES_DIRECTORY_VIEW_SMOOTH_FONT "directory-view/smooth_font"
/* File Indexing */
#define NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE "preferences/search_bar_type"
......
......@@ -1184,6 +1184,25 @@ nautilus_gtk_widget_set_font (GtkWidget *widget, GdkFont *font)
gtk_style_unref (new_style);
}
/**
* nautilus_gtk_widget_set_shown
*
* Show or hide a widget.
* @widget: The widget.
* @shown: Boolean value indicating whether the widget should be shown or hidden.
**/
void
nautilus_gtk_widget_set_shown (GtkWidget *widget, gboolean shown)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
if (shown) {
gtk_widget_show (widget);
} else {
gtk_widget_hide (widget);
}
}
/**
* nautilus_gtk_widget_set_font_by_name
*
......
......@@ -86,6 +86,8 @@ void nautilus_gtk_object_list_free (GList
GList * nautilus_gtk_object_list_copy (GList *list);
/* GtkWidget */
void nautilus_gtk_widget_set_shown (GtkWidget *widget,
gboolean shown);
gboolean nautilus_point_in_allocation (const GtkAllocation *allocation,
int x,
int y);
......
......@@ -24,6 +24,7 @@
#include <config.h>
#include "nautilus-preferences-group.h"
#include "nautilus-gtk-extensions.h"
#include <gnome.h>
#include <gtk/gtkradiobutton.h>
......@@ -232,22 +233,26 @@ nautilus_preferences_group_update (NautilusPreferencesGroup *group)
{
GList *iterator;
NautilusPreferencesItem *preferences_item;
gboolean shown;
char *name = NULL;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_GROUP (group));
for (iterator = group->details->items; iterator != NULL; iterator = iterator->next) {
char *name;
preferences_item = NAUTILUS_PREFERENCES_ITEM (iterator->data);
name = nautilus_preferences_item_get_name (preferences_item);
nautilus_preferences_item_update_displayed_value (preferences_item);
if (nautilus_preferences_is_visible (name)) {
gtk_widget_show (GTK_WIDGET (iterator->data));
shown = nautilus_preferences_item_get_control_showing (preferences_item);
} else {
gtk_widget_hide (GTK_WIDGET (iterator->data));
shown = FALSE;
}
nautilus_gtk_widget_set_shown (GTK_WIDGET (iterator->data), shown);
g_free (name);
}
}
......
......@@ -39,6 +39,7 @@
#include "nautilus-radio-button-group.h"
#include "nautilus-string-picker.h"
#include "nautilus-font-picker.h"
#include "nautilus-text-caption.h"
#include "nautilus-global-preferences.h"
......@@ -55,6 +56,8 @@ struct _NautilusPreferencesItemDetails
NautilusPreferencesItemType item_type;
GtkWidget *child;
guint change_signal_ID;
char *control_preference_name;
NautilusPreferencesItemControlAction control_action;
};
/* GtkObjectClass methods */
......@@ -78,6 +81,8 @@ static void preferences_item_create_integer (NautilusPreference
const char *preference_name);
static void preferences_item_create_font_family (NautilusPreferencesItem *item,
const char *preference_name);
static void preferences_item_create_smooth_font (NautilusPreferencesItem *item,
const char *preference_name);
static void preferences_item_update_text_settings_at_idle (NautilusPreferencesItem *preferences_item);
static void preferences_item_update_integer_settings_at_idle (NautilusPreferencesItem *preferences_item);
static void enum_radio_group_changed_callback (GtkWidget *button_group,
......@@ -128,6 +133,7 @@ preferences_item_destroy (GtkObject *object)
item = NAUTILUS_PREFERENCES_ITEM (object);
g_free (item->details->preference_name);
g_free (item->details->control_preference_name);
g_free (item->details);
/* Chain destroy */
......@@ -173,6 +179,10 @@ preferences_item_construct (NautilusPreferencesItem *item,
preferences_item_create_font_family (item, preference_name);
break;
case NAUTILUS_PREFERENCE_ITEM_SMOOTH_FONT:
preferences_item_create_smooth_font (item, preference_name);
break;
case NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING:
preferences_item_create_editable_string (item, preference_name);
break;
......@@ -450,7 +460,7 @@ preferences_item_update_font_family (const NautilusPreferencesItem *item)
static void
preferences_item_create_font_family (NautilusPreferencesItem *item,
const char *preference_name)
const char *preference_name)
{
char *description;
NautilusStringList *font_list;
......@@ -483,6 +493,64 @@ preferences_item_create_font_family (NautilusPreferencesItem *item,
(gpointer) item);
}
static void
preferences_item_update_smooth_font (const NautilusPreferencesItem *item)
{
char *current_value;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
g_return_if_fail (item->details->item_type == NAUTILUS_PREFERENCE_ITEM_SMOOTH_FONT);
current_value = nautilus_preferences_get (item->details->preference_name);
g_assert (current_value != NULL);
nautilus_font_picker_set_selected_font (NAUTILUS_FONT_PICKER (item->details->child),
current_value);
g_free (current_value);
}
static void
preferences_smooth_font_changed_callback (NautilusFontPicker *font_picker,
gpointer callback_data)
{
NautilusPreferencesItem *item;
char *new_value;
g_return_if_fail (NAUTILUS_IS_FONT_PICKER (font_picker));
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (callback_data));
item = NAUTILUS_PREFERENCES_ITEM (callback_data);
new_value = nautilus_font_picker_get_selected_font (NAUTILUS_FONT_PICKER (item->details->child));
g_assert (new_value != NULL);
nautilus_preferences_set (item->details->preference_name, new_value);
g_free (new_value);
}
static void
preferences_item_create_smooth_font (NautilusPreferencesItem *item,
const char *preference_name)
{
char *description = NULL;
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item));
g_return_if_fail (nautilus_strlen (preference_name) > 0);
description = nautilus_preferences_get_description (preference_name);
g_return_if_fail (description != NULL);
item->details->child = nautilus_font_picker_new ();
nautilus_font_picker_set_title_label (NAUTILUS_FONT_PICKER (item->details->child),
description);
g_free (description);
item->details->change_signal_ID = gtk_signal_connect (GTK_OBJECT (item->details->child),
"changed",
GTK_SIGNAL_FUNC (preferences_smooth_font_changed_callback),
item);
}
/* NautilusPreferencesItem public methods */
GtkWidget *
nautilus_preferences_item_new (const char *preference_name,
......@@ -629,6 +697,10 @@ nautilus_preferences_item_update_displayed_value (const NautilusPreferencesItem
preferences_item_update_font_family (item);
break;
case NAUTILUS_PREFERENCE_ITEM_SMOOTH_FONT:
preferences_item_update_smooth_font (item);
break;
case NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING:
preferences_item_update_editable_string (item);
break;
......@@ -701,3 +773,57 @@ preferences_item_update_integer_settings_at_idle (NautilusPreferencesItem *prefe
integer_idle_handler = TRUE;
}
}
void
nautilus_preferences_item_set_control_preference (NautilusPreferencesItem *preferences_item,
const char *control_preference_name)
{
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (preferences_item));
if (nautilus_str_is_equal (preferences_item->details->control_preference_name,
control_preference_name)) {
return;
}
g_free (preferences_item->details->control_preference_name);
preferences_item->details->control_preference_name = g_strdup (control_preference_name);
}
void
nautilus_preferences_item_set_control_action (NautilusPreferencesItem *preferences_item,
NautilusPreferencesItemControlAction control_action)
{
g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (preferences_item));
g_return_if_fail (control_action >= NAUTILUS_PREFERENCE_ITEM_SHOW);
g_return_if_fail (control_action <= NAUTILUS_PREFERENCE_ITEM_HIDE);
if (preferences_item->details->control_action == control_action) {
return;
}
preferences_item->details->control_action = control_action;
}
gboolean
nautilus_preferences_item_get_control_showing (const NautilusPreferencesItem *preferences_item)
{
gboolean value;
g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (preferences_item), FALSE);
if (preferences_item->details->control_preference_name == NULL) {
return TRUE;
}
value = nautilus_preferences_get_boolean (preferences_item->details->control_preference_name);
if (preferences_item->details->control_action == NAUTILUS_PREFERENCE_ITEM_SHOW) {
return value;
}
if (preferences_item->details->control_action == NAUTILUS_PREFERENCE_ITEM_HIDE) {
return !value;
}