birthday_reminder.c File Reference

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

Go to the source code of this file.

Enumerations

enum  { COL_NAME = 0, COL_BIRTH, COL_EMAIL, NUM_COLS }
enum  { NEW_COL_STRING = 0, NEW_COL_EMAIL, NEW_NUM_COLS }

Functions

static GtkWidget * create_view (void)
 This function creates the view in which records will be shown.
static GtkTreeModel * create_model ()
 This function is used to create the model in which we will show the records.
void fill_model (GtkTreeModel *model, char *name, char *bdate, char *email)
 This function fill the model with records.
void callback_action_add (GtkWidget *widget, GtkTreeView *view)
 This function acts as callback function for add button in the main window which opens a window to add a new record.
void callback_add_record (GtkWidget *widget, GtkTreeView *view)
 This function acts as callback function for save button of add window.
void callback_action_edit (GtkWidget *widget, GtkTreeView *view)
 This function acts as callback function for edit button in the main window which opens a window to edit selected record.
void callback_edit_record (GtkWidget *widget, GtkTreeView *view)
 This function acts as callback function for save button in the edit record window.
void callback_action_delete (GtkWidget *widget, GtkTreeView *view)
 This function acts as callback function for delete button in the main window.
void window_destroy (GtkWidget *widget, gpointer data)
 This function acts as callback function for add and edit window.
int row_selected (GtkTreeView *view)
 This function fetches the selected record from the main window to edit or delete.
void callback_rowselected (GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
 This function is invoked by row activated signal.
int callback_generate (GtkWidget *btn, gpointer data)
 This function acts as callback function for generate button in main window which generate csv file of all records.
static int callback_csv (void *filePointer, int argc, char **argv, char **azColName)
 This function acts as callback function for query exicuted in callback_generate and writes the records in csv file.
int callback_upload (GtkWidget *widget1, GtkTreeView *view)
 This function acts as callback function for upload button in main window which uploads csv file of all records.
void callback_email (GtkWidget *widget, GtkTreeView *second_view)
 This function acts as callback function for email button in starting window.
int mail_row_selected (GtkTreeView *view)
 This function fetches the mail id of the selected record.
int listwindow ()
 This function generates the upcoming birthday list.
void callback_quit (GtkWidget *widget, gpointer data)
 This function acts as callback function for quitting window and shows the main window on clicking.
void exit_program (GtkWidget *widget, gpointer data)
 This function exits from program.
static GtkWidget * create_second_view (void)
 This function view for the window showing upcoming birthdays.
static GtkTreeModel * create_second_model ()
 This function is to create the model for start window which shows the upcoming birthdays.
void fill_second_model (GtkTreeModel *second_model, char *str, char *email)
 This function is used to populate the upcoming birthdays window.
void main_window_destroy (GtkWidget *widget, gpointer data)
 This function destroys the main window on closing and stores the days in advance and days after event.
void parameters (int days_after_event, int days_in_advance, int s)
 This function stores the days in advance and days after event.
int ReadParameters ()
 This function sets the value of parameters.
static int callback_parameters (void *NotUsed, int argc, char **argv, char **azColName)
 This function acts as callback function for query to store records in parameters_tbl.
void check_button_callback (GtkWidget *widget, gpointer data)
 This function acts as callback function of toggling of check button for startup run in main window.
int AddRecords (char *name, char *bdate, char *eid)
 This function is used to store the birthday records in sqlite database.
int EditRecords (char *oname, char *name, char *bdate, char *eid)
 This function is used to edit the birthday records in sqlite database.
int DeleteRecords (char *name)
 This function is used to delete the birthday record in sqlite database.
int ReadRecords ()
static int sql_callback (void *second_model, int argc, char **argv, char **azColName)
 This function checks upcoming and recently past birthdays from database and show it in the window.
int con_to_sql (char *qry)
 This function connects to the database and executes the qyery and load its results to the main window.
int LoadRecords (GtkTreeModel *model)
 This function loads records from the database to the window.It also checks whether database exists or not if not then it also creates the database.
static int sql_callback_load (void *model, int argc, char **argv, char **azColName)
 This function acts as callback function for load_sql.
int load_sql (GtkTreeModel *model, char *qry, int flag)
 This function loads the records from database to model.
int ReadRecords (GtkTreeModel *second_model)
 This function is used to populate the list of upcoming and recently past birthdays.
int isLeapYear (int year)
 This function checks whether given year is leap year or not.
int main (int argc, char *argv[])
 This is main function which shows main window and calls upcoming birthday window.

Variables

GtkWidget * btn_new
GtkWidget * btn_edit
GtkWidget * btn_delete
GtkWidget * add_window
GtkWidget * edit_window
GtkWidget * entry_name
GtkWidget * entry_email
GtkWidget * edit_entry_name
GtkWidget * edit_entry_email
GtkWidget * combo_date
GtkWidget * combo_month
GtkWidget * combo_year
GtkWidget * edit_combo_date
GtkWidget * edit_combo_month
GtkWidget * edit_combo_year
GtkWidget * spin_pdays
GtkWidget * spin_adays
gchar * clicked_name
gchar * clicked_dob
gchar * clicked_email
gchar * replaced_name
gchar * mail_clicked_email
int day_in_advance
int day_after_event
int flag_listwindow
int startup

Enumeration Type Documentation

anonymous enum
Enumerator:
COL_NAME 
COL_BIRTH 
COL_EMAIL 
NUM_COLS 

Definition at line 522 of file birthday_reminder.c.

00523 {
00524     COL_NAME = 0,
00525     COL_BIRTH,
00526     COL_EMAIL,
00527     NUM_COLS
00528 } ;

anonymous enum
Enumerator:
NEW_COL_STRING 
NEW_COL_EMAIL 
NEW_NUM_COLS 

Definition at line 1144 of file birthday_reminder.c.

01145 {
01146     NEW_COL_STRING = 0,
01147     NEW_COL_EMAIL,
01148     NEW_NUM_COLS
01149 };


Function Documentation

int AddRecords ( char *  name,
char *  bdate,
char *  eid 
)

This function is used to store the birthday records in sqlite database.

Parameters:
name is stores the name
bdate stores the date of birth/ anniversary
eid stores the email id of the person
Returns:
0 on success

Definition at line 92 of file birthday_reminder.c.

References con_to_sql().

Referenced by callback_add_record(), and callback_upload().

00093 {
00094     char qry[1024];         
00095     
00096     bzero(qry,1024);        
00097     sprintf(qry , "insert into birthday_tbl values ('%s', '%s', '%s')", name, bdate, eid);
00098     con_to_sql(qry);
00099 
00100     //fprintf(stdout,"\nRecord added successfully!\n");
00101 
00102     return(0);
00103 }

void callback_action_add ( GtkWidget *  widget,
GtkTreeView *  view 
)

This function acts as callback function for add button in the main window which opens a window to add a new record.

Parameters:
widget is the button for which function is called
view is the view to be filled
Returns:
void

Definition at line 609 of file birthday_reminder.c.

References add_window, callback_add_record(), combo_date, combo_month, combo_year, entry_email, entry_name, and window_destroy().

Referenced by main().

00610 {
00611     // disabling add button after first click
00612     gtk_widget_set_sensitive(widget,FALSE); 
00613 
00614 
00615     GtkWidget *table;
00616     GtkWidget *button_save,*button_cancel;
00617     GtkWidget *lbl_name,*lbl_heading,*lbl_bday,*lbl_email;
00618     
00619     int i;
00620 //Initialize window and it's attributes
00621     //gtk_init(&argc, &argv);
00622 
00623     add_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
00624     gtk_window_set_position((GtkWindow *)add_window, GTK_WIN_POS_CENTER);
00625     gtk_window_set_title(GTK_WINDOW(add_window), "**ADD New Record**");
00626     gtk_window_set_default_size(GTK_WINDOW(add_window),300,150);
00627     gtk_container_set_border_width(GTK_CONTAINER(add_window),20);
00628 
00629     /* Create a 5x4 table */
00630     table = gtk_table_new (5, 4, TRUE);
00631 
00632     /* Put the table in the main window */
00633     gtk_container_add (GTK_CONTAINER (add_window), table);
00634 
00635     lbl_heading=gtk_label_new("Add New Record");
00636     gtk_table_attach_defaults (GTK_TABLE(table), lbl_heading, 0, 4, 0, 1);
00637 
00638     lbl_name=gtk_label_new("Name*");
00639     gtk_table_attach_defaults (GTK_TABLE(table), lbl_name, 0, 1, 1, 2);
00640 
00641     entry_name =  gtk_entry_new();  
00642     gtk_table_attach_defaults (GTK_TABLE(table), entry_name, 1, 4, 1, 2);
00643 
00644     lbl_bday=gtk_label_new("Birth Date*");
00645     gtk_table_attach_defaults (GTK_TABLE(table), lbl_bday, 0, 1, 2, 3);
00646         
00647     char temp[10];
00648     
00649     // adding month in combo box
00650     combo_month = gtk_combo_box_new_text();
00651 
00652     sprintf(temp,"MM");
00653     gtk_combo_box_append_text(GTK_COMBO_BOX (combo_month),temp);
00654 
00655     for(i=1;i<=12;i++)
00656     {
00657         if(i <= 9)
00658         {
00659             sprintf(temp,"0%d",i);
00660         }
00661         else
00662         {       
00663             sprintf(temp,"%d",i);
00664         }
00665         gtk_combo_box_append_text(GTK_COMBO_BOX (combo_month),temp);
00666     
00667     }
00668 
00669     gtk_combo_box_set_active(GTK_COMBO_BOX(combo_month ),0);    
00670       //  gtk_combo_set_popdown_strings (GTK_COMBO (combo_month), items);
00671     
00672     gtk_table_attach_defaults (GTK_TABLE(table), combo_month, 1, 2, 2, 3);
00673 
00674     // adding date in combo box
00675     combo_date = gtk_combo_box_new_text();
00676     sprintf(temp,"DD");
00677     gtk_combo_box_append_text(GTK_COMBO_BOX (combo_date),temp);
00678     for(i=1;i<=31;i++)
00679     {
00680         if(i <= 9)
00681         {
00682             sprintf(temp,"0%d",i);
00683         }
00684         else
00685         {       
00686             sprintf(temp,"%d",i);
00687         }
00688         gtk_combo_box_append_text(GTK_COMBO_BOX (combo_date),temp);
00689     }    
00690 
00691     gtk_combo_box_set_active(GTK_COMBO_BOX(combo_date),0);
00692       //gtk_combo_set_popdown_strings (GTK_COMBO (combo_date), items);
00693     
00694     gtk_table_attach_defaults (GTK_TABLE(table), combo_date, 2, 3, 2, 3);
00695     
00696     
00697     
00698     // adding year in combo box
00699     combo_year = gtk_combo_box_new_text();
00700     sprintf(temp,"YYYY");
00701     gtk_combo_box_append_text(GTK_COMBO_BOX (combo_year),temp);
00702     for(i=1950;i<=2050;i++)
00703     {
00704         sprintf(temp,"%d",i);
00705         //items = g_list_append (items, temp);
00706         gtk_combo_box_append_text(GTK_COMBO_BOX (combo_year),temp);
00707     
00708     }  
00709 
00710     gtk_combo_box_set_active(GTK_COMBO_BOX(combo_year),0);    
00711       //gtk_combo_set_popdown_strings (GTK_COMBO (combo_year), items);
00712     
00713     gtk_table_attach_defaults (GTK_TABLE(table), combo_year, 3, 4, 2, 3);
00714     
00715     
00716     lbl_email=gtk_label_new("Email Address");
00717     gtk_table_attach_defaults (GTK_TABLE(table), lbl_email, 0, 1, 3, 4);
00718     
00719     entry_email =  gtk_entry_new(); 
00720     gtk_table_attach_defaults (GTK_TABLE(table), entry_email, 1, 4, 3, 4);
00721     
00722     button_save = gtk_button_new_with_label ("Save");
00723     g_signal_connect(G_OBJECT(button_save),"clicked",G_CALLBACK(callback_add_record) , view);
00724         gtk_table_attach_defaults (GTK_TABLE(table), button_save, 0, 2, 4, 5);
00725         
00726 
00727     button_cancel = gtk_button_new_with_label ("Cancel");
00728         g_signal_connect_swapped(G_OBJECT(button_cancel), "clicked", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(add_window));
00729     gtk_table_attach_defaults (GTK_TABLE(table), button_cancel, 2, 4, 4, 5);
00730         
00731     //Handling Events
00732     g_signal_connect(G_OBJECT(add_window),"destroy",G_CALLBACK(window_destroy),NULL);
00733     
00734     //Displaying Window
00735     gtk_widget_show_all(add_window);
00736     gtk_main();
00737 
00738 }

void callback_action_delete ( GtkWidget *  widget,
GtkTreeView *  view 
)

This function acts as callback function for delete button in the main window.

Parameters:
widget is the button for which function is called
view is the view to be filled
Returns:
void

Definition at line 1025 of file birthday_reminder.c.

References clicked_name, DeleteRecords(), LoadRecords(), and row_selected().

Referenced by main().

01026 {
01027     //Function Calls For Getting Clicked attribute's Values
01028 
01029     int res;
01030 
01031     res = row_selected(view);
01032     if(res)
01033     {
01034         return;
01035     }
01036     
01037     GtkWidget *dialog;
01038     gint response;
01039 
01040     dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Delete %s's Record! Are You Sure?", clicked_name);
01041     gtk_window_set_title(GTK_WINDOW(dialog), "Confirm Delete");
01042     
01043     response = gtk_dialog_run(GTK_DIALOG(dialog));
01044     gtk_widget_destroy(dialog);
01045 
01046     if(response == GTK_RESPONSE_YES)
01047     {
01048         DeleteRecords(clicked_name);
01049         gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(view)));
01050         LoadRecords(gtk_tree_view_get_model(view));
01051     }
01052     //clicked_name = NULL;
01053     //clicked_dob = NULL;
01054     //clicked_email = NULL;
01055 }

