From ac56ca8067fd1258bd3c146a624b6430cda57abc Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Wed, 1 Mar 2000 11:14:05 +0000 Subject: [PATCH] r200: Fixed some problems with styles and the collection widget. Still not quite right, but it should work with non-pixmap themes at least! --- ROX-Filer/src/collection.c | 20 +++++++++++++++++++- ROX-Filer/src/dnd.c | 20 ++++++++++++++------ ROX-Filer/src/filer.c | 28 ++++++++++------------------ ROX-Filer/src/gui_support.c | 2 ++ ROX-Filer/src/gui_support.h | 1 + 5 files changed, 46 insertions(+), 25 deletions(-) diff --git a/ROX-Filer/src/collection.c b/ROX-Filer/src/collection.c index 22737dcb..05039f2d 100644 --- a/ROX-Filer/src/collection.c +++ b/ROX-Filer/src/collection.c @@ -97,7 +97,9 @@ static gint collection_paint(Collection *collection, static void collection_size_request(GtkWidget *widget, GtkRequisition *requisition); static void collection_size_allocate(GtkWidget *widget, - GtkAllocation *allocation); + GtkAllocation *allocation); +static void collection_set_style(GtkWidget *widget, + GtkStyle *previous_style); static void collection_set_adjustment(Collection *collection, GtkAdjustment *vadj); static void collection_set_arg( GtkObject *object, @@ -213,6 +215,7 @@ static void collection_class_init(CollectionClass *class) widget_class->expose_event = collection_expose; widget_class->size_request = collection_size_request; widget_class->size_allocate = collection_size_allocate; + widget_class->style_set = collection_set_style; widget_class->key_press_event = collection_key_press; widget_class->button_press_event = collection_button_press; @@ -493,6 +496,21 @@ static void collection_size_allocate(GtkWidget *widget, } } +static void collection_set_style(GtkWidget *widget, + GtkStyle *previous_style) +{ + Collection *collection; + + g_return_if_fail(IS_COLLECTION(widget)); + + collection = COLLECTION(widget); + + collection->paint_level = PAINT_CLEAR; + + if (parent_class->style_set) + (*parent_class->style_set)(widget, previous_style); +} + static gint collection_paint(Collection *collection, GdkRectangle *area) { diff --git a/ROX-Filer/src/dnd.c b/ROX-Filer/src/dnd.c index f59594e0..5c6c333e 100644 --- a/ROX-Filer/src/dnd.c +++ b/ROX-Filer/src/dnd.c @@ -520,14 +520,22 @@ static gboolean drag_motion(GtkWidget *widget, else { /* Drop onto a program of some sort */ - if (provides(context, text_uri_list) - || provides(context, application_octet_stream)) + if (!(provides(context, text_uri_list) || + provides(context, application_octet_stream))) + goto out; + + if (gtk_drag_get_source_widget(context) == widget) { - /* Actually, we should probably allow any data type */ - type = drop_dest_prog; - new_path = make_path(filer_window->path, - item->leafname)->str; + Collection *collection = filer_window->collection; + + if (collection->items[item_number].selected) + goto out; } + + /* Actually, we should probably allow any data type */ + type = drop_dest_prog; + new_path = make_path(filer_window->path, + item->leafname)->str; collection_set_cursor_item(filer_window->collection, item_number); } diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c index 8ffe60a9..94a2b647 100644 --- a/ROX-Filer/src/filer.c +++ b/ROX-Filer/src/filer.c @@ -398,8 +398,7 @@ static gboolean test_point_large(Collection *collection, int width, int height) { DirItem *item = (DirItem *) colitem->data; - GdkFont *font = GTK_WIDGET(collection)->style->font; - int text_height = font->ascent + font->descent; + int text_height = item_font->ascent + item_font->descent; MaskedPixmap *image = item->image; int image_y = MAX(0, MAX_ICON_HEIGHT - image->height); int image_width = (image->width >> 1) + 2; @@ -425,7 +424,6 @@ static gboolean test_point_full_info(Collection *collection, int width, int height) { DirItem *item = (DirItem *) colitem->data; - GdkFont *font = GTK_WIDGET(collection)->style->font; MaskedPixmap *image = item->image; int image_y = MAX(0, MAX_ICON_HEIGHT - image->height); int low_top = height @@ -438,7 +436,7 @@ static gboolean test_point_full_info(Collection *collection, if (point_y >= low_top) return point_x < item->details_width; - if (point_y >= low_top - font->ascent - font->descent) + if (point_y >= low_top - item_font->ascent - item_font->descent) return point_x < item->name_width; return FALSE; } @@ -451,9 +449,8 @@ static gboolean test_point_small(Collection *collection, DirItem *item = (DirItem *) colitem->data; MaskedPixmap *image = item->image; int image_y = MAX(0, SMALL_ICON_HEIGHT - image->height); - GdkFont *font = GTK_WIDGET(collection)->style->font; int low_top = height - - fixed_font->descent - 2 - font->ascent; + - fixed_font->descent - 2 - item_font->ascent; int iwidth = MIN(SMALL_ICON_WIDTH, image->width); if (point_x < iwidth + 2) @@ -655,7 +652,6 @@ static void draw_item_full_info(GtkWidget *widget, { DirItem *item = (DirItem *) colitem->data; MaskedPixmap *image = item->image; - GdkFont *font = widget->style->font; int text_x = area->x + MAX_ICON_WIDTH + 8; int low_text_y = area->y + area->height - fixed_font->descent - 2; gboolean selected = colitem->selected; @@ -669,10 +665,10 @@ static void draw_item_full_info(GtkWidget *widget, draw_large_icon(widget, &pic_area, item, selected); draw_string(widget, - widget->style->font, + item_font, item->leafname, text_x, - low_text_y - font->descent - fixed_font->ascent, + low_text_y - item_font->descent - fixed_font->ascent, item->name_width, selected); draw_string(widget, @@ -696,9 +692,8 @@ static void draw_item_small(GtkWidget *widget, GdkRectangle *area) { DirItem *item = (DirItem *) colitem->data; - GdkFont *font = widget->style->font; int text_x = area->x + SMALL_ICON_WIDTH + 4; - int low_text_y = area->y + area->height - font->descent - 2; + int low_text_y = area->y + area->height - item_font->descent - 2; gboolean selected = colitem->selected; GdkRectangle pic_area; @@ -710,7 +705,7 @@ static void draw_item_small(GtkWidget *widget, draw_small_icon(widget, &pic_area, item, selected); draw_string(widget, - widget->style->font, + item_font, item->leafname, text_x, low_text_y, @@ -723,15 +718,14 @@ static void draw_item_large(GtkWidget *widget, GdkRectangle *area) { DirItem *item = (DirItem *) colitem->data; - GdkFont *font = widget->style->font; int text_x = area->x + ((area->width - item->name_width) >> 1); - int text_y = area->y + area->height - font->descent - 2; + int text_y = area->y + area->height - item_font->descent - 2; gboolean selected = colitem->selected; draw_large_icon(widget, area, item, selected); draw_string(widget, - widget->style->font, + item_font, item->leafname, text_x, text_y, item->name_width, selected); @@ -1326,11 +1320,9 @@ static void shrink_width(FilerWindow *filer_window) int width = MIN_ITEM_WIDTH; int this_width; DisplayStyle style = filer_window->display_style; - GdkFont *font; int text_height; - font = gtk_widget_get_default_style()->font; - text_height = font->ascent + font->descent; + text_height = item_font->ascent + item_font->descent; for (i = 0; i < col->number_of_items; i++) { diff --git a/ROX-Filer/src/gui_support.c b/ROX-Filer/src/gui_support.c index 9d5e6a6d..6b86e58a 100644 --- a/ROX-Filer/src/gui_support.c +++ b/ROX-Filer/src/gui_support.c @@ -36,6 +36,7 @@ #include "main.h" #include "gui_support.h" +GdkFont *item_font = NULL; GdkFont *fixed_font = NULL; GtkStyle *fixed_style = NULL; gint fixed_width; @@ -45,6 +46,7 @@ static GdkAtom xa_cardinal; void gui_support_init() { fixed_font = gdk_font_load("fixed"); + item_font = gtk_widget_get_default_style()->font; fixed_style = gtk_style_copy(gtk_widget_get_default_style()); fixed_style->font = fixed_font; diff --git a/ROX-Filer/src/gui_support.h b/ROX-Filer/src/gui_support.h index 57776f3f..2152d618 100644 --- a/ROX-Filer/src/gui_support.h +++ b/ROX-Filer/src/gui_support.h @@ -16,6 +16,7 @@ #define WIN_STATE_ARRANGE_IGNORE (1<<9) /* Ignore for auto arranging */ extern GdkFont *fixed_font; +extern GdkFont *item_font; extern GtkStyle *fixed_style; extern gint fixed_width; -- 2.11.4.GIT