static void show_vendor (GnomePnpIds *ids, const char *id) { char *vendor; vendor = gnome_pnp_ids_get_pnp_id (ids, id); g_message ("%s => %s", id, vendor); g_free (vendor); }
const gchar * gcm_edid_get_vendor_name (GcmEdid *edid) { GcmEdidPrivate *priv = edid->priv; g_return_val_if_fail (GCM_IS_EDID (edid), NULL); if (priv->vendor_name == NULL) priv->vendor_name = gnome_pnp_ids_get_pnp_id (priv->pnp_ids, priv->pnp_id); return priv->vendor_name; }
static const char * find_vendor (const char *code) { const char *vendor_name; GnomePnpIds *pnp_ids; pnp_ids = gnome_pnp_ids_new (); vendor_name = gnome_pnp_ids_get_pnp_id (pnp_ids, code); g_object_unref (pnp_ids); if (vendor_name) return vendor_name; return code; }
static char * make_display_name (MetaMonitorManager *manager, MetaOutput *output) { if (g_str_has_prefix (output->name, "LVDS") || g_str_has_prefix (output->name, "eDP")) return g_strdup (_("Built-in display")); if (output->width_mm != -1 && output->height_mm != -1) { double d = sqrt (output->width_mm * output->width_mm + output->height_mm * output->height_mm); char *inches = diagonal_to_str (d / 25.4); char *vendor_name; char *ret; if (g_strcmp0 (output->vendor, "unknown") != 0) { if (!manager->pnp_ids) manager->pnp_ids = gnome_pnp_ids_new (); vendor_name = gnome_pnp_ids_get_pnp_id (manager->pnp_ids, output->vendor); ret = g_strdup_printf ("%s %s", vendor_name, inches); g_free (vendor_name); } else { /* TRANSLATORS: this is a monitor name (in case we don't know the vendor), it's Unknown followed by a size in inches, like 'Unknown 15"' */ ret = g_strdup_printf (_("Unknown %s"), inches); } g_free (inches); return ret; } else { return g_strdup (output->vendor); } }
int main (int argc, char *argv[]) { GnomePnpIds *ids; guint i; g_type_init (); ids = gnome_pnp_ids_new (); if (argc == 2 && g_str_equal (argv[1], "--timed")) { GTimer *timer; gdouble elapsed; timer = g_timer_new (); for (i = 0; i < NUM_ITERS; i++) { char *vendor; vendor = gnome_pnp_ids_get_pnp_id (ids, "ZZZ"); g_free (vendor); } elapsed = g_timer_elapsed (timer, NULL); g_timer_destroy (timer); g_message ("%d iterations took %lf seconds", NUM_ITERS, elapsed); g_object_unref (ids); return 0; } for (i = 1; i < argc; i++) show_vendor (ids, argv[i]); if (argc < 2) { show_vendor (ids, "ELO"); show_vendor (ids, "IBM"); } g_object_unref (ids); return 0; }