This repository has been archived by the owner on Apr 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.c
104 lines (72 loc) · 2.76 KB
/
gui.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "gui.h"
#include <gtk/gtk.h>
/* Another callback */
static void quit( GtkWidget *widget,
gpointer data )
{
gtk_main_quit ();
}
static void send( GtkWidget *widget,
gpointer data )
{
g_print (" sending mail to be done \n");
}
void giveMeACall(void (*callback)() ){
g_print (" calling callback from c \n");
if(callback){
(*callback)();
}else{
g_print ("amit you have sckrewed up something... your callback is null .. fix it ... \n");
}
}
void showGtkUI(int argc, char* argv[])
{
GtkWidget *window;
GtkWidget *button;
GtkWidget *toLabel, *fromLabel , *bodyLabel;
GtkWidget *toEntry, * fromEntry, *bodyEntry;
GtkWidget *box;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (quit), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
box = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER(window), box);
gtk_widget_show(box);
// Create a label and add it to the box
toLabel = gtk_label_new ("enter recipient");
gtk_box_pack_start (GTK_BOX (box), toLabel, TRUE, TRUE, 5);
gtk_widget_show(toLabel);
// Create an entry field and add it to the box
toEntry = gtk_entry_new();
gtk_box_pack_start (GTK_BOX (box), toEntry, TRUE, TRUE, 5);
gtk_widget_show(toEntry);
gtk_widget_grab_focus(toEntry);
//-----------------------------------------------------------------
// Create a label and add it to the box
fromLabel = gtk_label_new ("enter sender ");
gtk_box_pack_start (GTK_BOX (box), fromLabel, TRUE, TRUE, 5);
gtk_widget_show(fromLabel);
// Create an entry field and add it to the box
fromEntry = gtk_entry_new();
gtk_box_pack_start (GTK_BOX (box), fromEntry, TRUE, TRUE, 5);
gtk_widget_show(fromEntry);
// Create a label and add it to the box
bodyLabel = gtk_label_new ("enter message ");
gtk_box_pack_start (GTK_BOX (box), bodyLabel, TRUE, TRUE, 5);
gtk_widget_show(bodyLabel);
// Create an entry field and add it to the box
bodyEntry = gtk_entry_new();
gtk_box_pack_start (GTK_BOX (box), bodyEntry, TRUE, TRUE, 5);
gtk_widget_show(bodyEntry);
/* Creates a new button with the label "Hello World". */
button = gtk_button_new_with_label ("Sendmail");
gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 5);
g_signal_connect (button, "clicked",G_CALLBACK (send), NULL);
/* This packs the button into the window (a gtk container). */
gtk_container_add (GTK_CONTAINER (window), button);
/* The final step is to display this newly created widget. */
gtk_widget_show (button);
gtk_widget_show (window);
gtk_main ();
}