Dear friends,
My code looks like:
Code:
GtkWidget *entryAuth;
GtkWidget *entryEditor;
GtkWidget *entryTitle;
GtkWidget *entry1;
GtkWidget *combo;
typedef struct {
GtkWidget *combo, *entry1, *entryAuth, *entryEditor,*entryTitle;
} Entries;
static void
activate_func (GtkWidget *widget, gpointer data)
{
Entries *e = (Entries*) data;
const gchar *strcombo, *strkey, *strAuth, *strEditor, *strTitle;
strcombo = gtk_combo_box_get_active_text(GTK_COMBO_BOX(e->combo));
strkey = gtk_entry_get_text(GTK_ENTRY(e->entry1));
strAuth = gtk_entry_get_text(GTK_ENTRY(e->entryAuth));
strEditor = gtk_entry_get_text(GTK_ENTRY(e->entryEditor));
strTitle = gtk_entry_get_text(GTK_ENTRY(e->entryTitle));
g_print (strcombo);
g_print (strkey);
g_print (strAuth);
g_print (strEditor);
g_print (strTitle);
}
int main(int argc,
char *argv[]) {
Entries *e = g_slice_new (Entries);
/*****/
e->combo = gtk_combo_box_text_new();
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(e->combo), "Book");
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(e->combo), "Article");
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(e->combo), "Booklet");
e-> entryAuth = gtk_entry_new();
gtk_entry_set_placeholder_text (GTK_ENTRY (e->entryAuth), "Hostname");
e-> entryEditor = gtk_entry_new();
gtk_entry_set_placeholder_text(GTK_ENTRY(e->entryEditor), "Editor");
e-> entryTitle = gtk_entry_new();
gtk_entry_set_placeholder_text(GTK_ENTRY(e->entryTitle), "Title");
label = gtk_label_new("Authors/Title");
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), frame, label);
gtk_grid_attach (GTK_GRID (page1), e-> entryAuth, 0, 0, 1, 1);
gtk_grid_attach (GTK_GRID (page1), e->entryEditor, 0, 4, 1, 1);
gtk_grid_attach (GTK_GRID (page1), e-> entryTitle, 0, 8, 1, 1);
button = gtk_button_new_with_label("CREATE");
g_signal_connect (button, "clicked", G_CALLBACK (activate_func), e);
gtk_grid_attach (GTK_GRID (grid), e->combo, 0, 1, 1, 1);
gtk_grid_attach (GTK_GRID (grid), e->entry1, 1, 1, 1, 1);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
when I am trying to compile it, I am getting error:
$ gcc try_entry.c -o centry `pkg-config --cflags gtk+-3.0` `pkg-config --libs gtk+-3.0`
try_entry.c: In function ‘activate_func’:
try_entry.c:63:12: warning: assignment makes pointer from integer without a cast [enabled by default]
/tmp/ccDkMhTQ.o: In function `activate_func':
try_entry.c:(.text+0x3b): undefined reference to `gtk_combo_box_get_active_text'
collect2: error: ld returned 1 exit status
but if I put combo entry out of the activate_func and the structure, its running fine.
So, my question in how should I include a combo along with entry in a structure and extract the data?
Please reply.