|
@@ -25,6 +25,7 @@
|
|
|
#include "iridium-note.h"
|
|
#include "iridium-note.h"
|
|
|
#include "iridium-note-row.h"
|
|
#include "iridium-note-row.h"
|
|
|
#include "iridium-standard-file.h"
|
|
#include "iridium-standard-file.h"
|
|
|
|
|
+#include "iridium-storage.h"
|
|
|
#include "iridium-signin-dialog.h"
|
|
#include "iridium-signin-dialog.h"
|
|
|
#include "iridium-tag-row.h"
|
|
#include "iridium-tag-row.h"
|
|
|
#include "iridium-window.h"
|
|
#include "iridium-window.h"
|
|
@@ -55,6 +56,7 @@ struct _IridiumWindow
|
|
|
guint compile_handler;
|
|
guint compile_handler;
|
|
|
|
|
|
|
|
IridiumMarkdown *markdown;
|
|
IridiumMarkdown *markdown;
|
|
|
|
|
+ IridiumStorage *storage;
|
|
|
IridiumStandardFile *client;
|
|
IridiumStandardFile *client;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -274,20 +276,61 @@ on_standard_file_connected (GObject *object,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static void
|
|
|
|
|
+on_storage_loaded (GObject *object,
|
|
|
|
|
+ GAsyncResult *result,
|
|
|
|
|
+ gpointer user_data)
|
|
|
|
|
+{
|
|
|
|
|
+ IridiumWindow *self;
|
|
|
|
|
+ IridiumStorage *storage;
|
|
|
|
|
+ GList *notes;
|
|
|
|
|
+ GError *error = NULL;
|
|
|
|
|
+
|
|
|
|
|
+ self = IRIDIUM_WINDOW (user_data);
|
|
|
|
|
+ storage = IRIDIUM_STORAGE (object);
|
|
|
|
|
+
|
|
|
|
|
+ notes = iridium_storage_sync_local_finish (storage, result, &error);
|
|
|
|
|
+
|
|
|
|
|
+ if (notes) {
|
|
|
|
|
+ IridiumTag *tag_all;
|
|
|
|
|
+
|
|
|
|
|
+ tag_all = iridium_tag_new ("All");
|
|
|
|
|
+
|
|
|
|
|
+ for (GList *it = g_list_first (notes); it != NULL; it = g_list_next (it)) {
|
|
|
|
|
+ IridiumNote *note;
|
|
|
|
|
+
|
|
|
|
|
+ note = IRIDIUM_NOTE (it->data);
|
|
|
|
|
+ iridium_note_add_tag (note, tag_all);
|
|
|
|
|
+ gtk_list_box_insert (self->note_list, iridium_note_row_new (note), -1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ g_list_free (notes);
|
|
|
|
|
+ gtk_widget_show_all (GTK_WIDGET (self->note_list));
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (error != NULL) {
|
|
|
|
|
+ show_error_dialog (self, error);
|
|
|
|
|
+ g_error_free (error);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void
|
|
static void
|
|
|
on_show (IridiumWindow *self, gpointer user_data)
|
|
on_show (IridiumWindow *self, gpointer user_data)
|
|
|
{
|
|
{
|
|
|
- gchar *server;
|
|
|
|
|
gchar *email;
|
|
gchar *email;
|
|
|
|
|
+ gchar *server = NULL;
|
|
|
gchar *password = NULL;
|
|
gchar *password = NULL;
|
|
|
- gboolean valid = TRUE;
|
|
|
|
|
|
|
+ gboolean valid_input;
|
|
|
|
|
|
|
|
- server = g_settings_get_string (self->preferences, "server");
|
|
|
|
|
|
|
+ /* server = g_settings_get_string (self->preferences, "server"); */
|
|
|
email = g_settings_get_string (self->preferences, "email");
|
|
email = g_settings_get_string (self->preferences, "email");
|
|
|
|
|
|
|
|
- if (strlen (server) > 0 && strlen (email) > 0) {
|
|
|
|
|
|
|
+ if (strlen (email) > 0) {
|
|
|
|
|
+ /* if (strlen (server) > 0 && strlen (email) > 0) { */
|
|
|
password = secret_password_lookup_sync (STANDARD_FILE_SCHEMA, NULL, NULL,
|
|
password = secret_password_lookup_sync (STANDARD_FILE_SCHEMA, NULL, NULL,
|
|
|
- "email", email, "server", server, NULL);
|
|
|
|
|
|
|
+ "email", email,
|
|
|
|
|
+ /* "server", server, */
|
|
|
|
|
+ NULL);
|
|
|
|
|
+ valid_input = TRUE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (password == NULL) {
|
|
if (password == NULL) {
|
|
@@ -309,13 +352,14 @@ on_show (IridiumWindow *self, gpointer user_data)
|
|
|
g_settings_set_string (self->preferences, "email", email);
|
|
g_settings_set_string (self->preferences, "email", email);
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- valid = FALSE;
|
|
|
|
|
|
|
+ valid_input = FALSE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (valid) {
|
|
|
|
|
|
|
+ if (valid_input) {
|
|
|
|
|
+#if 0
|
|
|
gchar *text;
|
|
gchar *text;
|
|
|
|
|
|
|
|
text = g_strdup_printf ("Connecting to %s …", server);
|
|
text = g_strdup_printf ("Connecting to %s …", server);
|
|
@@ -324,6 +368,9 @@ on_show (IridiumWindow *self, gpointer user_data)
|
|
|
gtk_revealer_set_reveal_child (self->notification_revealer, TRUE);
|
|
gtk_revealer_set_reveal_child (self->notification_revealer, TRUE);
|
|
|
iridium_standard_file_connect_async (self->client, server, email, password, NULL,
|
|
iridium_standard_file_connect_async (self->client, server, email, password, NULL,
|
|
|
on_standard_file_connected, self);
|
|
on_standard_file_connected, self);
|
|
|
|
|
+#endif
|
|
|
|
|
+ iridium_storage_sync_local_async (self->storage, email, server, password, NULL,
|
|
|
|
|
+ on_storage_loaded, self);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
secret_password_free (password);
|
|
secret_password_free (password);
|
|
@@ -382,6 +429,7 @@ iridium_window_constructed (GObject *object)
|
|
|
|
|
|
|
|
self->markdown = iridium_markdown_new ();
|
|
self->markdown = iridium_markdown_new ();
|
|
|
self->client = iridium_standard_file_new ();
|
|
self->client = iridium_standard_file_new ();
|
|
|
|
|
+ self->storage = iridium_storage_new ();
|
|
|
self->source_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
|
|
self->source_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
|
|
|
|
|
|
|
|
style_data = g_resources_lookup_data ("/net/bloerg/Iridium/css/iridium-theme.css", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
|
|
style_data = g_resources_lookup_data ("/net/bloerg/Iridium/css/iridium-theme.css", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
|
|
@@ -418,6 +466,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->storage);
|
|
|
g_clear_object (&self->preferences);
|
|
g_clear_object (&self->preferences);
|
|
|
G_OBJECT_CLASS (iridium_window_parent_class)->dispose (object);
|
|
G_OBJECT_CLASS (iridium_window_parent_class)->dispose (object);
|
|
|
}
|
|
}
|