comparison src/bluetooth/scan_gui.c @ 2853:fed560b80720

added Retry button for the pairing interface
author Paula Stanciu <paula.stanciu@gmail.com>
date Tue, 29 Jul 2008 18:49:04 +0300
parents 671cdfc2d62d
children 43557eb3180f
comparison
equal deleted inserted replaced
2847:671cdfc2d62d 2853:fed560b80720
29 static GtkWidget *progress_bar; 29 static GtkWidget *progress_bar;
30 static GtkWidget *rescan_buttton; 30 static GtkWidget *rescan_buttton;
31 static GtkWidget *close_button; 31 static GtkWidget *close_button;
32 static gint usage=0; 32 static gint usage=0;
33 33
34 gpointer progress() { 34 gpointer progress()
35 {
35 36
36 for(;;){ 37 for(;;){
37 if(window){ 38 if(window){
38 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar)); 39 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar));
39 } 40 }
40 sleep(1); 41 sleep(1);
41 if(usage == 0){ 42 if(usage == 0){
42 if(discover_finish == 2 ) { 43 if(discover_finish == 2 ) {
43 if(window){ 44 if(window){
44 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar),1); 45 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar),1);
46 }
47 return 0;
45 } 48 }
46 return 0; 49 }else
50 {
51 if(bonding_finish == 1 ) {
52 if(window){
53 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar),1);
54 show_pairing_ok();
55 }
56 return 0;
57 }
47 } 58 }
48 }else
49 {
50 if(bonding_finish == 1 ) {
51 if(window){
52 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar),1);
53 show_pairing_ok();
54 }
55 return 0;
56 }
57 }
58 } 59 }
59 return 0; 60 return 0;
60 } 61 }
61 62
62 void show_pairing_ok() 63 void show_pairing_ok()
63 { 64 {
64 if(window ){ 65 if(window ){
65 gtk_label_set_text(GTK_LABEL(scan_label),_("Bonding finish!")); 66 gtk_label_set_text(GTK_LABEL(scan_label),_("Bonding finish!"));
66 } 67 }
67 } 68 }
68 69
69 void show_no_devices(){ 70 void show_no_devices()
71 {
70 if(window ){ 72 if(window ){
71 gtk_label_set_text(GTK_LABEL(scan_label),_("No devices found!")); 73 gtk_label_set_text(GTK_LABEL(scan_label),_("No devices found!"));
72 } 74 }
73 } 75 }
74 void destroy_scan_window(){ 76 void destroy_scan_window()
77 {
75 gtk_widget_hide(window); 78 gtk_widget_hide(window);
76 } 79 }
77 void close_window(void){ 80 void close_window(void)
81 {
78 printf("scan_gui close callback \n"); 82 printf("scan_gui close callback \n");
79 gtk_widget_destroy (window); 83 gtk_widget_destroy (window);
80 window = NULL; 84 window = NULL;
81 } 85 }
82 86 void retry_call(void)
87 {
88 printf("retry callback\n");
89 }
83 90
84 void show_scan(gint use) 91 void show_scan(gint use)
85 { 92 {
86 GThread *th1; 93 GThread *th1;
87 gchar *filename; 94 gchar *filename;
111 gtk_image_set_pixel_size(GTK_IMAGE(bluetooth_img),-1); 118 gtk_image_set_pixel_size(GTK_IMAGE(bluetooth_img),-1);
112 gtk_container_add(GTK_CONTAINER(scanbox),bluetooth_img); 119 gtk_container_add(GTK_CONTAINER(scanbox),bluetooth_img);
113 if(usage == 0){ 120 if(usage == 0){
114 scan_label = gtk_label_new_with_mnemonic(_("Scanning...")); 121 scan_label = gtk_label_new_with_mnemonic(_("Scanning..."));
115 }else 122 }else
116 { 123 {
117 scan_label = gtk_label_new_with_mnemonic(_("Pairing...")); 124 scan_label = gtk_label_new_with_mnemonic(_("Pairing..."));
118 } 125 }
119 126
120 gtk_container_add(GTK_CONTAINER(scanbox),scan_label); 127 gtk_container_add(GTK_CONTAINER(scanbox),scan_label);
121 128
122 progress_bar = gtk_progress_bar_new(); 129 progress_bar = gtk_progress_bar_new();
123 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar)); 130 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar));
127 gtk_container_set_border_width(GTK_CONTAINER(buttonsbox),2); 134 gtk_container_set_border_width(GTK_CONTAINER(buttonsbox),2);
128 gtk_container_add(GTK_CONTAINER(progressbox),buttonsbox); 135 gtk_container_add(GTK_CONTAINER(progressbox),buttonsbox);
129 /* I have to modify the rescan button with a play one 136 /* I have to modify the rescan button with a play one
130 * and treat the case when the bounding is not ok 137 * and treat the case when the bounding is not ok
131 */ 138 */
132 rescan_buttton = gtk_button_new_with_mnemonic(_("Rescan")); 139 if(usage == 0){
133 g_signal_connect(rescan_buttton,"clicked",G_CALLBACK (refresh_call),NULL); 140 rescan_buttton = gtk_button_new_with_mnemonic(_("Rescan"));
141 g_signal_connect(rescan_buttton,"clicked",G_CALLBACK (refresh_call),NULL);
142 }else{
143 rescan_buttton = gtk_button_new_with_mnemonic(_("Retry"));
144 g_signal_connect(rescan_buttton,"clicked",G_CALLBACK (retry_call),NULL);
145 }
146
147
134 148
135 close_button = gtk_button_new_with_mnemonic(_("Close")); 149 close_button = gtk_button_new_with_mnemonic(_("Close"));
136 gtk_container_add(GTK_CONTAINER(buttonsbox),rescan_buttton); 150 gtk_container_add(GTK_CONTAINER(buttonsbox),rescan_buttton);
137 gtk_container_add(GTK_CONTAINER(buttonsbox),close_button); 151 gtk_container_add(GTK_CONTAINER(buttonsbox),close_button);
138 g_signal_connect(close_button,"clicked",G_CALLBACK (close_window),NULL); 152 g_signal_connect(close_button,"clicked",G_CALLBACK (close_window),NULL);