Skip to content

Commit

Permalink
Use KDE Connect's verification codes
Browse files Browse the repository at this point in the history
Fixes #1091
  • Loading branch information
strugee committed Jul 29, 2021
1 parent 91e4390 commit 5731b63
Show file tree
Hide file tree
Showing 6 changed files with 339 additions and 71 deletions.
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 @@ -51,6 +51,9 @@
<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 @@ -6,6 +6,8 @@
<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 @@ -2508,14 +2508,14 @@
</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 @@ -2538,88 +2538,228 @@
<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>
<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 -->
<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 @@ -2629,11 +2769,17 @@
</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
22 changes: 20 additions & 2 deletions src/preferences/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,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 @@ -306,15 +309,30 @@ 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
);

// Action setup
this._setupActions();

// Settings Pages
Expand Down
Loading

0 comments on commit 5731b63

Please sign in to comment.