selection: Make the model an interface property

This is in line with what we do for other wrapper models.
This commit is contained in:
Matthias Clasen
2019-01-05 22:38:23 -05:00
parent dfd280acd0
commit d0ef5f5db4
5 changed files with 40 additions and 42 deletions

View File

@@ -53,9 +53,11 @@ struct _GtkMultiSelectionClass
enum {
PROP_0,
/* selectionmodel */
PROP_MODEL,
N_PROPS,
N_PROPS = PROP_MODEL
};
static GParamSpec *properties[N_PROPS] = { NULL, };
@@ -287,19 +289,7 @@ gtk_multi_selection_class_init (GtkMultiSelectionClass *klass)
gobject_class->set_property = gtk_multi_selection_set_property;
gobject_class->dispose = gtk_multi_selection_dispose;
/**
* GtkMultiSelection:model
*
* The list managed by this selection
*/
properties[PROP_MODEL] =
g_param_spec_object ("model",
P_("Model"),
P_("List managed by this selection"),
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
g_object_class_override_property (gobject_class, PROP_MODEL, "model");
}
static void

View File

@@ -48,9 +48,11 @@ struct _GtkNoSelectionClass
enum {
PROP_0,
/* selectionmodel */
PROP_MODEL,
N_PROPS,
N_PROPS = PROP_MODEL
};
static GParamSpec *properties[N_PROPS] = { NULL, };
@@ -177,19 +179,7 @@ gtk_no_selection_class_init (GtkNoSelectionClass *klass)
gobject_class->set_property = gtk_no_selection_set_property;
gobject_class->dispose = gtk_no_selection_dispose;
/**
* GtkNoSelection:model
*
* The list managed by this selection
*/
properties[PROP_MODEL] =
g_param_spec_object ("model",
P_("Model"),
P_("List managed by this selection"),
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
g_object_class_override_property (gobject_class, PROP_MODEL, "model");
}
static void

View File

@@ -21,6 +21,7 @@
#include "gtkselectionmodel.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
/**
@@ -156,6 +157,17 @@ gtk_selection_model_default_init (GtkSelectionModelInterface *iface)
g_signal_set_va_marshaller (signals[SELECTION_CHANGED],
GTK_TYPE_SELECTION_MODEL,
_gtk_marshal_VOID__UINT_UINTv);
g_object_interface_install_property (iface,
g_param_spec_object ("model",
P_("Model"),
P_("List managed by this selection"),
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE
| G_PARAM_CONSTRUCT_ONLY
| G_PARAM_EXPLICIT_NOTIFY
| G_PARAM_STATIC_STRINGS));
}
/**
@@ -254,6 +266,18 @@ gtk_selection_model_unselect_all (GtkSelectionModel *model)
return iface->unselect_all (model);
}
GListModel *
gtk_selection_model_get_model (GtkSelectionModel *model)
{
GListModel *child;
g_object_get (model, "model", &child, NULL);
if (child)
g_object_unref (child);
return child;
}
void
gtk_selection_model_selection_changed (GtkSelectionModel *model,
guint position,

View File

@@ -108,6 +108,9 @@ gboolean gtk_selection_model_select_all (GtkSelectionMod
GDK_AVAILABLE_IN_ALL
gboolean gtk_selection_model_unselect_all (GtkSelectionModel *model);
GDK_AVAILABLE_IN_ALL
GListModel * gtk_selection_model_get_model (GtkSelectionModel *model);
/* for implementations only */
GDK_AVAILABLE_IN_ALL
void gtk_selection_model_selection_changed (GtkSelectionModel *model,

View File

@@ -55,10 +55,11 @@ enum {
PROP_0,
PROP_AUTOSELECT,
PROP_CAN_UNSELECT,
PROP_MODEL,
PROP_SELECTED,
N_PROPS,
/* selectionmodel */
PROP_MODEL,
N_PROPS = PROP_MODEL
};
static GParamSpec *properties[N_PROPS] = { NULL, };
@@ -337,6 +338,8 @@ gtk_single_selection_class_init (GtkSingleSelectionClass *klass)
gobject_class->set_property = gtk_single_selection_set_property;
gobject_class->dispose = gtk_single_selection_dispose;
g_object_class_override_property (gobject_class, PROP_MODEL, "model");
/**
* GtkSingleSelection:autoselect
*
@@ -361,18 +364,6 @@ gtk_single_selection_class_init (GtkSingleSelectionClass *klass)
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GtkSingleSelection:model
*
* The list managed by this selection
*/
properties[PROP_MODEL] =
g_param_spec_object ("model",
P_("Model"),
P_("List managed by this selection"),
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GtkSingleSelection:selected
*