0
votes

In GTK 3, how do we add a theme's icon to a tree view's column? In my following snippets, I'm trying to add a Gnome delete icon to the third column in a tree view.

I set up the third tree-view column as follows:

GtkCellRenderer *rendererDelete;
GtkTreeViewColumn *columnDelete;
rendererDelete = gtk_cell_renderer_pixbuf_new();
columnDelete = gtk_tree_view_column_new_with_attributes("Delete",
    rendererDelete,
    "gicon",
    DELETE_ICON,
    NULL);

I attempt to retrieve the Gnome "delete" icon as follows:

GdkPixbuf * delete_icon =  gtk_icon_theme_load_icon(
    gtk_icon_theme_get_default(),
    "edit-delete", /* This parameter is obviously incorrect; what is the correct value? */
    GTK_ICON_SIZE_BUTTON,
    GTK_ICON_LOOKUP_USE_BUILTIN,
    NULL);

I then append the entire record to the list store.

gtk_list_store_set(list_store, &iter,
    ACCOUNT_NUMBER, local_account->number,
    DESCRIPTION, local_account->description,
    DELETE_ICON, delete_icon,
    FALSE,
    -1);
1

1 Answers

0
votes

The character string edit-delete was correct. The possible character strings are the file names in /usr/share/icons/gnome/16x16/actions. For example, to use the icon for gtk-underline.png, use the character string gtk-underline.

My error was not instantiating the GtkListStore correctly.

GtkListStore *list_store = gtk_list_store_new(
  N_COLUMNS,
  G_TYPE_STRING,
  G_TYPE_STRING,
  GDK_TYPE_PIXBUF);

In the last position I mistakenly used an incorrect data type.