GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Apr 16, 2014 7:29 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [Solved] blank lines in combobox
PostPosted: Mon Sep 14, 2009 3:07 am 
I'm stuck again, this time I need to preload groups data from a config file into several comboboxen with the first of each group being the default for that box but I end up with a blank line displayed instead.

I'm using glade-3 to layout the interface.

I also need to place the values collected into this struct
Code:
struct login_data
{
   char logname[127];      /* the yahoo ID we are using */
   char passwd[64];      /* our password in plain text */
   char server[128];      /* server we are connecting to */
   char port[7];         /* port */
   char room[128];         /* name of chat room */
   int  invisible;         /* are we logging in invsisble */
   int    noroom;         /* are we entering a room */
} login_data;


Code:
void on_connect_activate(GtkMenuItem *menuitem, gpointer user_data)
{
   /* Get the nameentry box from the GtkBuilder... */
    nameentry = GTK_WIDGET(gtk_builder_get_object(builder, "nameentry"));
   
    /* ...and set it up with a GtkListStore and GtkCellRenderer */
    set_up_combobox(nameentry);

   /* Since we set up our combo box the same way as _new_text does, we can use the _text functions */
   this_item = login_list;
   while(this_item)
   {
      gtk_combo_box_append_text(GTK_COMBO_BOX(nameentry), (char *)this_item->data);
      this_item = g_list_next(this_item);
   }
   
   if(remember_password)
   {
      passwdentry = GTK_WIDGET(gtk_builder_get_object(builder, "passwdentry"));
      gtk_entry_set_text(GTK_ENTRY(passwdentry), password);
   }

   /* Get the serverentry box from the GtkBuilder... */
    serverentry = GTK_WIDGET(gtk_builder_get_object(builder, "serverentry"));
    set_up_combobox(serverentry);
   this_item = server_list;
   while(this_item)
   {
      gtk_combo_box_append_text(GTK_COMBO_BOX(serverentry), (char *)this_item->data);
      this_item = g_list_next(this_item);
   }
   
   /* Get the roomentry box from the GtkBuilder... */
    roomentry = GTK_WIDGET(gtk_builder_get_object(builder, "roomentry"));
    set_up_combobox(roomentry);
   this_item = favroom_list;
   while(this_item)
   {
      gtk_combo_box_append_text(GTK_COMBO_BOX(roomentry), (char *)this_item->data);
      this_item = g_list_next(this_item);
   }
   
   /* Get the portentry box from the GtkBuilder... */
    portentry = GTK_WIDGET(gtk_builder_get_object(builder, "portentry"));
    set_up_combobox(portentry);
   this_item = port_list;
   while(this_item)
   {
      gtk_combo_box_append_text(GTK_COMBO_BOX(portentry), (char *)this_item->data);
      this_item = g_list_next(this_item);
   }

    invisiblebutton = GTK_WIDGET(gtk_builder_get_object(builder, "invisiblebutton"));
   if(login_invisible)
   {
      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(invisiblebutton), TRUE);
   }
   
    noroombutton = GTK_WIDGET(gtk_builder_get_object(builder, "noroombutton"));
   if(login_noroom)
   {
      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(noroombutton), TRUE);
   }
   
   /* got the box set up so show the bastard */
   gtk_widget_show_all(logindialog);
}


