[sysprof/wip/visualizers] visualizer-view: add ::visualizer-added and ::visualizer-removed
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/visualizers] visualizer-view: add ::visualizer-added and ::visualizer-removed
- Date: Wed, 28 Sep 2016 20:24:42 +0000 (UTC)
commit b5fccca06981bf49eeef7420bc1a834a6bb90b57
Author: Christian Hergert <chergert redhat com>
Date: Wed Sep 28 13:22:51 2016 -0700
visualizer-view: add ::visualizer-added and ::visualizer-removed
These signals are emitted when a visualizer row has been added
or removed from the view. This might be handy if you want to
resize a paned based on the natural size of the visualizers.
lib/sp-visualizer-view.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++
lib/sp-visualizer-view.h | 7 +++++
2 files changed, 70 insertions(+), 0 deletions(-)
---
diff --git a/lib/sp-visualizer-view.c b/lib/sp-visualizer-view.c
index 6856d7d..4284a6a 100644
--- a/lib/sp-visualizer-view.c
+++ b/lib/sp-visualizer-view.c
@@ -38,6 +38,12 @@ enum {
N_PROPS
};
+enum {
+ VISUALIZER_ADDED,
+ VISUALIZER_REMOVED,
+ N_SIGNALS
+};
+
static void buildable_iface_init (GtkBuildableIface *iface);
G_DEFINE_TYPE_EXTENDED (SpVisualizerView, sp_visualizer_view, GTK_TYPE_BIN, 0,
@@ -45,9 +51,36 @@ G_DEFINE_TYPE_EXTENDED (SpVisualizerView, sp_visualizer_view, GTK_TYPE_BIN, 0,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, buildable_iface_init))
static GParamSpec *properties [N_PROPS];
+static guint signals [N_SIGNALS];
static GtkBuildableIface *parent_buildable;
static void
+sp_visualizer_view_row_added (SpVisualizerView *self,
+ GtkWidget *widget,
+ SpVisualizerList *list)
+{
+ g_assert (SP_IS_VISUALIZER_VIEW (self));
+ g_assert (GTK_IS_WIDGET (widget));
+ g_assert (SP_IS_VISUALIZER_LIST (list));
+
+ if (SP_IS_VISUALIZER_ROW (widget))
+ g_signal_emit (self, signals [VISUALIZER_ADDED], 0, widget);
+}
+
+static void
+sp_visualizer_view_row_removed (SpVisualizerView *self,
+ GtkWidget *widget,
+ SpVisualizerList *list)
+{
+ g_assert (SP_IS_VISUALIZER_VIEW (self));
+ g_assert (GTK_IS_WIDGET (widget));
+ g_assert (SP_IS_VISUALIZER_LIST (list));
+
+ if (SP_IS_VISUALIZER_ROW (widget))
+ g_signal_emit (self, signals [VISUALIZER_REMOVED], 0, widget);
+}
+
+static void
sp_visualizer_view_finalize (GObject *object)
{
SpVisualizerView *self = (SpVisualizerView *)object;
@@ -115,6 +148,22 @@ sp_visualizer_view_class_init (SpVisualizerViewClass *klass)
g_object_class_install_properties (object_class, N_PROPS, properties);
+ signals [VISUALIZER_ADDED] =
+ g_signal_new ("visualizer-added",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (SpVisualizerViewClass, visualizer_added),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1, SP_TYPE_VISUALIZER_ROW);
+
+ signals [VISUALIZER_REMOVED] =
+ g_signal_new ("visualizer-removed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (SpVisualizerViewClass, visualizer_removed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1, SP_TYPE_VISUALIZER_ROW);
+
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sp-visualizer-view.ui");
gtk_widget_class_bind_template_child_private (widget_class, SpVisualizerView, list);
gtk_widget_class_bind_template_child_private (widget_class, SpVisualizerView, ticks);
@@ -125,7 +174,21 @@ sp_visualizer_view_class_init (SpVisualizerViewClass *klass)
static void
sp_visualizer_view_init (SpVisualizerView *self)
{
+ SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
+
gtk_widget_init_template (GTK_WIDGET (self));
+
+ g_signal_connect_object (priv->list,
+ "add",
+ G_CALLBACK (sp_visualizer_view_row_added),
+ self,
+ G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (priv->list,
+ "remove",
+ G_CALLBACK (sp_visualizer_view_row_removed),
+ self,
+ G_CONNECT_SWAPPED);
}
/**
diff --git a/lib/sp-visualizer-view.h b/lib/sp-visualizer-view.h
index 1050fc8..b1e00a7 100644
--- a/lib/sp-visualizer-view.h
+++ b/lib/sp-visualizer-view.h
@@ -21,6 +21,8 @@
#include <gtk/gtk.h>
+#include "sp-visualizer-row.h"
+
G_BEGIN_DECLS
#define SP_TYPE_VISUALIZER_VIEW (sp_visualizer_view_get_type())
@@ -31,6 +33,11 @@ struct _SpVisualizerViewClass
{
GtkBinClass parent_class;
+ void (*visualizer_added) (SpVisualizerView *self,
+ SpVisualizerRow *visualizer);
+ void (*visualizer_removed) (SpVisualizerView *self,
+ SpVisualizerRow *visualizer);
+
gpointer _reserved1;
gpointer _reserved2;
gpointer _reserved3;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]