Mercurial > audlegacy-plugins
annotate src/bluetooth/scan_gui.c @ 3144:de2f796d6f04
crossfade: fix preprocessor conditional compilation
author | Michal Lipski <tallica@o2.pl> |
---|---|
date | Sat, 09 May 2009 18:06:58 +0200 |
parents | 5e97b55f87cf |
children |
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); |
2885
7a1bc6c600e0
Disable rescan/connect while scanning / when no device is selected
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2884
diff
changeset
|
46 gtk_widget_set_sensitive(rescan_buttton,TRUE); |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
47 } |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
48 return 0; |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
49 } |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
50 }else |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
51 { |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
52 if(bonding_finish == 1 ) { |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
53 if(window){ |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
54 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
|
55 show_pairing_ok(); |
2884
4128ae5633e4
disable play button while pairing - some cleanups
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2871
diff
changeset
|
56 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
|
57 |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
58 } |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
59 return 0; |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
60 } |
2889
6c53f9fa9029
Backed out changeset 59ff744e1e23
Matti Hamalainen <ccr@tnsp.org>
parents:
2854
diff
changeset
|
61 } |
2728 | 62 } |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
63 return 0; |
2728 | 64 } |
65 | |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
66 void show_pairing_ok() |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
67 { |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
68 if(window ){ |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
69 gtk_label_set_text(GTK_LABEL(scan_label),_("Bonding finish!")); |
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 } |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
72 |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
73 void show_no_devices() |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
74 { |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
75 if(window ){ |
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2756
diff
changeset
|
76 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
|
77 } |
2728 | 78 } |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
79 void destroy_scan_window() |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
80 { |
2728 | 81 gtk_widget_hide(window); |
82 } | |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
83 void close_window(void) |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
84 { |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
85 printf("scan_gui close callback \n"); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
86 gtk_widget_destroy (window); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
87 window = NULL; |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
88 } |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
89 void show_scan(gint use) |
2728 | 90 { |
91 GThread *th1; | |
92 gchar *filename; | |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
93 usage = use; |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
94 /* |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
95 * 0 - discovery |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
96 * 1 - pairing |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
97 */ |
2728 | 98 if (!window) |
99 { | |
100 window = gtk_window_new (GTK_WINDOW_TOPLEVEL); | |
101 g_signal_connect (window, "destroy",G_CALLBACK (gtk_widget_destroyed), &window); | |
102 | |
103 winbox = gtk_vbox_new(FALSE,2); | |
104 gtk_container_set_border_width (GTK_CONTAINER (winbox), 2); | |
105 gtk_container_add (GTK_CONTAINER (window), winbox); | |
106 | |
107 scanbox = gtk_hbox_new(FALSE,2); | |
108 gtk_container_set_border_width(GTK_CONTAINER(scanbox),2); | |
109 gtk_container_add(GTK_CONTAINER(winbox),scanbox); | |
110 | |
111 progressbox = gtk_vbox_new(FALSE,2); | |
112 gtk_container_set_border_width(GTK_CONTAINER(progressbox),4); | |
113 gtk_container_add(GTK_CONTAINER(winbox),progressbox); | |
114 filename = DATA_DIR G_DIR_SEPARATOR_S "images" G_DIR_SEPARATOR_S "blue.png"; | |
115 bluetooth_img = gtk_image_new_from_file(filename); | |
116 gtk_image_set_pixel_size(GTK_IMAGE(bluetooth_img),-1); | |
117 gtk_container_add(GTK_CONTAINER(scanbox),bluetooth_img); | |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
118 if(usage == 0){ |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
119 scan_label = gtk_label_new_with_mnemonic(_("Scanning...")); |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
120 }else |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
121 { |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
122 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
|
123 } |
2728 | 124 |
125 gtk_container_add(GTK_CONTAINER(scanbox),scan_label); | |
126 | |
127 progress_bar = gtk_progress_bar_new(); | |
128 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar)); | |
129 gtk_container_add(GTK_CONTAINER(progressbox),progress_bar); | |
130 th1 = g_thread_create((GThreadFunc)progress, NULL,TRUE,NULL); | |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
131 buttonsbox = gtk_hbox_new(FALSE,2); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
132 gtk_container_set_border_width(GTK_CONTAINER(buttonsbox),2); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
133 gtk_container_add(GTK_CONTAINER(progressbox),buttonsbox); |
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
134 /* 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
|
135 * and treat the case when the bounding is not ok |
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
136 */ |
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
137 if(usage == 0){ |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
138 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
|
139 g_signal_connect(rescan_buttton,"clicked",G_CALLBACK (refresh_call),NULL); |
2885
7a1bc6c600e0
Disable rescan/connect while scanning / when no device is selected
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2884
diff
changeset
|
140 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
|
141 }else{ |
2854 | 142 rescan_buttton = gtk_button_new_with_mnemonic(_("Play")); |
143 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
|
144 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
|
145 } |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
146 |
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
147 |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
148 |
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2756
diff
changeset
|
149 close_button = gtk_button_new_with_mnemonic(_("Close")); |
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
150 gtk_container_add(GTK_CONTAINER(buttonsbox),rescan_buttton); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
151 gtk_container_add(GTK_CONTAINER(buttonsbox),close_button); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
152 g_signal_connect(close_button,"clicked",G_CALLBACK (close_window),NULL); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
153 |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
154 gtk_window_set_default_size (GTK_WINDOW (window), 60, 40); |
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
155 gtk_window_set_resizable(GTK_WINDOW(window),FALSE); |
2728 | 156 if (!GTK_WIDGET_VISIBLE (window)) |
157 gtk_widget_show_all (window); | |
158 else | |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
159 { |
2728 | 160 gtk_widget_destroy (window); |
161 g_free(filename); | |
162 window = NULL; | |
163 } | |
164 | |
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
165 } |
2728 | 166 |
167 } |