Added `visible'.

1998-10-01  Martin Baulig  <martin@home-of-linux.org>

	* gtk/gtkclist.h (GtkCListColumn): Added `visible'.

	* gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
	Makes it possible to individually show and hide columns.
	(size_allocate_columns): Adapted to keep track of hidden columns.
	(size_allocate_title_buttons): Likewise.
This commit is contained in:
Martin Baulig 1998-10-04 10:52:52 +00:00 committed by Martin Baulig
parent c62ab96bcc
commit a9c05acd70
9 changed files with 115 additions and 7 deletions

View File

@ -1,3 +1,12 @@
1998-10-01 Martin Baulig <martin@home-of-linux.org>
* gtk/gtkclist.h (GtkCListColumn): Added `visible'.
* gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
Makes it possible to individually show and hide columns.
(size_allocate_columns): Adapted to keep track of hidden columns.
(size_allocate_title_buttons): Likewise.
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org> Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign

View File

@ -1,3 +1,12 @@
1998-10-01 Martin Baulig <martin@home-of-linux.org>
* gtk/gtkclist.h (GtkCListColumn): Added `visible'.
* gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
Makes it possible to individually show and hide columns.
(size_allocate_columns): Adapted to keep track of hidden columns.
(size_allocate_title_buttons): Likewise.
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org> Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign

View File

@ -1,3 +1,12 @@
1998-10-01 Martin Baulig <martin@home-of-linux.org>
* gtk/gtkclist.h (GtkCListColumn): Added `visible'.
* gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
Makes it possible to individually show and hide columns.
(size_allocate_columns): Adapted to keep track of hidden columns.
(size_allocate_title_buttons): Likewise.
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org> Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign

View File

@ -1,3 +1,12 @@
1998-10-01 Martin Baulig <martin@home-of-linux.org>
* gtk/gtkclist.h (GtkCListColumn): Added `visible'.
* gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
Makes it possible to individually show and hide columns.
(size_allocate_columns): Adapted to keep track of hidden columns.
(size_allocate_title_buttons): Likewise.
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org> Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign

View File

@ -1,3 +1,12 @@
1998-10-01 Martin Baulig <martin@home-of-linux.org>
* gtk/gtkclist.h (GtkCListColumn): Added `visible'.
* gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
Makes it possible to individually show and hide columns.
(size_allocate_columns): Adapted to keep track of hidden columns.
(size_allocate_title_buttons): Likewise.
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org> Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign

View File

@ -1,3 +1,12 @@
1998-10-01 Martin Baulig <martin@home-of-linux.org>
* gtk/gtkclist.h (GtkCListColumn): Added `visible'.
* gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
Makes it possible to individually show and hide columns.
(size_allocate_columns): Adapted to keep track of hidden columns.
(size_allocate_title_buttons): Likewise.
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org> Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign

View File