Code:
  <object class="GtkDialog" id="logindialog">
    <property name="border_width">5</property>
    <property name="title" translatable="yes">Chimp - Login</property>
    <property name="destroy_with_parent">True</property>
    <property name="type_hint">normal</property>
    <property name="has_separator">False</property>
    <signal handler="gtk_widget_destroy" name="destroy"/>
    <child internal-child="vbox">
      <object class="GtkVBox" id="dialog-vbox1">
        <property name="visible">True</property>
        <property name="orientation">vertical</property>
        <property name="spacing">2</property>
        <child>
          <object class="GtkHBox" id="hbox1">
            <property name="visible">True</property>
            <child>
              <object class="GtkImage" id="image2">
                <property name="visible">True</property>
                <property name="pixbuf">pixmaps/chimpkwondo.xpm</property>
              </object>
              <packing>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkVBox" id="vbox2">
                <property name="visible">True</property>
                <property name="orientation">vertical</property>
                <child>
                  <object class="GtkLabel" id="label6">
                    <property name="visible">True</property>
                    <property name="label" translatable="yes">Enter Login Information</property>
                  </object>
                  <packing>
                    <property name="position">0</property>
                  </packing>
                </child>
                <child>
                  <object class="GtkTable" id="table1">
                    <property name="visible">True</property>
                    <property name="n_rows">6</property>
                    <property name="n_columns">2</property>
                    <child>
                      <object class="GtkLabel" id="label1">
                        <property name="visible">True</property>
                        <property name="label" translatable="yes">Username:</property>
                      </object>
                    </child>
                    <child>
                      <object class="GtkComboBoxEntry" id="nameentry">
                        <property name="visible">True</property>
                        <property name="app_paintable">True</property>
                        <property name="can_focus">True</property>
                        <property name="active">0</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkEntry" id="passwdentry">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="visibility">False</property>
                        <property name="invisible_char">●</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                        <property name="top_attach">1</property>
                        <property name="bottom_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkLabel" id="label2">
                        <property name="visible">True</property>
                        <property name="label" translatable="yes">Password:</property>
                      </object>
                      <packing>
                        <property name="top_attach">1</property>
                        <property name="bottom_attach">2</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkLabel" id="label3">
                        <property name="visible">True</property>
                        <property name="label" translatable="yes">Room:</property>
                      </object>
                      <packing>
                        <property name="top_attach">2</property>
                        <property name="bottom_attach">3</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkComboBoxEntry" id="roomentry">
                        <property name="visible">True</property>
                        <property name="model">model1</property>
                        <child>
                          <object class="GtkCellRendererText" id="renderer1"/>
                          <attributes>
                            <attribute name="text">0</attribute>
                          </attributes>
                        </child>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                        <property name="top_attach">2</property>
                        <property name="bottom_attach">3</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkLabel" id="label4">
                        <property name="visible">True</property>
                        <property name="label" translatable="yes">Server:</property>
                      </object>
                      <packing>
                        <property name="top_attach">3</property>
                        <property name="bottom_attach">4</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkLabel" id="label7">
                        <property name="visible">True</property>
                        <property name="label" translatable="yes">Port:</property>
                      </object>
                      <packing>
                        <property name="top_attach">4</property>
                        <property name="bottom_attach">5</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkToggleButton" id="invisiblebutton">
                        <property name="label" translatable="yes">Login invisible</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <property name="draw_indicator">True</property>
                        <signal handler="on_invisiblebutton_toggled" name="toggled"/>
                      </object>
                      <packing>
                        <property name="top_attach">5</property>
                        <property name="bottom_attach">6</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkToggleButton" id="noroombutton">
                        <property name="label" translatable="yes">Dont enter Room</property>
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="receives_default">True</property>
                        <property name="draw_indicator">True</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                        <property name="top_attach">5</property>
                        <property name="bottom_attach">6</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkComboBoxEntry" id="serverentry">
                        <property name="visible">True</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                        <property name="top_attach">3</property>
                        <property name="bottom_attach">4</property>
                      </packing>
                    </child>
                    <child>
                      <object class="GtkComboBoxEntry" id="portentry">
                        <property name="visible">True</property>
                      </object>
                      <packing>
                        <property name="left_attach">1</property>
                        <property name="right_attach">2</property>
                        <property name="top_attach">4</property>
                        <property name="bottom_attach">5</property>
                      </packing>
                    </child>
                  </object>
                  <packing>
                    <property name="position">1</property>
                  </packing>
                </child>
              </object>
              <packing>
                <property name="position">1</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="position">1</property>
          </packing>
        </child>
        <child internal-child="action_area">
          <object class="GtkHButtonBox" id="dialog-action_area1">
            <property name="visible">True</property>
            <property name="layout_style">end</property>
            <child>
              <object class="GtkButton" id="loginbutton">
                <property name="label" translatable="yes">Login</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <signal handler="on_loginbutton_clicked" name="clicked"/>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">False</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="panicbutton">
                <property name="label" translatable="yes">Panic</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <signal handler="on_panicbutton_clicked" name="clicked"/>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">False</property>
                <property name="position">1</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="pack_type">end</property>
            <property name="position">0</property>
          </packing>
        </child>
      </object>
    </child>
  </object>


All help and/or guidance welcome.


Last edited by Cheifchimp on Wed Sep 16, 2009 5:39 am, edited 1 time in total.

Top
  
 
 Post subject:
PostPosted: Mon Sep 14, 2009 6:24 am 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hi.

I thunk that after creating combo box, calling gtk_combo_box_set_active with 0 as a second parameter should do the trick.

Tadej


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 14, 2009 6:43 am 
Once again you leap to the aid of a poor novice, may your god record it in his/her ledger.

Mik


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group