summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2013-06-12 12:10:53 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2013-06-19 23:04:50 +0200
commit053b72ea7a2bf0dbb28d61ad70e7836034ca4e7e (patch)
tree8f7015cb35e974350a6a87c6c6cb6a92d332811d
parent4f1daf9620c7919db40c5aece15f2fcb01107612 (diff)
Fix play seek scale.
In the transition from glade to gtkbuilder the adjustment for seek_scale went AWOL. As a result that slider didn't move in playback and trying to seek with the mouse rewound the track to the start because the range for the scale wasn't properly initialized. This fix adds the adjustment back into the UI file, updates the scale widget to GtkScale and fixes seeking with the keyboard as well. N.B. The keyboard fix bumps the minimum GTK version requirement to 3.2 https://bugzilla.gnome.org/show_bug.cgi?id=637867
-rw-r--r--configure.ac2
-rw-r--r--data/sound-juicer.ui13
-rw-r--r--src/sj-play.c26
-rw-r--r--src/sj-play.h4
4 files changed, 39 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index 91ea529..97e3cbd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,7 @@ GNOME_COMPILE_WARNINGS([maximum])
GNOME_DEBUG_CHECK
GNOME_MAINTAINER_MODE_DEFINES
-GTK_REQUIRED=2.90.0
+GTK_REQUIRED=3.2.0
AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(socket,socket)])
diff --git a/data/sound-juicer.ui b/data/sound-juicer.ui
index 7bbb200..f0da8c4 100644
--- a/data/sound-juicer.ui
+++ b/data/sound-juicer.ui
@@ -361,7 +361,9 @@
</packing>
</child>
<child>
- <object class="GtkHScale" id="seek_scale">
+ <object class="GtkScale" id="seek_scale">
+ <property name="orientation">0</property>
+ <property name="adjustment">seek_adjustment</property>
<property name="can_focus">True</property>
<property name="digits">0</property>
<property name="draw_value">False</property>
@@ -371,12 +373,21 @@
</object>
</child>
<signal name="button_press_event" handler="on_seek_press"/>
+ <signal name="key_press_event" handler="on_seek_press"/>
<signal name="value_changed" handler="on_seek_moved"/>
<signal name="button_release_event" handler="on_seek_release"/>
+ <signal name="key_release_event" handler="on_seek_release"/>
</object>
<packing>
<property name="position">2</property>
</packing>
+ <object class="GtkAdjustment" id="seek_adjustment">
+ <property name="value">0</property>
+ <property name="lower">0</property>
+ <property name="upper">1</property>
+ <property name="step_increment">0.01</property>
+ <property name="page_increment">0</property>
+ </object>
</child>
<child>
<object class="GtkVolumeButton" id="volume_button">
diff --git a/src/sj-play.c b/src/sj-play.c
index c00ebb4..d6fbac9 100644
--- a/src/sj-play.c
+++ b/src/sj-play.c
@@ -539,13 +539,30 @@ on_volume_changed (GtkWidget * volb, gdouble value, gpointer data)
gconf_client_set_float (gconf_client, GCONF_AUDIO_VOLUME, vol, NULL);
}
+static gboolean
+is_non_seek_key (GdkEvent * event)
+{
+ guint key;
+
+ return gdk_event_get_keyval (event, &key) &&
+ key != GDK_KEY_Left && key != GDK_KEY_KP_Left &&
+ key != GDK_KEY_Right && key != GDK_KEY_KP_Right &&
+ key != GDK_KEY_Up && key != GDK_KEY_KP_Up &&
+ key != GDK_KEY_Down && key != GDK_KEY_KP_Down &&
+ key != GDK_KEY_End && key != GDK_KEY_KP_End &&
+ key != GDK_KEY_Home && key != GDK_KEY_KP_Home;
+}
+
/*
* Seeking.
*/
G_MODULE_EXPORT gboolean
-on_seek_press (GtkWidget * scale, GdkEventButton * event, gpointer user_data)
+on_seek_press (GtkWidget * scale, GdkEvent * event, gpointer user_data)
{
+ if (is_non_seek_key (event))
+ return FALSE;
+
seeking = TRUE;
return FALSE;
@@ -568,10 +585,15 @@ on_seek_moved (GtkWidget * scale, gpointer user_data)
}
G_MODULE_EXPORT gboolean
-on_seek_release (GtkWidget * scale, GdkEventButton * event, gpointer user_data)
+on_seek_release (GtkWidget * scale, GdkEvent * event, gpointer user_data)
{
gdouble val = gtk_range_get_value (GTK_RANGE (scale));
+ /* If gst_element_seek is called when non-seeking key is released it
+ causes a glitch in playback*/
+ if (is_non_seek_key (event))
+ return FALSE;
+
seeking = FALSE;
gst_element_seek (pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, slen * val, GST_SEEK_TYPE_NONE, -1);
diff --git a/src/sj-play.h b/src/sj-play.h
index 03395d3..354fee2 100644
--- a/src/sj-play.h
+++ b/src/sj-play.h
@@ -47,13 +47,13 @@ G_MODULE_EXPORT void on_tracklist_row_selected (GtkTreeView *treeview,
G_MODULE_EXPORT void on_volume_changed (GtkWidget* volb, gdouble value, gpointer data);
G_MODULE_EXPORT gboolean on_seek_press (GtkWidget * scale,
- GdkEventButton * event,
+ GdkEvent * event,
gpointer user_data);
G_MODULE_EXPORT void on_seek_moved (GtkWidget * scale, gpointer user_data);
G_MODULE_EXPORT gboolean on_seek_release (GtkWidget * scale,
- GdkEventButton * event,
+ GdkEvent * event,
gpointer user_data);
#endif /* SJ_PLAY_H_H */