Skip to content

Instantly share code, notes, and snippets.

@ikskuh
Created March 28, 2020 10:19
Show Gist options
  • Save ikskuh/5bdb9e1f972678019cae8301bc40da26 to your computer and use it in GitHub Desktop.
Save ikskuh/5bdb9e1f972678019cae8301bc40da26 to your computer and use it in GitHub Desktop.
Dunstblick (behind the scenes)
/* Resource ID = 1 */
TabLayout
{
margins: 0;
DockLayout
{
tab-title: "Menu";
Button
{
dock-site: bottom;
Label { text: "Exit"; }
}
Label
{
dock-site: top;
text: "Available Applications";
font-family: serif;
}
StackLayout
{
/* This is where the magic happens! */
child-source: bind(1);
child-template: resource(2);
}
}
}
/* Resource ID = 2 */
Panel
{
DockLayout
{
Button {
on-click: callback(2);
dock-site: right;
widget-name: bind(5);
Label { text: "Open"; }
}
Button {
on-click: callback(3);
dock-site: right;
widget-name: bind(5);
Label { text: "Close"; }
}
Label {
dock-site: right;
text: bind(4); /* port */
margins: 0,4,4,4;
}
Label {
dock-site: right;
text: ":";
margins: 0,4,0,4;
}
Label {
dock-site: right;
text: bind(3); /* ip */
margins: 4,4,0,4;
}
Label {
horizontal-alignment: left;
text: bind(2);
}
}
}
// Update objects in local session
{
std::vector<DiscoveredClient> clients;
{
std::lock_guard<std::mutex> lock{discovered_clients_lock};
clients = discovered_clients;
}
ObjectList list;
list.reserve(clients.size());
for (size_t i = 0; i < clients.size(); i++) {
auto const id = local_session_id(i);
Object obj{id};
obj.add(local_app_name /* = 2 */, UIValue(clients[i].name));
obj.add(local_app_port /* = 4 */, UIValue(clients[i].tcp_port));
obj.add(local_app_ip /* = 3 */, UIValue(xnet::to_string(clients[i].udp_ep, false)));
obj.add(local_app_id /* = 5 */, UIValue(WidgetName(i + 1)));
list.emplace_back(obj);
sess.addOrUpdateObject(std::move(obj));
}
sess.clear(local_root_obj, local_discovery_list /* = 1 */);
sess.insertRange(local_root_obj, local_discovery_list /* = 1 */, 0, list.size(), list.data());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment