Commit 1a3bf03d authored by Ramiro Estrugo's avatar Ramiro Estrugo
Browse files

libnautilus-extensions/nautilus-icon-container.c, New function to set the

* libnautilus-extensions/nautilus-icon-container.c,
* libnautilus-extensions/nautilus-icon-container.h:
(nautilus_icon_container_set_label_font_for_zoom_level):
New function to set the font for a zoom level.

(nautilus_icon_container_initialize),
Initialize to fonts to a well known font.  Dont look at font
preferences here.  Fonts should be suppied by the icon container
user.

* src/file-manager/fm-icon-view.c:
(fm_icon_view_update_icon_container_fonts),
New function to update the icon container's zoom level specific
fonts.

(directory_view_font_familiy_changed_callback),
(fm_icon_view_initialize),
(fm_icon_view_destroy),
Keep track of font familiy preference changes and update the icon
container fonts as needed.

(create_icon_container):
Update the fonts for the first time when the icon container is
created.
parent fb853124
2000-07-05 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus-extensions/nautilus-icon-container.c,
* libnautilus-extensions/nautilus-icon-container.h:
(nautilus_icon_container_set_label_font_for_zoom_level):
New function to set the font for a zoom level.
(nautilus_icon_container_initialize),
Initialize to fonts to a well known font. Dont look at font
preferences here. Fonts should be suppied by the icon container
user.
* src/file-manager/fm-icon-view.c:
(fm_icon_view_update_icon_container_fonts),
New function to update the icon container's zoom level specific
fonts.
(directory_view_font_familiy_changed_callback),
(fm_icon_view_initialize),
(fm_icon_view_destroy),
Keep track of font familiy preference changes and update the icon
container fonts as needed.
(create_icon_container):
Update the fonts for the first time when the icon container is
created.
2000-07-05 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus-extensions/nautilus-string-picker.c:
......
......@@ -2406,17 +2406,14 @@ nautilus_icon_container_initialize (NautilusIconContainer *container)
details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
/* FIXME: Fonts should be supplied by the caller and not
* hard-wired calls from NautilusIconContainer to font factory.
*/
/* font table - this isn't exactly proportional, but it looks better than computed */
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLEST] = nautilus_font_factory_get_font_from_preferences (8);
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLER] = nautilus_font_factory_get_font_from_preferences (8);
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALL] = nautilus_font_factory_get_font_from_preferences (10);
details->label_font[NAUTILUS_ZOOM_LEVEL_STANDARD] = nautilus_font_factory_get_font_from_preferences (12);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGE] = nautilus_font_factory_get_font_from_preferences (14);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGER] = nautilus_font_factory_get_font_from_preferences (18);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGEST] = nautilus_font_factory_get_font_from_preferences (18);
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLEST] = nautilus_font_factory_get_font_by_family ("helvetica", 8);
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLER] = nautilus_font_factory_get_font_by_family ("helvetica", 8);
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALL] = nautilus_font_factory_get_font_by_family ("helvetica", 10);
details->label_font[NAUTILUS_ZOOM_LEVEL_STANDARD] = nautilus_font_factory_get_font_by_family ("helvetica", 12);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGE] = nautilus_font_factory_get_font_by_family ("helvetica", 14);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGER] = nautilus_font_factory_get_font_by_family ("helvetica", 18);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGEST] = nautilus_font_factory_get_font_by_family ("helvetica", 18);
container->details = details;
......@@ -3708,6 +3705,26 @@ nautilus_icon_container_has_stored_icon_positions (NautilusIconContainer *contai
return FALSE;
}
void
nautilus_icon_container_set_label_font_for_zoom_level (NautilusIconContainer *container,
int zoom_level,
GdkFont *font)
{
g_return_if_fail (container != NULL);
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
g_return_if_fail (font != NULL);
g_return_if_fail (zoom_level >= NAUTILUS_ZOOM_LEVEL_SMALLEST);
g_return_if_fail (zoom_level <= NAUTILUS_ZOOM_LEVEL_LARGEST);
if (container->details->label_font[zoom_level] != NULL) {
gdk_font_unref (container->details->label_font[zoom_level]);
}
gdk_font_ref (font);
container->details->label_font[zoom_level] = font;
}
#if ! defined (NAUTILUS_OMIT_SELF_CHECK)
static char *
......
......@@ -126,6 +126,7 @@ struct NautilusIconContainerClass {
guint nautilus_icon_container_get_type (void);
GtkWidget *nautilus_icon_container_new (void);
/* adding, removing, and managing icons */
void nautilus_icon_container_clear (NautilusIconContainer *view);
gboolean nautilus_icon_container_add (NautilusIconContainer *view,
......@@ -136,6 +137,7 @@ void nautilus_icon_container_request_update (NautilusIconCon
NautilusIconData *data);
void nautilus_icon_container_request_update_all (NautilusIconContainer *container);
/* control the layout */
gboolean nautilus_icon_container_is_auto_layout (NautilusIconContainer *container);
void nautilus_icon_container_set_auto_layout (NautilusIconContainer *container,
......@@ -143,10 +145,12 @@ void nautilus_icon_container_set_auto_layout (NautilusIconCon
void nautilus_icon_container_sort (NautilusIconContainer *container);
void nautilus_icon_container_freeze_icon_positions (NautilusIconContainer *container);
/* operations on all icons */
void nautilus_icon_container_unselect_all (NautilusIconContainer *view);
void nautilus_icon_container_select_all (NautilusIconContainer *view);
/* operations on the selection */
GList *nautilus_icon_container_get_selection (NautilusIconContainer *view);
void nautilus_icon_container_set_selection (NautilusIconContainer *view,
......@@ -158,6 +162,7 @@ void nautilus_icon_container_unstretch (NautilusIconCon
void nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *container);
gboolean nautilus_icon_container_is_renaming (NautilusIconContainer *container);
/* options */
int nautilus_icon_container_get_zoom_level (NautilusIconContainer *view);
void nautilus_icon_container_set_zoom_level (NautilusIconContainer *view,
......@@ -168,5 +173,8 @@ void nautilus_icon_container_enable_linger_selection (NautilusIconCon
gboolean enable);
void nautilus_icon_container_set_anti_aliased_mode (NautilusIconContainer *view,
gboolean anti_aliased_mode);
void nautilus_icon_container_set_label_font_for_zoom_level (NautilusIconContainer *container,
int zoom_level,
GdkFont *font);
#endif
......@@ -2406,17 +2406,14 @@ nautilus_icon_container_initialize (NautilusIconContainer *container)
details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
/* FIXME: Fonts should be supplied by the caller and not
* hard-wired calls from NautilusIconContainer to font factory.
*/
/* font table - this isn't exactly proportional, but it looks better than computed */
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLEST] = nautilus_font_factory_get_font_from_preferences (8);
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLER] = nautilus_font_factory_get_font_from_preferences (8);
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALL] = nautilus_font_factory_get_font_from_preferences (10);
details->label_font[NAUTILUS_ZOOM_LEVEL_STANDARD] = nautilus_font_factory_get_font_from_preferences (12);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGE] = nautilus_font_factory_get_font_from_preferences (14);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGER] = nautilus_font_factory_get_font_from_preferences (18);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGEST] = nautilus_font_factory_get_font_from_preferences (18);
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLEST] = nautilus_font_factory_get_font_by_family ("helvetica", 8);
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLER] = nautilus_font_factory_get_font_by_family ("helvetica", 8);
details->label_font[NAUTILUS_ZOOM_LEVEL_SMALL] = nautilus_font_factory_get_font_by_family ("helvetica", 10);
details->label_font[NAUTILUS_ZOOM_LEVEL_STANDARD] = nautilus_font_factory_get_font_by_family ("helvetica", 12);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGE] = nautilus_font_factory_get_font_by_family ("helvetica", 14);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGER] = nautilus_font_factory_get_font_by_family ("helvetica", 18);
details->label_font[NAUTILUS_ZOOM_LEVEL_LARGEST] = nautilus_font_factory_get_font_by_family ("helvetica", 18);
container->details = details;
......@@ -3708,6 +3705,26 @@ nautilus_icon_container_has_stored_icon_positions (NautilusIconContainer *contai
return FALSE;
}
void
nautilus_icon_container_set_label_font_for_zoom_level (NautilusIconContainer *container,
int zoom_level,
GdkFont *font)
{
g_return_if_fail (container != NULL);
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
g_return_if_fail (font != NULL);
g_return_if_fail (zoom_level >= NAUTILUS_ZOOM_LEVEL_SMALLEST);
g_return_if_fail (zoom_level <= NAUTILUS_ZOOM_LEVEL_LARGEST);
if (container->details->label_font[zoom_level] != NULL) {
gdk_font_unref (container->details->label_font[zoom_level]);
}
gdk_font_ref (font);
container->details->label_font[zoom_level] = font;
}
#if ! defined (NAUTILUS_OMIT_SELF_CHECK)
static char *
......
......@@ -126,6 +126,7 @@ struct NautilusIconContainerClass {
guint nautilus_icon_container_get_type (void);
GtkWidget *nautilus_icon_container_new (void);
/* adding, removing, and managing icons */
void nautilus_icon_container_clear (NautilusIconContainer *view);
gboolean nautilus_icon_container_add (NautilusIconContainer *view,
......@@ -136,6 +137,7 @@ void nautilus_icon_container_request_update (NautilusIconCon
NautilusIconData *data);
void nautilus_icon_container_request_update_all (NautilusIconContainer *container);
/* control the layout */
gboolean nautilus_icon_container_is_auto_layout (NautilusIconContainer *container);
void nautilus_icon_container_set_auto_layout (NautilusIconContainer *container,
......@@ -143,10 +145,12 @@ void nautilus_icon_container_set_auto_layout (NautilusIconCon
void nautilus_icon_container_sort (NautilusIconContainer *container);
void nautilus_icon_container_freeze_icon_positions (NautilusIconContainer *container);
/* operations on all icons */
void nautilus_icon_container_unselect_all (NautilusIconContainer *view);
void nautilus_icon_container_select_all (NautilusIconContainer *view);
/* operations on the selection */
GList *nautilus_icon_container_get_selection (NautilusIconContainer *view);
void nautilus_icon_container_set_selection (NautilusIconContainer *view,
......@@ -158,6 +162,7 @@ void nautilus_icon_container_unstretch (NautilusIconCon
void nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *container);
gboolean nautilus_icon_container_is_renaming (NautilusIconContainer *container);
/* options */
int nautilus_icon_container_get_zoom_level (NautilusIconContainer *view);
void nautilus_icon_container_set_zoom_level (NautilusIconContainer *view,
......@@ -168,5 +173,8 @@ void nautilus_icon_container_enable_linger_selection (NautilusIconCon
gboolean enable);
void nautilus_icon_container_set_anti_aliased_mode (NautilusIconContainer *view,
gboolean anti_aliased_mode);
void nautilus_icon_container_set_label_font_for_zoom_level (NautilusIconContainer *container,
int zoom_level,
GdkFont *font);
#endif
......@@ -48,17 +48,18 @@
#include <libgnomevfs/gnome-vfs-xfer.h>
#include <libgnomevfs/gnome-vfs-async-ops.h>
#include <libnautilus/nautilus-bonobo-ui.h>
#include <libnautilus-extensions/nautilus-metadata.h>
#include <libnautilus-extensions/nautilus-directory-background.h>
#include <libnautilus-extensions/nautilus-directory.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-container.h>
#include <libnautilus-extensions/nautilus-icon-factory.h>
#include <libnautilus-extensions/nautilus-link.h>
#include <libnautilus-extensions/nautilus-metadata.h>
#include <libnautilus-extensions/nautilus-string.h>
#include <libnautilus-extensions/nautilus-directory.h>
#include <libnautilus-extensions/nautilus-directory-background.h>
#include <libnautilus-extensions/nautilus-global-preferences.h>
#include <libnautilus-extensions/nautilus-icon-factory.h>
#include <libnautilus-extensions/nautilus-icon-container.h>
/* Paths to use when creating & referring to Bonobo menu items */
#define MENU_PATH_STRETCH_ICON "/Settings/Stretch"
......@@ -81,7 +82,9 @@ static void fm_icon_view_initialize_class (FMIconViewC
static void fm_icon_view_set_zoom_level (FMIconView *view,
NautilusZoomLevel new_level,
gboolean always_set_level);
static void fm_icon_view_update_icon_container_fonts (FMIconView *icon_view);
static void text_attribute_names_changed_callback (gpointer user_data);
static void directory_view_font_familiy_changed_callback (gpointer user_data);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (FMIconView, fm_icon_view, FM_TYPE_DIRECTORY_VIEW);
......@@ -166,6 +169,10 @@ fm_icon_view_destroy (GtkObject *object)
text_attribute_names_changed_callback,
icon_view);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
directory_view_font_familiy_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);
}
......@@ -1505,6 +1512,15 @@ text_attribute_names_changed_callback (gpointer user_data)
(get_icon_container (FM_ICON_VIEW (user_data)));
}
static void
directory_view_font_familiy_changed_callback (gpointer user_data)
{
g_assert (user_data != NULL);
g_assert (FM_IS_ICON_VIEW (user_data));
fm_icon_view_update_icon_container_fonts (FM_ICON_VIEW (user_data));
}
/* GtkObject methods. */
static void
......@@ -1549,11 +1565,15 @@ fm_icon_view_initialize (FMIconView *icon_view)
icon_view->details->default_zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
icon_view->details->sort = &sort_criteria[0];
nautilus_preferences_add_callback
(NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES,
text_attribute_names_changed_callback, icon_view);
create_icon_container (icon_view);
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES,
text_attribute_names_changed_callback,
icon_view);
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
directory_view_font_familiy_changed_callback,
icon_view);
}
static gboolean
......@@ -1585,6 +1605,30 @@ icon_view_move_copy_items (NautilusIconContainer *container,
copy_action, x, y, view);
}
static void
fm_icon_view_update_icon_container_fonts (FMIconView *icon_view)
{
/* font size table - this isn't exactly proportional, but it looks better than computed */
static guint font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST + 1] = {
8, 8, 10, 12, 14, 18, 18 };
NautilusIconContainer *icon_container;
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);
nautilus_icon_container_set_label_font_for_zoom_level (icon_container, i, font);
gdk_font_unref (font);
}
nautilus_icon_container_request_update_all (icon_container);
}
static void
create_icon_container (FMIconView *icon_view)
{
......@@ -1664,5 +1708,7 @@ create_icon_container (FMIconView *icon_view)
gtk_container_add (GTK_CONTAINER (icon_view),
GTK_WIDGET (icon_container));
fm_icon_view_update_icon_container_fonts (icon_view);
gtk_widget_show (GTK_WIDGET (icon_container));
}
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