[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk
Subject:    Re: GtkHScale: Jump-to-position by left-click instead of middle-click?
From:       Phong Cao <phngcv () gmail ! com>
Date:       2011-11-19 13:28:09
Message-ID: CAAg__xvv2F-hUAx5gHE6_QmN66DwuAqwweFb2WWh-Hcv05yckA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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 <yeti@physics.muni.cz> 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
phngcv@gmail.com

[Attachment #5 (text/html)]

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 &amp; I won&#39;t do it again next time. Thank \
you and have a good day.<br><br>On Saturday, November 19, 2011, David Nečas &lt;<a \
href="mailto:yeti@physics.muni.cz">yeti@physics.muni.cz</a>&gt; wrote:<br> \
&gt;<br>&gt; Was it really necessary to cross-post this question to *four* \
mailing<br>&gt; lists?<br>&gt;<br>&gt; On Sat, Nov 19, 2011 at 07:55:59AM -0500, \
Phong Cao wrote:<br>&gt;&gt; I use GtkHScale for the progress bar, which is \
responsible for<br> &gt;&gt; updating the track progress &amp; allow user to move to \
different time position<br>&gt;&gt; in the track.<br>&gt;&gt;<br>&gt;&gt; Everything \
works fine until now, except that I can not use left-click<br>&gt;&gt; button to snap \
(or jump) to random position in the GtkHScale. Instead, I<br> &gt;&gt; have to either \
drag or right-mouse-click.<br>&gt;<br>&gt; The following is a kluge, but I suppose if \
you want the first button to<br>&gt; invoke the same response as the middle button it \
should be all right<br>&gt; (written in Python for brevity):<br> &gt;<br>&gt; from \
gi.repository import Gtk<br>&gt;<br>&gt; def button1to2(scale, event):<br>&gt;      \
if event.button == 1:<br>&gt;            event.button = 2<br>&gt;      return \
False<br>&gt;<br>&gt; adj = Gtk.Adjustment.new(0.0, 0.0, 1.0, 0.001, 0.01, 0)<br> \
&gt; scale = Gtk.Scale.new(Gtk.Orientation.HORIZONTAL, adj)<br>&gt; \
scale.set_round_digits(3)<br>&gt; scale.connect(&quot;button-press-event&quot;, \
button1to2)<br>&gt; scale.connect(&quot;button-release-event&quot;, button1to2)<br> \
&gt;<br>&gt; window = Gtk.Window()<br>&gt; window.add(scale)<br>&gt; \
window.set_default_size(400, -1)<br>&gt; window.show_all()<br>&gt; \
window.connect(&quot;destroy&quot;, Gtk.main_quit)<br>&gt; \
Gtk.main()<br>&gt;<br>&gt;<br> &gt; Yeti<br>&gt;<br>&gt;<br><br>-- <br>Phong V. \
Cao<div><a href="mailto:phngcv@gmail.com" \
target="_blank">phngcv@gmail.com</a></div><div><br></div><br>



_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic