|
@@ -16,6 +16,7 @@
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
+#include <string.h>
|
|
|
#include <gtksourceview/gtksource.h>
|
|
#include <gtksourceview/gtksource.h>
|
|
|
#include <webkit2/webkit2.h>
|
|
#include <webkit2/webkit2.h>
|
|
|
|
|
|
|
@@ -32,6 +33,8 @@ struct _IridiumWindow
|
|
|
{
|
|
{
|
|
|
GtkApplicationWindow parent_instance;
|
|
GtkApplicationWindow parent_instance;
|
|
|
|
|
|
|
|
|
|
+ GSettings *settings;
|
|
|
|
|
+
|
|
|
GtkHeaderBar *header_bar;
|
|
GtkHeaderBar *header_bar;
|
|
|
GtkListBox *tag_list;
|
|
GtkListBox *tag_list;
|
|
|
GtkListBox *note_list;
|
|
GtkListBox *note_list;
|
|
@@ -194,20 +197,35 @@ on_standard_file_connected (GObject *object,
|
|
|
static void
|
|
static void
|
|
|
on_show (IridiumWindow *self, gpointer user_data)
|
|
on_show (IridiumWindow *self, gpointer user_data)
|
|
|
{
|
|
{
|
|
|
- GtkDialog *dialog;
|
|
|
|
|
- const gchar *server;
|
|
|
|
|
- const gchar *email;
|
|
|
|
|
|
|
+ gchar *server;
|
|
|
|
|
+ gchar *email;
|
|
|
gchar *password;
|
|
gchar *password;
|
|
|
- GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
- dialog = iridium_signin_dialog_new ();
|
|
|
|
|
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (self));
|
|
|
|
|
- gtk_dialog_run (dialog);
|
|
|
|
|
|
|
+ server = g_settings_get_string (self->settings, "server");
|
|
|
|
|
+ email = g_settings_get_string (self->settings, "email");
|
|
|
|
|
|
|
|
- server = iridium_signin_dialog_get_server (IRIDIUM_SIGNIN_DIALOG (dialog));
|
|
|
|
|
- email = iridium_signin_dialog_get_email (IRIDIUM_SIGNIN_DIALOG (dialog));
|
|
|
|
|
- password = secret_password_lookup_sync (STANDARD_FILE_SCHEMA, NULL, &error,
|
|
|
|
|
- "email", email, "server", server, NULL);
|
|
|
|
|
|
|
+ if (strlen (server) > 0 && strlen (email) > 0) {
|
|
|
|
|
+ password = secret_password_lookup_sync (STANDARD_FILE_SCHEMA, NULL, NULL,
|
|
|
|
|
+ "email", email, "server", server, NULL);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ GtkDialog *dialog;
|
|
|
|
|
+
|
|
|
|
|
+ dialog = iridium_signin_dialog_new ();
|
|
|
|
|
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (self));
|
|
|
|
|
+ gtk_dialog_run (dialog);
|
|
|
|
|
+ server = g_strdup (iridium_signin_dialog_get_server (IRIDIUM_SIGNIN_DIALOG (dialog)));
|
|
|
|
|
+ email = g_strdup (iridium_signin_dialog_get_email (IRIDIUM_SIGNIN_DIALOG (dialog)));
|
|
|
|
|
+ password = g_strdup (iridium_signin_dialog_get_password (IRIDIUM_SIGNIN_DIALOG (dialog)));
|
|
|
|
|
+
|
|
|
|
|
+ secret_password_store_sync (STANDARD_FILE_SCHEMA, NULL,
|
|
|
|
|
+ "Iridium", password, NULL, NULL,
|
|
|
|
|
+ "email", email, "server", server, NULL);
|
|
|
|
|
+ g_settings_set_string (self->settings, "server", server);
|
|
|
|
|
+ g_settings_set_string (self->settings, "email", email);
|
|
|
|
|
+
|
|
|
|
|
+ gtk_widget_destroy (GTK_WIDGET (dialog));
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
gtk_revealer_set_reveal_child (self->notification_revealer, TRUE);
|
|
gtk_revealer_set_reveal_child (self->notification_revealer, TRUE);
|
|
|
|
|
|
|
@@ -215,8 +233,8 @@ on_show (IridiumWindow *self, gpointer user_data)
|
|
|
on_standard_file_connected, self);
|
|
on_standard_file_connected, self);
|
|
|
|
|
|
|
|
secret_password_free (password);
|
|
secret_password_free (password);
|
|
|
-
|
|
|
|
|
- gtk_widget_destroy (GTK_WIDGET (dialog));
|
|
|
|
|
|
|
+ g_free (server);
|
|
|
|
|
+ g_free (email);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
static void
|
|
@@ -236,6 +254,7 @@ iridium_window_dispose (GObject *object)
|
|
|
g_clear_object (&self->content_binding);
|
|
g_clear_object (&self->content_binding);
|
|
|
g_clear_object (&self->markdown);
|
|
g_clear_object (&self->markdown);
|
|
|
g_clear_object (&self->client);
|
|
g_clear_object (&self->client);
|
|
|
|
|
+ g_clear_object (&self->settings);
|
|
|
G_OBJECT_CLASS (iridium_window_parent_class)->dispose (object);
|
|
G_OBJECT_CLASS (iridium_window_parent_class)->dispose (object);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -280,6 +299,7 @@ iridium_window_init (IridiumWindow *self)
|
|
|
|
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
|
|
|
|
|
|
|
|
|
+ self->settings = g_settings_new ("net.bloerg.Iridium");
|
|
|
self->title_binding = NULL;
|
|
self->title_binding = NULL;
|
|
|
self->content_binding = NULL;
|
|
self->content_binding = NULL;
|
|
|
self->markdown = iridium_markdown_new ();
|
|
self->markdown = iridium_markdown_new ();
|