changeset 2756:d3d71539d675

rescan functionality
author Paula Stanciu <paula.stanciu@gmail.com>
date Tue, 01 Jul 2008 19:35:16 +0300
parents 5a0f5e9af5ef
children 652651eeb5f1
files src/bluetooth/bluetooth.c src/bluetooth/gui.c src/bluetooth/scan_gui.c src/bluetooth/scan_gui.h
diffstat 4 files changed, 43 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/bluetooth/bluetooth.c	Tue Jul 01 00:51:38 2008 -0500
+++ b/src/bluetooth/bluetooth.c	Tue Jul 01 19:35:16 2008 +0300
@@ -49,7 +49,7 @@
 {
     printf("bluetooth: exit\n");
     if (config ==1 ){
-        destroy_scan_window();
+        close_window();
         config =0;
     }
     if(discover_finish == 2) {
@@ -91,14 +91,25 @@
 
 }
 
+void clean_devices_list(){
+    g_list_free(audio_devices);
+    dbus_g_connection_flush (bus);
+    dbus_g_connection_unref(bus);
+    audio_devices = NULL;
+    //g_list_free(current_device);
+}
 
 void refresh_call(void)
 {
     printf("refresh function called\n");
     disconnect_dbus_signals();
+    clean_devices_list();
     if(discover_finish == 0 ||discover_finish== 2){
         discover_finish = 0;
+
         discover_devices();
+        close_window();
+        show_scan();
     }
     else 
         printf("Scanning please wait!\n");
--- a/src/bluetooth/gui.c	Tue Jul 01 00:51:38 2008 -0500
+++ b/src/bluetooth/gui.c	Tue Jul 01 19:35:16 2008 +0300
@@ -173,6 +173,13 @@
     }
 }
 
+void refresh_resultsui(){
+  gtk_widget_destroy (window);
+  window = NULL;
+  refresh_call();
+}
+   
+
 void results_ui()
 {
     gchar *temp;
@@ -200,7 +207,7 @@
         gtk_container_add(GTK_CONTAINER(hbox_top),about_frame);
 
         refresh = gtk_button_new_with_mnemonic ("_Refresh");
-        g_signal_connect (refresh, "clicked",G_CALLBACK (refresh_call), NULL);
+        g_signal_connect (refresh, "clicked",G_CALLBACK (refresh_resultsui), NULL);
         gtk_container_add(GTK_CONTAINER(hbox_bottom),refresh);
 
         connect_button = gtk_button_new_with_mnemonic("_Connect");
--- a/src/bluetooth/scan_gui.c	Tue Jul 01 00:51:38 2008 -0500
+++ b/src/bluetooth/scan_gui.c	Tue Jul 01 19:35:16 2008 +0300
@@ -3,11 +3,13 @@
 static GtkWidget *window = NULL;
 static GtkWidget *winbox;
 static GtkWidget *scanbox;
+static GtkWidget *buttonsbox;
 static GtkWidget *progressbox;
 static GtkWidget *bluetooth_img;
 static GtkWidget *scan_label;
 static GtkWidget *progress_bar;
-
+static GtkWidget *rescan_buttton;
+static GtkWidget *close_button;
 gpointer progress() {
 
     for(;;){
@@ -33,6 +35,12 @@
 void destroy_scan_window(){
     gtk_widget_hide(window);
 }
+void close_window(void){
+    printf("scan_gui close callback \n");
+    gtk_widget_destroy (window);
+    window = NULL;
+}
+
 
 void show_scan()
 {
@@ -69,7 +77,19 @@
         /* I have to add a button for Rescan when there are
          * no devices found and not currently scanning
          */
-        gtk_window_set_default_size (GTK_WINDOW (window), 50, 40);
+        buttonsbox = gtk_hbox_new(FALSE,2);
+        gtk_container_set_border_width(GTK_CONTAINER(buttonsbox),2);
+        gtk_container_add(GTK_CONTAINER(progressbox),buttonsbox);
+        rescan_buttton = gtk_button_new_with_mnemonic("Rescan");
+        g_signal_connect(rescan_buttton,"clicked",G_CALLBACK (refresh_call),NULL);
+
+        close_button = gtk_button_new_with_mnemonic("Close");
+        gtk_container_add(GTK_CONTAINER(buttonsbox),rescan_buttton);
+        gtk_container_add(GTK_CONTAINER(buttonsbox),close_button);
+        g_signal_connect(close_button,"clicked",G_CALLBACK (close_window),NULL);
+
+        gtk_window_set_default_size (GTK_WINDOW (window), 60, 40);
+        gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
         if (!GTK_WIDGET_VISIBLE (window))
             gtk_widget_show_all (window);
         else
--- a/src/bluetooth/scan_gui.h	Tue Jul 01 00:51:38 2008 -0500
+++ b/src/bluetooth/scan_gui.h	Tue Jul 01 19:35:16 2008 +0300
@@ -3,3 +3,4 @@
 void show_scan();
 void show_no_devices();
 void destroy_scan_window();
+void close_window();