forked from AuroraMiddleware/gtk
gtk: add gtk_widget_get_scale_factor()
This commit is contained in:
parent
d4607be003
commit
c0ea0b5aad
@ -641,7 +641,8 @@ enum {
|
||||
PROP_VEXPAND,
|
||||
PROP_HEXPAND_SET,
|
||||
PROP_VEXPAND_SET,
|
||||
PROP_EXPAND
|
||||
PROP_EXPAND,
|
||||
PROP_SCALE_FACTOR
|
||||
};
|
||||
|
||||
typedef struct _GtkStateData GtkStateData;
|
||||
@ -1607,6 +1608,25 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
1.0,
|
||||
1.0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkWidget:scale-factor:
|
||||
*
|
||||
* The scale factor of the widget. See gtk_widget_get_scale_factor() for
|
||||
* more details about widget scaling.
|
||||
*
|
||||
* Since: 3.10
|
||||
*/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_SCALE_FACTOR,
|
||||
g_param_spec_int ("scale-factor",
|
||||
P_("Scale factor"),
|
||||
P_("The scaling factor of the window"),
|
||||
1,
|
||||
G_MAXINT,
|
||||
1,
|
||||
GTK_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* GtkWidget::show:
|
||||
* @widget: the object which received the signal.
|
||||
@ -3883,6 +3903,9 @@ gtk_widget_get_property (GObject *object,
|
||||
case PROP_OPACITY:
|
||||
g_value_set_double (value, gtk_widget_get_opacity (widget));
|
||||
break;
|
||||
case PROP_SCALE_FACTOR:
|
||||
g_value_set_int (value, gtk_widget_get_scale_factor (widget));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -9969,6 +9992,26 @@ gtk_widget_has_screen (GtkWidget *widget)
|
||||
return (gtk_widget_get_screen_unchecked (widget) != NULL);
|
||||
}
|
||||
|
||||
gint
|
||||
gtk_widget_get_scale_factor (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *toplevel;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), 1);
|
||||
|
||||
if (gtk_widget_get_realized (widget))
|
||||
return gdk_window_get_scale_factor (gtk_widget_get_window (widget));
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
if (toplevel && toplevel != widget)
|
||||
return gtk_widget_get_scale_factor (toplevel);
|
||||
|
||||
/* else fall back to something that is more likely to be right than
|
||||
* just returning 1:
|
||||
*/
|
||||
return gdk_screen_get_monitor_scale_factor (gtk_widget_get_screen (widget), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_get_display:
|
||||
* @widget: a #GtkWidget
|
||||
|
@ -848,6 +848,8 @@ GDK_AVAILABLE_IN_ALL
|
||||
GdkScreen * gtk_widget_get_screen (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_widget_has_screen (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_3_10
|
||||
gint gtk_widget_get_scale_factor (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDisplay * gtk_widget_get_display (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
Loading…
Reference in New Issue
Block a user