Skip to content

Commit

Permalink
Work around more SN/dbusmenu quirks (#438)
Browse files Browse the repository at this point in the history
* Work around more SN/dbusmenu quirks

* Update src/panel/applets/tray/TrayItem.vala

Co-authored-by: Evan Maddock <[email protected]>

---------

Co-authored-by: Evan Maddock <[email protected]>
  • Loading branch information
serebit and EbonJaeger authored Sep 4, 2023
1 parent 980b72e commit 8e6951b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
14 changes: 8 additions & 6 deletions src/panel/applets/tray/DBusMenu.vala
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class DBusMenu : Object {
all_nodes.set(id, node);
}

if (v_children.is_container() && v_children.n_children() > 0) {
if (v_children.get_type().is_array() && v_children.n_children() > 0) {
var new_children = new List<DBusMenuNode>();

VariantIter it = v_children.iterator();
Expand Down Expand Up @@ -119,11 +119,13 @@ public class DBusMenu : Object {
}

private void update_node_properties(DBusMenuNode node, Variant props) {
VariantIter prop_it = props.iterator();
string key;
Variant value;
while (prop_it.next("{sv}", out key, out value)) {
node.update_property(key, value);
VariantIter it = props.iterator();
for (var prop = it.next_value(); prop != null; prop = it.next_value()) {
if (prop.is_of_type(new VariantType("{sv}"))) {
string key = prop.get_child_value(0).get_string();
Variant value = prop.get_child_value(1);
node.update_property(key, value);
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/panel/applets/tray/DBusMenuNode.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public class DBusMenuNode : Object {
for (int i = 0; i < new_children.length(); i++) {
var item = new_children.nth_data(i).item;

if (item.parent != null) {
item.parent.remove(item);
}

if (item.parent != submenu) {
submenu.add(item);
}
Expand Down
26 changes: 19 additions & 7 deletions src/panel/applets/tray/TrayItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ internal interface SnItemProperties : Object {
public abstract SnIconPixmap[] attention_icon_pixmap {owned get;}
public abstract string attention_movie_name {owned get;}
public abstract string icon_theme_path {owned get;}
public abstract SnToolTip? tool_tip {owned get;}
[DBus (signature="(sa(iiay)ss)")]
public abstract Variant? tool_tip {owned get;}
public abstract bool item_is_menu {get;}
public abstract ObjectPath? menu {owned get;}
}
Expand Down Expand Up @@ -206,14 +207,25 @@ internal class TrayItem : Gtk.EventBox {

private void reset_tooltip() {
if (dbus_properties.tool_tip != null) {
if (dbus_properties.tool_tip.markup != "") {
set_tooltip_markup(dbus_properties.tool_tip.markup);
} else {
set_tooltip_text(dbus_properties.tool_tip.title);
if (dbus_properties.tool_tip.get_type_string() == "(sa(iiay)ss)") {
string title = dbus_properties.tool_tip.get_child_value(2).get_string();
string markup = dbus_properties.tool_tip.get_child_value(3).get_string();

if (markup != "") {
set_tooltip_markup(markup);
} else {
set_tooltip_text(title);
}

return;
} else if (dbus_properties.tool_tip.is_of_type(VariantType.STRING)) {
// quirk for TeamViewer
set_tooltip_text(dbus_properties.tool_tip.get_string());
return;
}
} else {
set_tooltip_text(null);
}

set_tooltip_text(null);
}

public override bool button_release_event(Gdk.EventButton event) {
Expand Down

0 comments on commit 8e6951b

Please sign in to comment.