Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use KDE Connect's verification codes #1148

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions data/org.gnome.Shell.Extensions.GSConnect.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ SPDX-License-Identifier: GPL-2.0-or-later
<key name="name" type="s">
<default>""</default>
</key>
<key name="pairing" type="b">
<default>false</default>
</key>
<key name="paired" type="b">
<default>false</default>
</key>
Expand Down
2 changes: 2 additions & 0 deletions data/org.gnome.Shell.Extensions.GSConnect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
<property type="s" name="Id" access="read"/>
<property type="s" name="Name" access="read"/>
<property type="b" name="Paired" access="read"/>
<property type="b" name="Pairing" access="read"/>
<property type="s" name="VerifyCode" access="read"/>
<property type="s" name="IconName" access="read"/>
<property type="s" name="Type" access="read"/>
</interface>
Expand Down
258 changes: 202 additions & 56 deletions data/ui/preferences-device-panel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2515,14 +2515,14 @@ SPDX-License-Identifier: GPL-2.0-or-later
</accessibility>
</object>
</child>
<accessibility>
<relation type="controller-for" target="stack"/>
</accessibility>
<child internal-child="accessible">
<object class="AtkObject" id="sidebar-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Device Settings</property>
</object>
</child>
<accessibility>
<relation type="controller-for" target="stack"/>
</accessibility>
</object>
<packing>
<property name="left_attach">0</property>
Expand All @@ -2545,88 +2545,228 @@ SPDX-License-Identifier: GPL-2.0-or-later
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkInfoBar">
<object class="GtkStack" id="infobar_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
<property name="can-focus">False</property>
<child>
<object class="GtkInfoBar" id="infobar_verify">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">Pair</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="action_name">settings.pair</property>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<!-- n-columns=3 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label">🔑</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="verifycode">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
<property name="name">page0</property>
<property name="title" translatable="yes">page0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkInfoBar" id="infobar_pair">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<object class="GtkLabel">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes" context="Send a pair request to the device">Request pairing</property>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<property name="label" translatable="yes" context="Send a pair request to the device">Request pairing</property>
<property name="label" translatable="yes" comment="Send a pair request to the device">Request pairing</property>

This should be a translator comment= property, rather than a context=. Contexts are typically used in a more structured way, usually as a hierarchy based on things like class names or high-level UI objects.1 (For example, obvious picks for the context of these messages might be GSConnectPreferencesDevicePanel or Preferences|Device.)

Comments, OTOH, are for supplying free-form hints about intended meaning to assist translators, as you've done. 👍

Notes

  1. (Contexts are used to categorize strings within the code, so that the same source-language string can be used in different situations where it would potentially get translated differently. Like, "Print" could be the title of a dialog, the label for an action button, or it may be used to refer to the output of a printer. Those might be three completely different words in some languages. So there would be three different translatable "Print" strings in the translation master, each tagged with a different context.)

<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Device is unpaired</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="action-name">settings.pair</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<!-- n-columns=3 n-rows=3 -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these dimension comments inserted automatically by some tool, or did you place them manually?

I don't love embedding narration into code, especially as hidden comment text. Simple reason: I have never, ever seen a narrative comment get updated when subsequent changes to the code turn it into a complete LIE. Not one single time. Any narrative comment that's more than a year or two old, or is located in a file that's had more than 20 commits touch it since then, has a roughly 99% chance of being completely false. And the only thing worse than a comment that describes code, is a comment that describes code incorrectly.

...But if some tool manages those, then I suppose it's fine. At least when that tool is used to make changes, they'll presumably be brought up to date.

<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">You may configure this device before pairing</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Device is unpaired</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">You may configure this device before pairing</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
</object>
Expand All @@ -2636,11 +2776,17 @@ SPDX-License-Identifier: GPL-2.0-or-later
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
<property name="width">3</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</template>

<!-- Device Menu -->
Expand Down
21 changes: 19 additions & 2 deletions src/preferences/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ var Panel = GObject.registerClass({
},
Template: 'resource:///org/gnome/Shell/Extensions/GSConnect/ui/preferences-device-panel.ui',
Children: [
'sidebar', 'stack', 'infobar',
'sidebar', 'stack',

// Pairing process
'infobar', 'infobar_stack', 'infobar_pair', 'infobar_verify', 'verifycode',

// Sharing
'sharing', 'sharing-page',
Expand Down Expand Up @@ -313,14 +316,28 @@ var Panel = GObject.registerClass({
path: `/org/gnome/shell/extensions/gsconnect/device/${device.id}/`,
});

// Infobar
// Pairing infobar
this.device.bind_property(
'paired',
this.infobar,
'reveal-child',
(GObject.BindingFlags.SYNC_CREATE |
GObject.BindingFlags.INVERT_BOOLEAN)
);
this.device.connect('notify::pairing', () => {
if (this.device.pairing)
this.infobar_stack.visible_child = this.infobar_verify;
else
this.infobar_stack.visible_child = this.infobar_pair;

});

this.device.bind_property(
'verify-code',
this.verifycode,
'label',
GObject.BindingFlags.SYNC_CREATE
);

this._setupActions();

Expand Down
Loading