general: Remove canvas view

The new grid view has reached feature parity with the canvas, if we
ignore drag-and-drop and clipboard support (which would need to be
reimplemented in GTK 4 anyway) and performance scalability (which is
a problem of GtkFlowBox and solvable by using GtkGridView in GTK 4).

The canvas view relies on extensive custom implementation for layout,
drawing, input handling, accessibility, etc., which would be too
hard to port to in GT1K4.

Furthermore, most of its features, such as support for manual sorting,
haven't been used since the "icons on desktop" feature has been taken
out from this app. We are actually using a swiss army knife for a job
where we only need a single blade -- a simple pocketknife would do!

Therefore, we say goodbye to this seasoned veteran widget, who has
served us for 2 whole decades.
This commit is contained in:
António Fernandes 2021-12-12 17:59:39 +00:00
parent 5830de7f41
commit 2d1deaac2d
23 changed files with 12 additions and 19035 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,497 +0,0 @@
/*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If not,
* see <http://www.gnu.org/licenses/>.
*/
/*
@NOTATION@
*/
/* EelCanvas widget - Tk-like canvas widget for Gnome
*
* EelCanvas is basically a port of the Tk toolkit's most excellent canvas
* widget. Tk is copyrighted by the Regents of the University of California,
* Sun Microsystems, and other parties.
*
*
* Authors: Federico Mena <federico@nuclecu.unam.mx>
* Raph Levien <raph@gimp.org>
*/
#pragma once
#include <gtk/gtk.h>
#include <gtk/gtk-a11y.h>
#include <gdk/gdk.h>
#include <stdarg.h>
G_BEGIN_DECLS
/* "Small" value used by canvas stuff */
#define EEL_CANVAS_EPSILON 1e-10
/* Macros for building colors that fit in a 32-bit integer. The values are in
* [0, 255].
*/
#define EEL_CANVAS_COLOR(r, g, b) ((((int) (r) & 0xff) << 24) \
| (((int) (g) & 0xff) << 16) \
| (((int) (b) & 0xff) << 8) \
| 0xff)
#define EEL_CANVAS_COLOR_A(r, g, b, a) ((((int) (r) & 0xff) << 24) \
| (((int) (g) & 0xff) << 16) \
| (((int) (b) & 0xff) << 8) \
| ((int) (a) & 0xff))
typedef struct _EelCanvas EelCanvas;
typedef struct _EelCanvasClass EelCanvasClass;
typedef struct _EelCanvasItem EelCanvasItem;
typedef struct _EelCanvasItemClass EelCanvasItemClass;
typedef struct _EelCanvasGroup EelCanvasGroup;
typedef struct _EelCanvasGroupClass EelCanvasGroupClass;
/* EelCanvasItem - base item class for canvas items
*
* All canvas items are derived from EelCanvasItem. The only information a
* EelCanvasItem contains is its parent canvas, its parent canvas item group,
* and its bounding box in world coordinates.
*
* Items inside a canvas are organized in a tree of EelCanvasItemGroup nodes
* and EelCanvasItem leaves. Each canvas has a single root group, which can
* be obtained with the eel_canvas_get_root() function.
*
* The abstract EelCanvasItem class does not have any configurable or
* queryable attributes.
*/
/* Object flags for items */
enum {
EEL_CANVAS_ITEM_REALIZED = 1 << 4,
EEL_CANVAS_ITEM_MAPPED = 1 << 5,
EEL_CANVAS_ITEM_ALWAYS_REDRAW = 1 << 6,
EEL_CANVAS_ITEM_VISIBLE = 1 << 7,
EEL_CANVAS_ITEM_NEED_UPDATE = 1 << 8,
EEL_CANVAS_ITEM_NEED_DEEP_UPDATE = 1 << 9
};
/* Update flags for items */
enum {
EEL_CANVAS_UPDATE_REQUESTED = 1 << 0,
EEL_CANVAS_UPDATE_DEEP = 1 << 1
};
#define EEL_TYPE_CANVAS_ITEM (eel_canvas_item_get_type ())
#define EEL_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEL_TYPE_CANVAS_ITEM, EelCanvasItem))
#define EEL_CANVAS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEL_TYPE_CANVAS_ITEM, EelCanvasItemClass))
#define EEL_IS_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEL_TYPE_CANVAS_ITEM))
#define EEL_IS_CANVAS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEL_TYPE_CANVAS_ITEM))
#define EEL_CANVAS_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEL_TYPE_CANVAS_ITEM, EelCanvasItemClass))
struct _EelCanvasItem {
GInitiallyUnowned object;
/* Parent canvas for this item */
EelCanvas *canvas;
/* Parent canvas group for this item (a EelCanvasGroup) */
EelCanvasItem *parent;
/* Bounding box for this item (in canvas coordinates) */
double x1, y1, x2, y2;
/* Object flags */
guint flags;
};
struct _EelCanvasItemClass {
GInitiallyUnownedClass parent_class;
void (* destroy) (EelCanvasItem *item);
/* Tell the item to update itself. The flags are from the update flags
* defined above. The item should update its internal state from its
* queued state, and recompute and request its repaint area. The
* update method also recomputes the bounding box of the item.
*/
void (* update) (EelCanvasItem *item, double i2w_dx, double i2w_dy, int flags);
/* Realize an item -- create GCs, etc. */
void (* realize) (EelCanvasItem *item);
/* Unrealize an item */
void (* unrealize) (EelCanvasItem *item);
/* Map an item - normally only need by items with their own GdkWindows */
void (* map) (EelCanvasItem *item);
/* Unmap an item */
void (* unmap) (EelCanvasItem *item);
/* Draw an item of this type. (x, y) are the upper-left canvas pixel
* coordinates of the drawable, a temporary pixmap, where things get
* drawn. (width, height) are the dimensions of the drawable.
*/
void (* draw) (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region);
/* Calculate the distance from an item to the specified point. It also
* returns a canvas item which is the item itself in the case of the
* object being an actual leaf item, or a child in case of the object
* being a canvas group. (cx, cy) are the canvas pixel coordinates that
* correspond to the item-relative coordinates (x, y).
*/
double (* point) (EelCanvasItem *item, double x, double y, int cx, int cy,
EelCanvasItem **actual_item);
void (* translate) (EelCanvasItem *item, double dx, double dy);
/* Fetch the item's bounding box (need not be exactly tight). This
* should be in item-relative coordinates.
*/
void (* bounds) (EelCanvasItem *item, double *x1, double *y1, double *x2, double *y2);
/* Signal: an event ocurred for an item of this type. The (x, y)
* coordinates are in the canvas world coordinate system.
*/
gboolean (* event) (EelCanvasItem *item, GdkEvent *event);
/* Reserved for future expansion */
gpointer spare_vmethods [4];
};
/* Standard Gtk function */
GType eel_canvas_item_get_type (void) G_GNUC_CONST;
/* Create a canvas item using the standard Gtk argument mechanism. The item is
* automatically inserted at the top of the specified canvas group. The last
* argument must be a NULL pointer.
*/
EelCanvasItem *eel_canvas_item_new (EelCanvasGroup *parent, GType type,
const gchar *first_arg_name, ...);
void eel_canvas_item_destroy (EelCanvasItem *item);
/* Configure an item using the standard Gtk argument mechanism. The last
* argument must be a NULL pointer.
*/
void eel_canvas_item_set (EelCanvasItem *item, const gchar *first_arg_name, ...);
/* Move an item by the specified amount */
void eel_canvas_item_move (EelCanvasItem *item, double dx, double dy);
/* Raise an item in the z-order of its parent group by the specified number of
* positions.
*/
void eel_canvas_item_raise (EelCanvasItem *item, int positions);
/* Lower an item in the z-order of its parent group by the specified number of
* positions.
*/
void eel_canvas_item_lower (EelCanvasItem *item, int positions);
/* Raise an item to the top of its parent group's z-order. */
void eel_canvas_item_raise_to_top (EelCanvasItem *item);
/* Lower an item to the bottom of its parent group's z-order */
void eel_canvas_item_lower_to_bottom (EelCanvasItem *item);
/* Send an item behind another item */
void eel_canvas_item_send_behind (EelCanvasItem *item,
EelCanvasItem *behind_item);
/* Show an item (make it visible). If the item is already shown, it has no
* effect.
*/
void eel_canvas_item_show (EelCanvasItem *item);
/* Hide an item (make it invisible). If the item is already invisible, it has
* no effect.
*/
void eel_canvas_item_hide (EelCanvasItem *item);
/* Grab the seat for the specified item. Only the events in event_mask will be
* reported. If cursor is non-NULL, it will be used during the duration of the
* grab. event is the event, triggering the grab. Returns the same values as gdk_seat_grab().
*/
GdkGrabStatus eel_canvas_item_grab (EelCanvasItem *item,
GdkEventMask event_mask,
GdkCursor *cursor,
const GdkEvent* event);
/* Ungrabs the seat -- the specified item must be the same that was passed to
* eel_canvas_item_grab().
*/
void eel_canvas_item_ungrab (EelCanvasItem *item);
/* These functions convert from a coordinate system to another. "w" is world
* coordinates and "i" is item coordinates.
*/
void eel_canvas_item_i2w (EelCanvasItem *item, double *x, double *y);
/* Fetch the bounding box of the item. The bounding box may not be exactly
* tight, but the canvas items will do the best they can. The returned bounding
* box is in the coordinate system of the item's parent.
*/
void eel_canvas_item_get_bounds (EelCanvasItem *item,
double *x1, double *y1, double *x2, double *y2);
/* Request that the update method eventually get called. This should be used
* only by item implementations.
*/
void eel_canvas_item_request_update (EelCanvasItem *item);
/* Request a redraw of the bounding box of the canvas item */
void eel_canvas_item_request_redraw (EelCanvasItem *item);
/* EelCanvasGroup - a group of canvas items
*
* A group is a node in the hierarchical tree of groups/items inside a canvas.
* Groups serve to give a logical structure to the items.
*
* Consider a circuit editor application that uses the canvas for its schematic
* display. Hierarchically, there would be canvas groups that contain all the
* components needed for an "adder", for example -- this includes some logic
* gates as well as wires. You can move stuff around in a convenient way by
* doing a eel_canvas_item_move() of the hierarchical groups -- to move an
* adder, simply move the group that represents the adder.
*
* The following arguments are available:
*
* name type read/write description
* --------------------------------------------------------------------------------
* x double RW X coordinate of group's origin
* y double RW Y coordinate of group's origin
*/
#define EEL_TYPE_CANVAS_GROUP (eel_canvas_group_get_type ())
#define EEL_CANVAS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEL_TYPE_CANVAS_GROUP, EelCanvasGroup))
#define EEL_CANVAS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEL_TYPE_CANVAS_GROUP, EelCanvasGroupClass))
#define EEL_IS_CANVAS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEL_TYPE_CANVAS_GROUP))
#define EEL_IS_CANVAS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEL_TYPE_CANVAS_GROUP))
#define EEL_CANVAS_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEL_TYPE_CANVAS_GROUP, EelCanvasGroupClass))
struct _EelCanvasGroup {
EelCanvasItem item;
double xpos, ypos;
/* Children of the group */
GList *item_list;
GList *item_list_end;
};
struct _EelCanvasGroupClass {
EelCanvasItemClass parent_class;
};
/* Standard Gtk function */
GType eel_canvas_group_get_type (void) G_GNUC_CONST;
/*** EelCanvas ***/
#define EEL_TYPE_CANVAS (eel_canvas_get_type ())
#define EEL_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEL_TYPE_CANVAS, EelCanvas))
#define EEL_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEL_TYPE_CANVAS, EelCanvasClass))
#define EEL_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEL_TYPE_CANVAS))
#define EEL_IS_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEL_TYPE_CANVAS))
#define EEL_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEL_TYPE_CANVAS, EelCanvasClass))
struct _EelCanvas {
GtkLayout layout;
/* Root canvas group */
EelCanvasItem *root;
/* The item containing the mouse pointer, or NULL if none */
EelCanvasItem *current_item;
/* Item that is about to become current (used to track deletions and such) */
EelCanvasItem *new_current_item;
/* Item that holds a pointer grab, or NULL if none */
EelCanvasItem *grabbed_item;
/* If non-NULL, the currently focused item */
EelCanvasItem *focused_item;
/* Event on which selection of current item is based */
GdkEvent pick_event;
/* Scrolling region */
double scroll_x1, scroll_y1;
double scroll_x2, scroll_y2;
/* Scaling factor to be used for display */
double pixels_per_unit;
/* Idle handler ID */
guint idle_id;
/* Signal handler ID for destruction of the root item */
gulong root_destroy_id;
/* Internal pixel offsets when zoomed out */
int zoom_xofs, zoom_yofs;
/* Last known modifier state, for deferred repick when a button is down */
int state;
/* Event mask specified when grabbing an item */
guint grabbed_event_mask;
/* Tolerance distance for picking items */
int close_enough;
/* Whether the canvas should center the canvas in the middle of
* the window if the scroll region is smaller than the window */
unsigned int center_scroll_region : 1;
/* Whether items need update at next idle loop iteration */
unsigned int need_update : 1;
/* Are we in the midst of an update */
unsigned int doing_update : 1;
/* Whether the canvas needs redrawing at the next idle loop iteration */
unsigned int need_redraw : 1;
/* Whether current item will be repicked at next idle loop iteration */
unsigned int need_repick : 1;
/* For use by internal pick_current_item() function */
unsigned int left_grabbed_item : 1;
/* For use by internal pick_current_item() function */
unsigned int in_repick : 1;
};
struct _EelCanvasClass {
GtkLayoutClass parent_class;
/* Private Virtual methods for groping the canvas inside bonobo */
void (* request_update) (EelCanvas *canvas);
/* Reserved for future expansion */
gpointer spare_vmethods [4];
};
/* Standard Gtk function */
GType eel_canvas_get_type (void) G_GNUC_CONST;
/* Creates a new canvas. You should check that the canvas is created with the
* proper visual and colormap. Any visual will do unless you intend to insert
* gdk_imlib images into it, in which case you should use the gdk_imlib visual.
*
* You should call eel_canvas_set_scroll_region() soon after calling this
* function to set the desired scrolling limits for the canvas.
*/
GtkWidget *eel_canvas_new (void);
/* Returns the root canvas item group of the canvas */
EelCanvasGroup *eel_canvas_root (EelCanvas *canvas);
/* Sets the limits of the scrolling region, in world coordinates */
void eel_canvas_set_scroll_region (EelCanvas *canvas,
double x1, double y1, double x2, double y2);
/* Gets the limits of the scrolling region, in world coordinates */
void eel_canvas_get_scroll_region (EelCanvas *canvas,
double *x1, double *y1, double *x2, double *y2);
/* Sets the number of pixels that correspond to one unit in world coordinates */
void eel_canvas_set_pixels_per_unit (EelCanvas *canvas, double n);
/* Returns the scroll offsets of the canvas in canvas pixel coordinates. You
* can specify NULL for any of the values, in which case that value will not be
* queried.
*/
void eel_canvas_get_scroll_offsets (EelCanvas *canvas, int *cx, int *cy);
/* For use only by item type implementations. Request that the canvas
* eventually redraw the specified region, specified in canvas pixel
* coordinates. The region contains (x1, y1) but not (x2, y2).
*/
void eel_canvas_request_redraw (EelCanvas *canvas, int x1, int y1, int x2, int y2);
/* These functions convert from a coordinate system to another. "w" is world
* coordinates, "c" is canvas pixel coordinates (pixel coordinates that are
* (0,0) for the upper-left scrolling limit and something else for the
* lower-left scrolling limit).
*/
void eel_canvas_w2c_rect_d (EelCanvas *canvas,
double *x1, double *y1,
double *x2, double *y2);
void eel_canvas_w2c (EelCanvas *canvas, double wx, double wy, int *cx, int *cy);
void eel_canvas_w2c_d (EelCanvas *canvas, double wx, double wy, double *cx, double *cy);
void eel_canvas_c2w (EelCanvas *canvas, int cx, int cy, double *wx, double *wy);
/* This function takes in coordinates relative to the GTK_LAYOUT
* (canvas)->bin_window and converts them to world coordinates.
* These days canvas coordinates and window coordinates are the same, but
* these are left for backwards compat reasons.
*/
void eel_canvas_window_to_world (EelCanvas *canvas,
double winx, double winy, double *worldx, double *worldy);
/* This is the inverse of eel_canvas_window_to_world() */
void eel_canvas_world_to_window (EelCanvas *canvas,
double worldx, double worldy, double *winx, double *winy);
/* Accessible implementation */
GType eel_canvas_accessible_get_type (void);
typedef struct _EelCanvasAccessible EelCanvasAccessible;
struct _EelCanvasAccessible
{
GtkContainerAccessible parent;
};
typedef struct _EelCanvasAccessibleClass EelCanvasAccessibleClass;
struct _EelCanvasAccessibleClass
{
GtkContainerAccessibleClass parent_class;
};
GType eel_canvas_item_accessible_get_type (void);
typedef struct _EelCanvasItemAccessible EelCanvasItemAccessible;
struct _EelCanvasItemAccessible
{
GtkAccessible parent;
};
typedef struct _EelCanvasItemAccessibleClass EelCanvasItemAccessibleClass;
struct _EelCanvasItemAccessibleClass
{
GtkAccessibleClass parent_class;
};
G_END_DECLS

