[gnome-builder] GbEditorView: add ui to see load/save errors
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] GbEditorView: add ui to see load/save errors
- Date: Fri, 12 Dec 2014 10:04:33 +0000 (UTC)
commit 86e76a80b64b2f9e443f3cbc7e54b274e3fdeec8
Author: Christian Hergert <christian hergert me>
Date: Fri Dec 12 02:04:16 2014 -0800
GbEditorView: add ui to see load/save errors
src/editor/gb-editor-view.c | 43 +++++++++++++++++++++++
src/resources/ui/gb-editor-view.ui | 67 +++++++++++++++++++++++++++++++++++-
2 files changed, 109 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-editor-view.c b/src/editor/gb-editor-view.c
index e83113e..1ea04b8 100644
--- a/src/editor/gb-editor-view.c
+++ b/src/editor/gb-editor-view.c
@@ -42,6 +42,9 @@ struct _GbEditorViewPrivate
GtkToggleButton *split_button;
GbEditorFrame *frame;
GtkProgressBar *progress_bar;
+ GtkLabel *error_label;
+ GtkButton *error_close_button;
+ GtkRevealer *error_revealer;
GtkLabel *modified_label;
GtkButton *modified_reload_button;
GtkButton *modified_cancel_button;
@@ -260,6 +263,31 @@ gb_editor_view_reload_document (GbEditorView *view,
}
static void
+gb_editor_view_notify_error (GbEditorView *view,
+ GParamSpec *pspec,
+ GbEditorDocument *document)
+{
+ const GError *error;
+
+ g_return_if_fail (GB_IS_EDITOR_VIEW (view));
+ g_return_if_fail (pspec);
+ g_return_if_fail (GB_IS_EDITOR_DOCUMENT (document));
+
+ error = gb_editor_document_get_error (document);
+
+ if (!error)
+ {
+ if (gtk_revealer_get_reveal_child (view->priv->error_revealer))
+ gtk_revealer_set_reveal_child (view->priv->error_revealer, FALSE);
+ }
+ else
+ {
+ gtk_label_set_label (view->priv->error_label, error->message);
+ gtk_revealer_set_reveal_child (view->priv->error_revealer, TRUE);
+ }
+}
+
+static void
gb_editor_view_connect (GbEditorView *view,
GbEditorDocument *document)
{
@@ -299,6 +327,18 @@ gb_editor_view_connect (GbEditorView *view,
G_CONNECT_SWAPPED);
g_signal_connect_object (document,
+ "notify::error",
+ G_CALLBACK (gb_editor_view_notify_error),
+ view,
+ G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (view->priv->error_close_button,
+ "clicked",
+ G_CALLBACK (gb_editor_view_hide_revealer_child),
+ view->priv->error_revealer,
+ G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (document,
"notify::file-changed-on-volume",
G_CALLBACK (gb_editor_view_file_changed_on_volume),
view,
@@ -530,6 +570,9 @@ gb_editor_view_class_init (GbEditorViewClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GbEditorView, modified_label);
gtk_widget_class_bind_template_child_private (widget_class, GbEditorView, modified_cancel_button);
gtk_widget_class_bind_template_child_private (widget_class, GbEditorView, modified_reload_button);
+ gtk_widget_class_bind_template_child_private (widget_class, GbEditorView, error_label);
+ gtk_widget_class_bind_template_child_private (widget_class, GbEditorView, error_revealer);
+ gtk_widget_class_bind_template_child_private (widget_class, GbEditorView, error_close_button);
g_type_ensure (GB_TYPE_EDITOR_FRAME);
}
diff --git a/src/resources/ui/gb-editor-view.ui b/src/resources/ui/gb-editor-view.ui
index 392247f..bc5bc48 100644
--- a/src/resources/ui/gb-editor-view.ui
+++ b/src/resources/ui/gb-editor-view.ui
@@ -55,7 +55,6 @@
<child>
<object class="GtkInfoBar">
<property name="visible">True</property>
- <property name="app_paintable">True</property>
<property name="can_focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
@@ -127,6 +126,72 @@
</object>
</child>
<child>
+ <object class="GtkRevealer" id="error_revealer">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="transition_type">GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN</property>
+ <property name="reveal_child">False</property>
+ <child>
+ <object class="GtkInfoBar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="message-type">GTK_MESSAGE_ERROR</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="error_close_button">
+ <property name="label" translatable="yes">_Close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child internal-child="content_area">
+ <object class="GtkBox">
+ <property name="can_focus">False</property>
+ <property name="spacing">16</property>
+ <child>
+ <object class="GtkLabel" id="error_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"></property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GtkPaned" id="paned">
<property name="orientation">vertical</property>
<property name="expand">true</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]