Re: [patch] fix bug #97486 (In single click mode, underlining items is irritating)



On Mon, 2002-11-04 at 17:09, Alexander Larsson wrote:

Hi,

> > this patch fixes bug #97486. There are no longer underlined icons, but
> > there is a hand cursor in single click mode.
> > 
> @@ -1443,8 +1426,13 @@
>                         icon_item->details->is_prelit = FALSE;
>                         icon_item->details->is_active = 0;                      
>                         icon_item->details->is_highlighted_for_drop = FALSE;
> -                       update_label_layouts (icon_item);
>                         eel_canvas_item_request_update (item);
> +
> +                       /* show default cursor */
> +                       cursor = gdk_cursor_new_for_display (gdk_display_get_default(),
> +                                                            GDK_LEFT_PTR);
> +                       gdk_window_set_cursor (((GdkEventAny *)event)->window, cursor);
> +                       gdk_cursor_unref (cursor);
>                 }
>                 return TRUE;
> 
> Set the window cursor to NULL instead here.

Ok. Updated patch attached.

Jan Arne Petersen
Index: nautilus-icon-canvas-item.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-canvas-item.c,v
retrieving revision 1.160
diff -u -r1.160 nautilus-icon-canvas-item.c
--- nautilus-icon-canvas-item.c	6 Oct 2002 01:12:58 -0000	1.160
+++ nautilus-icon-canvas-item.c	4 Nov 2002 20:07:16 -0000
@@ -178,7 +178,6 @@
 
 static gboolean hit_test_stretch_handle              (NautilusIconCanvasItem        *item,
 						      ArtIRect                       canvas_rect);
-static void     update_label_layouts                 (NautilusIconCanvasItem        *item);
 static void     clear_rounded_corners                (GdkPixbuf                     *destination_pixbuf,
 						      GdkPixbuf                     *corner_pixbuf,
 						      int                            corner_size);
@@ -728,7 +727,7 @@
 	/* No font or no text, then do no work. */
 	if (!have_editable && !have_additional) {
 		details->text_height = 0;
-		details->text_width = 0;			
+		details->text_width = 0;
 		return;
 	}
 
@@ -828,19 +827,19 @@
 				      "frame_text", &needs_frame,
 				      NULL);
 		if (needs_frame && !needs_highlight && details->text_width > 0 && details->text_height > 0) {
-			draw_frame (item, 
+			draw_frame (item,
 				    drawable,
 				    eel_gdk_color_to_rgb (&GTK_WIDGET (container)->style->base[GTK_STATE_NORMAL]),
 				    icon_left + (icon_width - details->text_width) / 2,
 				    icon_bottom,
-				    details->text_width, 
-				    details->text_height);	    
+				    details->text_width,
+				    details->text_height);
 		}
 		
 		gc = nautilus_icon_container_get_label_color_and_gc
 			(NAUTILUS_ICON_CONTAINER (canvas_item->canvas),
 			 &label_color, TRUE, needs_highlight);
-		
+
 		draw_label_layout (item, drawable,
 				   editable_layout, needs_highlight,
 				   label_color,
@@ -1241,23 +1240,6 @@
 	draw_label_text (icon_item, drawable, icon_rect.x0, icon_rect.y1);
 }
 
-static void
-update_label_layouts (NautilusIconCanvasItem *item)
-{
-	PangoUnderline underline;
-
-	underline = (item->details->is_prelit && in_single_click_mode ()) ?
-		PANGO_UNDERLINE_SINGLE : PANGO_UNDERLINE_NONE;
-
-	if (item->details->editable_text_layout != NULL) {
-		eel_pango_layout_set_underline (item->details->editable_text_layout, underline);
-	}
-
-	if (item->details->additional_text_layout != NULL) {
-		eel_pango_layout_set_underline (item->details->additional_text_layout, underline);
-	}
-}
-
 static PangoLayout *
 create_label_layout (NautilusIconCanvasItem *item,
 		     const char *text)
@@ -1292,11 +1274,6 @@
 	pango_layout_set_font_description (layout, desc);
 	pango_font_description_free (desc);
 	
-	/* if it's prelit, and we're in click-to-activate mode, underline the text */
-	if (item->details->is_prelit && in_single_click_mode ()) {
-		eel_pango_layout_set_underline (layout, PANGO_UNDERLINE_SINGLE);
-	}
-	
 	return layout;
 }
 
@@ -1307,8 +1284,6 @@
 {
 	if (*layout == NULL) {
 		*layout = create_label_layout (item, text);
-
-		update_label_layouts (item);
 	}
 	
 	g_object_ref (*layout);
@@ -1395,6 +1370,7 @@
 nautilus_icon_canvas_item_event (EelCanvasItem *item, GdkEvent *event)
 {
 	NautilusIconCanvasItem *icon_item;
+	GdkCursor *cursor;
 
 	icon_item = NAUTILUS_ICON_CANVAS_ITEM (item);
 
@@ -1402,8 +1378,15 @@
 	case GDK_ENTER_NOTIFY:
 		if (!icon_item->details->is_prelit) {
 			icon_item->details->is_prelit = TRUE;
-			update_label_layouts (icon_item);
 			eel_canvas_item_request_update (item);
+			/* show a hand cursor */
+			if (in_single_click_mode ()) {
+				cursor = gdk_cursor_new_for_display (gdk_display_get_default(),
+								     GDK_HAND2);
+				gdk_window_set_cursor (((GdkEventAny *)event)->window, cursor);
+				gdk_cursor_unref (cursor);
+			}
+
 			/* FIXME bugzilla.gnome.org 42473: 
 			 * We should emit our own signal here,
 			 * not one from the container; it could hook
@@ -1443,8 +1426,10 @@
 			icon_item->details->is_prelit = FALSE;
 			icon_item->details->is_active = 0;			
 			icon_item->details->is_highlighted_for_drop = FALSE;
-			update_label_layouts (icon_item);
 			eel_canvas_item_request_update (item);
+
+			/* show default cursor */
+			gdk_window_set_cursor (((GdkEventAny *)event)->window, NULL);
 		}
 		return TRUE;
 		


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]