Add Player detection
This commit is contained in:
parent
a2b1ddf747
commit
d61b3c43c2
1 changed files with 51 additions and 0 deletions
|
@ -36,5 +36,56 @@ public class Extension.QuickSetting : Phosh.QuickSetting {
|
|||
construct {
|
||||
info.set_icon_name ("face-shutmouth-symbolic");
|
||||
info.set_info ("I'm Inactive");
|
||||
parent_set.connect (() => replace_player (Stage.QickSettings_Box));
|
||||
}
|
||||
enum Stage {
|
||||
QickSettings_Box = 0,
|
||||
QickSettings,
|
||||
BoxSettings;
|
||||
|
||||
public string to_string () {
|
||||
return ((EnumClass) typeof (Stage).class_ref ()).get_value (this).value_nick.up ();
|
||||
}
|
||||
}
|
||||
void replace_player (Stage stage) {
|
||||
message ("Replace player: Stage %d %s", stage, stage.to_string ());
|
||||
if (parent == null) {
|
||||
message ("Parent is null");
|
||||
return;
|
||||
}
|
||||
if (stage != Stage.BoxSettings) {
|
||||
var _p = parent;
|
||||
for (uint i = 0; i < stage; i++)
|
||||
_p = _p.parent;
|
||||
if (_p.parent != null)
|
||||
replace_player (stage + 1);
|
||||
_p.parent_set.connect (() => replace_player (stage + 1));
|
||||
return;
|
||||
}
|
||||
Gtk.Box box = (Gtk.Box) parent.parent.parent;
|
||||
foreach (var child in box.get_children ())
|
||||
on_something_added (child);
|
||||
box.add.connect ((w) => on_something_added (w));
|
||||
}
|
||||
|
||||
void on_something_added (Gtk.Widget widget) {
|
||||
if (widget.get_type ().is_a (typeof (Gtk.Container))) {
|
||||
((Gtk.Container) widget).add.connect ((w) => on_something_added (w));
|
||||
}
|
||||
|
||||
Gtk.Box box = (Gtk.Box) parent.parent.parent;
|
||||
find_player (box);
|
||||
}
|
||||
|
||||
void find_player (Gtk.Container container) {
|
||||
foreach (var child in container.get_children ()) {
|
||||
if (child.name == "PhoshDefaultMediaPlayer") {
|
||||
message ("Player found");
|
||||
// container.remove (child);
|
||||
}
|
||||
if (child.get_type ().is_a (typeof (Gtk.Container))) {
|
||||
find_player ((Gtk.Container) child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue