Hi everyone,
I have a combo box in which there are a few words. I am trying to build a menu option that will generate a LaTeX file with those words, that can then be compiled to produce PDF output. For that, I need to first obtain the list of words that already in the combo box.
I checked the DevHelp documentation thoroughly; in particular, I looked at the sample programmes in the section on GtkTreeModel. The sample given there is almost exactly what I am doing here. (The only difference is that in the sample programme a new tree model is built explicitly, whereas in my code below, I am obtaining the tree model from the combo box known as WordListComboBox.) Note: The code below shows only the relevant portion.
I am at a total loss as to why the following code will not work:
Code:
void on_generate_tex_activate (GtkMenuItem *menuitem, gpointer user_data)
{
GtkTreeModel *TreeModel;
GtkTreeIter Iter;
gboolean Valid;
TreeModel = gtk_combo_box_get_model(GTK_COMBO_BOX(lookup_widget(GTK_WIDGET(menuitem), "WordListComboBox")));
Valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(TreeModel), &Iter);
while(Valid) {
gchar Word[65];
gint i;
for(i = 0; i < 65; i++) {
Word[i] = '\0';
} /* End for(i) */
gtk_tree_model_get(GTK_TREE_MODEL(TreeModel), &Iter, 0, &Word[0], -1);
g_print("%s\n", &Word[0]);
Valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(TreeModel), &Iter);
} /* End while() */
}
When I run the programme and activate the menu option, instead of seeing the words in the combo box echoed in the terminal, I get strange characters. However, the number of lines of strange characters always matches the number of words in currently in the combo box.
Can someone please tell me what I am doing incorrectly? Instead of output like:
word_1
word_2
word_3
why do I see:
..P
*Q>
>V,
Thanks in advance for your help.