[PATCH] Mouse wheel support in icon selector



Hello,

attached is a patch that adds support for mouse wheel scrolling in the
gnome icon selector. It doesn't change any data structures so it should
be safe to add this to the stable branch.

//andersca
andersca gnu org
Index: libgnomeui/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/ChangeLog,v
retrieving revision 1.1161.4.104
diff -u -r1.1161.4.104 ChangeLog
--- libgnomeui/ChangeLog	2001/01/23 03:29:07	1.1161.4.104
+++ libgnomeui/ChangeLog	2001/02/04 18:25:25
@@ -1,3 +1,11 @@
+2001-02-04  Anders Carlsson  <andersca codefactory se>
+
+	* gnome-icon-sel.c (gnome_icon_selection_init): Connect to 
+	button_press_events, since mouse wheel events are mouse button
+	events with buttons 4 and 5.
+	(gnome_icon_list_button_press_event): New function that sets the
+	adjustments if the wheel is used.
+
 2001-01-22  Miguel de Icaza  <miguel ximian com>
 
 	* gnome-dialog.c (gnome_dialog_set_default): Do not grab focus.
Index: libgnomeui/gnome-icon-sel.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-icon-sel.c,v
retrieving revision 1.18.4.1
diff -u -r1.18.4.1 gnome-icon-sel.c
--- libgnomeui/gnome-icon-sel.c	1999/11/11 01:55:59	1.18.4.1
+++ libgnomeui/gnome-icon-sel.c	2001/02/04 18:25:25
@@ -43,6 +43,7 @@
 static GtkVBoxClass *parent_class;
 
 static int sort_file_list( gconstpointer a, gconstpointer b);
+static gboolean gnome_icon_list_button_press_event (GtkWidget *widget, GdkEventButton *button, gpointer data);
 
 guint
 gnome_icon_selection_get_type ()
@@ -109,6 +110,9 @@
 	gis->gil = gnome_icon_list_new(ICON_SIZE+30,
 				       gtk_range_get_adjustment(GTK_RANGE(sb)),
 				       FALSE);
+	gtk_signal_connect (GTK_OBJECT (gis->gil), "button_press_event",
+			    GTK_SIGNAL_FUNC (gnome_icon_list_button_press_event), gis);
+	
 	gtk_widget_set_usize(gis->gil,350,300);
 	gnome_icon_list_set_selection_mode(GNOME_ICON_LIST(gis->gil),
 					   GTK_SELECTION_SINGLE);
@@ -117,8 +121,24 @@
 
 	gis->file_list = NULL;
 }
-
+	
+static gboolean gnome_icon_list_button_press_event (GtkWidget *widget, GdkEventButton *button, gpointer data)
+{
+	if (button->button == 4 || button->button == 5) {
+		GnomeIconSelection *gis = GNOME_ICON_SELECTION (data);
+		GtkAdjustment *adj = GNOME_ICON_LIST (gis->gil)->adj;
+		gfloat new_value = adj->value + ((button->button == 4) ?
+						 - adj->page_increment / 2:
+						 adj->page_increment / 2);
+		new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
+		gtk_adjustment_set_value (adj, new_value);
+		
+		return TRUE;
+	}
 
+	return FALSE;
+}
+	
 /**
  * gnome_icon_selection_new:
  *


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