]> err.no Git - mapper/commitdiff
Fix duplicate functions. Use common scan_bluetooth in gps-browse.c
authorKaj-Michael Lang <milang@angel.tal.org>
Tue, 24 Jul 2007 11:26:48 +0000 (14:26 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Tue, 24 Jul 2007 11:26:48 +0000 (14:26 +0300)
Start idle scanning function in bt-bluez.c

src/bt-bluez.c
src/gps-browse.c

index 8097c6367445cb5131c66c2deea68e85cbaadad4..0f7a643f163e633bab7a94036842f8c72bd1899b 100644 (file)
 
 struct sockaddr_rc _rcvr_addr = { 0 };
 
-gint scan_start_search()
+gint scan_start_search(ScanInfo * scan_info)
 {
-       return 0;
+scan_info->sid = g_idle_add((GSourceFunc) scan_bluetooth_idle, scan_info);
+return 0;
 }
 
 /**
@@ -265,86 +266,4 @@ gboolean scan_bluetooth_idle(ScanInfo * scan_info)
        return FALSE;
 }
 
-/**
- * Scan for all bluetooth devices.  This method can take a few seconds,
- * during which the UI will freeze.
- */
-gboolean scan_bluetooth(GtkWidget * widget, ScanInfo * scan_info)
-{
-       /* Do an hci_inquiry for our boy. */
-       GtkWidget *dialog;
-       GtkWidget *lst_devices;
-       GtkTreeViewColumn *column;
-       GtkCellRenderer *renderer;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       dialog = gtk_dialog_new_with_buttons(_("Select Bluetooth Device"),
-                                            GTK_WINDOW(scan_info->
-                                                       settings_dialog),
-                                            GTK_DIALOG_MODAL, GTK_STOCK_OK,
-                                            GTK_RESPONSE_ACCEPT,
-                                            GTK_STOCK_CANCEL,
-                                            GTK_RESPONSE_REJECT, NULL);
-
-       scan_info->scan_dialog = dialog;
-
-       scan_info->banner = hildon_banner_show_animation(dialog, NULL,
-                                                        _
-                                                        ("Scanning Bluetooth Devices"));
-
-       scan_info->store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
-
-       scan_info->sid =
-           g_idle_add((GSourceFunc) scan_bluetooth_idle, scan_info);
-
-       gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300);
-
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                          lst_devices =
-                          gtk_tree_view_new_with_model(GTK_TREE_MODEL
-                                                       (scan_info->store)),
-                          TRUE, TRUE, 0);
-
-       g_object_unref(G_OBJECT(scan_info->store));
-
-       gtk_tree_selection_set_mode(gtk_tree_view_get_selection
-                                   (GTK_TREE_VIEW(lst_devices)),
-                                   GTK_SELECTION_SINGLE);
-       gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(lst_devices), TRUE);
-
-       renderer = gtk_cell_renderer_text_new();
-       column = gtk_tree_view_column_new_with_attributes(_("MAC"), renderer, "text", 0, NULL);
-       gtk_tree_view_append_column(GTK_TREE_VIEW(lst_devices), column);
-
-       renderer = gtk_cell_renderer_text_new();
-       column = gtk_tree_view_column_new_with_attributes(_("Description"), renderer, "text", 1, NULL);
-       gtk_tree_view_append_column(GTK_TREE_VIEW(lst_devices), column);
-
-       gtk_widget_show_all(dialog);
-
-       while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
-               GtkTreeIter iter;
-               if (gtk_tree_selection_get_selected
-                   (gtk_tree_view_get_selection(GTK_TREE_VIEW(lst_devices)),
-                    NULL, &iter)) {
-                       gchar *mac;
-                       gtk_tree_model_get(GTK_TREE_MODEL(scan_info->store),
-                                          &iter, 0, &mac, -1);
-                       gtk_entry_set_text(GTK_ENTRY(scan_info->txt_rcvr_mac),
-                                          mac);
-                       break;
-               } else
-                       popup_error(dialog,
-                                   _
-                                   ("Please select a bluetooth device from the list."));
-       }
-
-       if (scan_info->sid)
-               g_source_remove(scan_info->sid);
-       gtk_widget_destroy(dialog);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
-}
-
 #endif
index cdf0b930fc61d9d4086b97804defc29af138f17a..73e5486902b0a6646e434792c1b281a7a042077d 100644 (file)
@@ -26,7 +26,7 @@
  * Scan for all bluetooth devices.  This method can take a few seconds,
  * during which the UI will freeze.
  */
-static gboolean scan_bluetooth(GtkWidget * widget, ScanInfo * scan_info)
+gboolean scan_bluetooth(GtkWidget * widget, ScanInfo * scan_info)
 {
        GError *error = NULL;
        GtkWidget *dialog;
@@ -63,22 +63,19 @@ static gboolean scan_bluetooth(GtkWidget * widget, ScanInfo * scan_info)
        gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(lst_devices), TRUE);
 
        renderer = gtk_cell_renderer_text_new();
-       column =
-           gtk_tree_view_column_new_with_attributes(_("MAC"), renderer, "text",
+       column = gtk_tree_view_column_new_with_attributes(_("MAC"), renderer, "text",
                                                     0, NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(lst_devices), column);
 
        renderer = gtk_cell_renderer_text_new();
-       column =
-           gtk_tree_view_column_new_with_attributes(_("Description"), renderer,
+       column = gtk_tree_view_column_new_with_attributes(_("Description"), renderer,
                                                     "text", 1, NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(lst_devices), column);
 
        gtk_widget_show_all(dialog);
 
        scan_info->banner = hildon_banner_show_animation(dialog, NULL,
-                                                        _
-                                                        ("Scanning for Bluetooth Devices"));
+                                                        _("Scanning for Bluetooth Devices"));
 
        if (scan_start_search(scan_info)) {
                gtk_widget_destroy(scan_info->banner);
@@ -86,8 +83,7 @@ static gboolean scan_bluetooth(GtkWidget * widget, ScanInfo * scan_info)
                            _("An error occurred while attempting to scan for "
                              "bluetooth devices."));
        } else
-               while (GTK_RESPONSE_ACCEPT ==
-                      gtk_dialog_run(GTK_DIALOG(dialog))) {
+               while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
                        GtkTreeIter iter;
                        if (gtk_tree_selection_get_selected
                            (gtk_tree_view_get_selection
@@ -101,9 +97,7 @@ static gboolean scan_bluetooth(GtkWidget * widget, ScanInfo * scan_info)
                                                   mac);
                                break;
                        } else
-                               popup_error(dialog,
-                                           _
-                                           ("Please select a bluetooth device from the list."));
+                               popup_error(dialog, _("Please select a bluetooth device from the list."));
                }
 
        gtk_widget_destroy(dialog);