View file

@ -1,8 +1,6 @@
libeel_2_sources = [
'eel-art-extensions.h',
'eel-art-extensions.c',
'eel-canvas.h',
'eel-canvas.c',
'eel-debug.h',
'eel-debug.c',
'eel-glib-extensions.h',

View file

@ -4,7 +4,6 @@ data/nautilus-autorun-software.desktop.in
data/org.gnome.Nautilus.appdata.xml.in.in
data/org.gnome.Nautilus.desktop.in.in
data/org.gnome.nautilus.gschema.xml
eel/eel-canvas.c
eel/eel-gtk-extensions.c
eel/eel-stock-dialogs.c
eel/eel-vfs-extensions.c
@ -23,11 +22,6 @@ src/nautilus-autorun-software.c
src/nautilus-batch-rename-dialog.c
src/nautilus-batch-rename-dialog.h
src/nautilus-bookmark.c
src/nautilus-canvas-container.c
src/nautilus-canvas-dnd.c
src/nautilus-canvas-item.c
src/nautilus-canvas-view.c
src/nautilus-canvas-view-container.c
src/nautilus-clipboard.c
src/nautilus-column-chooser.c
src/nautilus-column-utilities.c

View file

@ -72,10 +72,6 @@ libnautilus_sources = [
'nautilus-application.h',
'nautilus-bookmark-list.c',
'nautilus-bookmark-list.h',
'nautilus-canvas-view.c',
'nautilus-canvas-view.h',
'nautilus-canvas-view-container.c',
'nautilus-canvas-view-container.h',
'nautilus-dbus-manager.c',
'nautilus-dbus-manager.h',
'nautilus-error-reporting.c',
@ -147,13 +143,6 @@ libnautilus_sources = [
'nautilus-x-content-bar.h',
'nautilus-bookmark.c',
'nautilus-bookmark.h',
'nautilus-canvas-container.c',
'nautilus-canvas-container.h',
'nautilus-canvas-dnd.c',
'nautilus-canvas-dnd.h',
'nautilus-canvas-item.c',
'nautilus-canvas-item.h',
'nautilus-canvas-private.h',
'nautilus-clipboard.c',
'nautilus-clipboard.h',
'nautilus-column-chooser.c',
@ -234,8 +223,6 @@ libnautilus_sources = [
'nautilus-search-engine-simple.h',
'nautilus-search-hit.c',
'nautilus-search-hit.h',
'nautilus-selection-canvas-item.c',
'nautilus-selection-canvas-item.h',
'nautilus-signaller.h',
'nautilus-signaller.c',
'nautilus-query.c',

File diff suppressed because it is too large Load diff

View file

@ -1,295 +0,0 @@
/* gnome-canvas-container.h - Canvas container widget.
Copyright (C) 1999, 2000 Free Software Foundation
Copyright (C) 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
see <http://www.gnu.org/licenses/>.
Authors: Ettore Perazzoli <ettore@gnu.org>, Darin Adler <darin@bentspoon.com>
*/
#pragma once
#include <eel/eel-canvas.h>
#include "nautilus-types.h"
#define NAUTILUS_TYPE_CANVAS_CONTAINER nautilus_canvas_container_get_type()
#define NAUTILUS_CANVAS_CONTAINER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_CANVAS_CONTAINER, NautilusCanvasContainer))
#define NAUTILUS_CANVAS_CONTAINER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_CANVAS_CONTAINER, NautilusCanvasContainerClass))
#define NAUTILUS_IS_CANVAS_CONTAINER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_CANVAS_CONTAINER))
#define NAUTILUS_IS_CANVAS_CONTAINER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_CANVAS_CONTAINER))
#define NAUTILUS_CANVAS_CONTAINER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_CANVAS_CONTAINER, NautilusCanvasContainerClass))
#define NAUTILUS_CANVAS_ICON_DATA(pointer) \
((NautilusCanvasIconData *) (pointer))
typedef struct NautilusCanvasIconData NautilusCanvasIconData;
typedef void (* NautilusCanvasCallback) (NautilusCanvasIconData *icon_data,
gpointer callback_data);
typedef struct {
int x;
int y;
double scale;
} NautilusCanvasPosition;
#define NAUTILUS_CANVAS_CONTAINER_TYPESELECT_FLUSH_DELAY 1000000
typedef struct _NautilusCanvasContainer NautilusCanvasContainer;
typedef struct NautilusCanvasContainerDetails NautilusCanvasContainerDetails;
struct _NautilusCanvasContainer {
EelCanvas canvas;
NautilusCanvasContainerDetails *details;
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NautilusCanvasContainer, g_object_unref)
typedef struct {
EelCanvasClass parent_slot;
/* Operations on the container. */
int (* button_press) (NautilusCanvasContainer *container,
GdkEventButton *event);
void (* context_click_background) (NautilusCanvasContainer *container,
GdkEventButton *event);
void (* middle_click) (NautilusCanvasContainer *container,
GdkEventButton *event);
/* Operations on icons. */
void (* activate) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
void (* activate_alternate) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
void (* activate_previewer) (NautilusCanvasContainer *container,
GList *files,
GArray *locations);
void (* context_click_selection) (NautilusCanvasContainer *container,
GdkEventButton *event);
void (* move_copy_items) (NautilusCanvasContainer *container,
const GList *item_uris,
const char *target_uri,
GdkDragAction action,
int x,
int y);
void (* handle_netscape_url) (NautilusCanvasContainer *container,
const char *url,
const char *target_uri,
GdkDragAction action,
int x,
int y);
void (* handle_uri_list) (NautilusCanvasContainer *container,
const char *uri_list,
const char *target_uri,
GdkDragAction action,
int x,
int y);
void (* handle_text) (NautilusCanvasContainer *container,
const char *text,
const char *target_uri,
GdkDragAction action,
int x,
int y);
void (* handle_raw) (NautilusCanvasContainer *container,
char *raw_data,
int length,
const char *target_uri,
const char *direct_save_uri,
GdkDragAction action,
int x,
int y);
void (* handle_hover) (NautilusCanvasContainer *container,
const char *target_uri);
/* Queries on the container for subclass/client.
* These must be implemented. The default "do nothing" is not good enough.
*/
char * (* get_container_uri) (NautilusCanvasContainer *container);
/* Queries on icons for subclass/client.
* These must be implemented. The default "do nothing" is not
* good enough, these are _not_ signals.
*/
NautilusIconInfo *(* get_icon_images) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data,
int canvas_size,
gboolean for_drag_accept);
void (* get_icon_text) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data,
char **editable_text,
char **additional_text,
gboolean include_invisible);
char * (* get_icon_description) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
int (* compare_icons) (NautilusCanvasContainer *container,
NautilusCanvasIconData *canvas_a,
NautilusCanvasIconData *canvas_b);
int (* compare_icons_by_name) (NautilusCanvasContainer *container,
NautilusCanvasIconData *canvas_a,
NautilusCanvasIconData *canvas_b);
void (* prioritize_thumbnailing) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
/* Queries on icons for subclass/client.
* These must be implemented => These are signals !
* The default "do nothing" is not good enough.
*/
gboolean (* get_stored_icon_position) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data,
NautilusCanvasPosition *position);
char * (* get_icon_uri) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
char * (* get_icon_activation_uri) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
char * (* get_icon_drop_target_uri) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
/* If canvas data is NULL, the layout timestamp of the container should be retrieved.
* That is the time when the container displayed a fully loaded directory with
* all canvas positions assigned.
*
* If canvas data is not NULL, the position timestamp of the canvas should be retrieved.
* That is the time when the file (i.e. canvas data payload) was last displayed in a
* fully loaded directory with all canvas positions assigned.
*/
gboolean (* get_stored_layout_timestamp) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data,
time_t *time);
/* If canvas data is NULL, the layout timestamp of the container should be stored.
* If canvas data is not NULL, the position timestamp of the container should be stored.
*/
gboolean (* store_layout_timestamp) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data,
const time_t *time);
/* Notifications for the whole container. */
void (* band_select_started) (NautilusCanvasContainer *container);
void (* band_select_ended) (NautilusCanvasContainer *container);
void (* selection_changed) (NautilusCanvasContainer *container);
void (* layout_changed) (NautilusCanvasContainer *container);
/* Notifications for icons. */
void (* icon_position_changed) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data,
const NautilusCanvasPosition *position);
int (* preview) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data,
gboolean start_flag);
void (* icon_added) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
void (* icon_removed) (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
void (* cleared) (NautilusCanvasContainer *container);
gboolean (* start_interactive_search) (NautilusCanvasContainer *container);
} NautilusCanvasContainerClass;
/* GtkObject */
GType nautilus_canvas_container_get_type (void);
GtkWidget * nautilus_canvas_container_new (void);
/* adding, removing, and managing icons */
void nautilus_canvas_container_clear (NautilusCanvasContainer *view);
gboolean nautilus_canvas_container_add (NautilusCanvasContainer *view,
NautilusCanvasIconData *data);
void nautilus_canvas_container_layout_now (NautilusCanvasContainer *container);
gboolean nautilus_canvas_container_remove (NautilusCanvasContainer *view,
NautilusCanvasIconData *data);
void nautilus_canvas_container_for_each (NautilusCanvasContainer *view,
NautilusCanvasCallback callback,
gpointer callback_data);
void nautilus_canvas_container_request_update (NautilusCanvasContainer *view,
NautilusCanvasIconData *data);
void nautilus_canvas_container_request_update_all (NautilusCanvasContainer *container);
void nautilus_canvas_container_reveal (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
gboolean nautilus_canvas_container_is_empty (NautilusCanvasContainer *container);
NautilusCanvasIconData *nautilus_canvas_container_get_first_visible_icon (NautilusCanvasContainer *container);
NautilusCanvasIconData *nautilus_canvas_container_get_focused_icon (NautilusCanvasContainer *container);
GdkRectangle *nautilus_canvas_container_get_icon_bounding_box (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
void nautilus_canvas_container_scroll_to_canvas (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
void nautilus_canvas_container_begin_loading (NautilusCanvasContainer *container);
void nautilus_canvas_container_end_loading (NautilusCanvasContainer *container,
gboolean all_icons_added);
void nautilus_canvas_container_sort (NautilusCanvasContainer *container);
void nautilus_canvas_container_freeze_icon_positions (NautilusCanvasContainer *container);
int nautilus_canvas_container_get_max_layout_lines (NautilusCanvasContainer *container);
int nautilus_canvas_container_get_max_layout_lines_for_pango (NautilusCanvasContainer *container);
void nautilus_canvas_container_set_highlighted_for_clipboard (NautilusCanvasContainer *container,
GList *clipboard_canvas_data);
/* operations on all icons */
void nautilus_canvas_container_unselect_all (NautilusCanvasContainer *view);
void nautilus_canvas_container_select_all (NautilusCanvasContainer *view);
void nautilus_canvas_container_select_first (NautilusCanvasContainer *view);
void nautilus_canvas_container_preview_selection_event (NautilusCanvasContainer *view,
GtkDirectionType direction);
/* operations on the selection */
GList * nautilus_canvas_container_get_selection (NautilusCanvasContainer *view);
void nautilus_canvas_container_invert_selection (NautilusCanvasContainer *view);
void nautilus_canvas_container_set_selection (NautilusCanvasContainer *view,
GList *selection);
GArray * nautilus_canvas_container_get_selected_icon_locations (NautilusCanvasContainer *view);
/* options */
NautilusCanvasZoomLevel nautilus_canvas_container_get_zoom_level (NautilusCanvasContainer *view);
void nautilus_canvas_container_set_zoom_level (NautilusCanvasContainer *view,
int new_zoom_level);
void nautilus_canvas_container_set_single_click_mode (NautilusCanvasContainer *container,
gboolean single_click_mode);
void nautilus_canvas_container_enable_linger_selection (NautilusCanvasContainer *view,
gboolean enable);
void nautilus_canvas_container_set_font (NautilusCanvasContainer *container,
const char *font);
void nautilus_canvas_container_set_margins (NautilusCanvasContainer *container,
int left_margin,
int right_margin,
int top_margin,
int bottom_margin);
char* nautilus_canvas_container_get_icon_description (NautilusCanvasContainer *container,
NautilusCanvasIconData *data);
gboolean nautilus_canvas_container_is_layout_rtl (NautilusCanvasContainer *container);
gboolean nautilus_canvas_container_get_store_layout_timestamps (NautilusCanvasContainer *container);
void nautilus_canvas_container_widget_to_file_operation_position (NautilusCanvasContainer *container,
GdkPoint *position);
guint nautilus_canvas_container_get_icon_size_for_zoom_level (NautilusCanvasZoomLevel zoom_level);
#define CANVAS_WIDTH(container,allocation) (allocation.width \
/ EEL_CANVAS (container)->pixels_per_unit)
#define CANVAS_HEIGHT(container,allocation) (allocation.height \
/ EEL_CANVAS (container)->pixels_per_unit)

File diff suppressed because it is too large Load diff

View file

@ -1,56 +0,0 @@
/* nautilus-canvas-dnd.h - Drag & drop handling for the canvas container widget.
Copyright (C) 1999, 2000 Free Software Foundation
Copyright (C) 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
see <http://www.gnu.org/licenses/>.
Authors: Ettore Perazzoli <ettore@gnu.org>,
Darin Adler <darin@bentspoon.com>,
Andy Hertzfeld <andy@eazel.com>
*/
#pragma once
#include "nautilus-canvas-container.h"
#include "nautilus-dnd.h"
/* DnD-related information. */
typedef struct {
/* inherited drag info context */
NautilusDragInfo drag_info;
gboolean highlighted;
char *target_uri;
/* Shadow for the icons being dragged. */
EelCanvasItem *shadow;
guint hover_id;
} NautilusCanvasDndInfo;
void nautilus_canvas_dnd_init (NautilusCanvasContainer *container);
void nautilus_canvas_dnd_fini (NautilusCanvasContainer *container);
void nautilus_canvas_dnd_begin_drag (NautilusCanvasContainer *container,
GdkDragAction actions,
gint button,
GdkEventMotion *event,
int start_x,
int start_y);
void nautilus_canvas_dnd_end_drag (NautilusCanvasContainer *container);
NautilusDragInfo* nautilus_canvas_dnd_get_drag_source_data (NautilusCanvasContainer *container,
GdkDragContext *context);

File diff suppressed because it is too large Load diff

View file

@ -1,90 +0,0 @@
/* Nautilus - Canvas item class for canvas container.
*
* Copyright (C) 2000 Eazel, Inc.
*
* Author: Andy Hertzfeld <andy@eazel.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <eel/eel-canvas.h>
#include <eel/eel-art-extensions.h>
G_BEGIN_DECLS
#define NAUTILUS_TYPE_CANVAS_ITEM nautilus_canvas_item_get_type()
#define NAUTILUS_CANVAS_ITEM(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_CANVAS_ITEM, NautilusCanvasItem))
#define NAUTILUS_CANVAS_ITEM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_CANVAS_ITEM, NautilusCanvasItemClass))
#define NAUTILUS_IS_CANVAS_ITEM(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_CANVAS_ITEM))
#define NAUTILUS_IS_CANVAS_ITEM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_CANVAS_ITEM))
#define NAUTILUS_CANVAS_ITEM_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_CANVAS_ITEM, NautilusCanvasItemClass))
typedef struct NautilusCanvasItem NautilusCanvasItem;
typedef struct NautilusCanvasItemClass NautilusCanvasItemClass;
typedef struct NautilusCanvasItemDetails NautilusCanvasItemDetails;
struct NautilusCanvasItem {
EelCanvasItem item;
NautilusCanvasItemDetails *details;
gpointer user_data;
};
struct NautilusCanvasItemClass {
EelCanvasItemClass parent_class;
};
/* not namespaced due to their length */
typedef enum {
BOUNDS_USAGE_FOR_LAYOUT,
BOUNDS_USAGE_FOR_ENTIRE_ITEM,
BOUNDS_USAGE_FOR_DISPLAY
} NautilusCanvasItemBoundsUsage;
/* GObject */
GType nautilus_canvas_item_get_type (void);
/* attributes */
void nautilus_canvas_item_set_image (NautilusCanvasItem *item,
GdkPixbuf *image);
cairo_surface_t* nautilus_canvas_item_get_drag_surface (NautilusCanvasItem *item);
void nautilus_canvas_item_set_emblems (NautilusCanvasItem *item,
GList *emblem_pixbufs);
/* geometry and hit testing */
gboolean nautilus_canvas_item_hit_test_rectangle (NautilusCanvasItem *item,
EelIRect canvas_rect);
void nautilus_canvas_item_invalidate_label (NautilusCanvasItem *item);
void nautilus_canvas_item_invalidate_label_size (NautilusCanvasItem *item);
EelDRect nautilus_canvas_item_get_icon_rectangle (const NautilusCanvasItem *item);
void nautilus_canvas_item_get_bounds_for_layout (NautilusCanvasItem *item,
double *x1, double *y1, double *x2, double *y2);
void nautilus_canvas_item_get_bounds_for_entire_item (NautilusCanvasItem *item,
double *x1, double *y1, double *x2, double *y2);
void nautilus_canvas_item_update_bounds (NautilusCanvasItem *item,
double i2w_dx, double i2w_dy);
void nautilus_canvas_item_set_is_visible (NautilusCanvasItem *item,
gboolean visible);
/* whether the entire label text must be visible at all times */
void nautilus_canvas_item_set_entire_text (NautilusCanvasItem *canvas_item,
gboolean entire_text);
G_END_DECLS

View file

@ -1,223 +0,0 @@
/* gnome-canvas-container-private.h
Copyright (C) 1999, 2000 Free Software Foundation
Copyright (C) 2000 Eazel, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
see <http://www.gnu.org/licenses/>.
Author: Ettore Perazzoli <ettore@gnu.org>
*/
#pragma once
#include <eel/eel-glib-extensions.h>
#include "nautilus-canvas-item.h"
#include "nautilus-canvas-container.h"
#include "nautilus-canvas-dnd.h"
/* An Icon. */
typedef struct {
/* Object represented by this icon. */
NautilusCanvasIconData *data;
/* Canvas item for the icon. */
NautilusCanvasItem *item;
/* X/Y coordinates. */
double x, y;
/*
* In RTL mode x is RTL x position, we use saved_ltr_x for
* keeping track of x value before it gets converted into
* RTL value, this is used for saving the icon position
* to the nautilus metafile.
*/
double saved_ltr_x;
/* Position in the view */
int position;
/* Whether this item is selected. */
eel_boolean_bit is_selected : 1;
/* Whether this item was selected before rubberbanding. */
eel_boolean_bit was_selected_before_rubberband : 1;
/* Whether this item is visible in the view. */
eel_boolean_bit is_visible : 1;
} NautilusCanvasIcon;
/* Private NautilusCanvasContainer members. */
typedef struct {
gboolean active;
double start_x, start_y;
EelCanvasItem *selection_rectangle;
GdkDevice *device;
guint timer_id;
guint prev_x, prev_y;
int last_adj_x;
int last_adj_y;
} NautilusCanvasRubberbandInfo;
typedef enum {
DRAG_STATE_INITIAL,
DRAG_STATE_MOVE_OR_COPY,
DRAG_STATE_STRETCH
} DragState;
typedef struct {
/* Pointer position in canvas coordinates. */
int pointer_x, pointer_y;
/* Icon top, left, and size in canvas coordinates. */
int icon_x, icon_y;
guint icon_size;
} StretchState;
typedef enum {
AXIS_NONE,
AXIS_HORIZONTAL,
AXIS_VERTICAL
} Axis;
enum {
LABEL_COLOR,
LABEL_COLOR_HIGHLIGHT,
LABEL_COLOR_ACTIVE,
LABEL_COLOR_PRELIGHT,
LABEL_INFO_COLOR,
LABEL_INFO_COLOR_HIGHLIGHT,
LABEL_INFO_COLOR_ACTIVE,
LAST_LABEL_COLOR
};
struct NautilusCanvasContainerDetails {
/* List of icons. */
GList *icons;
GList *new_icons;
GList *selection;
GHashTable *icon_set;
/* Currently focused icon for accessibility. */
NautilusCanvasIcon *focus;
gboolean keyboard_focus;
/* Starting icon for keyboard rubberbanding. */
NautilusCanvasIcon *keyboard_rubberband_start;
/* Last highlighted drop target. */
NautilusCanvasIcon *drop_target;
/* Rubberbanding status. */
NautilusCanvasRubberbandInfo rubberband_info;
/* Timeout used to make a selected icon fully visible after a short
* period of time. (The timeout is needed to make sure
* double-clicking still works.)
*/
guint keyboard_icon_reveal_timer_id;
NautilusCanvasIcon *keyboard_icon_to_reveal;
/* Used to coalesce selection changed signals in some cases */
guint selection_changed_id;
/* If a request is made to reveal an unpositioned icon we remember
* it and reveal it once it gets positioned (in relayout).
*/
NautilusCanvasIcon *pending_icon_to_reveal;
/* Remembered information about the start of the current event. */
guint32 button_down_time;
/* Drag state. Valid only if drag_button is non-zero. */
guint drag_button;
NautilusCanvasIcon *drag_icon;
int drag_x, drag_y;
DragState drag_state;
gboolean drag_started;
gboolean icon_selected_on_button_down;
gboolean double_clicked;
NautilusCanvasIcon *double_click_icon[2]; /* Both clicks in a double click need to be on the same icon */
guint double_click_button[2];
NautilusCanvasIcon *range_selection_base_icon;
/* Idle ID. */
guint idle_id;
/* Align idle id */
guint align_idle_id;
/* DnD info. */
NautilusCanvasDndInfo *dnd_info;
NautilusDragInfo *dnd_source_info;
/* zoom level */
int zoom_level;
/* specific fonts used to draw labels */
char *font;
/* State used so arrow keys don't wander if icons aren't lined up.
*/
int arrow_key_start_x;
int arrow_key_start_y;
GtkDirectionType arrow_key_direction;
/* Mode settings. */
gboolean single_click_mode;
/* Set to TRUE after first allocation has been done */
gboolean has_been_allocated;
int size_allocation_count;
guint size_allocation_count_id;
/* a11y items used by canvas items */
guint a11y_item_action_idle_handler;
GQueue* a11y_item_action_queue;
eel_boolean_bit in_layout_now : 1;
eel_boolean_bit is_loading : 1;
eel_boolean_bit is_populating_container : 1;
eel_boolean_bit needs_resort : 1;
eel_boolean_bit selection_needs_resort : 1;
};
/* Private functions shared by mutiple files. */
NautilusCanvasIcon *nautilus_canvas_container_get_icon_by_uri (NautilusCanvasContainer *container,
const char *uri);
void nautilus_canvas_container_select_list_unselect_others (NautilusCanvasContainer *container,
GList *icons);
char * nautilus_canvas_container_get_icon_uri (NautilusCanvasContainer *container,
NautilusCanvasIcon *canvas);
char * nautilus_canvas_container_get_icon_activation_uri (NautilusCanvasContainer *container,
NautilusCanvasIcon *canvas);
char * nautilus_canvas_container_get_icon_drop_target_uri (NautilusCanvasContainer *container,
NautilusCanvasIcon *canvas);
void nautilus_canvas_container_update_icon (NautilusCanvasContainer *container,
NautilusCanvasIcon *canvas);
gboolean nautilus_canvas_container_scroll (NautilusCanvasContainer *container,
int delta_x,
int delta_y);
void nautilus_canvas_container_update_scroll_region (NautilusCanvasContainer *container);

View file

@ -1,377 +0,0 @@
/* fm-icon-container.h - the container widget for file manager icons
*
* Copyright (C) 2002 Sun Microsystems, Inc.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If not,
* see <http://www.gnu.org/licenses/>.
*
* Author: Michael Meeks <michael@ximian.com>
*/
#include "nautilus-canvas-view-container.h"
#include <eel/eel-glib-extensions.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
#include <string.h>
#include "nautilus-canvas-view.h"
#include "nautilus-enums.h"
#include "nautilus-global-preferences.h"
#include "nautilus-thumbnails.h"
struct _NautilusCanvasViewContainer
{
NautilusCanvasContainer parent;
NautilusCanvasView *view;
};
G_DEFINE_TYPE (NautilusCanvasViewContainer, nautilus_canvas_view_container, NAUTILUS_TYPE_CANVAS_CONTAINER);
static GQuark attribute_none_q;
static NautilusCanvasView *
get_canvas_view (NautilusCanvasContainer *container)
{
/* Type unsafe comparison for performance */
return ((NautilusCanvasViewContainer *) container)->view;
}
static NautilusIconInfo *
nautilus_canvas_view_container_get_icon_images (NautilusCanvasContainer *container,
NautilusCanvasIconData *data,
int size,
gboolean for_drag_accept)
{
NautilusCanvasView *canvas_view;
NautilusFile *file;
NautilusFileIconFlags flags;
NautilusIconInfo *icon_info;
gint scale;
file = (NautilusFile *) data;
g_assert (NAUTILUS_IS_FILE (file));
canvas_view = get_canvas_view (container);
g_return_val_if_fail (canvas_view != NULL, NULL);
flags = NAUTILUS_FILE_ICON_FLAGS_USE_EMBLEMS |
NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS;
if (for_drag_accept)
{
flags |= NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT;
}
scale = gtk_widget_get_scale_factor (GTK_WIDGET (canvas_view));
icon_info = nautilus_file_get_icon (file, size, scale, flags);
return icon_info;
}
static char *
nautilus_canvas_view_container_get_icon_description (NautilusCanvasContainer *container,
NautilusCanvasIconData *data)
{
NautilusFile *file;
char *mime_type;
const char *description;
file = NAUTILUS_FILE (data);
g_assert (NAUTILUS_IS_FILE (file));
mime_type = nautilus_file_get_mime_type (file);
description = g_content_type_get_description (mime_type);
g_free (mime_type);
return g_strdup (description);
}
static void
nautilus_canvas_view_container_prioritize_thumbnailing (NautilusCanvasContainer *container,
NautilusCanvasIconData *data)
{
NautilusFile *file;
char *uri;
file = (NautilusFile *) data;
g_assert (NAUTILUS_IS_FILE (file));
if (nautilus_file_is_thumbnailing (file))
{
uri = nautilus_file_get_uri (file);
nautilus_thumbnail_prioritize (uri);
g_free (uri);
}
}
static GQuark *
get_quark_from_strv (gchar **value)
{
GQuark *quark;
int i;
quark = g_new0 (GQuark, g_strv_length (value) + 1);
for (i = 0; value[i] != NULL; ++i)
{
quark[i] = g_quark_from_string (value[i]);
}
return quark;
}
/*
* Get the preference for which caption text should appear
* beneath icons.
*/
static GQuark *
nautilus_canvas_view_container_get_icon_text_attributes_from_preferences (void)
{
GQuark *attributes;
gchar **value;
value = g_settings_get_strv (nautilus_icon_view_preferences,
NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
attributes = get_quark_from_strv (value);
g_strfreev (value);
/* We don't need to sanity check the attributes list even though it came
* from preferences.
*
* There are 2 ways that the values in the list could be bad.
*
* 1) The user picks "bad" values. "bad" values are those that result in
* there being duplicate attributes in the list.
*
* 2) Value stored in GConf are tampered with. Its possible physically do
* this by pulling the rug underneath GConf and manually editing its
* config files. Its also possible to use a third party GConf key
* editor and store garbage for the keys in question.
*
* Thankfully, the Nautilus preferences machinery deals with both of
* these cases.
*
* In the first case, the preferences dialog widgetry prevents
* duplicate attributes by making "bad" choices insensitive.
*
* In the second case, the preferences getter (and also the auto storage) for
* string_array values are always valid members of the enumeration associated
* with the preference.
*
* So, no more error checking on attributes is needed here and we can return
* a the auto stored value.
*/
return attributes;
}
static int
quarkv_length (GQuark *attributes)
{
int i;
i = 0;
while (attributes[i] != 0)
{
i++;
}
return i;
}
/**
* nautilus_canvas_view_get_icon_text_attribute_names:
*
* Get a list representing which text attributes should be displayed
* beneath an icon. The result is dependent on zoom level and possibly
* user configuration. Don't free the result.
* @view: NautilusCanvasView to query.
*
**/
static GQuark *
nautilus_canvas_view_container_get_icon_text_attribute_names (NautilusCanvasContainer *container,
int *len)
{
GQuark *attributes;
int piece_count;
const int pieces_by_level[] =
{
1, /* NAUTILUS_ZOOM_LEVEL_SMALL */
2, /* NAUTILUS_ZOOM_LEVEL_STANDARD */
3, /* NAUTILUS_ZOOM_LEVEL_LARGE */
3, /* NAUTILUS_ZOOM_LEVEL_LARGER */
};
piece_count = pieces_by_level[nautilus_canvas_container_get_zoom_level (container)];
attributes = nautilus_canvas_view_container_get_icon_text_attributes_from_preferences ();
*len = MIN (piece_count, quarkv_length (attributes));
return attributes;
}
/* This callback returns the text, both the editable part, and the
* part below that is not editable.
*/
static void
nautilus_canvas_view_container_get_icon_text (NautilusCanvasContainer *container,
NautilusCanvasIconData *data,
char **editable_text,
char **additional_text,
gboolean include_invisible)
{
GQuark *attributes;
char *text_array[4];
int i, j, num_attributes;
NautilusCanvasView *canvas_view;
NautilusFile *file;
gboolean use_additional;
file = NAUTILUS_FILE (data);
g_assert (NAUTILUS_IS_FILE (file));
g_assert (editable_text != NULL);
canvas_view = get_canvas_view (container);
g_return_if_fail (canvas_view != NULL);
use_additional = (additional_text != NULL);
/* Strip the suffix for nautilus object xml files. */
*editable_text = nautilus_file_get_display_name (file);
if (!use_additional)
{
return;
}
/* Find out what attributes go below each icon. */
attributes = nautilus_canvas_view_container_get_icon_text_attribute_names (container,
&num_attributes);
/* Get the attributes. */
j = 0;
for (i = 0; i < num_attributes; ++i)
{
char *text;
if (attributes[i] == attribute_none_q)
{
continue;
}
text = nautilus_file_get_string_attribute_q (file, attributes[i]);
if (text == NULL)
{
continue;
}
text_array[j++] = text;
}
text_array[j] = NULL;
/* Return them. */
if (j == 0)
{
*additional_text = NULL;
}
else if (j == 1)
{
/* Only one item, avoid the strdup + free */
*additional_text = text_array[0];
}
else
{
*additional_text = g_strjoinv ("\n", text_array);
for (i = 0; i < j; i++)
{
g_free (text_array[i]);
}
}
g_free (attributes);
}
static int
nautilus_canvas_view_container_compare_icons (NautilusCanvasContainer *container,
NautilusCanvasIconData *icon_a,
NautilusCanvasIconData *icon_b)
{
NautilusCanvasView *canvas_view;
canvas_view = get_canvas_view (container);
g_return_val_if_fail (canvas_view != NULL, 0);
/* Type unsafe comparisons for performance */
return nautilus_canvas_view_compare_files (canvas_view,
(NautilusFile *) icon_a,
(NautilusFile *) icon_b);
}
static int
nautilus_canvas_view_container_compare_icons_by_name (NautilusCanvasContainer *container,
NautilusCanvasIconData *icon_a,
NautilusCanvasIconData *icon_b)
{
return nautilus_file_compare_for_sort
(NAUTILUS_FILE (icon_a),
NAUTILUS_FILE (icon_b),
NAUTILUS_FILE_SORT_BY_DISPLAY_NAME,
FALSE, FALSE);
}
static void
nautilus_canvas_view_container_class_init (NautilusCanvasViewContainerClass *klass)
{
NautilusCanvasContainerClass *ic_class;
ic_class = &klass->parent_class;
attribute_none_q = g_quark_from_static_string ("none");
ic_class->get_icon_text = nautilus_canvas_view_container_get_icon_text;
ic_class->get_icon_images = nautilus_canvas_view_container_get_icon_images;
ic_class->get_icon_description = nautilus_canvas_view_container_get_icon_description;
ic_class->prioritize_thumbnailing = nautilus_canvas_view_container_prioritize_thumbnailing;
ic_class->compare_icons = nautilus_canvas_view_container_compare_icons;
ic_class->compare_icons_by_name = nautilus_canvas_view_container_compare_icons_by_name;
}
static void
nautilus_canvas_view_container_init (NautilusCanvasViewContainer *canvas_container)
{
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (canvas_container)),
GTK_STYLE_CLASS_VIEW);
}
NautilusCanvasContainer *
nautilus_canvas_view_container_construct (NautilusCanvasViewContainer *canvas_container,
NautilusCanvasView *view)
{
AtkObject *atk_obj;
g_return_val_if_fail (NAUTILUS_IS_CANVAS_VIEW (view), NULL);
canvas_container->view = view;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (canvas_container));
atk_object_set_name (atk_obj, _("Icon View"));
return NAUTILUS_CANVAS_CONTAINER (canvas_container);
}
NautilusCanvasContainer *
nautilus_canvas_view_container_new (NautilusCanvasView *view)
{
return nautilus_canvas_view_container_construct
(g_object_new (NAUTILUS_TYPE_CANVAS_VIEW_CONTAINER, NULL),
view);
}

