hm.c File Reference

This program is to make a hangman game using GTK programming as an interface. More...

#include <string.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sqlite3.h>

Go to the source code of this file.

Defines

#define BUFFER   4096
#define MAX_IMAGES   8

Functions

static int callback (void *NotUsed, int argc, char **argv, char **azColName)
 Standard callback function used to display the results sqlite3.
void setup_tables ()
 This function sets up the database name and table.
void get_random_element (char *category)
 This function will return a random element from choosen category.
void enter_callback (GtkWidget *widget, GtkWidget *entry)
void playername_callback (GtkWidget *widget, GtkWidget *entry)
int update_entryText (char ch)
 This function will update the text entry.
void set_images (int wrongcount)
 This function will display and hide image depents on number of wrongcount.
void update_score (int score)
 This function will display and update score from text file scorefile.txt.
void win_or_loose (int res)
 This function will pop up a GAME OVER msg and YOU WON msg and change the hangman picture arcording to worgcount.
gint action_button_a (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'A' are clicked.
gint action_button_b (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'B' are clicked.
gint action_button_c (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'C' are clicked.
gint action_button_d (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'D' are clicked.
gint action_button_e (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'E' are clicked.
gint action_button_f (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'F' are clicked.
gint action_button_g (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'G' are clicked.
gint action_button_h (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'H' are clicked.
gint action_button_i (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'I' are clicked.
gint action_button_j (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'J' are clicked.
gint action_button_k (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'K' are clicked.
gint action_button_l (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'L' are clicked.
gint action_button_m (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'M' are clicked.
gint action_button_n (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'N' are clicked.
gint action_button_o (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'O' are clicked.
gint action_button_p (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'P' are clicked.
gint action_button_q (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'Q' are clicked.
gint action_button_r (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'R' are clicked.
gint action_button_s (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'S' are clicked.
gint action_button_t (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'T' are clicked.
gint action_button_u (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'U' are clicked.
gint action_button_v (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'V' are clicked.
gint action_button_w (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'W' are clicked.
gint action_button_x (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'X' are clicked.
gint action_button_y (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'Y' are clicked.
gint action_button_z (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'Z' are clicked.
gint popup_box (char *message)
gint action_button_country (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'country' are clicked.
gint action_button_animal (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'animal' are clicked.
gint action_button_fruit (GtkWidget *widget, GdkEvent *event, gpointer value)
 This funtion is taken action when 'fruit' are clicked.
int main (int argc, char *argv[])
 This is where program execution starts.

Variables

sqlite3 * db1
GtkWidget * window
GtkWidget * vbox
GtkWidget * entry
GtkWidget * table
GtkWidget * playername
GtkWidget * button [25]
GtkWidget * button1
GtkWidget * button2
GtkWidget * button3
GtkWidget * image
GtkWidget * image0
GtkWidget * image1
GtkWidget * image2
GtkWidget * image3
GtkWidget * image4
GtkWidget * image5
GtkWidget * image6
GtkWidget * label
GtkWidget * label1
GtkWidget * label2
GtkWidget * label3
GtkWidget * label4
GtkWidget * dialog
GtkWidget * dialog2
GtkWidget * dialog3
GtkWidget * dialog4
char randomname [10]
char randomcategory [2]
char showstring [10]
int wrongcount = 0
const gchar * entry_text
const gchar str [30]
const gchar * playername_text

Detailed Description

This program is to make a hangman game using GTK programming as an interface.

The program will use GtkWidget of GtkLabel, GtkImage, GtkButton, GtkEntry and GtkWindow to show the hangman game to user.

Author:
Nur Syahidah binti Azhari Effendi
Version:
1.0

Definition in file hm.c.


Define Documentation

#define BUFFER   4096

Definition at line 15 of file hm.c.

Referenced by get_random_element(), setup_tables(), and update_score().

#define MAX_IMAGES   8

Definition at line 16 of file hm.c.

Referenced by win_or_loose().


Function Documentation

gint action_button_a ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'A' are clicked.

Definition at line 362 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_animal ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'animal' are clicked.

Definition at line 949 of file hm.c.

References entry, get_random_element(), playername, popup_box(), randomcategory, randomname, set_images(), showstring, and wrongcount.

Referenced by main().

gint action_button_b ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'B' are clicked.

Definition at line 382 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_c ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'C' are clicked.

Definition at line 403 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_country ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'country' are clicked.

Definition at line 915 of file hm.c.

References entry, get_random_element(), playername, popup_box(), randomcategory, randomname, set_images(), showstring, and wrongcount.

Referenced by main().

gint action_button_d ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'D' are clicked.

Definition at line 424 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_e ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'E' are clicked.

Definition at line 445 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_f ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'F' are clicked.

Definition at line 466 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_fruit ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'fruit' are clicked.

Definition at line 986 of file hm.c.

References entry, get_random_element(), playername, popup_box(), randomcategory, randomname, set_images(), showstring, and wrongcount.

Referenced by main().

gint action_button_g ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'G' are clicked.

Definition at line 487 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_h ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'H' are clicked.

Definition at line 508 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_i ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'I' are clicked.

Definition at line 529 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_j ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'J' are clicked.

Definition at line 550 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_k ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'K' are clicked.

Definition at line 571 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_l ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'L' are clicked.

Definition at line 592 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_m ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'M' are clicked.

Definition at line 613 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_n ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'N' are clicked.

Definition at line 634 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_o ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'O' are clicked.

Definition at line 655 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_p ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'P' are clicked.

Definition at line 676 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_q ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'Q' are clicked.

Definition at line 697 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_r ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'R' are clicked.

Definition at line 718 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_s ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'S' are clicked.

Definition at line 739 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_t ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'T' are clicked.

Definition at line 760 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_u ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'U' are clicked.

Definition at line 781 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_v ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'V' are clicked.

Definition at line 801 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_w ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'W' are clicked.

Definition at line 822 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_x ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'X' are clicked.

Definition at line 843 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_y ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'Y' are clicked.

Definition at line 864 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

gint action_button_z ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  value 
)

This funtion is taken action when 'Z' are clicked.

Definition at line 885 of file hm.c.

References dialog, entry, update_entryText(), and win_or_loose().

Referenced by main().

static int callback ( void *  NotUsed,
int  argc,
char **  argv,
char **  azColName 
) [static]

Standard callback function used to display the results sqlite3.

Definition at line 63 of file hm.c.

References randomname.

Referenced by get_random_element(), and setup_tables().

void enter_callback ( GtkWidget *  widget,
GtkWidget *  entry 
)

Definition at line 118 of file hm.c.

References entry_text, and str.

Referenced by main().

void get_random_element ( char *  category  ) 

This function will return a random element from choosen category.

Definition at line 101 of file hm.c.

References BUFFER, callback(), and db1.

Referenced by action_button_animal(), action_button_country(), and action_button_fruit().

int main ( int  argc,
char *  argv[] 
)
void playername_callback ( GtkWidget *  widget,
GtkWidget *  entry 
)

Definition at line 126 of file hm.c.

References playername_text.

Referenced by main().

gint popup_box ( char *  message  ) 

Definition at line 902 of file hm.c.

References dialog.

Referenced by action_button_animal(), action_button_country(), and action_button_fruit().

void set_images ( int  wrongcount  ) 

This function will display and hide image depents on number of wrongcount.

Definition at line 156 of file hm.c.

References image0, image1, image2, image3, image4, image5, and image6.

Referenced by action_button_animal(), action_button_country(), action_button_fruit(), main(), and win_or_loose().

void setup_tables (  ) 

This function sets up the database name and table.

Definition at line 80 of file hm.c.

References BUFFER, callback(), and db1.

Referenced by main().

int update_entryText ( char  ch  ) 
void update_score ( int  score  ) 

This function will display and update score from text file scorefile.txt.

Definition at line 241 of file hm.c.

References BUFFER, label, and playername.

Referenced by win_or_loose().

void win_or_loose ( int  res  ) 

Variable Documentation

GtkWidget* button[25]

Definition at line 27 of file hm.c.

Referenced by main().

GtkWidget* button1

Definition at line 29 of file hm.c.

Referenced by main().

GtkWidget* button2

Definition at line 30 of file hm.c.

Referenced by main().

GtkWidget* button3

Definition at line 31 of file hm.c.

Referenced by main().

sqlite3* db1

Definition at line 18 of file hm.c.

Referenced by get_random_element(), and setup_tables().

GtkWidget* dialog
GtkWidget* dialog2

Definition at line 49 of file hm.c.

Referenced by win_or_loose().

GtkWidget* dialog3

Definition at line 50 of file hm.c.

Referenced by win_or_loose().

GtkWidget* dialog4

Definition at line 51 of file hm.c.

GtkWidget* entry
const gchar* entry_text

Definition at line 57 of file hm.c.

Referenced by enter_callback(), and main().

GtkWidget* image

Definition at line 33 of file hm.c.

Referenced by win_or_loose().

GtkWidget* image0

Definition at line 34 of file hm.c.

Referenced by main(), and set_images().

GtkWidget* image1

Definition at line 35 of file hm.c.

Referenced by main(), and set_images().

GtkWidget* image2

Definition at line 36 of file hm.c.

Referenced by main(), and set_images().

GtkWidget* image3

Definition at line 37 of file hm.c.

Referenced by main(), and set_images().

GtkWidget* image4

Definition at line 38 of file hm.c.

Referenced by main(), and set_images().

GtkWidget* image5

Definition at line 39 of file hm.c.

Referenced by main(), and set_images().

GtkWidget* image6

Definition at line 40 of file hm.c.

Referenced by main(), and set_images().

GtkWidget* label

Definition at line 42 of file hm.c.

Referenced by main(), and update_score().

GtkWidget* label1

Definition at line 43 of file hm.c.

Referenced by main().

GtkWidget* label2

Definition at line 44 of file hm.c.

Referenced by main().

GtkWidget* label3

Definition at line 45 of file hm.c.

Referenced by main().

GtkWidget* label4

Definition at line 46 of file hm.c.

Referenced by main().

GtkWidget* playername
const gchar * playername_text

Definition at line 57 of file hm.c.

Referenced by main(), and playername_callback().

char randomcategory[2]

Definition at line 54 of file hm.c.

Referenced by action_button_animal(), action_button_country(), and action_button_fruit().

char randomname[10]
char showstring[10]
const gchar str[30]

Definition at line 57 of file hm.c.

Referenced by enter_callback().

GtkWidget* table

Definition at line 23 of file hm.c.

Referenced by main().

GtkWidget* vbox

Definition at line 21 of file hm.c.

Referenced by main().

GtkWidget* window

Definition at line 20 of file hm.c.

Referenced by main().

int wrongcount = 0
Generated on Thu Apr 7 13:28:00 2011 for hangman by  doxygen 1.6.3