static void gcm_edid_init (GcmEdid *edid) { edid->priv = GCM_EDID_GET_PRIVATE (edid); edid->priv->pnp_ids = gnome_pnp_ids_new (); edid->priv->pnp_id = g_new0 (gchar, 4); edid->priv->red = cd_color_yxy_new (); edid->priv->green = cd_color_yxy_new (); edid->priv->blue = cd_color_yxy_new (); edid->priv->white = cd_color_yxy_new (); }
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; }