View file

@ -1,35 +0,0 @@
/* fm-icon-container.h - the container widget for file manager icons
Copyright (C) 2002 Sun Microsystems, Inc.
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
see <http://www.gnu.org/licenses/>.
Author: Michael Meeks <michael@ximian.com>
*/
#pragma once
#include "nautilus-canvas-container.h"
#define NAUTILUS_TYPE_CANVAS_VIEW_CONTAINER nautilus_canvas_view_container_get_type()
G_DECLARE_FINAL_TYPE (NautilusCanvasViewContainer, nautilus_canvas_view_container,
NAUTILUS, CANVAS_VIEW_CONTAINER,
NautilusCanvasContainer)
NautilusCanvasContainer *nautilus_canvas_view_container_construct (NautilusCanvasViewContainer *canvas_container,
NautilusCanvasView *view);
NautilusCanvasContainer *nautilus_canvas_view_container_new (NautilusCanvasView *view);

File diff suppressed because it is too large Load diff

View file

@ -1,45 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-canvas-view.h - interface for canvas view of directory.
*
* Copyright (C) 2000 Eazel, Inc.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If not,
* see <http://www.gnu.org/licenses/>.
*
* Authors: John Sullivan <sullivan@eazel.com>
*
*/
#pragma once
#include "nautilus-files-view.h"
#include "nautilus-types.h"
G_BEGIN_DECLS
#define NAUTILUS_TYPE_CANVAS_VIEW nautilus_canvas_view_get_type()
G_DECLARE_FINAL_TYPE (NautilusCanvasView, nautilus_canvas_view, NAUTILUS, CANVAS_VIEW, NautilusFilesView)
int nautilus_canvas_view_compare_files (NautilusCanvasView *canvas_view,
NautilusFile *a,
NautilusFile *b);
NautilusFilesView * nautilus_canvas_view_new (NautilusWindowSlot *slot);
NautilusCanvasContainer * nautilus_canvas_view_get_canvas_container (NautilusCanvasView *view);
G_END_DECLS

