[gnome-builder/wip/libide-merge] bring back the reload buffer bar
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide-merge] bring back the reload buffer bar
- Date: Mon, 23 Mar 2015 00:58:51 +0000 (UTC)
commit 8fe7ea4975951f3876c437654a8697650cc3f4fc
Author: Christian Hergert <christian hergert me>
Date: Sun Mar 22 17:58:35 2015 -0700
bring back the reload buffer bar
This still needs to be connected to the changed-on-volume signal which
needs to be forward-ported.
data/ui/gb-editor-view.ui | 115 +++++++++++++++++++++++++---------
src/editor/gb-editor-view-actions.c | 65 ++++++++++++++++++++
src/editor/gb-editor-view-private.h | 2 +
src/editor/gb-editor-view.c | 17 +++++
4 files changed, 168 insertions(+), 31 deletions(-)
---
diff --git a/data/ui/gb-editor-view.ui b/data/ui/gb-editor-view.ui
index 14cd987..eee0105 100644
--- a/data/ui/gb-editor-view.ui
+++ b/data/ui/gb-editor-view.ui
@@ -3,48 +3,101 @@
<!-- interface-requires gtk+ 3.15 -->
<template class="GbEditorView" parent="GbView">
<child>
- <object class="GtkOverlay">
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
<property name="visible">true</property>
- <child type="overlay">
- <object class="GtkProgressBar" id="progress_bar">
- <property name="halign">fill</property>
- <property name="orientation">horizontal</property>
- <property name="valign">start</property>
- <property name="visible">false</property>
- <style>
- <class name="osd"/>
- </style>
- </object>
- </child>
<child>
- <object class="GtkPaned" id="paned">
- <property name="expand">true</property>
- <property name="orientation">vertical</property>
+ <object class="GtkRevealer" id="modified_revealer">
<property name="visible">true</property>
+ <property name="reveal-child">false</property>
<child>
- <object class="GbEditorFrame" id="frame1">
+ <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">view.reload-buffer</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>
- <packing>
- <property name="resize">true</property>
- <property name="shrink">false</property>
- </packing>
</child>
</object>
</child>
- </object>
- </child>
- <child internal-child="controls">
- <object class="GtkBox">
<child>
- <object class="GtkMenuButton" id="tweak_button">
- <property name="popover">popover</property>
+ <object class="GtkOverlay">
<property name="visible">true</property>
- <style>
- <class name="dim-label"/>
- <class name="text-button"/>
- <class name="flat"/>
- </style>
+ <child type="overlay">
+ <object class="GtkProgressBar" id="progress_bar">
+ <property name="halign">fill</property>
+ <property name="orientation">horizontal</property>
+ <property name="valign">start</property>
+ <property name="visible">false</property>
+ <style>
+ <class name="osd"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkPaned" id="paned">
+ <property name="expand">true</property>
+ <property name="orientation">vertical</property>
+ <property name="visible">true</property>
+ <child>
+ <object class="GbEditorFrame" id="frame1">
+ <property name="visible">true</property>
+ </object>
+ <packing>
+ <property name="resize">true</property>
+ <property name="shrink">false</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child internal-child="controls">
+ <object class="GtkBox">
+ <child>
+ <object class="GtkMenuButton" id="tweak_button">
+ <property name="popover">popover</property>
+ <property name="visible">true</property>
+ <style>
+ <class name="dim-label"/>
+ <class name="text-button"/>
+ <class name="flat"/>
+ </style>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/src/editor/gb-editor-view-actions.c b/src/editor/gb-editor-view-actions.c
index a8327d6..868540a 100644
--- a/src/editor/gb-editor-view-actions.c
+++ b/src/editor/gb-editor-view-actions.c
@@ -510,6 +510,70 @@ gb_editor_view_actions_find_other_file (GSimpleAction *action,
}
static void
+gb_editor_view_actions_reload_buffer_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ IdeBufferManager *buffer_manager = (IdeBufferManager *)object;
+ g_autoptr(GbEditorView) self = user_data;
+ g_autoptr(GError) error = NULL;
+ g_autoptr(IdeBuffer) buffer = NULL;
+
+ g_assert (IDE_IS_BUFFER_MANAGER (buffer_manager));
+ g_assert (GB_IS_EDITOR_VIEW (self));
+
+ if (!(buffer = ide_buffer_manager_load_file_finish (buffer_manager, result, &error)))
+ {
+ g_warning ("%s", error->message);
+ }
+ else
+ {
+ g_signal_emit_by_name (self->frame1->source_view, "movement",
+ IDE_SOURCE_VIEW_MOVEMENT_FIRST_LINE, FALSE, TRUE,
+ FALSE);
+ if (self->frame2 != NULL)
+ g_signal_emit_by_name (self->frame2->source_view, "movement",
+ IDE_SOURCE_VIEW_MOVEMENT_FIRST_LINE, FALSE, TRUE,
+ FALSE);
+ }
+
+ gb_widget_fade_hide (GTK_WIDGET (self->progress_bar));
+}
+
+static void
+gb_editor_view_actions_reload_buffer (GSimpleAction *action,
+ GVariant *param,
+ gpointer user_data)
+{
+ GbEditorView *self = user_data;
+ IdeContext *context;
+ IdeBufferManager *buffer_manager;
+ IdeFile *file;
+ g_autoptr(IdeProgress) progress = NULL;
+
+ g_assert (GB_IS_EDITOR_VIEW (self));
+
+ context = ide_buffer_get_context (IDE_BUFFER (self->document));
+ file = ide_buffer_get_file (IDE_BUFFER (self->document));
+
+ buffer_manager = ide_context_get_buffer_manager (context);
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (self->progress_bar), 0.0);
+ gtk_widget_show (GTK_WIDGET (self->progress_bar));
+
+ ide_buffer_manager_load_file_async (buffer_manager,
+ file,
+ TRUE,
+ &progress,
+ NULL,
+ gb_editor_view_actions_reload_buffer_cb,
+ g_object_ref (self));
+
+ g_object_bind_property (progress, "fraction", self->progress_bar, "fraction",
+ G_BINDING_SYNC_CREATE);
+}
+
+static void
gb_editor_view_actions_preview (GSimpleAction *action,
GVariant *param,
gpointer user_data)
@@ -572,6 +636,7 @@ static GActionEntry GbEditorViewActions[] = {
{ "highlight-current-line", NULL, NULL, "false", gb_editor_view_actions_highlight_current_line },
{ "language", NULL, "s", "''", gb_editor_view_actions_language },
{ "preview", gb_editor_view_actions_preview },
+ { "reload-buffer", gb_editor_view_actions_reload_buffer },
{ "save", gb_editor_view_actions_save },
{ "save-as", gb_editor_view_actions_save_as },
{ "show-line-numbers", NULL, NULL, "false", gb_editor_view_actions_show_line_numbers },
diff --git a/src/editor/gb-editor-view-private.h b/src/editor/gb-editor-view-private.h
index 280df02..b833636 100644
--- a/src/editor/gb-editor-view-private.h
+++ b/src/editor/gb-editor-view-private.h
@@ -35,6 +35,8 @@ struct _GbEditorView
GbEditorFrame *frame1;
GbEditorFrame *frame2;
+ GtkButton *modified_cancel_button;
+ GtkRevealer *modified_revealer;
GtkPaned *paned;
GtkProgressBar *progress_bar;
GtkMenuButton *tweak_button;
diff --git a/src/editor/gb-editor-view.c b/src/editor/gb-editor-view.c
index 694d8e9..c1fd73f 100644
--- a/src/editor/gb-editor-view.c
+++ b/src/editor/gb-editor-view.c
@@ -235,6 +235,15 @@ gb_editor_view_set_back_forward_list (GbView *view,
}
static void
+gb_editor_view_hide_reload_bar (GbEditorView *self,
+ GtkWidget *button)
+{
+ g_assert (GB_IS_EDITOR_VIEW (self));
+
+ gtk_revealer_set_reveal_child (self->modified_revealer, FALSE);
+}
+
+static void
gb_editor_view_finalize (GObject *object)
{
GbEditorView *self = (GbEditorView *)object;
@@ -314,6 +323,8 @@ gb_editor_view_class_init (GbEditorViewClass *klass)
GB_WIDGET_CLASS_TEMPLATE (klass, "gb-editor-view.ui");
GB_WIDGET_CLASS_BIND (klass, GbEditorView, frame1);
+ GB_WIDGET_CLASS_BIND (klass, GbEditorView, modified_cancel_button);
+ GB_WIDGET_CLASS_BIND (klass, GbEditorView, modified_revealer);
GB_WIDGET_CLASS_BIND (klass, GbEditorView, paned);
GB_WIDGET_CLASS_BIND (klass, GbEditorView, progress_bar);
GB_WIDGET_CLASS_BIND (klass, GbEditorView, tweak_button);
@@ -331,4 +342,10 @@ gb_editor_view_init (GbEditorView *self)
self->settings = g_settings_new ("org.gnome.builder.editor");
gb_editor_view_actions_init (self);
+
+ g_signal_connect_object (self->modified_cancel_button,
+ "clicked",
+ G_CALLBACK (gb_editor_view_hide_reload_bar),
+ self,
+ G_CONNECT_SWAPPED);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]