about libglade migration and combobox

Making & changing box plugins and external apps
Post Reply
matthieuG
Posts: 54
Joined: Thu Nov 12, 2009 10:22 am
Location: grenoble

about libglade migration and combobox

Post by matthieuG »

Hi,

To change a file.glade to a file.ui, I think "glade 3" (http://ftp.gnome.org/pub/GNOME/binaries ... lade3/3.6/ ) is a good way because they are both known...
So basically open a glade file and save it as ui file with gtkbuilder as option. It works fine but not in case of combobox:
La propriété « Éléments » de la classe d'objet « Boîte combinée » n'est prise en charge que dans le format libglade (or the property elements in combobox is accepted only in libglade format)

How to save combobox with elements? I saw sometime renderer in other example but I have never seen where text is!! It is possible to have some help here?!

Thanks

EDIT : http://www.youtube.com/watch?v=Z5_F-rW2cL8

bpayan
Posts: 46
Joined: Fri Jan 08, 2010 4:02 pm

Re: about libglade migration and combobox

Post by bpayan »

Hello matthieuG,

For the combo box, in your file .ui, you can make a GtkListStore who contains your elements, like this:

Code: Select all

<object class="GtkListStore" id="model2">
  <columns>
    <!-- column-name gchararray -->
    <column type="gchararray"/>
  </columns>
  <data>
    <row>
      <col id="0" translatable="yes">128</col>
    </row>
    <row>
      <col id="0" translatable="yes">256</col>
    </row>
    <row>
      <col id="0" translatable="yes">512</col>
    </row>
    <row>
      <col id="0" translatable="yes">1024</col>
    </row>
    <row>
      <col id="0" translatable="yes">2048</col>
    </row>
    <row>
      <col id="0" translatable="yes">4096</col>
    </row>
  </data>
</object>
Create your combo box and change the property "model" for using your GtkListStore, like this:

Code: Select all

<object class="GtkComboBox" id="combobox_sampling_frequency">
  <property name="visible">True</property>
  <property name="model">model2</property>
  <child>
    <object class="GtkCellRendererText" id="renderer2"/>
    <attributes>
      <attribute name="text">0</attribute>
    </attributes>
  </child>
</object>
If you want change your elements dynamically, you can use these methods in your file .cpp:

Code: Select all

::GtkComboBox* l_pComboBox=GTK_COMBO_BOX(gtk_builder_get_object(m_pBuilderConfigureInterface, "combobox_sampling_frequency"));

::GtkListStore* l_pListStoreComboBox= GTK_LIST_STORE(gtk_combo_box_get_model(l_pComboBox));

GtkTreeIter iter;

gtk_list_store_append(l_pListStoreComboBox,&iter);

gtk_list_store_set (l_pListStoreComboBox, &iter,0,"new element",-1);
I hope this helps.

Baptiste

matthieuG
Posts: 54
Joined: Thu Nov 12, 2009 10:22 am
Location: grenoble

Re: about libglade migration and combobox

Post by matthieuG »

Thanks for this answer. However it doesn't work :

[model2] La propriété « Colonnes » de la classe d'objet « Stockage de liste » a été introduite dans gtk+ 2.12
[model2] La propriété « Données » de la classe d'objet « Stockage de liste » a été introduite dans gtk+ 2.12
(or property "column" of listStore is used after gtk+ 2.12. Idem for "data")
I have exactly the same error message with the direct glade interface as in the video.
Any clues?! :cry:

EDIT: I put version preferences to 2.12 to correct this point; 2.16 seems to be too much :rool:

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: about libglade migration and combobox

Post by yrenard »

Dear Matthieu,

what problem are you facing with 2.16 ?

Yann

Post Reply