[gnome-builder] IdeEditorPerspective: add view-added view-removed signals
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] IdeEditorPerspective: add view-added view-removed signals
- Date: Fri, 12 Feb 2016 23:31:09 +0000 (UTC)
commit a5b077173f5b882a520640d05f4f4b53d6d417e5
Author: Sebastien Lafargue <slafargue gnome org>
Date: Fri Feb 12 22:35:41 2016 +0100
IdeEditorPerspective: add view-added view-removed signals
libide/editor/ide-editor-perspective.c | 44 +++++++++++++++++++++++++++++++-
1 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/libide/editor/ide-editor-perspective.c b/libide/editor/ide-editor-perspective.c
index f56f27b..9f4c0a9 100644
--- a/libide/editor/ide-editor-perspective.c
+++ b/libide/editor/ide-editor-perspective.c
@@ -51,9 +51,19 @@ typedef struct
static void ide_perspective_iface_init (IdePerspectiveInterface *iface);
+static void ide_editor_perspective_add (GtkContainer *container, GtkWidget *widget);
+
G_DEFINE_TYPE_EXTENDED (IdeEditorPerspective, ide_editor_perspective, IDE_TYPE_LAYOUT, 0,
G_IMPLEMENT_INTERFACE (IDE_TYPE_PERSPECTIVE, ide_perspective_iface_init))
+enum {
+ VIEW_ADDED,
+ VIEW_REMOVED,
+ LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL];
+
static void
ide_editor_perspective_restore_panel_state (IdeEditorPerspective *self)
{
@@ -166,7 +176,7 @@ ide_editor_perspective_load_buffer (IdeEditorPerspective *self,
stack = ide_layout_grid_get_last_focus (self->grid);
- gtk_container_add (GTK_CONTAINER (stack), GTK_WIDGET (view));
+ ide_editor_perspective_add (GTK_CONTAINER (self), GTK_WIDGET (view));
workbench = ide_widget_get_workbench (GTK_WIDGET (stack));
ide_workbench_focus (workbench, GTK_WIDGET (view));
@@ -270,6 +280,13 @@ ide_editor_perspective_finalize (GObject *object)
}
static void
+ide_editor_perspective_view_weak_cb (IdeEditorPerspective *self,
+ IdeLayoutView *view)
+{
+ g_signal_emit (self, signals [VIEW_REMOVED], 0, view);
+}
+
+static void
ide_editor_perspective_add (GtkContainer *container,
GtkWidget *widget)
{
@@ -284,6 +301,11 @@ ide_editor_perspective_add (GtkContainer *container,
last_focus = ide_layout_grid_get_last_focus (self->grid);
gtk_container_add (GTK_CONTAINER (last_focus), widget);
+ g_object_weak_ref (G_OBJECT (widget),
+ (GWeakNotify)ide_editor_perspective_view_weak_cb,
+ container);
+
+ g_signal_emit (self, signals [VIEW_ADDED], 0, widget);
return;
}
@@ -305,6 +327,26 @@ ide_editor_perspective_class_init (IdeEditorPerspectiveClass *klass)
gtk_widget_class_bind_template_child (widget_class, IdeEditorPerspective, actions);
gtk_widget_class_bind_template_child (widget_class, IdeEditorPerspective, grid);
gtk_widget_class_bind_template_child (widget_class, IdeEditorPerspective, titlebar);
+
+ signals[VIEW_ADDED] =
+ g_signal_new ("view-added",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ GTK_TYPE_WIDGET);
+
+ signals[VIEW_REMOVED] =
+ g_signal_new ("view-removed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ GTK_TYPE_WIDGET);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]