[gnome-builder] editor-view: set back changed on volume infobar
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor-view: set back changed on volume infobar
- Date: Tue, 15 Aug 2017 11:36:56 +0000 (UTC)
commit f1288c0f5dac61f1c47feb8424545893d7dfc7b7
Author: Sebastien Lafargue <slafargue gnome org>
Date: Tue Aug 15 13:32:15 2017 +0200
editor-view: set back changed on volume infobar
We bring back this feature but it should probably
mutate to a more generic infobar and the changed-on-volume
signal doesn't seems to be prefectly reliable too.
Well, we are going out of time before the freeze, so...
https://bugzilla.gnome.org/show_bug.cgi?id=786293
libide/editor/ide-editor-private.h | 2 +
libide/editor/ide-editor-view.c | 33 ++++++++++++++++++++++++
libide/editor/ide-editor-view.ui | 49 ++++++++++++++++++++++++++++++++++++
3 files changed, 84 insertions(+), 0 deletions(-)
---
diff --git a/libide/editor/ide-editor-private.h b/libide/editor/ide-editor-private.h
index 5198162..80ca106 100644
--- a/libide/editor/ide-editor-private.h
+++ b/libide/editor/ide-editor-private.h
@@ -76,6 +76,8 @@ struct _IdeEditorView
GtkBox *scroller_box;
IdeEditorSearchBar *search_bar;
GtkRevealer *search_revealer;
+ GtkRevealer *modified_revealer;
+ GtkButton *modified_cancel_button;
guint toggle_map_source;
diff --git a/libide/editor/ide-editor-view.c b/libide/editor/ide-editor-view.c
index cb8caa2..a8623ce 100644
--- a/libide/editor/ide-editor-view.c
+++ b/libide/editor/ide-editor-view.c
@@ -293,6 +293,27 @@ unset_primary_color:
ide_layout_view_set_primary_color_fg (IDE_LAYOUT_VIEW (self), NULL);
}
+static void
+ide_editor_view__buffer_notify_changed_on_volume (IdeEditorView *self,
+ GParamSpec *pspec,
+ IdeBuffer *buffer)
+{
+ g_assert (IDE_IS_EDITOR_VIEW (self));
+ g_assert (IDE_IS_BUFFER (buffer));
+
+ gtk_revealer_set_reveal_child (self->modified_revealer,
+ ide_buffer_get_changed_on_volume (buffer));
+}
+
+static void
+ide_editor_view_hide_reload_bar (IdeEditorView *self,
+ GtkWidget *button)
+{
+ g_assert (IDE_IS_EDITOR_VIEW (self));
+
+ gtk_revealer_set_reveal_child (self->modified_revealer, FALSE);
+}
+
static gboolean
ide_editor_view_source_view_event (IdeEditorView *self,
GdkEvent *event,
@@ -746,6 +767,8 @@ ide_editor_view_class_init (IdeEditorViewClass *klass)
gtk_widget_class_bind_template_child (widget_class, IdeEditorView, scroller_box);
gtk_widget_class_bind_template_child (widget_class, IdeEditorView, search_bar);
gtk_widget_class_bind_template_child (widget_class, IdeEditorView, search_revealer);
+ gtk_widget_class_bind_template_child (widget_class, IdeEditorView, modified_revealer);
+ gtk_widget_class_bind_template_child (widget_class, IdeEditorView, modified_cancel_button);
gtk_widget_class_bind_template_child (widget_class, IdeEditorView, source_view);
gtk_widget_class_bind_template_callback (widget_class, ide_editor_view_notify_child_revealed);
gtk_widget_class_bind_template_callback (widget_class, ide_editor_view_stop_search);
@@ -790,12 +813,22 @@ ide_editor_view_init (IdeEditorView *self)
"notify::style-scheme",
G_CALLBACK (ide_editor_view_buffer_notify_style_scheme),
self);
+ dzl_signal_group_connect_swapped (self->buffer_signals,
+ "notify::changed-on-volume",
+ G_CALLBACK (ide_editor_view__buffer_notify_changed_on_volume),
+ self);
g_signal_connect_swapped (self->buffer_signals,
"bind",
G_CALLBACK (ide_editor_view_bind_signals),
self);
+ g_signal_connect_object (self->modified_cancel_button,
+ "clicked",
+ G_CALLBACK (ide_editor_view_hide_reload_bar),
+ self,
+ G_CONNECT_SWAPPED);
+
/*
* Setup our search context. The sourceview has it's own search
* infrastructure that we want to reserve for use by vim keybindings
diff --git a/libide/editor/ide-editor-view.ui b/libide/editor/ide-editor-view.ui
index aa65852..c7fa19e 100644
--- a/libide/editor/ide-editor-view.ui
+++ b/libide/editor/ide-editor-view.ui
@@ -21,6 +21,55 @@
</object>
</child>
<child type="overlay">
+ <object class="GtkRevealer" id="modified_revealer">
+ <property name="halign">fill</property>
+ <property name="valign">start</property>
+ <property name="visible">true</property>
+ <property name="reveal-child">false</property>
+ <child>
+ <object class="GtkInfoBar">
+ <property name="visible">true</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="spacing">6</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton">
+ <property name="action-name">editor-view.reload</property>
+ <property name="label" translatable="yes">_Reload</property>
+ <property name="visible">true</property>
+ <property name="receives_default">true</property>
+ <property name="use_underline">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="modified_cancel_button">
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="visible">true</property>
+ <property name="use_underline">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child internal-child="content_area">
+ <object class="GtkBox">
+ <property name="spacing">16</property>
+ <child>
+ <object class="GtkLabel" id="modified_label">
+ <property name="hexpand">true</property>
+ <property name="label" translatable="yes">Builder has discovered that this file has
been modified externally. Would you like to reload the file?</property>
+ <property name="visible">true</property>
+ <property name="wrap">true</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="overlay">
<object class="GtkProgressBar" id="progress_bar">
<property name="hexpand">true</property>
<property name="valign">start</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]