Commit bb7871f8 authored by Pavel Cisler's avatar Pavel Cisler Committed by Pavel Cisler

Bug 1561: Font preferences have no effect on the list view.

2000-07-27  Pavel Cisler  <pavel@eazel.com>

	Bug 1561: Font preferences have no effect on the list view.

	* src/file-manager/fm-directory-view.c:
	(text_attribute_names_changed_callback),
	(directory_view_font_family_changed_callback),
	(click_policy_changed_callback),
	(anti_aliased_mode_changed_callback),
	(fm_directory_view_initialize), (fm_directory_view_destroy):
	* src/file-manager/fm-directory-view.h:
	* src/file-manager/fm-icon-view.c: (fm_icon_view_destroy),
	(fm_icon_view_text_attribute_names_changed),
	(fm_icon_view_font_family_changed),
	(fm_icon_view_click_policy_changed),
	(fm_icon_view_anti_aliased_mode_changed),
	(fm_icon_view_initialize_class), (fm_icon_view_initialize),
	(fm_icon_view_update_icon_container_fonts):

	Moved all the registering of preference change callbacks into
	FMDirectoryView.
	Added default signal handlers that get called for each preference
	item change.
	Converted original preference change callbacks into default signal
	handler overrides in FMDirectoryView.

	* src/file-manager/fm-list-view.c: (fm_list_view_initialize_class),
	(fm_list_view_initialize), (fm_list_view_destroy),
	(fm_list_view_setup_list), (fm_list_view_update_click_mode),
	(fm_list_view_font_family_changed):
	Removed extra preference change callback setup calls, they are now
	all done in FMDirectoryView for both the icon view and list view.
	Added a simple font family changed callback that sets the selected
	font.
	Called it during list view initialization to make sure the list view
	comes up with the right saved font.
