mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-15 06:40:08 +00:00
gtk: add gtk_widget_get_scale_factor()
This commit is contained in:
parent
d4607be003
commit
c0ea0b5aad
@ -641,7 +641,8 @@ enum {
|
|||||||
PROP_VEXPAND,
|
PROP_VEXPAND,
|
||||||
PROP_HEXPAND_SET,
|
PROP_HEXPAND_SET,
|
||||||
PROP_VEXPAND_SET,
|
PROP_VEXPAND_SET,
|
||||||
PROP_EXPAND
|
PROP_EXPAND,
|
||||||
|
PROP_SCALE_FACTOR
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _GtkStateData GtkStateData;
|
typedef struct _GtkStateData GtkStateData;
|
||||||
@ -1607,6 +1608,25 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
|||||||
1.0,
|
1.0,
|
||||||
1.0,
|
1.0,
|
||||||
GTK_PARAM_READWRITE));
|
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:
|
* GtkWidget::show:
|
||||||
* @widget: the object which received the signal.
|
* @widget: the object which received the signal.
|
||||||
@ -3883,6 +3903,9 @@ gtk_widget_get_property (GObject *object,
|
|||||||
case PROP_OPACITY:
|
case PROP_OPACITY:
|
||||||
g_value_set_double (value, gtk_widget_get_opacity (widget));
|
g_value_set_double (value, gtk_widget_get_opacity (widget));
|
||||||
break;
|
break;
|
||||||
|
case PROP_SCALE_FACTOR:
|
||||||
|
g_value_set_int (value, gtk_widget_get_scale_factor (widget));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -9969,6 +9992,26 @@ gtk_widget_has_screen (GtkWidget *widget)
|
|||||||
return (gtk_widget_get_screen_unchecked (widget) != NULL);
|
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:
|
* gtk_widget_get_display:
|
||||||
* @widget: a #GtkWidget
|
* @widget: a #GtkWidget
|
||||||
|
@ -848,6 +848,8 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
GdkScreen * gtk_widget_get_screen (GtkWidget *widget);
|
GdkScreen * gtk_widget_get_screen (GtkWidget *widget);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
gboolean gtk_widget_has_screen (GtkWidget *widget);
|
gboolean gtk_widget_has_screen (GtkWidget *widget);
|
||||||
|
GDK_AVAILABLE_IN_3_10
|
||||||
|
gint gtk_widget_get_scale_factor (GtkWidget *widget);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GdkDisplay * gtk_widget_get_display (GtkWidget *widget);
|
GdkDisplay * gtk_widget_get_display (GtkWidget *widget);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
Loading…
Reference in New Issue
Block a user