Support 'symbolic' themed icons
Add gtk_icon_info_load_symbolic() to load symbolic icons, and theme their background/foreground colours to match the colours used in the theme. Adds the gtk_icon_info_load_symbolic() function, explicit support in GtkImage and GtkCellRendererPixbuf, and test cases for those 2 widgets. With help from Bastien Nocera <hadess@hadess.net> https://bugzilla.gnome.org/show_bug.cgi?id=614711
This commit is contained in:
committed by
Bastien Nocera
parent
3cc9575323
commit
6b939d57c7
@ -317,6 +317,7 @@ do_images (GtkWidget *do_widget)
|
||||
GtkWidget *align;
|
||||
GtkWidget *button;
|
||||
GdkPixbuf *pixbuf;
|
||||
GIcon *gicon;
|
||||
GError *error = NULL;
|
||||
char *filename;
|
||||
|
||||
@ -415,6 +416,26 @@ do_images (GtkWidget *do_widget)
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), image);
|
||||
|
||||
/* Symbolic icon */
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (label),
|
||||
"<u>Symbolic themed icon</u>");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
/* The alignment keeps the frame from growing when users resize
|
||||
* the window
|
||||
*/
|
||||
align = gtk_alignment_new (0.5, 0.5, 0, 0);
|
||||
gtk_container_add (GTK_CONTAINER (align), frame);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
|
||||
|
||||
gicon = g_themed_icon_new_with_default_fallbacks ("battery-critical-charging-symbolic");
|
||||
image = gtk_image_new_from_gicon (gicon, GTK_ICON_SIZE_DIALOG);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), image);
|
||||
|
||||
/* Progressive */
|
||||
|
||||
|
||||
@ -29,7 +29,9 @@ enum
|
||||
COLUMN_SEVERITY,
|
||||
COLUMN_DESCRIPTION,
|
||||
COLUMN_PULSE,
|
||||
COLUMN_ICON,
|
||||
COLUMN_ACTIVE,
|
||||
COLUMN_SENSITIVE,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
@ -92,11 +94,24 @@ create_model (void)
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_UINT,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_BOOLEAN);
|
||||
|
||||
/* add data to the list store */
|
||||
for (i = 0; i < G_N_ELEMENTS (data); i++)
|
||||
{
|
||||
gchar *icon_name;
|
||||
gboolean sensitive;
|
||||
|
||||
if (i == 1 || i == 3)
|
||||
icon_name = "battery-critical-charging-symbolic";
|
||||
else
|
||||
icon_name = NULL;
|
||||
if (i == 3)
|
||||
sensitive = FALSE;
|
||||
else
|
||||
sensitive = TRUE;
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
COLUMN_FIXED, data[i].fixed,
|
||||
@ -104,7 +119,9 @@ create_model (void)
|
||||
COLUMN_SEVERITY, data[i].severity,
|
||||
COLUMN_DESCRIPTION, data[i].description,
|
||||
COLUMN_PULSE, 0,
|
||||
COLUMN_ICON, icon_name,
|
||||
COLUMN_ACTIVE, FALSE,
|
||||
COLUMN_SENSITIVE, sensitive,
|
||||
-1);
|
||||
}
|
||||
|
||||
@ -199,6 +216,19 @@ add_columns (GtkTreeView *treeview)
|
||||
NULL);
|
||||
gtk_tree_view_column_set_sort_column_id (column, COLUMN_PULSE);
|
||||
gtk_tree_view_append_column (treeview, column);
|
||||
|
||||
/* column for symbolic icon */
|
||||
renderer = gtk_cell_renderer_pixbuf_new ();
|
||||
g_object_set (G_OBJECT (renderer), "follow-state", TRUE, NULL);
|
||||
column = gtk_tree_view_column_new_with_attributes ("Symbolic icon",
|
||||
renderer,
|
||||
"icon-name",
|
||||
COLUMN_ICON,
|
||||
"sensitive",
|
||||
COLUMN_SENSITIVE,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_sort_column_id (column, COLUMN_ICON);
|
||||
gtk_tree_view_append_column (treeview, column);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
Reference in New Issue
Block a user