2 * Copyright © 2009 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 aoview_dev_dialog_map(GtkWidget *widget, gpointer data)
23 GtkTreeView *dev_list = data;
24 GtkListStore *list_store;
29 list_store = gtk_list_store_new(3,
34 ndev = aoview_usb_scan(&devs);
35 for (n = 0; n < ndev; n++) {
36 gtk_list_store_append(list_store, &iter);
37 gtk_list_store_set(list_store, &iter,
43 gtk_tree_view_set_model (dev_list, GTK_TREE_MODEL(list_store));
44 g_object_unref(G_OBJECT(list_store));
45 gtk_tree_view_columns_autosize(dev_list);
49 aoview_dev_selected(GtkTreeModel *model,
55 gtk_tree_model_get(model, iter,
58 aoview_monitor_connect(string);
61 static GtkWidget *dialog;
64 aoview_dev_dialog_connect(GtkWidget *widget, gpointer data)
66 GtkTreeView *dev_list = data;
67 GtkListStore *list_store;
68 GtkTreeSelection *tree_selection;
70 list_store = GTK_LIST_STORE(gtk_tree_view_get_model(dev_list));
71 tree_selection = gtk_tree_view_get_selection(dev_list);
72 gtk_tree_selection_selected_foreach(tree_selection,
76 gtk_widget_hide(dialog);
80 aoview_dev_disconnect(GtkWidget *widget)
82 aoview_monitor_disconnect();
88 aoview_dev_dialog_init(GladeXML *xml)
90 GtkTreeView *dev_list;
91 GtkWidget *connect_button;
92 GtkTreeSelection *dev_selection;
93 GtkWidget *ao_disconnect;
95 dialog = glade_xml_get_widget(xml, "device_connect_dialog");
98 dev_list = GTK_TREE_VIEW(glade_xml_get_widget(xml, "dev_list"));
101 aoview_add_plain_text_column(dev_list, _("Product"), 0, 16);
102 aoview_add_plain_text_column(dev_list, _("Serial"), 1, 8);
103 aoview_add_plain_text_column(dev_list, _("Device"), 2, 13);
105 dev_selection = gtk_tree_view_get_selection(dev_list);
106 gtk_tree_selection_set_mode(dev_selection, GTK_SELECTION_SINGLE);
108 g_signal_connect(G_OBJECT(dialog), "map",
109 G_CALLBACK(aoview_dev_dialog_map),
112 connect_button = glade_xml_get_widget(xml, "connect_button");
113 assert(connect_button);
115 g_signal_connect(G_OBJECT(connect_button), "clicked",
116 G_CALLBACK(aoview_dev_dialog_connect),
120 ao_disconnect = glade_xml_get_widget(xml, "ao_disconnect");
121 assert(ao_disconnect);
123 g_signal_connect(G_OBJECT(ao_disconnect), "activate",
124 G_CALLBACK(aoview_dev_disconnect),