mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
monitor: Add a ::valid property
This is slightly more useful than the existing ::invalidate signal, since it can be queried at any time.
This commit is contained in:
parent
2d31a5499a
commit
f2655b055d
@ -1271,6 +1271,7 @@ gdk_monitor_get_refresh_rate
|
|||||||
GdkSubpixelLayout
|
GdkSubpixelLayout
|
||||||
gdk_monitor_get_subpixel_layout
|
gdk_monitor_get_subpixel_layout
|
||||||
gdk_monitor_is_primary
|
gdk_monitor_is_primary
|
||||||
|
gdk_monitor_is_valid
|
||||||
|
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
gdk_monitor_get_type
|
gdk_monitor_get_type
|
||||||
|
@ -49,6 +49,7 @@ enum {
|
|||||||
PROP_HEIGHT_MM,
|
PROP_HEIGHT_MM,
|
||||||
PROP_REFRESH_RATE,
|
PROP_REFRESH_RATE,
|
||||||
PROP_SUBPIXEL_LAYOUT,
|
PROP_SUBPIXEL_LAYOUT,
|
||||||
|
PROP_VALID,
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,6 +68,7 @@ static void
|
|||||||
gdk_monitor_init (GdkMonitor *monitor)
|
gdk_monitor_init (GdkMonitor *monitor)
|
||||||
{
|
{
|
||||||
monitor->scale_factor = 1;
|
monitor->scale_factor = 1;
|
||||||
|
monitor->valid = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -123,6 +125,10 @@ gdk_monitor_get_property (GObject *object,
|
|||||||
g_value_set_enum (value, monitor->subpixel_layout);
|
g_value_set_enum (value, monitor->subpixel_layout);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_VALID:
|
||||||
|
g_value_set_boolean (value, monitor->valid);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
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_TYPE_SUBPIXEL_LAYOUT,
|
||||||
GDK_SUBPIXEL_LAYOUT_UNKNOWN,
|
GDK_SUBPIXEL_LAYOUT_UNKNOWN,
|
||||||
G_PARAM_READABLE);
|
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);
|
g_object_class_install_properties (object_class, LAST_PROP, props);
|
||||||
|
|
||||||
@ -595,5 +607,27 @@ gdk_monitor_set_subpixel_layout (GdkMonitor *monitor,
|
|||||||
void
|
void
|
||||||
gdk_monitor_invalidate (GdkMonitor *monitor)
|
gdk_monitor_invalidate (GdkMonitor *monitor)
|
||||||
{
|
{
|
||||||
|
monitor->valid = FALSE;
|
||||||
|
g_object_notify (G_OBJECT (monitor), "valid");
|
||||||
g_signal_emit (monitor, signals[INVALIDATE], 0);
|
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;
|
||||||
|
}
|
||||||
|
@ -89,6 +89,8 @@ GDK_AVAILABLE_IN_3_22
|
|||||||
GdkSubpixelLayout gdk_monitor_get_subpixel_layout (GdkMonitor *monitor);
|
GdkSubpixelLayout gdk_monitor_get_subpixel_layout (GdkMonitor *monitor);
|
||||||
GDK_AVAILABLE_IN_3_22
|
GDK_AVAILABLE_IN_3_22
|
||||||
gboolean gdk_monitor_is_primary (GdkMonitor *monitor);
|
gboolean gdk_monitor_is_primary (GdkMonitor *monitor);
|
||||||
|
GDK_AVAILABLE_IN_3_94
|
||||||
|
gboolean gdk_monitor_is_valid (GdkMonitor *monitor);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ struct _GdkMonitor {
|
|||||||
int scale_factor;
|
int scale_factor;
|
||||||
int refresh_rate;
|
int refresh_rate;
|
||||||
GdkSubpixelLayout subpixel_layout;
|
GdkSubpixelLayout subpixel_layout;
|
||||||
|
gboolean valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GdkMonitorClass {
|
struct _GdkMonitorClass {
|
||||||
|
Loading…
Reference in New Issue
Block a user