Re: CellRenderText properties question.
* Diego Zuccato ([EMAIL PROTECTED]) wrote: Carl B. Constantine wrote: Thanks for the reply. That confirms what I suspected, but IMHO very bad design as it creates extra overhead for memory and storage in the TreeModel (ListStore in this case) instead of being able to determine the property programatically. What if I have a preference setting where the user change pick a color so it's not just red or blue it's between blue and purple? You can have multiple views on the same model, and tha'ts the real power of the new widgets over GtkCList and GtkCTree (that, OTOH, are much faster). And as Owen said (and I didn't know!) you can have a callback to calculate on the fly the properties. Indeed. I'll try this a little later today, but if I have the extra data in the model and currently that column has a black setting for each cell, and then I set a cell in that column to red, will the visible text then automatically change color for that cell? As you probably already understood, it's not an hide it matter. If you follow the easy way, then you store different attributes in different MODEL columns. But these columns get ALL referenced when you add a new column to the VIEW. This way you could have different attribute sets for different views. again, will try some test code in a couple hours to test this and see what happens, but any pointers you can give would be helpful. -- .''`. Carl B. Constantine : :' : [EMAIL PROTECTED] `. `'GnuPG: 135F FC30 7A02 B0EB 61DB 34E3 3AF1 DC6C 9F7A 3FF8 `- Debian GNU/Linux -- The power of freedom pgp0.pgp Description: PGP signature
CellRenderText properties question.
The Gnome 2.0 porting docs contain the following information on the GtkCellRender widget (under new widgets in the docs): * Cell renderer properties can be set per-renderer or per-cell (based on data in the model). So for example, the text renderer has a foreground property for the foreground color. You could set the foreground color globally for an entire column, or you could have the foreground property change per-cell according to data in the model. * For a given cell renderer, multiple fields in the model can affect it. For example, if your mail client model has a boolean field indicating unread message, and a string field indicating subject, you can set the bold property of the cell from the unread flag and the text property of the cell from the subject. Looking at the API docs for GtkCellRender and GtkCellRenderText, I see the following description under gtk_cell_renderer_text_new (): ...Also, with GtkTreeViewColumn, you can bind a property to a value in a GtkTreeModel. For example, you can bind the text property on the cell renderer to a string value in the model, thus rendering a different string in each row of the GtkTreeView. However, I can't really find any code examples of how to do anything suggested in these docs. For example, I have a GtkTextView that only has a single column in it. When I click a button in my window, I want to find out the current selection in that TreeView and set it's text to Red or Bold or something. I can't seem to find anything that shows how to get the exact cell and then change its attributes. I can do it globably for a column (and have for testing) but not on a single cell. These docs seem to imply that I need some further data in my cell model to apply an attribute to. So, it seems like I have to have an extra invisible column in my model that holds text attributes, update the column text with a new string (say to red from black in order for the text in the visible column to have the attribute change. This seems very confusing to me. The docs say based on data in the model but it's not clear what that means, if it's actual attributes stored in the model, or just change based on a programmatic condition (col 1 is true so set text to bold). How can I change attributes on a single cell without having extra data in my model or do I really need the extra data in my model? I'm sure I'm missing something obvious but the docs are confusing. Also, storing extra attribute data in my ListStore adds memory overhead. Additionally, I see this description for gtk_tree_view_column_cell_set_cell_data: Sets the cell renderer based on the tree_model and iter. That is, for every attribute mapping in tree_column, it will get a value from the set column on the iter, and use that value to set the attribute on the cell renderer. I'm sorry but that's not very clear, and in fact it's extremely confusing. Maybe RedHat could hire me as a technical writer (I have several years experience at this and worked for Metrowerks as a professional technical writer). Any help is greatly appreciated. -- .''`. Carl B. Constantine : :' : [EMAIL PROTECTED] `. `'GnuPG: 135F FC30 7A02 B0EB 61DB 34E3 3AF1 DC6C 9F7A 3FF8 `- Debian GNU/Linux -- The power of freedom pgp0.pgp Description: PGP signature
Re: CellRenderText properties question.
Carl B. Constantine wrote: ...Also, with GtkTreeViewColumn, you can bind a property to a value in a GtkTreeModel. For example, you can bind the text property on the cell renderer to a string value in the model, thus rendering a different string in each row of the GtkTreeView. When you add a column to your view, you put ..., text, COL, ... to show the text from model column COL in the currently being added column. The same is with background and foreground attributes, and the pointed columns must contain a colour name (as string: red, blue, etc). However, I can't really find any code examples of how to do anything suggested in these docs. For example, I have a GtkTextView that only has a single column in it. When I click a button in my window, I want to find out the current selection in that TreeView and set it's text to Red or Bold or something. I can't seem to find anything that shows how to get the exact cell and then change its attributes. I can do it globably for a column (and have for testing) but not on a single cell. I posted an example a couple of days ago. Just a code snippet from one of my projects, but should give you the idea. You have to add a column for every attribute. ... If only it could be possible to map values to attributes (1=red, 2=blue and so on...) BYtE, Diego. ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: CellRenderText properties question.
Hi, Carl B. Constantine [EMAIL PROTECTED] writes: However, I can't really find any code examples of how to do anything suggested in these docs. For example, I have a GtkTextView that only has a single column in it. When I click a button in my window, I want to find out the current selection in that TreeView and set it's text to Red or Bold or something. I can't seem to find anything that shows how to get the exact cell and then change its attributes. I can do it globably for a column (and have for testing) but not on a single cell. the API reference is not exactly the place where you'd look for code examples. The gtk-demo as found in the demos directory of the GTK+ source tree seems like a good place to look for such examples. These docs seem to imply that I need some further data in my cell model to apply an attribute to. So, it seems like I have to have an extra invisible column in my model that holds text attributes, update the column text with a new string (say to red from black in order for the text in the visible column to have the attribute change. This seems very confusing to me. The docs say based on data in the model but it's not clear what that means, if it's actual attributes stored in the model, or just change based on a programmatic condition (col 1 is true so set text to bold). How can I change attributes on a single cell without having extra data in my model or do I really need the extra data in my model? I'm sure I'm missing something obvious but the docs are confusing. Also, storing extra attribute data in my ListStore adds memory overhead. of course you need the extra data. You want to display additional information, where should it come from if not from the model? Of course you can write your own custom cell renderer which calculcates the information for each cell but unless you want to do that, you need an extra column in your model. Please note that the model columns don't necessarily correspond to the view columns. It thus doesn't make any sense to speak of an invisible column in a model. Salut, Sven ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: CellRenderText properties question.
* Diego Zuccato ([EMAIL PROTECTED]) wrote: Carl B. Constantine wrote: ...Also, with GtkTreeViewColumn, you can bind a property to a value in a GtkTreeModel. For example, you can bind the text property on the cell renderer to a string value in the model, thus rendering a different string in each row of the GtkTreeView. When you add a column to your view, you put ..., text, COL, ... to show the text from model column COL in the currently being added column. The same is with background and foreground attributes, and the pointed columns must contain a colour name (as string: red, blue, etc). Thanks for the reply. That confirms what I suspected, but IMHO very bad design as it creates extra overhead for memory and storage in the TreeModel (ListStore in this case) instead of being able to determine the property programatically. What if I have a preference setting where the user change pick a color so it's not just red or blue it's between blue and purple? However, I can't really find any code examples of how to do anything suggested in these docs. For example, I have a GtkTextView that only has a single column in it. When I click a button in my window, I want to find out the current selection in that TreeView and set it's text to Red or Bold or something. I can't seem to find anything that shows how to get the exact cell and then change its attributes. I can do it globably for a column (and have for testing) but not on a single cell. I posted an example a couple of days ago. Just a code snippet from one of my projects, but should give you the idea. You have to add a column for every attribute. or add multiple attributes to the column with gtk_tree_view_column_add_attribute(). But this means I have to add a column to the model and then hide it after it's appended to the view right? ... If only it could be possible to map values to attributes (1=red, 2=blue and so on...) or have a hex value that can then be used for the color. Then a user can use the color selector to pick a color for certain cells. However, I find that interface rather awkward to use in that instance, again because it can't be determined programatically or you have to change the column the cell looks at on the fly which is awkward. -- .''`. Carl B. Constantine : :' : [EMAIL PROTECTED] `. `'GnuPG: 135F FC30 7A02 B0EB 61DB 34E3 3AF1 DC6C 9F7A 3FF8 `- Debian GNU/Linux -- The power of freedom pgp0.pgp Description: PGP signature
Re: CellRenderText properties question.
Hi, Carl B. Constantine [EMAIL PROTECTED] writes: Thanks for the reply. That confirms what I suspected, but IMHO very bad design as it creates extra overhead for memory and storage in the TreeModel (ListStore in this case) instead of being able to determine the property programatically. What if I have a preference setting where the user change pick a color so it's not just red or blue it's between blue and purple? noone said you have to store the color as string. You could for example have model column that holds a GdkColor which would give you 16 bit per color channel and I suspect that's more fine-grained than you'll ever need it to be. or add multiple attributes to the column with gtk_tree_view_column_add_attribute(). But this means I have to add a column to the model and then hide it after it's appended to the view right? However, I find that interface rather awkward to use in that instance, again because it can't be determined programatically or you have to change the column the cell looks at on the fly which is awkward. you shouldn't judge on an API that you obviously did not understood. Salut, Sven ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: CellRenderText properties question.
* Sven Neumann ([EMAIL PROTECTED]) wrote: the API reference is not exactly the place where you'd look for code examples. The gtk-demo as found in the demos directory of the GTK+ source tree seems like a good place to look for such examples. I didn't look there, I looked at the various examples that come with GTK. of course you need the extra data. You want to display additional information, where should it come from if not from the model? Of course you can write your own custom cell renderer which calculcates the information for each cell but unless you want to do that, you need an extra column in your model. Please note that the model columns don't necessarily correspond to the view columns. It thus doesn't make any sense to speak of an invisible column in a model. Yes, I suppose that's correct. I'm a bit confused as you create the column with gtk_tree_view_column_new (or gtk_tree_view_column_new_with_attributes) and then call gtk_tree_view_append_column to append it to the tree view, at least for the view. However, I gather I would call gtk_list_store_new with the extra column (or columns) so I have a place in the store to save my data, but the view doesn't show it. This makes sense now that you point that out. I was doing a 1:1 mapping between the TreeModel (ListStore in my case) and the TreeView but it doesn't have to be such. Thanks for the help! -- .''`. Carl B. Constantine : :' : [EMAIL PROTECTED] `. `'GnuPG: 135F FC30 7A02 B0EB 61DB 34E3 3AF1 DC6C 9F7A 3FF8 `- Debian GNU/Linux -- The power of freedom pgp0.pgp Description: PGP signature
Re: CellRenderText properties question.
On Tue, 2003-03-04 at 17:51, Sven Neumann wrote: How can I change attributes on a single cell without having extra data in my model or do I really need the extra data in my model? I'm sure I'm missing something obvious but the docs are confusing. Also, storing extra attribute data in my ListStore adds memory overhead. of course you need the extra data. You want to display additional information, where should it come from if not from the model? Of course you can write your own custom cell renderer which calculcates the information for each cell but unless you want to do that, you need an extra column in your model. Please note that the model columns don't necessarily correspond to the view columns. It thus doesn't make any sense to speak of an invisible column in a model. It should be pointed out here that if you _do_ want to calculate things per-cell, then there's a much easier way to do it than to write your own renderer - use: http://developer.gnome.org/doc/API/2.2/gtk/GtkTreeViewColumn.html#gtk-tree-view-column-set-cell-data-func This is gives you a callback to calculate the properties, usually from an application-specific data structure you store in a treeviewcolumn (you can use G_TYPE_POINTER or register your own type with g_boxed_type_register_static()) Regards, Owen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list