Include parent and child items of GtkTreeStore in GtkEntryCompletion - gtk3

I have a GtkEntryCompletion declared as follows:
<object class="GtkEntryCompletion" id="search_entry_completion">
<property name="model">menu_treestore</property>
<property name="text_column">0</property>
</object>
The model is a GtkTreeStore with two columns, and column 0 is rendered as the text that should appear in the entry completion.
The problem is that as it is a GtkTreeStore, only the parent items are used in the completion.
So, for example, if I have:
test0
test00
test01
test1
Only test0 and test1 will be available for the entry completion. I can't change the model to a GtkListStore, so, is there a way to make all items of the GtkTreeStore available for the entry completion?
I'm using Python and Glade for the development of that task.

Related

SAPUI5 - How to change the table in the same View?

situation:
2 diferent tables, 1 view;
want to achieve:
I've got to change the table when I change the selectedKey in a select.
I already tried to create fragments with each table and call the one I want when I change the select.
fragment1 - table 1
fragment2 - table 2
select - oEvent (onChangeSelect) - getSelectedKey - if(key === 1) - call fragment1, if(key === 2) - call fragment2, but it gives me an error.
I don't know if this is correct and I'm not finding any infos related online.
If someone can show some links or give me just an idea on how can I do this, it would be perfect.
You could use the concept of binding to achieve this without coding. assume you have something like that in your view:
<Select><!-- ... --></Select>
<core:Fragment ... /><!-- table 1 -->
<core:Fragment ... /><!-- table 2 -->
First, add a model to your app, which will contain the information about the status of the app (which of the fragments is visible currently). Easiest way is to start with an empty JSON model. If you are familiar with manifest.json config, add it there. if not, you could add this in your Components init method:
this.setModel(new JSONModel(), "config");
This way, the new empty model is available under the name "config" in all the views of the app.
Now, we will add a visibility flag, which will control the visibility of your fragments (tables), and can be changed by the select:
<Select selectedKey="{config>/selectedFragmentKey}">
<core:Item key="" text="Please choose one" />
<core:Item key="showFragment1" text="Show Fragment 1" />
<core:Item key="showFragment2" text="Show Fragment 2" />
</Select>
This new version will store the key of the selected item in the config model in the path /selectedFragment. Add visibility flag to fragments (tables):
<!-- table 1 is only visible if "Show Fragment 1" was selected -->
<Table visible="{= ${config>/selectedFragmentKey} === 'showFragment1'}" .../>
<!-- table 2 is only visible if "Show Fragment 2" was selected -->
<Table visible="{= ${config>/selectedFragmentKey} === 'showFragment2'}" .../>
and you're done.
Main lesson here: learn to use bindings.
If I understood the question correctly, you have a selection control (which has 2 entries), and a table in the view. Based on the selection item, you want to display ONE of the tables at any given point of time. I am also assuming here, that the tables are purely used in the current view only & not really a "re-useable" thing - which gets used in different places of the app (which then renders the use of fragments an overkill).
I am assuming, both tables are bound (although to different data sets).
In that case, consider using the "visible" property of the appropriate table to "false".
Remember - all UI components, including tables inherit from sap.ui.core.Control - which has the "visible" property.
In API reference for table : https://sapui5.hana.ondemand.com/#/api/sap.ui.table.Table%23methods/Summary
If you scroll down to "Borrowed from:" section, you will see the "setVisible" and "getVisibe" methods.
So, in the event fired during selection change, you can grab the table control & set the visibility using the aforementioned methods.
Alternatively, you can also set an expression binding directly on the table control in XML, which evaluates to "true" or "false" (perhaps using a formatter).
Let me know if you need further info on this.
Best Regards,
Gopal Nair.

manage signals in GTK .ui files in vala

from the following .ui files, I have the signal :
<object class="GtkButton" id="button2">
<property name="label">Button 2</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<signal name="clicked" handler="on_button2_clicked" swapped="no"/>
</object>
the name of signal on_button2_clicked and the following code I used to handle event by add_callback_symbool :
// Create Builder
var build = new Gtk.Builder ();
build.add_from_resource ("/me/rush/Rush/main.ui");
// Create an instance
var window = (Gtk.ApplicationWindow) build.get_object ("window");
// handle event
build.add_callback_symbol ("on_button2_clicked", ()=> {print ("click");});
window.application = app;
window.show_all ();
GUI appeard in screen but handling of event on_button2_clicked doesnt work, I tried to handle event with build.connect_signals (null) and defiend function with same name but also doesnt work
when googling I found a way to work with callbaks in templates, but what I want to do is handle event with connect.signals or add_callback_symbol
also I tried example here but it doesnt work
I also replied this to your question on GNOME's discourse, but I'll post the answer again here for visibility:
It's maybe good to know that Vala has built-in support for GtkTemplates, which means you don't need to explicitly call the GtkBuilder API anymore. Vala will do the necessary checks for you (at compile-time even).
You can find multiple examples for this in the GNOME Contacts repository, but to give a concrete one, let's show the SetupWindow:
The UI definition
The GResources XML where it gets included
The Vala source code. Look especially for [GtkTemplate] and [GtkChild]. A speicifcally callback isn't part of this class, but there are examples of this if you look for [GtkCallback]

Aggregation Binding to Child Collection

