Mercurial > audlegacy-plugins
changeset 2644:6fd8ca4b7b17
add bluetooth plugin
author | Paula Stanciu <paula.stanciu@gmail.com> |
---|---|
date | Sat, 17 May 2008 21:22:49 +0300 |
parents | 12aa69e560b2 |
children | 5c769ade286a |
files | configure.ac src/bluetooth/Makefile src/bluetooth/bluetooth.c src/bluetooth/bluetooth.h src/bluetooth/gui.c src/bluetooth/gui.h |
diffstat | 6 files changed, 316 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac Tue May 13 20:10:57 2008 +0200 +++ b/configure.ac Sat May 17 21:22:49 2008 +0300 @@ -1372,6 +1372,26 @@ AC_SUBST(MTP_LIBS) AC_SUBST(MTP_CFLAGS) +dnl *** Bluetooth audio suport + +AC_ARG_ENABLE(bluetooth, +[ --disable-bluetooth disable bluetooth audio support. (default=enabled)], +[have_bluetooth=$enableval], +[have_bluetooth=yes]) + +if test "x$have_bluetooth" = "xyes"; then + have_bluetooth=yes + PKG_CHECK_MODULES(BLUEZ, [bluez >= 2.22], + [GENERAL_PLUGINS="$GENERAL_PLUGINS bluetooth" ], [have_bluetooth="no"]) + BLUEZ_LIBS=`pkg-config --libs bluez` + BLUEZ_CFLAGS=`pkg-config --cflags bluez` +else + have_bluetooth=no + AC_MSG_RESULT([*** bluetooth audio suport plugin disabled by request ***]) +fi +AC_SUBST(BLUEZ_LIBS) +AC_SUBST(BLUEZ_CFLAGS) + dnl *** libparanormal checks AC_ARG_ENABLE(paranormal, @@ -1687,6 +1707,7 @@ echo " LIRC: $have_lirc" echo " AudioScrobbler Client: $scrobbler" echo " Upload to MTP device: $have_mtp_up" +echo " Bluetooth audio suport: $have_bluetooth" echo " MacOS Dock Album Art plugin: $have_dockalbumart" echo echo " Effect"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/bluetooth/Makefile Sat May 17 21:22:49 2008 +0300 @@ -0,0 +1,11 @@ +PLUGIN = bluetooth${PLUGIN_SUFFIX} + +SRCS = bluetooth.c gui.c +include ../../buildsys.mk +include ../../extra.mk + +plugindir := ${plugindir}/${GENERAL_PLUGIN_DIR} + +CFLAGS += ${PLUGIN_CFLAGS} +CPPFLAGS += ${PLUGIN_CPPFLAGS} ${BEEP_DEFINES} ${MOWGLI_CFLAGS} ${DBUS_CFLAGS} ${GTK_CFLAGS} ${GLIB_CFLAGS} ${PANGO_CFLAGS} -I../../intl -I../.. ${BLUEZ_CFLAGS} +LIBS += ${GTK_LIBS} ${GLIB_LIBS} ${PANGO_LIBS} ${BLUEZ_LIBS}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/bluetooth/bluetooth.c Sat May 17 21:22:49 2008 +0300 @@ -0,0 +1,47 @@ +#include "bluetooth.h" +#define DEBUG 1 +static gboolean plugin_active = FALSE,exiting=FALSE; + +void bluetooth_init ( void ); +void bluetooth_cleanup ( void ); +void bt_cfg(void); +void bt_about(void); +GeneralPlugin bluetooth_gp = +{ + .description = "Bluetooth audio suport", + .init = bluetooth_init, + .about = bt_about, + .configure = bt_cfg, + .cleanup = bluetooth_cleanup +}; +GeneralPlugin *bluetooth_gplist[] = { &bluetooth_gp, NULL }; +DECLARE_PLUGIN(bluetooth_gp, NULL, NULL, NULL, NULL, NULL, bluetooth_gplist, NULL, NULL) + +void bluetooth_init ( void ) +{ + +} + +void bluetooth_cleanup ( void ) +{ + +} +/*void bt_cfg( void ) +{ + +} +*/ +void bt_about( void ) +{ + +} + + +void refresh_call(void){ + printf("refresh function called\n"); +} + +void connect_call(void){ + printf("connect function \n"); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/bluetooth/bluetooth.h Sat May 17 21:22:49 2008 +0300 @@ -0,0 +1,12 @@ +#include <config.h> + +#include <glib.h> +#include <sys/types.h> +#include <audacious/plugin.h> +#include <audacious/ui_plugin_menu.h> +#include <audacious/i18n.h> +#include <gtk/gtk.h> +#include <audacious/util.h> +#include "gui.h" +void refresh_call(void); +void connect_call(void);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/bluetooth/gui.c Sat May 17 21:22:49 2008 +0300 @@ -0,0 +1,224 @@ +#include "gui.h" +#include "bluetooth.h" +#include <gtk/gtk.h> +#include <glib.h> + +static GtkWidget *window = NULL; +static GtkTreeModel *model; +GtkWidget *mainbox; +GtkWidget *hbox_top; +GtkWidget *hbox_bottom; +GtkWidget *box_about; +GtkWidget *box_about_left; +GtkWidget *box_about_right; +GtkWidget *headset_frame; +GtkWidget *about_frame; +GtkWidget *refresh; +GtkWidget *connect_button; +GtkWidget *close_button; +GtkWidget *treeview; +GtkWidget *label_p; +GtkWidget *label_m; +GtkWidget *label_a; +GtkWidget *label_prod; +GtkWidget *label_model; +GtkWidget *label_address; + + +typedef struct +{ + gchar *producer; + gchar *model; +}Headset; + +enum{ + COLUMN_PRODUCER, + COLUMN_MODEL, + NUM_COLUMNS +}; + +static Headset test_data[]= +{ + {"Motorola", "S9"}, + {"Nokia", "BH-503"}, + {"Blueant","Stereo X5"} +}; + +static GtkTreeModel * create_model(void) +{ + gint i = 0; + GtkListStore *store; + GtkTreeIter iter; + /* create list store */ + store = gtk_list_store_new(NUM_COLUMNS, + G_TYPE_STRING, + G_TYPE_STRING); + /* add data to the list store */ + for(i = 0;i<G_N_ELEMENTS(test_data);i++) + { + gtk_list_store_append(store,&iter); + gtk_list_store_set(store,&iter, + COLUMN_PRODUCER, test_data[i].producer, + COLUMN_MODEL, test_data[i].model, + -1); + } + return GTK_TREE_MODEL(store); +} + +static void add_columns(GtkTreeView *treeview) +{ + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + // GtkTreeModel *model = gtk_tree_view_get_model (treeview); + + /* column for producer */ + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("Producer", + renderer, + "text", + COLUMN_PRODUCER, + NULL); + gtk_tree_view_column_set_sort_column_id (column,COLUMN_PRODUCER); + gtk_tree_view_append_column (treeview, column); + + /* column for model */ + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("Model", + renderer, + "text", + COLUMN_MODEL, + NULL); + gtk_tree_view_column_set_sort_column_id (column,COLUMN_MODEL); + gtk_tree_view_append_column (treeview, column); + +} + +void close_call(void){ + printf("close callback \n"); + gtk_widget_destroy (window); + window = NULL; +} +void select_row(GtkWidget *treeview){ + + GtkTreeIter iter; + gint sel; + printf("select\n"); + GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(treeview)); + if(gtk_tree_selection_get_selected (selection, NULL,&iter)){ + GtkTreePath *path; + path = gtk_tree_model_get_path (model, &iter); + sel = gtk_tree_path_get_indices (path)[0]; + printf("i=%d\n",sel); + gtk_label_set_text(GTK_LABEL(label_prod),test_data[sel].producer); + gtk_label_set_text(GTK_LABEL(label_model),test_data[sel].model); + gtk_label_set_text(GTK_LABEL(label_address),"00:01:02:03:04:05"); + + gtk_tree_path_free (path); + + } + + + +} +void bt_cfg() +{ + + if (!window) + { + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_signal_connect (window, "destroy",G_CALLBACK (gtk_widget_destroyed), &window); + + mainbox = gtk_vbox_new(FALSE,4); + gtk_container_set_border_width (GTK_CONTAINER (mainbox), 4); + gtk_container_add (GTK_CONTAINER (window), mainbox); + + hbox_top = gtk_hbox_new(FALSE,4); + gtk_container_set_border_width (GTK_CONTAINER(hbox_top), 4); + gtk_container_add (GTK_CONTAINER (mainbox), hbox_top); + + hbox_bottom = gtk_hbox_new(FALSE,4); + gtk_container_set_border_width (GTK_CONTAINER (hbox_bottom), 4); + gtk_container_add (GTK_CONTAINER (mainbox), hbox_bottom); + + headset_frame = gtk_frame_new("Available Headsets"); + gtk_container_add (GTK_CONTAINER (hbox_top), headset_frame); + + about_frame = gtk_frame_new("Current Headset"); + gtk_container_add(GTK_CONTAINER(hbox_top),about_frame); + + refresh = gtk_button_new_with_mnemonic ("_Refresh"); + g_signal_connect (refresh, "clicked",G_CALLBACK (refresh_call), NULL); + gtk_container_add(GTK_CONTAINER(hbox_bottom),refresh); + + connect_button = gtk_button_new_with_mnemonic("_Connect"); + g_signal_connect(connect_button,"clicked",G_CALLBACK (connect_call), NULL); + gtk_container_add(GTK_CONTAINER(hbox_bottom),connect_button); + + close_button = gtk_button_new_with_mnemonic("_Close"); + g_signal_connect(close_button,"clicked",G_CALLBACK (close_call),NULL); + gtk_container_add(GTK_CONTAINER(hbox_bottom),close_button); + /* create tree model */ + model = create_model (); + + /* create tree view */ + treeview = gtk_tree_view_new_with_model (model); + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE); + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)),GTK_SELECTION_SINGLE); + g_object_unref (model); + gtk_container_add (GTK_CONTAINER (headset_frame), treeview); + /* add columns to the tree view */ + add_columns (GTK_TREE_VIEW (treeview)); + g_signal_connect(treeview,"cursor-changed",G_CALLBACK(select_row),treeview); + + + box_about = gtk_hbox_new(FALSE,4); + gtk_container_set_border_width (GTK_CONTAINER (box_about), 4); + gtk_container_add (GTK_CONTAINER (about_frame), box_about); + + /*about box left - vbox */ + + box_about_left = gtk_vbox_new(FALSE,4); + gtk_container_set_border_width (GTK_CONTAINER (box_about_left), 4); + gtk_container_add (GTK_CONTAINER (box_about), box_about_left); + + /*about box right - vbox */ + box_about_right = gtk_vbox_new(TRUE,4); + gtk_container_set_border_width (GTK_CONTAINER (box_about_right), 4); + gtk_container_add (GTK_CONTAINER (box_about), box_about_right); + + /* Left labels */ + label_p = gtk_label_new("Producer:"); + gtk_container_add(GTK_CONTAINER(box_about_left),label_p); + + label_m = gtk_label_new("Model:"); + gtk_container_add(GTK_CONTAINER(box_about_left),label_m); + + + label_a = gtk_label_new("Address:"); + gtk_container_add(GTK_CONTAINER(box_about_left),label_a); + + + /*right labels */ + label_prod = gtk_label_new("Producer:"); + gtk_container_add(GTK_CONTAINER(box_about_right),label_prod); + + label_model = gtk_label_new("Model:"); + gtk_container_add(GTK_CONTAINER(box_about_right),label_model); + + + label_address = gtk_label_new("Address:"); + gtk_container_add(GTK_CONTAINER(box_about_right),label_address); + + gtk_window_set_default_size (GTK_WINDOW (window), 480, 180); + if (!GTK_WIDGET_VISIBLE (window)) + gtk_widget_show_all (window); + else + { + gtk_widget_destroy (window); + window = NULL; + } + // return window; + } + // return window; +} +