void callback_action_edit ( GtkWidget *  widget,
GtkTreeView *  view 
)

This function acts as callback function for edit button in the main window which opens a window to edit selected record.

Parameters:
widget is the button for which function is called
view is the view to be filled
Returns:
void

Definition at line 802 of file birthday_reminder.c.

References callback_edit_record(), clicked_dob, clicked_email, clicked_name, edit_combo_date, edit_combo_month, edit_combo_year, edit_entry_email, edit_entry_name, edit_window, row_selected(), and window_destroy().

Referenced by callback_rowselected(), and main().

00803 {
00804     //Function Calls For Getting Clicked attribute's Values 
00805 
00806     int res;
00807 
00808     res = row_selected(view);
00809     if(res)
00810     {
00811         return;
00812     }
00813 
00814     // disabling edit button after first click
00815     gtk_widget_set_sensitive(widget,FALSE);
00816 
00817     GtkWidget *table;
00818     GtkWidget *button_save,*button_cancel;
00819     GtkWidget *lbl_name,*lbl_heading,*lbl_bday,*lbl_email;
00820     
00821     int i;
00822 //Initialize window and it's attributes
00823     //gtk_init(&argc, &argv);
00824 
00825     edit_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
00826     gtk_window_set_position((GtkWindow *)edit_window, GTK_WIN_POS_CENTER);
00827     gtk_window_set_title(GTK_WINDOW(edit_window), "**EDIT Record**");
00828     gtk_window_set_default_size(GTK_WINDOW(edit_window),300,150);
00829     gtk_container_set_border_width(GTK_CONTAINER(edit_window),20);
00830 
00831     /* Create a 5x4 table */
00832     table = gtk_table_new (5, 4, TRUE);
00833 
00834     /* Put the table in the main window */
00835     gtk_container_add (GTK_CONTAINER (edit_window), table);
00836 
00837     lbl_heading=gtk_label_new("Edit This Record");
00838     gtk_table_attach_defaults (GTK_TABLE(table), lbl_heading, 0, 4, 0, 1);
00839 
00840     lbl_name=gtk_label_new("Name*");
00841     gtk_table_attach_defaults (GTK_TABLE(table), lbl_name, 0, 1, 1, 2);
00842 
00843     edit_entry_name =  gtk_entry_new();
00844     gtk_entry_set_text(GTK_ENTRY(edit_entry_name), clicked_name);   
00845     gtk_table_attach_defaults (GTK_TABLE(table), edit_entry_name, 1, 4, 1, 2);
00846 
00847     lbl_bday=gtk_label_new("Birth Date*");
00848     gtk_table_attach_defaults (GTK_TABLE(table), lbl_bday, 0, 1, 2, 3);
00849     
00850     char *pch,mm[5],dd[5],yy[10];
00851     int count = 0;
00852 
00853     strcpy(mm ,"0");
00854     strcpy(dd ,"0");
00855     strcpy(yy ,"0");
00856 
00857     if(clicked_dob != NULL)
00858     {
00859          pch = strtok (clicked_dob,"-");
00860          while (pch != NULL)
00861         {
00862             if(count == 0)
00863             {
00864                 strcpy(mm,pch);             
00865             }
00866             if(count == 1)
00867             {
00868                 strcpy(dd,pch);                 
00869             }
00870             if(count == 2)
00871             {
00872                 strcpy(yy,pch);                         
00873             }
00874                 pch = strtok (NULL, "-");
00875                 count++;    
00876          }
00877     }   
00878     
00879     char temp[10];
00880     
00881     // adding month in combo box
00882     edit_combo_month = gtk_combo_box_new_text();
00883     sprintf(temp,"MM");
00884     gtk_combo_box_append_text(GTK_COMBO_BOX (edit_combo_month),temp);
00885 
00886     for(i=1;i<=12;i++)
00887     {
00888         if(i <= 9)
00889         {
00890             sprintf(temp,"0%d",i);
00891         }
00892         else
00893         {       
00894             sprintf(temp,"%d",i);
00895         }
00896         gtk_combo_box_append_text(GTK_COMBO_BOX (edit_combo_month),temp);
00897     
00898     }    
00899 
00900     gtk_combo_box_set_active(GTK_COMBO_BOX(edit_combo_month ),atoi(mm));
00901     gtk_table_attach_defaults (GTK_TABLE(table), edit_combo_month, 1, 2, 2, 3);
00902     
00903     // adding date in combo box
00904     edit_combo_date = gtk_combo_box_new_text();
00905     sprintf(temp,"MM");
00906     gtk_combo_box_append_text(GTK_COMBO_BOX (edit_combo_date),temp);
00907 
00908     for(i=1;i<=31;i++)
00909     {
00910         if(i <= 9)
00911         {
00912             sprintf(temp,"0%d",i);
00913         }
00914         else
00915         {       
00916             sprintf(temp,"%d",i);
00917         }
00918         gtk_combo_box_append_text(GTK_COMBO_BOX (edit_combo_date),temp);
00919     } 
00920 
00921     gtk_combo_box_set_active(GTK_COMBO_BOX(edit_combo_date ),atoi(dd));
00922     gtk_table_attach_defaults (GTK_TABLE(table), edit_combo_date, 2, 3, 2, 3);
00923 
00924     // adding year in combo box
00925     edit_combo_year = gtk_combo_box_new_text();
00926     sprintf(temp,"MM");
00927     gtk_combo_box_append_text(GTK_COMBO_BOX (edit_combo_year),temp);
00928 
00929     for(i=1950;i<=2050;i++)
00930     {
00931         sprintf(temp,"%d",i);
00932         //items = g_list_append (items, temp);
00933         gtk_combo_box_append_text(GTK_COMBO_BOX (edit_combo_year),temp);
00934     
00935     }      
00936     
00937     gtk_combo_box_set_active(GTK_COMBO_BOX(edit_combo_year ),(atoi(yy)-1949));
00938     gtk_table_attach_defaults (GTK_TABLE(table), edit_combo_year, 3, 4, 2, 3);
00939     
00940     
00941     lbl_email=gtk_label_new("Email Address");
00942     gtk_table_attach_defaults (GTK_TABLE(table), lbl_email, 0, 1, 3, 4);
00943     
00944     edit_entry_email =  gtk_entry_new();
00945     gtk_entry_set_text(GTK_ENTRY(edit_entry_email), clicked_email);
00946     gtk_table_attach_defaults (GTK_TABLE(table), edit_entry_email, 1, 4, 3, 4);
00947     
00948     button_save = gtk_button_new_with_label ("Save");
00949     g_signal_connect(G_OBJECT(button_save),"clicked",G_CALLBACK(callback_edit_record) , view);
00950         gtk_table_attach_defaults (GTK_TABLE(table), button_save, 0, 2, 4, 5);
00951         
00952 
00953     button_cancel = gtk_button_new_with_label ("Cancel");
00954         g_signal_connect_swapped(G_OBJECT(button_cancel), "clicked", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(edit_window));
00955         gtk_table_attach_defaults (GTK_TABLE(table), button_cancel, 2, 4, 4, 5);
00956         
00957     //Handling Events
00958     g_signal_connect(G_OBJECT(edit_window),"destroy",G_CALLBACK(window_destroy),NULL);
00959     
00960     //Displaying Window
00961     gtk_widget_show_all(edit_window);
00962     gtk_main(); 
00963 }

