Add private getter for a monitor connector

The migration from GdkScreen's monitor API to GdkMonitor left out a way
to get the connector's name of a monitor. While there's no real
guarantee that the connector's name is stable, some system components
used it to uniquely identify a monitor until the next plug in/out event.

Since GTK 3 is API stable, we can only add a private setter and getter
functions pair, without a property.
This commit is contained in:
Emmanuele Bassi 2019-06-20 14:52:41 +01:00
parent 4119578562
commit af778ec7d0
2 changed files with 31 additions and 0 deletions

View File

@ -155,6 +155,7 @@ gdk_monitor_finalize (GObject *object)
{
GdkMonitor *monitor = GDK_MONITOR (object);
g_free (monitor->connector);
g_free (monitor->manufacturer);
g_free (monitor->model);
@ -354,6 +355,22 @@ gdk_monitor_get_height_mm (GdkMonitor *monitor)
return monitor->height_mm;
}
/*< private >
* gdk_monitor_get_connector:
* @monitor: a #GdkMonitor
*
* Gets the name of the monitor's connector, if available.
*
* Returns: (transfer none) (nullable): the name of the connector
*/
const char *
gdk_monitor_get_connector (GdkMonitor *monitor)
{
g_return_val_if_fail (GDK_IS_MONITOR (monitor), NULL);
return monitor->connector;
}
/**
* gdk_monitor_get_manufacturer:
* @monitor: a #GdkMonitor
@ -493,6 +510,16 @@ gdk_monitor_set_model (GdkMonitor *monitor,
g_object_notify (G_OBJECT (monitor), "model");
}
void
gdk_monitor_set_connector (GdkMonitor *monitor,
const char *connector)
{
g_free (monitor->connector);
monitor->connector = g_strdup (connector);
/* g_object_notify (G_OBJECT (monitor), "connector"); */
}
void
gdk_monitor_set_position (GdkMonitor *monitor,
int x,

View File

@ -36,6 +36,7 @@ struct _GdkMonitor {
GdkDisplay *display;
char *manufacturer;
char *model;
char *connector;
GdkRectangle geometry;
int width_mm;
int height_mm;
@ -57,6 +58,9 @@ void gdk_monitor_set_manufacturer (GdkMonitor *monitor,
const char *manufacturer);
void gdk_monitor_set_model (GdkMonitor *monitor,
const char *model);
void gdk_monitor_set_connector (GdkMonitor *monitor,
const char *connector);
const char * gdk_monitor_get_connector (GdkMonitor *monitor);
void gdk_monitor_set_position (GdkMonitor *monitor,
int x,
int y);