Commit aa98d924 authored by Pavel Cisler's avatar Pavel Cisler Committed by Pavel Cisler

Fix some bugs that John kindly uncovered.

2000-03-17  Pavel Cisler  <pavel@eazel.com>

	Fix some bugs that John kindly uncovered.
parent 6441e04b
2000-03-17 Pavel Cisler <pavel@eazel.com>
Fix some bugs that John kindly uncovered.
* libnautilus/gtkflist.c
(gtk_flist_resize_column):
Make it so that the column title updates when column width changes
by zooming in and out.
* libnautilus/gtkflist.c
(gtk_flist_column_resize_track_start), (gtk_flist_column_resize_track_end):
Fix a dumb segfault - clist was not being initialized properly.
* libnautilus/nautilus-list-column-title.c
(nautilus_list_column_title_paint):
Make the resize indicator draw on the other side of the column title
as it should.
Tweak an assert.
* libnautilus/nautilus-list-column-title.c
(nautilus_list_column_title_leave):
Fix a problem where the column title would sometimes get stuck in a
prelight state after the mouse has exited.
2000-03-16 Pavel Cisler <pavel@eazel.com>
* scr/file-manager/fm-directory-view-list.c
......
......@@ -92,6 +92,8 @@ static void draw_row (GtkCList *flist, GdkRectangle *area, gint row, GtkCListRow
static void gtk_flist_realize (GtkWidget *widget);
static void gtk_flist_size_request (GtkWidget *widget, GtkRequisition *requisition);
static void gtk_flist_resize_column (GtkCList *widget, int column, int width);
static void gtk_flist_column_resize_track_start (GtkWidget *widget, int column);
static void gtk_flist_column_resize_track (GtkWidget *widget, int column);
static void gtk_flist_column_resize_track_end (GtkWidget *widget, int column);
......@@ -161,6 +163,7 @@ gtk_flist_initialize_class (GtkFListClass *klass)
clist_class->clear = gtk_flist_clear;
clist_class->draw_row = draw_row;
clist_class->resize_column = gtk_flist_resize_column;
widget_class->button_press_event = gtk_flist_button_press;
widget_class->button_release_event = gtk_flist_button_release;
......@@ -1112,6 +1115,21 @@ draw_rows (GtkCList *clist, GdkRectangle *area)
}
}
static void
gtk_flist_resize_column (GtkCList *clist, int column, int width)
{
/* override resize column to invalidate the title */
GtkFList *flist;
g_assert (GTK_IS_FLIST (clist));
flist = GTK_FLIST (clist);
gtk_widget_queue_draw (flist->details->title);
NAUTILUS_CALL_PARENT_CLASS (GTK_CLIST_CLASS, resize_column, (clist, column, width));
}
static void
gtk_flist_track_new_column_width (GtkCList *clist, int column, int new_width)
{
......@@ -1218,6 +1236,7 @@ gtk_flist_column_resize_track_start (GtkWidget *widget, int column)
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_FLIST (widget));
clist = GTK_CLIST (widget);
clist->drag_pos = column;
}
......@@ -1246,6 +1265,7 @@ gtk_flist_column_resize_track_end (GtkWidget *widget, int column)
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_FLIST (widget));
clist = GTK_CLIST (widget);
clist->drag_pos = -1;
}
......
......@@ -171,7 +171,6 @@ nautilus_list_column_title_realize (GtkWidget *widget)
GdkWindowAttr attributes;
int attributes_mask;
g_assert (widget != NULL);
g_assert (NAUTILUS_IS_LIST_COLUMN_TITLE (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
......@@ -326,10 +325,12 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
GdkRectangle cell_rectangle;
GdkRectangle cell_redraw_area;
const char *cell_label;
int x_offset;
int text_x_offset;
int sort_indicator_x_offset;
GnomePixmap *sort_indicator;
gboolean right_justified;
sort_indicator_x_offset = 0;
sort_indicator = NULL;
right_justified = (parent_clist->column[index].justification == GTK_JUSTIFY_RIGHT);
......@@ -354,9 +355,9 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
*/
if (right_justified) {
x_offset = cell_rectangle.x + cell_rectangle.width - CELL_TITLE_INSET;
text_x_offset = cell_rectangle.x + cell_rectangle.width - CELL_TITLE_INSET;
} else {
x_offset = cell_rectangle.x + CELL_TITLE_INSET;
text_x_offset = cell_rectangle.x + CELL_TITLE_INSET;
}
/* Paint the column title tiles as rectangles using "menu" style
......@@ -375,11 +376,16 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
/* Draw the sort indicator if needed */
if (sort_indicator != NULL) {
int y_offset = TITLE_BASELINE_OFFSET + 2;
int y_offset;
if (right_justified) {
x_offset -= SORT_ORDER_INDICATOR_WIDTH;
sort_indicator_x_offset = cell_rectangle.x + CELL_TITLE_INSET;
} else {
sort_indicator_x_offset = cell_rectangle.x + cell_rectangle.width
- CELL_TITLE_INSET - SORT_ORDER_INDICATOR_WIDTH;
}
y_offset = TITLE_BASELINE_OFFSET + 2;
/* allocate the sort indicator copy gc first time around */
if (column_title->details->copy_area_gc == NULL) {
......@@ -389,16 +395,13 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
/* move the pixmap clip mask and origin to the right spot in the gc */
gdk_gc_set_clip_mask (column_title->details->copy_area_gc,
sort_indicator->mask);
gdk_gc_set_clip_origin (column_title->details->copy_area_gc, x_offset, y_offset);
gdk_gc_set_clip_origin (column_title->details->copy_area_gc, sort_indicator_x_offset, y_offset);
gdk_draw_pixmap (widget->window, column_title->details->copy_area_gc,
sort_indicator->pixmap, 0, 0, x_offset, y_offset,
sort_indicator->pixmap, 0, 0, sort_indicator_x_offset, y_offset,
-1, -1);
if (!right_justified) {
x_offset += SORT_ORDER_INDICATOR_WIDTH;
}
}
if (cell_label) {
......@@ -410,12 +413,12 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
*/
nautilus_rectangle_inset (&cell_redraw_area, 2, 2);
if (right_justified) {
x_offset -= gdk_string_width (widget->style->font, cell_label) + 4;
text_x_offset -= gdk_string_width (widget->style->font, cell_label) + 4;
}
gtk_paint_string (widget->style, widget->window, GTK_STATE_NORMAL,
&cell_redraw_area, widget, "label",
x_offset,
text_x_offset,
cell_rectangle.y + cell_rectangle.height - TITLE_BASELINE_OFFSET,
cell_label);
}
......@@ -624,11 +627,16 @@ nautilus_list_column_title_motion (GtkWidget *widget, GdkEventMotion *event)
static gboolean
nautilus_list_column_title_leave (GtkWidget *widget, GdkEventCrossing *event)
{
NautilusListColumnTitle *column_title;
g_assert (GTK_FLIST (widget->parent) != NULL);
g_assert (NAUTILUS_IS_LIST_COLUMN_TITLE (widget));
column_title = NAUTILUS_LIST_COLUMN_TITLE(widget);
/* see if we need to update the prelight state of a column */
if (track_prelight (widget, (int)event->x, (int)event->y)) {
if (column_title->details->tracking_column_prelight != -1) {
column_title->details->tracking_column_prelight = -1;
gtk_widget_set_state (widget, GTK_STATE_NORMAL);
nautilus_list_column_title_buffered_draw (widget);
}
......
......@@ -92,6 +92,8 @@ static void draw_row (GtkCList *flist, GdkRectangle *area, gint row, GtkCListRow
static void gtk_flist_realize (GtkWidget *widget);
static void gtk_flist_size_request (GtkWidget *widget, GtkRequisition *requisition);
static void gtk_flist_resize_column (GtkCList *widget, int column, int width);
static void gtk_flist_column_resize_track_start (GtkWidget *widget, int column);
static void gtk_flist_column_resize_track (GtkWidget *widget, int column);
static void gtk_flist_column_resize_track_end (GtkWidget *widget, int column);
......@@ -161,6 +163,7 @@ gtk_flist_initialize_class (GtkFListClass *klass)
clist_class->clear = gtk_flist_clear;
clist_class->draw_row = draw_row;
clist_class->resize_column = gtk_flist_resize_column;
widget_class->button_press_event = gtk_flist_button_press;
widget_class->button_release_event = gtk_flist_button_release;
......@@ -1112,6 +1115,21 @@ draw_rows (GtkCList *clist, GdkRectangle *area)
}
}
static void
gtk_flist_resize_column (GtkCList *clist, int column, int width)
{
/* override resize column to invalidate the title */
GtkFList *flist;
g_assert (GTK_IS_FLIST (clist));
flist = GTK_FLIST (clist);
gtk_widget_queue_draw (flist->details->title);
NAUTILUS_CALL_PARENT_CLASS (GTK_CLIST_CLASS, resize_column, (clist, column, width));
}
static void
gtk_flist_track_new_column_width (GtkCList *clist, int column, int new_width)
{
......@@ -1218,6 +1236,7 @@ gtk_flist_column_resize_track_start (GtkWidget *widget, int column)
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_FLIST (widget));
clist = GTK_CLIST (widget);
clist->drag_pos = column;
}
......@@ -1246,6 +1265,7 @@ gtk_flist_column_resize_track_end (GtkWidget *widget, int column)
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_FLIST (widget));
clist = GTK_CLIST (widget);
clist->drag_pos = -1;
}
......
......@@ -171,7 +171,6 @@ nautilus_list_column_title_realize (GtkWidget *widget)
GdkWindowAttr attributes;
int attributes_mask;
g_assert (widget != NULL);
g_assert (NAUTILUS_IS_LIST_COLUMN_TITLE (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
......@@ -326,10 +325,12 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
GdkRectangle cell_rectangle;
GdkRectangle cell_redraw_area;
const char *cell_label;
int x_offset;
int text_x_offset;
int sort_indicator_x_offset;
GnomePixmap *sort_indicator;
gboolean right_justified;
sort_indicator_x_offset = 0;
sort_indicator = NULL;
right_justified = (parent_clist->column[index].justification == GTK_JUSTIFY_RIGHT);
......@@ -354,9 +355,9 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
*/
if (right_justified) {
x_offset = cell_rectangle.x + cell_rectangle.width - CELL_TITLE_INSET;
text_x_offset = cell_rectangle.x + cell_rectangle.width - CELL_TITLE_INSET;
} else {
x_offset = cell_rectangle.x + CELL_TITLE_INSET;
text_x_offset = cell_rectangle.x + CELL_TITLE_INSET;
}
/* Paint the column title tiles as rectangles using "menu" style
......@@ -375,11 +376,16 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
/* Draw the sort indicator if needed */
if (sort_indicator != NULL) {
int y_offset = TITLE_BASELINE_OFFSET + 2;
int y_offset;
if (right_justified) {
x_offset -= SORT_ORDER_INDICATOR_WIDTH;
sort_indicator_x_offset = cell_rectangle.x + CELL_TITLE_INSET;
} else {
sort_indicator_x_offset = cell_rectangle.x + cell_rectangle.width
- CELL_TITLE_INSET - SORT_ORDER_INDICATOR_WIDTH;
}
y_offset = TITLE_BASELINE_OFFSET + 2;
/* allocate the sort indicator copy gc first time around */
if (column_title->details->copy_area_gc == NULL) {
......@@ -389,16 +395,13 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
/* move the pixmap clip mask and origin to the right spot in the gc */
gdk_gc_set_clip_mask (column_title->details->copy_area_gc,
sort_indicator->mask);
gdk_gc_set_clip_origin (column_title->details->copy_area_gc, x_offset, y_offset);
gdk_gc_set_clip_origin (column_title->details->copy_area_gc, sort_indicator_x_offset, y_offset);
gdk_draw_pixmap (widget->window, column_title->details->copy_area_gc,
sort_indicator->pixmap, 0, 0, x_offset, y_offset,
sort_indicator->pixmap, 0, 0, sort_indicator_x_offset, y_offset,
-1, -1);
if (!right_justified) {
x_offset += SORT_ORDER_INDICATOR_WIDTH;
}
}
if (cell_label) {
......@@ -410,12 +413,12 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
*/
nautilus_rectangle_inset (&cell_redraw_area, 2, 2);
if (right_justified) {
x_offset -= gdk_string_width (widget->style->font, cell_label) + 4;
text_x_offset -= gdk_string_width (widget->style->font, cell_label) + 4;
}
gtk_paint_string (widget->style, widget->window, GTK_STATE_NORMAL,
&cell_redraw_area, widget, "label",
x_offset,
text_x_offset,
cell_rectangle.y + cell_rectangle.height - TITLE_BASELINE_OFFSET,
cell_label);
}
......@@ -624,11 +627,16 @@ nautilus_list_column_title_motion (GtkWidget *widget, GdkEventMotion *event)
static gboolean
nautilus_list_column_title_leave (GtkWidget *widget, GdkEventCrossing *event)
{
NautilusListColumnTitle *column_title;
g_assert (GTK_FLIST (widget->parent) != NULL);
g_assert (NAUTILUS_IS_LIST_COLUMN_TITLE (widget));
column_title = NAUTILUS_LIST_COLUMN_TITLE(widget);
/* see if we need to update the prelight state of a column */
if (track_prelight (widget, (int)event->x, (int)event->y)) {
if (column_title->details->tracking_column_prelight != -1) {
column_title->details->tracking_column_prelight = -1;
gtk_widget_set_state (widget, GTK_STATE_NORMAL);
nautilus_list_column_title_buffered_draw (widget);
}
......
......@@ -92,6 +92,8 @@ static void draw_row (GtkCList *flist, GdkRectangle *area, gint row, GtkCListRow
static void gtk_flist_realize (GtkWidget *widget);
static void gtk_flist_size_request (GtkWidget *widget, GtkRequisition *requisition);
static void gtk_flist_resize_column (GtkCList *widget, int column, int width);
static void gtk_flist_column_resize_track_start (GtkWidget *widget, int column);
static void gtk_flist_column_resize_track (GtkWidget *widget, int column);
static void gtk_flist_column_resize_track_end (GtkWidget *widget, int column);
......@@ -161,6 +163,7 @@ gtk_flist_initialize_class (GtkFListClass *klass)
clist_class->clear = gtk_flist_clear;
clist_class->draw_row = draw_row;
clist_class->resize_column = gtk_flist_resize_column;
widget_class->button_press_event = gtk_flist_button_press;
widget_class->button_release_event = gtk_flist_button_release;
......@@ -1112,6 +1115,21 @@ draw_rows (GtkCList *clist, GdkRectangle *area)
}
}
static void
gtk_flist_resize_column (GtkCList *clist, int column, int width)
{
/* override resize column to invalidate the title */
GtkFList *flist;
g_assert (GTK_IS_FLIST (clist));
flist = GTK_FLIST (clist);
gtk_widget_queue_draw (flist->details->title);
NAUTILUS_CALL_PARENT_CLASS (GTK_CLIST_CLASS, resize_column, (clist, column, width));
}
static void
gtk_flist_track_new_column_width (GtkCList *clist, int column, int new_width)
{
......@@ -1218,6 +1236,7 @@ gtk_flist_column_resize_track_start (GtkWidget *widget, int column)
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_FLIST (widget));
clist = GTK_CLIST (widget);
clist->drag_pos = column;
}
......@@ -1246,6 +1265,7 @@ gtk_flist_column_resize_track_end (GtkWidget *widget, int column)
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_FLIST (widget));
clist = GTK_CLIST (widget);
clist->drag_pos = -1;
}
......
......@@ -171,7 +171,6 @@ nautilus_list_column_title_realize (GtkWidget *widget)
GdkWindowAttr attributes;
int attributes_mask;
g_assert (widget != NULL);
g_assert (NAUTILUS_IS_LIST_COLUMN_TITLE (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
......@@ -326,10 +325,12 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
GdkRectangle cell_rectangle;
GdkRectangle cell_redraw_area;
const char *cell_label;
int x_offset;
int text_x_offset;
int sort_indicator_x_offset;
GnomePixmap *sort_indicator;
gboolean right_justified;
sort_indicator_x_offset = 0;
sort_indicator = NULL;
right_justified = (parent_clist->column[index].justification == GTK_JUSTIFY_RIGHT);
......@@ -354,9 +355,9 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
*/
if (right_justified) {
x_offset = cell_rectangle.x + cell_rectangle.width - CELL_TITLE_INSET;
text_x_offset = cell_rectangle.x + cell_rectangle.width - CELL_TITLE_INSET;
} else {
x_offset = cell_rectangle.x + CELL_TITLE_INSET;
text_x_offset = cell_rectangle.x + CELL_TITLE_INSET;
}
/* Paint the column title tiles as rectangles using "menu" style
......@@ -375,11 +376,16 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
/* Draw the sort indicator if needed */
if (sort_indicator != NULL) {
int y_offset = TITLE_BASELINE_OFFSET + 2;
int y_offset;
if (right_justified) {
x_offset -= SORT_ORDER_INDICATOR_WIDTH;
sort_indicator_x_offset = cell_rectangle.x + CELL_TITLE_INSET;
} else {
sort_indicator_x_offset = cell_rectangle.x + cell_rectangle.width
- CELL_TITLE_INSET - SORT_ORDER_INDICATOR_WIDTH;
}
y_offset = TITLE_BASELINE_OFFSET + 2;
/* allocate the sort indicator copy gc first time around */
if (column_title->details->copy_area_gc == NULL) {
......@@ -389,16 +395,13 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
/* move the pixmap clip mask and origin to the right spot in the gc */
gdk_gc_set_clip_mask (column_title->details->copy_area_gc,
sort_indicator->mask);
gdk_gc_set_clip_origin (column_title->details->copy_area_gc, x_offset, y_offset);
gdk_gc_set_clip_origin (column_title->details->copy_area_gc, sort_indicator_x_offset, y_offset);
gdk_draw_pixmap (widget->window, column_title->details->copy_area_gc,
sort_indicator->pixmap, 0, 0, x_offset, y_offset,
sort_indicator->pixmap, 0, 0, sort_indicator_x_offset, y_offset,
-1, -1);
if (!right_justified) {
x_offset += SORT_ORDER_INDICATOR_WIDTH;
}
}
if (cell_label) {
......@@ -410,12 +413,12 @@ nautilus_list_column_title_paint (GtkWidget *widget, GdkRectangle *area)
*/
nautilus_rectangle_inset (&cell_redraw_area, 2, 2);
if (right_justified) {
x_offset -= gdk_string_width (widget->style->font, cell_label) + 4;
text_x_offset -= gdk_string_width (widget->style->font, cell_label) + 4;
}
gtk_paint_string (widget->style, widget->window, GTK_STATE_NORMAL,
&cell_redraw_area, widget, "label",
x_offset,
text_x_offset,
cell_rectangle.y + cell_rectangle.height - TITLE_BASELINE_OFFSET,
cell_label);
}
......@@ -624,11 +627,16 @@ nautilus_list_column_title_motion (GtkWidget *widget, GdkEventMotion *event)
static gboolean
nautilus_list_column_title_leave (GtkWidget *widget, GdkEventCrossing *event)
{
NautilusListColumnTitle *column_title;
g_assert (GTK_FLIST (widget->parent) != NULL);
g_assert (NAUTILUS_IS_LIST_COLUMN_TITLE (widget));
column_title = NAUTILUS_LIST_COLUMN_TITLE(widget);
/* see if we need to update the prelight state of a column */
if (track_prelight (widget, (int)event->x, (int)event->y)) {
if (column_title->details->tracking_column_prelight != -1) {
column_title->details->tracking_column_prelight = -1;
gtk_widget_set_state (widget, GTK_STATE_NORMAL);
nautilus_list_column_title_buffered_draw (widget);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment