summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2020-02-10 12:45:56 +0000
committerAlexander Larsson <alexl@redhat.com>2020-02-10 12:45:56 +0000
commit1698369d52a2288b59724856f2ae1be00e5a3d51 (patch)
tree061aa3821a2bb7e48f42d9a353f759eb9700c736 /demos
parente123fff545ab04470848d206ad438cdf1c221023 (diff)
parent96a4bb446cdf3ed25c015b759d73de49f674203b (diff)
downloadgtk+-1698369d52a2288b59724856f2ae1be00e5a3d51.tar.gz
Merge branch 'icon-theme-api-rework' into 'master'
Icon theme api rework See merge request GNOME/gtk!1390
Diffstat (limited to 'demos')
-rw-r--r--demos/gtk-demo/textview.c20
-rw-r--r--demos/icon-browser/iconbrowserwin.c41
-rw-r--r--demos/icon-browser/window.ui74
3 files changed, 101 insertions, 34 deletions
diff --git a/demos/gtk-demo/textview.c b/demos/gtk-demo/textview.c
index b7c5b514bf..2a2298a14c 100644
--- a/demos/gtk-demo/textview.c
+++ b/demos/gtk-demo/textview.c
@@ -9,6 +9,7 @@
#include <gtk/gtk.h>
#include <stdlib.h> /* for exit() */
+#include "paintable.h"
static void easter_egg_callback (GtkWidget *button, gpointer data);
@@ -130,20 +131,18 @@ insert_text (GtkTextView *view)
GtkTextBuffer *buffer = gtk_text_view_get_buffer (view);
GtkTextIter iter;
GtkTextIter start, end;
- GdkTexture *texture;
GtkIconTheme *icon_theme;
GtkIconPaintable *icon;
+ GdkPaintable *nuclear;
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
icon = gtk_icon_theme_lookup_icon (icon_theme,
- "gtk3-demo",
+ "face-cool",
NULL,
32, 1,
gtk_widget_get_direction (widget),
0);
- texture = gtk_icon_paintable_download_texture (icon, NULL);
- g_object_unref (icon);
- g_assert (texture);
+ nuclear = gtk_nuclear_animation_new ();
/* get start of buffer; each insertion will revalidate the
* iterator to point to just after the inserted text.
@@ -239,9 +238,11 @@ insert_text (GtkTextView *view)
"heading", NULL);
gtk_text_buffer_insert (buffer, &iter, "The buffer can have images in it: ", -1);
- gtk_text_buffer_insert_texture (buffer, &iter, texture);
- gtk_text_buffer_insert_texture (buffer, &iter, texture);
- gtk_text_buffer_insert_texture (buffer, &iter, texture);
+ gtk_text_buffer_insert_paintable (buffer, &iter, GDK_PAINTABLE (icon));
+ gtk_text_buffer_insert_paintable (buffer, &iter, GDK_PAINTABLE (icon));
+
+ gtk_text_buffer_insert_paintable (buffer, &iter, nuclear);
+
gtk_text_buffer_insert (buffer, &iter, " for example.\n\n", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Spacing. ", -1,
@@ -386,7 +387,8 @@ insert_text (GtkTextView *view)
gtk_text_buffer_end_irreversible_action (buffer);
- g_object_unref (texture);
+ g_object_unref (icon);
+ g_object_unref (nuclear);
}
static gboolean
diff --git a/demos/icon-browser/iconbrowserwin.c b/demos/icon-browser/iconbrowserwin.c
index fc10a82020..c0fe825031 100644
--- a/demos/icon-browser/iconbrowserwin.c
+++ b/demos/icon-browser/iconbrowserwin.c
@@ -49,7 +49,9 @@ struct _IconBrowserWindow
GtkWidget *image4;
GtkWidget *image5;
GtkWidget *image6;
- GtkWidget *label6;
+ GtkWidget *image7;
+ GtkWidget *image8;
+ GtkWidget *label8;
GtkWidget *description;
};
@@ -113,21 +115,23 @@ item_activated (GtkIconView *icon_view, GtkTreePath *path, IconBrowserWindow *wi
}
gtk_window_set_title (GTK_WINDOW (win->details), name);
- set_image (win->image1, name, 16);
- set_image (win->image2, name, 24);
- set_image (win->image3, name, 32);
- set_image (win->image4, name, 48);
- set_image (win->image5, name, 64);
+ set_image (win->image1, name, 8);
+ set_image (win->image2, name, 16);
+ set_image (win->image3, name, 18);
+ set_image (win->image4, name, 24);
+ set_image (win->image5, name, 32);
+ set_image (win->image6, name, 48);
+ set_image (win->image7, name, 64);
if (win->symbolic)
{
- gtk_widget_show (win->image6);
- gtk_widget_show (win->label6);
- set_image (win->image6, name, 64);
+ gtk_widget_show (win->image8);
+ gtk_widget_show (win->label8);
+ set_image (win->image8, name, 64);
}
else
{
- gtk_widget_hide (win->image6);
- gtk_widget_hide (win->label6);
+ gtk_widget_hide (win->image8);
+ gtk_widget_hide (win->label8);
}
if (description && description[0])
{
@@ -372,7 +376,7 @@ get_image_paintable (GtkImage *image)
NULL,
size, 1,
gtk_widget_get_direction (GTK_WIDGET (image)),
- GTK_ICON_LOOKUP_FORCE_SIZE);
+ 0);
if (icon == NULL)
return NULL;
return GDK_PAINTABLE (icon);
@@ -419,7 +423,6 @@ get_file (GValue *value,
GtkIconTheme *icon_theme;
const char *name;
GtkIconPaintable *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)));
@@ -430,9 +433,7 @@ get_file (GValue *value,
32, 1,
gtk_widget_get_direction (GTK_WIDGET (data)),
0);
- file = g_file_new_for_path (gtk_icon_paintable_get_filename (info));
- g_value_set_object (value, file);
- g_object_unref (file);
+ g_value_take_object (value, gtk_icon_paintable_get_file (info));
g_object_unref (info);
}
@@ -484,7 +485,9 @@ icon_browser_window_init (IconBrowserWindow *win)
setup_image_dnd (win->image3);
setup_image_dnd (win->image4);
setup_image_dnd (win->image5);
- setup_scalable_image_dnd (win->image6);
+ setup_image_dnd (win->image6);
+ setup_image_dnd (win->image7);
+ setup_scalable_image_dnd (win->image8);
win->contexts = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, context_free);
@@ -541,7 +544,9 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image4);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image5);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image6);
- gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, label6);
+ gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image7);
+ gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, image8);
+ gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, label8);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, description);
gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (class), search_text_changed);
diff --git a/demos/icon-browser/window.ui b/demos/icon-browser/window.ui
index 40964afc44..0aa0c48d4f 100644
--- a/demos/icon-browser/window.ui
+++ b/demos/icon-browser/window.ui
@@ -198,7 +198,7 @@
<property name="halign">center</property>
<property name="valign">end</property>
<accessibility>
- <relation type="labelled-by" target="label6"/>
+ <relation type="labelled-by" target="label5"/>
</accessibility>
<layout>
<property name="left-attach">5</property>
@@ -207,10 +207,36 @@
</object>
</child>
<child>
+ <object class="GtkImage" id="image7">
+ <property name="halign">center</property>
+ <property name="valign">end</property>
+ <accessibility>
+ <relation type="labelled-by" target="label5"/>
+ </accessibility>
+ <layout>
+ <property name="left-attach">6</property>
+ <property name="top-attach">1</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="image8">
+ <property name="halign">center</property>
+ <property name="valign">end</property>
+ <accessibility>
+ <relation type="labelled-by" target="label6"/>
+ </accessibility>
+ <layout>
+ <property name="left-attach">7</property>
+ <property name="top-attach">1</property>
+ </layout>
+ </object>
+ </child>
+ <child>
<object class="GtkLabel" id="label1">
<property name="halign">center</property>
<property name="valign">baseline</property>
- <property name="label">16×16</property>
+ <property name="label">8×8</property>
<style>
<class name="dim-label"/>
</style>
@@ -227,7 +253,7 @@
<object class="GtkLabel" id="label2">
<property name="halign">center</property>
<property name="valign">baseline</property>
- <property name="label">24×24</property>
+ <property name="label">16×16</property>
<style>
<class name="dim-label"/>
</style>
@@ -244,7 +270,7 @@
<object class="GtkLabel" id="label3">
<property name="halign">center</property>
<property name="valign">baseline</property>
- <property name="label">32×32</property>
+ <property name="label">18×18</property>
<style>
<class name="dim-label"/>
</style>
@@ -261,7 +287,7 @@
<object class="GtkLabel" id="label4">
<property name="halign">center</property>
<property name="valign">baseline</property>
- <property name="label">48×48</property>
+ <property name="label">24×24</property>
<style>
<class name="dim-label"/>
</style>
@@ -278,7 +304,7 @@
<object class="GtkLabel" id="label5">
<property name="halign">center</property>
<property name="valign">baseline</property>
- <property name="label">64×64</property>
+ <property name="label">32×32</property>
<style>
<class name="dim-label"/>
</style>
@@ -295,7 +321,7 @@
<object class="GtkLabel" id="label6">
<property name="halign">center</property>
<property name="valign">baseline</property>
- <property name="label">scalable</property>
+ <property name="label">48×48</property>
<style>
<class name="dim-label"/>
</style>
@@ -308,6 +334,40 @@
</layout>
</object>
</child>
+ <child>
+ <object class="GtkLabel" id="label7">
+ <property name="halign">center</property>
+ <property name="valign">baseline</property>
+ <property name="label">64×64</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ <accessibility>
+ <relation type="label-for" target="image7"/>
+ </accessibility>
+ <layout>
+ <property name="left-attach">6</property>
+ <property name="top-attach">2</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label8">
+ <property name="halign">center</property>
+ <property name="valign">baseline</property>
+ <property name="label">scalable</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ <accessibility>
+ <relation type="label-for" target="image8"/>
+ </accessibility>
+ <layout>
+ <property name="left-attach">7</property>
+ <property name="top-attach">2</property>
+ </layout>
+ </object>
+ </child>
</object>
</child>
<child>