void callback_add_record ( GtkWidget *  widget,
GtkTreeView *  view 
)

This function acts as callback function for save button of add window.

Parameters:
widget is the button for which function is called
view is the view to be filled
Returns:
void

Definition at line 745 of file birthday_reminder.c.

References add_window, AddRecords(), btn_new, clicked_dob, clicked_email, clicked_name, combo_date, combo_month, combo_year, entry_email, entry_name, LoadRecords(), and replaced_name.

Referenced by callback_action_add().

00746 {
00747     // enabling add button after first click
00748     gtk_widget_set_sensitive(btn_new,TRUE);
00749 
00750     const gchar *name,*month = NULL,*date = NULL,*year= NULL,*email;
00751     char dob[1024]; 
00752     GtkWidget *dialog;  
00753     name = gtk_entry_get_text(GTK_ENTRY(entry_name));
00754     email = gtk_entry_get_text(GTK_ENTRY(entry_email));
00755     
00756     month = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo_month));
00757     date = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo_date));
00758     year = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo_year));
00759     
00760     if(strcmp(name,"") == 0)
00761     {
00762         dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Name not entered. Please enter name");
00763         gtk_window_set_title(GTK_WINDOW(dialog), "Error");
00764         gtk_dialog_run (GTK_DIALOG (dialog));
00765         gtk_widget_destroy (dialog);
00766         
00767         return ;
00768     }
00769     
00770     
00771     if(strcmp(month , "MM" ) == 0 || strcmp(date , "DD" ) == 0 || strcmp(year , "YYYY" ) == 0)
00772     {
00773         dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Date not entered. Please enter complete date.");
00774         gtk_window_set_title(GTK_WINDOW(dialog), "Error");
00775         gtk_dialog_run (GTK_DIALOG (dialog));
00776         gtk_widget_destroy (dialog);
00777         
00778         return ;
00779     }
00780     else
00781     {
00782         sprintf(dob,"%s-%s-%s",(char *)month,(char *)date,(char *)year);
00783     }
00784 
00785     clicked_name = (char*)name;
00786     replaced_name = clicked_name;
00787     clicked_dob = dob;
00788     clicked_email = (char*)email;
00789     AddRecords((char*)name, dob, (char*)email);
00790 
00791     gtk_widget_destroy (add_window);
00792 
00793     gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(view)));
00794     LoadRecords(gtk_tree_view_get_model(view));
00795 }

static int callback_csv ( void *  filePointer,
int  argc,
char **  argv,
char **  azColName 
) [static]

This function acts as callback function for query exicuted in callback_generate and writes the records in csv file.

Parameters:
filePointer is pointer of the csv file generated
argc Number of arguments passed
argv NULL terminated array of command line arguments
azColName is the name of column of the table
Returns:
0 on complition

Definition at line 1591 of file birthday_reminder.c.

Referenced by callback_generate().

01592 {
01593     if(argc)
01594         fprintf((FILE*)filePointer,"%s, %s, %s\n",argv[0],argv[1],argv[2]);
01595     
01596     return 0;
01597 }

void callback_edit_record ( GtkWidget *  widget,
GtkTreeView *  view 
)

This function acts as callback function for save button in the edit record window.

Parameters:
widget is the button for which function is called
view is the view to be filled
Returns:
void

Definition at line 970 of file birthday_reminder.c.

References btn_edit, clicked_name, edit_combo_date, edit_combo_month, edit_combo_year, edit_entry_email, edit_entry_name, edit_window, EditRecords(), LoadRecords(), and replaced_name.

Referenced by callback_action_edit().

00971 {
00972     // enabling edit button after first click
00973     gtk_widget_set_sensitive(btn_edit,TRUE);
00974 
00975 
00976     const gchar *name,*month = NULL,*date = NULL,*year= NULL,*email;
00977     char dob[1024]; 
00978     GtkWidget *dialog;
00979     
00980     name = gtk_entry_get_text(GTK_ENTRY(edit_entry_name));
00981     email = gtk_entry_get_text(GTK_ENTRY(edit_entry_email));
00982     
00983     month = gtk_combo_box_get_active_text(GTK_COMBO_BOX(edit_combo_month));
00984     date = gtk_combo_box_get_active_text(GTK_COMBO_BOX(edit_combo_date));
00985     year = gtk_combo_box_get_active_text(GTK_COMBO_BOX(edit_combo_year));
00986     
00987     if(strcmp(name,"") == 0)
00988     {
00989             dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Name not entered. Please enter name");
00990         gtk_window_set_title(GTK_WINDOW(dialog), "Error");
00991         gtk_dialog_run (GTK_DIALOG (dialog));
00992         gtk_widget_destroy (dialog);
00993         
00994         return ;
00995     }
00996     
00997     if(strcmp(month , "MM" ) == 0 || strcmp(date , "DD" ) == 0 || strcmp(year , "YYYY" ) == 0)
00998     {
00999         dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Date not entered. Please enter complete date.");
01000         gtk_window_set_title(GTK_WINDOW(dialog), "Error");
01001         gtk_dialog_run (GTK_DIALOG (dialog));
01002         gtk_widget_destroy (dialog);
01003         
01004         return ;
01005     }
01006     else
01007     {
01008         sprintf(dob,"%s-%s-%s",(char *)month,(char *)date,(char *)year);
01009     }
01010 
01011     replaced_name = (char*)name;
01012     EditRecords(clicked_name, (char*)name, dob, (char*)email);
01013 
01014     gtk_widget_destroy (edit_window);
01015     
01016     gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(view)));
01017     LoadRecords(gtk_tree_view_get_model(view));
01018 }

void callback_email ( GtkWidget *  widget,
GtkTreeView *  second_view 
)

This function acts as callback function for email button in starting window.

Parameters:
widget is the widget for which function is called
second_view is the view showing upcoming/recent birthday list
Returns:
void

Definition at line 1743 of file birthday_reminder.c.

References mail_clicked_email, and mail_row_selected().

Referenced by listwindow().

01744 {
01745     char str[100];
01746 
01747     mail_row_selected(second_view);
01748 
01749     sprintf(str, "evolution mailto:%s", mail_clicked_email);
01750 
01751     //puts(str);
01752 
01753     system(str);
01754 }

int callback_generate ( GtkWidget *  btn,
gpointer  data 
)

This function acts as callback function for generate button in main window which generate csv file of all records.

Parameters:
btn is the widget for which function is called
data is the gpointer supplied by the widget
Returns:
0 on success

Definition at line 1605 of file birthday_reminder.c.

References callback_csv().

Referenced by main().

01606 {
01607     sqlite3 *db;
01608     char *zErrMsg = 0;
01609     int rc;
01610     char qry[1024];
01611     FILE *fp;
01612     char *filename;
01613     GtkWidget *filedialog;
01614 
01615 
01616     
01617     filedialog = gtk_file_chooser_dialog_new ("Save File", NULL, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
01618     gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (filedialog), TRUE);
01619     
01620     //gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filedialog), "./");
01621     gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filedialog), "BirthDayList.csv");
01622     //gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filedialog), "BirthDayList.csv");
01623     
01624     if (gtk_dialog_run (GTK_DIALOG (filedialog)) == GTK_RESPONSE_ACCEPT)
01625     {
01626         
01627         filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filedialog));
01628 
01629         fp = fopen(filename,"w+");
01630 
01631         g_free (filename);
01632     }
01633     else
01634     {
01635         gtk_widget_destroy (filedialog);
01636         return(0);
01637     }
01638     gtk_widget_destroy (filedialog);
01639 
01640     strcpy(qry , "select * from birthday_tbl order by name");
01641     
01642     rc = sqlite3_open ("Birthday", &db);
01643     if (rc)
01644     {
01645         fprintf (stderr, "Can't open database: %s\n", sqlite3_errmsg (db));
01646         sqlite3_close (db);
01647         exit (1);
01648     }
01649     rc = sqlite3_exec (db, qry, callback_csv, (void*)fp, &zErrMsg);
01650     if (rc != SQLITE_OK)
01651     {
01652     //  fprintf (stderr, "SQL error: %s\n", zErrMsg);
01653         
01654     }
01655     
01656     fclose(fp);
01657     sqlite3_close (db);
01658     return 0;
01659 }

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