@ -1,3 +1,12 @@
1998-10-01 Martin Baulig <martin@home-of-linux.org>
* gtk/gtkclist.h (GtkCListColumn): Added `visible'.
* gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
Makes it possible to individually show and hide columns.
(size_allocate_columns): Adapted to keep track of hidden columns.
(size_allocate_title_buttons): Likewise.
Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org> Sat Oct 3 17:54:48 1998 Tim Janik <timj@gtk.org>
* gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign

View File

@ -1009,6 +1009,23 @@ gtk_clist_column_titles_hide (GtkCList * clist)
} }
} }
void
gtk_clist_set_column_visibility (GtkCList * clist, gint column, gint visible)
{
g_return_if_fail (clist != NULL);
g_return_if_fail (GTK_IS_CLIST (clist));
if (column < 0 || column >= clist->columns)
return;
if (clist->column[column].visible && !visible)
gtk_widget_hide (clist->column[column].button);
else if (!clist->column[column].visible && visible)
gtk_widget_show (clist->column[column].button);
clist->column[column].visible = visible ? TRUE : FALSE;
}
void void
gtk_clist_column_title_active (GtkCList * clist, gtk_clist_column_title_active (GtkCList * clist,
gint column) gint column)
@ -2653,6 +2670,8 @@ gtk_clist_draw (GtkWidget * widget,
for (i = 0; i < clist->columns; i++) for (i = 0; i < clist->columns; i++)
{ {
if (!clist->column[i].visible)
continue;
if (gtk_widget_intersect (clist->column[i].button, area, &child_area)) if (gtk_widget_intersect (clist->column[i].button, area, &child_area))
gtk_widget_draw (clist->column[i].button, &child_area); gtk_widget_draw (clist->column[i].button, &child_area);
} }
@ -3913,6 +3932,7 @@ size_allocate_title_buttons (GtkCList * clist)
{ {
gint i, last_button = 0; gint i, last_button = 0;
GtkAllocation button_allocation; GtkAllocation button_allocation;
gint visible_columns = clist->columns;
if (!GTK_WIDGET_REALIZED (clist)) if (!GTK_WIDGET_REALIZED (clist))
return; return;
@ -3922,16 +3942,22 @@ size_allocate_title_buttons (GtkCList * clist)
button_allocation.width = 0; button_allocation.width = 0;
button_allocation.height = clist->column_title_area.height; button_allocation.height = clist->column_title_area.height;
for (i = 0; i < clist->columns; i++) for (i = clist->columns-1; i > 0; i--)
if (!clist->column[i].visible)
visible_columns = i;
else
break;
for (i = 0; i < visible_columns; i++)
{ {
button_allocation.width += clist->column[i].area.width; button_allocation.width += clist->column[i].area.width;
if (i == clist->columns - 1) if (i == visible_columns - 1)
button_allocation.width += 2 * (CELL_SPACING + COLUMN_INSET); button_allocation.width += 2 * (CELL_SPACING + COLUMN_INSET);
else else if (clist->column[i].visible)
button_allocation.width += CELL_SPACING + (2 * COLUMN_INSET); button_allocation.width += CELL_SPACING + (2 * COLUMN_INSET);
if (i == (clist->columns - 1) || clist->column[i + 1].button) if (i == (visible_columns - 1) || clist->column[i + 1].button)
{ {
gtk_widget_size_allocate (clist->column[last_button].button, &button_allocation); gtk_widget_size_allocate (clist->column[last_button].button, &button_allocation);
button_allocation.x += button_allocation.width; button_allocation.x += button_allocation.width;
@ -3955,12 +3981,19 @@ static void
size_allocate_columns (GtkCList * clist) size_allocate_columns (GtkCList * clist)
{ {
gint i, xoffset = 0; gint i, xoffset = 0;
gint visible_columns = clist->columns;
for (i = 0; i < clist->columns; i++) for (i = visible_columns-1; i > 0; i--)
if (!clist->column[i].visible)
visible_columns = i;
else
break;
for (i = 0; i < visible_columns; i++)
{ {
clist->column[i].area.x = xoffset + CELL_SPACING + COLUMN_INSET; clist->column[i].area.x = xoffset + CELL_SPACING + COLUMN_INSET;
if (i == clist->columns - 1) if (i == visible_columns - 1)
{ {
gint width; gint width;
@ -3987,8 +4020,13 @@ size_allocate_columns (GtkCList * clist)
clist->column[i].area.width = clist->column[i].width; clist->column[i].area.width = clist->column[i].width;
} }
xoffset += clist->column[i].area.width + CELL_SPACING + (2 * COLUMN_INSET); if (clist->column[i].visible)
xoffset += clist->column[i].area.width +
CELL_SPACING + (2 * COLUMN_INSET);
} }
for (i = visible_columns; i < clist->columns; i++)
clist->column[i].area.width = 0;
} }
/* /*
@ -4749,6 +4787,7 @@ columns_new (GtkCList * clist)
column[i].button = NULL; column[i].button = NULL;
column[i].window = NULL; column[i].window = NULL;
column[i].width = 0; column[i].width = 0;
column[i].visible = 1;
column[i].width_set = FALSE; column[i].width_set = FALSE;
column[i].justification = GTK_JUSTIFY_LEFT; column[i].justification = GTK_JUSTIFY_LEFT;
} }

View File

@ -261,6 +261,7 @@ struct _GtkCListColumn
gint width; gint width;
GtkJustification justification; GtkJustification justification;
gint visible : 1;
gint width_set : 1; gint width_set : 1;
}; };
@ -401,6 +402,11 @@ void gtk_clist_column_title_passive (GtkCList *clist,
void gtk_clist_column_titles_active (GtkCList *clist); void gtk_clist_column_titles_active (GtkCList *clist);
void gtk_clist_column_titles_passive (GtkCList *clist); void gtk_clist_column_titles_passive (GtkCList *clist);
/* set visibility of a column */
void gtk_clist_set_column_visibility (GtkCList *clist,
gint column,
gint visible);
/* set the title in the column title button */ /* set the title in the column title button */
void gtk_clist_set_column_title (GtkCList *clist, void gtk_clist_set_column_title (GtkCList *clist,
gint column, gint column,