summaryrefslogtreecommitdiff
path: root/gdk/gdkmonitor.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2023-02-02 12:30:46 +0100
committerMatthias Clasen <mclasen@redhat.com>2023-02-02 12:32:28 +0100
commit2c883a70e22eeaeb43b6c67b9f553adb24371797 (patch)
tree710435f1614a5745f5f1990afb8cdf4041cd4af0 /gdk/gdkmonitor.c
parent3dfeb2fd3736ccea4fa224396d192b3501d1ade6 (diff)
downloadgtk+-2c883a70e22eeaeb43b6c67b9f553adb24371797.tar.gz
Add GdkMonitor::description
This is the right string to when showing monitors in the UI.
Diffstat (limited to 'gdk/gdkmonitor.c')
-rw-r--r--gdk/gdkmonitor.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/gdk/gdkmonitor.c b/gdk/gdkmonitor.c
index 2d6cbb4fde..96d7fe4416 100644
--- a/gdk/gdkmonitor.c
+++ b/gdk/gdkmonitor.c
@@ -39,6 +39,7 @@
enum {
PROP_0,
+ PROP_DESCRIPTION,
PROP_DISPLAY,
PROP_MANUFACTURER,
PROP_MODEL,
@@ -81,6 +82,10 @@ gdk_monitor_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_DESCRIPTION:
+ g_value_set_string (value, monitor->description);
+ break;
+
case PROP_DISPLAY:
g_value_set_object (value, monitor->display);
break;
@@ -154,6 +159,7 @@ gdk_monitor_finalize (GObject *object)
{
GdkMonitor *monitor = GDK_MONITOR (object);
+ g_free (monitor->description);
g_free (monitor->connector);
g_free (monitor->manufacturer);
g_free (monitor->model);
@@ -171,6 +177,18 @@ gdk_monitor_class_init (GdkMonitorClass *class)
object_class->set_property = gdk_monitor_set_property;
/**
+ * GdkMonitor:description: (attributes org.gtk.Property.get=gdk_monitor_get_description)
+ *
+ * A short description of the monitor, meant for display to the user.
+ *
+ * Since: 4.10
+ */
+ props[PROP_DESCRIPTION] =
+ g_param_spec_string ("description", NULL, NULL,
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+ /**
* GdkMonitor:display: (attributes org.gtk.Property.get=gdk_monitor_get_display)
*
* The `GdkDisplay` of the monitor.
@@ -623,3 +641,33 @@ gdk_monitor_is_valid (GdkMonitor *monitor)
return monitor->valid;
}
+
+/**
+ * gdk_monitor_get_description: (attributes org.gtk.Method.get_property=description)
+ * @monitor: a `GdkMonitor`
+ *
+ * Gets a string describing the monitor, if available.
+ *
+ * This can be used to identify a monitor in the UI.
+ *
+ * Returns: (transfer none) (nullable): the monitor description
+ *
+ * Since: 4.10
+ */
+const char *
+gdk_monitor_get_description (GdkMonitor *monitor)
+{
+ g_return_val_if_fail (GDK_IS_MONITOR (monitor), NULL);
+
+ return monitor->description;
+}
+
+void
+gdk_monitor_set_description (GdkMonitor *monitor,
+ const char *description)
+{
+ g_free (monitor->description);
+ monitor->description = g_strdup (description);
+ g_object_notify_by_pspec (G_OBJECT (monitor), props[PROP_DESCRIPTION]);
+}
+