summaryrefslogtreecommitdiff
path: root/liblogdiag/ld-category-symbol-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'liblogdiag/ld-category-symbol-view.c')
-rw-r--r--liblogdiag/ld-category-symbol-view.c106
1 files changed, 32 insertions, 74 deletions
diff --git a/liblogdiag/ld-category-symbol-view.c b/liblogdiag/ld-category-symbol-view.c
index 6116566..3cf975f 100644
--- a/liblogdiag/ld-category-symbol-view.c
+++ b/liblogdiag/ld-category-symbol-view.c
@@ -70,6 +70,11 @@ static void ld_category_symbol_view_set_property (GObject *object,
guint property_id, const GValue *value, GParamSpec *pspec);
static void ld_category_symbol_view_finalize (GObject *gobject);
+static void ld_category_symbol_view_set_category
+ (LdCategoryViewIf *iface, LdCategory *category);
+static LdCategory *ld_category_symbol_view_get_category
+ (LdCategoryViewIf *iface);
+
static void on_size_request (GtkWidget *widget, GtkRequisition *requisition,
gpointer user_data);
static void on_size_allocate (GtkWidget *widget, GdkRectangle *allocation,
@@ -78,59 +83,28 @@ static gboolean on_expose_event (GtkWidget *widget, GdkEventExpose *event,
gpointer user_data);
-G_DEFINE_TYPE (LdCategorySymbolView,
- ld_category_symbol_view, GTK_TYPE_DRAWING_AREA);
+static void
+ld_category_view_if_init (LdCategoryViewIfInterface *iface)
+{
+ iface->set_category = ld_category_symbol_view_set_category;
+ iface->get_category = ld_category_symbol_view_get_category;
+}
+
+G_DEFINE_TYPE_WITH_CODE (LdCategorySymbolView,
+ ld_category_symbol_view, GTK_TYPE_DRAWING_AREA,
+ G_IMPLEMENT_INTERFACE (LD_TYPE_CATEGORY_VIEW_IF, ld_category_view_if_init));
static void
ld_category_symbol_view_class_init (LdCategorySymbolViewClass *klass)
{
GObjectClass *object_class;
- GParamSpec *pspec;
object_class = G_OBJECT_CLASS (klass);
object_class->get_property = ld_category_symbol_view_get_property;
object_class->set_property = ld_category_symbol_view_set_property;
object_class->finalize = ld_category_symbol_view_finalize;
-/**
- * LdCategorySymbolView::symbol-selected:
- * @self: an #LdCategorySymbolView object.
- * @symbol: the selected #LdSymbol object.
- * @path: location of the symbol within the library.
- *
- * A symbol has been selected.
- */
- klass->symbol_selected_signal = g_signal_new
- ("symbol-selected", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- ld_marshal_VOID__OBJECT_STRING,
- G_TYPE_NONE, 2, LD_TYPE_SYMBOL,
- G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
-
-/**
- * LdCategorySymbolView::symbol-deselected:
- * @self: an #LdCategorySymbolView object.
- * @symbol: the deselected #LdSymbol object.
- * @path: location of the symbol within the library.
- *
- * A symbol has been deselected.
- */
- klass->symbol_deselected_signal = g_signal_new
- ("symbol-deselected", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- ld_marshal_VOID__OBJECT_STRING,
- G_TYPE_NONE, 2, LD_TYPE_SYMBOL,
- G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
-
-/**
- * LdCategorySymbolView:category:
- *
- * The underlying #LdCategory object of this view.
- */
- pspec = g_param_spec_object ("category", "Category",
- "The underlying category object of this view.",
- LD_TYPE_CATEGORY, G_PARAM_READWRITE);
- g_object_class_install_property (object_class, PROP_CATEGORY, pspec);
+ g_object_class_override_property (object_class, PROP_CATEGORY, "category");
g_type_class_add_private (klass, sizeof (LdCategorySymbolViewPrivate));
}
@@ -154,7 +128,7 @@ symbol_deselect (LdCategorySymbolView *self)
if (!preselected)
return;
- g_signal_emit (self, LD_CATEGORY_SYMBOL_VIEW_GET_CLASS (self)->
+ g_signal_emit (self, LD_CATEGORY_VIEW_IF_GET_INTERFACE (self)->
symbol_deselected_signal, 0, preselected->symbol, preselected->path);
symbol_redraw (self, preselected);
@@ -201,7 +175,7 @@ on_motion_notify (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
gtk_drag_source_set (widget,
GDK_BUTTON1_MASK, &target, 1, GDK_ACTION_COPY);
- g_signal_emit (self, LD_CATEGORY_SYMBOL_VIEW_GET_CLASS (self)->
+ g_signal_emit (self, LD_CATEGORY_VIEW_IF_GET_INTERFACE (self)->
symbol_selected_signal, 0, data->symbol, data->path);
}
return FALSE;
@@ -320,13 +294,11 @@ static void
ld_category_symbol_view_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec)
{
- LdCategorySymbolView *self;
-
- self = LD_CATEGORY_SYMBOL_VIEW (object);
switch (property_id)
{
case PROP_CATEGORY:
- g_value_set_object (value, ld_category_symbol_view_get_category (self));
+ g_value_set_object (value,
+ ld_category_view_if_get_category (LD_CATEGORY_VIEW_IF (object)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -337,13 +309,10 @@ static void
ld_category_symbol_view_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec)
{
- LdCategorySymbolView *self;
-
- self = LD_CATEGORY_SYMBOL_VIEW (object);
switch (property_id)
{
case PROP_CATEGORY:
- ld_category_symbol_view_set_category (self,
+ ld_category_view_if_set_category (LD_CATEGORY_VIEW_IF (object),
LD_CATEGORY (g_value_get_object (value)));
break;
default:
@@ -572,24 +541,20 @@ ld_category_symbol_view_new (LdCategory *category)
LdCategorySymbolView *self;
self = g_object_new (LD_TYPE_CATEGORY_SYMBOL_VIEW, NULL);
- ld_category_symbol_view_set_category (self, category);
+ ld_category_view_if_set_category (LD_CATEGORY_VIEW_IF (self), category);
return GTK_WIDGET (self);
}
-/**
- * ld_category_symbol_view_set_category:
- * @self: an #LdCategorySymbolView object.
- * @category: the #LdCategory to be assigned to the view.
- *
- * Assign an #LdCategory object to the view.
- */
-void
-ld_category_symbol_view_set_category (LdCategorySymbolView *self,
+static void
+ld_category_symbol_view_set_category (LdCategoryViewIf *iface,
LdCategory *category)
{
- g_return_if_fail (LD_IS_CATEGORY_SYMBOL_VIEW (self));
+ LdCategorySymbolView *self;
+
+ g_return_if_fail (LD_IS_CATEGORY_SYMBOL_VIEW (iface));
g_return_if_fail (LD_IS_CATEGORY (category));
+ self = LD_CATEGORY_SYMBOL_VIEW (iface);
if (self->priv->category)
{
g_object_unref (self->priv->category);
@@ -609,16 +574,9 @@ ld_category_symbol_view_set_category (LdCategorySymbolView *self,
gtk_widget_queue_resize (GTK_WIDGET (self));
}
-/**
- * ld_category_symbol_view_get_category:
- * @self: an #LdCategorySymbolView object.
- *
- * Get the #LdCategory object assigned to this view.
- * The reference count on the category is not incremented.
- */
-LdCategory *
-ld_category_symbol_view_get_category (LdCategorySymbolView *self)
+static LdCategory *
+ld_category_symbol_view_get_category (LdCategoryViewIf *iface)
{
- g_return_val_if_fail (LD_IS_CATEGORY_SYMBOL_VIEW (self), NULL);
- return self->priv->category;
+ g_return_val_if_fail (LD_IS_CATEGORY_SYMBOL_VIEW (iface), NULL);
+ return LD_CATEGORY_SYMBOL_VIEW (iface)->priv->category;
}