In an XML view I have a JSON model bound to the page with the name 'foo'. The model's object has a 'name' field and child collection 'bar' (that has a 'code' field) that I want to show in a list. This is modeled as such:
JS Code
var foo = { name:'My Name', bar:[{ code:'Code 1' }, { code:'Code 2' }] }
var fooModel = new sap.ui.model.JSONModel(foo);
page.setModel(fooModel, 'foo');
page.bindElement('foo>/');
XML Markup
<Label text='{foo>name}'/>
<List items='{foo>bar}'>
<StandardListItem title='{foo>code}'/>
</List>
Notice that the list item's values for the child 'bar' array are resolved via the name 'foo'. At least this works for me and I have found no other way to reference them in the list.
But the problem is how do I get the top-level 'foo' object data in my list-item also? Say I wanted to show the 'name' field also in the list items?
In other words, is there a way to do the equivalent of the following, where I can reference the child collection by a different name? Is there some way to achieve this?
<List items="{ path:'foo>bar', name='bar' }">
<StandardListItem title='{bar>code}' info='{foo>name}' />
</List>
You need to use an absolute path to bind the name property. Absolute means the complete path to the property within your model. The opposite is a relative binding path. Here you just use a property somewhere within your model and set a binding context to tell the runtime where your property is located within the model. You do this by using:
page.bindElement("foo>/");
Now the runtime will apply this information to all relative bindings against the model foo within this page. Therefore you can write foo>bar and the runtime automatically look up foo>/bar. However within the item aggregation this does not work, because the bar object does not have a property name. Therefore you need to use a absolute binding path to bind the property.
<List items="{foo>bar}">
<StandardListItem title='{foo>code}' info='{foo>/name}' />
</List>
You find an explanation of the binding syntax for JSONModel in the documenation.

Item Descriptor Inheritance in ATG for "contactInfo"

I am trying to inherit the "contactInfo" item and create a new item descriptor.. Something like this as given below..
<item-descriptor name="testContactInfo" super-type="contactInfo">
<table name="test_contact_info" type="auxiliary" id-column-name="contact_id" shared-table-sequence="1">
<property name="fixedlinenumber" column-name="fixed_line_num" data-type="string"/>
</table>
</item-descriptor>
I get the following error when i start the server.
14:19:52,856 ERROR [ProfileAdapterRepository] Error parsing template: atg.repository.RepositoryException: Your item-descriptor definition for testContactInfo has super-type contactInfo but no sub-type attribute.
what am i doing wrong here? I have kept the definition in userProfile.xml
First question: are you actually looking to create a subtype of the contactInfo item descriptor - that is to say, are you expecting there to be some items in your system of type contactInfo and some items of type testContactInfo - or are you just looking to add a custom property to the existing contactInfo item descriptor?
If you are actually trying to create a subtype of contactInfo, then you need to modify the descriptor of contactInfo to tell it how to differentiate between items of type contactInfo and items of type testContactInfo. You will need to add a property, say contactType, to contactInfo and set the sub-type-property attribute
<item-descriptor name="contactInfo" sub-type-property="contactType" ...>
...
<property name="contactType" data-type="enumerated">
<option value="standard"/>
<option value="test"/>
</property>
...
</item-descriptor>
and then you can subtype it
<item-descriptor name="testContactInfo" super-type="contactInfo" sub-type-value="test">
...
</item-descriptor>
If, however, you are just looking to add a custom property to it, you can very well add to the existing definition. You do not need to subtype to extend an out-of-the-box item. For example
<item-descriptor name="contactInfo">
<table name="test_contact_info" type="auxiliary" id-column-name="contact_id" shared-table-sequence="1">
<property name="fixedlinenumber" column-name="fixed_line_num" data-type="string"/>
</table>
</item-descriptor>
will result in a new property called fixedlinenumber added to the standard contactInfo item.
Item-descriptor inheritance can be done in two ways. You can:-
Add new properties for existing item-descriptor.
Here you can add many properties to an existing item-descriptor. This can be out of the box, or your custom repository.
For example, you can have a employeeId property to contactInfo item-descriptor, which would be available for all contactInfo items.
Create a sub-type of an item-descriptor.
This is generally used to have distinctive properties for a particular item-descriptor.
For example, in your contactInfo type, you can have a "employeeContactInfo" wherein you want to store an extra employee id, and you can have a "employeeId" only for this type.
So, it basically depends on your requirements. You can see some details on this website.. nice tutorials:-
http://learnoracleatg.blogspot.in/2014/11/art203-how-to-extend-out-of-box-non.html
and
http://learnoracleatg.blogspot.in/2014/12/art204-how-to-add-new-item-descriptor.html

Django-tastypie -- how to generate customized xml

I have ModelResource in tastypie for a Simple Model that has an id and a name.
The XML output is shown below. But I would like to use my model name in place of "object". I seem to endlessly struggle on how to solve this -- any quick help on this? Thanks a million-- really!
<response>
<objects type="list">
<object>
<id>1</id>
<name>foo1</name>
<resource_uri> blah </resource_uri>
</object>
<object>
<id>2</id>
<name>foo2</name>
<resource_uri> blah </resource_uri>
</object>
</objects>
</response>
You could try overloading the "alter_list_data_to_serialize(...)" method of the Resource class. As the docstring says:
A hook to alter list data just before it gets serialized & sent to the user.
Useful for restructuring/renaming aspects of the what's going to be sent.
So that's the place when you change the "data" which soon after gets transformed into XML and sent to the user.
Something like this should get you going:
def alter_list_data_to_serialize(self, request, data):
#self.object_class.lower() is the name you'd like instead of "objects"
data = { self.object_class.lower() : [ element for element in data[ 'objects' ] ] }
return data
I haven't tested this, but I'm using this method to alter how my responses look succesfully.