RE: 3000 toggle buttons in a table?
Thanks Yeti, for all your advices. I could implement my 3168 toggle buttons successfully, except that Editable cells don't serve the purpose. Anyways thanks once again for all the support rendered by you. Have a great day Laxmi ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: 3000 toggle buttons in a table?
Hi, I've designed my application like this Address(label) 1-16 radio buttons(represent the binary value) hex value Data of 178 rows is filled in the above structure. But now when I'm selecting a radio button, all the radio buttons in the same column of 178 rows are getting selected. Can anyone help me out Laxmi -Original Message- From: David Necas (Yeti) [mailto:[EMAIL PROTECTED] Sent: Thursday, April 06, 2006 1:00 PM To: Sailaxmi korada Cc: gtk-app-devel-list@gnome.org Subject: Re: 3000 toggle buttons in a table? On Thu, Apr 06, 2006 at 12:24:18PM +0530, Sailaxmi korada wrote: I was trying to fulfill my requirement of 3000 toggle buttons, with list store...that was just fantasticBut I'm held up with another requirement...it is like this... The 16 toggle buttons in a row represent a hex value(they are binary representations). So whenever I toggle the checkbox, the corresponding hex value shall be displayed in a text entry and vice versa. I mean if I'm entering a hex value in text entry then the corresponding toggles shall be selected/deselected. Is it possible to achieve this using list storeif yes, can you suggest me an efficient way of doing it... The bit checkbuttons and the hex representation are visualizations of the same single list store column, namely the integer holding the value (if they are not, you tree model is misdesigned and you should fix it), so if you update the value in the list store both representations are updated. Yeti -- That's enough. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 3000 toggle buttons in a table?
On Mon, Apr 10, 2006 at 12:40:12PM +0530, Sailaxmi korada wrote: Address(label) 1-16 radio buttons(represent the binary value) hex value Data of 178 rows is filled in the above structure. But now when I'm selecting a radio button, all the radio buttons in the same column of 178 rows are getting selected. Can anyone help me out Do you really want *radiobuttons* i.e. only one bit being always set? Anyway, this can be hardly answered without the code (moreover your description is pretty unclear -- do you describe the model, the view, or what?). You have a complete working code sample which sets bits in some integers using treeview checkbuttons, I sent it in my first reply (it only misses the hex value representation part), so compare it with your code. Yeti -- That's enough. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: 3000 toggle buttons in a table?
--) { renderer = gtk_cell_renderer_toggle_new(); column = gtk_tree_view_column_new(); g_object_set_data(G_OBJECT(renderer), id, GUINT_TO_POINTER(ctr)); int temp=GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(renderer), id)); gtk_cell_renderer_toggle_set_radio( GTK_CELL_RENDERER_TOGGLE(renderer), TRUE); g_signal_connect(renderer, toggled, G_CALLBACK(toggle_cell), store); if(strnum[i] == '1') g_object_set(G_OBJECT(renderer), active, TRUE, NULL); }//end of for i column = gtk_tree_view_column_new(); text = gtk_cell_renderer_text_new(); gtk_list_store_set (store, iter,18,0, -1); } gtk_tree_view_append_column(treeView, column); selection = gtk_tree_view_get_selection(treeView); gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE); gtk_container_add (GTK_CONTAINER(scroll), treeWidget); gtk_widget_show_all(window); gtk_main(); return 0; } Pl. note that I'm new to GTK programming, so if you find some blunders pl. excuse me. Regards Laxmi -Original Message- From: David Necas (Yeti) [mailto:[EMAIL PROTECTED] Sent: Monday, April 10, 2006 12:49 PM To: Sailaxmi korada Cc: gtk-app-devel-list@gnome.org Subject: Re: 3000 toggle buttons in a table? On Mon, Apr 10, 2006 at 12:40:12PM +0530, Sailaxmi korada wrote: Address(label) 1-16 radio buttons(represent the binary value) hex value Data of 178 rows is filled in the above structure. But now when I'm selecting a radio button, all the radio buttons in the same column of 178 rows are getting selected. Can anyone help me out Do you really want *radiobuttons* i.e. only one bit being always set? Anyway, this can be hardly answered without the code (moreover your description is pretty unclear -- do you describe the model, the view, or what?). You have a complete working code sample which sets bits in some integers using treeview checkbuttons, I sent it in my first reply (it only misses the hex value representation part), so compare it with your code. Yeti -- That's enough. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 3000 toggle buttons in a table?
You do not set the renderer active property anywhere except in the toggle_cell callback. Therefore it always renders *all* the cells in the last state (active or inactive) some cell was toggled to. You need either a cell data func or to use gtk_tree_view_column_new_with_attributes() to tell the renderer in which state it should render the cells. The active propery is not set in any automagic way, *something* must set it before the cell is rendered. It seems all my previous advices were vain too. The tree model should have exactly two columns: G_TYPE_STRING (the label) and G_TYPE_UINT16 (the value), and you should use a cell data function to set renderer properties to display the guint16 value once as toggles, once as hex, in different columns. In fact, everything that the code sample I sent needs to add to do *exactly* what you want is s/64/16/g, a hex-value column (in the view, *not* in the model) + its cell data function + its cell-edited callback. Of course, I can write the missing bits too -- it would be shorter than this mail -- but that would not teach you fishing. Please read the Gtk+ Tree View Tutorial to learn the concepts first. Yeti -- That's enough. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: 3000 toggle buttons in a table?
Thanks for the suggession, and certainly by the end of this week I shall do it perfectly. Afterall its matter of some time to understand the depth of any new language or packageright??? thanks once again for the support regards laxmi --- With your talent you may reach the top of the success, but it is your attitude that keeps you there From: David Necas (Yeti) [mailto:[EMAIL PROTECTED] Sent: Mon 4/10/2006 10:05 AM To: Sailaxmi korada Cc: gtk-app-devel-list@gnome.org Subject: Re: 3000 toggle buttons in a table? You do not set the renderer active property anywhere except in the toggle_cell callback. Therefore it always renders *all* the cells in the last state (active or inactive) some cell was toggled to. You need either a cell data func or to use gtk_tree_view_column_new_with_attributes() to tell the renderer in which state it should render the cells. The active propery is not set in any automagic way, *something* must set it before the cell is rendered. It seems all my previous advices were vain too. The tree model should have exactly two columns: G_TYPE_STRING (the label) and G_TYPE_UINT16 (the value), and you should use a cell data function to set renderer properties to display the guint16 value once as toggles, once as hex, in different columns. In fact, everything that the code sample I sent needs to add to do *exactly* what you want is s/64/16/g, a hex-value column (in the view, *not* in the model) + its cell data function + its cell-edited callback. Of course, I can write the missing bits too -- it would be shorter than this mail -- but that would not teach you fishing. Please read the Gtk+ Tree View Tutorial to learn the concepts first. Yeti -- That's enough. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: 3000 toggle buttons in a table?
Hi, I was trying to fulfill my requirement of 3000 toggle buttons, with list store...that was just fantasticBut I'm held up with another requirement...it is like this... The 16 toggle buttons in a row represent a hex value(they are binary representations). So whenever I toggle the checkbox, the corresponding hex value shall be displayed in a text entry and vice versa. I mean if I'm entering a hex value in text entry then the corresponding toggles shall be selected/deselected. Is it possible to achieve this using list storeif yes, can you suggest me an efficient way of doing it... Thanks and Regards Laxmi -Original Message- From: David Necas (Yeti) [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 04, 2006 2:10 PM To: Sailaxmi korada Cc: gtk-app-devel-list@gnome.org Subject: Re: 3000 toggle buttons in a table? On Tue, Apr 04, 2006 at 01:47:10PM +0530, Sailaxmi korada wrote: Why I said Tree view doesn't fit my requirement was, in a row I've to display label, 15 toggle buttons, text entry... Like this I've to fill the widgets in 178 rows. Displaying label is fine with List store... But how can I manage with text entry?? What about an editable column? If it has to look exactly like a classic text entry, then this is a problem, but if any editable text field will do, treeview can do that easily. Yeti -- That's enough. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 3000 toggle buttons in a table?
On Thu, Apr 06, 2006 at 12:24:18PM +0530, Sailaxmi korada wrote: I was trying to fulfill my requirement of 3000 toggle buttons, with list store...that was just fantasticBut I'm held up with another requirement...it is like this... The 16 toggle buttons in a row represent a hex value(they are binary representations). So whenever I toggle the checkbox, the corresponding hex value shall be displayed in a text entry and vice versa. I mean if I'm entering a hex value in text entry then the corresponding toggles shall be selected/deselected. Is it possible to achieve this using list storeif yes, can you suggest me an efficient way of doing it... The bit checkbuttons and the hex representation are visualizations of the same single list store column, namely the integer holding the value (if they are not, you tree model is misdesigned and you should fix it), so if you update the value in the list store both representations are updated. Yeti -- That's enough. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 3000 toggle buttons in a table?
On Tue, Apr 04, 2006 at 10:55:08AM +0530, Sailaxmi korada wrote: Perhaps, my application requires 16 toggle buttons to be placed in each row, that represent a hex value. So I need not write 3000 callbacks for them, instead with one call back I can manage to calculate the hex value, based on the position of toggle button. Tree view doesn't fit my requirement. The treeview example I sent does exactly that -- the toggle buttons represents bits in some integers (64bit in that case). So why it does not fit? Yeti -- That's enough. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: 3000 toggle buttons in a table?
That was great David, it was doing the task in fraction of seconds... Why I said Tree view doesn't fit my requirement was, in a row I've to display label, 15 toggle buttons, text entry... Like this I've to fill the widgets in 178 rows. Displaying label is fine with List store... But how can I manage with text entry?? Thanks Laxmi -Original Message- From: David Necas (Yeti) [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 04, 2006 12:33 PM To: Sailaxmi korada Cc: gtk-app-devel-list@gnome.org Subject: Re: 3000 toggle buttons in a table? On Tue, Apr 04, 2006 at 10:55:08AM +0530, Sailaxmi korada wrote: Perhaps, my application requires 16 toggle buttons to be placed in each row, that represent a hex value. So I need not write 3000 callbacks for them, instead with one call back I can manage to calculate the hex value, based on the position of toggle button. Tree view doesn't fit my requirement. The treeview example I sent does exactly that -- the toggle buttons represents bits in some integers (64bit in that case). So why it does not fit? Yeti -- That's enough. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 3000 toggle buttons in a table?
On Tue, Apr 04, 2006 at 01:47:10PM +0530, Sailaxmi korada wrote: Why I said Tree view doesn't fit my requirement was, in a row I've to display label, 15 toggle buttons, text entry... Like this I've to fill the widgets in 178 rows. Displaying label is fine with List store... But how can I manage with text entry?? What about an editable column? If it has to look exactly like a classic text entry, then this is a problem, but if any editable text field will do, treeview can do that easily. Yeti -- That's enough. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 3000 toggle buttons in a table?
Gus Koppel wrote: Sailaxmi korada wrote: My application has to display around 3000 toggle buttons, in 178 rows of a table. It is taking almost 12 seconds to do so. Can you help me out in reducing this time. Here are the two steps that are consuming maximum time gtk_button_set_label (GTK_BUTTON(drpentry_binbutton), 1); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(drpentry_binbutton),FALSE); I refrain from asking who might be supposed to toggle all 3000 buttons. I rather suggest you to do without standard widgets at all when it comes to such an exorbitant number of toggles. Sorry if I'm jumping into a thread that I havent read... maybe this comment was already made on this thread... Why not use GtkCellRendererToggle w/ GtkTreeView GtkListStore ? Or use a GtkListStore to select your data item and some togglebuttons and whatever other control widgets below your treeview (i.e. the single toggle button applies only to the selected row) ? (Sure; writing treeview code is a pain, but its perfect for these large dataset situations). Cheers, -Tristan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 3000 toggle buttons in a table?
On Mon, Apr 03, 2006 at 01:40:25PM -0400, Tristan Van Berkom wrote: Why not use GtkCellRendererToggle w/ GtkTreeView GtkListStore ? Or use a GtkListStore to select your data item and some togglebuttons and whatever other control widgets below your treeview (i.e. the single toggle button applies only to the selected row) ? (Sure; writing treeview code is a pain, but its perfect for these large dataset situations). It is not so much pain -- if your code actually does something, the treeview bureaucracy is not substantial. What bugs me more is the extra requested space at the right side of the tree view when one goes mad and simply creates a large grid of GtkCellRendererToggles. Is it a bug? Does anyone observe it too? Yeti -- That's enough. === #include stdlib.h #include gtk/gtk.h /* Someone put this into GLib... */ static guint64 g_rand_int64(GRand *rand) { guint64 low, hi; low = g_rand_int(rand); hi = g_rand_int(rand); return low | (hi 32); } static void render_cell(G_GNUC_UNUSED GtkCellLayout *layout, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) { guint i = GPOINTER_TO_UINT(user_data); guint64 x; gtk_tree_model_get(model, iter, 0, x, -1); g_object_set(G_OBJECT(renderer), active, (gboolean)((x i) 1), NULL); } static void toggle_cell(GtkCellRendererToggle *renderer, gchar *path, GtkListStore *store) { GtkTreeModel *model; GtkTreeIter iter; guint64 x, bit = 1; g_print(Setting (%u, %u) to %s\n, GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(renderer), id)), atoi(path), !gtk_cell_renderer_toggle_get_active(renderer) ? On : Off); model = GTK_TREE_MODEL(store); gtk_tree_model_iter_nth_child(model, iter, NULL, atoi(path)); gtk_tree_model_get(model, iter, 0, x, -1); bit = bit GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(renderer), id)); if (gtk_cell_renderer_toggle_get_active(renderer)) x = ~bit; else x |= bit; gtk_list_store_set(store, iter, 0, x, -1); } int main(int argc, char *argv[]) { GtkWidget *window, *treewidget; GtkTreeView *treeview; GtkListStore *store; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkCellLayout *layout; GtkTreeSelection *selection; GtkTreeIter iter; GRand *rng; guint i, nrows = 50; gtk_init(argc, argv); rng = g_rand_new(); store = gtk_list_store_new(1, G_TYPE_UINT64); for (i = 0; i nrows; i++) { gtk_list_store_append(store, iter); gtk_list_store_set(store, iter, 0, g_rand_int64(rng), -1); } g_rand_free(rng); treewidget = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); treeview = GTK_TREE_VIEW(treewidget); g_object_unref(store); column = gtk_tree_view_column_new(); layout = GTK_CELL_LAYOUT(column); for (i = 0; i 64; i++) { renderer = gtk_cell_renderer_toggle_new(); g_object_set_data(G_OBJECT(renderer), id, GUINT_TO_POINTER(i)); gtk_cell_layout_pack_start(layout, renderer, FALSE); gtk_cell_layout_set_cell_data_func(layout, renderer, render_cell, GUINT_TO_POINTER(i), NULL); g_object_set(renderer, activatable, TRUE, NULL); g_signal_connect(renderer, toggled, G_CALLBACK(toggle_cell), store); } gtk_tree_view_append_column(treeview, column); gtk_tree_view_set_headers_visible(treeview, FALSE); selection = gtk_tree_view_get_selection(treeview); gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_add(GTK_CONTAINER(window), treewidget); g_signal_connect(window, destroy, G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show_all(window); gtk_main(); return 0; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 3000 toggle buttons in a table?
Tristan Van Berkom wrote: Gus Koppel wrote: Sailaxmi korada wrote: My application has to display around 3000 toggle buttons, in 178 rows of a table. It is taking almost 12 seconds to do so. Can you help me out in reducing this time. Here are the two steps that are consuming maximum time gtk_button_set_label (GTK_BUTTON(drpentry_binbutton), 1); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(drpentry_binbutton),FALSE); I refrain from asking who might be supposed to toggle all 3000 buttons. I rather suggest you to do without standard widgets at all when it comes to such an exorbitant number of toggles. Sorry if I'm jumping into a thread that I havent read... maybe this comment was already made on this thread... Why not use GtkCellRendererToggle w/ GtkTreeView GtkListStore ? Or use a GtkListStore to select your data item and some togglebuttons and whatever other control widgets below your treeview (i.e. the single toggle button applies only to the selected row) ? (Sure; writing treeview code is a pain, but its perfect for these large dataset situations). I suppose for Sailaxmi's application it is important to have all toggles clearly arranged, likely for some sort of state matrix. Using a treeview with togglebuttons below it for just the currently selected line would be the more conventional approach to avoid huge numbers of widgets but likely doesn't fit the demands. On the other hand, filling the visible area of a treeview with 3000 toggles would still result in suboptimal display performance. For (basically) maintaining the original layout while significantly increasing its build speed, I think doing all the drawing on one's own, without keeping any widget or field structures behind it, is the best way. At least it's the fastest by far. Perhaps it would be beneficial to be able to toggle multiple buttons just as the mouse passes over them while the mouse button is being pressed? This could be accomplished with a custom implementation as well. Think of The Gimp with a 16 * 178 B/W bitmap. There's no way of implementing such behaviour (one button press, multiple state changes) with any standatrd means. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 3000 toggle buttons in a table?
On Mon, Apr 03, 2006 at 11:23:51PM +0200, Gus Koppel wrote: On the other hand, filling the visible area of a treeview with 3000 toggles would still result in suboptimal display performance. Suboptimal maybe, OTOH if you try the example I attached to my previous mail, you can see we are now in fractions of a second -- at this point hacking together a new widget makes sense only if it has other advantages (visual presentation or behaviour hard to achieve with GtkTreeView, perhaps with a more fitting API). However the primary question is still what is this supposed to be good for... Yeti -- That's enough. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: 3000 toggle buttons in a table?
Perhaps, my application requires 16 toggle buttons to be placed in each row, that represent a hex value. So I need not write 3000 callbacks for them, instead with one call back I can manage to calculate the hex value, based on the position of toggle button. Tree view doesn't fit my requirement. With this clear picture any suggessions?? Laxmi -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gus Koppel Sent: Tuesday, April 04, 2006 2:54 AM To: gtk-app-devel-list@gnome.org Subject: Re: 3000 toggle buttons in a table? Tristan Van Berkom wrote: Gus Koppel wrote: Sailaxmi korada wrote: My application has to display around 3000 toggle buttons, in 178 rows of a table. It is taking almost 12 seconds to do so. Can you help me out in reducing this time. Here are the two steps that are consuming maximum time gtk_button_set_label (GTK_BUTTON(drpentry_binbutton), 1); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(drpentry_binbutton),FALSE); I refrain from asking who might be supposed to toggle all 3000 buttons. I rather suggest you to do without standard widgets at all when it comes to such an exorbitant number of toggles. Sorry if I'm jumping into a thread that I havent read... maybe this comment was already made on this thread... Why not use GtkCellRendererToggle w/ GtkTreeView GtkListStore ? Or use a GtkListStore to select your data item and some togglebuttons and whatever other control widgets below your treeview (i.e. the single toggle button applies only to the selected row) ? (Sure; writing treeview code is a pain, but its perfect for these large dataset situations). I suppose for Sailaxmi's application it is important to have all toggles clearly arranged, likely for some sort of state matrix. Using a treeview with togglebuttons below it for just the currently selected line would be the more conventional approach to avoid huge numbers of widgets but likely doesn't fit the demands. On the other hand, filling the visible area of a treeview with 3000 toggles would still result in suboptimal display performance. For (basically) maintaining the original layout while significantly increasing its build speed, I think doing all the drawing on one's own, without keeping any widget or field structures behind it, is the best way. At least it's the fastest by far. Perhaps it would be beneficial to be able to toggle multiple buttons just as the mouse passes over them while the mouse button is being pressed? This could be accomplished with a custom implementation as well. Think of The Gimp with a 16 * 178 B/W bitmap. There's no way of implementing such behaviour (one button press, multiple state changes) with any standatrd means. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list