1 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
2 #include <hildon/hildon.h>
7 osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activated)
14 GtkWidget *btnVibrate;
19 gdouble sldValue = 0.0;
20 gdouble newValue = 0.0;
26 /* Create dialog with OK and Cancel buttons. Leave the separator out,
27 * as we do not have any content. */
28 dialog = gtk_dialog_new_with_buttons(
29 "Call Notify Settings",
31 GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
38 /* ... add something to the dialog ... */
39 //btnVisual = gtk_check_button_new_with_label();
40 btnVisual = (GtkWidget*)hildon_check_button_new(HILDON_SIZE_FULLSCREEN_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
41 gtk_button_set_label (GTK_BUTTON (btnVisual), "Visual Notification");
43 btnVibrate = (GtkWidget*)hildon_check_button_new(HILDON_SIZE_FULLSCREEN_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
44 gtk_button_set_label (GTK_BUTTON (btnVibrate), "Vibrate Notification");
46 btnSound = (GtkWidget*)hildon_check_button_new(HILDON_SIZE_FULLSCREEN_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
47 gtk_button_set_label (GTK_BUTTON (btnSound), "Sound Notification");
49 lblText = (GtkWidget*)gtk_label_new("Please select notification interval:");
52 slider = gtk_hscale_new_with_range(0.0, 60.0, 0.1);
53 adj = gtk_range_get_adjustment(GTK_RANGE(slider));
56 FILE *inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "r");
58 if (inputFilePtr != NULL)
62 fgets(fileContent, 12,inputFilePtr);
65 if (fileContent[0]=='y')
66 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVisual), TRUE);
67 if (fileContent[2]=='y')
68 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnVibrate) , TRUE);
69 if (fileContent[4]=='y')
70 hildon_check_button_set_active (HILDON_CHECK_BUTTON(btnSound), TRUE);
72 (char*)strtok(fileContent, ";");
73 (char*)strtok(NULL, ";");
74 (char*)strtok(NULL, ";");
76 fileDouble = strtok(NULL, ";");
79 for (i=0; i<strlen(fileDouble); i++)
80 if (fileDouble[i]==',')
83 sldValue = g_strtod(fileDouble, NULL);
85 gtk_adjustment_set_value(adj, sldValue);
92 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), btnVisual);
93 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), btnVibrate);
94 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), btnSound);
95 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), lblText);
96 gtk_container_add(GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), slider);
98 gtk_widget_show_all(dialog);
100 /* Wait until user finishes the dialog. */
101 response = gtk_dialog_run(GTK_DIALOG(dialog));
103 if (response == GTK_RESPONSE_OK)
105 /* ... do something with the dialog stuff ... */
107 inputFilePtr = fopen("/home/user/.config/CallNotify/conf.txt", "w");
110 a = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnVisual)) ? 'y' : 'n';
111 b = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnVibrate)) ? 'y' : 'n';
112 c = hildon_check_button_get_active(HILDON_CHECK_BUTTON(btnSound)) ? 'y' : 'n';
114 newValue = gtk_adjustment_get_value(adj);
117 fprintf(inputFilePtr, "%c;%c;%c;%.1f\n",a,b,c,newValue);
119 fclose(inputFilePtr);
123 /* Free the dialog (and it's children) */
125 gtk_widget_destroy(GTK_WIDGET(dialog));
130 osso_return_t save_state(osso_context_t *osso, gpointer data)
132 /* ... save state ... */