static void
on_page_switched (GtkNotebook * notebook, GParamSpec * arg, gpointer user_data)
{
  BtSettingsPageInteractionController *self =
      BT_SETTINGS_PAGE_INTERACTION_CONTROLLER (user_data);
  guint page_num;
  static gint prev_page_num = -1;

  g_object_get (notebook, "page", &page_num, NULL);

  if (page_num == BT_SETTINGS_PAGE_INTERACTION_CONTROLLER) {
    // only do this if the page really has changed
    if (prev_page_num != BT_SETTINGS_PAGE_INTERACTION_CONTROLLER) {
      GST_DEBUG ("enter page");
      on_device_menu_changed (self->priv->device_menu, (gpointer) self);
    }
  } else {
    // only do this if the page was BT_SETTINGS_PAGE_INTERACTION_CONTROLLER
    if (prev_page_num == BT_SETTINGS_PAGE_INTERACTION_CONTROLLER) {
      GST_DEBUG ("leave page");
      if (self->priv->device) {
        stop_device (self);
      }
    }
  }
  prev_page_num = page_num;
}
static void
on_device_menu_changed (GtkComboBox * combo_box, gpointer user_data)
{
  BtSettingsPageInteractionController *self =
      BT_SETTINGS_PAGE_INTERACTION_CONTROLLER (user_data);
  GObject *device = NULL;
  BtObjectListModel *store;
  GtkTreeModel *model;
  GtkTreeIter iter;
  GList *node, *list;

  // release the old one
  if (self->priv->device) {
    stop_device (self);
  }

  GST_INFO ("interaction controller device changed");
  model = gtk_combo_box_get_model (self->priv->device_menu);
  if (gtk_combo_box_get_active_iter (self->priv->device_menu, &iter)) {
    device =
        bt_object_list_model_get_object (BT_OBJECT_LIST_MODEL (model), &iter);
  }
  // update list of controllers
  store = bt_object_list_model_new (2, BTIC_TYPE_CONTROL, "bound", "name");
  if (device) {
    g_object_get (device, "controls", &list, NULL);
    for (node = list; node; node = g_list_next (node)) {
      bt_object_list_model_append (store, (GObject *) node->data);
      g_signal_connect_object (node->data, "notify::value",
          G_CALLBACK (notify_controlchange), (gpointer) self, 0);
    }
    g_list_free (list);

    // activate the new one
    self->priv->device = g_object_ref ((gpointer) device);
    start_device (self);
  }
  GST_INFO ("control list refreshed");
  gtk_widget_set_sensitive (GTK_WIDGET (self->priv->controller_list),
      (device != NULL));
  gtk_tree_view_set_model (self->priv->controller_list, GTK_TREE_MODEL (store));
  g_object_unref (store);       // drop with treeview
}
static void
bt_settings_page_interaction_controller_dispose (GObject * object)
{
  BtSettingsPageInteractionController *self =
      BT_SETTINGS_PAGE_INTERACTION_CONTROLLER (object);

  return_if_disposed ();
  self->priv->dispose_has_run = TRUE;

  GST_DEBUG ("!!!! self=%p", self);

  if (self->priv->device) {
    stop_device (self);
  }

  g_object_unref (self->priv->app);

  G_OBJECT_CLASS (bt_settings_page_interaction_controller_parent_class)->dispose
      (object);
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
	int i;
	const char *name;

	if (argc <= 1) {
		return list_devices();
	}
	else {
		for (i = 1; i < argc; i++) {
			name = argv[i];
			if (name[0] == '+') {
				start_device(name + 1);
			}
			else if (name[0] == '-') {
				stop_device(name + 1);
			}
			else {
				printf("USAGE: %s [+|-]input_device_name\n", argv[0]);
			}
		}
	}
	return 0;
}
Ejemplo n.º 5
0
Archivo: wrapper.c Proyecto: jadler/k4l
static void nui_stop_device() {
    stop_device();
}