[gnome-builder] greeter: add can-expand to track when model can expand
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] greeter: add can-expand to track when model can expand
- Date: Tue, 22 Jan 2019 06:49:23 +0000 (UTC)
commit a99293a1ab4e3837121d4f1010e29662100e2d11
Author: Christian Hergert <chergert redhat com>
Date: Mon Jan 21 22:47:28 2019 -0800
greeter: add can-expand to track when model can expand
src/libide/greeter/ide-truncate-model.c | 25 +++++++++++++++++++++++++
src/libide/greeter/ide-truncate-model.h | 1 +
2 files changed, 26 insertions(+)
---
diff --git a/src/libide/greeter/ide-truncate-model.c b/src/libide/greeter/ide-truncate-model.c
index 5d6c0f18a..1d0048c16 100644
--- a/src/libide/greeter/ide-truncate-model.c
+++ b/src/libide/greeter/ide-truncate-model.c
@@ -69,6 +69,7 @@ G_DEFINE_TYPE_WITH_CODE (IdeTruncateModel, ide_truncate_model, G_TYPE_OBJECT,
enum {
PROP_0,
+ PROP_CAN_EXPAND,
PROP_CHILD_MODEL,
PROP_EXPANDED,
PROP_MAX_ITEMS,
@@ -127,6 +128,8 @@ ide_truncate_model_items_changed_cb (IdeTruncateModel *self,
}
self->prev_n_items = n_items;
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CAN_EXPAND]);
}
static void
@@ -149,6 +152,10 @@ ide_truncate_model_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_CAN_EXPAND:
+ g_value_set_boolean (value, ide_truncate_model_get_can_expand (self));
+ break;
+
case PROP_CHILD_MODEL:
g_value_set_object (value, ide_truncate_model_get_child_model (self));
break;
@@ -208,6 +215,13 @@ ide_truncate_model_class_init (IdeTruncateModelClass *klass)
object_class->get_property = ide_truncate_model_get_property;
object_class->set_property = ide_truncate_model_set_property;
+ properties [PROP_CAN_EXPAND] =
+ g_param_spec_boolean ("can-expand",
+ "Can Expand",
+ "If the model can be expanded",
+ FALSE,
+ (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
/**
* IdeTruncateModel:child-model:
*
@@ -277,6 +291,7 @@ ide_truncate_model_set_expanded (IdeTruncateModel *self,
0, old_n_items, new_n_items);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_EXPANDED]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CAN_EXPAND]);
}
}
@@ -314,6 +329,7 @@ ide_truncate_model_set_max_items (IdeTruncateModel *self,
}
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_MAX_ITEMS]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CAN_EXPAND]);
}
}
@@ -331,3 +347,12 @@ ide_truncate_model_get_child_model (IdeTruncateModel *self)
return self->child_model;
}
+
+gboolean
+ide_truncate_model_get_can_expand (IdeTruncateModel *self)
+{
+ g_return_val_if_fail (IDE_IS_TRUNCATE_MODEL (self), FALSE);
+
+ return !self->expanded &&
+ g_list_model_get_n_items (self->child_model) > self->max_items;
+}
diff --git a/src/libide/greeter/ide-truncate-model.h b/src/libide/greeter/ide-truncate-model.h
index dcd8af27c..2c2d1c62e 100644
--- a/src/libide/greeter/ide-truncate-model.h
+++ b/src/libide/greeter/ide-truncate-model.h
@@ -33,6 +33,7 @@ GListModel *ide_truncate_model_get_child_model (IdeTruncateModel *self);
guint ide_truncate_model_get_max_items (IdeTruncateModel *self);
void ide_truncate_model_set_max_items (IdeTruncateModel *self,
guint max_items);
+gboolean ide_truncate_model_get_can_expand (IdeTruncateModel *self);
gboolean ide_truncate_model_get_expanded (IdeTruncateModel *self);
void ide_truncate_model_set_expanded (IdeTruncateModel *self,
gboolean expanded);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]