Mercurial > audlegacy-plugins
annotate src/bluetooth/scan_gui.c @ 2839:22a5075fc7f7
GPL Headers
| author | Paula Stanciu <paula.stanciu@gmail.com> |
|---|---|
| date | Wed, 16 Jul 2008 20:57:17 +0300 |
| parents | d45b4beadf6c |
| children | 671cdfc2d62d |
| 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" | |
| 21 static GtkWidget *window = NULL; | |
| 22 static GtkWidget *winbox; | |
| 23 static GtkWidget *scanbox; | |
|
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
24 static GtkWidget *buttonsbox; |
| 2728 | 25 static GtkWidget *progressbox; |
| 26 static GtkWidget *bluetooth_img; | |
| 27 static GtkWidget *scan_label; | |
| 28 static GtkWidget *progress_bar; | |
|
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
29 static GtkWidget *rescan_buttton; |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
30 static GtkWidget *close_button; |
| 2728 | 31 gpointer progress() { |
| 32 | |
|
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
33 for(;;){ |
|
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
34 if(window){ |
|
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
35 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
|
36 } |
|
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
37 sleep(1); |
|
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
38 if(discover_finish == 2 ) { |
|
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
39 if(window){ |
|
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
40 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar),1); |
|
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
41 } |
| 2728 | 42 return 0; |
| 43 } | |
| 44 } | |
|
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
45 return 0; |
| 2728 | 46 } |
| 47 | |
| 48 void show_no_devices(){ | |
|
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
49 if(window ){ |
|
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2756
diff
changeset
|
50 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
|
51 } |
| 2728 | 52 } |
| 53 void destroy_scan_window(){ | |
| 54 gtk_widget_hide(window); | |
| 55 } | |
|
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
56 void close_window(void){ |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
57 printf("scan_gui close callback \n"); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
58 gtk_widget_destroy (window); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
59 window = NULL; |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
60 } |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
61 |
| 2728 | 62 |
| 63 void show_scan() | |
| 64 { | |
| 65 GThread *th1; | |
| 66 gchar *filename; | |
| 67 if (!window) | |
| 68 { | |
| 69 window = gtk_window_new (GTK_WINDOW_TOPLEVEL); | |
| 70 g_signal_connect (window, "destroy",G_CALLBACK (gtk_widget_destroyed), &window); | |
| 71 | |
| 72 winbox = gtk_vbox_new(FALSE,2); | |
| 73 gtk_container_set_border_width (GTK_CONTAINER (winbox), 2); | |
| 74 gtk_container_add (GTK_CONTAINER (window), winbox); | |
| 75 | |
| 76 scanbox = gtk_hbox_new(FALSE,2); | |
| 77 gtk_container_set_border_width(GTK_CONTAINER(scanbox),2); | |
| 78 gtk_container_add(GTK_CONTAINER(winbox),scanbox); | |
| 79 | |
| 80 progressbox = gtk_vbox_new(FALSE,2); | |
| 81 gtk_container_set_border_width(GTK_CONTAINER(progressbox),4); | |
| 82 gtk_container_add(GTK_CONTAINER(winbox),progressbox); | |
| 83 filename = DATA_DIR G_DIR_SEPARATOR_S "images" G_DIR_SEPARATOR_S "blue.png"; | |
| 84 bluetooth_img = gtk_image_new_from_file(filename); | |
| 85 gtk_image_set_pixel_size(GTK_IMAGE(bluetooth_img),-1); | |
| 86 gtk_container_add(GTK_CONTAINER(scanbox),bluetooth_img); | |
| 87 | |
|
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2756
diff
changeset
|
88 scan_label = gtk_label_new_with_mnemonic(_("Scanning...")); |
| 2728 | 89 gtk_container_add(GTK_CONTAINER(scanbox),scan_label); |
| 90 | |
| 91 progress_bar = gtk_progress_bar_new(); | |
| 92 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar)); | |
| 93 gtk_container_add(GTK_CONTAINER(progressbox),progress_bar); | |
| 94 th1 = g_thread_create((GThreadFunc)progress, NULL,TRUE,NULL); | |
| 95 /* I have to add a button for Rescan when there are | |
| 96 * no devices found and not currently scanning | |
| 97 */ | |
|
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
98 buttonsbox = gtk_hbox_new(FALSE,2); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
99 gtk_container_set_border_width(GTK_CONTAINER(buttonsbox),2); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
100 gtk_container_add(GTK_CONTAINER(progressbox),buttonsbox); |
|
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2756
diff
changeset
|
101 rescan_buttton = gtk_button_new_with_mnemonic(_("Rescan")); |
|
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
102 g_signal_connect(rescan_buttton,"clicked",G_CALLBACK (refresh_call),NULL); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
103 |
|
2764
d45b4beadf6c
Made "bluetooth" and "streambrowser" plugins translatable.
Stany HENRY <StrassBoy@gmail.com>
parents:
2756
diff
changeset
|
104 close_button = gtk_button_new_with_mnemonic(_("Close")); |
|
2756
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
105 gtk_container_add(GTK_CONTAINER(buttonsbox),rescan_buttton); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
106 gtk_container_add(GTK_CONTAINER(buttonsbox),close_button); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
107 g_signal_connect(close_button,"clicked",G_CALLBACK (close_window),NULL); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
108 |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
109 gtk_window_set_default_size (GTK_WINDOW (window), 60, 40); |
|
d3d71539d675
rescan functionality
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2732
diff
changeset
|
110 gtk_window_set_resizable(GTK_WINDOW(window),FALSE); |
| 2728 | 111 if (!GTK_WIDGET_VISIBLE (window)) |
| 112 gtk_widget_show_all (window); | |
| 113 else | |
|
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
114 { |
| 2728 | 115 gtk_widget_destroy (window); |
| 116 g_free(filename); | |
| 117 window = NULL; | |
| 118 } | |
| 119 | |
|
2732
1a27c497e526
indentation and some small bug fixing
Paula Stanciu <paula.stanciu@gmail.com>
parents:
2728
diff
changeset
|
120 } |
| 2728 | 121 |
| 122 } |
