2019-10-28 00:18:14 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2019 Benjamin Otte
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: Benjamin Otte <otte@gnome.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2019-10-28 19:50:49 +00:00
|
|
|
#include "gtkcolumnviewcolumnprivate.h"
|
2019-12-04 13:13:13 +00:00
|
|
|
#include "gtkcolumnviewsorterprivate.h"
|
2019-10-28 00:18:14 +00:00
|
|
|
|
2019-11-08 20:23:03 +00:00
|
|
|
#include "gtkcolumnviewprivate.h"
|
|
|
|
#include "gtkcolumnviewtitleprivate.h"
|
2019-10-28 00:18:14 +00:00
|
|
|
#include "gtklistbaseprivate.h"
|
2019-11-02 05:15:38 +00:00
|
|
|
#include "gtklistitemwidgetprivate.h"
|
2019-10-28 00:18:14 +00:00
|
|
|
#include "gtkmain.h"
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
#include "gtkrbtreeprivate.h"
|
2019-11-02 05:15:38 +00:00
|
|
|
#include "gtksizegroup.h"
|
2019-10-28 00:18:14 +00:00
|
|
|
#include "gtkwidgetprivate.h"
|
2019-12-04 13:13:13 +00:00
|
|
|
#include "gtksorter.h"
|
2019-10-28 00:18:14 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* GtkColumnViewColumn:
|
2019-10-28 00:18:14 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* `GtkColumnViewColumn` represents the columns being added to `GtkColumnView`.
|
|
|
|
*
|
|
|
|
* The main ingredient for a `GtkColumnViewColumn` is the `GtkListItemFactory`
|
|
|
|
* that tells the columnview how to create cells for this column from items in
|
|
|
|
* the model.
|
2020-08-03 22:41:36 +00:00
|
|
|
*
|
|
|
|
* Columns have a title, and can optionally have a header menu set
|
2021-02-28 17:55:44 +00:00
|
|
|
* with [method@Gtk.ColumnViewColumn.set_header_menu].
|
2020-08-03 22:41:36 +00:00
|
|
|
*
|
|
|
|
* A sorter can be associated with a column using
|
2021-02-28 17:55:44 +00:00
|
|
|
* [method@Gtk.ColumnViewColumn.set_sorter], to let users influence sorting
|
|
|
|
* by clicking on the column header.
|
2019-10-28 00:18:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct _GtkColumnViewColumn
|
|
|
|
{
|
|
|
|
GObject parent_instance;
|
|
|
|
|
|
|
|
GtkListItemFactory *factory;
|
|
|
|
char *title;
|
2019-12-04 13:13:13 +00:00
|
|
|
GtkSorter *sorter;
|
2019-10-28 00:18:14 +00:00
|
|
|
|
|
|
|
/* data for the view */
|
|
|
|
GtkColumnView *view;
|
2019-11-08 20:23:03 +00:00
|
|
|
GtkWidget *header;
|
2019-11-02 05:15:38 +00:00
|
|
|
|
|
|
|
int minimum_size_request;
|
|
|
|
int natural_size_request;
|
2019-11-07 22:40:47 +00:00
|
|
|
int allocation_offset;
|
|
|
|
int allocation_size;
|
2019-12-20 22:19:55 +00:00
|
|
|
int header_position;
|
2019-11-02 05:15:38 +00:00
|
|
|
|
2020-06-01 01:07:38 +00:00
|
|
|
int fixed_width;
|
|
|
|
|
2019-12-23 04:10:01 +00:00
|
|
|
guint visible : 1;
|
|
|
|
guint resizable : 1;
|
|
|
|
guint expand : 1;
|
2019-12-16 19:01:42 +00:00
|
|
|
|
2019-12-22 03:20:42 +00:00
|
|
|
GMenuModel *menu;
|
|
|
|
|
2019-11-02 05:15:38 +00:00
|
|
|
/* This list isn't sorted - this is just caching for performance */
|
|
|
|
GtkColumnViewCell *first_cell; /* no reference, just caching */
|
2019-10-28 00:18:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _GtkColumnViewColumnClass
|
|
|
|
{
|
|
|
|
GObjectClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_COLUMN_VIEW,
|
|
|
|
PROP_FACTORY,
|
|
|
|
PROP_TITLE,
|
2019-12-04 13:13:13 +00:00
|
|
|
PROP_SORTER,
|
2019-12-16 19:01:42 +00:00
|
|
|
PROP_VISIBLE,
|
2019-12-22 03:20:42 +00:00
|
|
|
PROP_HEADER_MENU,
|
2019-12-20 19:07:14 +00:00
|
|
|
PROP_RESIZABLE,
|
2019-12-23 04:10:01 +00:00
|
|
|
PROP_EXPAND,
|
2020-06-01 01:07:38 +00:00
|
|
|
PROP_FIXED_WIDTH,
|
2019-10-28 00:18:14 +00:00
|
|
|
|
|
|
|
N_PROPS
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GtkColumnViewColumn, gtk_column_view_column, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
static GParamSpec *properties[N_PROPS] = { NULL, };
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_column_view_column_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GtkColumnViewColumn *self = GTK_COLUMN_VIEW_COLUMN (object);
|
|
|
|
|
|
|
|
g_assert (self->view == NULL); /* would hold a ref otherwise */
|
2019-11-02 05:15:38 +00:00
|
|
|
g_assert (self->first_cell == NULL); /* no view = no children */
|
|
|
|
|
2019-10-28 00:18:14 +00:00
|
|
|
g_clear_object (&self->factory);
|
2019-12-04 13:13:13 +00:00
|
|
|
g_clear_object (&self->sorter);
|
2019-10-28 00:18:14 +00:00
|
|
|
g_clear_pointer (&self->title, g_free);
|
2019-12-22 03:20:42 +00:00
|
|
|
g_clear_object (&self->menu);
|
2019-10-28 00:18:14 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_column_view_column_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_column_view_column_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkColumnViewColumn *self = GTK_COLUMN_VIEW_COLUMN (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_COLUMN_VIEW:
|
|
|
|
g_value_set_object (value, self->view);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_FACTORY:
|
|
|
|
g_value_set_object (value, self->factory);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_TITLE:
|
|
|
|
g_value_set_string (value, self->title);
|
|
|
|
break;
|
|
|
|
|
2019-12-04 13:13:13 +00:00
|
|
|
case PROP_SORTER:
|
|
|
|
g_value_set_object (value, self->sorter);
|
|
|
|
break;
|
|
|
|
|
2019-12-16 19:01:42 +00:00
|
|
|
case PROP_VISIBLE:
|
|
|
|
g_value_set_boolean (value, self->visible);
|
|
|
|
break;
|
|
|
|
|
2019-12-22 03:20:42 +00:00
|
|
|
case PROP_HEADER_MENU:
|
|
|
|
g_value_set_object (value, self->menu);
|
|
|
|
break;
|
|
|
|
|
2019-12-20 19:07:14 +00:00
|
|
|
case PROP_RESIZABLE:
|
|
|
|
g_value_set_boolean (value, self->resizable);
|
|
|
|
break;
|
|
|
|
|
2019-12-23 04:10:01 +00:00
|
|
|
case PROP_EXPAND:
|
|
|
|
g_value_set_boolean (value, self->expand);
|
|
|
|
break;
|
|
|
|
|
2020-06-01 01:07:38 +00:00
|
|
|
case PROP_FIXED_WIDTH:
|
|
|
|
g_value_set_int (value, self->fixed_width);
|
|
|
|
break;
|
|
|
|
|
2019-10-28 00:18:14 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_column_view_column_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkColumnViewColumn *self = GTK_COLUMN_VIEW_COLUMN (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_FACTORY:
|
|
|
|
gtk_column_view_column_set_factory (self, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_TITLE:
|
|
|
|
gtk_column_view_column_set_title (self, g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
|
2019-12-04 13:13:13 +00:00
|
|
|
case PROP_SORTER:
|
|
|
|
gtk_column_view_column_set_sorter (self, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
|
2019-12-16 19:01:42 +00:00
|
|
|
case PROP_VISIBLE:
|
|
|
|
gtk_column_view_column_set_visible (self, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
|
2019-12-22 03:20:42 +00:00
|
|
|
case PROP_HEADER_MENU:
|
|
|
|
gtk_column_view_column_set_header_menu (self, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
|
2019-12-20 19:07:14 +00:00
|
|
|
case PROP_RESIZABLE:
|
|
|
|
gtk_column_view_column_set_resizable (self, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
|
2019-12-23 04:10:01 +00:00
|
|
|
case PROP_EXPAND:
|
|
|
|
gtk_column_view_column_set_expand (self, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
|
2020-06-01 01:07:38 +00:00
|
|
|
case PROP_FIXED_WIDTH:
|
|
|
|
gtk_column_view_column_set_fixed_width (self, g_value_get_int (value));
|
|
|
|
break;
|
|
|
|
|
2019-10-28 00:18:14 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_column_view_column_class_init (GtkColumnViewColumnClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->dispose = gtk_column_view_column_dispose;
|
|
|
|
gobject_class->get_property = gtk_column_view_column_get_property;
|
|
|
|
gobject_class->set_property = gtk_column_view_column_set_property;
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* GtkColumnViewColumn:column-view: (attributes org.gtk.Property.get=gtk_column_view_column_get_column_view)
|
2019-10-28 00:18:14 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* The `GtkColumnView` this column is a part of.
|
2019-10-28 00:18:14 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_COLUMN_VIEW] =
|
2022-05-11 12:19:39 +00:00
|
|
|
g_param_spec_object ("column-view", NULL, NULL,
|
2019-10-28 00:18:14 +00:00
|
|
|
GTK_TYPE_COLUMN_VIEW,
|
|
|
|
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* GtkColumnViewColumn:factory: (attributes org.gtk.Property.get=gtk_column_view_column_get_factory org.gtk.Property.set=gtk_column_view_column_set_factory)
|
2019-10-28 00:18:14 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* Factory for populating list items.
|
2019-10-28 00:18:14 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_FACTORY] =
|
2022-05-11 12:19:39 +00:00
|
|
|
g_param_spec_object ("factory", NULL, NULL,
|
2019-10-28 00:18:14 +00:00
|
|
|
GTK_TYPE_LIST_ITEM_FACTORY,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* GtkColumnViewColumn:title: (attributes org.gtk.Property.get=gtk_column_view_column_get_title org.gtk.Property.set=gtk_column_view_column_set_title)
|
2019-10-28 00:18:14 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* Title displayed in the header.
|
2019-10-28 00:18:14 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_TITLE] =
|
2022-05-11 12:19:39 +00:00
|
|
|
g_param_spec_string ("title", NULL, NULL,
|
2019-10-28 00:18:14 +00:00
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
2019-12-04 13:13:13 +00:00
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* GtkColumnViewColumn:sorter: (attributes org.gtk.Property.get=gtk_column_view_column_get_sorter org.gtk.Property.set=gtk_column_view_column_set_sorter)
|
2019-12-04 13:13:13 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* Sorter for sorting items according to this column.
|
2019-12-04 13:13:13 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_SORTER] =
|
2022-05-11 12:19:39 +00:00
|
|
|
g_param_spec_object ("sorter", NULL, NULL,
|
2019-12-04 13:13:13 +00:00
|
|
|
GTK_TYPE_SORTER,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2019-12-16 19:01:42 +00:00
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* GtkColumnViewColumn:visible: (attributes org.gtk.Property.get=gtk_column_view_column_get_visible org.gtk.Property.set=gtk_column_view_column_set_visible)
|
2019-12-16 19:01:42 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* Whether this column is visible.
|
2019-12-16 19:01:42 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_VISIBLE] =
|
2022-05-11 12:19:39 +00:00
|
|
|
g_param_spec_boolean ("visible", NULL, NULL,
|
2019-12-16 19:01:42 +00:00
|
|
|
TRUE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2019-12-22 03:20:42 +00:00
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* GtkColumnViewColumn:header-menu: (attributes org.gtk.Property.get=gtk_column_view_column_get_header_menu org.gtk.Property.set=gtk_column_view_column_set_header_menu)
|
2019-12-22 03:20:42 +00:00
|
|
|
*
|
|
|
|
* Menu model used to create the context menu for the column header.
|
|
|
|
*/
|
|
|
|
properties[PROP_HEADER_MENU] =
|
2022-05-11 12:19:39 +00:00
|
|
|
g_param_spec_object ("header-menu", NULL, NULL,
|
2019-12-22 03:20:42 +00:00
|
|
|
G_TYPE_MENU_MODEL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2019-12-20 19:07:14 +00:00
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* GtkColumnViewColumn:resizable: (attributes org.gtk.Property.get=gtk_column_view_column_get_resizable org.gtk.Property.set=gtk_column_view_column_set_resizable)
|
2019-12-20 19:07:14 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* Whether this column is resizable.
|
2019-12-20 19:07:14 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_RESIZABLE] =
|
2022-05-11 12:19:39 +00:00
|
|
|
g_param_spec_boolean ("resizable", NULL, NULL,
|
2019-12-20 19:07:14 +00:00
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2019-12-23 04:10:01 +00:00
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* GtkColumnViewColumn:expand: (attributes org.gtk.Property.get=gtk_column_view_column_get_expand org.gtk.Property.set=gtk_column_view_column_set_expand)
|
2019-12-23 04:10:01 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* Column gets share of extra width allocated to the view.
|
2019-12-23 04:10:01 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_EXPAND] =
|
2022-05-11 12:19:39 +00:00
|
|
|
g_param_spec_boolean ("expand", NULL, NULL,
|
2019-12-23 04:10:01 +00:00
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2020-06-01 01:07:38 +00:00
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* GtkColumnViewColumn:fixed-width: (attributes org.gtk.Property.get=gtk_column_view_column_get_fixed_width org.gtk.Property.set=gtk_column_view_column_set_fixed_width)
|
2020-06-01 01:07:38 +00:00
|
|
|
*
|
|
|
|
* If not -1, this is the width that the column is allocated,
|
|
|
|
* regardless of the size of its content.
|
|
|
|
*/
|
|
|
|
properties[PROP_FIXED_WIDTH] =
|
2022-05-11 12:19:39 +00:00
|
|
|
g_param_spec_int ("fixed-width", NULL, NULL,
|
2020-06-01 01:07:38 +00:00
|
|
|
-1, G_MAXINT, -1,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2019-10-28 00:18:14 +00:00
|
|
|
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_column_view_column_init (GtkColumnViewColumn *self)
|
|
|
|
{
|
2019-11-02 05:15:38 +00:00
|
|
|
self->minimum_size_request = -1;
|
|
|
|
self->natural_size_request = -1;
|
2019-12-16 19:01:42 +00:00
|
|
|
self->visible = TRUE;
|
2019-12-20 19:07:14 +00:00
|
|
|
self->resizable = FALSE;
|
2019-12-23 04:10:01 +00:00
|
|
|
self->expand = FALSE;
|
2020-06-01 01:07:38 +00:00
|
|
|
self->fixed_width = -1;
|
2019-10-28 00:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_column_view_column_new:
|
|
|
|
* @title: (nullable): Title to use for this column
|
2020-09-25 17:53:42 +00:00
|
|
|
* @factory: (transfer full) (nullable): The factory to populate items with
|
2019-10-28 00:18:14 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* Creates a new `GtkColumnViewColumn` that uses the given @factory for
|
2019-10-28 00:18:14 +00:00
|
|
|
* mapping items to widgets.
|
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* You most likely want to call [method@Gtk.ColumnView.append_column] next.
|
2019-10-28 00:18:14 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* The function takes ownership of the argument, so you can write code like:
|
|
|
|
*
|
|
|
|
* ```c
|
|
|
|
* column = gtk_column_view_column_new (_("Name"),
|
|
|
|
* gtk_builder_list_item_factory_new_from_resource ("/name.ui"));
|
2019-10-28 00:18:14 +00:00
|
|
|
* ```
|
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* Returns: a new `GtkColumnViewColumn` using the given @factory
|
|
|
|
*/
|
2019-10-28 00:18:14 +00:00
|
|
|
GtkColumnViewColumn *
|
2020-09-25 17:53:42 +00:00
|
|
|
gtk_column_view_column_new (const char *title,
|
|
|
|
GtkListItemFactory *factory)
|
2019-10-28 00:18:14 +00:00
|
|
|
{
|
|
|
|
GtkColumnViewColumn *result;
|
|
|
|
|
2022-02-08 14:25:28 +00:00
|
|
|
g_return_val_if_fail (factory == NULL || GTK_IS_LIST_ITEM_FACTORY (factory), NULL);
|
2019-10-28 00:18:14 +00:00
|
|
|
|
|
|
|
result = g_object_new (GTK_TYPE_COLUMN_VIEW_COLUMN,
|
|
|
|
"factory", factory,
|
|
|
|
"title", title,
|
|
|
|
NULL);
|
|
|
|
|
2020-09-25 17:53:42 +00:00
|
|
|
g_clear_object (&factory);
|
2019-10-28 00:18:14 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-11-02 05:15:38 +00:00
|
|
|
GtkColumnViewCell *
|
|
|
|
gtk_column_view_column_get_first_cell (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
return self->first_cell;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-06-01 18:45:01 +00:00
|
|
|
gtk_column_view_column_add_cell (GtkColumnViewColumn *self,
|
2019-11-02 05:15:38 +00:00
|
|
|
GtkColumnViewCell *cell)
|
|
|
|
{
|
|
|
|
self->first_cell = cell;
|
|
|
|
|
2020-06-01 18:45:01 +00:00
|
|
|
gtk_widget_set_visible (GTK_WIDGET (cell), self->visible);
|
2019-11-02 05:15:38 +00:00
|
|
|
gtk_column_view_column_queue_resize (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_column_view_column_remove_cell (GtkColumnViewColumn *self,
|
|
|
|
GtkColumnViewCell *cell)
|
|
|
|
{
|
|
|
|
if (cell == self->first_cell)
|
|
|
|
self->first_cell = gtk_column_view_cell_get_next (cell);
|
|
|
|
|
|
|
|
gtk_column_view_column_queue_resize (self);
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (cell));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_column_view_column_queue_resize (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
GtkColumnViewCell *cell;
|
|
|
|
|
|
|
|
if (self->minimum_size_request < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->minimum_size_request = -1;
|
|
|
|
self->natural_size_request = -1;
|
|
|
|
|
2019-11-08 20:23:03 +00:00
|
|
|
if (self->header)
|
|
|
|
gtk_widget_queue_resize (self->header);
|
|
|
|
|
2019-11-02 05:15:38 +00:00
|
|
|
for (cell = self->first_cell; cell; cell = gtk_column_view_cell_get_next (cell))
|
|
|
|
{
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (cell));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_column_view_column_measure (GtkColumnViewColumn *self,
|
|
|
|
int *minimum,
|
|
|
|
int *natural)
|
|
|
|
{
|
2020-06-01 01:07:38 +00:00
|
|
|
if (self->fixed_width > -1)
|
|
|
|
{
|
|
|
|
self->minimum_size_request = self->fixed_width;
|
|
|
|
self->natural_size_request = self->fixed_width;
|
|
|
|
}
|
|
|
|
|
2019-11-02 05:15:38 +00:00
|
|
|
if (self->minimum_size_request < 0)
|
|
|
|
{
|
|
|
|
GtkColumnViewCell *cell;
|
|
|
|
int min, nat, cell_min, cell_nat;
|
|
|
|
|
2019-11-08 20:23:03 +00:00
|
|
|
if (self->header)
|
|
|
|
{
|
|
|
|
gtk_widget_measure (self->header, GTK_ORIENTATION_HORIZONTAL, -1, &min, &nat, NULL, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
min = 0;
|
|
|
|
nat = 0;
|
|
|
|
}
|
2019-11-02 05:15:38 +00:00
|
|
|
|
|
|
|
for (cell = self->first_cell; cell; cell = gtk_column_view_cell_get_next (cell))
|
|
|
|
{
|
2019-11-07 22:40:47 +00:00
|
|
|
gtk_widget_measure (GTK_WIDGET (cell),
|
|
|
|
GTK_ORIENTATION_HORIZONTAL,
|
|
|
|
-1,
|
|
|
|
&cell_min, &cell_nat,
|
|
|
|
NULL, NULL);
|
2019-11-02 05:15:38 +00:00
|
|
|
|
|
|
|
min = MAX (min, cell_min);
|
|
|
|
nat = MAX (nat, cell_nat);
|
|
|
|
}
|
|
|
|
|
|
|
|
self->minimum_size_request = min;
|
|
|
|
self->natural_size_request = nat;
|
|
|
|
}
|
|
|
|
|
|
|
|
*minimum = self->minimum_size_request;
|
|
|
|
*natural = self->natural_size_request;
|
|
|
|
}
|
|
|
|
|
2019-11-07 22:40:47 +00:00
|
|
|
void
|
|
|
|
gtk_column_view_column_allocate (GtkColumnViewColumn *self,
|
|
|
|
int offset,
|
|
|
|
int size)
|
|
|
|
{
|
|
|
|
self->allocation_offset = offset;
|
|
|
|
self->allocation_size = size;
|
2019-12-20 22:19:55 +00:00
|
|
|
self->header_position = offset;
|
2019-11-07 22:40:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_column_view_column_get_allocation (GtkColumnViewColumn *self,
|
|
|
|
int *offset,
|
|
|
|
int *size)
|
|
|
|
{
|
|
|
|
if (offset)
|
|
|
|
*offset = self->allocation_offset;
|
|
|
|
if (size)
|
|
|
|
*size = self->allocation_size;
|
|
|
|
}
|
|
|
|
|
2019-11-02 05:15:38 +00:00
|
|
|
static void
|
|
|
|
gtk_column_view_column_create_cells (GtkColumnViewColumn *self)
|
|
|
|
{
|
2020-06-19 15:40:54 +00:00
|
|
|
GtkListView *list;
|
2019-11-02 05:15:38 +00:00
|
|
|
GtkWidget *row;
|
|
|
|
|
|
|
|
if (self->first_cell)
|
|
|
|
return;
|
|
|
|
|
2020-06-19 15:40:54 +00:00
|
|
|
list = gtk_column_view_get_list_view (GTK_COLUMN_VIEW (self->view));
|
|
|
|
for (row = gtk_widget_get_first_child (GTK_WIDGET (list));
|
2019-11-02 05:15:38 +00:00
|
|
|
row != NULL;
|
|
|
|
row = gtk_widget_get_next_sibling (row))
|
|
|
|
{
|
|
|
|
GtkListItemWidget *list_item;
|
|
|
|
GtkWidget *cell;
|
|
|
|
|
|
|
|
if (!gtk_widget_get_root (row))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
list_item = GTK_LIST_ITEM_WIDGET (row);
|
|
|
|
cell = gtk_column_view_cell_new (self);
|
|
|
|
gtk_list_item_widget_add_child (list_item, cell);
|
|
|
|
gtk_list_item_widget_update (GTK_LIST_ITEM_WIDGET (cell),
|
|
|
|
gtk_list_item_widget_get_position (list_item),
|
|
|
|
gtk_list_item_widget_get_item (list_item),
|
|
|
|
gtk_list_item_widget_get_selected (list_item));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_column_view_column_remove_cells (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
while (self->first_cell)
|
|
|
|
gtk_column_view_cell_remove (self->first_cell);
|
|
|
|
}
|
|
|
|
|
2019-11-08 20:23:03 +00:00
|
|
|
static void
|
|
|
|
gtk_column_view_column_create_header (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
if (self->header != NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->header = gtk_column_view_title_new (self);
|
2020-06-01 18:45:01 +00:00
|
|
|
gtk_widget_set_visible (self->header, self->visible);
|
2019-11-08 20:23:03 +00:00
|
|
|
gtk_list_item_widget_add_child (gtk_column_view_get_header_widget (self->view),
|
|
|
|
self->header);
|
|
|
|
gtk_column_view_column_queue_resize (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_column_view_column_remove_header (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
if (self->header == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_list_item_widget_remove_child (gtk_column_view_get_header_widget (self->view),
|
|
|
|
self->header);
|
|
|
|
self->header = NULL;
|
|
|
|
gtk_column_view_column_queue_resize (self);
|
|
|
|
}
|
|
|
|
|
2019-11-02 05:15:38 +00:00
|
|
|
static void
|
|
|
|
gtk_column_view_column_ensure_cells (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
if (self->view && gtk_widget_get_root (GTK_WIDGET (self->view)))
|
|
|
|
gtk_column_view_column_create_cells (self);
|
|
|
|
else
|
|
|
|
gtk_column_view_column_remove_cells (self);
|
2019-11-08 20:23:03 +00:00
|
|
|
|
|
|
|
if (self->view)
|
|
|
|
gtk_column_view_column_create_header (self);
|
|
|
|
else
|
|
|
|
gtk_column_view_column_remove_header (self);
|
2019-11-02 05:15:38 +00:00
|
|
|
}
|
|
|
|
|
2019-10-28 00:18:14 +00:00
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_get_column_view: (attributes org.gtk.Method.get_property=column-view)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2019-10-28 00:18:14 +00:00
|
|
|
*
|
|
|
|
* Gets the column view that's currently displaying this column.
|
|
|
|
*
|
|
|
|
* If @self has not been added to a column view yet, %NULL is returned.
|
|
|
|
*
|
|
|
|
* Returns: (nullable) (transfer none): The column view displaying @self.
|
2021-02-28 17:55:44 +00:00
|
|
|
*/
|
2019-10-28 00:18:14 +00:00
|
|
|
GtkColumnView *
|
|
|
|
gtk_column_view_column_get_column_view (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), NULL);
|
|
|
|
|
|
|
|
return self->view;
|
|
|
|
}
|
|
|
|
|
2019-10-28 19:50:49 +00:00
|
|
|
void
|
|
|
|
gtk_column_view_column_set_column_view (GtkColumnViewColumn *self,
|
|
|
|
GtkColumnView *view)
|
|
|
|
{
|
|
|
|
if (self->view == view)
|
|
|
|
return;
|
|
|
|
|
2019-11-08 20:23:03 +00:00
|
|
|
gtk_column_view_column_remove_cells (self);
|
|
|
|
gtk_column_view_column_remove_header (self);
|
|
|
|
|
2019-10-28 19:50:49 +00:00
|
|
|
self->view = view;
|
|
|
|
|
2019-11-08 20:23:03 +00:00
|
|
|
gtk_column_view_column_ensure_cells (self);
|
2019-11-02 05:15:38 +00:00
|
|
|
|
2019-10-28 19:50:49 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COLUMN_VIEW]);
|
|
|
|
}
|
|
|
|
|
2020-06-05 16:39:48 +00:00
|
|
|
void
|
|
|
|
gtk_column_view_column_set_position (GtkColumnViewColumn *self,
|
|
|
|
guint position)
|
|
|
|
{
|
|
|
|
GtkColumnViewCell *cell;
|
|
|
|
|
|
|
|
gtk_list_item_widget_reorder_child (gtk_column_view_get_header_widget (self->view),
|
|
|
|
self->header,
|
|
|
|
position);
|
|
|
|
|
|
|
|
for (cell = self->first_cell; cell; cell = gtk_column_view_cell_get_next (cell))
|
|
|
|
{
|
|
|
|
GtkListItemWidget *list_item;
|
|
|
|
|
|
|
|
list_item = GTK_LIST_ITEM_WIDGET (gtk_widget_get_parent (GTK_WIDGET (cell)));
|
|
|
|
gtk_list_item_widget_reorder_child (list_item, GTK_WIDGET (cell), position);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-28 00:18:14 +00:00
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_get_factory: (attributes org.gtk.Method.get_property=factory)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2019-10-28 00:18:14 +00:00
|
|
|
*
|
|
|
|
* Gets the factory that's currently used to populate list items for
|
|
|
|
* this column.
|
|
|
|
*
|
|
|
|
* Returns: (nullable) (transfer none): The factory in use
|
|
|
|
**/
|
|
|
|
GtkListItemFactory *
|
|
|
|
gtk_column_view_column_get_factory (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), NULL);
|
|
|
|
|
|
|
|
return self->factory;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_set_factory: (attributes org.gtk.Method.set_property=factory)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2021-05-21 00:45:06 +00:00
|
|
|
* @factory: (nullable) (transfer none): the factory to use
|
2019-10-28 00:18:14 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* Sets the `GtkListItemFactory` to use for populating list items for this
|
2019-10-28 00:18:14 +00:00
|
|
|
* column.
|
2021-02-28 17:55:44 +00:00
|
|
|
*/
|
2019-10-28 00:18:14 +00:00
|
|
|
void
|
|
|
|
gtk_column_view_column_set_factory (GtkColumnViewColumn *self,
|
|
|
|
GtkListItemFactory *factory)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
|
|
|
|
g_return_if_fail (factory == NULL || GTK_LIST_ITEM_FACTORY (factory));
|
|
|
|
|
|
|
|
if (!g_set_object (&self->factory, factory))
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FACTORY]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_set_title: (attributes org.gtk.Method.set_property=title)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2019-10-28 00:18:14 +00:00
|
|
|
* @title: (nullable): Title to use for this column
|
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* Sets the title of this column.
|
|
|
|
*
|
|
|
|
* The title is displayed in the header of a `GtkColumnView`
|
|
|
|
* for this column and is therefore user-facing text that should
|
2019-10-28 00:18:14 +00:00
|
|
|
* be translated.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_column_view_column_set_title (GtkColumnViewColumn *self,
|
|
|
|
const char *title)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
|
|
|
|
|
|
|
|
if (g_strcmp0 (self->title, title) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_free (self->title);
|
|
|
|
self->title = g_strdup (title);
|
|
|
|
|
2019-11-08 20:23:03 +00:00
|
|
|
if (self->header)
|
|
|
|
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
|
|
|
|
|
2019-10-28 00:18:14 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_get_title: (attributes org.gtk.Method.get_property=title)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2019-10-28 00:18:14 +00:00
|
|
|
*
|
|
|
|
* Returns the title set with gtk_column_view_column_set_title().
|
|
|
|
*
|
2020-05-31 14:05:59 +00:00
|
|
|
* Returns: (nullable): The column's title
|
2019-10-28 00:18:14 +00:00
|
|
|
*/
|
|
|
|
const char *
|
|
|
|
gtk_column_view_column_get_title (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), FALSE);
|
|
|
|
|
|
|
|
return self->title;
|
|
|
|
}
|
2019-11-02 05:15:38 +00:00
|
|
|
|
2019-12-04 13:13:13 +00:00
|
|
|
static void
|
|
|
|
gtk_column_view_column_remove_from_sorter (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
if (self->view == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_column_view_sorter_remove_column (GTK_COLUMN_VIEW_SORTER (gtk_column_view_get_sorter (self->view)), self);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_set_sorter: (attributes org.gtk.Method.set_property=sorter)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
|
|
|
* @sorter: (nullable): the `GtkSorter` to associate with @column
|
2019-12-04 13:13:13 +00:00
|
|
|
*
|
|
|
|
* Associates a sorter with the column.
|
|
|
|
*
|
2020-12-01 04:40:03 +00:00
|
|
|
* If @sorter is %NULL, the column will not let users change
|
|
|
|
* the sorting by clicking on its header.
|
|
|
|
*
|
2019-12-04 13:13:13 +00:00
|
|
|
* This sorter can be made active by clicking on the column
|
2021-02-28 17:55:44 +00:00
|
|
|
* header, or by calling [method@Gtk.ColumnView.sort_by_column].
|
2020-08-03 22:41:36 +00:00
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* See [method@Gtk.ColumnView.get_sorter] for the necessary steps
|
|
|
|
* for setting up customizable sorting for [class@Gtk.ColumnView].
|
2019-12-04 13:13:13 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_column_view_column_set_sorter (GtkColumnViewColumn *self,
|
|
|
|
GtkSorter *sorter)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
|
|
|
|
g_return_if_fail (sorter == NULL || GTK_IS_SORTER (sorter));
|
|
|
|
|
|
|
|
if (!g_set_object (&self->sorter, sorter))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_column_view_column_remove_from_sorter (self);
|
|
|
|
|
|
|
|
if (self->header)
|
|
|
|
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SORTER]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_get_sorter: (attributes org.gtk.Method.get_property=sorter)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2019-12-04 13:13:13 +00:00
|
|
|
*
|
|
|
|
* Returns the sorter that is associated with the column.
|
|
|
|
*
|
2021-02-28 17:55:44 +00:00
|
|
|
* Returns: (nullable) (transfer none): the `GtkSorter` of @self
|
2019-12-04 13:13:13 +00:00
|
|
|
*/
|
|
|
|
GtkSorter *
|
|
|
|
gtk_column_view_column_get_sorter (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), NULL);
|
|
|
|
|
|
|
|
return self->sorter;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_column_view_column_notify_sort (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
if (self->header)
|
|
|
|
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
|
|
|
|
}
|
2019-12-16 19:01:42 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_set_visible: (attributes org.gtk.Method.set_property=visible)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2019-12-16 19:01:42 +00:00
|
|
|
* @visible: whether this column should be visible
|
|
|
|
*
|
|
|
|
* Sets whether this column should be visible in views.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_column_view_column_set_visible (GtkColumnViewColumn *self,
|
|
|
|
gboolean visible)
|
|
|
|
{
|
|
|
|
GtkColumnViewCell *cell;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
|
|
|
|
|
|
|
|
if (self->visible == visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->visible = visible;
|
|
|
|
|
|
|
|
self->minimum_size_request = -1;
|
|
|
|
self->natural_size_request = -1;
|
|
|
|
|
|
|
|
if (self->header)
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->header), visible);
|
|
|
|
|
|
|
|
for (cell = self->first_cell; cell; cell = gtk_column_view_cell_get_next (cell))
|
|
|
|
{
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (cell), visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VISIBLE]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_get_visible: (attributes org.gtk.Method.get_property=visible)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2019-12-16 19:01:42 +00:00
|
|
|
*
|
|
|
|
* Returns whether this column is visible.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if this column is visible
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gtk_column_view_column_get_visible (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), TRUE);
|
|
|
|
|
|
|
|
return self->visible;
|
|
|
|
}
|
2019-12-22 03:20:42 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_set_header_menu: (attributes org.gtk.Method.set_property=header-menu)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2021-05-21 00:45:06 +00:00
|
|
|
* @menu: (nullable): a `GMenuModel`
|
2019-12-22 03:20:42 +00:00
|
|
|
*
|
|
|
|
* Sets the menu model that is used to create the context menu
|
|
|
|
* for the column header.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_column_view_column_set_header_menu (GtkColumnViewColumn *self,
|
|
|
|
GMenuModel *menu)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
|
|
|
|
g_return_if_fail (menu == NULL || G_IS_MENU_MODEL (menu));
|
|
|
|
|
|
|
|
if (!g_set_object (&self->menu, menu))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (self->header)
|
|
|
|
gtk_column_view_title_update (GTK_COLUMN_VIEW_TITLE (self->header));
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HEADER_MENU]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_get_header_menu: (attributes org.gtk.Method.get_property=header-menu)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2019-12-22 03:20:42 +00:00
|
|
|
*
|
|
|
|
* Gets the menu model that is used to create the context menu
|
|
|
|
* for the column header.
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
* Returns: (transfer none) (nullable): the `GMenuModel`
|
2019-12-22 03:20:42 +00:00
|
|
|
*/
|
|
|
|
GMenuModel *
|
|
|
|
gtk_column_view_column_get_header_menu (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), NULL);
|
|
|
|
|
|
|
|
return self->menu;
|
|
|
|
}
|
2020-06-01 01:07:38 +00:00
|
|
|
|
2019-12-23 04:10:01 +00:00
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_set_expand: (attributes org.gtk.Method.set_property=expand)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2019-12-23 04:10:01 +00:00
|
|
|
* @expand: %TRUE if this column should expand to fill available sace
|
|
|
|
*
|
|
|
|
* Sets the column to take available extra space.
|
|
|
|
*
|
|
|
|
* The extra space is shared equally amongst all columns that
|
|
|
|
* have the expand set to %TRUE.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_column_view_column_set_expand (GtkColumnViewColumn *self,
|
|
|
|
gboolean expand)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
|
|
|
|
|
|
|
|
if (self->expand == expand)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->expand = expand;
|
|
|
|
|
|
|
|
if (self->visible && self->view)
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self->view));
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_EXPAND]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_get_expand: (attributes org.gtk.Method.get_property=expand)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2019-12-23 04:10:01 +00:00
|
|
|
*
|
|
|
|
* Returns whether this column should expand.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if this column expands
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gtk_column_view_column_get_expand (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), TRUE);
|
|
|
|
|
|
|
|
return self->expand;
|
|
|
|
}
|
|
|
|
|
2019-12-20 19:07:14 +00:00
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_set_resizable: (attributes org.gtk.Method.set_property=resizable)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2020-06-06 01:36:27 +00:00
|
|
|
* @resizable: whether this column should be resizable
|
2019-12-20 19:07:14 +00:00
|
|
|
*
|
|
|
|
* Sets whether this column should be resizable by dragging.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_column_view_column_set_resizable (GtkColumnViewColumn *self,
|
|
|
|
gboolean resizable)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
|
|
|
|
|
|
|
|
if (self->resizable == resizable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->resizable = resizable;
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RESIZABLE]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_get_resizable: (attributes org.gtk.Method.get_property=resizable)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2019-12-20 19:07:14 +00:00
|
|
|
*
|
|
|
|
* Returns whether this column is resizable.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if this column is resizable
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gtk_column_view_column_get_resizable (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), TRUE);
|
|
|
|
|
|
|
|
return self->resizable;
|
|
|
|
}
|
|
|
|
|
2020-06-01 01:07:38 +00:00
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_set_fixed_width: (attributes org.gtk.Method.set_property=fixed-width)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2020-06-01 01:07:38 +00:00
|
|
|
* @fixed_width: the new fixed width, or -1
|
|
|
|
*
|
|
|
|
* If @fixed_width is not -1, sets the fixed width of @column;
|
|
|
|
* otherwise unsets it.
|
|
|
|
*
|
|
|
|
* Setting a fixed width overrides the automatically calculated
|
|
|
|
* width. Interactive resizing also sets the “fixed-width” property.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_column_view_column_set_fixed_width (GtkColumnViewColumn *self,
|
|
|
|
int fixed_width)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
|
|
|
|
g_return_if_fail (fixed_width >= -1);
|
|
|
|
|
|
|
|
if (self->fixed_width == fixed_width)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->fixed_width = fixed_width;
|
|
|
|
|
|
|
|
gtk_column_view_column_queue_resize (self);
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FIXED_WIDTH]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 17:55:44 +00:00
|
|
|
* gtk_column_view_column_get_fixed_width: (attributes org.gtk.Method.get_property=fixed-width)
|
|
|
|
* @self: a `GtkColumnViewColumn`
|
2020-06-01 01:07:38 +00:00
|
|
|
*
|
|
|
|
* Gets the fixed width of the column.
|
|
|
|
*
|
|
|
|
* Returns: the fixed with of the column
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
gtk_column_view_column_get_fixed_width (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self), -1);
|
|
|
|
|
|
|
|
return self->fixed_width;
|
|
|
|
}
|
2019-12-21 04:01:55 +00:00
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gtk_column_view_column_get_header (GtkColumnViewColumn *self)
|
|
|
|
{
|
|
|
|
return self->header;
|
|
|
|
}
|
2019-12-20 22:19:55 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
gtk_column_view_column_set_header_position (GtkColumnViewColumn *self,
|
|
|
|
int offset)
|
|
|
|
{
|
|
|
|
self->header_position = offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_column_view_column_get_header_allocation (GtkColumnViewColumn *self,
|
|
|
|
int *offset,
|
|
|
|
int *size)
|
|
|
|
{
|
|
|
|
if (offset)
|
|
|
|
*offset = self->header_position;
|
|
|
|
|
|
|
|
if (size)
|
|
|
|
*size = self->allocation_size;
|
|
|
|
}
|