The API encouraged wrong usage - most of the users were indeed wrong.
Use the correct version instead:
gtk_icon_theme_get_for_display (gtk_widget_get_display ())
{
GtkWidget *image;
- image = gtk_image_new_from_icon_name (get_random_icon_name (gtk_icon_theme_get_default ()));
+ image = gtk_image_new ();
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
+ gtk_image_set_from_icon_name (GTK_IMAGE (image),
+ get_random_icon_name (gtk_icon_theme_get_for_display (gtk_widget_get_display (image))));
return image;
}
if (!icons_added)
{
icons_added = TRUE;
- gtk_icon_theme_add_resource_path (gtk_icon_theme_get_default (), "/icons");
+ gtk_icon_theme_add_resource_path (gtk_icon_theme_get_for_display (gtk_widget_get_display (do_widget)), "/icons");
}
g_type_ensure (G_TYPE_FILE_ICON);
}
static void
-insert_text (GtkTextBuffer *buffer)
+insert_text (GtkTextView *view)
{
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer (view);
GtkTextIter iter;
GtkTextIter start, end;
GdkTexture *texture;
GtkIconTheme *icon_theme;
GtkIcon *icon;
- icon_theme = gtk_icon_theme_get_default ();
+ icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (view)));
icon = gtk_icon_theme_lookup_icon (icon_theme,
"gtk3-demo",
32, 1,
gtk_container_add (GTK_CONTAINER (sw), view2);
create_tags (buffer);
- insert_text (buffer);
+ insert_text (GTK_TEXT_VIEW (view1));
attach_widgets (GTK_TEXT_VIEW (view1));
attach_widgets (GTK_TEXT_VIEW (view2));
G_DEFINE_TYPE(IconBrowserWindow, icon_browser_window, GTK_TYPE_APPLICATION_WINDOW);
+static GtkIconTheme *
+icon_browser_window_get_icon_theme (IconBrowserWindow *win)
+{
+ return gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (win)));
+}
+
static void
search_text_changed (GtkEntry *entry, IconBrowserWindow *win)
{
static void
item_activated (GtkIconView *icon_view, GtkTreePath *path, IconBrowserWindow *win)
{
+ GtkIconTheme *icon_theme = icon_browser_window_get_icon_theme (win);
GtkTreeIter iter;
gchar *name;
gchar *description;
ICON_STORE_DESCRIPTION_COLUMN, &description,
-1);
- if (name == NULL || !gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), name))
+ if (name == NULL || !gtk_icon_theme_has_icon (icon_theme, name))
{
g_free (description);
return;
const gchar *description,
const gchar *context)
{
+ GtkIconTheme *icon_theme = icon_browser_window_get_icon_theme (win);
gchar *regular_name;
gchar *symbolic_name;
regular_name = g_strdup (name);
- if (!gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), regular_name))
+ if (!gtk_icon_theme_has_icon (icon_theme, regular_name))
{
g_free (regular_name);
regular_name = NULL;
}
symbolic_name = g_strconcat (name, "-symbolic", NULL);
- if (!gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), symbolic_name))
+ if (!gtk_icon_theme_has_icon (icon_theme, symbolic_name))
{
g_free (symbolic_name);
symbolic_name = NULL;
get_file (GValue *value,
gpointer data)
{
+ GtkIconTheme *icon_theme;
const char *name;
GtkIcon *info;
GFile *file;
name = gtk_image_get_icon_name (GTK_IMAGE (data));
+ icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (data)));
- info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), name, 32, 1, 0);
+ info = gtk_icon_theme_lookup_icon (icon_theme, name, 32, 1, 0);
file = g_file_new_for_path (gtk_icon_get_filename (info));
g_value_set_object (value, file);
g_object_unref (file);
GTK_TYPE_ICON_LOOKUP_FLAGS
GtkIconThemeError
gtk_icon_theme_new
-gtk_icon_theme_get_default
gtk_icon_theme_get_for_display
gtk_icon_theme_set_display
gtk_icon_theme_set_search_path
if (icon_name)
{
- gint *sizes = gtk_icon_theme_get_icon_sizes (gtk_icon_theme_get_default (),
- icon_name);
+ GtkIconTheme *icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (about)));
+ gint *sizes = gtk_icon_theme_get_icon_sizes (icon_theme, icon_name);
gint i, best_size = 0;
for (i = 0; sizes[i]; i++)
parsed = TRUE;
}
- theme = gtk_icon_theme_get_default ();
+ theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
/* we need a run-time check for the backingScaleFactor selector because we
GtkIconTheme *default_theme;
gchar *iconspath;
- default_theme = gtk_icon_theme_get_default ();
+ default_theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
iconspath = g_strconcat (base_path, "/icons/", NULL);
gtk_icon_theme_add_resource_path (default_theme, iconspath);
g_free (iconspath);
g_error_free (tmp_error);
/* fall back to a missing image */
- theme = gtk_icon_theme_get_default ();
+ /* FIXME: this should be using the correct display */
+ theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
icon = gtk_icon_theme_lookup_icon (theme, "image-missing", 16, 1,
GTK_ICON_LOOKUP_USE_BUILTIN);
static void
_gtk_css_image_icon_theme_init (GtkCssImageIconTheme *icon_theme)
{
- icon_theme->icon_theme = gtk_icon_theme_get_default ();
+ icon_theme->icon_theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
icon_theme->scale = 1;
icon_theme->cached_size = -1;
icon_theme->cached_icon = NULL;
* directly is also simple. The #GtkIconTheme object acts
* as a database of all the icons in the current theme. You
* can create new #GtkIconTheme objects, but it’s much more
- * efficient to use the standard icon theme for the #GdkDisplay
+ * efficient to use the standard icon theme of the #GtkWidget
* so that the icon information is shared with other people
* looking up icons.
* |[<!-- language="C" -->
* GtkIconTheme *icon_theme;
* GtkIcon *icon;
*
- * icon_theme = gtk_icon_theme_get_default ();
+ * icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (my_widget));
* icon = gtk_icon_theme_lookup_icon (icon_theme,
* "my-icon-name", // icon name
* 48, // icon size
*
* Creates a new icon theme object. Icon theme objects are used
* to lookup up an icon by name in a particular icon theme.
- * Usually, you’ll want to use gtk_icon_theme_get_default()
- * or gtk_icon_theme_get_for_display() rather than creating
- * a new icon theme object for scratch.
+ * Usually, you’ll want to use gtk_icon_theme_get_for_display()
+ * rather than creating a new icon theme object for scratch.
*
* Returns: the newly created #GtkIconTheme object.
*/
return g_object_new (GTK_TYPE_ICON_THEME, NULL);
}
-/**
- * gtk_icon_theme_get_default:
- *
- * Gets the icon theme for the default display. See
- * gtk_icon_theme_get_for_display().
- *
- * Returns: (transfer none): A unique #GtkIconTheme associated with
- * the default display. This icon theme is associated with
- * the display and can be used as long as the display
- * is open. Do not ref or unref it.
- */
-GtkIconTheme *
-gtk_icon_theme_get_default (void)
-{
- return gtk_icon_theme_get_for_display (gdk_display_get_default ());
-}
-
static void
load_theme_thread (GTask *task,
gpointer source_object,
*
* Sets the name of the icon theme that the #GtkIconTheme object uses
* overriding system configuration. This function cannot be called
- * on the icon theme objects returned from gtk_icon_theme_get_default()
- * and gtk_icon_theme_get_for_display().
+ * on the icon theme objects returned from gtk_icon_theme_get_for_display().
*/
void
gtk_icon_theme_set_custom_theme (GtkIconTheme *self,
GDK_AVAILABLE_IN_ALL
GtkIconTheme *gtk_icon_theme_new (void);
GDK_AVAILABLE_IN_ALL
-GtkIconTheme *gtk_icon_theme_get_default (void);
-GDK_AVAILABLE_IN_ALL
GtkIconTheme *gtk_icon_theme_get_for_display (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_set_display (GtkIconTheme *self,
if (!name)
return NULL;
- info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
+ info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (window))),
name, size, priv->scale,
GTK_ICON_LOOKUP_FORCE_SIZE);
if (info == NULL)
"Empty");
g_value_init (&value, GDK_TYPE_PIXBUF);
- icon = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
+ icon = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_for_display (gdk_clipboard_get_display (clipboard)),
"utilities-terminal",
48, 1, 0);
texture = gtk_icon_download_texture (icon, NULL);
int hot_x, hot_y;
int size = 48;
- icon = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
+ icon = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_for_display (
+ gtk_widget_get_display (
+ gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source)))),
icon_name, size, 1, 0);
switch (hotspot)
{
static void
test_icon_existence (gconstpointer icon_name)
{
+ GtkIconTheme *icon_theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
GtkIcon *info;
/* Not using generic fallback and builtins here, as we explicitly want to check the
* icon theme.
* The icon size is randomly chosen.
*/
- info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), icon_name, 16, 1, GTK_ICON_LOOKUP_DIR_LTR);
+ info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 16, 1, GTK_ICON_LOOKUP_DIR_LTR);
if (info == NULL)
{
g_test_message ("Failed to look up icon for \"%s\"", (char *) icon_name);
g_assert_cmpint (width, !=, height);
/* now load it through GtkIconTheme */
- icon_theme = gtk_icon_theme_get_default ();
+ icon_theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
file = g_file_new_for_path (path);
icon = g_file_icon_new (file);
info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon,