mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-13 04:51:15 +00:00
Add a mode for text-beside-icons.
2003-06-09 Dave Camp <dave@ximian.com> * libnautilus-private/nautilus-icon-canvas-item.c: (compute_text_rectangle), (nautilus_icon_canvas_item_update_bounds), (draw_or_measure_label_text), (measure_label_text), (draw_label_text), (nautilus_icon_canvas_item_draw), (create_label_layout), (nautilus_icon_canvas_item_bounds), (nautilus_icon_canvas_item_get_text_rectangle), (nautilus_icon_canvas_item_get_max_text_width): * libnautilus-private/nautilus-icon-canvas-item.h: * libnautilus-private/nautilus-icon-container.c: (get_grid_width), (lay_down_icons_horizontal), (nautilus_icon_container_set_label_position): * libnautilus-private/nautilus-icon-container.h: * libnautilus-private/nautilus-icon-private.h: Add a mode for text-beside-icons. * libnautilus-private/apps_nautilus_preferences.schemas.in: * libnautilus-private/nautilus-global-preferences.h: * src/file-manager/fm-desktop-icon-view.c: (fm_desktop_icon_view_class_init), (real_supports_keep_aligned), (real_supports_labels_beside_icons): * src/file-manager/fm-icon-view.c: (fm_icon_view_supports_labels_beside_icons), (real_supports_labels_beside_icons), (set_labels_beside_icons), (fm_icon_view_begin_loading), (labels_beside_icons_changed_callback), (fm_icon_view_class_init), (fm_icon_view_instance_init): * src/file-manager/fm-icon-view.h: Add a "text beside icons" preference. * src/nautilus-file-management-properties.c: (nautilus_file_management_properties_dialog_setup): * src/nautilus-file-management-properties.glade: Add the pref to the dialog.
This commit is contained in:
parent
4154d5aa12
commit
de539cfded
37
ChangeLog
37
ChangeLog
|
@ -1,3 +1,40 @@
|
|||
2003-06-09 Dave Camp <dave@ximian.com>
|
||||
|
||||
* libnautilus-private/nautilus-icon-canvas-item.c:
|
||||
(compute_text_rectangle),
|
||||
(nautilus_icon_canvas_item_update_bounds),
|
||||
(draw_or_measure_label_text), (measure_label_text),
|
||||
(draw_label_text), (nautilus_icon_canvas_item_draw),
|
||||
(create_label_layout), (nautilus_icon_canvas_item_bounds),
|
||||
(nautilus_icon_canvas_item_get_text_rectangle),
|
||||
(nautilus_icon_canvas_item_get_max_text_width):
|
||||
* libnautilus-private/nautilus-icon-canvas-item.h:
|
||||
* libnautilus-private/nautilus-icon-container.c: (get_grid_width),
|
||||
(lay_down_icons_horizontal),
|
||||
(nautilus_icon_container_set_label_position):
|
||||
* libnautilus-private/nautilus-icon-container.h:
|
||||
* libnautilus-private/nautilus-icon-private.h: Add a mode for
|
||||
text-beside-icons.
|
||||
|
||||
* libnautilus-private/apps_nautilus_preferences.schemas.in:
|
||||
* libnautilus-private/nautilus-global-preferences.h:
|
||||
* src/file-manager/fm-desktop-icon-view.c:
|
||||
(fm_desktop_icon_view_class_init), (real_supports_keep_aligned),
|
||||
(real_supports_labels_beside_icons):
|
||||
* src/file-manager/fm-icon-view.c:
|
||||
(fm_icon_view_supports_labels_beside_icons),
|
||||
(real_supports_labels_beside_icons), (set_labels_beside_icons),
|
||||
(fm_icon_view_begin_loading),
|
||||
(labels_beside_icons_changed_callback), (fm_icon_view_class_init),
|
||||
(fm_icon_view_instance_init):
|
||||
* src/file-manager/fm-icon-view.h: Add a "text beside icons"
|
||||
preference.
|
||||
|
||||
* src/nautilus-file-management-properties.c:
|
||||
(nautilus_file_management_properties_dialog_setup):
|
||||
* src/nautilus-file-management-properties.glade: Add the pref
|
||||
to the dialog.
|
||||
|
||||
2003-06-08 Dave Camp <dave@ximian.com>
|
||||
|
||||
* components/adapter/main.c: (main): Call
|
||||
|
|
|
@ -492,6 +492,20 @@
|
|||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/nautilus/icon_view/labels_beside_icons</key>
|
||||
<applyto>/apps/nautilus/icon_view/labels_beside_icons</applyto>
|
||||
<owner>nautilus</owner>
|
||||
<type>bool</type>
|
||||
<default>false</default>
|
||||
<locale name="C">
|
||||
<short>Put labels beside icons</short>
|
||||
<long>
|
||||
If true, labels will be placed beside icons icons rather than underneath them.
|
||||
</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/nautilus/icon_view/default_use_manual_layout</key>
|
||||
<applyto>/apps/nautilus/icon_view/default_use_manual_layout</applyto>
|
||||
|
|
|
@ -108,6 +108,9 @@ enum
|
|||
#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL "icon_view/default_zoom_level"
|
||||
#define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT "icon_view/default_use_manual_layout"
|
||||
|
||||
#define NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS "icon_view/labels_beside_icons"
|
||||
|
||||
|
||||
/* The icon view uses 2 variables to store the sort order and
|
||||
* whether to use manual layout. However, the UI for these
|
||||
* preferences presensts them as single option menu. So we
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
|
||||
#define MAX_TEXT_WIDTH_STANDARD 135
|
||||
#define MAX_TEXT_WIDTH_TIGHTER 80
|
||||
#define MAX_TEXT_WIDTH_BESIDE 90
|
||||
|
||||
/* Private part of the NautilusIconCanvasItem structure. */
|
||||
struct NautilusIconCanvasItemDetails {
|
||||
|
@ -148,12 +149,10 @@ static void nautilus_icon_canvas_item_init (NautilusIconCanvasItem
|
|||
/* private */
|
||||
static void draw_or_measure_label_text (NautilusIconCanvasItem *item,
|
||||
GdkDrawable *drawable,
|
||||
int icon_left,
|
||||
int icon_bottom);
|
||||
ArtIRect icon_rect);
|
||||
static void draw_label_text (NautilusIconCanvasItem *item,
|
||||
GdkDrawable *drawable,
|
||||
int icon_left,
|
||||
int icon_bottom);
|
||||
ArtIRect icon_rect);
|
||||
static void measure_label_text (NautilusIconCanvasItem *item);
|
||||
static void get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
|
||||
ArtIRect *rect);
|
||||
|
@ -569,22 +568,35 @@ recompute_bounding_box (NautilusIconCanvasItem *icon_item,
|
|||
}
|
||||
|
||||
static ArtIRect
|
||||
compute_text_rectangle (NautilusIconCanvasItem *item,
|
||||
ArtIRect icon_rectangle)
|
||||
compute_text_rectangle (const NautilusIconCanvasItem *item,
|
||||
ArtIRect icon_rectangle,
|
||||
gboolean canvas_coords)
|
||||
{
|
||||
ArtIRect text_rectangle;
|
||||
double pixels_per_unit;
|
||||
double text_width, text_height;
|
||||
|
||||
pixels_per_unit = EEL_CANVAS_ITEM (item)->canvas->pixels_per_unit;
|
||||
text_width = item->details->text_width / pixels_per_unit;
|
||||
text_height = item->details->text_height / pixels_per_unit;
|
||||
|
||||
/* Compute text rectangle. */
|
||||
text_rectangle.x0 = (icon_rectangle.x0 + icon_rectangle.x1) / 2 - text_width / 2;
|
||||
text_rectangle.y0 = icon_rectangle.y1;
|
||||
text_rectangle.x1 = text_rectangle.x0 + text_width;
|
||||
text_rectangle.y1 = text_rectangle.y0 + text_height + LABEL_OFFSET / pixels_per_unit;
|
||||
if (canvas_coords) {
|
||||
text_width = item->details->text_width;
|
||||
text_height = item->details->text_height;
|
||||
} else {
|
||||
text_width = item->details->text_width / pixels_per_unit;
|
||||
text_height = item->details->text_height / pixels_per_unit;
|
||||
}
|
||||
|
||||
if (NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas)->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
|
||||
text_rectangle.x0 = icon_rectangle.x1;
|
||||
text_rectangle.x1 = text_rectangle.x0 + text_width;
|
||||
text_rectangle.y0 = icon_rectangle.y0;
|
||||
text_rectangle.y1 = text_rectangle.y0 + text_height + LABEL_OFFSET / pixels_per_unit;
|
||||
} else {
|
||||
text_rectangle.x0 = (icon_rectangle.x0 + icon_rectangle.x1) / 2
|
||||
- text_width / 2;
|
||||
text_rectangle.y0 = icon_rectangle.y1;
|
||||
text_rectangle.x1 = text_rectangle.x0 + text_width;
|
||||
text_rectangle.y1 = text_rectangle.y0 + text_height + LABEL_OFFSET / pixels_per_unit;
|
||||
}
|
||||
|
||||
return text_rectangle;
|
||||
}
|
||||
|
@ -627,7 +639,7 @@ nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item,
|
|||
|
||||
/* Update canvas and text rect cache */
|
||||
get_icon_canvas_rectangle (item, &item->details->canvas_rect);
|
||||
item->details->text_rect = compute_text_rectangle (item, item->details->canvas_rect);
|
||||
item->details->text_rect = compute_text_rectangle (item, item->details->canvas_rect, FALSE);
|
||||
|
||||
/* Update emblem rect cache */
|
||||
item->details->emblem_rect.x0 = 0;
|
||||
|
@ -761,8 +773,7 @@ draw_frame (NautilusIconCanvasItem *item,
|
|||
static void
|
||||
draw_or_measure_label_text (NautilusIconCanvasItem *item,
|
||||
GdkDrawable *drawable,
|
||||
int icon_left,
|
||||
int icon_bottom)
|
||||
ArtIRect icon_rect)
|
||||
{
|
||||
NautilusIconCanvasItemDetails *details;
|
||||
NautilusIconContainer *container;
|
||||
|
@ -774,12 +785,14 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
|
|||
GdkColor *label_color;
|
||||
int icon_width;
|
||||
gboolean have_editable, have_additional, needs_highlight, needs_frame;
|
||||
int max_text_width, box_left;
|
||||
int max_text_width;
|
||||
int x;
|
||||
GdkGC *gc;
|
||||
ArtIRect text_rect;
|
||||
|
||||
icon_width = 0;
|
||||
gc = NULL;
|
||||
|
||||
|
||||
details = item->details;
|
||||
needs_highlight = details->is_highlighted_for_selection || details->is_highlighted_for_drop;
|
||||
|
||||
|
@ -871,6 +884,8 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
text_rect = compute_text_rectangle (item, icon_rect, TRUE);
|
||||
|
||||
/* if the icon is highlighted, do some set-up */
|
||||
if (needs_highlight && !details->is_renaming &&
|
||||
|
@ -878,12 +893,19 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
|
|||
draw_frame (item,
|
||||
drawable,
|
||||
GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (container)) ? container->details->highlight_color_rgba : container->details->active_color_rgba,
|
||||
icon_left + (icon_width - details->text_width) / 2,
|
||||
icon_bottom,
|
||||
details->text_width,
|
||||
details->text_height);
|
||||
text_rect.x0,
|
||||
text_rect.y0,
|
||||
text_rect.x1 - text_rect.x0,
|
||||
text_rect.y1 - text_rect.y0);
|
||||
}
|
||||
|
||||
|
||||
if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
|
||||
x = text_rect.x0 + 2;
|
||||
} else {
|
||||
x = text_rect.x0 + ((text_rect.x1 - text_rect.x0) - max_text_width) / 2;
|
||||
}
|
||||
|
||||
if (have_editable) {
|
||||
gtk_widget_style_get (GTK_WIDGET (container),
|
||||
"frame_text", &needs_frame,
|
||||
|
@ -892,21 +914,21 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
|
|||
draw_frame (item,
|
||||
drawable,
|
||||
eel_gdk_color_to_rgb (>K_WIDGET (container)->style->base[GTK_STATE_NORMAL]),
|
||||
icon_left + (icon_width - details->text_width) / 2,
|
||||
icon_bottom,
|
||||
details->text_width,
|
||||
details->text_height);
|
||||
text_rect.x0,
|
||||
text_rect.y0,
|
||||
text_rect.x1 - text_rect.x0,
|
||||
text_rect.y1 - text_rect.y0);
|
||||
}
|
||||
|
||||
gc = nautilus_icon_container_get_label_color_and_gc
|
||||
(NAUTILUS_ICON_CONTAINER (canvas_item->canvas),
|
||||
&label_color, TRUE, needs_highlight);
|
||||
|
||||
|
||||
draw_label_layout (item, drawable,
|
||||
editable_layout, needs_highlight,
|
||||
label_color,
|
||||
icon_left + (icon_width - max_text_width) / 2,
|
||||
icon_bottom, gc);
|
||||
x,
|
||||
text_rect.y0, gc);
|
||||
}
|
||||
|
||||
if (have_additional) {
|
||||
|
@ -917,12 +939,10 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
|
|||
draw_label_layout (item, drawable,
|
||||
additional_layout, needs_highlight,
|
||||
label_color,
|
||||
icon_left + (icon_width - max_text_width) / 2,
|
||||
icon_bottom + editable_height + LABEL_LINE_SPACING, gc);
|
||||
x,
|
||||
text_rect.y0 + editable_height + LABEL_LINE_SPACING, gc);
|
||||
}
|
||||
|
||||
box_left = icon_left + (icon_width - details->text_width) / 2;
|
||||
|
||||
if (item->details->is_highlighted_as_keyboard_focus) {
|
||||
gtk_paint_focus (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)->style,
|
||||
drawable,
|
||||
|
@ -930,10 +950,10 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
|
|||
NULL,
|
||||
GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas),
|
||||
"icon-container",
|
||||
box_left,
|
||||
icon_bottom,
|
||||
details->text_width,
|
||||
details->text_height);
|
||||
text_rect.x0,
|
||||
text_rect.y0,
|
||||
text_rect.x1 - text_rect.x0,
|
||||
text_rect.y1 - text_rect.y0);
|
||||
}
|
||||
|
||||
if (editable_layout) {
|
||||
|
@ -948,6 +968,8 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
|
|||
static void
|
||||
measure_label_text (NautilusIconCanvasItem *item)
|
||||
{
|
||||
ArtIRect rect = {0, };
|
||||
|
||||
/* check to see if the cached values are still valid; if so, there's
|
||||
* no work necessary
|
||||
*/
|
||||
|
@ -956,14 +978,14 @@ measure_label_text (NautilusIconCanvasItem *item)
|
|||
return;
|
||||
}
|
||||
|
||||
draw_or_measure_label_text (item, NULL, 0, 0);
|
||||
draw_or_measure_label_text (item, NULL, rect);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_label_text (NautilusIconCanvasItem *item, GdkDrawable *drawable,
|
||||
int icon_left, int icon_bottom)
|
||||
ArtIRect icon_rect)
|
||||
{
|
||||
draw_or_measure_label_text (item, drawable, icon_left, icon_bottom + LABEL_OFFSET);
|
||||
draw_or_measure_label_text (item, drawable, icon_rect);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1331,7 +1353,7 @@ nautilus_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
|
|||
draw_stretch_handles (icon_item, drawable, &icon_rect);
|
||||
|
||||
/* Draw the label text. */
|
||||
draw_label_text (icon_item, drawable, icon_rect.x0, icon_rect.y1);
|
||||
draw_label_text (icon_item, drawable, icon_rect);
|
||||
}
|
||||
|
||||
static PangoLayout *
|
||||
|
@ -1352,7 +1374,13 @@ create_label_layout (NautilusIconCanvasItem *item,
|
|||
|
||||
pango_layout_set_text (layout, text, -1);
|
||||
pango_layout_set_width (layout, floor (nautilus_icon_canvas_item_get_max_text_width (item)) * PANGO_SCALE);
|
||||
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
|
||||
|
||||
if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
|
||||
pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
|
||||
} else {
|
||||
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
pango_layout_set_spacing (layout, LABEL_LINE_SPACING);
|
||||
pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
|
||||
|
||||
|
@ -1693,7 +1721,7 @@ nautilus_icon_canvas_item_bounds (EelCanvasItem *item,
|
|||
}
|
||||
|
||||
/* Compute text rectangle. */
|
||||
text_rect = compute_text_rectangle (icon_item, icon_rect);
|
||||
text_rect = compute_text_rectangle (icon_item, icon_rect, FALSE);
|
||||
|
||||
/* Compute total rectangle, adding in emblem rectangles. */
|
||||
art_irect_union (&total_rect, &icon_rect, &text_rect);
|
||||
|
@ -1738,6 +1766,45 @@ nautilus_icon_canvas_item_get_icon_rectangle (const NautilusIconCanvasItem *item
|
|||
return rectangle;
|
||||
}
|
||||
|
||||
ArtDRect
|
||||
nautilus_icon_canvas_item_get_text_rectangle (const NautilusIconCanvasItem *item)
|
||||
{
|
||||
/* FIXME */
|
||||
ArtIRect icon_rectangle;
|
||||
ArtIRect text_rectangle;
|
||||
ArtDRect ret;
|
||||
double pixels_per_unit;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), eel_art_drect_empty);
|
||||
|
||||
icon_rectangle.x0 = item->details->x;
|
||||
icon_rectangle.y0 = item->details->y;
|
||||
|
||||
pixbuf = item->details->pixbuf;
|
||||
|
||||
pixels_per_unit = EEL_CANVAS_ITEM (item)->canvas->pixels_per_unit;
|
||||
icon_rectangle.x1 = icon_rectangle.x0 + (pixbuf == NULL ? 0 : gdk_pixbuf_get_width (pixbuf)) / pixels_per_unit;
|
||||
icon_rectangle.y1 = icon_rectangle.y0 + (pixbuf == NULL ? 0 : gdk_pixbuf_get_height (pixbuf)) / pixels_per_unit;
|
||||
|
||||
text_rectangle = compute_text_rectangle (item, icon_rectangle, FALSE);
|
||||
|
||||
ret.x0 = text_rectangle.x0;
|
||||
ret.y0 = text_rectangle.y0;
|
||||
ret.x1 = text_rectangle.x1;
|
||||
ret.y1 = text_rectangle.y1;
|
||||
|
||||
eel_canvas_item_i2w (EEL_CANVAS_ITEM (item),
|
||||
&ret.x0,
|
||||
&ret.y0);
|
||||
eel_canvas_item_i2w (EEL_CANVAS_ITEM (item),
|
||||
&ret.x1,
|
||||
&ret.y1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Get the rectangle of the icon only, in canvas coordinates. */
|
||||
static void
|
||||
get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
|
||||
|
@ -1875,7 +1942,14 @@ nautilus_icon_canvas_item_get_max_text_width (NautilusIconCanvasItem *item)
|
|||
if (nautilus_icon_container_is_tighter_layout (NAUTILUS_ICON_CONTAINER (canvas_item->canvas))) {
|
||||
return MAX_TEXT_WIDTH_TIGHTER * canvas_item->canvas->pixels_per_unit;
|
||||
} else {
|
||||
return MAX_TEXT_WIDTH_STANDARD * canvas_item->canvas->pixels_per_unit;
|
||||
|
||||
if (NAUTILUS_ICON_CONTAINER (canvas_item->canvas)->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
|
||||
return MAX_TEXT_WIDTH_BESIDE * canvas_item->canvas->pixels_per_unit;
|
||||
} else {
|
||||
return MAX_TEXT_WIDTH_STANDARD * canvas_item->canvas->pixels_per_unit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ gboolean nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanv
|
|||
ArtPoint world_point);
|
||||
void nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item);
|
||||
ArtDRect nautilus_icon_canvas_item_get_icon_rectangle (const NautilusIconCanvasItem *item);
|
||||
ArtDRect nautilus_icon_canvas_item_get_text_rectangle (const NautilusIconCanvasItem *item);
|
||||
void nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item,
|
||||
double i2w_dx, double i2w_dy);
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@
|
|||
|
||||
#define STANDARD_ICON_GRID_WIDTH 155
|
||||
|
||||
#define TEXT_BESIDE_ICON_GRID_WIDTH 205
|
||||
|
||||
/* Desktop layout mode defines */
|
||||
#define DESKTOP_PAD_HORIZONTAL 10
|
||||
#define DESKTOP_PAD_VERTICAL 10
|
||||
|
@ -869,7 +871,11 @@ resort (NautilusIconContainer *container)
|
|||
static double
|
||||
get_grid_width (NautilusIconContainer *container)
|
||||
{
|
||||
return STANDARD_ICON_GRID_WIDTH;
|
||||
if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
|
||||
return TEXT_BESIDE_ICON_GRID_WIDTH;
|
||||
} else {
|
||||
return STANDARD_ICON_GRID_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -922,6 +928,7 @@ lay_down_icons_horizontal (NautilusIconContainer *container,
|
|||
IconPositions *position;
|
||||
ArtDRect bounds;
|
||||
ArtDRect icon_bounds;
|
||||
ArtDRect text_bounds;
|
||||
EelCanvasItem *item;
|
||||
double max_height_above, max_height_below;
|
||||
double height_above, height_below;
|
||||
|
@ -965,13 +972,16 @@ lay_down_icons_horizontal (NautilusIconContainer *container,
|
|||
&bounds.x0, &bounds.y0,
|
||||
&bounds.x1, &bounds.y1);
|
||||
|
||||
icon_bounds = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
|
||||
text_bounds = nautilus_icon_canvas_item_get_text_rectangle (icon->item);
|
||||
|
||||
if (gridded_layout) {
|
||||
icon_width = ceil ((bounds.x1 - bounds.x0)/grid_width) * grid_width;
|
||||
|
||||
|
||||
} else {
|
||||
icon_width = ICON_PAD_LEFT + (bounds.x1 - bounds.x0) + ICON_PAD_RIGHT + 8; /* 8 pixels extra for fancy selection box */
|
||||
}
|
||||
|
||||
icon_bounds = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
|
||||
}
|
||||
|
||||
/* Calculate size above/below baseline */
|
||||
height_above = icon_bounds.y1 - bounds.y0;
|
||||
|
@ -984,14 +994,22 @@ lay_down_icons_horizontal (NautilusIconContainer *container,
|
|||
* the first column?
|
||||
*/
|
||||
if (line_start != p && line_width + icon_width - ICON_PAD_RIGHT > canvas_width ) {
|
||||
/* Advance to the baseline. */
|
||||
y += ICON_PAD_TOP + max_height_above;
|
||||
if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
|
||||
y += ICON_PAD_TOP;
|
||||
} else {
|
||||
/* Advance to the baseline. */
|
||||
y += ICON_PAD_TOP + max_height_above;
|
||||
}
|
||||
|
||||
lay_down_one_line (container, line_start, p, y, positions);
|
||||
|
||||
/* Advance to next line. */
|
||||
y += max_height_below + ICON_PAD_BOTTOM;
|
||||
|
||||
if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
|
||||
y += max_height_above + max_height_below + ICON_PAD_BOTTOM;
|
||||
} else {
|
||||
/* Advance to next line. */
|
||||
y += max_height_below + ICON_PAD_BOTTOM;
|
||||
}
|
||||
|
||||
line_width = 0;
|
||||
line_start = p;
|
||||
i = 0;
|
||||
|
@ -1010,8 +1028,14 @@ lay_down_icons_horizontal (NautilusIconContainer *container,
|
|||
g_array_set_size (positions, i + 1);
|
||||
position = &g_array_index (positions, IconPositions, i++);
|
||||
position->width = icon_width;
|
||||
position->x_offset = (icon_width - (icon_bounds.x1 - icon_bounds.x0)) / 2;
|
||||
position->y_offset = icon_bounds.y0 - icon_bounds.y1;
|
||||
|
||||
if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
|
||||
position->x_offset = (MAXIMUM_IMAGE_SIZE - (icon_bounds.x1 - icon_bounds.x0));
|
||||
position->y_offset = 0;
|
||||
} else {
|
||||
position->x_offset = (icon_width - (icon_bounds.x1 - icon_bounds.x0)) / 2;
|
||||
position->y_offset = icon_bounds.y0 - icon_bounds.y1;
|
||||
}
|
||||
|
||||
/* Add this icon. */
|
||||
line_width += icon_width;
|
||||
|
@ -1019,8 +1043,12 @@ lay_down_icons_horizontal (NautilusIconContainer *container,
|
|||
|
||||
/* Lay down that last line of icons. */
|
||||
if (line_start != NULL) {
|
||||
/* Advance to the baseline. */
|
||||
y += ICON_PAD_TOP + max_height_above;
|
||||
if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
|
||||
y += ICON_PAD_TOP;
|
||||
} else {
|
||||
/* Advance to the baseline. */
|
||||
y += ICON_PAD_TOP + max_height_above;
|
||||
}
|
||||
|
||||
lay_down_one_line (container, line_start, NULL, y, positions);
|
||||
|
||||
|
@ -5535,6 +5563,21 @@ nautilus_icon_container_set_layout_mode (NautilusIconContainer *container,
|
|||
g_signal_emit (container, signals[LAYOUT_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_icon_container_set_label_position (NautilusIconContainer *container,
|
||||
NautilusIconLabelPosition position)
|
||||
{
|
||||
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
|
||||
|
||||
if (container->details->label_position != position) {
|
||||
container->details->label_position = position;
|
||||
|
||||
invalidate_label_sizes (container);
|
||||
nautilus_icon_container_request_update_all (container);
|
||||
|
||||
schedule_redo_layout (container);
|
||||
}
|
||||
}
|
||||
|
||||
/* Switch from automatic to manual layout, freezing all the icons in their
|
||||
* current positions instead of restoring icon positions from the last manual
|
||||
|
@ -5751,14 +5794,23 @@ nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *con
|
|||
|
||||
width = nautilus_icon_canvas_item_get_max_text_width (icon->item);
|
||||
|
||||
eel_canvas_w2c (EEL_CANVAS_ITEM (icon->item)->canvas,
|
||||
(icon_rect.x0 + icon_rect.x1) / 2,
|
||||
icon_rect.y1,
|
||||
&x, &y);
|
||||
|
||||
if (details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
|
||||
eel_canvas_w2c (EEL_CANVAS_ITEM (icon->item)->canvas,
|
||||
icon_rect.x1,
|
||||
icon_rect.y0,
|
||||
&x, &y);
|
||||
} else {
|
||||
eel_canvas_w2c (EEL_CANVAS_ITEM (icon->item)->canvas,
|
||||
(icon_rect.x0 + icon_rect.x1) / 2,
|
||||
icon_rect.y1,
|
||||
&x, &y);
|
||||
x = x - width / 2 - 1;
|
||||
}
|
||||
|
||||
gtk_layout_move (GTK_LAYOUT (container),
|
||||
details->rename_widget,
|
||||
x - width/2 - 1, y);
|
||||
x, y);
|
||||
|
||||
gtk_widget_set_size_request (details->rename_widget,
|
||||
width, -1);
|
||||
|
|
|
@ -61,6 +61,11 @@ typedef enum {
|
|||
NAUTILUS_ICON_LAYOUT_T_B_R_L
|
||||
} NautilusIconLayoutMode;
|
||||
|
||||
typedef enum {
|
||||
NAUTILUS_ICON_LABEL_POSITION_UNDER,
|
||||
NAUTILUS_ICON_LABEL_POSITION_BESIDE
|
||||
} NautilusIconLabelPosition;
|
||||
|
||||
typedef struct NautilusIconContainerDetails NautilusIconContainerDetails;
|
||||
|
||||
typedef struct {
|
||||
|
@ -211,6 +216,8 @@ void nautilus_icon_container_set_keep_aligned (Nautilu
|
|||
gboolean keep_aligned);
|
||||
void nautilus_icon_container_set_layout_mode (NautilusIconContainer *container,
|
||||
NautilusIconLayoutMode mode);
|
||||
void nautilus_icon_container_set_label_position (NautilusIconContainer *container,
|
||||
NautilusIconLabelPosition pos);
|
||||
void nautilus_icon_container_sort (NautilusIconContainer *container);
|
||||
void nautilus_icon_container_freeze_icon_positions (NautilusIconContainer *container);
|
||||
|
||||
|
|
|
@ -218,6 +218,9 @@ struct NautilusIconContainerDetails {
|
|||
/* Layout mode */
|
||||
NautilusIconLayoutMode layout_mode;
|
||||
|
||||
/* Label position */
|
||||
NautilusIconLabelPosition label_position;
|
||||
|
||||
/* Should the container keep icons aligned to a grid */
|
||||
gboolean keep_aligned;
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ static void fm_desktop_icon_view_class_init (FMDesktopIconViewCl
|
|||
static void default_zoom_level_changed (gpointer user_data);
|
||||
static gboolean real_supports_auto_layout (FMIconView *view);
|
||||
static gboolean real_supports_keep_aligned (FMIconView *view);
|
||||
static gboolean real_supports_labels_beside_icons (FMIconView *view);
|
||||
static void real_merge_menus (FMDirectoryView *view);
|
||||
static void real_update_menus (FMDirectoryView *view);
|
||||
static gboolean real_supports_zooming (FMDirectoryView *view);
|
||||
|
@ -273,6 +274,7 @@ fm_desktop_icon_view_class_init (FMDesktopIconViewClass *class)
|
|||
|
||||
FM_ICON_VIEW_CLASS (class)->supports_auto_layout = real_supports_auto_layout;
|
||||
FM_ICON_VIEW_CLASS (class)->supports_keep_aligned = real_supports_keep_aligned;
|
||||
FM_ICON_VIEW_CLASS (class)->supports_labels_beside_icons = real_supports_labels_beside_icons;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1185,6 +1187,12 @@ real_supports_keep_aligned (FMIconView *view)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
real_supports_labels_beside_icons (FMIconView *view)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
real_supports_zooming (FMDirectoryView *view)
|
||||
{
|
||||
|
|
|
@ -590,6 +590,16 @@ fm_icon_view_supports_keep_aligned (FMIconView *view)
|
|||
supports_keep_aligned, (view));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
fm_icon_view_supports_labels_beside_icons (FMIconView *view)
|
||||
{
|
||||
g_return_val_if_fail (FM_IS_ICON_VIEW (view), FALSE);
|
||||
|
||||
return EEL_CALL_METHOD_WITH_RETURN_VALUE
|
||||
(FM_ICON_VIEW_CLASS, view,
|
||||
supports_labels_beside_icons, (view));
|
||||
}
|
||||
|
||||
static void
|
||||
update_layout_menus (FMIconView *view)
|
||||
{
|
||||
|
@ -946,6 +956,14 @@ real_supports_keep_aligned (FMIconView *view)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
real_supports_labels_beside_icons (FMIconView *view)
|
||||
{
|
||||
g_return_val_if_fail (FM_IS_ICON_VIEW (view), TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
set_sort_reversed (FMIconView *icon_view, gboolean new_value)
|
||||
{
|
||||
|
@ -1022,6 +1040,26 @@ get_default_zoom_level (void)
|
|||
return CLAMP (default_zoom_level, NAUTILUS_ZOOM_LEVEL_SMALLEST, NAUTILUS_ZOOM_LEVEL_LARGEST);
|
||||
}
|
||||
|
||||
static void
|
||||
set_labels_beside_icons (FMIconView *icon_view)
|
||||
{
|
||||
gboolean labels_beside;
|
||||
|
||||
if (fm_icon_view_supports_labels_beside_icons (icon_view)) {
|
||||
labels_beside = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS);
|
||||
|
||||
if (labels_beside) {
|
||||
nautilus_icon_container_set_label_position
|
||||
(get_icon_container (icon_view),
|
||||
NAUTILUS_ICON_LABEL_POSITION_BESIDE);
|
||||
} else {
|
||||
nautilus_icon_container_set_label_position
|
||||
(get_icon_container (icon_view),
|
||||
NAUTILUS_ICON_LABEL_POSITION_UNDER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fm_icon_view_begin_loading (FMDirectoryView *view)
|
||||
{
|
||||
|
@ -1079,6 +1117,8 @@ fm_icon_view_begin_loading (FMDirectoryView *view)
|
|||
(get_icon_container (icon_view),
|
||||
fm_icon_view_get_directory_tighter_layout (icon_view, file));
|
||||
|
||||
set_labels_beside_icons (icon_view);
|
||||
|
||||
/* We must set auto-layout last, because it invokes the layout_changed
|
||||
* callback, which works incorrectly if the other layout criteria are
|
||||
* not already set up properly (see bug 6500, e.g.)
|
||||
|
@ -2309,6 +2349,18 @@ default_zoom_level_changed_callback (gpointer callback_data)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
labels_beside_icons_changed_callback (gpointer callback_data)
|
||||
{
|
||||
FMIconView *icon_view;
|
||||
|
||||
g_return_if_fail (FM_IS_ICON_VIEW (callback_data));
|
||||
|
||||
icon_view = FM_ICON_VIEW (callback_data);
|
||||
|
||||
set_labels_beside_icons (icon_view);
|
||||
}
|
||||
|
||||
static void
|
||||
fm_icon_view_sort_directories_first_changed (FMDirectoryView *directory_view)
|
||||
{
|
||||
|
@ -2665,6 +2717,7 @@ fm_icon_view_class_init (FMIconViewClass *klass)
|
|||
klass->clean_up = fm_icon_view_real_clean_up;
|
||||
klass->supports_auto_layout = real_supports_auto_layout;
|
||||
klass->supports_keep_aligned = real_supports_keep_aligned;
|
||||
klass->supports_labels_beside_icons = real_supports_labels_beside_icons;
|
||||
klass->get_directory_auto_layout = fm_icon_view_real_get_directory_auto_layout;
|
||||
klass->get_directory_sort_by = fm_icon_view_real_get_directory_sort_by;
|
||||
klass->get_directory_sort_reversed = fm_icon_view_real_get_directory_sort_reversed;
|
||||
|
@ -2720,6 +2773,9 @@ fm_icon_view_instance_init (FMIconView *icon_view)
|
|||
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
|
||||
default_zoom_level_changed_callback,
|
||||
icon_view, G_OBJECT (icon_view));
|
||||
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS,
|
||||
labels_beside_icons_changed_callback,
|
||||
icon_view, G_OBJECT (icon_view));
|
||||
|
||||
g_signal_connect_object (get_icon_container (icon_view), "handle_uri_list",
|
||||
G_CALLBACK (icon_view_handle_uri_list), icon_view, 0);
|
||||
|
|
|
@ -90,6 +90,11 @@ struct FMIconViewClass {
|
|||
*/
|
||||
gboolean (* supports_keep_aligned) (FMIconView *view);
|
||||
|
||||
/* supports_auto_layout is a function pointer that subclasses may
|
||||
* override to control whether snap-to-grid mode
|
||||
* should be enabled. The default implementation returns FALSE.
|
||||
*/
|
||||
gboolean (* supports_labels_beside_icons) (FMIconView *view);
|
||||
};
|
||||
|
||||
/* GObject support */
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
/* bool preferences */
|
||||
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET "sort_folders_first_checkbutton"
|
||||
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_COMPACT_LAYOUT_WIDGET "compact_layout_checkbutton"
|
||||
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET "labels_beside_icons_checkbutton"
|
||||
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_WIDGET "trash_confirm_checkbutton"
|
||||
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET "trash_delete_checkbutton"
|
||||
#define NAUTILUS_FILE_MANAGEMENT_PROPERTIES_OPEN_NEW_WINDOW_WIDGET "new_window_checkbutton"
|
||||
|
@ -313,6 +314,9 @@ nautilus_file_management_properties_dialog_setup (GladeXML *xml_dialog, GtkWindo
|
|||
eel_preferences_glade_connect_bool (xml_dialog,
|
||||
NAUTILUS_FILE_MANAGEMENT_PROPERTIES_COMPACT_LAYOUT_WIDGET,
|
||||
NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT);
|
||||
eel_preferences_glade_connect_bool (xml_dialog,
|
||||
NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET,
|
||||
NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS);
|
||||
eel_preferences_glade_connect_bool (xml_dialog,
|
||||
NAUTILUS_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET,
|
||||
NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST);
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
|
||||
|
||||
<glade-interface>
|
||||
<requires lib="gnome"/>
|
||||
|
||||
<widget class="GtkDialog" id="file_management_dialog">
|
||||
<property name="border_width">5</property>
|
||||
|
@ -351,6 +350,24 @@
|
|||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckButton" id="labels_beside_icons_checkbutton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">_Text beside icons</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="active">False</property>
|
||||
<property name="inconsistent">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
|
|
Loading…
Reference in a new issue