]> err.no Git - mapper/commitdiff
GpsScan: Cleanups
authorKaj-Michael Lang <milang@tal.org>
Thu, 15 May 2008 15:54:37 +0000 (18:54 +0300)
committerKaj-Michael Lang <milang@tal.org>
Thu, 15 May 2008 15:54:37 +0000 (18:54 +0300)
src/gps-browse.c

index bdbf0f48d43498fea849c76c72f97c9cd477a815..71201fe4e652475080106dabc3d9ff525b902c18 100644 (file)
  */
 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);
-
+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
-       /* 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);
+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;
 }