View file

@ -41,7 +41,6 @@ static GDebugKey keys[] =
{ "DBus", NAUTILUS_DEBUG_DBUS },
{ "DirectoryView", NAUTILUS_DEBUG_DIRECTORY_VIEW },
{ "File", NAUTILUS_DEBUG_FILE },
{ "CanvasContainer", NAUTILUS_DEBUG_CANVAS_CONTAINER },
{ "IconView", NAUTILUS_DEBUG_GRID_VIEW },
{ "ListView", NAUTILUS_DEBUG_LIST_VIEW },
{ "Mime", NAUTILUS_DEBUG_MIME },

View file

@ -35,19 +35,18 @@ typedef enum {
NAUTILUS_DEBUG_DBUS = 1 << 4,
NAUTILUS_DEBUG_DIRECTORY_VIEW = 1 << 5,
NAUTILUS_DEBUG_FILE = 1 << 6,
NAUTILUS_DEBUG_CANVAS_CONTAINER = 1 << 7,
NAUTILUS_DEBUG_GRID_VIEW = 1 << 8,
NAUTILUS_DEBUG_LIST_VIEW = 1 << 9,
NAUTILUS_DEBUG_MIME = 1 << 10,
NAUTILUS_DEBUG_PLACES = 1 << 11,
NAUTILUS_DEBUG_PREVIEWER = 1 << 12,
NAUTILUS_DEBUG_SMCLIENT = 1 << 13,
NAUTILUS_DEBUG_WINDOW = 1 << 14,
NAUTILUS_DEBUG_UNDO = 1 << 15,
NAUTILUS_DEBUG_SEARCH = 1 << 16,
NAUTILUS_DEBUG_SEARCH_HIT = 1 << 17,
NAUTILUS_DEBUG_THUMBNAILS = 1 << 18,
NAUTILUS_DEBUG_TAG_MANAGER = 1 << 19,
NAUTILUS_DEBUG_GRID_VIEW = 1 << 7,
NAUTILUS_DEBUG_LIST_VIEW = 1 << 8,
NAUTILUS_DEBUG_MIME = 1 << 9,
NAUTILUS_DEBUG_PLACES = 1 << 10,
NAUTILUS_DEBUG_PREVIEWER = 1 << 11,
NAUTILUS_DEBUG_SMCLIENT = 1 << 12,
NAUTILUS_DEBUG_WINDOW = 1 << 13,
NAUTILUS_DEBUG_UNDO = 1 << 14,
NAUTILUS_DEBUG_SEARCH = 1 << 15,
NAUTILUS_DEBUG_SEARCH_HIT = 1 << 16,
NAUTILUS_DEBUG_THUMBNAILS = 1 << 17,
NAUTILUS_DEBUG_TAG_MANAGER = 1 << 18,
} DebugFlags;
void nautilus_debug_set_flags (DebugFlags flags);

