mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 06:10:15 +00:00
changed clist->selection GList so its data elements are casted row indexes instead
of pointers. I also cleaned up a few bugs with GTK_SELECTION_MULTIPLE mode, and some signal synronization problems with removing selected rows.
This commit is contained in:
parent
e60864761c
commit
85f1364922
@ -1,3 +1,12 @@
|
||||
Sun Mar 8 12:33:38 PST 1998 Jay Painter <jpaint@serv.net>
|
||||
|
||||
* gtk/gtkclist.c: the GList clist->selection now contains row indexes
|
||||
in the data portion of the linked list structure instead of pointers,
|
||||
fixed several bugs with the different selection modes
|
||||
|
||||
* gtk/testgtk.c: displays information for unselect events, and prints the list
|
||||
of selected rows
|
||||
|
||||
Sun Mar 8 13:03:22 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkrange.h: removed gtk_range_calc_value().
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Mar 8 12:33:38 PST 1998 Jay Painter <jpaint@serv.net>
|
||||
|
||||
* gtk/gtkclist.c: the GList clist->selection now contains row indexes
|
||||
in the data portion of the linked list structure instead of pointers,
|
||||
fixed several bugs with the different selection modes
|
||||
|
||||
* gtk/testgtk.c: displays information for unselect events, and prints the list
|
||||
of selected rows
|
||||
|
||||
Sun Mar 8 13:03:22 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkrange.h: removed gtk_range_calc_value().
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Mar 8 12:33:38 PST 1998 Jay Painter <jpaint@serv.net>
|
||||
|
||||
* gtk/gtkclist.c: the GList clist->selection now contains row indexes
|
||||
in the data portion of the linked list structure instead of pointers,
|
||||
fixed several bugs with the different selection modes
|
||||
|
||||
* gtk/testgtk.c: displays information for unselect events, and prints the list
|
||||
of selected rows
|
||||
|
||||
Sun Mar 8 13:03:22 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkrange.h: removed gtk_range_calc_value().
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Mar 8 12:33:38 PST 1998 Jay Painter <jpaint@serv.net>
|
||||
|
||||
* gtk/gtkclist.c: the GList clist->selection now contains row indexes
|
||||
in the data portion of the linked list structure instead of pointers,
|
||||
fixed several bugs with the different selection modes
|
||||
|
||||
* gtk/testgtk.c: displays information for unselect events, and prints the list
|
||||
of selected rows
|
||||
|
||||
Sun Mar 8 13:03:22 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkrange.h: removed gtk_range_calc_value().
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Mar 8 12:33:38 PST 1998 Jay Painter <jpaint@serv.net>
|
||||
|
||||
* gtk/gtkclist.c: the GList clist->selection now contains row indexes
|
||||
in the data portion of the linked list structure instead of pointers,
|
||||
fixed several bugs with the different selection modes
|
||||
|
||||
* gtk/testgtk.c: displays information for unselect events, and prints the list
|
||||
of selected rows
|
||||
|
||||
Sun Mar 8 13:03:22 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkrange.h: removed gtk_range_calc_value().
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Mar 8 12:33:38 PST 1998 Jay Painter <jpaint@serv.net>
|
||||
|
||||
* gtk/gtkclist.c: the GList clist->selection now contains row indexes
|
||||
in the data portion of the linked list structure instead of pointers,
|
||||
fixed several bugs with the different selection modes
|
||||
|
||||
* gtk/testgtk.c: displays information for unselect events, and prints the list
|
||||
of selected rows
|
||||
|
||||
Sun Mar 8 13:03:22 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkrange.h: removed gtk_range_calc_value().
|
||||
|
@ -1,3 +1,12 @@
|
||||
Sun Mar 8 12:33:38 PST 1998 Jay Painter <jpaint@serv.net>
|
||||
|
||||
* gtk/gtkclist.c: the GList clist->selection now contains row indexes
|
||||
in the data portion of the linked list structure instead of pointers,
|
||||
fixed several bugs with the different selection modes
|
||||
|
||||
* gtk/testgtk.c: displays information for unselect events, and prints the list
|
||||
of selected rows
|
||||
|
||||
Sun Mar 8 13:03:22 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkrange.h: removed gtk_range_calc_value().
|
||||
|
174
gtk/gtkclist.c
174
gtk/gtkclist.c
@ -102,6 +102,13 @@ enum
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
SYNC_REMOVE,
|
||||
SYNC_INSERT
|
||||
};
|
||||
|
||||
|
||||
typedef void (*GtkCListSignal1) (GtkObject * object,
|
||||
gint arg1,
|
||||
gint arg2,
|
||||
@ -113,6 +120,10 @@ typedef void (*GtkCListSignal2) (GtkObject * object,
|
||||
gpointer data);
|
||||
|
||||
|
||||
static void sync_selection (GtkCList * clist,
|
||||
gint row,
|
||||
gint mode);
|
||||
|
||||
/* GtkCList Methods */
|
||||
static void gtk_clist_class_init (GtkCListClass * klass);
|
||||
static void gtk_clist_init (GtkCList * clist);
|
||||
@ -1267,6 +1278,9 @@ gtk_clist_insert (GtkCList * clist,
|
||||
clist->row_list = g_list_insert (clist->row_list, clist_row, row);
|
||||
|
||||
clist->rows++;
|
||||
|
||||
/* syncronize the selection list */
|
||||
sync_selection (clist, row, SYNC_INSERT);
|
||||
}
|
||||
|
||||
/* redraw the list if it isn't frozen */
|
||||
@ -1283,7 +1297,7 @@ void
|
||||
gtk_clist_remove (GtkCList * clist,
|
||||
gint row)
|
||||
{
|
||||
gint was_visible;
|
||||
gint was_visible, was_selected;
|
||||
GList *list;
|
||||
GtkCListRow *clist_row;
|
||||
|
||||
@ -1294,11 +1308,33 @@ gtk_clist_remove (GtkCList * clist,
|
||||
return;
|
||||
|
||||
was_visible = gtk_clist_row_is_visible (clist, row);
|
||||
was_selected = 0;
|
||||
|
||||
/* get the row we're going to delete */
|
||||
list = g_list_nth (clist->row_list, row);
|
||||
clist_row = list->data;
|
||||
|
||||
/* if we're removing a selected row, we have to make sure
|
||||
* it's properly unselected, and then sync up the clist->selected
|
||||
* list to reflect the deincrimented indexies of rows after the
|
||||
* removal */
|
||||
if (clist_row->state == GTK_STATE_SELECTED)
|
||||
{
|
||||
was_selected = 1;
|
||||
|
||||
switch (clist->selection_mode)
|
||||
{
|
||||
case GTK_SELECTION_SINGLE:
|
||||
case GTK_SELECTION_BROWSE:
|
||||
case GTK_SELECTION_MULTIPLE:
|
||||
gtk_clist_unselect_row (clist, row, -1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* reset the row end pointer if we're removing at the
|
||||
* end of the list */
|
||||
if (row == clist->rows - 1)
|
||||
@ -1306,6 +1342,27 @@ gtk_clist_remove (GtkCList * clist,
|
||||
|
||||
clist->row_list = g_list_remove (clist->row_list, clist_row);
|
||||
clist->rows--;
|
||||
sync_selection (clist, row, SYNC_REMOVE);
|
||||
|
||||
/* preform any selections required by the selection mode */
|
||||
if (was_selected)
|
||||
{
|
||||
switch (clist->selection_mode)
|
||||
{
|
||||
case GTK_SELECTION_BROWSE:
|
||||
if (row == clist->rows)
|
||||
gtk_clist_select_row (clist, row - 1, -1);
|
||||
else
|
||||
gtk_clist_select_row (clist, row, -1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* toast the row */
|
||||
row_delete (clist, clist_row);
|
||||
|
||||
/* redraw the row if it isn't frozen */
|
||||
if (!GTK_CLIST_FROZEN (clist))
|
||||
@ -1315,26 +1372,35 @@ gtk_clist_remove (GtkCList * clist,
|
||||
if (was_visible)
|
||||
draw_rows (clist, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (clist_row->state == GTK_STATE_SELECTED)
|
||||
static void
|
||||
sync_selection (GtkCList * clist,
|
||||
gint row,
|
||||
gint mode)
|
||||
{
|
||||
switch (clist->selection_mode)
|
||||
GList *list;
|
||||
|
||||
list = clist->selection;
|
||||
while (list)
|
||||
{
|
||||
case GTK_SELECTION_BROWSE:
|
||||
if (row >= clist->rows)
|
||||
row--;
|
||||
gtk_clist_select_row (clist, row, -1);
|
||||
if ((gint) list->data >= row)
|
||||
switch (mode)
|
||||
{
|
||||
case SYNC_INSERT:
|
||||
(gint) list->data = (gint) list->data + 1;
|
||||
break;
|
||||
|
||||
case SYNC_REMOVE:
|
||||
(gint) list->data = (gint) list->data - 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* remove from selection list */
|
||||
clist->selection = g_list_remove (clist->selection, clist_row);
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
row_delete (clist, clist_row);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1402,11 +1468,9 @@ gtk_clist_set_row_data_full (GtkCList * clist,
|
||||
clist_row->data = data;
|
||||
clist_row->destroy = destroy;
|
||||
|
||||
/*
|
||||
* re-send the selected signal if data is changed/added
|
||||
/* re-send the selected signal if data is changed/added
|
||||
* so the application can respond to the new data --
|
||||
* this could be questionable behavior
|
||||
*/
|
||||
* this could be questionable behavior */
|
||||
if (clist_row->state == GTK_STATE_SELECTED)
|
||||
gtk_clist_select_row (clist, 0, 0);
|
||||
}
|
||||
@ -2782,77 +2846,67 @@ toggle_row (GtkCList * clist,
|
||||
{
|
||||
gint i;
|
||||
GList *list;
|
||||
GtkCListRow *clist_row;
|
||||
GtkCListRow *clist_row, *selected_row;
|
||||
|
||||
i = 0;
|
||||
list = clist->row_list;
|
||||
selected_row = NULL;
|
||||
|
||||
switch (clist->selection_mode)
|
||||
{
|
||||
case GTK_SELECTION_SINGLE:
|
||||
i = 0;
|
||||
list = clist->row_list;
|
||||
while (list)
|
||||
{
|
||||
clist_row = list->data;
|
||||
list = list->next;
|
||||
|
||||
if (row == i)
|
||||
{
|
||||
if (clist_row->state == GTK_STATE_SELECTED)
|
||||
selected_row = clist_row;
|
||||
else if (clist_row->state == GTK_STATE_SELECTED)
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
|
||||
i, column, event);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (selected_row && selected_row->state == GTK_STATE_SELECTED)
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
|
||||
row, column, event);
|
||||
else
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
|
||||
row, column, event);
|
||||
}
|
||||
else if (clist_row->state == GTK_STATE_SELECTED)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
|
||||
i, column, event);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case GTK_SELECTION_BROWSE:
|
||||
i = 0;
|
||||
list = clist->row_list;
|
||||
while (list)
|
||||
{
|
||||
clist_row = list->data;
|
||||
list = list->next;
|
||||
|
||||
if (row == i)
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
|
||||
row, column, event);
|
||||
else if (clist_row->state == GTK_STATE_SELECTED)
|
||||
if (i != row && clist_row->state == GTK_STATE_SELECTED)
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
|
||||
i, column, event);
|
||||
i++;
|
||||
}
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
|
||||
row, column, event);
|
||||
break;
|
||||
|
||||
|
||||
case GTK_SELECTION_MULTIPLE:
|
||||
i = 0;
|
||||
list = clist->row_list;
|
||||
while (list)
|
||||
{
|
||||
clist_row = list->data;
|
||||
list = list->next;
|
||||
clist_row = (g_list_nth (clist->row_list, row))->data;
|
||||
|
||||
if (row == i)
|
||||
{
|
||||
if (clist_row->state == GTK_STATE_SELECTED)
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
|
||||
row, column, event);
|
||||
else
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
|
||||
i, column, event);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
|
||||
row, column, event);
|
||||
break;
|
||||
|
||||
|
||||
case GTK_SELECTION_EXTENDED:
|
||||
break;
|
||||
|
||||
@ -2882,15 +2936,15 @@ select_row (GtkCList * clist,
|
||||
clist_row = list->data;
|
||||
list = list->next;
|
||||
|
||||
if (row == i)
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
|
||||
row, column, event);
|
||||
else if (clist_row->state == GTK_STATE_SELECTED)
|
||||
if (row != i && clist_row->state == GTK_STATE_SELECTED)
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
|
||||
i, column, event);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
|
||||
row, column, event);
|
||||
break;
|
||||
|
||||
case GTK_SELECTION_MULTIPLE:
|
||||
@ -2916,15 +2970,7 @@ unselect_row (GtkCList * clist,
|
||||
switch (clist->selection_mode)
|
||||
{
|
||||
case GTK_SELECTION_SINGLE:
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
|
||||
row, column, event);
|
||||
break;
|
||||
|
||||
case GTK_SELECTION_BROWSE:
|
||||
/* you can't force unselect a row in browse mode, because a row
|
||||
* must always be selected */
|
||||
break;
|
||||
|
||||
case GTK_SELECTION_MULTIPLE:
|
||||
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[UNSELECT_ROW],
|
||||
row, column, event);
|
||||
@ -2956,7 +3002,7 @@ real_select_row (GtkCList * clist,
|
||||
if (clist_row->state == GTK_STATE_NORMAL)
|
||||
{
|
||||
clist_row->state = GTK_STATE_SELECTED;
|
||||
clist->selection = g_list_append (clist->selection, clist_row);
|
||||
clist->selection = g_list_append (clist->selection, (gpointer) row);
|
||||
|
||||
if (!GTK_CLIST_FROZEN (clist) && gtk_clist_row_is_visible (clist, row))
|
||||
draw_row (clist, NULL, row, clist_row);
|
||||
@ -2981,7 +3027,7 @@ real_unselect_row (GtkCList * clist,
|
||||
if (clist_row->state == GTK_STATE_SELECTED)
|
||||
{
|
||||
clist_row->state = GTK_STATE_NORMAL;
|
||||
clist->selection = g_list_remove (clist->selection, clist_row);
|
||||
clist->selection = g_list_remove (clist->selection, (gpointer) row);
|
||||
|
||||
if (!GTK_CLIST_FROZEN (clist) && gtk_clist_row_is_visible (clist, row))
|
||||
draw_row (clist, NULL, row, clist_row);
|
||||
|
111
gtk/testgtk.c
111
gtk/testgtk.c
@ -2654,6 +2654,7 @@ select_clist (GtkWidget *widget,
|
||||
gchar *text;
|
||||
GdkPixmap *pixmap;
|
||||
GdkBitmap *mask;
|
||||
GList *list;
|
||||
|
||||
g_print ("GtkCList Selection: row %d column %d button %d\n",
|
||||
row, column, bevent ? bevent->button : 0);
|
||||
@ -2689,14 +2690,97 @@ select_clist (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
g_print ("\n\n");
|
||||
/* print selections list */
|
||||
g_print ("\nSelected Rows:");
|
||||
list = GTK_CLIST (widget)->selection;
|
||||
while (list)
|
||||
{
|
||||
g_print (" %d ", (gint) list->data);
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
g_print ("\n\n\n");
|
||||
|
||||
clist_selected_row = row;
|
||||
}
|
||||
|
||||
void
|
||||
list_selection_clist (GtkWidget *widget, gpointer data)
|
||||
unselect_clist (GtkWidget *widget,
|
||||
gint row,
|
||||
gint column,
|
||||
GdkEventButton * bevent)
|
||||
{
|
||||
gint i;
|
||||
guint8 spacing;
|
||||
gchar *text;
|
||||
GdkPixmap *pixmap;
|
||||
GdkBitmap *mask;
|
||||
GList *list;
|
||||
|
||||
g_print ("GtkCList Unselection: row %d column %d button %d\n",
|
||||
row, column, bevent ? bevent->button : 0);
|
||||
|
||||
for (i = 0; i < TESTGTK_CLIST_COLUMNS; i++)
|
||||
{
|
||||
switch (gtk_clist_get_cell_type (GTK_CLIST (widget), row, i))
|
||||
{
|
||||
case GTK_CELL_TEXT:
|
||||
g_print ("CELL %d GTK_CELL_TEXT\n", i);
|
||||
gtk_clist_get_text (GTK_CLIST (widget), row, i, &text);
|
||||
g_print ("TEXT: %s\n", text);
|
||||
break;
|
||||
|
||||
case GTK_CELL_PIXMAP:
|
||||
g_print ("CELL %d GTK_CELL_PIXMAP\n", i);
|
||||
gtk_clist_get_pixmap (GTK_CLIST (widget), row, i, &pixmap, &mask);
|
||||
g_print ("PIXMAP: %d\n", (int) pixmap);
|
||||
g_print ("MASK: %d\n", (int) mask);
|
||||
break;
|
||||
|
||||
case GTK_CELL_PIXTEXT:
|
||||
g_print ("CELL %d GTK_CELL_PIXTEXT\n", i);
|
||||
gtk_clist_get_pixtext (GTK_CLIST (widget), row, i, &text, &spacing, &pixmap, &mask);
|
||||
g_print ("TEXT: %s\n", text);
|
||||
g_print ("SPACING: %d\n", spacing);
|
||||
g_print ("PIXMAP: %d\n", (int) pixmap);
|
||||
g_print ("MASK: %d\n", (int) mask);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* print selections list */
|
||||
g_print ("\nSelected Rows:");
|
||||
list = GTK_CLIST (widget)->selection;
|
||||
while (list)
|
||||
{
|
||||
g_print (" %d ", (gint) list->data);
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
g_print ("\n\n\n");
|
||||
|
||||
clist_selected_row = row;
|
||||
}
|
||||
|
||||
void
|
||||
insert_row_clist (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
static char *text[] =
|
||||
{
|
||||
"This",
|
||||
"is",
|
||||
"a",
|
||||
"inserted",
|
||||
"row",
|
||||
"la la la la la",
|
||||
"la la la la"
|
||||
};
|
||||
|
||||
gtk_clist_insert (GTK_CLIST (data), clist_selected_row, text);
|
||||
clist_rows++;
|
||||
}
|
||||
|
||||
void
|
||||
@ -2804,6 +2888,16 @@ create_clist ()
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
button = gtk_button_new_with_label ("Insert Row");
|
||||
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button),
|
||||
"clicked",
|
||||
(GtkSignalFunc) insert_row_clist,
|
||||
(gpointer) clist);
|
||||
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label ("Show Title Buttons");
|
||||
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
||||
|
||||
@ -2840,14 +2934,20 @@ create_clist ()
|
||||
(GtkSignalFunc) select_clist,
|
||||
NULL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (clist),
|
||||
"unselect_row",
|
||||
(GtkSignalFunc) unselect_clist,
|
||||
NULL);
|
||||
|
||||
gtk_clist_set_column_width (GTK_CLIST (clist), 0, 100);
|
||||
|
||||
for (i = 1; i < TESTGTK_CLIST_COLUMNS; i++)
|
||||
gtk_clist_set_column_width (GTK_CLIST (clist), i, 80);
|
||||
|
||||
gtk_clist_set_selection_mode (GTK_CLIST (clist), GTK_SELECTION_BROWSE);
|
||||
|
||||
gtk_clist_set_policy (GTK_CLIST (clist), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
gtk_clist_set_policy (GTK_CLIST (clist),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
gtk_clist_set_column_justification (GTK_CLIST (clist), 1, GTK_JUSTIFY_RIGHT);
|
||||
gtk_clist_set_column_justification (GTK_CLIST (clist), 2, GTK_JUSTIFY_CENTER);
|
||||
@ -2896,7 +2996,10 @@ create_clist ()
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
{
|
||||
clist_rows = 0;
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
111
tests/testgtk.c
111
tests/testgtk.c
@ -2654,6 +2654,7 @@ select_clist (GtkWidget *widget,
|
||||
gchar *text;
|
||||
GdkPixmap *pixmap;
|
||||
GdkBitmap *mask;
|
||||
GList *list;
|
||||
|
||||
g_print ("GtkCList Selection: row %d column %d button %d\n",
|
||||
row, column, bevent ? bevent->button : 0);
|
||||
@ -2689,14 +2690,97 @@ select_clist (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
g_print ("\n\n");
|
||||
/* print selections list */
|
||||
g_print ("\nSelected Rows:");
|
||||
list = GTK_CLIST (widget)->selection;
|
||||
while (list)
|
||||
{
|
||||
g_print (" %d ", (gint) list->data);
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
g_print ("\n\n\n");
|
||||
|
||||
clist_selected_row = row;
|
||||
}
|
||||
|
||||
void
|
||||
list_selection_clist (GtkWidget *widget, gpointer data)
|
||||
unselect_clist (GtkWidget *widget,
|
||||
gint row,
|
||||
gint column,
|
||||
GdkEventButton * bevent)
|
||||
{
|
||||
gint i;
|
||||
guint8 spacing;
|
||||
gchar *text;
|
||||
GdkPixmap *pixmap;
|
||||
GdkBitmap *mask;
|
||||
GList *list;
|
||||
|
||||
g_print ("GtkCList Unselection: row %d column %d button %d\n",
|
||||
row, column, bevent ? bevent->button : 0);
|
||||
|
||||
for (i = 0; i < TESTGTK_CLIST_COLUMNS; i++)
|
||||
{
|
||||
switch (gtk_clist_get_cell_type (GTK_CLIST (widget), row, i))
|
||||
{
|
||||
case GTK_CELL_TEXT:
|
||||
g_print ("CELL %d GTK_CELL_TEXT\n", i);
|
||||
gtk_clist_get_text (GTK_CLIST (widget), row, i, &text);
|
||||
g_print ("TEXT: %s\n", text);
|
||||
break;
|
||||
|
||||
case GTK_CELL_PIXMAP:
|
||||
g_print ("CELL %d GTK_CELL_PIXMAP\n", i);
|
||||
gtk_clist_get_pixmap (GTK_CLIST (widget), row, i, &pixmap, &mask);
|
||||
g_print ("PIXMAP: %d\n", (int) pixmap);
|
||||
g_print ("MASK: %d\n", (int) mask);
|
||||
break;
|
||||
|
||||
case GTK_CELL_PIXTEXT:
|
||||
g_print ("CELL %d GTK_CELL_PIXTEXT\n", i);
|
||||
gtk_clist_get_pixtext (GTK_CLIST (widget), row, i, &text, &spacing, &pixmap, &mask);
|
||||
g_print ("TEXT: %s\n", text);
|
||||
g_print ("SPACING: %d\n", spacing);
|
||||
g_print ("PIXMAP: %d\n", (int) pixmap);
|
||||
g_print ("MASK: %d\n", (int) mask);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* print selections list */
|
||||
g_print ("\nSelected Rows:");
|
||||
list = GTK_CLIST (widget)->selection;
|
||||
while (list)
|
||||
{
|
||||
g_print (" %d ", (gint) list->data);
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
g_print ("\n\n\n");
|
||||
|
||||
clist_selected_row = row;
|
||||
}
|
||||
|
||||
void
|
||||
insert_row_clist (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
static char *text[] =
|
||||
{
|
||||
"This",
|
||||
"is",
|
||||
"a",
|
||||
"inserted",
|
||||
"row",
|
||||
"la la la la la",
|
||||
"la la la la"
|
||||
};
|
||||
|
||||
gtk_clist_insert (GTK_CLIST (data), clist_selected_row, text);
|
||||
clist_rows++;
|
||||
}
|
||||
|
||||
void
|
||||
@ -2804,6 +2888,16 @@ create_clist ()
|
||||
gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, FALSE, 0);
|
||||
gtk_widget_show (box2);
|
||||
|
||||
button = gtk_button_new_with_label ("Insert Row");
|
||||
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button),
|
||||
"clicked",
|
||||
(GtkSignalFunc) insert_row_clist,
|
||||
(gpointer) clist);
|
||||
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label ("Show Title Buttons");
|
||||
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
|
||||
|
||||
@ -2840,14 +2934,20 @@ create_clist ()
|
||||
(GtkSignalFunc) select_clist,
|
||||
NULL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (clist),
|
||||
"unselect_row",
|
||||
(GtkSignalFunc) unselect_clist,
|
||||
NULL);
|
||||
|
||||
gtk_clist_set_column_width (GTK_CLIST (clist), 0, 100);
|
||||
|
||||
for (i = 1; i < TESTGTK_CLIST_COLUMNS; i++)
|
||||
gtk_clist_set_column_width (GTK_CLIST (clist), i, 80);
|
||||
|
||||
gtk_clist_set_selection_mode (GTK_CLIST (clist), GTK_SELECTION_BROWSE);
|
||||
|
||||
gtk_clist_set_policy (GTK_CLIST (clist), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
gtk_clist_set_policy (GTK_CLIST (clist),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
gtk_clist_set_column_justification (GTK_CLIST (clist), 1, GTK_JUSTIFY_RIGHT);
|
||||
gtk_clist_set_column_justification (GTK_CLIST (clist), 2, GTK_JUSTIFY_CENTER);
|
||||
@ -2896,7 +2996,10 @@ create_clist ()
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
{
|
||||
clist_rows = 0;
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user