[gtk/wip/baedert/nodeeditor: 42/42] make the nodeparser a bit easier to use
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/nodeeditor: 42/42] make the nodeparser a bit easier to use
- Date: Thu, 25 Apr 2019 15:28:58 +0000 (UTC)
commit 3a249e6c03943b68e7e113878ace0ca34780c7b4
Author: Timm Bäder <mail baedert org>
Date: Thu Apr 25 17:25:14 2019 +0200
make the nodeparser a bit easier to use
demos/node-editor/node-editor-window.c | 29 ++++++----------------
demos/node-editor/node-editor-window.ui | 44 ++++++++++++++-------------------
2 files changed, 26 insertions(+), 47 deletions(-)
---
diff --git a/demos/node-editor/node-editor-window.c b/demos/node-editor/node-editor-window.c
index b00f52a4d6..255d7ce8bb 100644
--- a/demos/node-editor/node-editor-window.c
+++ b/demos/node-editor/node-editor-window.c
@@ -63,7 +63,6 @@ deserialize_error_func (const GtkCssSection *section,
g_message ("Error at %s: %s", section_str, error->message);
free (section_str);
-
}
static void
@@ -102,26 +101,12 @@ update_node (NodeEditorWindow *self)
}
}
-static gboolean
-update_timeout (gpointer data)
-{
- NodeEditorWindow *self = data;
-
- self->text_timeout = 0;
-
- update_node (self);
-
- return G_SOURCE_REMOVE;
-}
-
static void
text_changed (GtkTextBuffer *buffer,
NodeEditorWindow *self)
{
- if (self->text_timeout != 0)
- g_source_remove (self->text_timeout);
-
- self->text_timeout = g_timeout_add (100, update_timeout, self);
+ /* If this is too slow, go fix the parser performance */
+ update_node (self);
}
static gboolean
@@ -171,7 +156,7 @@ gboolean
node_editor_window_load (NodeEditorWindow *self,
GFile *file)
{
- GtkTextIter start, end;
+ GtkTextIter end;
GBytes *bytes;
bytes = g_file_load_bytes (file, NULL, NULL, NULL);
@@ -184,7 +169,6 @@ node_editor_window_load (NodeEditorWindow *self,
return FALSE;
}
- gtk_text_buffer_get_start_iter (self->text_buffer, &start);
gtk_text_buffer_get_end_iter (self->text_buffer, &end);
gtk_text_buffer_insert (self->text_buffer,
&end,
@@ -219,7 +203,7 @@ open_cb (GtkWidget *button,
{
GtkWidget *dialog;
- dialog = gtk_file_chooser_dialog_new ("",
+ dialog = gtk_file_chooser_dialog_new ("Open node file",
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))),
GTK_FILE_CHOOSER_ACTION_OPEN,
"_Cancel", GTK_RESPONSE_CANCEL,
@@ -228,7 +212,7 @@ open_cb (GtkWidget *button,
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
- gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), ".");
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), self);
gtk_widget_show (dialog);
}
@@ -275,7 +259,7 @@ save_cb (GtkWidget *button,
{
GtkWidget *dialog;
- dialog = gtk_file_chooser_dialog_new ("",
+ dialog = gtk_file_chooser_dialog_new ("Save node",
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))),
GTK_FILE_CHOOSER_ACTION_SAVE,
"_Cancel", GTK_RESPONSE_CANCEL,
@@ -285,6 +269,7 @@ save_cb (GtkWidget *button,
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), ".");
g_signal_connect (dialog, "response", G_CALLBACK (save_response_cb), self);
gtk_widget_show (dialog);
}
diff --git a/demos/node-editor/node-editor-window.ui b/demos/node-editor/node-editor-window.ui
index 7a8239649b..d9b2566de4 100644
--- a/demos/node-editor/node-editor-window.ui
+++ b/demos/node-editor/node-editor-window.ui
@@ -31,25 +31,24 @@
<property name="title" translatable="yes">GTK Node Editor</property>
<property name="show-title-buttons">1</property>
<child type="start">
- <object class="GtkBox">
- <child>
- <object class="GtkButton">
- <property name="icon-name">document-open-symbolic</property>
- <signal name="clicked" handler="open_cb"/>
- </object>
- </child>
- <child>
- <object class="GtkButton">
- <property name="icon-name">document-save-symbolic</property>
- <signal name="clicked" handler="save_cb"/>
- </object>
- </child>
- <child>
- <object class="GtkButton">
- <property name="icon-name">insert-image-symbolic</property>
- <signal name="clicked" handler="export_image_cb"/>
- </object>
- </child>
+ <object class="GtkButton">
+ <property name="icon-name">document-open-symbolic</property>
+ <property name="tooltip-text">Open node file</property>
+ <signal name="clicked" handler="open_cb"/>
+ </object>
+ </child>
+ <child type="start">
+ <object class="GtkButton">
+ <property name="icon-name">document-save-symbolic</property>
+ <property name="tooltip-text">Save to node file</property>
+ <signal name="clicked" handler="save_cb"/>
+ </object>
+ </child>
+ <child type="start">
+ <object class="GtkButton">
+ <property name="icon-name">insert-image-symbolic</property>
+ <property name="tooltip-text">Export to image</property>
+ <signal name="clicked" handler="export_image_cb"/>
</object>
</child>
<child type="title">
@@ -57,17 +56,12 @@
<property name="label" translatable="yes">GTK Node Editor</property>
</object>
</child>
- <child type="end">
- <object class="GtkToggleButton">
- <property name="icon-name">view-more-symbolic</property>
- </object>
- </child>
</object>
</child>
<child>
<object class="GtkPaned">
<property name="shrink-child2">false</property>
- <property name="position">99999</property>
+ <property name="position">400</property>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]