Mercurial > audlegacy-plugins
annotate src/bluetooth/scan_gui.c @ 2871:455e6e37feae
removed the warnings
| author | Paula Stanciu <paula.stanciu@gmail.com> |
|---|---|
| date | Thu, 07 Aug 2008 13:36:41 +0300 |
| parents | 43557eb3180f |
| children | 4128ae5633e4 |
| 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(); |
|
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
55 } |
|
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
56 return 0; |
|
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
57 } |
| 2728 | 58 } |
| 59 } | |
|
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
60 return 0; |
| 2728 | 61 } |
| 62 | |
|
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
63 void show_pairing_ok() |
|
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
64 { |
|
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
65 if(window ){ |
|
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
66 gtk_label_set_text(GTK_LABEL(scan_label),_("Bonding finish!")); |
|
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
67 } |
|
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
68 } |
|
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
69 |
|
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
70 void show_no_devices() |
|
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
71 { |
|
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
72 if(window ){ |
|
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2756
diff
changeset
|
73 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
|
74 } |
| 2728 | 75 } |
|
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
76 void destroy_scan_window() |
|
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
77 { |
| 2728 | 78 gtk_widget_hide(window); |
| 79 } | |
|
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
80 void close_window(void) |
|
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
81 { |
|
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
82 printf("scan_gui close callback \n"); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
83 gtk_widget_destroy (window); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
84 window = NULL; |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
85 } |
|
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
86 void show_scan(gint use) |
| 2728 | 87 { |
| 88 GThread *th1; | |
| 89 gchar *filename; | |
|
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
90 usage = use; |
|
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
91 /* |
|
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
92 * 0 - discovery |
|
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
93 * 1 - pairing |
|
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
94 */ |
| 2728 | 95 if (!window) |
| 96 { | |
| 97 window = gtk_window_new (GTK_WINDOW_TOPLEVEL); | |
| 98 g_signal_connect (window, "destroy",G_CALLBACK (gtk_widget_destroyed), &window); | |
| 99 | |
| 100 winbox = gtk_vbox_new(FALSE,2); | |
| 101 gtk_container_set_border_width (GTK_CONTAINER (winbox), 2); | |
| 102 gtk_container_add (GTK_CONTAINER (window), winbox); | |
| 103 | |
| 104 scanbox = gtk_hbox_new(FALSE,2); | |
| 105 gtk_container_set_border_width(GTK_CONTAINER(scanbox),2); | |
| 106 gtk_container_add(GTK_CONTAINER(winbox),scanbox); | |
| 107 | |
| 108 progressbox = gtk_vbox_new(FALSE,2); | |
| 109 gtk_container_set_border_width(GTK_CONTAINER(progressbox),4); | |
| 110 gtk_container_add(GTK_CONTAINER(winbox),progressbox); | |
| 111 filename = DATA_DIR G_DIR_SEPARATOR_S "images" G_DIR_SEPARATOR_S "blue.png"; | |
| 112 bluetooth_img = gtk_image_new_from_file(filename); | |
| 113 gtk_image_set_pixel_size(GTK_IMAGE(bluetooth_img),-1); | |
| 114 gtk_container_add(GTK_CONTAINER(scanbox),bluetooth_img); | |
|
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
115 if(usage == 0){ |
|
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
116 scan_label = gtk_label_new_with_mnemonic(_("Scanning...")); |
|
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
117 }else |
|
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
118 { |
|
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
119 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
|
120 } |
| 2728 | 121 |
| 122 gtk_container_add(GTK_CONTAINER(scanbox),scan_label); | |
| 123 | |
| 124 progress_bar = gtk_progress_bar_new(); | |
| 125 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar)); | |
| 126 gtk_container_add(GTK_CONTAINER(progressbox),progress_bar); | |
| 127 th1 = g_thread_create((GThreadFunc)progress, NULL,TRUE,NULL); | |
|
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
128 buttonsbox = gtk_hbox_new(FALSE,2); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
129 gtk_container_set_border_width(GTK_CONTAINER(buttonsbox),2); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
130 gtk_container_add(GTK_CONTAINER(progressbox),buttonsbox); |
|
2847
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
131 /* 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
|
132 * and treat the case when the bounding is not ok |
|
671cdfc2d62d
Basic pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2839
diff
changeset
|
133 */ |
|
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
134 if(usage == 0){ |
|
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
135 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
|
136 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
|
137 }else{ |
| 2854 | 138 rescan_buttton = gtk_button_new_with_mnemonic(_("Play")); |
| 139 g_signal_connect(rescan_buttton,"clicked",G_CALLBACK (play_call),NULL); | |
|
2853
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
140 } |
|
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
141 |
|
fed560b80720
added Retry button for the pairing interface
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2847
diff
changeset
|
142 |
|
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
143 |
|
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2756
diff
changeset
|
144 close_button = gtk_button_new_with_mnemonic(_("Close")); |
|
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
145 gtk_container_add(GTK_CONTAINER(buttonsbox),rescan_buttton); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
146 gtk_container_add(GTK_CONTAINER(buttonsbox),close_button); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
147 g_signal_connect(close_button,"clicked",G_CALLBACK (close_window),NULL); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
148 |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
149 gtk_window_set_default_size (GTK_WINDOW (window), 60, 40); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
150 gtk_window_set_resizable(GTK_WINDOW(window),FALSE); |
| 2728 | 151 if (!GTK_WIDGET_VISIBLE (window)) |
| 152 gtk_widget_show_all (window); | |
| 153 else | |
|
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
154 { |
| 2728 | 155 gtk_widget_destroy (window); |
| 156 g_free(filename); | |
| 157 window = NULL; | |
| 158 } | |
| 159 | |
|
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
160 } |
| 2728 | 161 |
| 162 } |