This function acts as callback function for query to store records in parameters_tbl.

Parameters:
NotUsed is the void pointer
argc Number of arguments passed
argv NULL terminated array of command line arguments
azColName is the name of column of the table
Returns:
0 on success

Definition at line 1536 of file birthday_reminder.c.

References day_after_event, day_in_advance, and startup.

Referenced by LoadRecords(), parameters(), and ReadParameters().

01537 {
01538     NotUsed = 0;
01539     if(argc)
01540     {
01541         day_after_event = atof(argv[0]);
01542         day_in_advance = atof(argv[1]);
01543         
01544         startup = atoi(argv[2]);
01545     }
01546 
01547     return 0;
01548 }

void callback_quit ( GtkWidget *  widget,
gpointer  data 
)

This function acts as callback function for quitting window and shows the main window on clicking.

Parameters:
widget is the widget for which function is called
data is the user data to pass in the fuction
Returns:
void

Definition at line 1303 of file birthday_reminder.c.

Referenced by listwindow().

01304 {
01305     gtk_main_quit();
01306 }

void callback_rowselected ( GtkTreeView *  view,
GtkTreePath *  path,
GtkTreeViewColumn *  col,
gpointer  data 
)

This function is invoked by row activated signal.

Parameters:
view is the view to be filled
path is the tree path
col is the column of the tree view
data is the gpointer
Returns:
0 on success

Definition at line 1136 of file birthday_reminder.c.

References btn_edit, and callback_action_edit().

Referenced by main().

01137 {
01138     callback_action_edit(btn_edit, view);
01139 }

int callback_upload ( GtkWidget *  widget1,
GtkTreeView *  view 
)

This function acts as callback function for upload button in main window which uploads csv file of all records.

Parameters:
widget1 is the widget for which function is called
view in which uploaded records will be shown
Returns:
void

Definition at line 1668 of file birthday_reminder.c.

References AddRecords(), clicked_dob, clicked_email, clicked_name, LoadRecords(), and replaced_name.

Referenced by main().

01669 {
01670     FILE *fp; char line[1024];
01671     char *filename;
01672     GtkWidget *filedialog;
01673     gint response;
01674     char *pch; int count = 0;
01675     char name[100],dob[15],email[100],*ptr;
01676 
01677 
01678     filedialog = gtk_file_chooser_dialog_new ("Choose File", NULL, GTK_FILE_CHOOSER_ACTION_OPEN, "Upload", GTK_RESPONSE_YES, "Cancel", GTK_RESPONSE_NO, NULL);
01679     
01680     response = gtk_dialog_run (GTK_DIALOG (filedialog));
01681         
01682     if(response == GTK_RESPONSE_YES)
01683     {
01684         filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filedialog));
01685         
01686         fp = fopen (filename, "r");
01687         g_free (filename);
01688     }
01689     else
01690     {
01691         gtk_widget_destroy (filedialog);
01692         return(0);
01693     }
01694     gtk_widget_destroy (filedialog);
01695 
01696     while((fscanf(fp,"%[^\n]",line)>0))
01697     {   
01698         count = 0;
01699         fseek(fp,1,1);      
01700         pch = strtok (line,",");
01701          while (pch != NULL)
01702         {
01703             if(count == 0)
01704             {
01705                 strcpy(name,pch);               
01706             }
01707             if(count == 1)
01708             {
01709                 strcpy(dob,pch);                    
01710             }
01711             if(count == 2)
01712             {
01713                 strcpy(email,pch);                          
01714             }
01715             pch = strtok (NULL, ",");
01716             count++;    
01717          }      
01718         
01719         ptr = dob;
01720         ptr++;
01721         strcpy(dob,ptr);
01722 
01723         ptr = email;
01724         ptr++;
01725         strcpy(email,ptr);
01726 
01727         clicked_name = name;
01728         replaced_name = clicked_name;
01729         clicked_dob = dob;
01730         clicked_email = email;
01731         AddRecords(name, dob, email);
01732         gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(view)));
01733         LoadRecords(gtk_tree_view_get_model(view));
01734     }
01735     return(0);
01736 }

void check_button_callback ( GtkWidget *  widget,
gpointer  data 
)

This function acts as callback function of toggling of check button for startup run in main window.

Parameters:
widget is the widget for which function is called
data is the gpointer supplied by the widget
Returns:
void

Definition at line 1480 of file birthday_reminder.c.

References startup.

Referenced by main().

01481 {
01482     if (GTK_TOGGLE_BUTTON (widget)->active) 
01483     {
01484         startup = 1;
01485     }
01486     else {
01487              startup = 0;
01488     }
01489 }

int con_to_sql ( char *  qry  ) 

This function connects to the database and executes the qyery and load its results to the main window.

Parameters:
qry is the query to be executed
Returns:
0 on success

Definition at line 332 of file birthday_reminder.c.

References DeleteRecords(), replaced_name, and sql_callback().

Referenced by AddRecords(), DeleteRecords(), and EditRecords().

00333 {
00334     sqlite3 *db;
00335     char *zErrMsg = 0;
00336     int rc;
00337 
00338     rc = sqlite3_open ("Birthday", &db);
00339     if (rc)
00340     {
00341         //fprintf (stderr, "Can't open database: %s\n", sqlite3_errmsg (db));
00342         sqlite3_close (db);
00343         exit (1);
00344     }
00345     rc = sqlite3_exec (db, qry, sql_callback, 0, &zErrMsg);
00346     if (rc != SQLITE_OK)
00347     {
00348         //fprintf (stderr, "SQL error: %s\n", zErrMsg);
00349         if(rc == 19)
00350         {   
00351             GtkWidget *dialog;
00352             gint response;
00353 
00354             dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "A Record with name %s already exists! Do you want to replace it?", replaced_name);
00355             gtk_window_set_title(GTK_WINDOW(dialog), "Confirm Replace");
00356     
00357             response = gtk_dialog_run(GTK_DIALOG(dialog));
00358             gtk_widget_destroy(dialog);
00359 
00360             if(response == GTK_RESPONSE_YES)
00361             {
00362                 DeleteRecords(replaced_name);
00363                 con_to_sql(qry);
00364             }
00365         }
00366     }
00367     sqlite3_close (db);
00368     return 0;
00369 }

static GtkTreeModel * create_model (  )  [static]

This function is used to create the model in which we will show the records.

Returns:
model

Definition at line 533 of file birthday_reminder.c.

References NUM_COLS.

Referenced by create_view().

00534 {
00535     GtkListStore  *store;
00536     
00537     store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
00538 
00539     return GTK_TREE_MODEL (store);
00540 }

static GtkTreeModel * create_second_model (  )  [static]

This function is to create the model for start window which shows the upcoming birthdays.

Returns:
model in which birthdays will be shown

Definition at line 1154 of file birthday_reminder.c.

References NEW_NUM_COLS.

Referenced by create_second_view().

01155 {
01156     GtkListStore  *second_store;
01157     
01158     second_store = gtk_list_store_new (NEW_NUM_COLS, G_TYPE_STRING, G_TYPE_STRING);
01159 
01160     return GTK_TREE_MODEL (second_store);
01161 }

static GtkWidget * create_second_view ( void   )  [static]

This function view for the window showing upcoming birthdays.

Returns:
view to show the information

Definition at line 1184 of file birthday_reminder.c.

References create_second_model(), NEW_COL_STRING, and ReadRecords().

Referenced by listwindow().

01185 {
01186     GtkCellRenderer     *second_renderer;
01187     GtkTreeModel        *second_model;
01188     GtkWidget           *second_view;
01189 
01190     second_view = gtk_tree_view_new ();
01191 
01192     /* --- Column #1 --- */
01193 
01194     second_renderer = gtk_cell_renderer_text_new ();
01195     gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (second_view), -1, "BirthDay Updates", second_renderer, "text", NEW_COL_STRING, NULL);
01196 
01197     /* --- Column #2 --- */
01198 
01199     //second_renderer = gtk_cell_renderer_text_new ();
01200     //gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (second_view), -1, "Email Id", second_renderer, "text", NEW_COL_EMAIL, NULL);
01201 
01202 
01203     second_model = create_second_model();
01204     ReadRecords(second_model);
01205 
01206     gtk_tree_view_set_model (GTK_TREE_VIEW (second_view), second_model);
01207 
01208     /* The tree view has acquired its own reference to the
01209     *  model, so we can drop ours. That way the model will
01210     *  be freed automatically when the tree view is destroyed */
01211 
01212     g_object_unref (second_model);
01213 
01214     return second_view;
01215 }

static GtkWidget * create_view ( void   )  [static]

This function creates the view in which records will be shown.

Returns:
view to be shown

Definition at line 565 of file birthday_reminder.c.

References COL_BIRTH, COL_EMAIL, COL_NAME, create_model(), and LoadRecords().

Referenced by main().

