last-exit r170 - in trunk: . data/glade liblast-exit src
- From: bhale svn gnome org
- To: svn-commits-list gnome org
- Subject: last-exit r170 - in trunk: . data/glade liblast-exit src
- Date: Sun, 30 Mar 2008 02:40:14 +0100 (BST)
Author: bhale
Date: Sun Mar 30 02:40:14 2008
New Revision: 170
URL: http://svn.gnome.org/viewvc/last-exit?rev=170&view=rev
Log:
Incorporate a long desired feature to display running track time vs
estimated track duration. This uses a label instead of an hscale, to
keep grumpy Last Exit maintainers at bay. Slightly modified from a
patch by Jordan Callicoat on Gnome Bug #490989.
Modified:
trunk/ChangeLog
trunk/data/glade/PlayerWindow.glade
trunk/liblast-exit/player.c
trunk/src/Config.cs
trunk/src/PlayerWindow.cs
trunk/src/Song.cs
Modified: trunk/data/glade/PlayerWindow.glade
==============================================================================
--- trunk/data/glade/PlayerWindow.glade (original)
+++ trunk/data/glade/PlayerWindow.glade Sun Mar 30 02:40:14 2008
@@ -446,7 +446,19 @@
<property name="spacing">0</property>
<child>
- <placeholder/>
+ <widget class="GtkLabel" id="progress_label">
+ <property name="visible">False</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_markup">True</property>
+ <property name="single_line_mode">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_START</property>
+ </packing>
</child>
<child>
Modified: trunk/liblast-exit/player.c
==============================================================================
--- trunk/liblast-exit/player.c (original)
+++ trunk/liblast-exit/player.c Sun Mar 30 02:40:14 2008
@@ -251,3 +251,16 @@
GST_STATE_NULL);
}
+gint64
+player_get_stream_position (Player *player)
+{
+ GstFormat fmt = GST_FORMAT_TIME; // time in nanoseconds
+ gint64 pos;
+
+ if (gst_element_query_position (player->priv->play,
+ &fmt,
+ &pos))
+ return pos;
+ else
+ return -1;
+}
Modified: trunk/src/Config.cs
==============================================================================
--- trunk/src/Config.cs (original)
+++ trunk/src/Config.cs Sun Mar 30 02:40:14 2008
@@ -31,6 +31,8 @@
private const string GConfRecommendationLevel = "/apps/lastexit/recommendation_level";
private const string GConfShowNotifications = "/apps/lastexit/show_notifications";
+ private const string GConfShowProgress = "/apps/lastexit/show_progress";
+ private const string GConfShowDuration = "/apps/lastexit/show_duration";
public static Client config;
@@ -138,6 +140,46 @@
set { config.Set (GConfShowNotifications, (object) value); }
}
+ public bool ShowProgress {
+ get {
+ object o;
+ try {
+ o = config.Get (GConfShowProgress);
+ } catch (GConf.NoSuchKeyException) {
+ config.Set (GConfShowProgress,
+ (object) false);
+ return false;
+ }
+
+ if (o == null) {
+ return false;
+ } else {
+ return (bool) o;
+ }
+ }
+ set { config.Set (GConfShowProgress, (object) value); }
+ }
+
+ public bool ShowDuration {
+ get {
+ object o;
+ try {
+ o = config.Get (GConfShowDuration);
+ } catch (GConf.NoSuchKeyException) {
+ config.Set (GConfShowDuration,
+ (object) false);
+ return false;
+ }
+
+ if (o == null) {
+ return false;
+ } else {
+ return (bool) o;
+ }
+ }
+ set { config.Set (GConfShowDuration, (object) value); }
+ }
+
public void GConfAddNotify (string dir, NotifyEventHandler handler)
{
config.AddNotify (dir, handler);
Modified: trunk/src/PlayerWindow.cs
==============================================================================
--- trunk/src/PlayerWindow.cs (original)
+++ trunk/src/PlayerWindow.cs Sun Mar 30 02:40:14 2008
@@ -20,6 +20,7 @@
*/
using System;
+using System.Text;
using System.Collections;
using Gtk;
@@ -81,6 +82,8 @@
private Gdk.Pixbuf recommended_image;
private Gdk.Pixbuf favourite_image;
+ [Glade.Widget] private Label progress_label;
+
private Song current_song;
private InfoWindow i_window = null;
@@ -264,6 +267,9 @@
hate_button.Add (hate_image);
hate_image.Visible = true;
+ progress_label.CanFocus = false;
+ progress_label.Visible = false;
+
// Add additional search path
IconTheme current_theme = IconTheme.Default;
current_theme.AppendSearchPath(Defines.PREFIX+"/share/icons/");
@@ -313,6 +319,7 @@
tag_button.Sensitive = false;
journal_button.Sensitive = false;
info_button.Sensitive = false;
+ progress_label.Visible = false;
}
station_combo.Model = stations;
@@ -442,7 +449,48 @@
bool sensitive = (bool) model.GetValue (iter, (int) Column.Sensitive);
cell.Sensitive = sensitive;
}
+
+ private string get_time (ref uint seconds, ushort divisor, string fallback)
+ {
+ uint time = seconds / divisor;
+ if (time > 0) {
+ string time_string;
+ time_string = Convert.ToInt32(time).ToString();
+ seconds = seconds % divisor;
+ return time_string + ":";
+ } else {
+ return fallback;
+ }
+ }
+
+ private string format_time_string (uint seconds) {
+ StringBuilder formatted_time = new StringBuilder ();
+ formatted_time.Append(get_time (ref seconds, 3600, ""));
+ formatted_time.Append(get_time (ref seconds, 60, "0:"));
+ formatted_time.Append(seconds.ToString().PadLeft(2, '0'));
+ seconds = Convert.ToUInt32(current_song.Length / 1000);
+ formatted_time.Append(" / ");
+ formatted_time.Append(get_time (ref seconds, 3600, ""));
+ formatted_time.Append(get_time (ref seconds, 60, "0:"));
+ formatted_time.Append(seconds.ToString().PadLeft(2, '0'));
+ return formatted_time.ToString();
+ }
+ private bool adjust_progress_label_callback () {
+ if (Driver.player.Playing) {
+ // in seconds
+ current_song.Progress =
+ (uint) (Driver.player.StreamPosition / 1000000000);
+ progress_label.Markup =
+ "<b>" +
+ format_time_string (current_song.Progress) +
+ "</b>";
+ return true;
+ } else {
+ return false;
+ }
+ }
+
private void OnDeleteEvent (object o, DeleteEventArgs args) {
Quit ();
}
@@ -480,6 +528,7 @@
tag_button.Sensitive = false;
journal_button.Sensitive = false;
info_button.Sensitive = false;
+ progress_label.Visible = false;
trayicon.CanShowPopup = false;
// FIXME: Need a blank cover.
@@ -692,6 +741,8 @@
tag_button.Sensitive = true;
journal_button.Sensitive = true;
info_button.Sensitive = true;
+ progress_label.Markup = "";
+ progress_label.Visible = true;
if (station_id != null) {
if (known_stations.Contains (station_id) == false) {
@@ -746,6 +797,8 @@
if (i_window != null) {
i_window.SetSong (song);
}
+
+ GLib.Timeout.Add (250, new GLib.TimeoutHandler (adjust_progress_label_callback));
}
private void show_error_message (string message)
Modified: trunk/src/Song.cs
==============================================================================
--- trunk/src/Song.cs (original)
+++ trunk/src/Song.cs Sun Mar 30 02:40:14 2008
@@ -98,8 +98,8 @@
get { return station_feed_url; }
}
- private int progress;
- public int Progress {
+ private uint progress;
+ public uint Progress {
set { progress = value; }
get { return progress; }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]