Compare commits

...

3 Commits

Author SHA1 Message Date
Matthias Clasen
9d61fc9e51 lists: Clarify rubberband docs
Say that it is only useful to enable rubberbanding
for multi-selection, and mention GtkMultiSelection
explicitly.
2020-07-17 08:18:07 -04:00
Matthias Clasen
dbfbb03748 lists: Adjust the selection docs
Don't mention the auto-created internal selection model.
It is confusing to mention it, since the state it maintains
is not easily accessible from the outside, and we want
users to create their own selection model.
2020-07-17 08:15:50 -04:00
Matthias Clasen
e4f3c5da40 lists: Don't create a ghost selection
If the model passed to gtk_...view_set_model is not
a selection model, create a GtkNoSelection for internal
purposes, not a GtkSingleSelection. The single selection
is confusing because it maintains a selection state that
cannot be accessed from the application side.
2020-07-17 08:10:51 -04:00
4 changed files with 31 additions and 19 deletions

View File

@@ -58,10 +58,9 @@
* separators between the rows or columns.
*
* GtkColumnView allows the user to select items according to the selection
* characteristics of the model. If the provided model is not a #GtkSelectionModel,
* GtkColumnView will wrap it in a #GtkSingleSelection. For models that allow
* multiple selected items, it is possible to turn on *rubberband selection*,
* using #GtkColumnView:enable-rubberband.
* characteristics of the model (see #GtkSelectionModel and its implementations).
* For models that allow multiple selected items, it is possible to turn on
* _rubberband selection_, using #GtkColumnView:enable-rubberband.
*
* The column view supports sorting that can be customized by the user by
* clicking on column headers. To set this up, the #GtkSorter returned by
@@ -1217,8 +1216,8 @@ gtk_column_view_get_model (GtkColumnView *self)
*
* Sets the #GListModel to use.
*
* If the @model is a #GtkSelectionModel, it is used for managing the selection.
* Otherwise, @self creates a #GtkSingleSelection for the selection.
* If the @model is a #GtkSelectionModel, it is used for managing
* the selection.
**/
void
gtk_column_view_set_model (GtkColumnView *self,
@@ -1632,6 +1631,10 @@ gtk_column_view_get_reorderable (GtkColumnView *self)
* @enable_rubberband: %TRUE to enable rubberband selection
*
* Sets whether selections can be changed by dragging with the mouse.
*
* Note that this is only useful when the model you passed to
* gtk_list_view_set_model() allows multi-selection (e.g. a
* #GtkMultiSelection).
*/
void
gtk_column_view_set_enable_rubberband (GtkColumnView *self,

View File

@@ -55,10 +55,9 @@
* grid reflows vertically or horizontally.
*
* GtkGridView allows the user to select items according to the selection
* characteristics of the model. If the provided model is not a #GtkSelectionModel,
* GtkGridView will wrap it in a #GtkSingleSelection. For models that allow
* multiple selected items, it is possible to turn on _rubberband selection_,
* using #GtkGridView:enable-rubberband.
* characteristics of the model (see #GtkSelectionModel and its implementations).
* For models that allow multiple selected items, it is possible to turn on
* _rubberband selection_, using #GtkGridView:enable-rubberband.
*
* To learn more about the list widget framework, see the [overview](#ListWidget).
*
@@ -1248,7 +1247,10 @@ gtk_grid_view_get_model (GtkGridView *self)
* @self: a #GtkGridView
* @model: (allow-none) (transfer none): the model to use or %NULL for none
*
* Sets the #GListModel to use for
* Sets the #GListModel to use.
*
* If the @model is a #GtkSelectionModel, it is used for managing
* the selection.
**/
void
gtk_grid_view_set_model (GtkGridView *self,
@@ -1436,6 +1438,10 @@ gtk_grid_view_get_single_click_activate (GtkGridView *self)
* @enable_rubberband: %TRUE to enable rubberband selection
*
* Sets whether selections can be changed by dragging with the mouse.
*
* Note that this is only useful when the model you passed to
* gtk_list_view_set_model() allows multi-selection (e.g. a
* #GtkMultiSelection).
*/
void
gtk_grid_view_set_enable_rubberband (GtkGridView *self,

View File

@@ -32,7 +32,7 @@
#include "gtkmultiselection.h"
#include "gtkorientable.h"
#include "gtkscrollable.h"
#include "gtksingleselection.h"
#include "gtknoselection.h"
#include "gtksnapshot.h"
#include "gtkstylecontextprivate.h"
#include "gtktypebuiltins.h"
@@ -2130,7 +2130,7 @@ gtk_list_base_set_model (GtkListBase *self,
if (GTK_IS_SELECTION_MODEL (model))
selection_model = GTK_SELECTION_MODEL (g_object_ref (model));
else
selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (model));
selection_model = GTK_SELECTION_MODEL (gtk_no_selection_new (model));
gtk_list_item_manager_set_model (priv->item_manager, selection_model);
gtk_list_base_set_anchor (self, 0, 0.0, GTK_PACK_START, 0.0, GTK_PACK_START);

View File

@@ -54,10 +54,9 @@
* between the rows.
*
* GtkListView allows the user to select items according to the selection
* characteristics of the model. If the provided model is not a #GtkSelectionModel,
* GtkListView will wrap it in a #GtkSingleSelection. For models that allow
* multiple selected items, it is possible to turn on _rubberband selection_,
* using #GtkListView:enable-rubberband.
* characteristics of the model (see #GtkSelectionModel and its implementations).
* For models that allow multiple selected items, it is possible to turn on
* _rubberband selection_, using #GtkListView:enable-rubberband.
*
* If you need multiple columns with headers, see #GtkColumnView.
*
@@ -1004,8 +1003,8 @@ gtk_list_view_get_model (GtkListView *self)
*
* Sets the #GListModel to use.
*
* If the @model is a #GtkSelectionModel, it is used for managing the selection.
* Otherwise, @self creates a #GtkSingleSelection for the selection.
* If the @model is a #GtkSelectionModel, it is used for managing
* the selection.
**/
void
gtk_list_view_set_model (GtkListView *self,
@@ -1147,6 +1146,10 @@ gtk_list_view_get_single_click_activate (GtkListView *self)
* @enable_rubberband: %TRUE to enable rubberband selection
*
* Sets whether selections can be changed by dragging with the mouse.
*
* Note that this is only useful when the model you passed to
* gtk_list_view_set_model() allows multi-selection (e.g. a
* #GtkMultiSelection).
*/
void
gtk_list_view_set_enable_rubberband (GtkListView *self,