From: Uwe Hermann Date: Fri, 17 Feb 2012 21:25:01 +0000 (+0100) Subject: sr/cli/gtk/qt: s/device/dev/ in many places. X-Git-Url: http://sigrok.org/gitweb/?a=commitdiff_plain;h=ffe80b55222c3f7e0ac6956082e365e3f81cdecf;hp=a9f1783afa00884dad2d6f01c5d7932f59d75aae;p=sigrok-gtk.git sr/cli/gtk/qt: s/device/dev/ in many places. Also, a few s/instance/inst/ occurences. --- diff --git a/devselect.c b/devselect.c index 3a6771c..945ed8a 100644 --- a/devselect.c +++ b/devselect.c @@ -21,30 +21,30 @@ #include #include "sigrok-gtk.h" -static void dev_selected(GtkComboBox *dev, GObject *parent) +static void dev_selected(GtkComboBox *devbox, GObject *parent) { - GtkTreeModel *devlist = gtk_combo_box_get_model(dev); + GtkTreeModel *devlist = gtk_combo_box_get_model(devbox); GtkTreeIter iter; const gchar *name; GtkCheckMenuItem *menuitem; - struct sr_device *device; + struct sr_dev *dev; - if (!gtk_combo_box_get_active_iter(dev, &iter)) { - g_object_set_data(parent, "device", NULL); + if (!gtk_combo_box_get_active_iter(devbox, &iter)) { + g_object_set_data(parent, "dev", NULL); return; } - gtk_tree_model_get(devlist, &iter, 0, &name, 1, &device, + gtk_tree_model_get(devlist, &iter, 0, &name, 1, &dev, 2, &menuitem, -1); gtk_check_menu_item_set_active(menuitem, TRUE); - sr_session_device_clear(); - if (sr_session_device_add(device) != SR_OK) { + sr_session_dev_clear(); + if (sr_session_dev_add(dev) != SR_OK) { g_critical("Failed to use device."); sr_session_destroy(); - device = NULL; + dev = NULL; } - g_object_set_data(parent, "device", device); + g_object_set_data(parent, "dev", dev); } static void dev_menuitem_toggled(GtkMenuItem *item, GtkComboBox *combo) @@ -65,20 +65,19 @@ static void dev_menuitem_toggled(GtkMenuItem *item, GtkComboBox *combo) } while (gtk_tree_model_iter_next(model, &iter)); } -#define GET_DEVICE_INSTANCE(device) \ - (device)->plugin->get_device_info((device)->plugin_index, \ - SR_DI_INSTANCE); +#define GET_DEV_INST(dev) \ + (dev)->plugin->get_dev_info((dev)->plugin_index, SR_DI_INSTANCE); void dev_select_rescan(GtkAction *action, GtkWindow *parent) { - GtkComboBox *dev = g_object_get_data(G_OBJECT(parent), "devcombo"); - g_return_if_fail(dev != NULL); - GtkListStore *devlist = GTK_LIST_STORE(gtk_combo_box_get_model(dev)); + GtkComboBox *devbox = g_object_get_data(G_OBJECT(parent), "devcombo"); + g_return_if_fail(devbox != NULL); + GtkListStore *devlist = GTK_LIST_STORE(gtk_combo_box_get_model(devbox)); GtkTreeIter iter; - struct sr_device *device; - struct sr_device_instance *sdi; + struct sr_dev *dev; + struct sr_dev_inst *sdi; gchar *sdevname = NULL; - GSList *devices, *l; + GSList *devs, *l; GtkUIManager *ui = g_object_get_data(G_OBJECT(parent), "ui_manager"); GtkWidget *menuitem = gtk_ui_manager_get_widget(ui, "/menubar/DevMenu/DevSelectMenu"); @@ -90,10 +89,10 @@ void dev_select_rescan(GtkAction *action, GtkWindow *parent) /* Make a copy of the selected device's short name for comparison. * We wish to select the same device after the refresh if possible. */ - if (gtk_combo_box_get_active_iter(dev, &iter)) { - gtk_tree_model_get(GTK_TREE_MODEL(devlist), &iter, 1, &device, -1); - /* FIXME: Use something other than device->plugin->name */ - sdevname = g_strdup(device->plugin->name); + if (gtk_combo_box_get_active_iter(devbox, &iter)) { + gtk_tree_model_get(GTK_TREE_MODEL(devlist), &iter, 1, &dev, -1); + /* FIXME: Use something other than dev->plugin->name */ + sdevname = g_strdup(dev->plugin->name); } /* Destroy the old menu items */ @@ -108,10 +107,10 @@ void dev_select_rescan(GtkAction *action, GtkWindow *parent) /* Scan for new devices and update our list */ /* TODO: Fix this in libsigrok first. */ /*sr_dev_scan();*/ - devices = sr_dev_list(); - for (l = devices; l; l = l->next) { - device = l->data; - sdi = GET_DEVICE_INSTANCE(device); + devs = sr_dev_list(); + for (l = devs; l; l = l->next) { + dev = l->data; + sdi = GET_DEV_INST(dev); gchar *name = sdi->model ? sdi->model : sdi->vendor; if (!name) name = "(unknown)"; @@ -122,51 +121,51 @@ void dev_select_rescan(GtkAction *action, GtkWindow *parent) radiolist = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(menuitem)); g_signal_connect(menuitem, "toggled", - G_CALLBACK(dev_menuitem_toggled), dev); + G_CALLBACK(dev_menuitem_toggled), devbox); gtk_menu_shell_prepend(devmenu, menuitem); gtk_list_store_append(devlist, &iter); gtk_list_store_set(devlist, &iter, 0, name, - 1, device, + 1, dev, 2, menuitem, -1); - if (sdevname && g_str_equal(sdevname, device->plugin->name)) - gtk_combo_box_set_active_iter(dev, &iter); + if (sdevname && g_str_equal(sdevname, dev->plugin->name)) + gtk_combo_box_set_active_iter(devbox, &iter); } if (sdevname) g_free(sdevname); /* Select a default if nothing selected */ - if (!gtk_combo_box_get_active_iter(dev, &iter)) { + if (!gtk_combo_box_get_active_iter(devbox, &iter)) { if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(devlist), &iter)) return; /* Skip demo if there's another available */ GtkTreeIter first = iter; if (gtk_tree_model_iter_next(GTK_TREE_MODEL(devlist), &iter)) - gtk_combo_box_set_active_iter(dev, &iter); + gtk_combo_box_set_active_iter(devbox, &iter); else - gtk_combo_box_set_active_iter(dev, &first); + gtk_combo_box_set_active_iter(devbox, &first); } } GtkWidget *dev_select_combo_box_new(GtkWindow *parent) { - GtkWidget *dev = gtk_combo_box_new(); + GtkWidget *devbox = gtk_combo_box_new(); /* Populate device list */ GtkListStore *devlist = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_POINTER, GTK_TYPE_CHECK_MENU_ITEM); GtkCellRenderer *cel = gtk_cell_renderer_text_new(); - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dev), cel, TRUE); - gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(dev), cel, "text", 0); - gtk_combo_box_set_model(GTK_COMBO_BOX(dev), GTK_TREE_MODEL(devlist)); - g_signal_connect(dev, "changed", G_CALLBACK(dev_selected), parent); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(devbox), cel, TRUE); + gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(devbox), cel, "text", 0); + gtk_combo_box_set_model(GTK_COMBO_BOX(devbox), GTK_TREE_MODEL(devlist)); + g_signal_connect(devbox, "changed", G_CALLBACK(dev_selected), parent); - g_object_set_data(G_OBJECT(parent), "devcombo", dev); + g_object_set_data(G_OBJECT(parent), "devcombo", devbox); dev_select_rescan(NULL, parent); - return dev; + return devbox; } diff --git a/main.c b/main.c index 03c1b8a..7095a11 100644 --- a/main.c +++ b/main.c @@ -34,7 +34,7 @@ static const char *colours[8] = { }; static void -datafeed_in(struct sr_device *device, struct sr_datafeed_packet *packet) +datafeed_in(struct sr_dev *dev, struct sr_datafeed_packet *packet) { static int probelist[65] = { 0 }; static int unitsize = 0; @@ -53,7 +53,7 @@ datafeed_in(struct sr_device *device, struct sr_datafeed_packet *packet) num_enabled_probes = 0; gtk_list_store_clear(siglist); for (i = 0; i < header->num_logic_probes; i++) { - probe = g_slist_nth_data(device->probes, i); + probe = g_slist_nth_data(dev->probes, i); if (probe->enabled) { GtkTreeIter iter; probelist[num_enabled_probes++] = probe->index; diff --git a/toolbar.c b/toolbar.c index 76e1ab5..3871dd6 100644 --- a/toolbar.c +++ b/toolbar.c @@ -43,7 +43,7 @@ static void prop_edited(GtkCellRendererText *cel, gchar *path, gchar *text, { (void)cel; - struct sr_device *device = g_object_get_data(G_OBJECT(props), "device"); + struct sr_dev *dev = g_object_get_data(G_OBJECT(props), "dev"); GtkTreeIter iter; int type, cap; guint64 tmp_u64; @@ -59,11 +59,11 @@ static void prop_edited(GtkCellRendererText *cel, gchar *path, gchar *text, if (sr_parse_sizestring(text, &tmp_u64) != SR_OK) return; - ret = device->plugin->set_configuration(device->plugin_index, + ret = dev->plugin->set_configuration(dev->plugin_index, cap, &tmp_u64); break; case SR_T_CHAR: - ret = device->plugin-> set_configuration(device->plugin_index, + ret = dev->plugin->set_configuration(dev->plugin_index, cap, text); break; /* SR_T_BOOL will be handled by prop_toggled */ @@ -76,7 +76,7 @@ static void prop_edited(GtkCellRendererText *cel, gchar *path, gchar *text, static void prop_toggled(GtkCellRendererToggle *cel, gchar *path, GtkListStore *props) { - struct sr_device *device = g_object_get_data(G_OBJECT(props), "device"); + struct sr_dev *dev = g_object_get_data(G_OBJECT(props), "dev"); GtkTreeIter iter; int type, cap; int ret; @@ -87,7 +87,7 @@ static void prop_toggled(GtkCellRendererToggle *cel, gchar *path, DEV_PROP_TYPE, &type, -1); val = !gtk_cell_renderer_toggle_get_active(cel); - ret = device->plugin-> set_configuration(device->plugin_index, cap, + ret = dev->plugin->set_configuration(dev->plugin_index, cap, GINT_TO_POINTER(val)); if (!ret) @@ -114,8 +114,8 @@ static void dev_set_options(GtkAction *action, GtkWindow *parent) { (void)action; - struct sr_device *device = g_object_get_data(G_OBJECT(parent), "device"); - if (!device) + struct sr_dev *dev = g_object_get_data(G_OBJECT(parent), "dev"); + if (!dev) return; GtkWidget *dialog = gtk_dialog_new_with_buttons("Device Properties", @@ -138,7 +138,7 @@ static void dev_set_options(GtkAction *action, GtkWindow *parent) G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_BOOLEAN); gtk_tree_view_set_model(GTK_TREE_VIEW(tv), GTK_TREE_MODEL(props)); - int *capabilities = device->plugin->get_capabilities(); + int *capabilities = dev->plugin->get_capabilities(); int cap; GtkTreeIter iter; for (cap = 0; capabilities[cap]; cap++) { @@ -161,7 +161,7 @@ static void dev_set_options(GtkAction *action, GtkWindow *parent) /* Save device with list so that property can be set by edited * handler. */ - g_object_set_data(G_OBJECT(props), "device", device); + g_object_set_data(G_OBJECT(props), "dev", dev); /* Add columns to the tree view */ GtkTreeViewColumn *col; @@ -203,7 +203,7 @@ enum { static void probe_toggled(GtkCellRenderer *cel, gchar *path, GtkTreeModel *probes) { - struct sr_device *device = g_object_get_data(G_OBJECT(probes), "device"); + struct sr_dev *dev = g_object_get_data(G_OBJECT(probes), "dev"); GtkTreeIter iter; struct sr_probe *probe; gint i; @@ -214,7 +214,7 @@ static void probe_toggled(GtkCellRenderer *cel, gchar *path, gtk_tree_model_get_iter_from_string(probes, &iter, path); gtk_tree_model_get(probes, &iter, PROBE_NUMBER, &i, PROBE_ENABLED, &en, -1); - probe = sr_dev_probe_find(device, i); + probe = sr_dev_probe_find(dev, i); probe->enabled = !en; gtk_list_store_set(GTK_LIST_STORE(probes), &iter, PROBE_ENABLED, probe->enabled, -1); @@ -223,7 +223,7 @@ static void probe_toggled(GtkCellRenderer *cel, gchar *path, static void probe_named(GtkCellRendererText *cel, gchar *path, gchar *text, GtkTreeModel *probes) { - struct sr_device *device = g_object_get_data(G_OBJECT(probes), "device"); + struct sr_dev *dev = g_object_get_data(G_OBJECT(probes), "dev"); GtkTreeIter iter; gint i; @@ -231,14 +231,14 @@ static void probe_named(GtkCellRendererText *cel, gchar *path, gchar *text, gtk_tree_model_get_iter_from_string(probes, &iter, path); gtk_tree_model_get(probes, &iter, PROBE_NUMBER, &i, -1); - sr_dev_probe_name(device, i, text); + sr_dev_probe_name(dev, i, text); gtk_list_store_set(GTK_LIST_STORE(probes), &iter, PROBE_NAME, text, -1); } static void probe_trigger_set(GtkCellRendererText *cel, gchar *path, gchar *text, GtkTreeModel *probes) { - struct sr_device *device = g_object_get_data(G_OBJECT(probes), "device"); + struct sr_dev *dev = g_object_get_data(G_OBJECT(probes), "dev"); GtkTreeIter iter; gint i; @@ -246,7 +246,7 @@ static void probe_trigger_set(GtkCellRendererText *cel, gchar *path, gtk_tree_model_get_iter_from_string(probes, &iter, path); gtk_tree_model_get(probes, &iter, PROBE_NUMBER, &i, -1); - sr_dev_trigger_set(device, i, text); + sr_dev_trigger_set(dev, i, text); gtk_list_store_set(GTK_LIST_STORE(probes), &iter, PROBE_TRIGGER, text, -1); } @@ -255,8 +255,8 @@ static void dev_set_probes(GtkAction *action, GtkWindow *parent) { (void)action; - struct sr_device *device = g_object_get_data(G_OBJECT(parent), "device"); - if (!device) + struct sr_dev *dev = g_object_get_data(G_OBJECT(parent), "dev"); + if (!dev) return; GtkWidget *dialog = gtk_dialog_new_with_buttons("Configure Probes", @@ -280,7 +280,7 @@ static void dev_set_probes(GtkAction *action, GtkWindow *parent) GtkTreeIter iter; GSList *p; int i; - for (p = device->probes, i = 1; p; p = g_slist_next(p), i++) { + for (p = dev->probes, i = 1; p; p = g_slist_next(p), i++) { struct sr_probe *probe = p->data; gtk_list_store_append(probes, &iter); gtk_list_store_set(probes, &iter, PROBE_NUMBER, i, @@ -292,7 +292,7 @@ static void dev_set_probes(GtkAction *action, GtkWindow *parent) /* Save device with list so that property can be set by edited * handler. */ - g_object_set_data(G_OBJECT(probes), "device", device); + g_object_set_data(G_OBJECT(probes), "dev", dev); /* Add columns to the tree view */ GtkTreeViewColumn *col; @@ -332,7 +332,7 @@ static void capture_run(GtkAction *action, GObject *parent) { (void)action; - struct sr_device *device = g_object_get_data(G_OBJECT(parent), "device"); + struct sr_dev *dev = g_object_get_data(G_OBJECT(parent), "dev"); GtkEntry *timesamples = g_object_get_data(parent, "timesamples"); GtkComboBox *timeunit = g_object_get_data(parent, "timeunit"); gint i = gtk_combo_box_get_active(timeunit); @@ -354,8 +354,8 @@ static void capture_run(GtkAction *action, GObject *parent) } if (time_msec) { - if (sr_hw_has_hwcap(device->plugin, SR_HWCAP_LIMIT_MSEC)) { - if (device->plugin->set_configuration(device->plugin_index, + if (sr_hw_has_hwcap(dev->plugin, SR_HWCAP_LIMIT_MSEC)) { + if (dev->plugin->set_configuration(dev->plugin_index, SR_HWCAP_LIMIT_MSEC, &time_msec) != SR_OK) { g_critical("Failed to configure time limit."); @@ -367,10 +367,10 @@ static void capture_run(GtkAction *action, GObject *parent) * convert to samples based on the samplerate. */ limit_samples = 0; - if (sr_dev_has_hwcap(device, SR_HWCAP_SAMPLERATE)) { + if (sr_dev_has_hwcap(dev, SR_HWCAP_SAMPLERATE)) { guint64 tmp_u64; - tmp_u64 = *((uint64_t *) device->plugin->get_device_info( - device->plugin_index, + tmp_u64 = *((uint64_t *)dev->plugin->get_dev_info( + dev->plugin_index, SR_DI_CUR_SAMPLERATE)); limit_samples = tmp_u64 * time_msec / (uint64_t) 1000; } @@ -379,7 +379,7 @@ static void capture_run(GtkAction *action, GObject *parent) return; } - if (device->plugin->set_configuration(device->plugin_index, + if (dev->plugin->set_configuration(dev->plugin_index, SR_HWCAP_LIMIT_SAMPLES, &limit_samples) != SR_OK) { g_critical("Failed to configure time-based sample limit."); @@ -388,7 +388,7 @@ static void capture_run(GtkAction *action, GObject *parent) } } if (limit_samples) { - if (device->plugin->set_configuration(device->plugin_index, + if (dev->plugin->set_configuration(dev->plugin_index, SR_HWCAP_LIMIT_SAMPLES, &limit_samples) != SR_OK) { g_critical("Failed to configure sample limit."); @@ -396,8 +396,8 @@ static void capture_run(GtkAction *action, GObject *parent) } } - if (device->plugin->set_configuration(device->plugin_index, - SR_HWCAP_PROBECONFIG, (char *)device->probes) != SR_OK) { + if (dev->plugin->set_configuration(dev->plugin_index, + SR_HWCAP_PROBECONFIG, (char *)dev->probes) != SR_OK) { printf("Failed to configure probes.\n"); sr_session_destroy(); return;