|
|
@@ -40,6 +40,7 @@ struct _IridiumWindow
|
|
|
GtkListBox *note_list;
|
|
|
GtkWidget *title_entry;
|
|
|
GtkWidget *source_view;
|
|
|
+ GtkTextBuffer *source_buffer;
|
|
|
GtkWidget *main_pane;
|
|
|
GtkSearchBar *search_bar;
|
|
|
GtkSearchEntry *search_entry;
|
|
|
@@ -47,6 +48,7 @@ struct _IridiumWindow
|
|
|
WebKitWebView *html_view;
|
|
|
GBinding *title_binding;
|
|
|
GBinding *content_binding;
|
|
|
+ guint compile_handler;
|
|
|
|
|
|
IridiumMarkdown *markdown;
|
|
|
IridiumStandardFile *client;
|
|
|
@@ -89,9 +91,9 @@ compile_markdown (IridiumWindow *self,
|
|
|
GtkTextIter end;
|
|
|
gchar *text;
|
|
|
|
|
|
- gtk_text_buffer_get_start_iter (buffer, &start);
|
|
|
- gtk_text_buffer_get_end_iter (buffer, &end);
|
|
|
- text = gtk_text_buffer_get_slice (buffer, &start, &end, FALSE);
|
|
|
+ gtk_text_buffer_get_start_iter (self->source_buffer, &start);
|
|
|
+ gtk_text_buffer_get_end_iter (self->source_buffer, &end);
|
|
|
+ text = gtk_text_buffer_get_slice (self->source_buffer, &start, &end, FALSE);
|
|
|
iridium_markdown_compile_async (self->markdown, text, G_PRIORITY_DEFAULT, NULL,
|
|
|
on_markdown_compiled, self);
|
|
|
g_free (text);
|
|
|
@@ -108,7 +110,6 @@ static void
|
|
|
on_note_selected (IridiumWindow *self, IridiumNoteRow *row, gpointer user_data)
|
|
|
{
|
|
|
IridiumNote *note;
|
|
|
- GtkTextBuffer *buffer;
|
|
|
GBindingFlags flags;
|
|
|
|
|
|
if (self->title_binding != NULL)
|
|
|
@@ -122,9 +123,13 @@ on_note_selected (IridiumWindow *self, IridiumNoteRow *row, gpointer user_data)
|
|
|
|
|
|
note = iridium_note_row_get_note (row);
|
|
|
flags = G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE;
|
|
|
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
|
|
|
self->title_binding = g_object_bind_property (note, "title", self->title_entry, "text", flags);
|
|
|
- self->content_binding = g_object_bind_property (note, "content", buffer, "text", flags);
|
|
|
+ self->content_binding = g_object_bind_property (note, "content", self->source_buffer, "text", flags);
|
|
|
+
|
|
|
+ if (self->compile_handler > 0) {
|
|
|
+ g_signal_handler_disconnect (self->source_buffer, self->compile_handler);
|
|
|
+ self->compile_handler = 0;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
static void
|
|
|
@@ -160,12 +165,12 @@ preview_toggled (GSimpleAction *action,
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->html_view), visible);
|
|
|
|
|
|
if (visible) {
|
|
|
- GtkTextBuffer *buffer;
|
|
|
-
|
|
|
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
|
|
|
- compile_markdown (self, buffer);
|
|
|
- g_signal_connect (buffer, "changed", G_CALLBACK (on_text_changed), self);
|
|
|
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
|
|
|
+ compile_markdown (self, self->source_buffer);
|
|
|
+ self->compile_handler = g_signal_connect (self->source_buffer, "changed", G_CALLBACK (on_text_changed), self);
|
|
|
+ }
|
|
|
+ else if (self->compile_handler > 0) {
|
|
|
+ g_signal_handler_disconnect (self->source_buffer, self->compile_handler);
|
|
|
+ self->compile_handler = 0;
|
|
|
}
|
|
|
|
|
|
g_variant_unref (state);
|
|
|
@@ -400,6 +405,8 @@ iridium_window_init (IridiumWindow *self)
|
|
|
self->content_binding = NULL;
|
|
|
self->markdown = iridium_markdown_new ();
|
|
|
self->client = iridium_standard_file_new ();
|
|
|
+ self->compile_handler = 0;
|
|
|
+ self->source_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->source_view));
|
|
|
|
|
|
style_data = g_resources_lookup_data ("/net/bloerg/Iridium/iridium-theme.css",
|
|
|
G_RESOURCE_LOOKUP_FLAGS_NONE, &error);
|