[Nautilus-list] [PATCH] Throbber prelighting



Hello,

this patch makes the throbber prelit when you move the mouse over it, it
also changes behavior to not be activated until you release the mouse
button.

//andersca
andersca gnu org
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.4618
diff -u -r1.4618 ChangeLog
--- ChangeLog	2001/05/17 03:15:15	1.4618
+++ ChangeLog	2001/05/17 09:44:24
@@ -1,3 +1,15 @@
+2001-05-17  Anders Carlsson  <andersca codefactory se>
+
+	* components/throbber/nautilus-throbber.c: Add is_prelit to the 
+	NautilusThrobberDetails struct.
+	(nautilus_throbber_enter_notify_event): New function, set
+	the throbber to be prelit if it isn't already.
+	(nautilus_throbber_leave_notify_event): New function, set
+	the throbber not to be prelit if it is.
+	(nautilus_throbber_button_release_event): Make the throbber
+	activated on button release events since it now behaves more
+	like a button UI wise.
+
 2001-05-16  Darin Adler  <darin eazel com>
 
 	* configure.in: Up version to 1.0.3.1 so we don't confuse cvs
Index: components/throbber/nautilus-throbber.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/throbber/nautilus-throbber.c,v
retrieving revision 1.13
diff -u -r1.13 nautilus-throbber.c
--- components/throbber/nautilus-throbber.c	2001/05/11 01:30:29	1.13
+++ components/throbber/nautilus-throbber.c	2001/05/17 09:44:24
@@ -37,6 +37,7 @@
 #include <libgnomeui/gnome-pixmap.h>
 #include <libnautilus-private/nautilus-file-utilities.h>
 #include <eel/eel-glib-extensions.h>
+#include <eel/eel-graphic-effects.h>
 #include <libnautilus-private/nautilus-global-preferences.h>
 #include <eel/eel-gtk-extensions.h>
 #include <eel/eel-gtk-macros.h>
@@ -61,6 +62,8 @@
 	
 	gboolean ready;
 	gboolean small_mode;
+
+	gboolean is_prelit;
 };
 
 
@@ -71,8 +74,13 @@
 							  GdkRectangle *box);
 static int      nautilus_throbber_expose 		 (GtkWidget *widget, 
 							  GdkEventExpose *event);
-static gboolean nautilus_throbber_button_press_event	 (GtkWidget *widget, 
+static gboolean nautilus_throbber_button_release_event	 (GtkWidget *widget, 
 							  GdkEventButton *event);
+static gboolean nautilus_throbber_enter_notify_event	 (GtkWidget *widget, 
+							  GdkEventCrossing *event);
+static gboolean nautilus_throbber_leave_notify_event	 (GtkWidget *widget, 
+							  GdkEventCrossing *event);
+
 static void nautilus_throbber_map				 (GtkWidget *widget); 
 
 static void	nautilus_throbber_load_images		 (NautilusThrobber *throbber);
@@ -94,7 +102,9 @@
 
 	widget_class->draw = nautilus_throbber_draw;
 	widget_class->expose_event = nautilus_throbber_expose;
-	widget_class->button_press_event = nautilus_throbber_button_press_event;
+	widget_class->button_release_event = nautilus_throbber_button_release_event;
+	widget_class->enter_notify_event = nautilus_throbber_enter_notify_event;
+	widget_class->leave_notify_event = nautilus_throbber_leave_notify_event;
 	widget_class->size_allocate = nautilus_throbber_size_allocate;
 	widget_class->size_request = nautilus_throbber_size_request;	
 	widget_class->map = nautilus_throbber_map;
@@ -264,7 +274,8 @@
 	GTK_WIDGET_UNSET_FLAGS (throbber, GTK_NO_WINDOW);
 
 	gtk_widget_set_events (widget, 
-			       gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
+			       gtk_widget_get_events (widget) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
+			       GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
 	
 	throbber->details = g_new0 (NautilusThrobberDetails, 1);
 	throbber->details->ready = FALSE;
@@ -392,8 +403,18 @@
 
 	/* center the throbber image in the gdk window */	
 	x_offset = (window_width - gdk_pixbuf_get_width (pixbuf)) / 2;
-	y_offset = (window_height - gdk_pixbuf_get_height (pixbuf)) / 2;		
-	draw_pixbuf (pixbuf, widget->window, box->x + x_offset, box->y + y_offset);
+	y_offset = (window_height - gdk_pixbuf_get_height (pixbuf)) / 2;
+	
+	if (throbber->details->is_prelit) {
+		GdkPixbuf *lit_pixbuf = eel_create_spotlight_pixbuf (pixbuf);
+
+		draw_pixbuf (lit_pixbuf, widget->window, box->x + x_offset, box->y + y_offset);
+
+		gdk_pixbuf_unref (lit_pixbuf);
+	}
+	else {
+		draw_pixbuf (pixbuf, widget->window, box->x + x_offset, box->y + y_offset);
+	}
 }
 
 static void
@@ -596,10 +617,42 @@
 	g_free (image_theme);
 }
 
+static gboolean
+nautilus_throbber_enter_notify_event (GtkWidget *widget, GdkEventCrossing *event)
+{
+	NautilusThrobber *throbber;
+
+	throbber = NAUTILUS_THROBBER (widget);
+
+	if (throbber->details->is_prelit == FALSE) {
+		throbber->details->is_prelit = TRUE;
+
+		gtk_widget_queue_draw (widget);
+	}
+
+	return TRUE;
+}
+
+static gboolean
+nautilus_throbber_leave_notify_event (GtkWidget *widget, GdkEventCrossing *event)
+{
+	NautilusThrobber *throbber;
+
+	throbber = NAUTILUS_THROBBER (widget);
+
+	if (throbber->details->is_prelit == TRUE) {
+		throbber->details->is_prelit = FALSE;
+
+		gtk_widget_queue_draw (widget);
+	}
+
+	return TRUE;
+}
+
 /* handle button presses by posting a change on the "location" property */
 
 static gboolean
-nautilus_throbber_button_press_event (GtkWidget *widget, GdkEventButton *event)
+nautilus_throbber_button_release_event (GtkWidget *widget, GdkEventButton *event)
 {	
 	char *location;
 	NautilusThrobber *throbber;


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