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;
}
/**
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
* 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;
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);
_("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
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);