]> err.no Git - mapper/blobdiff - src/gps-browse.c
Move ProgressUpdateInfo struct
[mapper] / src / gps-browse.c
index cdf0b930fc61d9d4086b97804defc29af138f17a..71201fe4e652475080106dabc3d9ff525b902c18 100644 (file)
@@ -1,4 +1,27 @@
-#define _GNU_SOURCE
+/*
+ * This file is part of mapper
+ *
+ * Copyright (C) 2007 Kaj-Michael Lang
+ * Copyright (C) 2006-2007 John Costigan.
+ *
+ * POI and GPS-Info code originally written by Cezary Jackiewicz.
+ *
+ * Default map data provided by http://www.openstreetmap.org/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #include <config.h>
 #include <unistd.h>
 
 #include <sqlite3.h>
 
+#ifdef WITH_HILDON_DBUS_BT
+#include <bt-dbus.h>
+#endif
+
 #include "utils.h"
 #include "mapper-types.h"
-#include "bt.h"
+#include "dialogs.h"
+#include "bluetooth-scan.h"
 
 /**
  * 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;
-       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->store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
-
-       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);
-
-       scan_info->banner = hildon_banner_show_animation(dialog, NULL,
-                                                        _
-                                                        ("Scanning for Bluetooth Devices"));
-
-       if (scan_start_search(scan_info)) {
-               gtk_widget_destroy(scan_info->banner);
-               popup_error(scan_info->settings_dialog,
-                           _("An error occurred while attempting to scan for "
-                             "bluetooth devices."));
-       } else
-               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."));
-               }
-
-       gtk_widget_destroy(dialog);
-
-#ifdef BT_HILDON_DBUS
-       /* Clean up D-Bus. */
-       dbus_g_proxy_call(scan_info->req_proxy, BTSEARCH_STOP_SEARCH_REQ,
-                         &error, G_TYPE_INVALID, G_TYPE_INVALID);
-       g_object_unref(scan_info->req_proxy);
-       g_object_unref(scan_info->sig_proxy);
+GError *error = NULL;
+GtkWidget *dialog;
+GtkWidget *lst_devices;
+GtkTreeViewColumn *column;
+GtkCellRenderer *renderer;
+
+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->store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+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);
+
+scan_info->banner = hildon_banner_show_animation(dialog, NULL, _("Scanning for Bluetooth Devices"));
+
+if (scan_start_search(scan_info)) {
+       gtk_widget_destroy(scan_info->banner);
+       popup_error(scan_info->settings_dialog, _("An error occurred while attempting to scan for bluetooth devices."));
+} else
+       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."));
+       }
+
+gtk_widget_destroy(dialog);
+
+/* Clean up D-Bus. */
+#ifdef WITH_HILDON_DBUS_BT
+dbus_g_proxy_call(scan_info->req_proxy, BTSEARCH_STOP_SEARCH_REQ, &error, G_TYPE_INVALID, G_TYPE_INVALID);
+#endif
+
+#if defined(WITH_HILDON_DBUS_BT)
+g_object_unref(scan_info->req_proxy);
+g_object_unref(scan_info->sig_proxy);
 #endif
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }