Commit 005f39e0 authored by Jay Painter's avatar Jay Painter

moved widget creation to gtk_clist_construct for the gtk-- folks.

parent 75fbe1ad
......@@ -415,20 +415,62 @@ gtk_clist_init (GtkCList * clist)
clist->selection = NULL;
}
/* Constructors */
void
gtk_clist_construct (GtkCList * clist,
gint columns,
gchar *titles[])
{
int i;
/* initalize memory chunks */
clist->row_mem_chunk = g_mem_chunk_new ("clist row mem chunk",
sizeof (GtkCListRow),
sizeof (GtkCListRow) * CLIST_OPTIMUM_SIZE,
G_ALLOC_AND_FREE);
clist->cell_mem_chunk = g_mem_chunk_new ("clist cell mem chunk",
sizeof (GtkCell) * columns,
sizeof (GtkCell) * columns * CLIST_OPTIMUM_SIZE,
G_ALLOC_AND_FREE);
/* set number of columns, allocate memory */
clist->columns = columns;
clist->column = columns_new (clist);
/* there needs to be at least one column button
* because there is alot of code that will break if it
* isn't there*/
column_button_create (clist, 0);
/* create scrollbars */
create_scrollbars (clist);
if (titles)
{
GTK_CLIST_SET_FLAGS (clist, CLIST_SHOW_TITLES);
for (i = 0; i < columns; i++)
gtk_clist_set_column_title (clist, i, titles[i]);
}
else
{
GTK_CLIST_UNSET_FLAGS (clist, CLIST_SHOW_TITLES);
}
}
/*
* GTKCLIST PUBLIC INTERFACE
* gtk_clist_new_with_titles
* gtk_clist_new
*/
GtkWidget *
gtk_clist_new_with_titles (int columns,
gtk_clist_new_with_titles (gint columns,
gchar * titles[])
{
int i;
GtkWidget *widget;
GtkCList *clist;
GtkWidget *widget;
if (titles == NULL)
if (titles == NULL)
return NULL;
widget = gtk_clist_new (columns);
......@@ -437,51 +479,20 @@ gtk_clist_new_with_titles (int columns,
else
clist = GTK_CLIST (widget);
/* set column titles */
GTK_CLIST_SET_FLAGS (clist, CLIST_SHOW_TITLES);
for (i = 0; i < columns; i++)
{
gtk_clist_set_column_title (clist, i, titles[i]);
}
gtk_clist_construct (clist, columns, titles);
return widget;
}
GtkWidget *
gtk_clist_new (int columns)
gtk_clist_new (gint columns)
{
GtkCList *clist;
/* sanity check */
if (columns < 1)
return NULL;
clist = gtk_type_new (gtk_clist_get_type ());
GTK_CLIST_UNSET_FLAGS (clist, CLIST_SHOW_TITLES);
/* initalize memory chunks */
clist->row_mem_chunk = g_mem_chunk_new ("clist row mem chunk",
sizeof (GtkCListRow),
sizeof (GtkCListRow) * CLIST_OPTIMUM_SIZE,
G_ALLOC_AND_FREE);
clist->cell_mem_chunk = g_mem_chunk_new ("clist cell mem chunk",
sizeof (GtkCell) * columns,
sizeof (GtkCell) * columns * CLIST_OPTIMUM_SIZE,
G_ALLOC_AND_FREE);
/* set number of columns, allocate memory */
clist->columns = columns;
clist->column = columns_new (clist);
/* there needs to be at least one column button
* because there is alot of code that will break if it
* isn't there*/
column_button_create (clist, 0);
/* create scrollbars */
create_scrollbars (clist);
gtk_clist_construct (clist, columns, NULL);
return GTK_WIDGET (clist);
}
......
......@@ -268,9 +268,14 @@ struct _GtkCell
guint gtk_clist_get_type (void);
/* constructers useful for gtk-- wrappers */
void gtk_clist_construct (GtkCList * clist,
gint columns,
gchar * titles[]);
/* create a new GtkCList */
GtkWidget *gtk_clist_new (int columns);
GtkWidget *gtk_clist_new_with_titles (int columns,
GtkWidget *gtk_clist_new (gint columns);
GtkWidget *gtk_clist_new_with_titles (gint columns,
gchar * titles[]);
/* set the border style of the clist */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment