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