GtkHScale: Jump-to-position by left-click instead of middle-click?

2011-11-19 Thread Phong Cao
Hello everybody,

I am new to GTK. I am trying to develop a small music player using GTK &
GStreamer. I use GtkHScale for the progress bar, which is responsible for
updating the track progress & allow user to move to different time position
in the track.

Everything works fine until now, except that I can not use left-click
button to snap (or jump) to random position in the GtkHScale. Instead, I
have to either drag or right-mouse-click. I have tried to solve this
problem for several days and still can not figure out how to use left-click
to jump to different position in the GtkHScale. I have searched through the
GTK+ mail archive & reference but found no place talking about this.

Does anybody here know how to implement this functionality for GtkHScale?
If so I hope you can give me a hint.

Thank you and have a good day!

-- 
Phong V. Cao
phn...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkHScale: Jump-to-position by left-click instead of middle-click?

2011-11-19 Thread David Nečas

Was it really necessary to cross-post this question to *four* mailing
lists?

On Sat, Nov 19, 2011 at 07:55:59AM -0500, Phong Cao wrote:
> I use GtkHScale for the progress bar, which is responsible for
> updating the track progress & allow user to move to different time position
> in the track.
> 
> Everything works fine until now, except that I can not use left-click
> button to snap (or jump) to random position in the GtkHScale. Instead, I
> have to either drag or right-mouse-click.

The following is a kluge, but I suppose if you want the first button to
invoke the same response as the middle button it should be all right
(written in Python for brevity):

from gi.repository import Gtk

def button1to2(scale, event):
if event.button == 1:
event.button = 2
return False

adj = Gtk.Adjustment.new(0.0, 0.0, 1.0, 0.001, 0.01, 0)
scale = Gtk.Scale.new(Gtk.Orientation.HORIZONTAL, adj)
scale.set_round_digits(3)
scale.connect("button-press-event", button1to2)
scale.connect("button-release-event", button1to2)

window = Gtk.Window()
window.add(scale)
window.set_default_size(400, -1)
window.show_all()
window.connect("destroy", Gtk.main_quit)
Gtk.main()


Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkHScale: Jump-to-position by left-click instead of middle-click?

2011-11-19 Thread Phong Cao
Thank you David for your response. I am just a Gtk newbie so this question
is a tough one for me. Sorry for cross-posting & I won't do it again next
time. Thank you and have a good day.

On Saturday, November 19, 2011, David Nečas  wrote:
>
> Was it really necessary to cross-post this question to *four* mailing
> lists?
>
> On Sat, Nov 19, 2011 at 07:55:59AM -0500, Phong Cao wrote:
>> I use GtkHScale for the progress bar, which is responsible for
>> updating the track progress & allow user to move to different time
position
>> in the track.
>>
>> Everything works fine until now, except that I can not use left-click
>> button to snap (or jump) to random position in the GtkHScale. Instead, I
>> have to either drag or right-mouse-click.
>
> The following is a kluge, but I suppose if you want the first button to
> invoke the same response as the middle button it should be all right
> (written in Python for brevity):
>
> from gi.repository import Gtk
>
> def button1to2(scale, event):
>if event.button == 1:
>event.button = 2
>return False
>
> adj = Gtk.Adjustment.new(0.0, 0.0, 1.0, 0.001, 0.01, 0)
> scale = Gtk.Scale.new(Gtk.Orientation.HORIZONTAL, adj)
> scale.set_round_digits(3)
> scale.connect("button-press-event", button1to2)
> scale.connect("button-release-event", button1to2)
>
> window = Gtk.Window()
> window.add(scale)
> window.set_default_size(400, -1)
> window.show_all()
> window.connect("destroy", Gtk.main_quit)
> Gtk.main()
>
>
> Yeti
>
>

-- 
Phong V. Cao
phn...@gmail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list