00566 {
00567     GtkCellRenderer     *renderer;
00568     GtkTreeModel        *model;
00569     GtkWidget           *view;
00570 
00571     view = gtk_tree_view_new ();
00572 
00573     /* --- Column #1 --- */
00574 
00575     renderer = gtk_cell_renderer_text_new ();
00576     gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), -1, "Name", renderer, "text", COL_NAME, NULL);
00577 
00578     /* --- Column #2 --- */
00579 
00580     renderer = gtk_cell_renderer_text_new ();
00581     gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), -1, "Birth Date", renderer, "text", COL_BIRTH, NULL);
00582 
00583     /* --- Column #3 --- */
00584 
00585     renderer = gtk_cell_renderer_text_new ();
00586     gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), -1, "Email", renderer, "text", COL_EMAIL, NULL);
00587 
00588     model = create_model();
00589     LoadRecords(model);
00590 
00591     gtk_tree_view_set_model (GTK_TREE_VIEW (view), model);
00592 
00593     /* The tree view has acquired its own reference to the
00594     *  model, so we can drop ours. That way the model will
00595     *  be freed automatically when the tree view is destroyed */
00596 
00597     g_object_unref (model);
00598 
00599     return view;
00600 }

int DeleteRecords ( char *  name  ) 

This function is used to delete the birthday record in sqlite database.

Parameters:
name stores the name of the record to be deleted.
Returns:
0 on success

Definition at line 132 of file birthday_reminder.c.

References con_to_sql().

Referenced by callback_action_delete(), and con_to_sql().

00133 {
00134     char qry[1024];
00135     
00136     bzero(qry,1024);
00137     sprintf(qry , "delete from birthday_tbl where name = '%s'", name);
00138     con_to_sql(qry);
00139 
00140     //fprintf(stdout,"\nRecord erased successfully!\n");
00141     
00142     return(0);
00143 }

int EditRecords ( char *  oname,
char *  name,
char *  bdate,
char *  eid 
)

This function is used to edit the birthday records in sqlite database.

Parameters:
oname is the name of entry to be edited
name stores the name
bdate stores the date of birth/ anniversary
eid stores the email id of the person
Returns:
0 on success

Definition at line 112 of file birthday_reminder.c.

References con_to_sql().

Referenced by callback_edit_record().

00113 {
00114 
00115     char qry[1024];
00116     
00117     bzero(qry,1024);
00118     
00119     sprintf(qry , "update birthday_tbl set name = '%s', birth_date = '%s', email_id = '%s' where name = '%s'", name, bdate, eid, oname);
00120         
00121     con_to_sql(qry);
00122 
00123     //fprintf(stdout,"\nRecord Modified successfully!\n");
00124     
00125     return(0);
00126 }

void exit_program ( GtkWidget *  widget,
gpointer  data 
)

This function exits from program.

Parameters:
widget is the widget for which function is called
data is the user data passed to this function
Returns:
void

Definition at line 1313 of file birthday_reminder.c.

Referenced by listwindow().

01314 {
01315     gtk_main_quit();
01316     exit(0);
01317 }

void fill_model ( GtkTreeModel *  model,
char *  name,
char *  bdate,
char *  email 
)

This function fill the model with records.

Parameters:
model is the model in which we will fill the records
name is the name of the person in the record
bdate is the birthdaye of the person in the record
email is the email address of the person in the record
Returns:
0 on success

Definition at line 549 of file birthday_reminder.c.

References COL_BIRTH, COL_EMAIL, and COL_NAME.

Referenced by sql_callback_load().

00550 {
00551     GtkListStore  *store;
00552     GtkTreeIter    iter;
00553 
00554     store = GTK_LIST_STORE(model);
00555 
00556     /* Append a row and fill in some data */
00557     gtk_list_store_append (store, &iter);
00558     gtk_list_store_set (store, &iter, COL_NAME, name, COL_BIRTH, bdate, COL_EMAIL, email, -1);
00559 
00560 }

void fill_second_model ( GtkTreeModel *  second_model,
char *  str,
char *  email 
)

This function is used to populate the upcoming birthdays window.

Parameters:
second_model is the model which will show the birthdays
str stores the information to be shown
email is the email address of the record
Returns:
void

Definition at line 1169 of file birthday_reminder.c.

References NEW_COL_EMAIL, and NEW_COL_STRING.

Referenced by listwindow(), and sql_callback().

01170 {
01171     GtkListStore  *second_store;
01172     GtkTreeIter    second_iter;
01173 
01174     second_store = GTK_LIST_STORE(second_model);
01175 
01176     /* Append a row and fill in some data */
01177     gtk_list_store_append (second_store, &second_iter);
01178     gtk_list_store_set (second_store, &second_iter, NEW_COL_STRING, str, NEW_COL_EMAIL, email, -1);
01179 }

int isLeapYear ( int  year  ) 

This function checks whether given year is leap year or not.

Parameters:
year is the year for which we are checking leap year condition.
Returns:
1 if year is leap year 0 if year is not leap year

Definition at line 164 of file birthday_reminder.c.

Referenced by sql_callback().

00165 {
00166     if(year%400 ==0 || (year%100 != 0 && year%4 == 0))
00167     {
00168         //printf("Year %d is a leap year",year);
00169         return 1;
00170     }
00171     else
00172     {
00173         //printf("Year %d is not a leap year",year);
00174         return 0;
00175     }
00176 }

int listwindow (  ) 

This function generates the upcoming birthday list.

Returns:
view to show the information

Definition at line 1220 of file birthday_reminder.c.

References callback_email(), callback_quit(), create_second_view(), exit_program(), fill_second_model(), and flag_listwindow.

Referenced by main().

01221 {
01222     GtkWidget *window;
01223     GtkWidget *scroll_window;
01224     GtkWidget *vbox;
01225     GtkWidget *btn_email, *btn_mainwindow, *btn_ok;
01226     GtkWidget *second_view;
01227     GtkWidget *table;
01228 
01229     flag_listwindow = 0;
01230 
01231 //Initialize window and it's attributes
01232     //gtk_init(&argc, &argv);
01233 
01234     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
01235     gtk_window_set_position((GtkWindow *)window, GTK_WIN_POS_CENTER);
01236     gtk_window_set_title(GTK_WINDOW(window), "BirthDay Updates");
01237     gtk_window_set_default_size(GTK_WINDOW(window),400,250);
01238     gtk_container_set_border_width(GTK_CONTAINER(window),20);
01239 
01240 //Vertical Box
01241     vbox = gtk_vbox_new (FALSE, 10);
01242 
01243 //scroll window
01244     scroll_window = gtk_scrolled_window_new(NULL,NULL);
01245     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
01246 
01247 //Tree View
01248 
01249     second_view = create_second_view ();
01250     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(second_view), FALSE);
01251                         
01252 // packing treeview in scroll window 
01253 
01254     gtk_container_add (GTK_CONTAINER (scroll_window), second_view);
01255 
01256     // CREATING TABLE
01257     table = gtk_table_new (1, 6, TRUE);
01258     //gtk_table_set_col_spacing (GTK_TABLE(table),3,10);
01259     
01260     btn_mainwindow = gtk_button_new_with_label("Home");
01261     g_signal_connect(G_OBJECT(btn_mainwindow),"clicked",G_CALLBACK(callback_quit) , NULL);
01262     gtk_table_attach_defaults (GTK_TABLE(table), btn_mainwindow, 2, 4, 0, 1);   
01263 
01264     btn_email = gtk_button_new_with_label("Email");
01265     g_signal_connect(G_OBJECT(btn_email),"clicked",G_CALLBACK(callback_email) ,second_view);
01266     gtk_table_attach_defaults (GTK_TABLE(table), btn_email, 0, 1, 0, 1);
01267     
01268     btn_ok = gtk_button_new_with_label("Close");
01269     //g_signal_connect_swapped(G_OBJECT(btn_ok), "clicked", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(window));
01270     g_signal_connect(G_OBJECT(btn_ok),"clicked",G_CALLBACK(exit_program), NULL);
01271     gtk_table_attach_defaults (GTK_TABLE(table), btn_ok, 5, 6, 0, 1);
01272 
01273 //Packing Components in vbox
01274     gtk_box_pack_start(GTK_BOX (vbox), scroll_window, TRUE, TRUE, 0);
01275     gtk_box_pack_start(GTK_BOX (vbox), table, FALSE, FALSE, 0);
01276         
01277 //Puting vbox in window
01278     gtk_container_add (GTK_CONTAINER (window), vbox);
01279 
01280 //Handling Events
01281     g_signal_connect(G_OBJECT(window), "delete-event",G_CALLBACK(exit_program), NULL);
01282     
01283 
01284 //Displaying Window
01285     if(flag_listwindow == 0)
01286     {
01287         fill_second_model (gtk_tree_view_get_model(GTK_TREE_VIEW(second_view)), "No Birthday in Recent & Upcoming Days!", "");
01288     }
01289     
01290     gtk_widget_show_all(window);
01291     gtk_main();
01292 
01293     gtk_widget_destroy(window);
01294 
01295     return EXIT_SUCCESS;
01296 }

int load_sql ( GtkTreeModel *  model,
char *  qry,
int  flag 
)

This function loads the records from database to model.

Parameters:
model is the model in which we will fill the records
qry is the query to be executed
flag is the indicator of database exists or not
Returns:
0 on success

Definition at line 483 of file birthday_reminder.c.

References sql_callback(), and sql_callback_load().

Referenced by LoadRecords(), and ReadRecords().

