[Glade-users] toggle buttons in a list view
- From: seb hypercubesystems co uk (Seb James)
- Subject: [Glade-users] toggle buttons in a list view
- Date: Mon, 14 Mar 2005 10:23:01 +0000
--=-DrMdfmtTKp0tHbwLWdx9
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Hello List,
I've got most of the methods worked out for dealing with a tree/list
view, but I'm having trouble toggling a check button in the list. A
quick pointer on this would be very much appreciated.
I set up a column in my list view, called "At boot" and connect a signal
like this:
/* "At boot" column */
renderer =3D gtk_cell_renderer_toggle_new ();
column =3D gtk_tree_view_column_new_with_attributes ("At boot?",=20
renderer,
"active", CONN_BOOT,
NULL);
g_object_set (renderer, "activatable", TRUE, NULL);
g_signal_connect (renderer, "toggled",=20
G_CALLBACK (boot_toggled_callback),=20
NULL);
gtk_tree_view_append_column (list_tree, column);
/* end "At boot" column */
Then I have a callback function that looks like this:
void boot_toggled_callback (GtkCellRendererToggle * cell,
gchar * path_string,
gpointer data)
{
GtkTreeIter iter;
gint active;
gchar * name;
/* Convert from path to iter: */
if (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (conn_store),
&iter,
path_string)) {
/* Get attributes from the list entry */
gtk_tree_model_get (GTK_TREE_MODEL (conn_store), &iter,=20
CONN_BOOT, &active,=20
CONN_NAME, &name,=20
-1);
} else {
g_print ("Couldn't set iter from path\n");
return;
}
/* Print something out to verify that we have selected out info from
the correct entry in the list (this works and the name of the entry=09
and the state of the toggle is printed correctly)=20
*/
g_print ("Name of connection is %s and active is %d\n", name, active);
if (active) {
gtk_cell_renderer_toggle_set_active (cell, FALSE);
g_print ("Boot toggled inactive\n");
}
else {
/* This call fails and does not set the cell active */
gtk_cell_renderer_toggle_set_active (cell, TRUE);
g_print ("Boot toggled active\n");
}
return;
}
/* End of callback */
Now, if I get the value of the cell pointer to print out, it is always
the same, no matter which line I click in my list, so I think that I am
not correctly referring to my toggle cell entry. Can anyone help me
toggle my check box?
regards,
Seb James
--=20
Hypercube Systems Ltd 'Embedded Linux Solutions'
35 Walkley Crescent Road, Sheffield, S6 5BA
Tel: 0845 4580277 Web: www.hypercubesystems.co.uk
gpg key: http://www.hypercubesystems.co.uk/ssl/seb.gpg.asc
--=-DrMdfmtTKp0tHbwLWdx9
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQBCNWYF1ORYCJQjGigRAgdmAJ9vHQn/AJ/jl2V59bstfyDYODYIHwCgof/V
RmDCzY0tgYmV6OLSvstiXgU=
=Jm+b
-----END PGP SIGNATURE-----
--=-DrMdfmtTKp0tHbwLWdx9--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]