forked from AuroraMiddleware/gtk
icontheme: Remove gtk_icon_theme_get_default()
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 ())
This commit is contained in:
parent
b8ffe5b245
commit
bfebc2b01a
@ -60,8 +60,10 @@ create_icon (void)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ do_shortcuts (GtkWidget *do_widget)
|
||||
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);
|
||||
|
@ -124,15 +124,16 @@ create_tags (GtkTextBuffer *buffer)
|
||||
}
|
||||
|
||||
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,
|
||||
@ -508,7 +509,7 @@ do_textview (GtkWidget *do_widget)
|
||||
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));
|
||||
|
@ -60,6 +60,12 @@ struct _IconBrowserWindowClass
|
||||
|
||||
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)
|
||||
{
|
||||
@ -83,6 +89,7 @@ set_image (GtkWidget *image, const gchar *name, gint size)
|
||||
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;
|
||||
@ -99,7 +106,7 @@ item_activated (GtkIconView *icon_view, GtkTreePath *path, IconBrowserWindow *wi
|
||||
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;
|
||||
@ -144,18 +151,19 @@ add_icon (IconBrowserWindow *win,
|
||||
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;
|
||||
@ -404,13 +412,15 @@ static void
|
||||
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);
|
||||
|
@ -4995,7 +4995,6 @@ GTK_TYPE_ICON_THEME_ERROR
|
||||
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
|
||||
|
@ -1831,8 +1831,8 @@ gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
|
||||
|
||||
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++)
|
||||
|
@ -291,7 +291,7 @@ icon_loaded (GObject *object,
|
||||
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
|
||||
|
@ -214,7 +214,7 @@ gtk_application_load_resources (GtkApplication *application)
|
||||
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);
|
||||
|
@ -2168,7 +2168,8 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
|
||||
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);
|
||||
|
@ -201,7 +201,7 @@ _gtk_css_image_icon_theme_class_init (GtkCssImageIconThemeClass *klass)
|
||||
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;
|
||||
|
@ -78,14 +78,14 @@
|
||||
* 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
|
||||
@ -705,9 +705,8 @@ G_DEFINE_TYPE (GtkIconTheme, gtk_icon_theme, G_TYPE_OBJECT)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
@ -717,23 +716,6 @@ gtk_icon_theme_new (void)
|
||||
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,
|
||||
@ -1372,8 +1354,7 @@ gtk_icon_theme_add_resource_path (GtkIconTheme *self,
|
||||
*
|
||||
* 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,
|
||||
|
@ -109,8 +109,6 @@ GType gtk_icon_theme_get_type (void) G_GNUC_CONST;
|
||||
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,
|
||||
|
@ -4111,7 +4111,7 @@ gtk_window_get_icon_for_size (GtkWindow *window,
|
||||
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)
|
||||
|
@ -286,7 +286,7 @@ get_button_list (GdkClipboard *clipboard,
|
||||
"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);
|
||||
|
@ -227,7 +227,9 @@ update_source_icon (GtkDragSource *source,
|
||||
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)
|
||||
{
|
||||
|
@ -73,13 +73,14 @@ static char *icon_names[] = {
|
||||
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);
|
||||
|
@ -687,7 +687,7 @@ test_nonsquare_symbolic (void)
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user