3
The panel on the right hand side
6
public const string LIGHT_WINDOW_STYLE = """
9
background-color:@bg_color;
15
border-color: alpha (#000, 0.25);
19
namespace Audience.Widgets
21
public class TagView : GtkClutter.Actor
24
public Gtk.Grid taggrid;
25
public Audience.App app;
27
public Gtk.ComboBoxText languages;
28
public Gtk.ComboBoxText subtitles;
29
private Gtk.FileChooserButton external_subtitle_file;
31
private Granite.Drawing.BufferSurface buffer;
35
double shadow_alpha = 0.5;
37
bool currently_parsing = false;
39
public signal void select_external_subtitle (string uri);
41
public TagView (Audience.App app) {
44
this.buffer = new Granite.Drawing.BufferSurface (100, 100);
46
var notebook = new Granite.Widgets.StaticNotebook (false);
49
var tagview = new Gtk.ScrolledWindow (null, null);
50
taggrid = new Gtk.Grid ();
51
taggrid.column_spacing = 10;
53
tagview.add_with_viewport (taggrid);
56
var setupgrid = new Gtk.Grid ();
57
this.languages = new Gtk.ComboBoxText ();
58
this.subtitles = new Gtk.ComboBoxText ();
59
this.external_subtitle_file = new Gtk.FileChooserButton (_("External Subtitles"), Gtk.FileChooserAction.OPEN);
60
var lang_lbl = new LLabel.right (_("Audio")+":");
61
var sub_lbl = new LLabel.right (_("Subtitles")+":");
62
var sub_ext_lbl = new LLabel.right (_("External Subtitles") + ":");
63
setupgrid.attach (lang_lbl, 0, 1, 1, 1);
64
setupgrid.attach (languages, 1, 1, 1, 1);
65
setupgrid.attach (sub_lbl, 0, 2, 1, 1);
66
setupgrid.attach (subtitles, 1, 2, 1, 1);
67
setupgrid.attach (sub_ext_lbl, 0, 3, 1, 1);
68
setupgrid.attach (this.external_subtitle_file, 1, 3, 1, 1);
69
setupgrid.column_homogeneous = true;
70
setupgrid.margin = 12;
71
setupgrid.column_spacing = 12;
73
external_subtitle_file.file_set.connect (() => {
74
select_external_subtitle (external_subtitle_file.get_uri ());
76
app.video_player.external_subtitle_changed.connect ( (uri) => {
77
external_subtitle_file.set_uri (uri);
79
this.subtitles.changed.connect ( () => {
80
if (subtitles.active_id == null || currently_parsing)
82
var id = int.parse (this.subtitles.active_id);
83
app.video_player.current_text = id;
86
languages.changed.connect ( () => { //place it here to not get problems
87
if (languages.active_id == null || currently_parsing)
89
app.video_player.current_audio = int.parse (this.languages.active_id);
92
var playlist_scrolled = new Gtk.ScrolledWindow (null, null);
93
playlist_scrolled.add (this.app.playlist);
95
notebook.append_page (playlist_scrolled, new Gtk.Label (_("Playlist")));
96
notebook.append_page (setupgrid, new Gtk.Label (_("Options")));
98
/*draw the window stylish!*/
99
var css = new Gtk.CssProvider ();
101
css.load_from_data (LIGHT_WINDOW_STYLE, -1);
102
} catch (Error e) { warning (e.message); }
104
var draw_ref = new Gtk.Window ();
105
draw_ref.get_style_context ().add_class ("content-view-window");
106
draw_ref.get_style_context ().add_provider (css, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK);
108
var w = -1; var h = -1;
109
this.get_widget ().size_allocate.connect ( () => {
110
if (w == this.get_widget ().get_allocated_width () &&
111
h == this.get_widget ().get_allocated_height ())
113
w = this.get_widget ().get_allocated_width ();
114
h = this.get_widget ().get_allocated_height ();
116
this.buffer = new Granite.Drawing.BufferSurface (w, h);
118
this.buffer.context.rectangle (shadow_blur + shadow_x,
119
shadow_blur + shadow_y, w - shadow_blur*2 + shadow_x, h - shadow_blur*2 + shadow_y);
120
this.buffer.context.set_source_rgba (0, 0, 0, shadow_alpha);
121
this.buffer.context.fill ();
122
this.buffer.exponential_blur (shadow_blur / 2);
124
draw_ref.get_style_context ().render_activity (this.buffer.context,
125
shadow_blur + shadow_x, shadow_blur + shadow_y,
126
w - shadow_blur*2 + shadow_x, h - shadow_blur*2 + shadow_y);
128
this.get_widget ().draw.connect ( (ctx) => {
129
ctx.set_operator (Cairo.Operator.SOURCE);
130
ctx.rectangle (0, 0, this.width, this.height);
131
ctx.set_source_rgba (0.0, 0.0, 0.0, 0.0);
134
ctx.set_source_surface (this.buffer.surface, 0, 0);
140
var no_bg = new Gtk.CssProvider ();
142
no_bg.load_from_data ("""
144
background-color: alpha(#fff, 0);
146
.view:selected:focused {
147
color: @selected_bg_color;
150
} catch (Error e) { warning (e.message); }
151
setupgrid.get_parent ().get_style_context ().add_provider (no_bg, 20000);
152
app.playlist.get_style_context ().add_provider (no_bg, 20000);
154
playlist_scrolled.margin = 3;
155
notebook.margin = shadow_blur + 2;
156
notebook.margin_top += 3;
157
this.get_widget ().get_style_context ().add_class ("content-view");
158
((Gtk.Bin)this.get_widget ()).add (notebook);
159
this.get_widget ().show_all ();
162
this.expanded = false;
165
public override void allocate (Clutter.ActorBox box, Clutter.AllocationFlags flags) {
166
//have a minimum height in order to not get the negative allocation warnings
167
if (box.y2 - box.y1 < 100) {
168
box.y2 = box.y1 + 100;
170
base.allocate (box, flags);
173
public void expand (){
174
//make sure it comes from right bounds
175
x = get_stage ().width + 100;
177
var x2 = this.get_stage ().width - this.width + 10;
178
this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, x:x2);
179
this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, opacity:255);
180
this.expanded = true;
183
public void collapse (){
184
var x2 = this.get_stage ().width;
185
this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, x:x2);
186
this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, opacity:0);
187
this.expanded = false;
190
public void setup_text_setup () { setup_setup ("text"); }
191
public void setup_audio_setup () { setup_setup ("audio"); }
192
/*target is either "text" or "audio"*/
193
public void setup_setup (string target) {
194
currently_parsing = true;
196
if (target == "audio" && languages.model.iter_n_children (null) > 0)
197
languages.remove_all ();
198
else if (target == "text" && subtitles.model.iter_n_children (null) > 0)
199
subtitles.remove_all ();
202
app.video_player.playbin.get_property ("n-"+target, ref num);
205
for (var i=0;i<num.get_int ();i++) {
206
Gst.TagList tags = null;
207
Signal.emit_by_name (app.video_player.playbin, "get-"+target+"-tags", i, out tags);
212
string readable = null;
213
tags.get_string (Gst.Tags.LANGUAGE_CODE, out desc);
215
tags.get_string (Gst.Tags.CODEC, out desc);
218
readable = Gst.Tag.get_language_name (desc);
220
if (target == "audio" && desc != null) {
221
this.languages.append (i.to_string (), readable == null ? desc : readable);
223
} else if (desc != null) {
224
var language = Gst.Tag.get_language_name (desc);
225
this.subtitles.append (i.to_string (), language == null ? desc : language);
230
if (target == "audio") {
233
languages.append ("def", _("Default"));
234
languages.active = 0;
235
languages.sensitive = false;
237
languages.sensitive = true;
238
languages.active_id = app.video_player.current_audio.to_string ();
242
subtitles.sensitive = false;
244
subtitles.sensitive = true;
246
subtitles.append ("-1", _("None"));
247
subtitles.active_id = app.video_player.current_text.to_string ();
250
currently_parsing = false;