Exemple #1
0
char *
make_display_name (const MonitorInfo *info)
{
    const char *vendor;
    int width_mm, height_mm;
    char *inches, *ret;

    if (info)
    {
	vendor = find_vendor (info->manufacturer_code);
    }
    else
    {
        /* Translators: "Unknown" here is used to identify a monitor for which
         * we don't know the vendor. When a vendor is known, the name of the
         * vendor is used. */
	vendor = C_("Monitor vendor", "Unknown");
    }

    if (info && info->width_mm != -1 && info->height_mm)
    {
	width_mm = info->width_mm;
	height_mm = info->height_mm;
    }
    else if (info && info->n_detailed_timings)
    {
	width_mm = info->detailed_timings[0].width_mm;
	height_mm = info->detailed_timings[0].height_mm;
    }
    else
    {
	width_mm = -1;
	height_mm = -1;
    }
    
    if (width_mm != -1 && height_mm != -1)
    {
	double d = sqrt (width_mm * width_mm + height_mm * height_mm);

	inches = diagonal_to_str (d / 25.4);
    }
    else
    {
	inches = NULL;
    }

    if (!inches)
	return g_strdup (vendor);

    ret = g_strdup_printf ("%s %s", vendor, inches);
    g_free (inches);

    return ret;
}
static char *
make_display_size_string (int width_mm,
                          int height_mm)
{
  char *inches = NULL;

  if (width_mm > 0 && height_mm > 0)
    {
      double d = sqrt (width_mm * width_mm + height_mm * height_mm);

      inches = diagonal_to_str (d / 25.4);
    }

  return inches;
}
Exemple #3
0
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);
    }
}