View file

@ -32,7 +32,6 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "nautilus-file-utilities.h"
#include "nautilus-canvas-dnd.h"
#include <src/nautilus-list-view-dnd.h>
#include <stdio.h>
#include <string.h>

View file

@ -51,7 +51,6 @@
#include "nautilus-application.h"
#include "nautilus-batch-rename-dialog.h"
#include "nautilus-batch-rename-utilities.h"
#include "nautilus-canvas-view.h"
#include "nautilus-clipboard.h"
#include "nautilus-compress-dialog-controller.h"
#include "nautilus-directory.h"

View file

@ -1,554 +0,0 @@
/* Nautilus - Canvas item for floating selection.
*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* Copyright (C) 2011 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Authors: Federico Mena <federico@nuclecu.unam.mx>
* Cosimo Cecchi <cosimoc@redhat.com>
*/
#include <config.h>
#include "nautilus-selection-canvas-item.h"
#include <math.h>
enum
{
PROP_X1 = 1,
PROP_Y1,
PROP_X2,
PROP_Y2,
NUM_PROPERTIES
};
static GParamSpec *properties[NUM_PROPERTIES] = { NULL };
typedef struct
{
/*< public >*/
int x0, y0, x1, y1;
} Rect;
struct _NautilusSelectionCanvasItemDetails
{
Rect last_update_rect;
Rect last_outline_update_rect;
int last_outline_update_width;
double x1, y1, x2, y2; /* Corners of item */
};
G_DEFINE_TYPE (NautilusSelectionCanvasItem, nautilus_selection_canvas_item, EEL_TYPE_CANVAS_ITEM);
static void
nautilus_selection_canvas_item_draw (EelCanvasItem *item,
cairo_t *cr,
cairo_region_t *region)
{
NautilusSelectionCanvasItem *self;
double x1, y1, x2, y2;
int cx1, cy1, cx2, cy2;
double i2w_dx, i2w_dy;
GtkStyleContext *context;
self = NAUTILUS_SELECTION_CANVAS_ITEM (item);
/* Get canvas pixel coordinates */
i2w_dx = 0.0;
i2w_dy = 0.0;
eel_canvas_item_i2w (item, &i2w_dx, &i2w_dy);
x1 = self->priv->x1 + i2w_dx;
y1 = self->priv->y1 + i2w_dy;
x2 = self->priv->x2 + i2w_dx;
y2 = self->priv->y2 + i2w_dy;
eel_canvas_w2c (item->canvas, x1, y1, &cx1, &cy1);
eel_canvas_w2c (item->canvas, x2, y2, &cx2, &cy2);
if (cx2 <= cx1 || cy2 <= cy1)
{
return;
}
context = gtk_widget_get_style_context (GTK_WIDGET (item->canvas));
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RUBBERBAND);
cairo_save (cr);
gtk_render_background (context, cr,
cx1, cy1,
cx2 - cx1,
cy2 - cy1);
gtk_render_frame (context, cr,
cx1, cy1,
cx2 - cx1,
cy2 - cy1);
cairo_restore (cr);
gtk_style_context_restore (context);
}
static double
nautilus_selection_canvas_item_point (EelCanvasItem *item,
double x,
double y,
int cx,
int cy,
EelCanvasItem **actual_item)
{
NautilusSelectionCanvasItem *self;
double x1, y1, x2, y2;
double hwidth;
double dx, dy;
self = NAUTILUS_SELECTION_CANVAS_ITEM (item);
*actual_item = item;
/* Find the bounds for the rectangle plus its outline width */
x1 = self->priv->x1;
y1 = self->priv->y1;
x2 = self->priv->x2;
y2 = self->priv->y2;
hwidth = (1.0 / item->canvas->pixels_per_unit) / 2.0;
x1 -= hwidth;
y1 -= hwidth;
x2 += hwidth;
y2 += hwidth;
/* Is point inside rectangle (which can be hollow if it has no fill set)? */
if ((x >= x1) && (y >= y1) && (x <= x2) && (y <= y2))
{
return 0.0;
}
/* Point is outside rectangle */
if (x < x1)
{
dx = x1 - x;
}
else if (x > x2)
{
dx = x - x2;
}
else
{
dx = 0.0;
}
if (y < y1)
{
dy = y1 - y;
}
else if (y > y2)
{
dy = y - y2;
}
else
{
dy = 0.0;
}
return sqrt (dx * dx + dy * dy);
}
static void
request_redraw_borders (EelCanvas *canvas,
Rect *update_rect,
int width)
{
/* Top */
eel_canvas_request_redraw (canvas,
update_rect->x0, update_rect->y0,
update_rect->x1, update_rect->y0 + width);
/* Bottom */
eel_canvas_request_redraw (canvas,
update_rect->x0, update_rect->y1 - width,
update_rect->x1, update_rect->y1);
/* Left */
eel_canvas_request_redraw (canvas,
update_rect->x0, update_rect->y0,
update_rect->x0 + width, update_rect->y1);
/* Right */
eel_canvas_request_redraw (canvas,
update_rect->x1 - width, update_rect->y0,
update_rect->x1, update_rect->y1);
}
static Rect make_rect (int x0,
int y0,
int x1,
int y1);
static int
rect_empty (const Rect *src)
{
return (src->x1 <= src->x0 || src->y1 <= src->y0);
}
static gboolean
rects_intersect (Rect r1,
Rect r2)
{
if (r1.x0 >= r2.x1)
{
return FALSE;
}
if (r2.x0 >= r1.x1)
{
return FALSE;
}
if (r1.y0 >= r2.y1)
{
return FALSE;
}
if (r2.y0 >= r1.y1)
{
return FALSE;
}
return TRUE;
}
static void
diff_rects_guts (Rect ra,
Rect rb,
int *count,
Rect result[4])
{
if (ra.x0 < rb.x0)
{
result[(*count)++] = make_rect (ra.x0, ra.y0, rb.x0, ra.y1);
}
if (ra.y0 < rb.y0)
{
result[(*count)++] = make_rect (ra.x0, ra.y0, ra.x1, rb.y0);
}
if (ra.x1 < rb.x1)
{
result[(*count)++] = make_rect (ra.x1, rb.y0, rb.x1, rb.y1);
}
if (ra.y1 < rb.y1)
{
result[(*count)++] = make_rect (rb.x0, ra.y1, rb.x1, rb.y1);
}
}
static void
diff_rects (Rect r1,
Rect r2,
int *count,
Rect result[4])
{
g_assert (count != NULL);
g_assert (result != NULL);
*count = 0;
if (rects_intersect (r1, r2))
{
diff_rects_guts (r1, r2, count, result);
diff_rects_guts (r2, r1, count, result);
}
else
{
if (!rect_empty (&r1))
{
result[(*count)++] = r1;
}
if (!rect_empty (&r2))
{
result[(*count)++] = r2;
}
}
}
static Rect
make_rect (int x0,
int y0,
int x1,
int y1)
{
Rect r;
r.x0 = x0;
r.y0 = y0;
r.x1 = x1;
r.y1 = y1;
return r;
}
static void
nautilus_selection_canvas_item_update (EelCanvasItem *item,
double i2w_dx,
double i2w_dy,
gint flags)
{
NautilusSelectionCanvasItem *self;
NautilusSelectionCanvasItemDetails *priv;
double x1, y1, x2, y2;
int cx1, cy1, cx2, cy2;
int repaint_rects_count, i;
GtkStyleContext *context;
GtkBorder border;
Rect update_rect, repaint_rects[4];
if (EEL_CANVAS_ITEM_CLASS (nautilus_selection_canvas_item_parent_class)->update)
{
(*EEL_CANVAS_ITEM_CLASS (nautilus_selection_canvas_item_parent_class)->update)(item, i2w_dx, i2w_dy, flags);
}
self = NAUTILUS_SELECTION_CANVAS_ITEM (item);
priv = self->priv;
x1 = priv->x1 + i2w_dx;
y1 = priv->y1 + i2w_dy;
x2 = priv->x2 + i2w_dx;
y2 = priv->y2 + i2w_dy;
eel_canvas_w2c (item->canvas, x1, y1, &cx1, &cy1);
eel_canvas_w2c (item->canvas, x2, y2, &cx2, &cy2);
update_rect = make_rect (cx1, cy1, cx2 + 1, cy2 + 1);
diff_rects (update_rect, priv->last_update_rect,
&repaint_rects_count, repaint_rects);
for (i = 0; i < repaint_rects_count; i++)
{
eel_canvas_request_redraw (item->canvas,
repaint_rects[i].x0, repaint_rects[i].y0,
repaint_rects[i].x1, repaint_rects[i].y1);
}
priv->last_update_rect = update_rect;
context = gtk_widget_get_style_context (GTK_WIDGET (item->canvas));
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RUBBERBAND);
gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border);
gtk_style_context_restore (context);
cx1 -= border.left;
cy1 -= border.top;
cx2 += border.right;
cy2 += border.bottom;
update_rect = make_rect (cx1, cy1, cx2, cy2);
request_redraw_borders (item->canvas, &update_rect,
border.left + border.top + border.right + border.bottom);
request_redraw_borders (item->canvas, &priv->last_outline_update_rect,
priv->last_outline_update_width);
priv->last_outline_update_rect = update_rect;
priv->last_outline_update_width = border.left + border.top + border.right + border.bottom;
item->x1 = cx1;
item->y1 = cy1;
item->x2 = cx2;
item->y2 = cy2;
}
static void
nautilus_selection_canvas_item_translate (EelCanvasItem *item,
double dx,
double dy)
{
NautilusSelectionCanvasItem *self;
self = NAUTILUS_SELECTION_CANVAS_ITEM (item);
self->priv->x1 += dx;
self->priv->y1 += dy;
self->priv->x2 += dx;
self->priv->y2 += dy;
}
static void
nautilus_selection_canvas_item_bounds (EelCanvasItem *item,
double *x1,
double *y1,
double *x2,
double *y2)
{
NautilusSelectionCanvasItem *self;
GtkStyleContext *context;
GtkBorder border;
self = NAUTILUS_SELECTION_CANVAS_ITEM (item);
context = gtk_widget_get_style_context (GTK_WIDGET (item->canvas));
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RUBBERBAND);
gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border);
gtk_style_context_restore (context);
*x1 = self->priv->x1 - (border.left / item->canvas->pixels_per_unit) / 2.0;
*y1 = self->priv->y1 - (border.top / item->canvas->pixels_per_unit) / 2.0;
*x2 = self->priv->x2 + (border.right / item->canvas->pixels_per_unit) / 2.0;
*y2 = self->priv->y2 + (border.bottom / item->canvas->pixels_per_unit) / 2.0;
}
static void
nautilus_selection_canvas_item_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
{
EelCanvasItem *item;
NautilusSelectionCanvasItem *self;
self = NAUTILUS_SELECTION_CANVAS_ITEM (object);
item = EEL_CANVAS_ITEM (object);
switch (param_id)
{
case PROP_X1:
{
self->priv->x1 = g_value_get_double (value);
eel_canvas_item_request_update (item);
}
break;
case PROP_Y1:
{
self->priv->y1 = g_value_get_double (value);
eel_canvas_item_request_update (item);
}
break;
case PROP_X2:
{
self->priv->x2 = g_value_get_double (value);
eel_canvas_item_request_update (item);
}
break;
case PROP_Y2:
{
self->priv->y2 = g_value_get_double (value);
eel_canvas_item_request_update (item);
}
break;
default:
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
}
break;
}
}
static void
nautilus_selection_canvas_item_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec)
{
NautilusSelectionCanvasItem *self;
self = NAUTILUS_SELECTION_CANVAS_ITEM (object);
switch (param_id)
{
case PROP_X1:
{
g_value_set_double (value, self->priv->x1);
}
break;
case PROP_Y1:
{
g_value_set_double (value, self->priv->y1);
}
break;
case PROP_X2:
{
g_value_set_double (value, self->priv->x2);
}
break;
case PROP_Y2:
{
g_value_set_double (value, self->priv->y2);
}
break;
default:
{
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
}
break;
}
}
static void
nautilus_selection_canvas_item_class_init (NautilusSelectionCanvasItemClass *klass)
{
EelCanvasItemClass *item_class;
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
item_class = EEL_CANVAS_ITEM_CLASS (klass);
gobject_class->set_property = nautilus_selection_canvas_item_set_property;
gobject_class->get_property = nautilus_selection_canvas_item_get_property;
item_class->draw = nautilus_selection_canvas_item_draw;
item_class->point = nautilus_selection_canvas_item_point;
item_class->update = nautilus_selection_canvas_item_update;
item_class->bounds = nautilus_selection_canvas_item_bounds;
item_class->translate = nautilus_selection_canvas_item_translate;
properties[PROP_X1] =
g_param_spec_double ("x1", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
properties[PROP_Y1] =
g_param_spec_double ("y1", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
properties[PROP_X2] =
g_param_spec_double ("x2", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
properties[PROP_Y2] =
g_param_spec_double ("y2", NULL, NULL,
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
G_PARAM_READWRITE);
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, properties);
g_type_class_add_private (klass, sizeof (NautilusSelectionCanvasItemDetails));
}
static void
nautilus_selection_canvas_item_init (NautilusSelectionCanvasItem *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_SELECTION_CANVAS_ITEM,
NautilusSelectionCanvasItemDetails);
}

View file

@ -1,62 +0,0 @@
/* Nautilus - Canvas item for floating selection.
*
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
* Copyright (C) 2011 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Authors: Federico Mena <federico@nuclecu.unam.mx>
* Cosimo Cecchi <cosimoc@redhat.com>
*/
#pragma once
#include <eel/eel-canvas.h>
G_BEGIN_DECLS
#define NAUTILUS_TYPE_SELECTION_CANVAS_ITEM nautilus_selection_canvas_item_get_type()
#define NAUTILUS_SELECTION_CANVAS_ITEM(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_SELECTION_CANVAS_ITEM, NautilusSelectionCanvasItem))
#define NAUTILUS_SELECTION_CANVAS_ITEM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SELECTION_CANVAS_ITEM, NautilusSelectionCanvasItemClass))
#define NAUTILUS_IS_SELECTION_CANVAS_ITEM(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_SELECTION_CANVAS_ITEM))
#define NAUTILUS_IS_SELECTION_CANVAS_ITEM_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_SELECTION_CANVAS_ITEM))
#define NAUTILUS_SELECTION_CANVAS_ITEM_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_SELECTION_CANVAS_ITEM, NautilusSelectionCanvasItemClass))
typedef struct _NautilusSelectionCanvasItem NautilusSelectionCanvasItem;
typedef struct _NautilusSelectionCanvasItemClass NautilusSelectionCanvasItemClass;
typedef struct _NautilusSelectionCanvasItemDetails NautilusSelectionCanvasItemDetails;
struct _NautilusSelectionCanvasItem {
EelCanvasItem item;
NautilusSelectionCanvasItemDetails *priv;
gpointer user_data;
};
struct _NautilusSelectionCanvasItemClass {
EelCanvasItemClass parent_class;
};
/* GObject */
GType nautilus_selection_canvas_item_get_type (void);
void nautilus_selection_canvas_item_fade_out (NautilusSelectionCanvasItem *self,
guint transition_time);
G_END_DECLS

View file

@ -8,18 +8,6 @@
opacity: 0.50;
}
.nautilus-canvas-item {
border-radius: 5px;
}
.nautilus-canvas-item.dim-label {
color: mix (@theme_fg_color, @theme_bg_color, 0.50);
}
.nautilus-canvas-item.dim-label:selected {
color: mix (@theme_selected_fg_color, @theme_selected_bg_color, 0.20);
}
/* Toolbar */
/* Here we use the .button background-image colors from Adwaita, but ligthen them,