~elementary-apps/audience/headerbar

« back to all changes in this revision

Viewing changes to src/Widgets/TimeWidget.vala

  • Committer: Corentin Noël
  • Date: 2014-04-28 22:27:55 UTC
  • Revision ID: tintou@mailoo.org-20140428222755-pr6ia7d6oh73krca
elementarized and first work to port it to Gtk 3.12.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
public class Audience.Widgets.TimeWidget : Gtk.Grid {
 
3
    public Gtk.Label progression_label;
 
4
    public Gtk.Label time_label;
 
5
    public Gtk.ProgressBar progress_bar;
 
6
    public signal void seeked (double val);
 
7
 
 
8
    public TimeWidget () {
 
9
        orientation = Gtk.Orientation.HORIZONTAL;
 
10
        column_spacing = 12;
 
11
        progression_label = new Gtk.Label ("");
 
12
        time_label = new Gtk.Label ("");
 
13
        progress_bar = new Gtk.ProgressBar ();
 
14
        progress_bar.hexpand = true;
 
15
        add (progression_label);
 
16
        add (progress_bar);
 
17
        add (time_label);
 
18
    }
 
19
 
 
20
    public override void get_preferred_width (out int minimum_width, out int natural_width) {
 
21
        base.get_preferred_width (out minimum_width, out natural_width);
 
22
 
 
23
        var width = parent.get_window ().get_width ();
 
24
        if (width > 0 && width >= minimum_width) {
 
25
            natural_width = width;
 
26
        }
 
27
    }
 
28
 
 
29
    public void set_progression_time (double current_time, double total_time) {
 
30
        progress_bar.fraction = current_time/total_time;
 
31
        progression_label.label = seconds_to_time ((int)(current_time / 1000000000));
 
32
        time_label.label = "-%s".printf (seconds_to_time ((int)((total_time - current_time) / 1000000000)));
 
33
    }
 
34
}
 
 
b'\\ No newline at end of file'