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 = 0.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));
58 inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "r");
60 if (inputFilePtr != NULL)
63 fgets(fileContent, 12,inputFilePtr);
66 if (fileContent[0]=='y')
67 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVisual), TRUE);
68 if (fileContent[2]=='y')
69 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVibrate) , TRUE);
70 if (fileContent[4]=='y')
71 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnSound), TRUE);
73 (char*)strtok(fileContent, ";");
74 (char*)strtok(NULL, ";");
75 (char*)strtok(NULL, ";");
77 fileDouble = strtok(NULL, ";");
83 for (i=0; i<strlen(fileDouble); i++)
84 if (fileDouble[i]==',')
87 sldValue = g_strtod(fileDouble, NULL);
95 gtk_adjustment_set_value(adj, sldValue);
97 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), btnVisual);
98 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), btnVibrate);
99 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), btnSound);
100 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), lblText);
101 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), slider);
103 gtk_widget_show_all(dialog);
105 /* Wait until user finishes the dialog. */
106 response = gtk_dialog_run(GTK_DIALOG(dialog));
108 if (response == GTK_RESPONSE_OK)
110 /* ... do something with the dialog stuff ... */
111 inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "w");
113 if (inputFilePtr == NULL)
115 mkdir("/home/user/.config/CallNotify", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
116 inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "w");
119 if (inputFilePtr != NULL)
121 a = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnVisual)) ? 'y' : 'n';
122 b = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnVibrate)) ? 'y' : 'n';
123 c = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnSound)) ? 'y' : 'n';
125 newValue = gtk_adjustment_get_value(adj);
127 fprintf(inputFilePtr, "%c;%c;%c;%.1f\n",a,b,c,newValue);
128 fclose(inputFilePtr);
133 /* Free the dialog (and it's children) */
135 gtk_widget_destroy(GTK_WIDGET(dialog));
140 osso_return_t save_state(osso_context_t *osso, gpointer data)
142 /* ... save state ... */