parent 4da8c083
2000-07-27 Pavel Cisler <pavel@eazel.com>
Bug 1561: Font preferences have no effect on the list view.
* src/file-manager/fm-directory-view.c:
(text_attribute_names_changed_callback),
(directory_view_font_family_changed_callback),
(click_policy_changed_callback),
(anti_aliased_mode_changed_callback),
(fm_directory_view_initialize), (fm_directory_view_destroy):
* src/file-manager/fm-directory-view.h:
* src/file-manager/fm-icon-view.c: (fm_icon_view_destroy),
(fm_icon_view_text_attribute_names_changed),
(fm_icon_view_font_family_changed),
(fm_icon_view_click_policy_changed),
(fm_icon_view_anti_aliased_mode_changed),
(fm_icon_view_initialize_class), (fm_icon_view_initialize),
(fm_icon_view_update_icon_container_fonts):
Moved all the registering of preference change callbacks into
FMDirectoryView.
Added default signal handlers that get called for each preference
item change.
Converted original preference change callbacks into default signal
handler overrides in FMDirectoryView.
* src/file-manager/fm-list-view.c: (fm_list_view_initialize_class),
(fm_list_view_initialize), (fm_list_view_destroy),
(fm_list_view_setup_list), (fm_list_view_update_click_mode),
(fm_list_view_font_family_changed):
Removed extra preference change callback setup calls, they are now
all done in FMDirectoryView for both the icon view and list view.
Added a simple font family changed callback that sets the selected
font.
Called it during list view initialization to make sure the list view
comes up with the right saved font.
2000-07-27 Gene Z. Ragan <gzr@eazel.com>
* libnautilus-extensions/nautilus-link.c:
......
......@@ -695,6 +695,51 @@ bonobo_control_activate_callback (BonoboObject *control, gboolean state, gpointe
*/
}
/* Preferences changed callbacks */
static void
text_attribute_names_changed_callback (gpointer user_data)
{
g_assert (FM_IS_DIRECTORY_VIEW (user_data));
if ((FM_DIRECTORY_VIEW_CLASS (GTK_OBJECT (user_data)->klass)->text_attribute_names_changed) != NULL) {
(FM_DIRECTORY_VIEW_CLASS (GTK_OBJECT (user_data)->klass)->text_attribute_names_changed)
(FM_DIRECTORY_VIEW (user_data));
}
}
static void
directory_view_font_family_changed_callback (gpointer user_data)
{
g_assert (FM_IS_DIRECTORY_VIEW (user_data));
if ((FM_DIRECTORY_VIEW_CLASS (GTK_OBJECT (user_data)->klass)->font_family_changed) != NULL) {
(FM_DIRECTORY_VIEW_CLASS (GTK_OBJECT (user_data)->klass)->font_family_changed)
(FM_DIRECTORY_VIEW (user_data));
}
}
static void
click_policy_changed_callback (gpointer user_data)
{
g_assert (FM_IS_DIRECTORY_VIEW (user_data));
if ((FM_DIRECTORY_VIEW_CLASS (GTK_OBJECT (user_data)->klass)->click_policy_changed) != NULL) {
(FM_DIRECTORY_VIEW_CLASS (GTK_OBJECT (user_data)->klass)->click_policy_changed)
(FM_DIRECTORY_VIEW (user_data));
}
}
static void
anti_aliased_mode_changed_callback (gpointer user_data)
{
g_assert (FM_IS_DIRECTORY_VIEW (user_data));
if ((FM_DIRECTORY_VIEW_CLASS (GTK_OBJECT (user_data)->klass)->anti_aliased_mode_changed) != NULL) {
(FM_DIRECTORY_VIEW_CLASS (GTK_OBJECT (user_data)->klass)->anti_aliased_mode_changed)
(FM_DIRECTORY_VIEW (user_data));
}
}
static double fm_directory_view_preferred_zoom_levels[] = {
(double) NAUTILUS_ICON_SIZE_SMALLEST / NAUTILUS_ICON_SIZE_STANDARD,
(double) NAUTILUS_ICON_SIZE_SMALLER / NAUTILUS_ICON_SIZE_STANDARD,
......@@ -771,6 +816,27 @@ fm_directory_view_initialize (FMDirectoryView *directory_view)
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
show_hidden_files_changed_callback,
directory_view);
/* Keep track of changes in text attribute names */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES,
text_attribute_names_changed_callback,
directory_view);
/* Keep track of changes in the font family */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
directory_view_font_family_changed_callback,
directory_view);
/* Keep track of changes in clicking policy */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
directory_view);
/* Keep track of changes in graphics trade offs */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS,
anti_aliased_mode_changed_callback,
directory_view);
}
static void
......@@ -784,6 +850,22 @@ fm_directory_view_destroy (GtkObject *object)
show_hidden_files_changed_callback,
view);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES,
text_attribute_names_changed_callback,
view);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
directory_view_font_family_changed_callback,
view);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
view);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS,
anti_aliased_mode_changed_callback,
view);
if (view->details->model != NULL) {
disconnect_model_handlers (view);
nautilus_directory_unref (view->details->model);
......
......@@ -198,13 +198,21 @@ struct FMDirectoryViewClass {
* the directory view. If overridden, subclasses must all parent class's
* function.
*/
void (* get_required_metadata_keys)
(FMDirectoryView *view,
void (* get_required_metadata_keys) (FMDirectoryView *view,
GList **directory_metadata_keys,
GList **file_metadata_keys);
void (* start_renaming_item) (FMDirectoryView *view,
const char *uri);
/* Preference change callbacks, overriden by icon and list views.
* Icon and list views respond by synchronizing to the new preference
* values and forcing an update if appropriate.
*/
void (* text_attribute_names_changed)(FMDirectoryView *view);
void (* font_family_changed) (FMDirectoryView *view);
void (* click_policy_changed) (FMDirectoryView *view);
void (* anti_aliased_mode_changed) (FMDirectoryView *view);
};
/* GtkObject support */
......
......@@ -87,12 +87,6 @@ static void fm_icon_view_update_icon_container_fonts (FMIconView *icon
static void fm_icon_view_update_click_mode (FMIconView *icon_view);
static void fm_icon_view_update_anti_aliased_mode (FMIconView *icon_view);
/* Preferences changed callbacks */
static void text_attribute_names_changed_callback (gpointer user_data);
static void directory_view_font_family_changed_callback (gpointer user_data);
static void anti_aliased_mode_changed_callback (gpointer user_data);
static void click_policy_changed_callback (gpointer user_data);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (FMIconView, fm_icon_view, FM_TYPE_DIRECTORY_VIEW);
typedef struct {
......@@ -172,22 +166,6 @@ fm_icon_view_destroy (GtkObject *object)
icon_view = FM_ICON_VIEW (object);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES,
text_attribute_names_changed_callback,
icon_view);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
directory_view_font_family_changed_callback,
icon_view);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
icon_view);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS,
anti_aliased_mode_changed_callback,
icon_view);
if (icon_view->details->react_to_icon_change_idle_id != 0) {
gtk_idle_remove (icon_view->details->react_to_icon_change_idle_id);
}
......@@ -1588,39 +1566,35 @@ get_icon_text_callback (NautilusIconContainer *container,
/* Preferences changed callbacks */
static void
text_attribute_names_changed_callback (gpointer user_data)
fm_icon_view_text_attribute_names_changed (FMDirectoryView *directory_view)
{
g_assert (user_data != NULL);
g_assert (FM_IS_ICON_VIEW (user_data));
g_assert (FM_IS_ICON_VIEW (directory_view));
nautilus_icon_container_request_update_all (get_icon_container (FM_ICON_VIEW (user_data)));
nautilus_icon_container_request_update_all (get_icon_container (FM_ICON_VIEW (directory_view)));
}
static void
directory_view_font_family_changed_callback (gpointer user_data)
fm_icon_view_font_family_changed (FMDirectoryView *directory_view)
{
g_assert (user_data != NULL);
g_assert (FM_IS_ICON_VIEW (user_data));
g_assert (FM_IS_ICON_VIEW (directory_view));
fm_icon_view_update_icon_container_fonts (FM_ICON_VIEW (user_data));
fm_icon_view_update_icon_container_fonts (FM_ICON_VIEW (directory_view));
}
static void
click_policy_changed_callback (gpointer user_data)
fm_icon_view_click_policy_changed (FMDirectoryView *directory_view)
{
g_assert (user_data != NULL);
g_assert (FM_IS_ICON_VIEW (user_data));
g_assert (FM_IS_ICON_VIEW (directory_view));
fm_icon_view_update_click_mode (FM_ICON_VIEW (user_data));
fm_icon_view_update_click_mode (FM_ICON_VIEW (directory_view));
}
static void
anti_aliased_mode_changed_callback (gpointer user_data)
fm_icon_view_anti_aliased_mode_changed (FMDirectoryView *directory_view)
{
g_assert (user_data != NULL);
g_assert (FM_IS_ICON_VIEW (user_data));
g_assert (FM_IS_ICON_VIEW (directory_view));
fm_icon_view_update_anti_aliased_mode (FM_ICON_VIEW (user_data));
fm_icon_view_update_anti_aliased_mode (FM_ICON_VIEW (directory_view));
}
/* GtkObject methods. */
......@@ -1656,6 +1630,11 @@ fm_icon_view_initialize_class (FMIconViewClass *klass)
fm_directory_view_class->merge_menus = fm_icon_view_merge_menus;
fm_directory_view_class->update_menus = fm_icon_view_update_menus;
fm_directory_view_class->start_renaming_item = fm_icon_view_start_renaming_item;
fm_directory_view_class->text_attribute_names_changed = fm_icon_view_text_attribute_names_changed;
fm_directory_view_class->font_family_changed = fm_icon_view_font_family_changed;
fm_directory_view_class->click_policy_changed = fm_icon_view_click_policy_changed;
fm_directory_view_class->anti_aliased_mode_changed = fm_icon_view_anti_aliased_mode_changed;
klass->get_directory_sort_by = fm_icon_view_real_get_directory_sort_by;
klass->set_directory_sort_by = fm_icon_view_real_set_directory_sort_by;
......@@ -1675,26 +1654,6 @@ fm_icon_view_initialize (FMIconView *icon_view)
icon_view->details->sort = &sort_criteria[0];
create_icon_container (icon_view);
/* Keep track of changes in text attribute names */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES,
text_attribute_names_changed_callback,
icon_view);
/* Keep track of changes in the font family */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
directory_view_font_family_changed_callback,
icon_view);
/* Keep track of changes in clicking policy */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
icon_view);
/* Keep track of changes in graphics trade offs */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS,
anti_aliased_mode_changed_callback,
icon_view);
}
static gboolean
......@@ -1733,13 +1692,13 @@ fm_icon_view_update_icon_container_fonts (FMIconView *icon_view)
static guint font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST + 1] = {
8, 8, 10, 12, 14, 18, 18 };
NautilusIconContainer *icon_container;
GdkFont *font;
guint i;
icon_container = get_icon_container (icon_view);
g_assert (icon_container != NULL);
for (i = 0; i <= NAUTILUS_ZOOM_LEVEL_LARGEST; i++) {
GdkFont *font;
font = nautilus_font_factory_get_font_from_preferences (font_size_table[i]);
g_assert (font != NULL);
......
......@@ -34,8 +34,10 @@
#include <libgnomeui/gnome-uidefs.h>
#include <libnautilus-extensions/nautilus-directory-background.h>
#include <libnautilus-extensions/nautilus-drag.h>
#include <libnautilus-extensions/nautilus-font-factory.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-global-preferences.h>
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
#include <libnautilus-extensions/nautilus-icon-factory.h>
#include <libnautilus-extensions/nautilus-list.h>
......@@ -151,6 +153,7 @@ static void fm_list_view_destroy (GtkObject
static void fm_list_view_done_adding_files (FMDirectoryView *view);
static void fm_list_view_select_all (FMDirectoryView *view);
static void fm_list_view_font_family_changed (FMDirectoryView *view);
static void fm_list_view_set_selection (FMDirectoryView *view, GList *selection);
static void fm_list_view_set_zoom_level (FMListView *list_view,
NautilusZoomLevel new_level,
......@@ -159,7 +162,7 @@ static void fm_list_view_sort_items (FMListView
int column,
gboolean reversed);
static void fm_list_view_update_click_mode (FMListView *icon_view);
static void fm_list_view_update_click_mode (FMDirectoryView *view);
static void fm_list_view_create_list (FMListView *list_view);
......@@ -171,12 +174,12 @@ static NautilusList * get_list (FMListView
static int sort_criterion_from_column (int column);
static void update_icons (FMListView *list_view);
static void click_policy_changed_callback (gpointer user_data);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (FMListView, fm_list_view, FM_TYPE_DIRECTORY_VIEW);
/* GtkObject methods. */
static void
fm_list_view_initialize_class (gpointer klass)
{
......@@ -205,6 +208,8 @@ fm_list_view_initialize_class (gpointer klass)
fm_directory_view_class->get_selection = fm_list_view_get_selection;
fm_directory_view_class->select_all = fm_list_view_select_all;
fm_directory_view_class->set_selection = fm_list_view_set_selection;
fm_directory_view_class->click_policy_changed = fm_list_view_update_click_mode;
fm_directory_view_class->font_family_changed = fm_list_view_font_family_changed;
object_class->destroy = fm_list_view_destroy;
......@@ -246,22 +251,13 @@ fm_list_view_initialize (gpointer object, gpointer klass)
update_icons,
GTK_OBJECT (list_view));
/* Keep track of changes in clicking policy */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
list_view);
fm_list_view_font_family_changed (FM_DIRECTORY_VIEW (list_view));
}
static void
fm_list_view_destroy (GtkObject *object)
{
g_return_if_fail (FM_IS_LIST_VIEW (object));
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
object);
g_free (FM_LIST_VIEW (object)->details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
......@@ -858,7 +854,7 @@ fm_list_view_setup_list (FMListView *list_view)
fm_list_view_reset_row_height,
NULL);
fm_list_view_update_click_mode (list_view);
fm_list_view_update_click_mode (FM_DIRECTORY_VIEW (list_view));
gtk_widget_show (GTK_WIDGET (list));
}
......@@ -1515,25 +1511,29 @@ update_icons (FMListView *list_view)
}
static void
fm_list_view_update_click_mode (FMListView *list_view)
fm_list_view_update_click_mode (FMDirectoryView *view)
{
NautilusList *list;
int click_mode;
list = get_list (list_view);
g_assert (list != NULL);
g_assert (FM_IS_LIST_VIEW (view));
g_assert (get_list (FM_LIST_VIEW (view)) != NULL);
click_mode = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY,
NAUTILUS_CLICK_POLICY_SINGLE);
nautilus_list_set_single_click_mode (list, click_mode == NAUTILUS_CLICK_POLICY_SINGLE);
nautilus_list_set_single_click_mode (get_list (FM_LIST_VIEW (view)),
click_mode == NAUTILUS_CLICK_POLICY_SINGLE);
}
static void
click_policy_changed_callback (gpointer user_data)
fm_list_view_font_family_changed (FMDirectoryView *view)
{
g_assert (user_data != NULL);
g_assert (FM_IS_LIST_VIEW (user_data));
GdkFont *font;
fm_list_view_update_click_mode (FM_LIST_VIEW (user_data));
/* FIXME: need to use the right font size for a given zoom level here */
font = nautilus_font_factory_get_font_from_preferences (10);
g_assert (font != NULL);
nautilus_gtk_widget_set_font (GTK_WIDGET (get_list (FM_LIST_VIEW (view))), font);
gdk_font_unref (font);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment