1 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
2 #include <hildon/hildon.h>
9 osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activated)
16 GtkWidget *btnVibrate;
21 gdouble sldValue = 5.0;
22 gdouble newValue = 0.0;
29 /* Create dialog with OK and Cancel buttons. Leave the separator out,
30 * as we do not have any content. */
31 dialog = gtk_dialog_new_with_buttons(
32 "Call Notify Settings",
34 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
41 /* ... add something to the dialog ... */
42 btnVisual = (GtkWidget*)hildon_check_button_new(HILDON_SIZE_FULLSCREEN_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
43 gtk_button_set_label (GTK_BUTTON (btnVisual), "Visual Notification");
45 btnVibrate = (GtkWidget*)hildon_check_button_new(HILDON_SIZE_FULLSCREEN_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
46 gtk_button_set_label (GTK_BUTTON (btnVibrate), "Vibrate Notification");
48 btnSound = (GtkWidget*)hildon_check_button_new(HILDON_SIZE_FULLSCREEN_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
49 gtk_button_set_label (GTK_BUTTON (btnSound), "Sound Notification");
51 lblText = (GtkWidget*)gtk_label_new("Please select notification interval:");
54 slider = gtk_hscale_new_with_range(0.0, 60.0, 0.1);
55 adj = gtk_range_get_adjustment(GTK_RANGE(slider));
57 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVisual), TRUE);
58 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVibrate) , TRUE);
59 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnSound), TRUE);
61 inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "r");
63 if (inputFilePtr != NULL)
66 fgets(fileContent, 12,inputFilePtr);
69 if (fileContent[0]=='n')
70 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVisual), FALSE);
71 if (fileContent[2]=='n')
72 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVibrate) , FALSE);
73 if (fileContent[4]=='n')
74 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnSound), FALSE);
76 (char*)strtok(fileContent, ";");
77 (char*)strtok(NULL, ";");
78 (char*)strtok(NULL, ";");
80 fileDouble = strtok(NULL, ";");
86 for (i=0; i<strlen(fileDouble); i++)
87 if (fileDouble[i]==',')
90 sldValue = g_strtod(fileDouble, NULL);
98 gtk_adjustment_set_value(adj, sldValue);
100 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), btnVisual);
101 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), btnVibrate);
102 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), btnSound);
103 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), lblText);
104 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), slider);
106 gtk_widget_show_all(dialog);
108 /* Wait until user finishes the dialog. */
109 response = gtk_dialog_run(GTK_DIALOG(dialog));
111 if (response == GTK_RESPONSE_OK)
113 /* ... do something with the dialog stuff ... */
114 inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "w");
116 if (inputFilePtr == NULL)
118 mkdir("/home/user/.config/CallNotify", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
119 inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "w");
122 if (inputFilePtr != NULL)
124 a = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnVisual)) ? 'y' : 'n';
125 b = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnVibrate)) ? 'y' : 'n';
126 c = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnSound)) ? 'y' : 'n';
128 newValue = gtk_adjustment_get_value(adj);
130 fprintf(inputFilePtr, "%c;%c;%c;%.1f\n",a,b,c,newValue);
131 fclose(inputFilePtr);
136 /* Free the dialog (and it's children) */
138 gtk_widget_destroy(GTK_WIDGET(dialog));
143 osso_return_t save_state(osso_context_t *osso, gpointer data)
145 /* ... save state ... */