00484 {
00485         sqlite3 *db;
00486         char *zErrMsg = 0;
00487     
00488         int rc;
00489 
00490         rc = sqlite3_open ("Birthday", &db);
00491         if (rc)
00492         {
00493         //fprintf (stderr, "Can't open database: %s\n", sqlite3_errmsg (db));
00494         sqlite3_close (db);
00495         exit (1);
00496         }
00497 
00498     if(flag)
00499     {
00500         rc = sqlite3_exec (db, qry, sql_callback, (void *)model, &zErrMsg);
00501     }
00502     else
00503     {
00504         rc = sqlite3_exec (db, qry, sql_callback_load, (void *)model, &zErrMsg);
00505     }
00506     if (rc != SQLITE_OK)
00507         {
00508 //      fprintf (stderr, "SQL error: %s\n", zErrMsg);
00509         sqlite3_close (db);
00510         return(1);
00511     }
00512     
00513         sqlite3_close (db);
00514         
00515     return 0;
00516 }

int LoadRecords ( GtkTreeModel *  model  ) 

This function loads records from the database to the window.It also checks whether database exists or not if not then it also creates the database.

Parameters:
model is the model where we want to load the records
Returns:
0 on success

Definition at line 378 of file birthday_reminder.c.

References callback_parameters(), and load_sql().

Referenced by callback_action_delete(), callback_add_record(), callback_edit_record(), callback_upload(), and create_view().

00379 {
00380     char qry[1024];
00381     GtkWidget *dialog;
00382     gint response;
00383         int rc;
00384 
00385 
00386     bzero(qry, 1024);
00387     sprintf(qry , "select * from birthday_tbl order by name");
00388 
00389         rc = load_sql(model, qry, 0);
00390         if (rc)
00391         {
00392         dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "No Previous Birthday File Found. Do you want to create new Birthday File?");
00393         
00394         gtk_window_set_title(GTK_WINDOW(dialog), "File Not Found!");
00395     
00396         response = gtk_dialog_run(GTK_DIALOG(dialog));
00397         gtk_widget_destroy(dialog);
00398 
00399         if(response == GTK_RESPONSE_YES)
00400         {
00401         //  fprintf (stderr, "Creating Table.\n");
00402 
00403             bzero(qry, 1024);
00404             sprintf(qry , "create table birthday_tbl (name, birth_date, email_id, primary key(name))");
00405             
00406             rc = load_sql(model, qry, 0);
00407             if(rc)
00408                 {
00409                 //fprintf (stdout, "SQL error: %s\n", zErrMsg);
00410                 exit(1);
00411             }
00412             else
00413             {
00414                 //fprintf (stdout, "Table created successfully\n");
00415             }
00416 
00417 
00418             sqlite3 *db;
00419                 char *zErrMsg = 0;
00420     
00421                 rc = sqlite3_open ("Birthday", &db);
00422                 if (rc)
00423                 {
00424                 //fprintf (stderr, "Can't open database: %s\n", sqlite3_errmsg (db));
00425                 sqlite3_close (db);
00426                 exit (1);
00427                 }
00428 
00429             bzero(qry, 1024);
00430             sprintf(qry , "create table parameters_tbl (days_after_event, days_in_advance, startup)");
00431         
00432             rc = sqlite3_exec (db, qry, callback_parameters, 0, &zErrMsg);
00433             if(rc)
00434                 {
00435                 //fprintf (stdout, "SQL error: %s\n", zErrMsg);
00436                 exit(1);
00437             }
00438             else
00439             {
00440                 //fprintf (stdout, "Table created successfully\n");
00441             }
00442 
00443             sqlite3_close (db);
00444             
00445         }
00446         else
00447         {
00448             system("rm Birthday");
00449             exit(0);
00450             return 0;
00451         }
00452 
00453         }
00454     else
00455     {
00456         //printf ("\nRecords Loaded Successfully!\n");
00457     }
00458 
00459     return(0);
00460 }

int mail_row_selected ( GtkTreeView *  view  ) 

This function fetches the mail id of the selected record.

Parameters:
view is the widget of view
Returns:
0 on success

Definition at line 1760 of file birthday_reminder.c.

References mail_clicked_email, and NEW_COL_EMAIL.

Referenced by callback_email().

01761 {
01762     GtkTreeIter iter;
01763     GtkTreeModel *model;
01764     GtkTreeSelection* select;
01765     GList* list;
01766     guint row_clicked_count;
01767     GtkWidget *dialog;
01768     GtkTreePath* path;
01769 
01770     select = gtk_tree_view_get_selection(view);
01771 
01772     list = gtk_tree_selection_get_selected_rows(select, NULL);
01773 
01774     row_clicked_count = g_list_length(list);
01775 
01776     if(row_clicked_count < 1)
01777     {
01778         dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "No Record Selected! Please Select a Record.");
01779         gtk_window_set_title(GTK_WINDOW(dialog), "Error");
01780         gtk_dialog_run (GTK_DIALOG (dialog));
01781         gtk_widget_destroy (dialog);
01782         
01783         return(1) ;
01784     }
01785     else if(row_clicked_count > 1)
01786     {
01787         dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "More Than One Record Selected! Select One Record At a Time.");
01788         gtk_window_set_title(GTK_WINDOW(dialog), "Error");
01789         gtk_dialog_run (GTK_DIALOG (dialog));
01790         gtk_widget_destroy (dialog);
01791         
01792         return(1) ;
01793     }
01794 
01795     path = (GtkTreePath*)g_list_nth_data(list, 0);
01796 
01797     model = gtk_tree_view_get_model(view);
01798     
01799     if(gtk_tree_model_get_iter(model, &iter, path))
01800     {
01801         gtk_tree_model_get(model, &iter, NEW_COL_EMAIL, &mail_clicked_email, -1);
01802     }
01803     return(0);
01804 }

int main ( int  argc,
char *  argv[] 
)

This is main function which shows main window and calls upcoming birthday window.

Parameters:
argc Number of arguments passed.
argv NULL terminated array of command line arguments. * returns void
Returns:
0 on complition

Definition at line 1325 of file birthday_reminder.c.

References btn_delete, btn_edit, btn_new, callback_action_add(), callback_action_delete(), callback_action_edit(), callback_generate(), callback_rowselected(), callback_upload(), check_button_callback(), clicked_dob, clicked_email, clicked_name, COL_BIRTH, COL_EMAIL, COL_NAME, create_view(), day_after_event, day_in_advance, listwindow(), main_window_destroy(), ReadParameters(), replaced_name, spin_adays, and spin_pdays.

