gnome-bluetooth r351 - trunk/common
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-bluetooth r351 - trunk/common
- Date: Wed, 25 Feb 2009 14:42:53 +0000 (UTC)
Author: hadess
Date: Wed Feb 25 14:42:53 2009
New Revision: 351
URL: http://svn.gnome.org/viewvc/gnome-bluetooth?rev=351&view=rev
Log:
Update test program for chooser button
This is what we want to use in gnome-phone-manager.
Modified:
trunk/common/test-deviceselection.c
Modified: trunk/common/test-deviceselection.c
==============================================================================
--- trunk/common/test-deviceselection.c (original)
+++ trunk/common/test-deviceselection.c Wed Feb 25 14:42:53 2009
@@ -29,6 +29,7 @@
#include <gtk/gtk.h>
#include "bluetooth-chooser.h"
+#include "bluetooth-chooser-button.h"
#include "bluetooth-client.h"
static void device_selected_cb(GObject *object,
@@ -58,15 +59,50 @@
GTK_RESPONSE_ACCEPT, address != NULL);
}
+/* Phone chooser */
+
+static void
+chooser_created (BluetoothChooserButton *button, BluetoothChooser *chooser, gpointer data)
+{
+ g_object_set(chooser,
+ "show-search", FALSE,
+ "show-pairing", FALSE,
+ "show-device-type", FALSE,
+ "device-type-filter", BLUETOOTH_TYPE_PHONE,
+ "show-device-category", FALSE,
+ "device-category-filter", BLUETOOTH_CATEGORY_PAIRED,
+ NULL);
+}
+
+static GtkWidget *
+create_phone_dialogue (const char *bdaddr)
+{
+ GtkWidget *dialog, *button;
+
+ dialog = gtk_dialog_new_with_buttons("My test prefs", NULL,
+ GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL);
+ button = bluetooth_chooser_button_new ();
+ if (bdaddr != NULL)
+ g_object_set (G_OBJECT (button), "device", bdaddr, NULL);
+ g_signal_connect (G_OBJECT (button), "chooser-created",
+ G_CALLBACK (chooser_created), NULL);
+ gtk_widget_show (button);
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), button);
+
+ return dialog;
+}
+
+/* Wizard and co. */
static GtkWidget *
create_dialogue (const char *title)
{
GtkWidget *dialog;
dialog = gtk_dialog_new_with_buttons(title, NULL,
- GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
- GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT, NULL);
+ GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+ GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT, NULL);
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
GTK_RESPONSE_ACCEPT, FALSE);
gtk_window_set_default_size(GTK_WINDOW(dialog), 480, 400);
@@ -78,25 +114,6 @@
}
static GtkWidget *
-create_phone_dialogue (void)
-{
- GtkWidget *dialog, *selector;
-
- dialog = create_dialogue ("Browse Devices");
-
- selector = bluetooth_chooser_new("Select device to use");
- gtk_container_set_border_width(GTK_CONTAINER(selector), 5);
- gtk_widget_show(selector);
- g_object_set(selector,
- "show-search", TRUE,
- "device-type-filter", BLUETOOTH_TYPE_PHONE,
- NULL);
- g_object_set_data (G_OBJECT (dialog), "selector", selector);
-
- return dialog;
-}
-
-static GtkWidget *
create_wizard_dialogue (void)
{
GtkWidget *dialog, *selector;
@@ -111,15 +128,24 @@
"show-device-category", FALSE,
"device-category-filter", BLUETOOTH_CATEGORY_NOT_PAIRED_OR_TRUSTED,
NULL);
- g_object_set_data (G_OBJECT (dialog), "selector", selector);
+
+ g_signal_connect(selector, "selected-device-changed",
+ G_CALLBACK(select_device_changed), dialog);
+ g_signal_connect(selector, "notify::device-selected",
+ G_CALLBACK(device_selected_cb), dialog);
+ g_signal_connect(selector, "notify::device-type-filter",
+ G_CALLBACK(device_type_filter_selected_cb), dialog);
+ g_signal_connect(selector, "notify::device-category-filter",
+ G_CALLBACK(device_category_filter_selected_cb), dialog);
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), selector);
+ bluetooth_chooser_start_discovery (BLUETOOTH_CHOOSER (selector));
return dialog;
}
-
int main(int argc, char **argv)
{
- GtkWidget *dialog, *selector;
+ GtkWidget *dialog;
const char *selection;
int response;
@@ -130,7 +156,10 @@
selection = argv[1];
if (g_str_equal (selection, "phone")) {
- dialog = create_phone_dialogue ();
+ if (argc == 3)
+ dialog = create_phone_dialogue (argv[2]);
+ else
+ dialog = create_phone_dialogue (NULL);
} else if (g_str_equal (selection, "wizard")) {
dialog = create_wizard_dialogue ();
} else {
@@ -138,22 +167,11 @@
return 1;
}
- selector = g_object_get_data (G_OBJECT (dialog), "selector");
-
- g_signal_connect(selector, "selected-device-changed",
- G_CALLBACK(select_device_changed), dialog);
- g_signal_connect(selector, "notify::device-selected",
- G_CALLBACK(device_selected_cb), dialog);
- g_signal_connect(selector, "notify::device-type-filter",
- G_CALLBACK(device_type_filter_selected_cb), dialog);
- g_signal_connect(selector, "notify::device-category-filter",
- G_CALLBACK(device_category_filter_selected_cb), dialog);
- gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), selector);
- bluetooth_chooser_start_discovery (BLUETOOTH_CHOOSER (selector));
gtk_widget_show(dialog);
response = gtk_dialog_run(GTK_DIALOG(dialog));
+#if 0
if (response == GTK_RESPONSE_ACCEPT) {
char *address;
@@ -161,7 +179,7 @@
g_message("Selected device is: %s", address);
g_free(address);
}
-
+#endif
gtk_widget_destroy(dialog);
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]