Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions data/icons/bluetooth.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/Widgets/DisplayWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public class BluetoothIndicator.Widgets.DisplayWidget : Granite.Bin {
if (state) {
context = _("Middle-click to turn Bluetooth off");
if (connected) {
symbol.state = Granite.Symbol.STATE_CHECKED;
symbol.state = Granite.SymbolState.ACTIVE;
description = _("Bluetooth connected");
} else {
symbol.state = Granite.Symbol.STATE_NORMAL;
symbol.state = Granite.SymbolState.NORMAL;
description = _("Bluetooth is on");
}
} else {
symbol.state = Granite.Symbol.STATE_DISABLED;
symbol.state = Granite.SymbolState.DISABLED;
description = _("Bluetooth is off");
context = _("Middle-click to turn Bluetooth on");
}
Expand Down
48 changes: 42 additions & 6 deletions src/Widgets/Symbol.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,57 @@
* SPDX-FileCopyrightText: 2026 elementary, Inc. (https://elementary.io)
*/

public class Granite.Symbol : Granite.Bin {
public const int STATE_NORMAL = 0;
public const int STATE_DISABLED = 1;
public const int STATE_CHECKED = 2;
namespace Granite.SymbolState {
// The default state
public const string NORMAL = "normal";
// Disabled state represented by a slash
public const string DISABLED = "disabled";
// e.g. paired, connected, needs attention
public const string ACTIVE = "active";
}

public class Granite.Symbol : Granite.Bin {
public string resource_path { get; construct; }

public int pixel_size {
get { return image.pixel_size; }
set { image.pixel_size = value; }
}

public uint state {
public uint state_index {
get { return svg.state; }
set { svg.state = value; }
set {
uint length = -1;
svg.get_state_names (out length);

if (value > length - 1) {
warning ("Granite.Symbol set to undefined state. Ignoring.");
return;
}

svg.state = value;
notify_property ("state");
}
}

public string state {
get {
uint length = -1;
return svg.get_state_names (out length)[state_index];
}
set {
uint length = -1;
var names = svg.get_state_names (out length);

for (int i = 0; i < length; i++) {
if (names[i] == value) {
state_index = i;
return;
}
}

warning ("Granite.Symbol set to undefined state. Ignoring.");
}
}

private Gtk.Image image;
Expand Down
Loading