01326 {
01327     GtkWidget *window;
01328     GtkWidget *scroll_window;
01329     GtkWidget *vbox;
01330     GtkWidget *hbox;
01331     GtkWidget *btn_export, *btn_import, *btn_close;
01332     GtkWidget *lbl_previous_days,*lbl_after_days,*lbl_csv;
01333     GtkWidget *chk_startup; 
01334     GtkWidget *view;
01335     GtkWidget *table;
01336 // initializing clicked variables
01337     clicked_name = NULL;
01338     clicked_dob = NULL;
01339     clicked_email = NULL;
01340     replaced_name = clicked_name;
01341 
01342     ReadParameters();
01343 
01344     //Initialize window and it's attributes
01345     gtk_init(&argc, &argv);
01346 
01347     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
01348     gtk_window_set_position((GtkWindow *)window, GTK_WIN_POS_CENTER);
01349     gtk_window_set_title(GTK_WINDOW(window), "BirthDay Reminder");
01350     gtk_window_set_default_size(GTK_WINDOW(window),500,400);
01351     gtk_container_set_border_width(GTK_CONTAINER(window),20);
01352 
01353 
01354 //Vertical Box
01355     vbox = gtk_vbox_new (FALSE, 10);
01356 
01357 //scroll window
01358     scroll_window = gtk_scrolled_window_new(NULL,NULL);
01359     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
01360 
01361 //Tree View
01362 
01363     view = create_view ();
01364     gtk_tree_view_column_set_sort_column_id( gtk_tree_view_get_column((GtkTreeView *)view, COL_NAME), COL_NAME);
01365         gtk_tree_view_column_set_sort_column_id( gtk_tree_view_get_column((GtkTreeView *)view, COL_BIRTH), COL_BIRTH);
01366         gtk_tree_view_column_set_sort_column_id( gtk_tree_view_get_column((GtkTreeView *)view, COL_EMAIL), COL_EMAIL);  
01367     gtk_tree_view_set_grid_lines((GtkTreeView *)view, GTK_TREE_VIEW_GRID_LINES_HORIZONTAL);
01368 
01369     // handling tree events
01370     g_signal_connect(G_OBJECT(view),"row-activated",GTK_SIGNAL_FUNC(callback_rowselected),NULL);
01371 
01372         
01373 // packing treeview in scroll window 
01374 
01375     gtk_container_add (GTK_CONTAINER (scroll_window), view);
01376 //Horizonatal Box
01377     hbox = gtk_hbox_new (FALSE, 10);
01378 
01379 //Buttons
01380     //Initialization
01381     btn_new = gtk_button_new_with_label("Add");
01382     //Packing in hbox
01383     gtk_box_pack_start(GTK_BOX (hbox), btn_new, TRUE, TRUE, 0);
01384     g_signal_connect(G_OBJECT(btn_new),"clicked",G_CALLBACK(callback_action_add) , view);
01385 
01386     btn_edit = gtk_button_new_with_label("Edit");
01387     gtk_box_pack_start(GTK_BOX (hbox), btn_edit, TRUE, TRUE, 0);
01388     g_signal_connect(G_OBJECT(btn_edit),"clicked",G_CALLBACK(callback_action_edit) ,view);
01389 
01390     btn_delete = gtk_button_new_with_label("Delete");
01391     gtk_box_pack_start(GTK_BOX (hbox), btn_delete, TRUE, TRUE, 0);
01392     g_signal_connect(G_OBJECT(btn_delete),"clicked",G_CALLBACK(callback_action_delete) , view);
01393 
01394 // CREATING TABLE
01395     table = gtk_table_new (4, 6, TRUE);
01396      gtk_table_set_col_spacing (GTK_TABLE(table),2,10);
01397 
01398 
01399     lbl_previous_days=gtk_label_new("Report Previous Days");
01400     gtk_misc_set_alignment(GTK_MISC(lbl_previous_days), 0 ,0.5);
01401     gtk_table_attach_defaults (GTK_TABLE(table), lbl_previous_days, 0, 2, 0, 1);    
01402     
01403     spin_pdays = gtk_spin_button_new_with_range(1, 30, 1);
01404     gtk_table_attach_defaults (GTK_TABLE(table), spin_pdays, 2, 3, 0, 1);   
01405 
01406     lbl_after_days=gtk_label_new("Report Days in Advance");
01407     gtk_misc_set_alignment(GTK_MISC(lbl_after_days), 0 ,0.5);
01408     gtk_table_attach_defaults (GTK_TABLE(table), lbl_after_days, 0, 2, 1, 2);
01409     
01410     spin_adays = gtk_spin_button_new_with_range(1, 90, 1);
01411     gtk_table_attach_defaults (GTK_TABLE(table), spin_adays, 2, 3, 1, 2);
01412 
01413     gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin_pdays), (day_after_event));
01414     gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin_adays), (day_in_advance));
01415 
01416 
01417     btn_import = gtk_button_new_with_label("Import BirthDay List");
01418     g_signal_connect(G_OBJECT(btn_import),"clicked",G_CALLBACK(callback_upload) ,view);
01419     gtk_table_attach_defaults (GTK_TABLE(table), btn_import, 4, 6, 0, 1);   
01420 
01421     btn_export = gtk_button_new_with_label("Export BirthDay List");
01422     g_signal_connect(G_OBJECT(btn_export),"clicked",G_CALLBACK(callback_generate) , NULL);
01423     gtk_table_attach_defaults (GTK_TABLE(table), btn_export, 4, 6, 1, 2);
01424 
01425     lbl_csv = gtk_label_new("(Supported Format : CSV)");
01426     gtk_misc_set_alignment(GTK_MISC(lbl_csv), 0 ,0.5);
01427     gtk_table_attach_defaults (GTK_TABLE(table), lbl_csv, 4, 6, 2, 3);
01428 
01429 
01430     chk_startup = gtk_check_button_new_with_label("Run on startup");
01431     g_signal_connect(G_OBJECT(chk_startup),"clicked",G_CALLBACK(check_button_callback) , NULL);
01432     gtk_table_attach_defaults (GTK_TABLE(table),chk_startup, 0, 2, 2, 3);
01433 
01434 
01435     btn_close = gtk_button_new_with_label("Exit");
01436     g_signal_connect(G_OBJECT(btn_close),"clicked",G_CALLBACK(main_window_destroy) , NULL);
01437     gtk_table_attach_defaults (GTK_TABLE(table), btn_close, 4, 6, 3, 4);        
01438 
01439     
01440 //Packing Components in vbox
01441     gtk_box_pack_start(GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
01442     gtk_box_pack_start(GTK_BOX (vbox), scroll_window, TRUE, TRUE, 0);
01443     gtk_box_pack_start(GTK_BOX (vbox), table, FALSE, FALSE, 0);
01444     
01445 //Puting vbox in window
01446     gtk_container_add (GTK_CONTAINER (window), vbox);
01447 
01448 //Handling Events
01449     g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(main_window_destroy),NULL);
01450 
01451 //Displaying Window
01452     
01453     listwindow();
01454 
01455     gtk_widget_show_all(window);
01456     gtk_main();
01457 
01458     return EXIT_SUCCESS;
01459 }

void main_window_destroy ( GtkWidget *  widget,
gpointer  data 
)

This function destroys the main window on closing and stores the days in advance and days after event.

Parameters:
widget is the widget for which function is called
data is the gpointer supplied by the widget
Returns:
void

Definition at line 1467 of file birthday_reminder.c.

References day_after_event, day_in_advance, parameters(), spin_adays, spin_pdays, and startup.

Referenced by main().

01468 {
01469     day_in_advance = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin_adays));
01470     day_after_event = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin_pdays) );
01471     parameters(day_after_event,day_in_advance,startup); 
01472     gtk_main_quit();
01473 }

void parameters ( int  days_after_event,
int  days_in_advance,
int  s 
)

This function stores the days in advance and days after event.

Parameters:
days_after_event stores the no. of days of which records to be shown previous the current date.
days_in_advance stores the no of days for which we have to show the birthday in advance.
s is flag for startup
Returns:
void

Definition at line 1497 of file birthday_reminder.c.

References callback_parameters().

Referenced by main_window_destroy().

01498 {
01499     sqlite3 *db;
01500     char *zErrMsg = 0;
01501     int rc;
01502     char sql_query[1024];
01503 
01504     rc = sqlite3_open ("Birthday", &db);
01505     if (rc)
01506     {
01507         fprintf (stderr, "Can't open database: %s\n", sqlite3_errmsg (db));
01508         sqlite3_close (db);
01509         exit (1);
01510     }
01511 
01512     strcpy(sql_query, "delete from parameters_tbl");
01513     rc = sqlite3_exec (db, sql_query, callback_parameters, 0, &zErrMsg);
01514     if (rc != SQLITE_OK)
01515     {
01516         //fprintf (stderr, "SQL error: %s\n", zErrMsg); 
01517     }
01518 
01519     sprintf(sql_query, "insert into parameters_tbl values (%d,%d,%d)",days_after_event, days_in_advance, s);
01520     rc = sqlite3_exec (db, sql_query, callback_parameters, 0, &zErrMsg);
01521     if (rc != SQLITE_OK)
01522     {
01523         //fprintf (stderr, "SQL error: %s\n", zErrMsg); 
01524     }
01525 
01526     return;
01527 }

int ReadParameters (  ) 

This function sets the value of parameters.

Returns:
0 on success

Definition at line 1553 of file birthday_reminder.c.

References callback_parameters().

Referenced by main().

01554 {
01555     
01556     sqlite3 *db;
01557     char *zErrMsg = 0;
01558     int rc;
01559     char sql_query[1024];
01560 
01561     rc = sqlite3_open ("Birthday", &db);
01562     if (rc)
01563     {
01564         fprintf (stderr, "Can't open database: %s\n", sqlite3_errmsg (db));
01565         sqlite3_close (db);
01566         //exit (1);
01567     }
01568 
01569     strcpy(sql_query, "select * from parameters_tbl");
01570     rc = sqlite3_exec (db, sql_query, callback_parameters, 0, &zErrMsg);
01571     if (rc != SQLITE_OK)
01572     {
01573         //fprintf (stderr, "SQL error: %s\n", zErrMsg); 
01574     }
01575 
01576     return 0;
01577 }

int ReadRecords ( GtkTreeModel *  second_model  ) 

This function is used to populate the list of upcoming and recently past birthdays.

Parameters:
second_model is the model which will populate
Returns:
0 on success

Definition at line 149 of file birthday_reminder.c.

References load_sql().

00150 {
00151     char qry[1024];
00152     
00153     strcpy(qry , "select * from birthday_tbl order by name");
00154 
00155     load_sql(second_model, qry, 1);
00156 
00157     return(0);
00158 }

int ReadRecords (  ) 

Referenced by create_second_view().

int row_selected ( GtkTreeView *  view  ) 

This function fetches the selected record from the main window to edit or delete.

Parameters:
view is the view to be filled
Returns:
0 on success

Definition at line 1077 of file birthday_reminder.c.

References clicked_dob, clicked_email, clicked_name, COL_BIRTH, COL_EMAIL, COL_NAME, and replaced_name.

Referenced by callback_action_delete(), and callback_action_edit().

01078 {
01079     GtkTreeIter iter;
01080     GtkTreeModel *model;
01081     GtkTreeSelection* select;
01082     GList* list;
01083     guint row_clicked_count;
01084     GtkWidget *dialog;
01085     GtkTreePath* path;
01086 
01087     select = gtk_tree_view_get_selection(view);
01088 
01089     list = gtk_tree_selection_get_selected_rows(select, NULL);
01090 
01091     row_clicked_count = g_list_length(list);
01092 
01093     if(row_clicked_count < 1)
01094     {
01095         dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "No Record Selected! Please Select a Record.");
01096         gtk_window_set_title(GTK_WINDOW(dialog), "Error");
01097         gtk_dialog_run (GTK_DIALOG (dialog));
01098         gtk_widget_destroy (dialog);
01099         
01100         return(1) ;
01101     }
01102     else if(row_clicked_count > 1)
01103     {
01104         dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "More Than One Record Selected! Select One Record At a Time.");
01105         gtk_window_set_title(GTK_WINDOW(dialog), "Error");
01106         gtk_dialog_run (GTK_DIALOG (dialog));
01107         gtk_widget_destroy (dialog);
01108         
01109         return(1) ;
01110     }
01111 
01112     path = (GtkTreePath*)g_list_nth_data(list, 0);
01113 
01114     model = gtk_tree_view_get_model(view);
01115     
01116     if(gtk_tree_model_get_iter(model, &iter, path))
01117     {
01118         gtk_tree_model_get(model, &iter, COL_NAME, &clicked_name, -1);
01119 
01120         gtk_tree_model_get(model, &iter, COL_BIRTH, &clicked_dob, -1);
01121 
01122         gtk_tree_model_get(model, &iter, COL_EMAIL, &clicked_email, -1);
01123 
01124         replaced_name = clicked_name;
01125     }
01126     return(0);
01127 }

