#include <glib.h>
#include <gtk/gtk.h>
#include <iostream>
using namespace std;
#ifndef CONNECT4MENU_H
#define CONNECT4MENU_H
static gboolean deleteEvent( GtkWidget *widget, GdkEvent *event, gpointer data);
static int startGame(GtkWidget *widget, GdkEvent *event, gpointer data);
static int gui();
GtkWidget *window;
GtkWidget *button;
GtkWidget *button2;
GtkWidget *button3;
GtkWidget *button4;
GtkWidget *button5;
GtkWidget *button6;
GtkWidget *box1;
GtkWidget *box2;
GtkWidget *box3;
GtkWidget *box4;
GtkWidget *box5;
GtkWidget *box6;
GSList *group;
GSList *group2;
int gamet = 0;
static int gui()
{
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(deleteEvent), NULL);
box3 = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(window), box3);
gtk_widget_show(box3);
box1 = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(box3), box1);
gtk_widget_show(box1);
button = gtk_radio_button_new_with_label(NULL, "1 Player");
gtk_box_pack_start(GTK_BOX(box1), button, TRUE, TRUE, 0);
gtk_widget_show(button);
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
button2 = gtk_radio_button_new_with_label(group, "2 Player");
gtk_box_pack_start(GTK_BOX(box1), button2, TRUE, TRUE, 0);
gtk_widget_show(button2);
box4 = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(box3), box4);
gtk_widget_show(box4);
box2 = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(box4), box2);
gtk_widget_show(box2);
button3 = gtk_radio_button_new_with_label(NULL, "Easy");
gtk_box_pack_start(GTK_BOX(box2), button3, TRUE, TRUE, 0);
gtk_widget_show(button3);
group2 = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button3));
button4 = gtk_radio_button_new_with_label(group2, "Medium");
gtk_box_pack_start(GTK_BOX(box2), button4, TRUE, TRUE, 0);
gtk_widget_show(button4);
group2 = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button4));
button5 = gtk_radio_button_new_with_label(group2, "Expert");
gtk_box_pack_start(GTK_BOX(box2), button5, TRUE, TRUE, 0);
gtk_widget_show(button5);
box5 = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(box4), box5);
gtk_widget_show(box5);
button6 = gtk_button_new_with_label ("Start Game");
g_signal_connect (G_OBJECT (button6), "clicked", G_CALLBACK (startGame), NULL);
gtk_box_pack_start(GTK_BOX (box5), button6, TRUE, TRUE, 0);
gtk_widget_show(button6);
gtk_widget_show(window);
gtk_main();
}
static gboolean deleteEvent(GtkWidget *widget, GdkEvent *event, gpointer data)
{
gtk_main_quit();
return FALSE;
}
static int startGame(GtkWidget *widget, GdkEvent *event, gpointer data)
{
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
{
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button3)))
{
gamet = 1;
gtk_main_quit();
}
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button4)))
{
gamet = 2;
gtk_main_quit();
}
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button5)))
{
gamet = 3;
gtk_main_quit();
}
}
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button2)))
{
gamet = 4;
gtk_main_quit();
}
}
#endif
The error I get when I try to compile this is:
connect4menu2.h: In member function 'void menu::gui()':
connect4menu2.h:46: error: invalid use of member (did you forget the '&' ?)
connect4menu2.h:96: error: invalid use of member (did you forget the '&' ?)
I cannot understand why I can't call startGame and deleteEvent from gui.
Does anybody know why I am getting this error