Invalid UTF-8 string being sent to callback function on "toggled" signal from GtkCellRendererToggle
- From: "Justin Stallard" <darkfloyd7 gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Invalid UTF-8 string being sent to callback function on "toggled" signal from GtkCellRendererToggle
- Date: Wed, 20 Jun 2007 17:52:04 -0400
Hi,
The subject pretty much says it all. The tree path string that is
being sent to my callback function as a result of the "toggled" signal
from a GtkCellRendererToggle in a GtkTreeView is an "Invalid path".
The following is the output to the terminal upon toggling one of the
GtkCellRendererToggle(s), followed by the code that will reproduce
this problem. What am I doing wrong?
Thank you,
-Justin
Terminal output:
[Invalid UTF-8]
\x8bU\x08\x8bM\x08\x0f\xb6B\x02\x89\xc2\x0f\xb6A\x01\x83\xe2\x01\x8dz\xff\xc0\xe8\x07\x83\xff\xfft*\x0f\xb6\xc0\x8d\x04P\x8d4\xc5\xf8\xff\xff\xff\x8bM\x08\x89\xf2O\x83\xee\x08\x03Q\x0c\x89L$\x04\x8b\x02\x89\x04$\xffR\x04\x83\xff\xffu\xe3\x0f\xb6E\xcb\x83\xe0\x01\x89\xc6\xc1\xe6\x06\x8dv
(keyboard:20321): Gtk-WARNING **: gtktreemodel.c:440: Invalid path
\x8bU\u0008\x8bM\u0008\u000f\xb6B\u0002\x89\xc2\u000f\xb6A\u0001\x83\xe2\u0001\x8dz\xff\xc0\xe8\u0007\x83\xff\xfft*\u000f\xb6\xc0\x8d\u0004P\x8d4\xc5\xf8\xff\xff\xff\x8bM\u0008\x89\xf2O\x83\xee\u0008\u0003Q\u000c\x89L$\u0004\x8b\u0002\x89\u0004$\xffR\u0004\x83\xff\xffu\xe3\u000f\xb6E?\xe0\u0001\x89\xc6\xc1\xe6\u0006\x8dv
passed to gtk_tree_path_new_from_string
Code:
#include <gtk/gtk.h>
GtkTreeStore *treestore;
void on_cell_renderer_toggle_toggled(GtkCellRendererToggle w,
const gchar *path_string,
gpointer data)
{
GtkTreePath *path;
GtkTreeIter iter;
gboolean oldval;
gboolean tmp;
g_print("%s\n", path_string);
path = gtk_tree_path_new_from_string(path_string);
}
int main(int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *treeview;
GtkCellRenderer *render;
GtkTreeViewColumn *column;
GtkTreeIter iter[3];
gtk_init (&argc, &argv);
/* create the treeview */
treeview = gtk_tree_view_new();
/* set up the tree model */
treestore = gtk_tree_store_new(1, G_TYPE_BOOLEAN);
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(treestore));
/* put some data in it */
gtk_tree_store_append(treestore, iter, NULL);
gtk_tree_store_set(treestore, iter, 0, TRUE, -1);
gtk_tree_store_append(treestore, iter + 1, iter);
gtk_tree_store_set(treestore, iter + 1, 0, TRUE, -1);
gtk_tree_store_append(treestore, iter + 2, NULL);
gtk_tree_store_set(treestore, iter + 2, 0, TRUE, -1);
/* set up the column */
column = gtk_tree_view_column_new();
render = gtk_cell_renderer_toggle_new();
gtk_tree_view_column_pack_start(column, render, TRUE);
gtk_tree_view_column_set_attributes(column, render, "active", 0, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
/* signal handler for the cell renderer */
g_signal_connect(render, "toggled",
G_CALLBACK(on_cell_renderer_toggle_toggled), NULL);
/* create the window, put the tree view in it, and show */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_add(GTK_CONTAINER(window), treeview);
gtk_widget_show_all(window);
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]