diff options
author | Alexander Larsson <alexl@redhat.com> | 2020-01-28 16:14:52 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2020-01-30 10:53:43 +0100 |
commit | b087f9ca51aec76f373f2d25676ea79de278f5a1 (patch) | |
tree | 1f111090993ced43d170a0f9032b790af7985df5 /gtk | |
parent | e2f778602b027572775ba58823b27509f7b3a589 (diff) | |
download | gtk+-b087f9ca51aec76f373f2d25676ea79de278f5a1.tar.gz |
icon-theme: Drop the _for_scale() versions and always take scale
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkapplication-quartz-menu.c | 2 | ||||
-rw-r--r-- | gtk/gtkbuilder.c | 2 | ||||
-rw-r--r-- | gtk/gtkcalendar.c | 2 | ||||
-rw-r--r-- | gtk/gtkcssimageicontheme.c | 12 | ||||
-rw-r--r-- | gtk/gtkdragsource.c | 2 | ||||
-rw-r--r-- | gtk/gtkiconhelper.c | 10 | ||||
-rw-r--r-- | gtk/gtkicontheme.c | 171 | ||||
-rw-r--r-- | gtk/gtkicontheme.h | 20 | ||||
-rw-r--r-- | gtk/gtkmountoperation.c | 2 | ||||
-rw-r--r-- | gtk/gtkwindow.c | 15 |
10 files changed, 50 insertions, 188 deletions
diff --git a/gtk/gtkapplication-quartz-menu.c b/gtk/gtkapplication-quartz-menu.c index 61188e3520..2d31dc0463 100644 --- a/gtk/gtkapplication-quartz-menu.c +++ b/gtk/gtkapplication-quartz-menu.c @@ -300,7 +300,7 @@ icon_loaded (GObject *object, if ([[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)]) scale = roundf ([[NSScreen mainScreen] backingScaleFactor]); #endif - info = gtk_icon_theme_lookup_by_gicon_for_scale (theme, icon, ICON_SIZE, scale, GTK_ICON_LOOKUP_USE_BUILTIN); + info = gtk_icon_theme_lookup_by_gicon (theme, icon, ICON_SIZE, scale, GTK_ICON_LOOKUP_USE_BUILTIN); if (info != NULL) { diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index 77174404c4..3c7dad5f90 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -2167,7 +2167,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder, /* fall back to a missing image */ theme = gtk_icon_theme_get_default (); - icon = gtk_icon_theme_lookup_icon (theme, "image-missing", 16, + icon = gtk_icon_theme_lookup_icon (theme, "image-missing", 16, 1, GTK_ICON_LOOKUP_USE_BUILTIN); texture = gtk_icon_download_texture (icon, NULL); pixbuf = gdk_pixbuf_get_from_texture (texture); diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index cc355c5ad5..928a5513b5 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -2604,7 +2604,7 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture, drag = gdk_drag_begin (surface, device, content, GDK_ACTION_COPY, start_x, start_y); theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget)); - icon = gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 0); + icon = gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 1, 0); gtk_drag_icon_set_from_paintable (drag, GDK_PAINTABLE (icon), 0, 0); g_clear_object (&icon); diff --git a/gtk/gtkcssimageicontheme.c b/gtk/gtkcssimageicontheme.c index 65790719d3..86786b8f61 100644 --- a/gtk/gtkcssimageicontheme.c +++ b/gtk/gtkcssimageicontheme.c @@ -61,15 +61,15 @@ gtk_css_image_icon_theme_snapshot (GtkCssImage *image, } else { - icon_info = gtk_icon_theme_lookup_icon_for_scale (icon_theme->icon_theme, - icon_theme->name, - size, - icon_theme->scale, - GTK_ICON_LOOKUP_USE_BUILTIN); + icon_info = gtk_icon_theme_lookup_icon (icon_theme->icon_theme, + icon_theme->name, + size, + icon_theme->scale, + GTK_ICON_LOOKUP_USE_BUILTIN); if (icon_info == NULL) icon_info = gtk_icon_theme_lookup_icon (icon_theme->icon_theme, "image-missing", - size, + size, icon_theme->scale, GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK); g_assert (icon_info != NULL); diff --git a/gtk/gtkdragsource.c b/gtk/gtkdragsource.c index 6bf730401c..0df09f1b56 100644 --- a/gtk/gtkdragsource.c +++ b/gtk/gtkdragsource.c @@ -486,7 +486,7 @@ gtk_drag_source_drag_begin (GtkDragSource *source) GtkIconTheme *theme; theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget)); - source->paintable = GDK_PAINTABLE(gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 0)); + source->paintable = GDK_PAINTABLE(gtk_icon_theme_lookup_icon (theme, "text-x-generic", 32, 1, 0)); source->hot_x = 0; source->hot_y = 0; } diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c index aa76783d67..7bd7a7bc48 100644 --- a/gtk/gtkiconhelper.c +++ b/gtk/gtkiconhelper.c @@ -110,14 +110,14 @@ ensure_paintable_for_gicon (GtkIconHelper *self, width = height = gtk_icon_helper_get_size (self); - info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme, - gicon, - MIN (width, height), - scale, flags); + info = gtk_icon_theme_lookup_by_gicon (icon_theme, + gicon, + MIN (width, height), + scale, flags); if (info == NULL) info = gtk_icon_theme_lookup_icon (icon_theme, "image-missing", - width, + width, scale, flags | GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK); *symbolic = gtk_icon_is_symbolic (info); diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 90854396ac..289e1fc0ba 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -2071,51 +2071,7 @@ choose_icon (GtkIconTheme *self, } /** - * gtk_icon_theme_lookup_icon: - * @self: a #GtkIconTheme - * @icon_name: the name of the icon to lookup - * @size: desired icon size - * @flags: flags modifying the behavior of the icon lookup - * - * Looks up a named icon and returns a #GtkIcon containing - * information such as the filename of the icon. The icon - * can then be rendered into a pixbuf using - * gtk_icon_load_icon(). (gtk_icon_theme_load_icon() - * combines these two steps if all you need is the pixbuf.) - * - * When rendering on displays with high pixel densities you should not - * use a @size multiplied by the scaling factor returned by functions - * like gdk_surface_get_scale_factor(). Instead, you should use - * gtk_icon_theme_lookup_icon_for_scale(), as the assets loaded - * for a given scaling factor may be different. - * - * This call is threadsafe, you can safely pass a GtkIconTheme - * to another thread and call this method on it. - * - * Returns: (nullable) (transfer full): a #GtkIcon object - * containing information about the icon, or %NULL if the - * icon wasn’t found. - */ -GtkIcon * -gtk_icon_theme_lookup_icon (GtkIconTheme *self, - const gchar *icon_name, - gint size, - GtkIconLookupFlags flags) -{ - g_return_val_if_fail (GTK_IS_ICON_THEME (self), NULL); - g_return_val_if_fail (icon_name != NULL, NULL); - g_return_val_if_fail ((flags & GTK_ICON_LOOKUP_NO_SVG) == 0 || - (flags & GTK_ICON_LOOKUP_FORCE_SVG) == 0, NULL); - - GTK_DISPLAY_NOTE (self->display, ICONTHEME, - g_message ("looking up icon %s", icon_name)); - - return gtk_icon_theme_lookup_icon_for_scale (self, icon_name, - size, 1, flags); -} - -/** - * gtk_icon_theme_lookup_icon_for_scale: + * gtk_icon_theme_lookup_icon_scale: * @self: a #GtkIconTheme * @icon_name: the name of the icon to lookup * @size: desired icon size @@ -2136,11 +2092,11 @@ gtk_icon_theme_lookup_icon (GtkIconTheme *self, * icon wasn’t found. */ GtkIcon * -gtk_icon_theme_lookup_icon_for_scale (GtkIconTheme *self, - const gchar *icon_name, - gint size, - gint scale, - GtkIconLookupFlags flags) +gtk_icon_theme_lookup_icon (GtkIconTheme *self, + const gchar *icon_name, + gint size, + gint scale, + GtkIconLookupFlags flags) { GtkIcon *icon; @@ -2224,54 +2180,6 @@ gtk_icon_theme_lookup_icon_for_scale (GtkIconTheme *self, /** * gtk_icon_theme_choose_icon: * @self: a #GtkIconTheme - * @icon_names: (array zero-terminated=1): %NULL-terminated array of - * icon names to lookup - * @size: desired icon size - * @flags: flags modifying the behavior of the icon lookup - * - * Looks up a named icon and returns a #GtkIcon containing - * information such as the filename of the icon. The icon - * can then be rendered into a pixbuf using - * gtk_icon_load_icon(). (gtk_icon_theme_load_icon() - * combines these two steps if all you need is the pixbuf.) - * - * If @icon_names contains more than one name, this function - * tries them all in the given order before falling back to - * inherited icon themes. - * - * This call is threadsafe, you can safely pass a GtkIconTheme - * to another thread and call this method on it. - * - * Returns: (nullable) (transfer full): a #GtkIcon object - * containing information about the icon, or %NULL if the icon wasn’t - * found. - */ -GtkIcon * -gtk_icon_theme_choose_icon (GtkIconTheme *self, - const gchar *icon_names[], - gint size, - GtkIconLookupFlags flags) -{ - GtkIcon *icon; - - g_return_val_if_fail (GTK_IS_ICON_THEME (self), NULL); - g_return_val_if_fail (icon_names != NULL, NULL); - g_return_val_if_fail ((flags & GTK_ICON_LOOKUP_NO_SVG) == 0 || - (flags & GTK_ICON_LOOKUP_FORCE_SVG) == 0, NULL); - g_warn_if_fail ((flags & GTK_ICON_LOOKUP_GENERIC_FALLBACK) == 0); - - gtk_icon_theme_lock (self); - - icon = choose_icon (self, icon_names, size, 1, flags, FALSE, NULL); - - gtk_icon_theme_unlock (self); - - return icon; -} - -/** - * gtk_icon_theme_choose_icon_for_scale: - * @self: a #GtkIconTheme * @icon_names: (array zero-terminated=1): %NULL-terminated * array of icon names to lookup * @size: desired icon size @@ -2296,11 +2204,11 @@ gtk_icon_theme_choose_icon (GtkIconTheme *self, * icon wasn’t found. */ GtkIcon * -gtk_icon_theme_choose_icon_for_scale (GtkIconTheme *self, - const gchar *icon_names[], - gint size, - gint scale, - GtkIconLookupFlags flags) +gtk_icon_theme_choose_icon (GtkIconTheme *self, + const gchar *icon_names[], + gint size, + gint scale, + GtkIconLookupFlags flags) { GtkIcon *icon; @@ -2358,11 +2266,11 @@ choose_icon_thread (GTask *task, GtkIconTheme *self = GTK_ICON_THEME (source_object); GtkIcon *icon; - icon = gtk_icon_theme_choose_icon_for_scale (self, - (const char **)data->icon_names, - data->size, - data->scale, - data->flags); + icon = gtk_icon_theme_choose_icon (self, + (const char **)data->icon_names, + data->size, + data->scale, + data->flags); if (icon) { @@ -2415,7 +2323,7 @@ load_icon_thread (GTask *task, * * Asynchronously lookup, load, render and scale an icon . * - * For more details, see gtk_icon_theme_choose_icon_for_scale() which is the synchronous + * For more details, see gtk_icon_theme_choose_icon() which is the synchronous * version of this call. * * Returns: (nullable) (transfer full): a #GtkIcon object @@ -4101,37 +4009,6 @@ icon_paintable_init (GdkPaintableInterface *iface) iface->get_intrinsic_height = icon_paintable_get_intrinsic_height; } -/** - * gtk_icon_theme_lookup_by_gicon: - * @self: a #GtkIconTheme - * @icon: the #GIcon to look up - * @size: desired icon size - * @flags: flags modifying the behavior of the icon lookup - * - * Looks up an icon and returns a #GtkIcon containing information - * such as the filename of the icon. The icon can then be rendered - * into a pixbuf using gtk_icon_load_icon(). - * - * When rendering on displays with high pixel densities you should not - * use a @size multiplied by the scaling factor returned by functions - * like gdk_surface_get_scale_factor(). Instead, you should use - * gtk_icon_theme_lookup_by_gicon_for_scale(), as the assets loaded - * for a given scaling factor may be different. - * - * Returns: (nullable) (transfer full): a #GtkIcon containing - * information about the icon, or %NULL if the icon wasn’t - * found. Unref with g_object_unref() - */ -GtkIcon * -gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self, - GIcon *icon, - gint size, - GtkIconLookupFlags flags) -{ - return gtk_icon_theme_lookup_by_gicon_for_scale (self, icon, - size, 1, flags); -} - static GtkIcon * gtk_icon_new_for_file (GFile *file, gint size, @@ -4189,7 +4066,7 @@ gtk_icon_new_for_pixbuf (GtkIconTheme *icon_theme, } /** - * gtk_icon_theme_lookup_by_gicon_for_scale: + * gtk_icon_theme_lookup_by_gicon: * @self: a #GtkIconTheme * @icon: the #GIcon to look up * @size: desired icon size @@ -4205,11 +4082,11 @@ gtk_icon_new_for_pixbuf (GtkIconTheme *icon_theme, * found. Unref with g_object_unref() */ GtkIcon * -gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *self, - GIcon *gicon, - gint size, - gint scale, - GtkIconLookupFlags flags) +gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self, + GIcon *gicon, + gint size, + gint scale, + GtkIconLookupFlags flags) { GtkIcon *icon; @@ -4281,7 +4158,7 @@ gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *self, const gchar **names; names = (const gchar **)g_themed_icon_get_names (G_THEMED_ICON (gicon)); - icon = gtk_icon_theme_choose_icon_for_scale (self, names, size, scale, flags); + icon = gtk_icon_theme_choose_icon (self, names, size, scale, flags); return icon; } diff --git a/gtk/gtkicontheme.h b/gtk/gtkicontheme.h index f1e22aa0ee..c40f0867d0 100644 --- a/gtk/gtkicontheme.h +++ b/gtk/gtkicontheme.h @@ -149,23 +149,12 @@ GDK_AVAILABLE_IN_ALL GtkIcon * gtk_icon_theme_lookup_icon (GtkIconTheme *self, const gchar *icon_name, gint size, - GtkIconLookupFlags flags); -GDK_AVAILABLE_IN_ALL -GtkIcon * gtk_icon_theme_lookup_icon_for_scale (GtkIconTheme *self, - const gchar *icon_name, - gint size, gint scale, GtkIconLookupFlags flags); - GDK_AVAILABLE_IN_ALL GtkIcon * gtk_icon_theme_choose_icon (GtkIconTheme *self, const gchar *icon_names[], gint size, - GtkIconLookupFlags flags); -GDK_AVAILABLE_IN_ALL -GtkIcon * gtk_icon_theme_choose_icon_for_scale (GtkIconTheme *self, - const gchar *icon_names[], - gint size, gint scale, GtkIconLookupFlags flags); GDK_AVAILABLE_IN_ALL @@ -182,17 +171,12 @@ GtkIcon * gtk_icon_theme_choose_icon_finish (GtkIconTheme GAsyncResult *result, GError **error); GDK_AVAILABLE_IN_ALL -GtkIcon * gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self, +GtkIcon * gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self, GIcon *icon, gint size, + gint scale, GtkIconLookupFlags flags); GDK_AVAILABLE_IN_ALL -GtkIcon * gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *self, - GIcon *icon, - gint size, - gint scale, - GtkIconLookupFlags flags); -GDK_AVAILABLE_IN_ALL GList * gtk_icon_theme_list_icons (GtkIconTheme *self, const gchar *context); GDK_AVAILABLE_IN_ALL diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c index 37f2398c09..b23734d0bf 100644 --- a/gtk/gtkmountoperation.c +++ b/gtk/gtkmountoperation.c @@ -1174,7 +1174,7 @@ add_pid_to_process_list_store (GtkMountOperation *mount_operation, theme = gtk_css_icon_theme_value_get_icon_theme (_gtk_style_context_peek_property (gtk_widget_get_style_context (GTK_WIDGET (mount_operation->priv->dialog)), GTK_CSS_PROPERTY_ICON_THEME)); - info = gtk_icon_theme_lookup_icon (theme, "application-x-executable", 24, 0); + info = gtk_icon_theme_lookup_icon (theme, "application-x-executable", 24, 1, 0); texture = gtk_icon_download_texture (info, NULL); g_object_unref (info); } diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index ba1f53440b..76295d9695 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -4027,13 +4027,13 @@ icon_list_from_theme (GtkWindow *window, * fixed size of 48. */ if (sizes[i] == -1) - info = gtk_icon_theme_lookup_icon_for_scale (icon_theme, name, - 48, priv->scale, - 0); + info = gtk_icon_theme_lookup_icon (icon_theme, name, + 48, priv->scale, + 0); else - info = gtk_icon_theme_lookup_icon_for_scale (icon_theme, name, - sizes[i], priv->scale, - 0); + info = gtk_icon_theme_lookup_icon (icon_theme, name, + sizes[i], priv->scale, + 0); if (info) { GdkTexture *texture = gtk_icon_download_texture (info, NULL); @@ -4100,6 +4100,7 @@ GdkPaintable * gtk_window_get_icon_for_size (GtkWindow *window, int size) { + GtkWindowPrivate *priv = gtk_window_get_instance_private (window); const char *name; GtkIcon *info; @@ -4111,7 +4112,7 @@ gtk_window_get_icon_for_size (GtkWindow *window, return NULL; info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), - name, size, + name, size, priv->scale, GTK_ICON_LOOKUP_FORCE_SIZE); if (info == NULL) return NULL; |