Gtk 3.4 - Glade 3.4.0 - How to read the data of the second column of a combobox in C Language?

51 Views Asked by At

I apologize for my uncertain English but it is not my main language. I am new to Glade and I am trying to create a combobox that contains two data per row, one shown and one hidden. I can read the first one without problems with gtk_entry_get_text, while I don't know how to read the entry from the second column. How to do this?

With Glade I created this:


<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface>
  <requires lib="gtk+" version="3.24"/>
  <object class="GtkListStore" id="CB">
    <columns>
      <!-- column-name gchararray1 -->
      <column type="gchararray"/>
      <!-- column-name gchararray2 -->
      <column type="gchararray"/>
    </columns>
    <data>
      <row>
        <col id="0">First value</col>
        <col id="1" translatable="yes">0</col>
      </row>
      <row>
        <col id="0" translatable="yes">Second value</col>
        <col id="1" translatable="yes">0</col>
      </row>
      <row>
        <col id="0">Third value</col>
        <col id="1" translatable="yes">1</col>
      </row>
    </data>
    <signal name="row-changed" handler="on_CB_row_changed" swapped="no"/>
  </object>

        <child>
          <object class="GtkComboBox" id="C_C">
            <property name="width-request">300</property>
            <property name="height-request">35</property>
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <property name="tooltip-text" translatable="yes">This is a tooltip</property>
            <property name="model">CB</property>
            <property name="has-entry">True</property>
            <property name="entry-text-column">0</property>
            <property name="active-id">0</property>
            <signal name="changed" handler="on_C_C_changed" swapped="no"/>
            <child internal-child="entry">
              <object class="GtkEntry">
                <property name="can-focus">False</property>
              </object>
            </child>
          </object>
          <packing>
            <property name="x">100</property>
            <property name="y">225</property>
          </packing>
        </child>
 

And my very simple code is:

void on_C_C_changed (GtkEntry *e)
{
  char Buf[128];

  sprintf (Buf, "%s :: '%s'\n", __func__, gtk_entry_get_text (e));
  g_print (Buf);
} // on_C_C_Entry_changed

In this function I also want to read the second value to make more of it.

Thank you in advance for the answer.

0

There are 0 best solutions below