[gnome-builder] glade: update designer when source buffer is saved
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] glade: update designer when source buffer is saved
- Date: Mon, 22 Oct 2018 23:06:00 +0000 (UTC)
commit 7f4bd68de50a1002eb28dbc6ae4dded857437a42
Author: Christian Hergert <chergert redhat com>
Date: Mon Oct 22 16:04:42 2018 -0700
glade: update designer when source buffer is saved
src/plugins/glade/gbp-glade-view.c | 46 ++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
---
diff --git a/src/plugins/glade/gbp-glade-view.c b/src/plugins/glade/gbp-glade-view.c
index a930fe006..096a505a7 100644
--- a/src/plugins/glade/gbp-glade-view.c
+++ b/src/plugins/glade/gbp-glade-view.c
@@ -240,6 +240,50 @@ viewport_style_changed_cb (GbpGladeView *self,
ide_layout_view_set_primary_color_fg (IDE_LAYOUT_VIEW (self), &fg);
}
+static void
+gbp_glade_view_buffer_saved_cb (GbpGladeView *self,
+ IdeBuffer *buffer,
+ IdeBufferManager *bufmgr)
+{
+ IdeFile *file;
+ GFile *gfile;
+
+ g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (IDE_IS_BUFFER (buffer));
+ g_assert (IDE_IS_BUFFER_MANAGER (bufmgr));
+
+ if (self->file == NULL)
+ return;
+
+ file = ide_buffer_get_file (buffer);
+ gfile = ide_file_get_file (file);
+
+ if (g_file_equal (gfile, self->file))
+ _gbp_glade_view_reload (self);
+}
+
+static void
+gbp_glade_view_context_set (GtkWidget *widget,
+ IdeContext *context)
+{
+ GbpGladeView *self = (GbpGladeView *)widget;
+ IdeBufferManager *bufmgr;
+
+ g_assert (GBP_IS_GLADE_VIEW (self));
+ g_assert (!context || IDE_IS_CONTEXT (context));
+
+ if (context == NULL)
+ return;
+
+ /* Track when buffers are saved so that we can reload the view */
+ bufmgr = ide_context_get_buffer_manager (context);
+ g_signal_connect_object (bufmgr,
+ "buffer-saved",
+ G_CALLBACK (gbp_glade_view_buffer_saved_cb),
+ self,
+ G_CONNECT_SWAPPED);
+}
+
static void
gbp_glade_view_dispose (GObject *object)
{
@@ -318,6 +362,8 @@ gbp_glade_view_init (GbpGladeView *self)
ide_layout_view_set_icon_name (IDE_LAYOUT_VIEW (self), "glade-symbolic");
ide_layout_view_set_menu_id (IDE_LAYOUT_VIEW (self), "gbp-glade-view-document-menu");
+ ide_widget_set_context_handler (self, gbp_glade_view_context_set);
+
self->project = glade_project_new ();
g_signal_connect_object (self->project,
"changed",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]