static int sql_callback ( void *  second_model,
int  argc,
char **  argv,
char **  azColName 
) [static]

This function checks upcoming and recently past birthdays from database and show it in the window.

Parameters:
second_model is the model in which we will fill the records
argc Number of arguments passed.
argv NULL terminated array of command line arguments.
azColName is the name of column of the table.
Returns:
0 on success

Definition at line 185 of file birthday_reminder.c.

References day_after_event, day_in_advance, fill_second_model(), flag_listwindow, and isLeapYear().

Referenced by con_to_sql(), and load_sql().

00186 {
00187     //used to store time in ticks temporarily
00188     time_t ticks;
00189     struct tm * timeinfo;
00190 
00191     char sysdaystr[10], sysyy[10], str[500], email[500];
00192     char *pch, mm[10], dd[10], yy[10];
00193     int sys_day_of_year, sysyear, month, day, year, birth_day_of_year, count=0, difference, backdiff;
00194     const int DaysInMonth[13] = {0,0,31,59,90,120,151,181,212,243,273,304,334};
00195 
00196     strcpy(str,"empty");
00197     strcpy(email,"empty");
00198 
00199     time ( &ticks );
00200     timeinfo = localtime ( &ticks );
00201 
00202     /*
00203     strftime (sysmm, 20, "Month = %m", timeinfo);
00204     puts (sysmm);
00205     strftime (sysdd, 20, "Date = %d", timeinfo);
00206     puts (sysdd);
00207     */
00208 
00209     strftime (sysyy, 10, "%Y", timeinfo);
00210     sysyear = atoi(sysyy);
00211 
00212     strftime (sysdaystr, 10, "%j", timeinfo);
00213     sys_day_of_year = atoi(sysdaystr);
00214     
00215     pch = strtok (argv[1],"-");
00216     while (pch != NULL)
00217     {
00218         if(count == 0)
00219         {
00220             strcpy(mm,pch);             
00221         }
00222         if(count == 1)
00223         {
00224             strcpy(dd,pch);                 
00225         }
00226         if(count == 2)
00227         {
00228             strcpy(yy,pch);                         
00229         }
00230         pch = strtok (NULL, "-");
00231         count++;    
00232      }
00233         
00234         month = atoi(mm);
00235     day = atoi(dd);
00236     year = atoi(yy);
00237     
00238     birth_day_of_year = DaysInMonth[month] + day;
00239     
00240     if(isLeapYear(sysyear))
00241     {
00242         if(month > 2)
00243         {
00244             birth_day_of_year++;
00245         }
00246     }
00247     
00248     if(sys_day_of_year > birth_day_of_year)
00249     {
00250         if(isLeapYear(sysyear + 1))
00251         {
00252             if(month > 2)
00253             {
00254                 birth_day_of_year++;
00255             }
00256         }
00257 
00258         if(isLeapYear(sysyear))
00259         {
00260             difference = 366 - sys_day_of_year + birth_day_of_year;
00261             if( difference <= day_in_advance)
00262             {
00263                 if(difference == 0)
00264                 {
00265                     sprintf(str, "It's %s's %d BirthDay Today!", argv[0], sysyear+1-year);
00266                     sprintf(email, "%s", argv[2]);
00267                 }
00268                 else
00269                 {
00270                     sprintf(str, "It's %s's BirthDay in %d day%s.", argv[0], difference, (difference>1?"s":""));
00271                     sprintf(email, "%s", argv[2]);
00272                 }
00273             }
00274         }
00275         else
00276         {
00277             difference = 365 - sys_day_of_year + birth_day_of_year;
00278             if( difference <= day_in_advance)
00279             {
00280                 if(difference == 0)
00281                 {
00282                     sprintf(str, "It's %s's %d BirthDay Today!", argv[0], sysyear+1-year);
00283                     sprintf(email, "%s", argv[2]);
00284                 }
00285                 else
00286                 {
00287                     sprintf(str, "It's %s's BirthDay in %d day%s.", argv[0], difference, (difference>1?"s":""));
00288                     sprintf(email, "%s", argv[2]);
00289                 }
00290             }
00291         }
00292 
00293         backdiff = sys_day_of_year - birth_day_of_year;
00294         if((backdiff != 0) && (backdiff <= day_after_event))
00295         {
00296             sprintf(str, "It was %s's BirthDay %d day%s ago.", argv[0], backdiff, (backdiff>1?"s":""));
00297             sprintf(email, "%s", argv[2]);
00298         }
00299 
00300     }
00301     else
00302     {
00303         difference = birth_day_of_year - sys_day_of_year;
00304         if(difference <= day_in_advance)
00305         {
00306             if(difference == 0)
00307             {
00308                 sprintf(str, "It's %s's %d BirthDay Today!", argv[0], sysyear-year);
00309                 sprintf(email, "%s", argv[2]);
00310             }
00311             else
00312             {
00313                 sprintf(str, "It's %s's BirthDay in %d day%s.", argv[0], difference, (difference>1?"s":""));
00314                 sprintf(email, "%s", argv[2]);
00315             }
00316         }
00317     }
00318 
00319     if(strcmp(str,"empty"))
00320     {
00321         fill_second_model(GTK_TREE_MODEL(second_model), str, email);
00322         flag_listwindow = 1;
00323     }
00324 
00325     return 0;
00326 }

static int sql_callback_load ( void *  model,
int  argc,
char **  argv,
char **  azColName 
) [static]

This function acts as callback function for load_sql.

Parameters:
model is the model in which we will fill the records
argc Number of arguments passed
argv NULL terminated array of command line arguments
azColName is the name of column of the table
Returns:
0 on success

Definition at line 469 of file birthday_reminder.c.

References fill_model().

Referenced by load_sql().

00470 {
00471     if(argc)    
00472         fill_model((GtkTreeModel *)model, argv[0] , argv[1] ? argv[1] : "NULL", argv[2] ? argv[2] : "NULL");
00473     
00474     return 0;
00475 }

void window_destroy ( GtkWidget *  widget,
gpointer  data 
)

This function acts as callback function for add and edit window.

Parameters:
widget is the widget for which function is called
data is the gpointer containing NULL
Returns:
void

Definition at line 1062 of file birthday_reminder.c.

References btn_edit, and btn_new.

Referenced by callback_action_add(), and callback_action_edit().

01063 {
01064     // enabling add button after first click
01065     gtk_widget_set_sensitive(btn_new,TRUE);
01066 
01067     // enabling edit button after first click
01068     gtk_widget_set_sensitive(btn_edit,TRUE);
01069 
01070     gtk_main_quit();
01071 }


Variable Documentation

GtkWidget* add_window

Definition at line 19 of file birthday_reminder.c.

Referenced by callback_action_add(), and callback_add_record().

GtkWidget * btn_delete

Definition at line 18 of file birthday_reminder.c.

Referenced by main().

GtkWidget * btn_edit
GtkWidget* btn_new

Definition at line 18 of file birthday_reminder.c.

Referenced by callback_add_record(), main(), and window_destroy().

gchar * clicked_dob
gchar * clicked_email
gchar* clicked_name
GtkWidget* combo_date

Definition at line 21 of file birthday_reminder.c.

Referenced by callback_action_add(), and callback_add_record().

GtkWidget * combo_month

Definition at line 21 of file birthday_reminder.c.

Referenced by callback_action_add(), and callback_add_record().

GtkWidget * combo_year

Definition at line 21 of file birthday_reminder.c.

Referenced by callback_action_add(), and callback_add_record().

Definition at line 27 of file birthday_reminder.c.

Referenced by callback_parameters(), main(), main_window_destroy(), and sql_callback().

Definition at line 26 of file birthday_reminder.c.

Referenced by callback_parameters(), main(), main_window_destroy(), and sql_callback().

GtkWidget * edit_combo_date

Definition at line 21 of file birthday_reminder.c.

Referenced by callback_action_edit(), and callback_edit_record().

GtkWidget * edit_combo_month

Definition at line 21 of file birthday_reminder.c.

Referenced by callback_action_edit(), and callback_edit_record().

GtkWidget * edit_combo_year

Definition at line 21 of file birthday_reminder.c.

Referenced by callback_action_edit(), and callback_edit_record().

GtkWidget * edit_entry_email

Definition at line 20 of file birthday_reminder.c.

Referenced by callback_action_edit(), and callback_edit_record().

GtkWidget * edit_entry_name

Definition at line 20 of file birthday_reminder.c.

Referenced by callback_action_edit(), and callback_edit_record().

GtkWidget * edit_window

Definition at line 19 of file birthday_reminder.c.

Referenced by callback_action_edit(), and callback_edit_record().

GtkWidget * entry_email

Definition at line 20 of file birthday_reminder.c.

Referenced by callback_action_add(), and callback_add_record().

GtkWidget* entry_name

Definition at line 20 of file birthday_reminder.c.

Referenced by callback_action_add(), and callback_add_record().

Definition at line 28 of file birthday_reminder.c.

Referenced by listwindow(), and sql_callback().

Definition at line 25 of file birthday_reminder.c.

Referenced by callback_email(), and mail_row_selected().

gchar * replaced_name
GtkWidget * spin_adays

Definition at line 22 of file birthday_reminder.c.

Referenced by main(), and main_window_destroy().

GtkWidget* spin_pdays

Definition at line 22 of file birthday_reminder.c.

Referenced by main(), and main_window_destroy().

int startup
 All Files Functions Variables Enumerator

Generated on 8 Apr 2010 for Doxygentestproject by  doxygen 1.6.1