Mercurial > audlegacy-plugins
annotate src/bluetooth/scan_gui.c @ 2884:4128ae5633e4
disable play button while pairing - some cleanups
author | Paula Stanciu <paula.stanciu@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 20:46:49 +0300 |
parents | 455e6e37feae |
children | 7a1bc6c600e0 |
rev | line source |
---|---|
2839 | 1 /* |
2 * Audacious Bluetooth headset suport plugin | |
3 * | |
4 * Copyright (c) 2008 Paula Stanciu paula.stanciu@gmail.com | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; under version 3 of the License. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with this program. If not, see <http://www.gnu.org/licenses>. | |
17 */ | |
18 | |
2728 | 19 #include "scan_gui.h" |
20 #include "bluetooth.h" | |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
21 #include "agent.h" |
2728 | 22 static GtkWidget *window = NULL; |
23 static GtkWidget *winbox; | |
24 static GtkWidget *scanbox; | |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
25 static GtkWidget *buttonsbox; |
2728 | 26 static GtkWidget *progressbox; |
27 static GtkWidget *bluetooth_img; | |
28 static GtkWidget *scan_label; | |
29 static GtkWidget *progress_bar; | |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
30 static GtkWidget *rescan_buttton; |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
31 static GtkWidget *close_button; |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
32 static gint usage=0; |
2871
455e6e37feae
removed the warnings
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2854
diff
changeset
|
33 void show_pairing_ok(void); |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
34 gpointer progress() |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
35 { |
2728 | 36 |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
37 for(;;){ |
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
38 if(window){ |
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
39 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar)); |
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
40 } |
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
41 sleep(1); |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
42 if(usage == 0){ |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
43 if(discover_finish == 2 ) { |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
44 if(window){ |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
45 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar),1); |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
46 } |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
47 return 0; |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
48 } |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
49 }else |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
50 { |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
51 if(bonding_finish == 1 ) { |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
52 if(window){ |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
53 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar),1); |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
54 show_pairing_ok(); |
2884
4128ae5633e4
disable play button while pairing - some cleanups
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2871
diff
changeset
|
55 gtk_widget_set_sensitive(rescan_buttton,TRUE); |
4128ae5633e4
disable play button while pairing - some cleanups
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2871
diff
changeset
|
56 |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
57 } |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
58 return 0; |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
59 } |
2728 | 60 } |
61 } | |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
62 return 0; |
2728 | 63 } |
64 | |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
65 void show_pairing_ok() |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
66 { |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
67 if(window ){ |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
68 gtk_label_set_text(GTK_LABEL(scan_label),_("Bonding finish!")); |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
69 } |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
70 } |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
71 |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
72 void show_no_devices() |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
73 { |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
74 if(window ){ |
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2756
diff
changeset
|
75 gtk_label_set_text(GTK_LABEL(scan_label),_("No devices found!")); |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
76 } |
2728 | 77 } |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
78 void destroy_scan_window() |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
79 { |
2728 | 80 gtk_widget_hide(window); |
81 } | |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
82 void close_window(void) |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
83 { |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
84 printf("scan_gui close callback \n"); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
85 gtk_widget_destroy (window); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
86 window = NULL; |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
87 } |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
88 void show_scan(gint use) |
2728 | 89 { |
90 GThread *th1; | |
91 gchar *filename; | |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
92 usage = use; |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
93 /* |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
94 * 0 - discovery |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
95 * 1 - pairing |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
96 */ |
2728 | 97 if (!window) |
98 { | |
99 window = gtk_window_new (GTK_WINDOW_TOPLEVEL); | |
100 g_signal_connect (window, "destroy",G_CALLBACK (gtk_widget_destroyed), &window); | |
101 | |
102 winbox = gtk_vbox_new(FALSE,2); | |
103 gtk_container_set_border_width (GTK_CONTAINER (winbox), 2); | |
104 gtk_container_add (GTK_CONTAINER (window), winbox); | |
105 | |
106 scanbox = gtk_hbox_new(FALSE,2); | |
107 gtk_container_set_border_width(GTK_CONTAINER(scanbox),2); | |
108 gtk_container_add(GTK_CONTAINER(winbox),scanbox); | |
109 | |
110 progressbox = gtk_vbox_new(FALSE,2); | |
111 gtk_container_set_border_width(GTK_CONTAINER(progressbox),4); | |
112 gtk_container_add(GTK_CONTAINER(winbox),progressbox); | |
113 filename = DATA_DIR G_DIR_SEPARATOR_S "images" G_DIR_SEPARATOR_S "blue.png"; | |
114 bluetooth_img = gtk_image_new_from_file(filename); | |
115 gtk_image_set_pixel_size(GTK_IMAGE(bluetooth_img),-1); | |
116 gtk_container_add(GTK_CONTAINER(scanbox),bluetooth_img); | |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
117 if(usage == 0){ |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
118 scan_label = gtk_label_new_with_mnemonic(_("Scanning...")); |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
119 }else |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
120 { |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
121 scan_label = gtk_label_new_with_mnemonic(_("Pairing...")); |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
122 } |
2728 | 123 |
124 gtk_container_add(GTK_CONTAINER(scanbox),scan_label); | |
125 | |
126 progress_bar = gtk_progress_bar_new(); | |
127 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar)); | |
128 gtk_container_add(GTK_CONTAINER(progressbox),progress_bar); | |
129 th1 = g_thread_create((GThreadFunc)progress, NULL,TRUE,NULL); | |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
130 buttonsbox = gtk_hbox_new(FALSE,2); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
131 gtk_container_set_border_width(GTK_CONTAINER(buttonsbox),2); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
132 gtk_container_add(GTK_CONTAINER(progressbox),buttonsbox); |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
133 /* I have to modify the rescan button with a play one |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
134 * and treat the case when the bounding is not ok |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
135 */ |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
136 if(usage == 0){ |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
137 rescan_buttton = gtk_button_new_with_mnemonic(_("Rescan")); |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
138 g_signal_connect(rescan_buttton,"clicked",G_CALLBACK (refresh_call),NULL); |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
139 }else{ |
2854 | 140 rescan_buttton = gtk_button_new_with_mnemonic(_("Play")); |
141 g_signal_connect(rescan_buttton,"clicked",G_CALLBACK (play_call),NULL); | |
2884
4128ae5633e4
disable play button while pairing - some cleanups
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2871
diff
changeset
|
142 gtk_widget_set_sensitive(rescan_buttton,FALSE); |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
143 } |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
144 |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
145 |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
146 |
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2756
diff
changeset
|
147 close_button = gtk_button_new_with_mnemonic(_("Close")); |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
148 gtk_container_add(GTK_CONTAINER(buttonsbox),rescan_buttton); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
149 gtk_container_add(GTK_CONTAINER(buttonsbox),close_button); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
150 g_signal_connect(close_button,"clicked",G_CALLBACK (close_window),NULL); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
151 |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
152 gtk_window_set_default_size (GTK_WINDOW (window), 60, 40); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
153 gtk_window_set_resizable(GTK_WINDOW(window),FALSE); |
2728 | 154 if (!GTK_WIDGET_VISIBLE (window)) |
155 gtk_widget_show_all (window); | |
156 else | |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
157 { |
2728 | 158 gtk_widget_destroy (window); |
159 g_free(filename); | |
160 window = NULL; | |
161 } | |
162 | |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
163 } |
2728 | 164 |
165 } |