[gnome-maps/wip/osm-edit: 11/11] osmEdit: Invoke the account dialog if trying to edit while not signed in
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/osm-edit: 11/11] osmEdit: Invoke the account dialog if trying to edit while not signed in
- Date: Thu, 3 Dec 2015 22:27:09 +0000 (UTC)
commit f4530c532ead8117d32bdfddfb1ce8681fbeb9fe
Author: Marcus Lundblad <ml update uu se>
Date: Wed Dec 2 23:48:19 2015 +0100
osmEdit: Invoke the account dialog if trying to edit while not signed in
src/application.js | 2 +-
src/osmAccountDialog.js | 34 ++++++++++++++++++++++++++++------
src/osmEdit.js | 6 ++++--
src/placeBubble.js | 10 ++++++++++
4 files changed, 43 insertions(+), 9 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 552d60b..99bb426 100644
--- a/src/application.js
+++ b/src/application.js
@@ -150,7 +150,7 @@ const Application = new Lang.Class({
},
_onOsmAccountSetupActivate: function() {
- osmEdit.showAccountDialog(this._mainWindow);
+ osmEdit.showAccountDialog(this._mainWindow, false);
},
_addContacts: function() {
diff --git a/src/osmAccountDialog.js b/src/osmAccountDialog.js
index 1a97867..6e8c1e9 100644
--- a/src/osmAccountDialog.js
+++ b/src/osmAccountDialog.js
@@ -27,6 +27,10 @@ const WebKit = imports.gi.WebKit;
const Application = imports.application;
+const Response = {
+ SIGNED_IN: 0
+};
+
const OSMAccountDialog = new Lang.Class({
Name: 'OSMAccountDialog',
Extends: Gtk.Dialog,
@@ -50,6 +54,9 @@ const OSMAccountDialog = new Lang.Class({
params.use_header_bar = true;
GObject.type_ensure(WebKit.WebView);
+ this._closeOnSignIn = params.closeOnSignIn;
+ delete params.closeOnSignIn;
+
this.parent(params);
this._emailEntry.connect('changed',
@@ -72,6 +79,16 @@ const OSMAccountDialog = new Lang.Class({
}
},
+/*
+ get closeOnSignIn() {
+ return this._closeOnSignIn;
+ },
+
+ set closeOnSignIn(closeOnSignIn) {
+ this._closeOnSignIn = closeOnSignIn;
+ },
+*/
+
_onCredentialsChanged: function() {
let email = this._emailEntry.text;
let password = this._passwordEntry.text;
@@ -142,12 +159,17 @@ const OSMAccountDialog = new Lang.Class({
if (success) {
/* update the username label */
this._signedInUserLabel.label = Application.osmEdit.username;
- /* switch to the logged in view and reset the state in case
- the user signs out and start over again */
- this._resetPasswordLabel.visible = false;
- this._verificationFailedLabel = false;
- this._signUpLinkButton.visible = true;
- this._stack.visible_child_name = 'logged-in';
+
+ if (this._closeOnSignIn) {
+ this.response(Response.SIGNED_IN);
+ } else {
+ /* switch to the logged in view and reset the state in case
+ the user signs out and start over again */
+ this._resetPasswordLabel.visible = false;
+ this._verificationFailedLabel = false;
+ this._signUpLinkButton.visible = true;
+ this._stack.visible_child_name = 'logged-in';
+ }
} else {
/* switch back to the sign-in view, and show a label indicating
that verification failed */
diff --git a/src/osmEdit.js b/src/osmEdit.js
index f4a9d60..cca0197 100644
--- a/src/osmEdit.js
+++ b/src/osmEdit.js
@@ -52,8 +52,10 @@ const OSMEdit = new Lang.Class({
return response;
},
- showAccountDialog: function(parentWindow) {
- let dialog = new OSMAccountDialog.OSMAccountDialog({transient_for: parentWindow });
+ showAccountDialog: function(parentWindow, closeOnSignIn) {
+ let dialog =
+ new OSMAccountDialog.OSMAccountDialog({transient_for: parentWindow,
+ closeOnSignIn: closeOnSignIn});
let response = dialog.run();
dialog.destroy();
return response;
diff --git a/src/placeBubble.js b/src/placeBubble.js
index eb53bb9..0637f85 100644
--- a/src/placeBubble.js
+++ b/src/placeBubble.js
@@ -26,6 +26,7 @@ const Lang = imports.lang;
const Application = imports.application;
const ContactPlace = imports.contactPlace;
const MapBubble = imports.mapBubble;
+const OSMAccountDialog = imports.osmAccountDialog;
const OSMEditDialog = imports.osmEditDialog;
const OSMUtils = imports.osmUtils;
const Overpass = imports.overpass;
@@ -161,6 +162,15 @@ const PlaceBubble = new Lang.Class({
},
_onEditClicked: function() {
+ /* if the user is not alread signed in, show the account dialog */
+ if (!Application.osmEdit.isSignedIn) {
+ let response =
+ Application.osmEdit.showAccountDialog(this.get_toplevel(),
+ true);
+ if (!response === OSMAccountDialog.Response.SIGNED_IN)
+ return;
+ }
+
let response =
Application.osmEdit.showEditDialog(this.get_toplevel(), this._place);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]