mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-12 20:41:34 +00:00
Finished task 376 (Resolve list-view single-click behavior)
* libnautilus/nautilus-gdk-extensions.h: #defines for colors NAUTILUS_RGB_COLOR_RED, _GREEN, _BLUE, _WHITE, and _BLACK. * libnautilus/nautilus-gdk-extensions.c: (nautilus_parse_rgb_with_white_default): Replaced hard-wired numbers with these #defines. * libnautilus/nautilus-list.h, * libnautilus/nautilus-list.c: added enum entry for NAUTILUS_CELL_LINK_TEXT; (nautilus_list_mark_cell_as_link): New functions, converts an ordinary text cell into a link-text cell. (nautilus_list_button_release): Only activate link-text cells on single click; other cells select as in other lists. (draw_row): draw link-text cells with blue text and an underline, so they look like typical web links. (nautilus_list_set_cell_contents): Convert link-text cell back to ordinary text cell before cleaning up old contents so parent function will do the right thing. * src/file-manager/fm-list-view.c: (add_to_list): mark file name cell as link-text cell. (remove_from_list): New function, extracted from... (fm_list_view_file_changed): Followed Darin's advice on how to simultaneously clarify this code and fix a storage leak. For Darin, fixed a typo that caused every file to be displayed as if it were a directory. * src/ntl-uri-map.c: (my_notify_when_ready): Added two missing "== 0"s.
This commit is contained in:
parent
c564c60240
commit
cb19a9692f
|
@ -1,3 +1,40 @@
|
|||
2000-04-06 John Sullivan <sullivan@eazel.com>
|
||||
|
||||
Finished task 376 (Resolve single-click behavior)
|
||||
|
||||
* libnautilus/nautilus-gdk-extensions.h:
|
||||
#defines for colors NAUTILUS_RGB_COLOR_RED, _GREEN,
|
||||
_BLUE, _WHITE, and _BLACK.
|
||||
* libnautilus/nautilus-gdk-extensions.c:
|
||||
(nautilus_parse_rgb_with_white_default): Replaced
|
||||
hard-wired numbers with these #defines.
|
||||
|
||||
* libnautilus/nautilus-list.h,
|
||||
* libnautilus/nautilus-list.c:
|
||||
added enum entry for NAUTILUS_CELL_LINK_TEXT;
|
||||
(nautilus_list_mark_cell_as_link): New functions, converts
|
||||
an ordinary text cell into a link-text cell.
|
||||
(nautilus_list_button_release): Only activate link-text
|
||||
cells on single click; other cells select as in other lists.
|
||||
(draw_row): draw link-text cells with blue text and an
|
||||
underline, so they look like typical web links.
|
||||
(nautilus_list_set_cell_contents): Convert link-text cell
|
||||
back to ordinary text cell before cleaning up old
|
||||
contents so parent function will do the right thing.
|
||||
|
||||
* src/file-manager/fm-list-view.c:
|
||||
(add_to_list): mark file name cell as link-text cell.
|
||||
(remove_from_list): New function, extracted from...
|
||||
(fm_list_view_file_changed): Followed Darin's advice on
|
||||
how to simultaneously clarify this code and fix a
|
||||
storage leak.
|
||||
|
||||
For Darin, fixed a typo that caused every file to be
|
||||
displayed as if it were a directory.
|
||||
|
||||
* src/ntl-uri-map.c:
|
||||
(my_notify_when_ready): Added two missing "== 0"s.
|
||||
|
||||
2000-04-06 Maciej Stachowiak <mjs@eazel.com>
|
||||
|
||||
* src/file-manager/fm-directory-view.c
|
||||
|
|
|
@ -440,11 +440,11 @@ nautilus_parse_rgb_with_white_default (const char *color_spec)
|
|||
GdkColor color;
|
||||
|
||||
if (color_spec == NULL || !gdk_color_parse (color_spec, &color)) {
|
||||
return 0xFFFFFF;
|
||||
return NAUTILUS_RGB_COLOR_WHITE;
|
||||
}
|
||||
return ((color.red << 8) & 0xFF0000)
|
||||
| (color.green & 0xFF00)
|
||||
| ((color.blue >> 8) & 0xFF);
|
||||
return ((color.red << 8) & NAUTILUS_RGB_COLOR_RED)
|
||||
| (color.green & NAUTILUS_RGB_COLOR_GREEN)
|
||||
| ((color.blue >> 8) & NAUTILUS_RGB_COLOR_BLUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
#define NAUTILUS_RGB_COLOR_RED 0xFF0000
|
||||
#define NAUTILUS_RGB_COLOR_GREEN 0x00FF00
|
||||
#define NAUTILUS_RGB_COLOR_BLUE 0x0000FF
|
||||
#define NAUTILUS_RGB_COLOR_WHITE 0xFFFFFF
|
||||
#define NAUTILUS_RGB_COLOR_BLACK 0x000000
|
||||
|
||||
/* A gradient spec. is a string that contains a specifier for either a
|
||||
color or a gradient. If the string has a "-" in it, then it's a gradient.
|
||||
The gradient is vertical by default and the spec. can end with ":v" to indicate that.
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "nautilus-gdk-extensions.h"
|
||||
|
||||
#include "nautilus-glib-extensions.h"
|
||||
#include "nautilus-gdk-extensions.h"
|
||||
#include "nautilus-gdk-pixbuf-extensions.h"
|
||||
#include "nautilus-gtk-macros.h"
|
||||
#include "nautilus-background.h"
|
||||
|
@ -66,6 +67,45 @@ struct NautilusListDetails
|
|||
/* horizontal space between images in a pixbuf list cell */
|
||||
#define PIXBUF_LIST_SPACING 2
|
||||
|
||||
/* Some #defines stolen from gtkclist.c that we need for other stolen code. */
|
||||
|
||||
/* minimum allowed width of a column */
|
||||
#define COLUMN_MIN_WIDTH 5
|
||||
|
||||
/* this defines the base grid spacing */
|
||||
#define CELL_SPACING 1
|
||||
|
||||
/* added the horizontal space at the beginning and end of a row */
|
||||
#define COLUMN_INSET 3
|
||||
|
||||
/* the width of the column resize windows */
|
||||
#define DRAG_WIDTH 6
|
||||
|
||||
/* gives the left pixel of the given column in context of
|
||||
* the clist's hoffset */
|
||||
#define COLUMN_LEFT_XPIXEL(clist, colnum) ((clist)->column[(colnum)].area.x + \
|
||||
(clist)->hoffset)
|
||||
|
||||
/* gives the top pixel of the given row in context of
|
||||
* the clist's voffset */
|
||||
#define ROW_TOP_YPIXEL(clist, row) (((clist)->row_height * (row)) + \
|
||||
(((row) + 1) * CELL_SPACING) + \
|
||||
(clist)->voffset)
|
||||
|
||||
/* returns the row index from a y pixel location in the
|
||||
* context of the clist's voffset */
|
||||
#define ROW_FROM_YPIXEL(clist, y) (((y) - (clist)->voffset) / \
|
||||
((clist)->row_height + CELL_SPACING))
|
||||
|
||||
/* returns the GList item for the nth row */
|
||||
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
|
||||
(clist)->row_list_end : \
|
||||
g_list_nth ((clist)->row_list, (row)))
|
||||
|
||||
/* returns the total height of the list */
|
||||
#define LIST_HEIGHT(clist) (((clist)->row_height * ((clist)->rows)) + \
|
||||
(CELL_SPACING * ((clist)->rows + 1)))
|
||||
|
||||
enum {
|
||||
CONTEXT_CLICK_SELECTION,
|
||||
CONTEXT_CLICK_BACKGROUND,
|
||||
|
@ -433,6 +473,7 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
{
|
||||
NautilusList *list;
|
||||
GtkCList *clist;
|
||||
GtkCListRow *clist_row;
|
||||
int on_row;
|
||||
gint row, col;
|
||||
int retval;
|
||||
|
@ -466,8 +507,9 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
list->details->dnd_select_pending_state = 0;
|
||||
}
|
||||
|
||||
/* Activate on single click if not extending selection, mouse hasn't moved to
|
||||
* a different row, and not too much time has passed.
|
||||
/*
|
||||
* Activate on single click if not extending selection, mouse hasn't moved to
|
||||
* a different row, not too much time has passed, and this is a link-type cell.
|
||||
*/
|
||||
if (list->details->single_click_mode &&
|
||||
!(event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)))
|
||||
|
@ -476,7 +518,10 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
|
||||
if (elapsed_time < MAX_CLICK_TIME && list->details->button_down_row == row)
|
||||
{
|
||||
activate_row (list, row);
|
||||
clist_row = ROW_ELEMENT (clist, row)->data;
|
||||
if (clist_row->cell[col].type == NAUTILUS_CELL_LINK_TEXT) {
|
||||
activate_row (list, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,45 +531,6 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
return retval;
|
||||
}
|
||||
|
||||
/* stolen from gtkclist.c for now */
|
||||
|
||||
/* minimum allowed width of a column */
|
||||
#define COLUMN_MIN_WIDTH 5
|
||||
|
||||
/* this defines the base grid spacing */
|
||||
#define CELL_SPACING 1
|
||||
|
||||
/* added the horizontal space at the beginning and end of a row */
|
||||
#define COLUMN_INSET 3
|
||||
|
||||
/* the width of the column resize windows */
|
||||
#define DRAG_WIDTH 6
|
||||
|
||||
/* gives the left pixel of the given column in context of
|
||||
* the clist's hoffset */
|
||||
#define COLUMN_LEFT_XPIXEL(clist, colnum) ((clist)->column[(colnum)].area.x + \
|
||||
(clist)->hoffset)
|
||||
|
||||
/* gives the top pixel of the given row in context of
|
||||
* the clist's voffset */
|
||||
#define ROW_TOP_YPIXEL(clist, row) (((clist)->row_height * (row)) + \
|
||||
(((row) + 1) * CELL_SPACING) + \
|
||||
(clist)->voffset)
|
||||
|
||||
/* returns the row index from a y pixel location in the
|
||||
* context of the clist's voffset */
|
||||
#define ROW_FROM_YPIXEL(clist, y) (((y) - (clist)->voffset) / \
|
||||
((clist)->row_height + CELL_SPACING))
|
||||
|
||||
/* returns the GList item for the nth row */
|
||||
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
|
||||
(clist)->row_list_end : \
|
||||
g_list_nth ((clist)->row_list, (row)))
|
||||
|
||||
/* returns the total height of the list */
|
||||
#define LIST_HEIGHT(clist) (((clist)->row_height * ((clist)->rows)) + \
|
||||
(CELL_SPACING * ((clist)->rows + 1)))
|
||||
|
||||
static void
|
||||
nautilus_list_realize (GtkWidget *widget)
|
||||
{
|
||||
|
@ -1003,6 +1009,7 @@ draw_row (GtkCList *clist,
|
|||
GtkStyle *style;
|
||||
GdkGC *fg_gc;
|
||||
GdkGC *bg_gc;
|
||||
GdkGCValues saved_values;
|
||||
|
||||
GList *p;
|
||||
|
||||
|
@ -1010,6 +1017,7 @@ draw_row (GtkCList *clist,
|
|||
gint height;
|
||||
gint pixmap_width;
|
||||
gint offset = 0;
|
||||
gint baseline;
|
||||
gint row_center_offset;
|
||||
|
||||
if (!clist->column[i].visible)
|
||||
|
@ -1043,6 +1051,7 @@ draw_row (GtkCList *clist,
|
|||
switch ((NautilusCellType)clist_row->cell[i].type)
|
||||
{
|
||||
case NAUTILUS_CELL_TEXT:
|
||||
case NAUTILUS_CELL_LINK_TEXT:
|
||||
width = gdk_string_width (style->font,
|
||||
GTK_CELL_TEXT (clist_row->cell[i])->text);
|
||||
break;
|
||||
|
@ -1110,6 +1119,7 @@ draw_row (GtkCList *clist,
|
|||
(clip_rectangle.height - height) / 2);
|
||||
offset += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
|
||||
case NAUTILUS_CELL_TEXT:
|
||||
case NAUTILUS_CELL_LINK_TEXT:
|
||||
if (style != GTK_WIDGET (clist)->style)
|
||||
row_center_offset = (((clist->row_height - style->font->ascent -
|
||||
style->font->descent - 1) / 2) + 1.5 +
|
||||
|
@ -1117,14 +1127,35 @@ draw_row (GtkCList *clist,
|
|||
else
|
||||
row_center_offset = clist->row_center_offset;
|
||||
|
||||
baseline = row_rectangle.y + row_center_offset + clist_row->cell[i].vertical;
|
||||
|
||||
gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
|
||||
|
||||
/* For link text cells, draw with blue link-like color and use underline. */
|
||||
if ((NautilusCellType)clist_row->cell[i].type == NAUTILUS_CELL_LINK_TEXT
|
||||
&& NAUTILUS_LIST (clist)->details->single_click_mode) {
|
||||
if (state == GTK_STATE_NORMAL) {
|
||||
gdk_gc_get_values (fg_gc, &saved_values);
|
||||
gdk_rgb_gc_set_foreground (fg_gc, NAUTILUS_RGB_COLOR_BLUE);
|
||||
}
|
||||
}
|
||||
gdk_draw_string (clist->clist_window, style->font, fg_gc,
|
||||
offset,
|
||||
row_rectangle.y + row_center_offset +
|
||||
clist_row->cell[i].vertical,
|
||||
baseline,
|
||||
((NautilusCellType)clist_row->cell[i].type == GTK_CELL_PIXTEXT) ?
|
||||
GTK_CELL_PIXTEXT (clist_row->cell[i])->text :
|
||||
GTK_CELL_TEXT (clist_row->cell[i])->text);
|
||||
|
||||
if ((NautilusCellType)clist_row->cell[i].type == NAUTILUS_CELL_LINK_TEXT
|
||||
&& NAUTILUS_LIST (clist)->details->single_click_mode) {
|
||||
gdk_draw_line (clist->clist_window, fg_gc,
|
||||
offset, baseline + 1,
|
||||
offset + width, baseline + 1);
|
||||
/* Revert color change we made a moment ago. */
|
||||
if (state == GTK_STATE_NORMAL) {
|
||||
gdk_gc_set_foreground (fg_gc, &saved_values.foreground);
|
||||
}
|
||||
}
|
||||
gdk_gc_set_clip_rectangle (fg_gc, NULL);
|
||||
break;
|
||||
case NAUTILUS_CELL_PIXBUF_LIST:
|
||||
|
@ -1230,6 +1261,43 @@ nautilus_list_resize_column (GtkCList *clist, int column, int width)
|
|||
/* redraw the list if it's not frozen */
|
||||
#define CLIST_UNFROZEN(clist) (((GtkCList*) (clist))->freeze_count == 0)
|
||||
|
||||
/**
|
||||
* nautilus_list_mark_cell_as_link:
|
||||
*
|
||||
* Mark a text cell as a link cell. Link cells are drawn differently,
|
||||
* and activate rather than select on single-click. The cell must
|
||||
* be a text cell (not a pixmap cell or one of the other types).
|
||||
*
|
||||
* @list: The NautilusList in question.
|
||||
* @column: The column of the desired cell.
|
||||
* @row: The row of the desired cell.
|
||||
*/
|
||||
void
|
||||
nautilus_list_mark_cell_as_link (NautilusList *list,
|
||||
gint row,
|
||||
gint column)
|
||||
{
|
||||
GtkCListRow *clist_row;
|
||||
GtkCList *clist;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_LIST (list));
|
||||
|
||||
clist = GTK_CLIST (list);
|
||||
|
||||
g_return_if_fail (row >= 0 && row < clist->rows);
|
||||
g_return_if_fail (column >= 0 && column < clist->columns);
|
||||
|
||||
clist_row = ROW_ELEMENT (clist, row)->data;
|
||||
|
||||
/*
|
||||
* We only support changing text cells to links. Maybe someday
|
||||
* we'll support pixmap or pixtext link cells too.
|
||||
*/
|
||||
g_return_if_fail ((NautilusCellType)clist_row->cell[column].type == NAUTILUS_CELL_TEXT);
|
||||
|
||||
clist_row->cell[column].type = NAUTILUS_CELL_LINK_TEXT;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nautilus_list_set_cell_contents (GtkCList *clist,
|
||||
|
@ -1253,8 +1321,16 @@ nautilus_list_set_cell_contents (GtkCList *clist,
|
|||
nautilus_gdk_pixbuf_list_free (NAUTILUS_CELL_PIXBUF_LIST (clist_row->cell[column])->pixbufs);
|
||||
}
|
||||
|
||||
/* If old cell was a link-text cell, convert it back to a normal text
|
||||
* cell so it gets cleaned up properly by GtkCList code.
|
||||
*/
|
||||
if ((NautilusCellType)clist_row->cell[column].type == NAUTILUS_CELL_LINK_TEXT) {
|
||||
clist_row->cell[column].type = NAUTILUS_CELL_TEXT;
|
||||
}
|
||||
|
||||
NAUTILUS_CALL_PARENT_CLASS (GTK_CLIST_CLASS, set_cell_contents, (clist, clist_row, column, type, text, spacing, pixmap, mask));
|
||||
|
||||
|
||||
if ((NautilusCellType)type == NAUTILUS_CELL_PIXBUF_LIST) {
|
||||
clist_row->cell[column].type = NAUTILUS_CELL_PIXBUF_LIST;
|
||||
/* Hideously, we concealed our list of pixbufs in the pixmap parameter. */
|
||||
|
|
|
@ -48,13 +48,16 @@ typedef enum
|
|||
NAUTILUS_CELL_PIXMAP, /* GTK_CELL_PIXMAP */
|
||||
NAUTILUS_CELL_PIXTEXT, /* GTK_CELL_PIXTEXT */
|
||||
NAUTILUS_CELL_WIDGET, /* GTK_CELL_WIDGET */
|
||||
NAUTILUS_CELL_PIXBUF_LIST /* new for Nautilus */
|
||||
NAUTILUS_CELL_PIXBUF_LIST, /* new for Nautilus */
|
||||
NAUTILUS_CELL_LINK_TEXT /* new for Nautilus */
|
||||
} NautilusCellType;
|
||||
|
||||
/* pointer casting for cells */
|
||||
#define NAUTILUS_CELL_PIXBUF_LIST(cell) (((NautilusCellPixbufList *) &(cell)))
|
||||
/* no #define for NAUTILUS_CELL_LINK_TEXT, use GTK_CELL_TEXT instead */
|
||||
|
||||
typedef struct _NautilusCellPixbufList NautilusCellPixbufList;
|
||||
/* no struct for NautilusCellLinkText, use GtkCellText instead */
|
||||
|
||||
/*
|
||||
* Since the info in each cell must fit in the GtkCell struct that CList defines,
|
||||
|
@ -112,15 +115,18 @@ struct NautilusListClass {
|
|||
void (* column_resize_track_end) (GtkWidget *widget, int column);
|
||||
};
|
||||
|
||||
GtkType nautilus_list_get_type (void);
|
||||
GtkWidget *nautilus_list_new_with_titles (int columns,
|
||||
const char * const *titles);
|
||||
GList * nautilus_list_get_selection (NautilusList *list);
|
||||
void nautilus_list_set_selection (NautilusList *list, GList *selection);
|
||||
gboolean nautilus_list_is_row_selected (NautilusList *list,
|
||||
int row);
|
||||
void nautilus_list_set_pixbuf_list (NautilusList *list,
|
||||
gint row,
|
||||
gint column,
|
||||
GList *pixbufs);
|
||||
GtkType nautilus_list_get_type (void);
|
||||
GtkWidget *nautilus_list_new_with_titles (int columns,
|
||||
const char * const *titles);
|
||||
GList * nautilus_list_get_selection (NautilusList *list);
|
||||
void nautilus_list_set_selection (NautilusList *list, GList *selection);
|
||||
gboolean nautilus_list_is_row_selected (NautilusList *list,
|
||||
int row);
|
||||
void nautilus_list_set_pixbuf_list (NautilusList *list,
|
||||
gint row,
|
||||
gint column,
|
||||
GList *pixbufs);
|
||||
void nautilus_list_mark_cell_as_link (NautilusList *list,
|
||||
gint row,
|
||||
gint column);
|
||||
#endif /* NAUTILUS_LIST_H */
|
||||
|
|
|
@ -440,11 +440,11 @@ nautilus_parse_rgb_with_white_default (const char *color_spec)
|
|||
GdkColor color;
|
||||
|
||||
if (color_spec == NULL || !gdk_color_parse (color_spec, &color)) {
|
||||
return 0xFFFFFF;
|
||||
return NAUTILUS_RGB_COLOR_WHITE;
|
||||
}
|
||||
return ((color.red << 8) & 0xFF0000)
|
||||
| (color.green & 0xFF00)
|
||||
| ((color.blue >> 8) & 0xFF);
|
||||
return ((color.red << 8) & NAUTILUS_RGB_COLOR_RED)
|
||||
| (color.green & NAUTILUS_RGB_COLOR_GREEN)
|
||||
| ((color.blue >> 8) & NAUTILUS_RGB_COLOR_BLUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
#define NAUTILUS_RGB_COLOR_RED 0xFF0000
|
||||
#define NAUTILUS_RGB_COLOR_GREEN 0x00FF00
|
||||
#define NAUTILUS_RGB_COLOR_BLUE 0x0000FF
|
||||
#define NAUTILUS_RGB_COLOR_WHITE 0xFFFFFF
|
||||
#define NAUTILUS_RGB_COLOR_BLACK 0x000000
|
||||
|
||||
/* A gradient spec. is a string that contains a specifier for either a
|
||||
color or a gradient. If the string has a "-" in it, then it's a gradient.
|
||||
The gradient is vertical by default and the spec. can end with ":v" to indicate that.
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "nautilus-gdk-extensions.h"
|
||||
|
||||
#include "nautilus-glib-extensions.h"
|
||||
#include "nautilus-gdk-extensions.h"
|
||||
#include "nautilus-gdk-pixbuf-extensions.h"
|
||||
#include "nautilus-gtk-macros.h"
|
||||
#include "nautilus-background.h"
|
||||
|
@ -66,6 +67,45 @@ struct NautilusListDetails
|
|||
/* horizontal space between images in a pixbuf list cell */
|
||||
#define PIXBUF_LIST_SPACING 2
|
||||
|
||||
/* Some #defines stolen from gtkclist.c that we need for other stolen code. */
|
||||
|
||||
/* minimum allowed width of a column */
|
||||
#define COLUMN_MIN_WIDTH 5
|
||||
|
||||
/* this defines the base grid spacing */
|
||||
#define CELL_SPACING 1
|
||||
|
||||
/* added the horizontal space at the beginning and end of a row */
|
||||
#define COLUMN_INSET 3
|
||||
|
||||
/* the width of the column resize windows */
|
||||
#define DRAG_WIDTH 6
|
||||
|
||||
/* gives the left pixel of the given column in context of
|
||||
* the clist's hoffset */
|
||||
#define COLUMN_LEFT_XPIXEL(clist, colnum) ((clist)->column[(colnum)].area.x + \
|
||||
(clist)->hoffset)
|
||||
|
||||
/* gives the top pixel of the given row in context of
|
||||
* the clist's voffset */
|
||||
#define ROW_TOP_YPIXEL(clist, row) (((clist)->row_height * (row)) + \
|
||||
(((row) + 1) * CELL_SPACING) + \
|
||||
(clist)->voffset)
|
||||
|
||||
/* returns the row index from a y pixel location in the
|
||||
* context of the clist's voffset */
|
||||
#define ROW_FROM_YPIXEL(clist, y) (((y) - (clist)->voffset) / \
|
||||
((clist)->row_height + CELL_SPACING))
|
||||
|
||||
/* returns the GList item for the nth row */
|
||||
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
|
||||
(clist)->row_list_end : \
|
||||
g_list_nth ((clist)->row_list, (row)))
|
||||
|
||||
/* returns the total height of the list */
|
||||
#define LIST_HEIGHT(clist) (((clist)->row_height * ((clist)->rows)) + \
|
||||
(CELL_SPACING * ((clist)->rows + 1)))
|
||||
|
||||
enum {
|
||||
CONTEXT_CLICK_SELECTION,
|
||||
CONTEXT_CLICK_BACKGROUND,
|
||||
|
@ -433,6 +473,7 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
{
|
||||
NautilusList *list;
|
||||
GtkCList *clist;
|
||||
GtkCListRow *clist_row;
|
||||
int on_row;
|
||||
gint row, col;
|
||||
int retval;
|
||||
|
@ -466,8 +507,9 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
list->details->dnd_select_pending_state = 0;
|
||||
}
|
||||
|
||||
/* Activate on single click if not extending selection, mouse hasn't moved to
|
||||
* a different row, and not too much time has passed.
|
||||
/*
|
||||
* Activate on single click if not extending selection, mouse hasn't moved to
|
||||
* a different row, not too much time has passed, and this is a link-type cell.
|
||||
*/
|
||||
if (list->details->single_click_mode &&
|
||||
!(event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)))
|
||||
|
@ -476,7 +518,10 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
|
||||
if (elapsed_time < MAX_CLICK_TIME && list->details->button_down_row == row)
|
||||
{
|
||||
activate_row (list, row);
|
||||
clist_row = ROW_ELEMENT (clist, row)->data;
|
||||
if (clist_row->cell[col].type == NAUTILUS_CELL_LINK_TEXT) {
|
||||
activate_row (list, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,45 +531,6 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
return retval;
|
||||
}
|
||||
|
||||
/* stolen from gtkclist.c for now */
|
||||
|
||||
/* minimum allowed width of a column */
|
||||
#define COLUMN_MIN_WIDTH 5
|
||||
|
||||
/* this defines the base grid spacing */
|
||||
#define CELL_SPACING 1
|
||||
|
||||
/* added the horizontal space at the beginning and end of a row */
|
||||
#define COLUMN_INSET 3
|
||||
|
||||
/* the width of the column resize windows */
|
||||
#define DRAG_WIDTH 6
|
||||
|
||||
/* gives the left pixel of the given column in context of
|
||||
* the clist's hoffset */
|
||||
#define COLUMN_LEFT_XPIXEL(clist, colnum) ((clist)->column[(colnum)].area.x + \
|
||||
(clist)->hoffset)
|
||||
|
||||
/* gives the top pixel of the given row in context of
|
||||
* the clist's voffset */
|
||||
#define ROW_TOP_YPIXEL(clist, row) (((clist)->row_height * (row)) + \
|
||||
(((row) + 1) * CELL_SPACING) + \
|
||||
(clist)->voffset)
|
||||
|
||||
/* returns the row index from a y pixel location in the
|
||||
* context of the clist's voffset */
|
||||
#define ROW_FROM_YPIXEL(clist, y) (((y) - (clist)->voffset) / \
|
||||
((clist)->row_height + CELL_SPACING))
|
||||
|
||||
/* returns the GList item for the nth row */
|
||||
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
|
||||
(clist)->row_list_end : \
|
||||
g_list_nth ((clist)->row_list, (row)))
|
||||
|
||||
/* returns the total height of the list */
|
||||
#define LIST_HEIGHT(clist) (((clist)->row_height * ((clist)->rows)) + \
|
||||
(CELL_SPACING * ((clist)->rows + 1)))
|
||||
|
||||
static void
|
||||
nautilus_list_realize (GtkWidget *widget)
|
||||
{
|
||||
|
@ -1003,6 +1009,7 @@ draw_row (GtkCList *clist,
|
|||
GtkStyle *style;
|
||||
GdkGC *fg_gc;
|
||||
GdkGC *bg_gc;
|
||||
GdkGCValues saved_values;
|
||||
|
||||
GList *p;
|
||||
|
||||
|
@ -1010,6 +1017,7 @@ draw_row (GtkCList *clist,
|
|||
gint height;
|
||||
gint pixmap_width;
|
||||
gint offset = 0;
|
||||
gint baseline;
|
||||
gint row_center_offset;
|
||||
|
||||
if (!clist->column[i].visible)
|
||||
|
@ -1043,6 +1051,7 @@ draw_row (GtkCList *clist,
|
|||
switch ((NautilusCellType)clist_row->cell[i].type)
|
||||
{
|
||||
case NAUTILUS_CELL_TEXT:
|
||||
case NAUTILUS_CELL_LINK_TEXT:
|
||||
width = gdk_string_width (style->font,
|
||||
GTK_CELL_TEXT (clist_row->cell[i])->text);
|
||||
break;
|
||||
|
@ -1110,6 +1119,7 @@ draw_row (GtkCList *clist,
|
|||
(clip_rectangle.height - height) / 2);
|
||||
offset += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
|
||||
case NAUTILUS_CELL_TEXT:
|
||||
case NAUTILUS_CELL_LINK_TEXT:
|
||||
if (style != GTK_WIDGET (clist)->style)
|
||||
row_center_offset = (((clist->row_height - style->font->ascent -
|
||||
style->font->descent - 1) / 2) + 1.5 +
|
||||
|
@ -1117,14 +1127,35 @@ draw_row (GtkCList *clist,
|
|||
else
|
||||
row_center_offset = clist->row_center_offset;
|
||||
|
||||
baseline = row_rectangle.y + row_center_offset + clist_row->cell[i].vertical;
|
||||
|
||||
gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
|
||||
|
||||
/* For link text cells, draw with blue link-like color and use underline. */
|
||||
if ((NautilusCellType)clist_row->cell[i].type == NAUTILUS_CELL_LINK_TEXT
|
||||
&& NAUTILUS_LIST (clist)->details->single_click_mode) {
|
||||
if (state == GTK_STATE_NORMAL) {
|
||||
gdk_gc_get_values (fg_gc, &saved_values);
|
||||
gdk_rgb_gc_set_foreground (fg_gc, NAUTILUS_RGB_COLOR_BLUE);
|
||||
}
|
||||
}
|
||||
gdk_draw_string (clist->clist_window, style->font, fg_gc,
|
||||
offset,
|
||||
row_rectangle.y + row_center_offset +
|
||||
clist_row->cell[i].vertical,
|
||||
baseline,
|
||||
((NautilusCellType)clist_row->cell[i].type == GTK_CELL_PIXTEXT) ?
|
||||
GTK_CELL_PIXTEXT (clist_row->cell[i])->text :
|
||||
GTK_CELL_TEXT (clist_row->cell[i])->text);
|
||||
|
||||
if ((NautilusCellType)clist_row->cell[i].type == NAUTILUS_CELL_LINK_TEXT
|
||||
&& NAUTILUS_LIST (clist)->details->single_click_mode) {
|
||||
gdk_draw_line (clist->clist_window, fg_gc,
|
||||
offset, baseline + 1,
|
||||
offset + width, baseline + 1);
|
||||
/* Revert color change we made a moment ago. */
|
||||
if (state == GTK_STATE_NORMAL) {
|
||||
gdk_gc_set_foreground (fg_gc, &saved_values.foreground);
|
||||
}
|
||||
}
|
||||
gdk_gc_set_clip_rectangle (fg_gc, NULL);
|
||||
break;
|
||||
case NAUTILUS_CELL_PIXBUF_LIST:
|
||||
|
@ -1230,6 +1261,43 @@ nautilus_list_resize_column (GtkCList *clist, int column, int width)
|
|||
/* redraw the list if it's not frozen */
|
||||
#define CLIST_UNFROZEN(clist) (((GtkCList*) (clist))->freeze_count == 0)
|
||||
|
||||
/**
|
||||
* nautilus_list_mark_cell_as_link:
|
||||
*
|
||||
* Mark a text cell as a link cell. Link cells are drawn differently,
|
||||
* and activate rather than select on single-click. The cell must
|
||||
* be a text cell (not a pixmap cell or one of the other types).
|
||||
*
|
||||
* @list: The NautilusList in question.
|
||||
* @column: The column of the desired cell.
|
||||
* @row: The row of the desired cell.
|
||||
*/
|
||||
void
|
||||
nautilus_list_mark_cell_as_link (NautilusList *list,
|
||||
gint row,
|
||||
gint column)
|
||||
{
|
||||
GtkCListRow *clist_row;
|
||||
GtkCList *clist;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_LIST (list));
|
||||
|
||||
clist = GTK_CLIST (list);
|
||||
|
||||
g_return_if_fail (row >= 0 && row < clist->rows);
|
||||
g_return_if_fail (column >= 0 && column < clist->columns);
|
||||
|
||||
clist_row = ROW_ELEMENT (clist, row)->data;
|
||||
|
||||
/*
|
||||
* We only support changing text cells to links. Maybe someday
|
||||
* we'll support pixmap or pixtext link cells too.
|
||||
*/
|
||||
g_return_if_fail ((NautilusCellType)clist_row->cell[column].type == NAUTILUS_CELL_TEXT);
|
||||
|
||||
clist_row->cell[column].type = NAUTILUS_CELL_LINK_TEXT;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nautilus_list_set_cell_contents (GtkCList *clist,
|
||||
|
@ -1253,8 +1321,16 @@ nautilus_list_set_cell_contents (GtkCList *clist,
|
|||
nautilus_gdk_pixbuf_list_free (NAUTILUS_CELL_PIXBUF_LIST (clist_row->cell[column])->pixbufs);
|
||||
}
|
||||
|
||||
/* If old cell was a link-text cell, convert it back to a normal text
|
||||
* cell so it gets cleaned up properly by GtkCList code.
|
||||
*/
|
||||
if ((NautilusCellType)clist_row->cell[column].type == NAUTILUS_CELL_LINK_TEXT) {
|
||||
clist_row->cell[column].type = NAUTILUS_CELL_TEXT;
|
||||
}
|
||||
|
||||
NAUTILUS_CALL_PARENT_CLASS (GTK_CLIST_CLASS, set_cell_contents, (clist, clist_row, column, type, text, spacing, pixmap, mask));
|
||||
|
||||
|
||||
if ((NautilusCellType)type == NAUTILUS_CELL_PIXBUF_LIST) {
|
||||
clist_row->cell[column].type = NAUTILUS_CELL_PIXBUF_LIST;
|
||||
/* Hideously, we concealed our list of pixbufs in the pixmap parameter. */
|
||||
|
|
|
@ -48,13 +48,16 @@ typedef enum
|
|||
NAUTILUS_CELL_PIXMAP, /* GTK_CELL_PIXMAP */
|
||||
NAUTILUS_CELL_PIXTEXT, /* GTK_CELL_PIXTEXT */
|
||||
NAUTILUS_CELL_WIDGET, /* GTK_CELL_WIDGET */
|
||||
NAUTILUS_CELL_PIXBUF_LIST /* new for Nautilus */
|
||||
NAUTILUS_CELL_PIXBUF_LIST, /* new for Nautilus */
|
||||
NAUTILUS_CELL_LINK_TEXT /* new for Nautilus */
|
||||
} NautilusCellType;
|
||||
|
||||
/* pointer casting for cells */
|
||||
#define NAUTILUS_CELL_PIXBUF_LIST(cell) (((NautilusCellPixbufList *) &(cell)))
|
||||
/* no #define for NAUTILUS_CELL_LINK_TEXT, use GTK_CELL_TEXT instead */
|
||||
|
||||
typedef struct _NautilusCellPixbufList NautilusCellPixbufList;
|
||||
/* no struct for NautilusCellLinkText, use GtkCellText instead */
|
||||
|
||||
/*
|
||||
* Since the info in each cell must fit in the GtkCell struct that CList defines,
|
||||
|
@ -112,15 +115,18 @@ struct NautilusListClass {
|
|||
void (* column_resize_track_end) (GtkWidget *widget, int column);
|
||||
};
|
||||
|
||||
GtkType nautilus_list_get_type (void);
|
||||
GtkWidget *nautilus_list_new_with_titles (int columns,
|
||||
const char * const *titles);
|
||||
GList * nautilus_list_get_selection (NautilusList *list);
|
||||
void nautilus_list_set_selection (NautilusList *list, GList *selection);
|
||||
gboolean nautilus_list_is_row_selected (NautilusList *list,
|
||||
int row);
|
||||
void nautilus_list_set_pixbuf_list (NautilusList *list,
|
||||
gint row,
|
||||
gint column,
|
||||
GList *pixbufs);
|
||||
GtkType nautilus_list_get_type (void);
|
||||
GtkWidget *nautilus_list_new_with_titles (int columns,
|
||||
const char * const *titles);
|
||||
GList * nautilus_list_get_selection (NautilusList *list);
|
||||
void nautilus_list_set_selection (NautilusList *list, GList *selection);
|
||||
gboolean nautilus_list_is_row_selected (NautilusList *list,
|
||||
int row);
|
||||
void nautilus_list_set_pixbuf_list (NautilusList *list,
|
||||
gint row,
|
||||
gint column,
|
||||
GList *pixbufs);
|
||||
void nautilus_list_mark_cell_as_link (NautilusList *list,
|
||||
gint row,
|
||||
gint column);
|
||||
#endif /* NAUTILUS_LIST_H */
|
||||
|
|
|
@ -440,11 +440,11 @@ nautilus_parse_rgb_with_white_default (const char *color_spec)
|
|||
GdkColor color;
|
||||
|
||||
if (color_spec == NULL || !gdk_color_parse (color_spec, &color)) {
|
||||
return 0xFFFFFF;
|
||||
return NAUTILUS_RGB_COLOR_WHITE;
|
||||
}
|
||||
return ((color.red << 8) & 0xFF0000)
|
||||
| (color.green & 0xFF00)
|
||||
| ((color.blue >> 8) & 0xFF);
|
||||
return ((color.red << 8) & NAUTILUS_RGB_COLOR_RED)
|
||||
| (color.green & NAUTILUS_RGB_COLOR_GREEN)
|
||||
| ((color.blue >> 8) & NAUTILUS_RGB_COLOR_BLUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
#define NAUTILUS_RGB_COLOR_RED 0xFF0000
|
||||
#define NAUTILUS_RGB_COLOR_GREEN 0x00FF00
|
||||
#define NAUTILUS_RGB_COLOR_BLUE 0x0000FF
|
||||
#define NAUTILUS_RGB_COLOR_WHITE 0xFFFFFF
|
||||
#define NAUTILUS_RGB_COLOR_BLACK 0x000000
|
||||
|
||||
/* A gradient spec. is a string that contains a specifier for either a
|
||||
color or a gradient. If the string has a "-" in it, then it's a gradient.
|
||||
The gradient is vertical by default and the spec. can end with ":v" to indicate that.
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "nautilus-gdk-extensions.h"
|
||||
|
||||
#include "nautilus-glib-extensions.h"
|
||||
#include "nautilus-gdk-extensions.h"
|
||||
#include "nautilus-gdk-pixbuf-extensions.h"
|
||||
#include "nautilus-gtk-macros.h"
|
||||
#include "nautilus-background.h"
|
||||
|
@ -66,6 +67,45 @@ struct NautilusListDetails
|
|||
/* horizontal space between images in a pixbuf list cell */
|
||||
#define PIXBUF_LIST_SPACING 2
|
||||
|
||||
/* Some #defines stolen from gtkclist.c that we need for other stolen code. */
|
||||
|
||||
/* minimum allowed width of a column */
|
||||
#define COLUMN_MIN_WIDTH 5
|
||||
|
||||
/* this defines the base grid spacing */
|
||||
#define CELL_SPACING 1
|
||||
|
||||
/* added the horizontal space at the beginning and end of a row */
|
||||
#define COLUMN_INSET 3
|
||||
|
||||
/* the width of the column resize windows */
|
||||
#define DRAG_WIDTH 6
|
||||
|
||||
/* gives the left pixel of the given column in context of
|
||||
* the clist's hoffset */
|
||||
#define COLUMN_LEFT_XPIXEL(clist, colnum) ((clist)->column[(colnum)].area.x + \
|
||||
(clist)->hoffset)
|
||||
|
||||
/* gives the top pixel of the given row in context of
|
||||
* the clist's voffset */
|
||||
#define ROW_TOP_YPIXEL(clist, row) (((clist)->row_height * (row)) + \
|
||||
(((row) + 1) * CELL_SPACING) + \
|
||||
(clist)->voffset)
|
||||
|
||||
/* returns the row index from a y pixel location in the
|
||||
* context of the clist's voffset */
|
||||
#define ROW_FROM_YPIXEL(clist, y) (((y) - (clist)->voffset) / \
|
||||
((clist)->row_height + CELL_SPACING))
|
||||
|
||||
/* returns the GList item for the nth row */
|
||||
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
|
||||
(clist)->row_list_end : \
|
||||
g_list_nth ((clist)->row_list, (row)))
|
||||
|
||||
/* returns the total height of the list */
|
||||
#define LIST_HEIGHT(clist) (((clist)->row_height * ((clist)->rows)) + \
|
||||
(CELL_SPACING * ((clist)->rows + 1)))
|
||||
|
||||
enum {
|
||||
CONTEXT_CLICK_SELECTION,
|
||||
CONTEXT_CLICK_BACKGROUND,
|
||||
|
@ -433,6 +473,7 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
{
|
||||
NautilusList *list;
|
||||
GtkCList *clist;
|
||||
GtkCListRow *clist_row;
|
||||
int on_row;
|
||||
gint row, col;
|
||||
int retval;
|
||||
|
@ -466,8 +507,9 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
list->details->dnd_select_pending_state = 0;
|
||||
}
|
||||
|
||||
/* Activate on single click if not extending selection, mouse hasn't moved to
|
||||
* a different row, and not too much time has passed.
|
||||
/*
|
||||
* Activate on single click if not extending selection, mouse hasn't moved to
|
||||
* a different row, not too much time has passed, and this is a link-type cell.
|
||||
*/
|
||||
if (list->details->single_click_mode &&
|
||||
!(event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)))
|
||||
|
@ -476,7 +518,10 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
|
||||
if (elapsed_time < MAX_CLICK_TIME && list->details->button_down_row == row)
|
||||
{
|
||||
activate_row (list, row);
|
||||
clist_row = ROW_ELEMENT (clist, row)->data;
|
||||
if (clist_row->cell[col].type == NAUTILUS_CELL_LINK_TEXT) {
|
||||
activate_row (list, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,45 +531,6 @@ nautilus_list_button_release (GtkWidget *widget, GdkEventButton *event)
|
|||
return retval;
|
||||
}
|
||||
|
||||
/* stolen from gtkclist.c for now */
|
||||
|
||||
/* minimum allowed width of a column */
|
||||
#define COLUMN_MIN_WIDTH 5
|
||||
|
||||
/* this defines the base grid spacing */
|
||||
#define CELL_SPACING 1
|
||||
|
||||
/* added the horizontal space at the beginning and end of a row */
|
||||
#define COLUMN_INSET 3
|
||||
|
||||
/* the width of the column resize windows */
|
||||
#define DRAG_WIDTH 6
|
||||
|
||||
/* gives the left pixel of the given column in context of
|
||||
* the clist's hoffset */
|
||||
#define COLUMN_LEFT_XPIXEL(clist, colnum) ((clist)->column[(colnum)].area.x + \
|
||||
(clist)->hoffset)
|
||||
|
||||
/* gives the top pixel of the given row in context of
|
||||
* the clist's voffset */
|
||||
#define ROW_TOP_YPIXEL(clist, row) (((clist)->row_height * (row)) + \
|
||||
(((row) + 1) * CELL_SPACING) + \
|
||||
(clist)->voffset)
|
||||
|
||||
/* returns the row index from a y pixel location in the
|
||||
* context of the clist's voffset */
|
||||
#define ROW_FROM_YPIXEL(clist, y) (((y) - (clist)->voffset) / \
|
||||
((clist)->row_height + CELL_SPACING))
|
||||
|
||||
/* returns the GList item for the nth row */
|
||||
#define ROW_ELEMENT(clist, row) (((row) == (clist)->rows - 1) ? \
|
||||
(clist)->row_list_end : \
|
||||
g_list_nth ((clist)->row_list, (row)))
|
||||
|
||||
/* returns the total height of the list */
|
||||
#define LIST_HEIGHT(clist) (((clist)->row_height * ((clist)->rows)) + \
|
||||
(CELL_SPACING * ((clist)->rows + 1)))
|
||||
|
||||
static void
|
||||
nautilus_list_realize (GtkWidget *widget)
|
||||
{
|
||||
|
@ -1003,6 +1009,7 @@ draw_row (GtkCList *clist,
|
|||
GtkStyle *style;
|
||||
GdkGC *fg_gc;
|
||||
GdkGC *bg_gc;
|
||||
GdkGCValues saved_values;
|
||||
|
||||
GList *p;
|
||||
|
||||
|
@ -1010,6 +1017,7 @@ draw_row (GtkCList *clist,
|
|||
gint height;
|
||||
gint pixmap_width;
|
||||
gint offset = 0;
|
||||
gint baseline;
|
||||
gint row_center_offset;
|
||||
|
||||
if (!clist->column[i].visible)
|
||||
|
@ -1043,6 +1051,7 @@ draw_row (GtkCList *clist,
|
|||
switch ((NautilusCellType)clist_row->cell[i].type)
|
||||
{
|
||||
case NAUTILUS_CELL_TEXT:
|
||||
case NAUTILUS_CELL_LINK_TEXT:
|
||||
width = gdk_string_width (style->font,
|
||||
GTK_CELL_TEXT (clist_row->cell[i])->text);
|
||||
break;
|
||||
|
@ -1110,6 +1119,7 @@ draw_row (GtkCList *clist,
|
|||
(clip_rectangle.height - height) / 2);
|
||||
offset += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
|
||||
case NAUTILUS_CELL_TEXT:
|
||||
case NAUTILUS_CELL_LINK_TEXT:
|
||||
if (style != GTK_WIDGET (clist)->style)
|
||||
row_center_offset = (((clist->row_height - style->font->ascent -
|
||||
style->font->descent - 1) / 2) + 1.5 +
|
||||
|
@ -1117,14 +1127,35 @@ draw_row (GtkCList *clist,
|
|||
else
|
||||
row_center_offset = clist->row_center_offset;
|
||||
|
||||
baseline = row_rectangle.y + row_center_offset + clist_row->cell[i].vertical;
|
||||
|
||||
gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
|
||||
|
||||
/* For link text cells, draw with blue link-like color and use underline. */
|
||||
if ((NautilusCellType)clist_row->cell[i].type == NAUTILUS_CELL_LINK_TEXT
|
||||
&& NAUTILUS_LIST (clist)->details->single_click_mode) {
|
||||
if (state == GTK_STATE_NORMAL) {
|
||||
gdk_gc_get_values (fg_gc, &saved_values);
|
||||
gdk_rgb_gc_set_foreground (fg_gc, NAUTILUS_RGB_COLOR_BLUE);
|
||||
}
|
||||
}
|
||||
gdk_draw_string (clist->clist_window, style->font, fg_gc,
|
||||
offset,
|
||||
row_rectangle.y + row_center_offset +
|
||||
clist_row->cell[i].vertical,
|
||||
baseline,
|
||||
((NautilusCellType)clist_row->cell[i].type == GTK_CELL_PIXTEXT) ?
|
||||
GTK_CELL_PIXTEXT (clist_row->cell[i])->text :
|
||||
GTK_CELL_TEXT (clist_row->cell[i])->text);
|
||||
|
||||
if ((NautilusCellType)clist_row->cell[i].type == NAUTILUS_CELL_LINK_TEXT
|
||||
&& NAUTILUS_LIST (clist)->details->single_click_mode) {
|
||||
gdk_draw_line (clist->clist_window, fg_gc,
|
||||
offset, baseline + 1,
|
||||
offset + width, baseline + 1);
|
||||
/* Revert color change we made a moment ago. */
|
||||
if (state == GTK_STATE_NORMAL) {
|
||||
gdk_gc_set_foreground (fg_gc, &saved_values.foreground);
|
||||
}
|
||||
}
|
||||
gdk_gc_set_clip_rectangle (fg_gc, NULL);
|
||||
break;
|
||||
case NAUTILUS_CELL_PIXBUF_LIST:
|
||||
|
@ -1230,6 +1261,43 @@ nautilus_list_resize_column (GtkCList *clist, int column, int width)
|
|||
/* redraw the list if it's not frozen */
|
||||
#define CLIST_UNFROZEN(clist) (((GtkCList*) (clist))->freeze_count == 0)
|
||||
|
||||
/**
|
||||
* nautilus_list_mark_cell_as_link:
|
||||
*
|
||||
* Mark a text cell as a link cell. Link cells are drawn differently,
|
||||
* and activate rather than select on single-click. The cell must
|
||||
* be a text cell (not a pixmap cell or one of the other types).
|
||||
*
|
||||
* @list: The NautilusList in question.
|
||||
* @column: The column of the desired cell.
|
||||
* @row: The row of the desired cell.
|
||||
*/
|
||||
void
|
||||
nautilus_list_mark_cell_as_link (NautilusList *list,
|
||||
gint row,
|
||||
gint column)
|
||||
{
|
||||
GtkCListRow *clist_row;
|
||||
GtkCList *clist;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_LIST (list));
|
||||
|
||||
clist = GTK_CLIST (list);
|
||||
|
||||
g_return_if_fail (row >= 0 && row < clist->rows);
|
||||
g_return_if_fail (column >= 0 && column < clist->columns);
|
||||
|
||||
clist_row = ROW_ELEMENT (clist, row)->data;
|
||||
|
||||
/*
|
||||
* We only support changing text cells to links. Maybe someday
|
||||
* we'll support pixmap or pixtext link cells too.
|
||||
*/
|
||||
g_return_if_fail ((NautilusCellType)clist_row->cell[column].type == NAUTILUS_CELL_TEXT);
|
||||
|
||||
clist_row->cell[column].type = NAUTILUS_CELL_LINK_TEXT;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nautilus_list_set_cell_contents (GtkCList *clist,
|
||||
|
@ -1253,8 +1321,16 @@ nautilus_list_set_cell_contents (GtkCList *clist,
|
|||
nautilus_gdk_pixbuf_list_free (NAUTILUS_CELL_PIXBUF_LIST (clist_row->cell[column])->pixbufs);
|
||||
}
|
||||
|
||||
/* If old cell was a link-text cell, convert it back to a normal text
|
||||
* cell so it gets cleaned up properly by GtkCList code.
|
||||
*/
|
||||
if ((NautilusCellType)clist_row->cell[column].type == NAUTILUS_CELL_LINK_TEXT) {
|
||||
clist_row->cell[column].type = NAUTILUS_CELL_TEXT;
|
||||
}
|
||||
|
||||
NAUTILUS_CALL_PARENT_CLASS (GTK_CLIST_CLASS, set_cell_contents, (clist, clist_row, column, type, text, spacing, pixmap, mask));
|
||||
|
||||
|
||||
if ((NautilusCellType)type == NAUTILUS_CELL_PIXBUF_LIST) {
|
||||
clist_row->cell[column].type = NAUTILUS_CELL_PIXBUF_LIST;
|
||||
/* Hideously, we concealed our list of pixbufs in the pixmap parameter. */
|
||||
|
|
|
@ -48,13 +48,16 @@ typedef enum
|
|||
NAUTILUS_CELL_PIXMAP, /* GTK_CELL_PIXMAP */
|
||||
NAUTILUS_CELL_PIXTEXT, /* GTK_CELL_PIXTEXT */
|
||||
NAUTILUS_CELL_WIDGET, /* GTK_CELL_WIDGET */
|
||||
NAUTILUS_CELL_PIXBUF_LIST /* new for Nautilus */
|
||||
NAUTILUS_CELL_PIXBUF_LIST, /* new for Nautilus */
|
||||
NAUTILUS_CELL_LINK_TEXT /* new for Nautilus */
|
||||
} NautilusCellType;
|
||||
|
||||
/* pointer casting for cells */
|
||||
#define NAUTILUS_CELL_PIXBUF_LIST(cell) (((NautilusCellPixbufList *) &(cell)))
|
||||
/* no #define for NAUTILUS_CELL_LINK_TEXT, use GTK_CELL_TEXT instead */
|
||||
|
||||
typedef struct _NautilusCellPixbufList NautilusCellPixbufList;
|
||||
/* no struct for NautilusCellLinkText, use GtkCellText instead */
|
||||
|
||||
/*
|
||||
* Since the info in each cell must fit in the GtkCell struct that CList defines,
|
||||
|
@ -112,15 +115,18 @@ struct NautilusListClass {
|
|||
void (* column_resize_track_end) (GtkWidget *widget, int column);
|
||||
};
|
||||
|
||||
GtkType nautilus_list_get_type (void);
|
||||
GtkWidget *nautilus_list_new_with_titles (int columns,
|
||||
const char * const *titles);
|
||||
GList * nautilus_list_get_selection (NautilusList *list);
|
||||
void nautilus_list_set_selection (NautilusList *list, GList *selection);
|
||||
gboolean nautilus_list_is_row_selected (NautilusList *list,
|
||||
int row);
|
||||
void nautilus_list_set_pixbuf_list (NautilusList *list,
|
||||
gint row,
|
||||
gint column,
|
||||
GList *pixbufs);
|
||||
GtkType nautilus_list_get_type (void);
|
||||
GtkWidget *nautilus_list_new_with_titles (int columns,
|
||||
const char * const *titles);
|
||||
GList * nautilus_list_get_selection (NautilusList *list);
|
||||
void nautilus_list_set_selection (NautilusList *list, GList *selection);
|
||||
gboolean nautilus_list_is_row_selected (NautilusList *list,
|
||||
int row);
|
||||
void nautilus_list_set_pixbuf_list (NautilusList *list,
|
||||
gint row,
|
||||
gint column,
|
||||
GList *pixbufs);
|
||||
void nautilus_list_mark_cell_as_link (NautilusList *list,
|
||||
gint row,
|
||||
gint column);
|
||||
#endif /* NAUTILUS_LIST_H */
|
||||
|
|
|
@ -431,6 +431,7 @@ list_selection_changed_callback (NautilusList *list,
|
|||
static int
|
||||
add_to_list (FMListView *list_view, NautilusFile *file)
|
||||
{
|
||||
NautilusList *list;
|
||||
GtkCList *clist;
|
||||
char **text;
|
||||
int new_row;
|
||||
|
@ -454,8 +455,9 @@ add_to_list (FMListView *list_view, NautilusFile *file)
|
|||
get_attribute_from_column (column));
|
||||
}
|
||||
}
|
||||
|
||||
clist = GTK_CLIST (get_list(list_view));
|
||||
|
||||
list = get_list (list_view);
|
||||
clist = GTK_CLIST (list);
|
||||
|
||||
/* Temporarily set user data value as hack for the problem
|
||||
* that compare_rows is called before the row data can be set.
|
||||
|
@ -464,6 +466,7 @@ add_to_list (FMListView *list_view, NautilusFile *file)
|
|||
/* Note that since list is auto-sorted new_row isn't necessarily last row. */
|
||||
new_row = gtk_clist_append (clist, text);
|
||||
gtk_clist_set_row_data (clist, new_row, file);
|
||||
nautilus_list_mark_cell_as_link (list, new_row, LIST_VIEW_COLUMN_NAME);
|
||||
gtk_object_set_data (GTK_OBJECT (clist), PENDING_USER_DATA_KEY, NULL);
|
||||
|
||||
install_row_images (list_view, new_row);
|
||||
|
@ -586,12 +589,34 @@ fm_list_view_add_file (FMDirectoryView *view, NautilusFile *file)
|
|||
add_to_list (FM_LIST_VIEW (view), file);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
remove_from_list (FMListView *list_view, NautilusFile *file)
|
||||
{
|
||||
NautilusList *list;
|
||||
int old_row;
|
||||
gboolean was_selected;
|
||||
|
||||
list = get_list (list_view);
|
||||
old_row = gtk_clist_find_row_from_data (GTK_CLIST (list), file);
|
||||
|
||||
g_return_val_if_fail (old_row >= 0, FALSE);
|
||||
|
||||
/* Keep this item selected if necessary. */
|
||||
was_selected = nautilus_list_is_row_selected (list, old_row);
|
||||
|
||||
/* Remove and re-add file to get new text/icon values and sort correctly. */
|
||||
gtk_clist_remove (GTK_CLIST (list), old_row);
|
||||
nautilus_file_unref (file);
|
||||
|
||||
return was_selected;
|
||||
}
|
||||
|
||||
static void
|
||||
fm_list_view_file_changed (FMDirectoryView *view, NautilusFile *file)
|
||||
{
|
||||
FMListView *list_view;
|
||||
NautilusList *nautilus_list;
|
||||
int old_row, new_row;
|
||||
GtkCList *clist;
|
||||
int new_row;
|
||||
gboolean was_selected;
|
||||
|
||||
g_return_if_fail (FM_IS_LIST_VIEW (view));
|
||||
|
@ -601,32 +626,29 @@ fm_list_view_file_changed (FMDirectoryView *view, NautilusFile *file)
|
|||
* existing file going away.
|
||||
*/
|
||||
list_view = FM_LIST_VIEW (view);
|
||||
nautilus_list = get_list (list_view);
|
||||
old_row = gtk_clist_find_row_from_data (GTK_CLIST (nautilus_list), file);
|
||||
clist = GTK_CLIST (get_list (list_view));
|
||||
|
||||
if (old_row < 0) {
|
||||
g_assert_not_reached ();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Keep this item selected if necessary. */
|
||||
was_selected = nautilus_list_is_row_selected (nautilus_list, old_row);
|
||||
/* Ref it here so it doesn't go away entirely after we remove it
|
||||
* but before we reinsert it.
|
||||
*/
|
||||
nautilus_file_ref (file);
|
||||
|
||||
gtk_clist_freeze (GTK_CLIST (nautilus_list));
|
||||
gtk_clist_freeze (clist);
|
||||
|
||||
/* Remove and re-add file to get new text/icon values and sort correctly. */
|
||||
gtk_clist_remove (GTK_CLIST (nautilus_list), old_row);
|
||||
was_selected = remove_from_list (list_view, file);
|
||||
|
||||
if (!nautilus_file_is_gone (file)) {
|
||||
nautilus_file_unref (file);
|
||||
new_row = add_to_list (list_view, file);
|
||||
|
||||
if (was_selected) {
|
||||
gtk_clist_select_row (clist, new_row, -1);
|
||||
}
|
||||
}
|
||||
|
||||
if (was_selected && !nautilus_file_is_gone (file)) {
|
||||
gtk_clist_select_row (GTK_CLIST (nautilus_list), new_row, -1);
|
||||
}
|
||||
gtk_clist_thaw (clist);
|
||||
|
||||
gtk_clist_thaw (GTK_CLIST (nautilus_list));
|
||||
/* Unref to match our keep-it-alive-for-this-function ref. */
|
||||
nautilus_file_unref (file);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -290,7 +290,7 @@ my_notify_when_ready (GnomeVFSAsyncHandle *ah,
|
|||
|
||||
/* FIXME: for now, we just do this for directories but it should apply to all places with available metadata */
|
||||
add_components_from_metadata (navinfo);
|
||||
} else if (strcmp (navinfo->navinfo.content_type, "special/webdav-directory")) {
|
||||
} else if (strcmp (navinfo->navinfo.content_type, "special/webdav-directory") == 0) {
|
||||
fallback_iid = "ntl_web_browser";
|
||||
navinfo->content_identifiers = g_slist_append
|
||||
(navinfo->content_identifiers,
|
||||
|
@ -317,7 +317,7 @@ my_notify_when_ready (GnomeVFSAsyncHandle *ah,
|
|||
navinfo->content_identifiers = g_slist_append
|
||||
(navinfo->content_identifiers,
|
||||
nautilus_view_identifier_new ("nautilus_rpm_view", "Package"));
|
||||
} else if (strcmp(navinfo->navinfo.content_type, "special/eazel-service")) {
|
||||
} else if (strcmp(navinfo->navinfo.content_type, "special/eazel-service") == 0) {
|
||||
fallback_iid = "nautilus_service_startup_view";
|
||||
navinfo->content_identifiers = g_slist_append
|
||||
(navinfo->content_identifiers,
|
||||
|
|
|
@ -290,7 +290,7 @@ my_notify_when_ready (GnomeVFSAsyncHandle *ah,
|
|||
|
||||
/* FIXME: for now, we just do this for directories but it should apply to all places with available metadata */
|
||||
add_components_from_metadata (navinfo);
|
||||
} else if (strcmp (navinfo->navinfo.content_type, "special/webdav-directory")) {
|
||||
} else if (strcmp (navinfo->navinfo.content_type, "special/webdav-directory") == 0) {
|
||||
fallback_iid = "ntl_web_browser";
|
||||
navinfo->content_identifiers = g_slist_append
|
||||
(navinfo->content_identifiers,
|
||||
|
@ -317,7 +317,7 @@ my_notify_when_ready (GnomeVFSAsyncHandle *ah,
|
|||
navinfo->content_identifiers = g_slist_append
|
||||
(navinfo->content_identifiers,
|
||||
nautilus_view_identifier_new ("nautilus_rpm_view", "Package"));
|
||||
} else if (strcmp(navinfo->navinfo.content_type, "special/eazel-service")) {
|
||||
} else if (strcmp(navinfo->navinfo.content_type, "special/eazel-service") == 0) {
|
||||
fallback_iid = "nautilus_service_startup_view";
|
||||
navinfo->content_identifiers = g_slist_append
|
||||
(navinfo->content_identifiers,
|
||||
|
|
Loading…
Reference in a new issue