summaryrefslogtreecommitdiff
path: root/libnautilus-private
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@gnu.org>2002-02-25 21:05:57 +0000
committerAnders Carlsson <andersca@src.gnome.org>2002-02-25 21:05:57 +0000
commit9f473be4794a0b28d572b8ee5251a3d460c93b11 (patch)
tree51e18360bcd15be52c8c8c3bdadddc03f7edca86 /libnautilus-private
parent21fb75e0e8196b36692eead4ddfa3194b7a84a39 (diff)
downloadnautilus-9f473be4794a0b28d572b8ee5251a3d460c93b11.tar.gz
Let "Loading" and "Empty" special nodes be italic.
2002-02-25 Anders Carlsson <andersca@gnu.org> * components/tree/nautilus-tree-model.c: (nautilus_tree_model_get_column_type), (nautilus_tree_model_get_value): * components/tree/nautilus-tree-model.h: * components/tree/nautilus-tree-view.c: (create_tree): Let "Loading" and "Empty" special nodes be italic. * libnautilus-private/nautilus-global-preferences.c: (default_font_callback): Return "sans" here instead of "fixed" * libnautilus-private/nautilus-icon-canvas-item.c: (draw_or_measure_label_text), (create_label_layout), Set font from icon container name, use gdk_gc_set_rgb_fg_color. * libnautilus-private/nautilus-icon-container.c: (finalize): (realize), (nautilus_icon_container_init), (nautilus_icon_container_update_icon), (nautilus_icon_container_set_zoom_level), (nautilus_icon_container_request_update_all), (nautilus_icon_container_get_label_color), (update_label_color), (nautilus_icon_container_theme_changed), (nautilus_icon_container_set_font_name), (nautilus_icon_container_set_font_size_table): Add support for setting fonts, and fix some bugs with the label color handling. * libnautilus-private/nautilus-icon-container.h: Add nautilus_icon_container_set_font_name and nautilus_icon_container_set_font_size_table. * libnautilus-private/nautilus-icon-factory.c: (embedded_text_font_changed_callback), (embed_text): Set the font of the embedded text to the default font. * libnautilus-private/nautilus-icon-private.h: Add font name and font size table variables to NautilusIconContainerDetails. * libnautilus-private/nautilus-program-chooser.c: (nautilus_program_chooser_init): Fix button ordering according to the HIG. * src/file-manager/fm-icon-view.c: (fm_icon_view_update_icon_container_fonts), (fm_icon_view_update_icon_container_font_size_table): Set font name and font size table in the icon container. * src/nautilus-sidebar-tabs.c: (nautilus_sidebar_tabs_load_theme_data), (default_font_changed_callback), (nautilus_sidebar_tabs_init), (nautilus_sidebar_tabs_destroy), (draw_one_tab_plain), (draw_one_tab_themed): Use the "default font" preference. * src/nautilus-sidebar-title.c: (nautilus_sidebar_title_class_init), (default_font_changed_callback), (nautilus_sidebar_title_init), (nautilus_sidebar_title_destroy), (update_title_font): Use the "default font" preference. * src/nautilus-window-menus.c: (help_menu_about_nautilus_callback): Use the GnomeAbout widget.
Diffstat (limited to 'libnautilus-private')
-rw-r--r--libnautilus-private/nautilus-global-preferences.c6
-rw-r--r--libnautilus-private/nautilus-icon-canvas-item.c20
-rw-r--r--libnautilus-private/nautilus-icon-container.c105
-rw-r--r--libnautilus-private/nautilus-icon-container.h4
-rw-r--r--libnautilus-private/nautilus-icon-factory.c40
-rw-r--r--libnautilus-private/nautilus-icon-private.h7
-rw-r--r--libnautilus-private/nautilus-program-chooser.c5
7 files changed, 107 insertions, 80 deletions
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 9a0180b82..535ce437d 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -707,11 +707,7 @@ global_preferences_install_defaults (void)
static gpointer
default_font_callback (void)
{
- if (eel_dumb_down_for_multi_byte_locale_hack ()) {
- return g_strdup ("fixed");
- }
-
- return g_strdup ("helvetica");
+ return g_strdup ("sans");
}
static int
diff --git a/libnautilus-private/nautilus-icon-canvas-item.c b/libnautilus-private/nautilus-icon-canvas-item.c
index 992cb6532..bb904d8bc 100644
--- a/libnautilus-private/nautilus-icon-canvas-item.c
+++ b/libnautilus-private/nautilus-icon-canvas-item.c
@@ -108,7 +108,6 @@ enum {
PROP_HIGHLIGHTED_FOR_SELECTION,
PROP_HIGHLIGHTED_AS_KEYBOARD_FOCUS,
PROP_HIGHLIGHTED_FOR_DROP,
- PROP_MODIFIER,
};
typedef enum {
@@ -315,7 +314,7 @@ nautilus_icon_canvas_item_set_property (GObject *object,
}
details->is_highlighted_for_drop = g_value_get_boolean (value);
break;
-
+
default:
g_warning ("nautilus_icons_view_item_item_set_arg on unknown argument");
return;
@@ -653,7 +652,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
icon_bottom);
g_object_unref (selection_pixbuf);
} else {
- gdk_gc_set_foreground (gc, &container->details->highlight_color);
+ gdk_gc_set_rgb_fg_color (gc, &container->details->highlight_color);
gdk_draw_rectangle
(drawable, GTK_WIDGET (GNOME_CANVAS_ITEM (item)->canvas)->style->black_gc, TRUE,
@@ -672,7 +671,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
(NAUTILUS_ICON_CONTAINER (canvas_item->canvas),
TRUE, needs_highlight);
- gdk_gc_set_foreground (gc, label_color);
+ gdk_gc_set_rgb_fg_color (gc, label_color);
draw_label_layout (item, drawable,
layout, needs_highlight,
@@ -696,7 +695,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
(NAUTILUS_ICON_CONTAINER (canvas_item->canvas),
FALSE, needs_highlight);
- gdk_gc_set_foreground (gc, label_color);
+ gdk_gc_set_rgb_fg_color (gc, label_color);
draw_label_layout (item, drawable,
layout, needs_highlight,
@@ -1134,7 +1133,10 @@ create_label_layout (NautilusIconCanvasItem *item,
const char *text)
{
PangoLayout *layout;
+ PangoFontDescription *desc;
+ NautilusIconContainer *container;
+ container = NAUTILUS_ICON_CONTAINER (GNOME_CANVAS_ITEM (item)->canvas);
layout = pango_layout_new (eel_gnome_canvas_get_pango_context (GNOME_CANVAS_ITEM (item)->canvas));
pango_layout_set_text (layout, text, -1);
@@ -1142,6 +1144,12 @@ create_label_layout (NautilusIconCanvasItem *item,
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
pango_layout_set_spacing (layout, LABEL_LINE_SPACING);
+ /* Create a font description */
+ desc = pango_font_description_from_string (container->details->font_name);
+ pango_font_description_set_size (desc, container->details->font_size_table [container->details->zoom_level] * PANGO_SCALE);
+ pango_layout_set_font_description (layout, desc);
+ pango_font_description_free (desc);
+
/* if it's prelit, and we're in click-to-activate mode, underline the text */
if (item->details->is_prelit && in_single_click_mode ()) {
eel_pango_layout_set_underline (layout, PANGO_UNDERLINE_SINGLE);
@@ -1716,7 +1724,7 @@ nautilus_icon_canvas_item_class_init (NautilusIconCanvasItemClass *class)
_("highlighted for drop"),
_("whether we are highlighted for a D&D drop"),
FALSE, G_PARAM_READWRITE));
-
+
signals[BOUNDS_CHANGED]
= g_signal_new ("bounds_changed",
G_TYPE_FROM_CLASS (class),
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index aac974cee..806a1faab 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -2314,7 +2314,9 @@ finalize (GObject *object)
g_hash_table_destroy (details->icon_set);
details->icon_set = NULL;
-
+
+ g_free (details->font_name);
+
g_free (details);
EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
@@ -2365,33 +2367,6 @@ size_allocate (GtkWidget *widget,
}
static void
-alloc_colors (NautilusIconContainer *container)
-{
- GtkWidget *widget = GTK_WIDGET (container);
-
- gdk_colormap_alloc_color (
- gtk_widget_get_colormap (widget),
- &container->details->highlight_color,
- TRUE, TRUE);
- gdk_colormap_alloc_color (
- gtk_widget_get_colormap (widget),
- &container->details->label_color,
- TRUE, TRUE);
- g_assert (gdk_colormap_alloc_color (
- gtk_widget_get_colormap (widget),
- &container->details->label_color_highlight,
- TRUE, TRUE));
- g_assert (gdk_colormap_alloc_color (
- gtk_widget_get_colormap (widget),
- &container->details->label_info_color,
- TRUE, TRUE));
- g_assert (gdk_colormap_alloc_color (
- gtk_widget_get_colormap (widget),
- &container->details->label_info_color_highlight,
- TRUE, TRUE));
-}
-
-static void
realize (GtkWidget *widget)
{
GtkStyle *style;
@@ -2411,8 +2386,6 @@ realize (GtkWidget *widget)
g_assert (GTK_IS_WINDOW (gtk_widget_get_toplevel (widget)));
window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
gtk_window_set_focus (window, widget);
-
- alloc_colors (NAUTILUS_ICON_CONTAINER (widget));
}
static void
@@ -3352,7 +3325,15 @@ nautilus_icon_container_init (NautilusIconContainer *container)
details->icon_set = g_hash_table_new (g_direct_hash, g_direct_equal);
details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
-
+
+ details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] = 8;
+ details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER] = 8;
+ details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL] = 10;
+ details->font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] = 10;
+ details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE] = 12;
+ details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER] = 14;
+ details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST] = 14;
+
container->details = details;
/* Set up DnD. */
@@ -3809,7 +3790,7 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
nautilus_icon_canvas_item_get_editable_text (icon->item)) != 0) {
end_renaming_mode (container, FALSE);
}
-
+
gnome_canvas_item_set (GNOME_CANVAS_ITEM (icon->item),
"editable_text", editable_text,
"additional_text", additional_text,
@@ -3820,6 +3801,10 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
nautilus_icon_canvas_item_set_attach_points (icon->item, &attach_points);
nautilus_icon_canvas_item_set_emblems (icon->item, emblem_pixbufs);
+ if (container->details->update_icon_font == TRUE) {
+ nautilus_icon_canvas_item_invalidate_label_size (icon->item);
+ }
+
/* Let the pixbufs go. */
g_object_unref (pixbuf);
eel_gdk_pixbuf_list_free (emblem_pixbufs);
@@ -4032,7 +4017,7 @@ nautilus_icon_container_set_zoom_level (NautilusIconContainer *container, int ne
} else if (pinned_level > NAUTILUS_ZOOM_LEVEL_LARGEST) {
pinned_level = NAUTILUS_ZOOM_LEVEL_LARGEST;
}
-
+
if (pinned_level == details->zoom_level) {
return;
}
@@ -4043,6 +4028,9 @@ nautilus_icon_container_set_zoom_level (NautilusIconContainer *container, int ne
/ NAUTILUS_ICON_SIZE_STANDARD;
gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (container), pixels_per_unit);
+ /* We need to update the icon font too */
+ container->details->update_icon_font = TRUE;
+
nautilus_icon_container_request_update_all (container);
}
@@ -4063,6 +4051,9 @@ nautilus_icon_container_request_update_all (NautilusIconContainer *container)
for (p = container->details->icons; p != NULL; p = p->next) {
nautilus_icon_container_update_icon (container, p->data);
}
+
+ container->details->update_icon_font = FALSE;
+
redo_layout (container);
}
@@ -4967,7 +4958,7 @@ nautilus_icon_container_get_label_color (NautilusIconContainer *container,
}
} else {
if (is_highlight) {
- return &container->details->label_color_highlight;
+ return &container->details->label_info_color_highlight;
} else {
return &container->details->label_info_color;
}
@@ -5004,20 +4995,16 @@ update_label_color (EelBackground *background,
g_free (dark_info_color);
}
+ container->details->label_color_highlight = eel_gdk_rgb_to_color (0xFFFFFF);
+ container->details->label_info_color_highlight = eel_gdk_rgb_to_color (0xCCCCCC);
+
if (eel_background_is_dark (background)) {
container->details->label_color = eel_gdk_rgb_to_color (0xEFEFEF);
- container->details->label_color_highlight = eel_gdk_rgb_to_color (0x000000);
container->details->label_info_color = eel_gdk_rgb_to_color (light_info_value);
- container->details->label_info_color_highlight = eel_gdk_rgb_to_color (dark_info_value);
} else { /* converse */
container->details->label_color = eel_gdk_rgb_to_color (0x000000);
- container->details->label_color_highlight = eel_gdk_rgb_to_color (0xEFEFEF);
container->details->label_info_color = eel_gdk_rgb_to_color (dark_info_value);
- container->details->label_info_color_highlight = eel_gdk_rgb_to_color (light_info_value);
}
-
- if (GTK_WIDGET_REALIZED (container))
- alloc_colors (container);
}
@@ -5093,6 +5080,42 @@ nautilus_icon_container_theme_changed (gpointer user_data)
container->details->highlight_color_rgba);
}
+void
+nautilus_icon_container_set_font_name (NautilusIconContainer *container,
+ const char *font_name)
+{
+ g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
+
+ g_free (container->details->font_name);
+
+ g_print ("new font name is: %s\n", font_name);
+
+ if (font_name != NULL) {
+ container->details->font_name = g_strdup (font_name);
+ }
+ else {
+ container->details->font_name = NULL;
+ }
+
+ container->details->update_icon_font = TRUE;
+}
+
+void
+nautilus_icon_container_set_font_size_table (NautilusIconContainer *container,
+ const int font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST + 1])
+{
+ int i;
+
+ g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
+ g_return_if_fail (font_size_table != NULL);
+
+ for (i = 0; i <= NAUTILUS_ZOOM_LEVEL_LARGEST; i++) {
+ container->details->font_size_table[i] = font_size_table[i];
+ }
+
+ container->details->update_icon_font = TRUE;
+}
+
#if ! defined (NAUTILUS_OMIT_SELF_CHECK)
static char *
diff --git a/libnautilus-private/nautilus-icon-container.h b/libnautilus-private/nautilus-icon-container.h
index e8324e88f..cf5ea7002 100644
--- a/libnautilus-private/nautilus-icon-container.h
+++ b/libnautilus-private/nautilus-icon-container.h
@@ -212,6 +212,10 @@ gboolean nautilus_icon_container_get_is_fixed_size (Nautilu
void nautilus_icon_container_set_is_fixed_size (NautilusIconContainer *container,
gboolean is_fixed_size);
void nautilus_icon_container_reset_scroll_region (NautilusIconContainer *container);
+void nautilus_icon_container_set_font_name (NautilusIconContainer *container,
+ const char *font_name);
+void nautilus_icon_container_set_font_size_table (NautilusIconContainer *container,
+ const int font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST + 1]);
void nautilus_icon_container_set_margins (NautilusIconContainer *container,
int left_margin,
int right_margin,
diff --git a/libnautilus-private/nautilus-icon-factory.c b/libnautilus-private/nautilus-icon-factory.c
index 12f33c52f..74a5ad420 100644
--- a/libnautilus-private/nautilus-icon-factory.c
+++ b/libnautilus-private/nautilus-icon-factory.c
@@ -2125,38 +2125,33 @@ embedded_text_rect_usable (ArtIRect embedded_text_rect)
return TRUE;
}
-#if GNOME2_CONVERSION_COMPLETE
-
static gboolean embedded_text_preferences_callbacks_added = FALSE;
-static EelScalableFont *embedded_text_font = NULL;
+static PangoFontDescription *embedded_text_font = NULL;
static void
embedded_text_font_changed_callback (gpointer callback_data)
{
gboolean clear_cache;
-
+ char *font_name;
+
clear_cache = GPOINTER_TO_INT (callback_data);
- embedded_text_font = nautilus_global_preferences_get_default_smooth_font ();
+ if (embedded_text_font != NULL) {
+ pango_font_description_free (embedded_text_font);
+ }
+
+ font_name = eel_preferences_get (NAUTILUS_PREFERENCES_DEFAULT_FONT);
+ embedded_text_font = pango_font_description_from_string (font_name);
+ g_free (font_name);
+
+ pango_font_description_set_size (embedded_text_font,
+ EMBEDDED_TEXT_FONT_SIZE * PANGO_SCALE);
if (clear_cache) {
nautilus_icon_factory_clear ();
}
}
-static void
-embedded_text_font_free (void)
-{
- if (embedded_text_font == NULL) {
- return;
- }
-
- g_object_unref (embedded_text_font);
- embedded_text_font = NULL;
-}
-
-#endif
-
static GdkPixbuf *
embed_text (GdkPixbuf *pixbuf_without_text,
ArtIRect text_rect,
@@ -2176,26 +2171,21 @@ embed_text (GdkPixbuf *pixbuf_without_text,
}
/* Listen for changes in embedded text (icon text preview) font preferences */
-#if GNOME2_CONVERSION_COMPLETE
if (!embedded_text_preferences_callbacks_added) {
embedded_text_preferences_callbacks_added = TRUE;
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_DEFAULT_SMOOTH_FONT,
+ eel_preferences_add_callback (NAUTILUS_PREFERENCES_DEFAULT_FONT,
embedded_text_font_changed_callback,
GINT_TO_POINTER (TRUE));
embedded_text_font_changed_callback (GINT_TO_POINTER (FALSE));
-
- eel_debug_call_at_shutdown (embedded_text_font_free);
}
-
- g_return_val_if_fail (EEL_IS_SCALABLE_FONT (embedded_text_font), NULL);
-#endif
if (context == NULL) {
context = eel_pango_ft2_get_context ();
eel_debug_call_at_shutdown_with_data (g_object_unref, context);
}
layout = pango_layout_new (context);
+ pango_layout_set_font_description (layout, embedded_text_font);
pango_layout_set_text (layout, text, -1);
pixbuf_with_text = gdk_pixbuf_copy (pixbuf_without_text);
diff --git a/libnautilus-private/nautilus-icon-private.h b/libnautilus-private/nautilus-icon-private.h
index 8709a5b67..285b07773 100644
--- a/libnautilus-private/nautilus-icon-private.h
+++ b/libnautilus-private/nautilus-icon-private.h
@@ -165,7 +165,12 @@ struct NautilusIconContainerDetails {
/* zoom level */
int zoom_level;
-
+
+ /* fonts used to draw labels */
+ char *font_name;
+ int font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST + 1];
+ gboolean update_icon_font;
+
/* pixbuf and color for label highlighting */
GdkPixbuf *highlight_frame;
GdkColor highlight_color;
diff --git a/libnautilus-private/nautilus-program-chooser.c b/libnautilus-private/nautilus-program-chooser.c
index 14a1047b9..db53ebac6 100644
--- a/libnautilus-private/nautilus-program-chooser.c
+++ b/libnautilus-private/nautilus-program-chooser.c
@@ -1283,11 +1283,12 @@ nautilus_program_chooser_init (NautilusProgramChooser *program_chooser)
program_chooser->details = g_new0 (NautilusProgramChooserDetails, 1);
+ program_chooser->details->cancel_button = gtk_dialog_add_button (GTK_DIALOG (program_chooser),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+
gtk_dialog_add_button (GTK_DIALOG (program_chooser),
_("Choose"), GTK_RESPONSE_OK);
- program_chooser->details->cancel_button = gtk_dialog_add_button (GTK_DIALOG (program_chooser),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
program_chooser->details->done_button = gtk_dialog_add_button (GTK_DIALOG (program_chooser),
_("Done"), GTK_RESPONSE_CANCEL);