diff options
author | Matthias Clasen <mclasen@redhat.com> | 2017-11-01 14:02:08 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-11-01 14:17:20 -0400 |
commit | f2655b055d6d1e7b81293aad7ecbcc0956857164 (patch) | |
tree | 5e63f04c8d8db2b2bef12545341a9d8cd89d3e51 /gdk/gdkmonitor.c | |
parent | 2d31a5499a5484e72dc30fe573d5934d8560361f (diff) | |
download | gtk+-f2655b055d6d1e7b81293aad7ecbcc0956857164.tar.gz |
monitor: Add a ::valid property
This is slightly more useful than the existing
::invalidate signal, since it can be queried at
any time.
Diffstat (limited to 'gdk/gdkmonitor.c')
-rw-r--r-- | gdk/gdkmonitor.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gdk/gdkmonitor.c b/gdk/gdkmonitor.c index fb721481db..3e8ec272b5 100644 --- a/gdk/gdkmonitor.c +++ b/gdk/gdkmonitor.c @@ -49,6 +49,7 @@ enum { PROP_HEIGHT_MM, PROP_REFRESH_RATE, PROP_SUBPIXEL_LAYOUT, + PROP_VALID, LAST_PROP }; @@ -67,6 +68,7 @@ static void gdk_monitor_init (GdkMonitor *monitor) { monitor->scale_factor = 1; + monitor->valid = TRUE; } static void @@ -123,6 +125,10 @@ gdk_monitor_get_property (GObject *object, g_value_set_enum (value, monitor->subpixel_layout); break; + case PROP_VALID: + g_value_set_boolean (value, monitor->valid); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -232,6 +238,12 @@ gdk_monitor_class_init (GdkMonitorClass *class) GDK_TYPE_SUBPIXEL_LAYOUT, GDK_SUBPIXEL_LAYOUT_UNKNOWN, G_PARAM_READABLE); + props[PROP_VALID] = + g_param_spec_boolean ("valid", + "Valid", + "Whether the monitor is still valid", + TRUE, + G_PARAM_READABLE); g_object_class_install_properties (object_class, LAST_PROP, props); @@ -595,5 +607,27 @@ gdk_monitor_set_subpixel_layout (GdkMonitor *monitor, void gdk_monitor_invalidate (GdkMonitor *monitor) { + monitor->valid = FALSE; + g_object_notify (G_OBJECT (monitor), "valid"); g_signal_emit (monitor, signals[INVALIDATE], 0); } + +/** + * gdk_monitor_is_valid: + * @monitor: a #GdkMonitor + * + * Returns %TRUE if the @monitor object corresponds to a + * physical monitor. The @monitor becomes invalid when the + * physical monitor is unplugged or removed. + * + * Returns: %TRUE if the object corresponds to a physical monitor + * + * Since: 3.94 + */ +gboolean +gdk_monitor_is_valid (GdkMonitor *monitor) +{ + g_return_val_if_fail (GDK_IS_MONITOR (monitor), FALSE); + + return monitor->valid; +} |