Wheel mouse support.
- From: Mike Kelly <mike csuchico edu>
- To: gtk-devel-list gnome org
- Subject: Wheel mouse support.
- Date: Fri, 27 Apr 2001 13:27:08 -0700
Hi,
I've created a small patch against gtk+-1.2.10 that enhances wheel mouse
support. I don't think that this patch should be applied to GTK as is
because I want to improve it some more after discussing it with this list.
=-=-=-=-=-=-= very short patch =-=-=-=-=-=-=
--- gtk+-1.2.10/gtk/gtkmain.c.orig Tue Feb 27 10:29:58 2001
+++ gtk+-1.2.10/gtk/gtkmain.c Thu Apr 26 20:34:36 2001
@@ -791,9 +791,19 @@
if (event->type == GDK_BUTTON_PRESS)
{
GtkAdjustment *adj = GTK_RANGE (range)->adjustment;
- gfloat new_value = adj->value + ((event->button.button == 4) ?
+ gfloat new_value;
+ if (event->button.state & GDK_SHIFT_MASK)
+ new_value = adj->value + ((event->button.button == 4) ?
-adj->page_increment / 2:
adj->page_increment / 2);
+ else if (event->button.state & GDK_CONTROL_MASK)
+ new_value = adj->value + ((event->button.button == 4) ?
+ -adj->page_increment:
+ adj->page_increment);
+ else
+ new_value = adj->value + ((event->button.button == 4) ?
+ -adj->step_increment:
+ adj->step_increment);
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Basically what my patch does is allow users to scroll by line, or by half
page when holding the shift key, or by full page when holding the control
key. The key bindings are simply my personal preference, which may not
be those of someone else. So, my first question is: Is there a config file
(.gtkrc or gtkrc.mine?) where these key bindings can be stored? Right now,
this file seems to be reserved for themes. Any thoughts on this would be
greatly appreciated.
My second question has to do with implementation. Currently GTK checks to
see if the object receiving the button clicks is either a range widget, or
a scrolled window (in which case its associated scroll bar is grabbed). The
problem with this seems to be that people who develop their own widgets don't
necessarily implement their widget as one of these two types. Two examples
of this are xchat and gnome-terminal. I'm not a long-time GTK hacker, so I
don't know if this is because these widgets are written incorrectly, or if
it is because GTK lacks a generic "scrollable" type. Should these apps
inherit from the range class, or from the scrolled window class, or should a
new (or existing) third class be inherited from? With a situation like this,
a programmer could mark their widget for inclusion of scrolling signals via
the default GTK handler, rather than having to essentially duplicate this
code.
Once again, any insight you can give me, comments or flames, are appreciated.
I'm not a regular subscriber to this list, so pleas CC me with any related
discussion.
Thanks,
Mike
(:
--
--------Mike csuchico edu--------------------------The_glass_is_too_big--------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]