diff options
Diffstat (limited to 'libnautilus')
-rw-r--r-- | libnautilus/nautilus-background-canvas-group.c | 8 | ||||
-rw-r--r-- | libnautilus/nautilus-background.c | 11 | ||||
-rw-r--r-- | libnautilus/nautilus-background.h | 5 | ||||
-rw-r--r-- | libnautilus/nautilus-gdk-extensions.c | 3 | ||||
-rw-r--r-- | libnautilus/nautilus-gdk-extensions.h | 1 | ||||
-rw-r--r-- | libnautilus/nautilus-gdk-pixbuf-extensions.c | 49 | ||||
-rw-r--r-- | libnautilus/nautilus-icon-dnd.c | 35 | ||||
-rw-r--r-- | libnautilus/nautilus-icon-factory.c | 34 | ||||
-rw-r--r-- | libnautilus/nautilus-icon-grid.c | 12 |
9 files changed, 113 insertions, 45 deletions
diff --git a/libnautilus/nautilus-background-canvas-group.c b/libnautilus/nautilus-background-canvas-group.c index 32217ca69..06cb28b8e 100644 --- a/libnautilus/nautilus-background-canvas-group.c +++ b/libnautilus/nautilus-background-canvas-group.c @@ -81,18 +81,15 @@ nautilus_background_canvas_group_draw (GnomeCanvasItem *item, GdkDrawable *drawa background = nautilus_get_widget_background(GTK_WIDGET (item->canvas)); if (background != NULL) { GdkGC *gc; - GdkColormap *colormap; GdkRectangle rectangle; /* Create a new gc each time. If this is a speed problem, we can create one and keep it around, but it's a bit more complicated to ensure that it's always compatible - with whatever drawable is passed in to use. + with whatever drawable is passed in. */ gc = gdk_gc_new (drawable); - colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas)); - /* The rectangle is the size of the entire viewed area of the canvas. The corner is determined by the current scroll position of the GtkLayout, and the size is determined by the current size of the widget. @@ -104,7 +101,8 @@ nautilus_background_canvas_group_draw (GnomeCanvasItem *item, GdkDrawable *drawa rectangle.width = GTK_WIDGET (item->canvas)->allocation.width; rectangle.height = GTK_WIDGET (item->canvas)->allocation.height; - nautilus_background_draw (background, drawable, gc, colormap, &rectangle); + nautilus_background_draw (background, drawable, gc, &rectangle, + -drawable_corner_x, -drawable_corner_y); gdk_gc_unref (gc); } diff --git a/libnautilus/nautilus-background.c b/libnautilus/nautilus-background.c index 944875a26..484f245f7 100644 --- a/libnautilus/nautilus-background.c +++ b/libnautilus/nautilus-background.c @@ -126,8 +126,9 @@ void nautilus_background_draw (NautilusBackground *background, GdkDrawable *drawable, GdkGC *gc, - GdkColormap *colormap, - const GdkRectangle *rectangle) + const GdkRectangle *rectangle, + int origin_x, + int origin_y) { char *start_color_spec, *end_color_spec; guint32 start_rgb, end_rgb; @@ -139,7 +140,7 @@ nautilus_background_draw (NautilusBackground *background, gc, rectangle, GDK_RGB_DITHER_NORMAL, - 0, 0); + origin_x, origin_y); } else { start_color_spec = nautilus_gradient_get_start_color_spec (background->details->color); end_color_spec = nautilus_gradient_get_end_color_spec (background->details->color); @@ -153,7 +154,6 @@ nautilus_background_draw (NautilusBackground *background, nautilus_fill_rectangle_with_gradient (drawable, gc, - colormap, rectangle, start_rgb, end_rgb, @@ -333,8 +333,7 @@ nautilus_background_draw_flat_box (GtkStyle *style, rectangle.height = height; nautilus_background_draw (background, window, gc, - gtk_widget_get_colormap (widget), - &rectangle); + &rectangle, 0, 0); gdk_gc_unref (gc); } diff --git a/libnautilus/nautilus-background.h b/libnautilus/nautilus-background.h index be2209b9c..45690c12d 100644 --- a/libnautilus/nautilus-background.h +++ b/libnautilus/nautilus-background.h @@ -74,8 +74,9 @@ char * nautilus_background_get_tile_image_uri (NautilusBackgroun void nautilus_background_draw (NautilusBackground *background, GdkDrawable *drawable, GdkGC *gc, - GdkColormap *colormap, - const GdkRectangle *rectangle); + const GdkRectangle *rectangle, + int origin_x, + int origin_y); /* Handles a dragged color being dropped on a widget to change the background color. */ void nautilus_background_receive_dropped_color (NautilusBackground *background, diff --git a/libnautilus/nautilus-gdk-extensions.c b/libnautilus/nautilus-gdk-extensions.c index d9a9ca1da..42fe1dc49 100644 --- a/libnautilus/nautilus-gdk-extensions.c +++ b/libnautilus/nautilus-gdk-extensions.c @@ -77,7 +77,6 @@ nautilus_fill_rectangle_with_color (GdkDrawable *drawable, * nautilus_fill_rectangle_with_gradient: * @drawable: Target to draw into. * @gc: Graphics context (mainly for clip). - * @colormap: Map to use to allocate colors for gradient. * @rectangle: Rectangle to draw gradient in. * @start_color: Color for the left or top; pixel value does not matter. * @end_color: Color for the right or bottom; pixel value does not matter. @@ -85,13 +84,11 @@ nautilus_fill_rectangle_with_color (GdkDrawable *drawable, * * Fill the rectangle with a gradient. * The color changes from start_color to end_color. - * A colormap is necessary because a gradient uses many different colors. * This effect works best on true color displays. */ void nautilus_fill_rectangle_with_gradient (GdkDrawable *drawable, GdkGC *gc, - GdkColormap *colormap, const GdkRectangle *rectangle, guint32 start_rgb, guint32 end_rgb, diff --git a/libnautilus/nautilus-gdk-extensions.h b/libnautilus/nautilus-gdk-extensions.h index 6b9eead97..e1c4d6f20 100644 --- a/libnautilus/nautilus-gdk-extensions.h +++ b/libnautilus/nautilus-gdk-extensions.h @@ -70,7 +70,6 @@ void nautilus_fill_rectangle_with_color (GdkDrawable *drawab guint32 rgb); void nautilus_fill_rectangle_with_gradient (GdkDrawable *drawable, GdkGC *gc, - GdkColormap *colormap, const GdkRectangle *rectangle, guint32 start_rgb, guint32 end_rgb, diff --git a/libnautilus/nautilus-gdk-pixbuf-extensions.c b/libnautilus/nautilus-gdk-pixbuf-extensions.c index 705fb1a54..993d198cc 100644 --- a/libnautilus/nautilus-gdk-pixbuf-extensions.c +++ b/libnautilus/nautilus-gdk-pixbuf-extensions.c @@ -274,21 +274,48 @@ nautilus_gdk_pixbuf_render_to_drawable_tiled (GdkPixbuf *pixbuf, int y_dither) { int x, y; - int width, height; + int start_x, start_y; + int end_x, end_y; + int tile_x, tile_y; + int blit_x, blit_y; + int tile_width, tile_height; + int blit_width, blit_height; + int tile_offset_x, tile_offset_y; + + tile_width = gdk_pixbuf_get_width (pixbuf); + tile_height = gdk_pixbuf_get_height (pixbuf); + + tile_offset_x = (rect->x - x_dither) % tile_width; + if (tile_offset_x < 0) { + tile_offset_x += tile_width; + } + g_assert (tile_offset_x >= 0 && tile_offset_x < tile_width); + + tile_offset_y = (rect->y - y_dither) % tile_height; + if (tile_offset_y < 0) { + tile_offset_y += tile_height; + } + g_assert (tile_offset_y >= 0 && tile_offset_y < tile_height); + + start_x = rect->x - tile_offset_x; + start_y = rect->y - tile_offset_y; + + end_x = rect->x + rect->width; + end_y = rect->y + rect->height; - for (x = rect->x; - x < rect->x + rect->width; - x += gdk_pixbuf_get_width (pixbuf)) { - width = MIN (gdk_pixbuf_get_width (pixbuf), rect->x + rect->width - x); + for (x = start_x; x < end_x; x += tile_width) { + blit_x = MAX (x, rect->x); + tile_x = blit_x - x; + blit_width = MIN (tile_width, end_x - x) - tile_x; - for (y = rect->y; - y < rect->y + rect->height; - y += gdk_pixbuf_get_height (pixbuf)) { - height = MIN (gdk_pixbuf_get_height (pixbuf), rect->y + rect->height - y); + for (y = start_y; y < end_y; y += tile_height) { + blit_y = MAX (y, rect->y); + tile_y = blit_y - y; + blit_height = MIN (tile_height, end_y - y) - tile_y; gdk_pixbuf_render_to_drawable (pixbuf, drawable, gc, - 0, 0, - x, y, width, height, + tile_x, tile_y, + blit_x, blit_y, blit_width, blit_height, dither, x_dither, y_dither); } } diff --git a/libnautilus/nautilus-icon-dnd.c b/libnautilus/nautilus-icon-dnd.c index c49faa175..503ce3dae 100644 --- a/libnautilus/nautilus-icon-dnd.c +++ b/libnautilus/nautilus-icon-dnd.c @@ -645,6 +645,23 @@ nautilus_icon_canvas_item_can_accept_items (NautilusIconContainer *container, } static void +receive_dropped_tile_image (NautilusIconContainer *container) +{ + GList *list; + + /* We only accept the image if it's the only thing dragged. */ + list = container->details->dnd_info->selection_list; + g_assert (list != NULL); + if (list->next != NULL) { + return; + } + + nautilus_background_set_tile_image_uri + (nautilus_get_widget_background (GTK_WIDGET (container)), + ((DndSelectionItem *) list->data)->uri); +} + +static void nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container, GdkDragContext *context, int x, int y) @@ -660,20 +677,27 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container, GdkPoint *source_item_locations; int index; int count; + GdkModifierType modifiers; - local_move_only = FALSE; - - if (container->details->dnd_info->selection_list == NULL) + if (container->details->dnd_info->selection_list == NULL) { return; + } + /* If the shift key is down, then this is a drag that customizes + * the background tile image. + */ + gdk_window_get_pointer (GTK_WIDGET (container)->window, + NULL, NULL, &modifiers); + if ((modifiers & GDK_SHIFT_MASK) != 0) { + receive_dropped_tile_image (container); + return; + } gnome_canvas_window_to_world (GNOME_CANVAS (container), x, y, &world_x, &world_y); /* find the item we hit with our drop, if any */ drop_target_icon = nautilus_icon_container_item_at (container, world_x, world_y); - - if (drop_target_icon != NULL && !nautilus_icon_canvas_item_can_accept_items (container, drop_target_icon, container->details->dnd_info->selection_list)) { /* the item we dropped our selection on cannot accept the items, @@ -682,6 +706,7 @@ nautilus_icon_container_receive_dropped_icons (NautilusIconContainer *container, drop_target_icon = NULL; } + local_move_only = FALSE; if (drop_target_icon == NULL && context->action == GDK_ACTION_MOVE) { /* we can just move the icon positions if the move ended up in * the item's parent container diff --git a/libnautilus/nautilus-icon-factory.c b/libnautilus/nautilus-icon-factory.c index 0ce263fbe..9b66c7ecc 100644 --- a/libnautilus/nautilus-icon-factory.c +++ b/libnautilus/nautilus-icon-factory.c @@ -53,6 +53,7 @@ /* List of suffixes to search when looking for an icon file. */ static const char *icon_file_name_suffixes[] = { + "", ".png", ".PNG", ".gif", @@ -467,6 +468,22 @@ nautilus_icon_factory_get_icon_name_for_file (NautilusFile *file) } } +static char * +make_full_icon_path (const char *path, const char *suffix) +{ + char *partial_path, *full_path; + + if (path[0] == '/') { + return g_strconcat (path, suffix, NULL); + } + + /* Build a path for this icon. */ + partial_path = g_strconcat ("nautilus/", path, suffix, NULL); + full_path = gnome_pixmap_file (partial_path); + g_free (partial_path); + return full_path; +} + /* Pick a particular icon to use, trying all the various suffixes. * Return the path of the icon or NULL if no icon is found. */ @@ -484,7 +501,7 @@ get_themed_icon_file_path (const char *theme_name, char *size_as_string, *property; ArtIRect parsed_rect; - if (theme_name == NULL) { + if (theme_name == NULL || icon_name[0] == '/') { themed_icon_name = g_strdup (icon_name); } else { themed_icon_name = g_strconcat (theme_name, "/", icon_name, NULL); @@ -496,12 +513,13 @@ get_themed_icon_file_path (const char *theme_name, for (i = 0; i < NAUTILUS_N_ELEMENTS (icon_file_name_suffixes); i++) { /* Build a path for this icon. */ - partial_path = g_strdup_printf ("nautilus/%s%s%.0u%s", + partial_path = g_strdup_printf ("%s%s%.0u", themed_icon_name, include_size ? "-" : "", - include_size ? icon_size : 0, - icon_file_name_suffixes[i]); - path = gnome_pixmap_file (partial_path); + include_size ? icon_size : 0); + + path = make_full_icon_path (partial_path, + icon_file_name_suffixes[i]); g_free (partial_path); /* Return the path if the file exists. */ @@ -509,16 +527,14 @@ get_themed_icon_file_path (const char *theme_name, break; } g_free (path); + path = NULL; } /* Open the XML file to get the text rectangle. */ if (path != NULL && text_rect != NULL) { memset (text_rect, 0, sizeof (*text_rect)); - partial_path = g_strdup_printf ("nautilus/%s.xml", - themed_icon_name); - xml_path = gnome_pixmap_file (partial_path); - g_free (partial_path); + xml_path = make_full_icon_path (themed_icon_name, ".xml"); doc = xmlParseFile (xml_path); g_free (xml_path); diff --git a/libnautilus/nautilus-icon-grid.c b/libnautilus/nautilus-icon-grid.c index 50b8b930b..3f2947258 100644 --- a/libnautilus/nautilus-icon-grid.c +++ b/libnautilus/nautilus-icon-grid.c @@ -73,8 +73,14 @@ nautilus_icon_grid_clear (NautilusIconGrid *grid) g_list_free (grid->elements[i]); } g_free (grid->elements); - - memset (grid, 0, sizeof (*grid)); + grid->elements = 0; + + grid->bounds.x0 = 0; + grid->bounds.y0 = 0; + grid->bounds.x1 = 0; + grid->bounds.y1 = 0; + grid->first_free_x = 0; + grid->first_free_y = 0; } void @@ -178,7 +184,7 @@ nautilus_icon_grid_set_visible_width (NautilusIconGrid *grid, int visible_width; ArtIRect bounds; - visible_width = floor (world_visible_width / GRID_CELL_WIDTH); + visible_width = MAX(1, floor (world_visible_width / GRID_CELL_WIDTH)); if (visible_width > grid->bounds.x1) { bounds = grid->bounds; |