+static GtkWidget *
+editor_create_item_from_name (EggToolbarEditor *editor,
+ const char * name,
+ GdkDragAction drag_action)
+{
+ GtkWidget *item;
+ const char *item_name;
+ char *short_label;
+ const char *collate_key;
+
+ if (strcmp (name, "_separator") == 0)
+ {
+ GtkWidget *icon;
+
+ icon = _egg_editable_toolbar_new_separator_image ();
+ short_label = _("Separator");
+ item_name = g_strdup (name);
+ collate_key = g_utf8_collate_key (short_label, -1);
+ item = editor_create_item (editor, GTK_IMAGE (icon),
+ short_label, drag_action);
+ }
+ else
+ {
+ GtkAction *action;
+ GtkWidget *icon;
+ char *stock_id, *icon_name = NULL;
+
+ action = find_action (editor, name);
+ g_return_val_if_fail (action != NULL, NULL);
+
+ g_object_get (action,
+ "icon-name", &icon_name,
+ "stock-id", &stock_id,
+ "short-label", &short_label,
+ NULL);
+
+ /* This is a workaround to catch named icons. */
+ if (icon_name)
+ icon = gtk_image_new_from_icon_name (icon_name,
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
+ else
+ icon = gtk_image_new_from_stock (stock_id ? stock_id : GTK_STOCK_DND,
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
+
+ item_name = g_strdup (name);
+ collate_key = g_utf8_collate_key (short_label, -1);
+ item = editor_create_item (editor, GTK_IMAGE (icon),
+ short_label, drag_action);
+
+ g_free (short_label);
+ g_free (stock_id);
+ g_free (icon_name);
+ }
+
+ g_object_set_data_full (G_OBJECT (item), "egg-collate-key",
+ (gpointer) collate_key, g_free);
+ g_object_set_data_full (G_OBJECT (item), "egg-item-name",
+ (gpointer) item_name, g_free);
+
+ return item;
+}
+
+static gint
+append_table (GtkTable *table, GList *items, gint y, gint width)
+{
+ if (items != NULL)
+ {
+ gint x = 0, height;
+ GtkWidget *alignment;
+ GtkWidget *item;
+
+ height = g_list_length (items) / width + 1;
+ gtk_table_resize (table, height, width);
+
+ if (y > 0)
+ {
+ item = gtk_hseparator_new ();
+ alignment = gtk_alignment_new (0.5, 0.5, 1.0, 0.0);
+ gtk_container_add (GTK_CONTAINER (alignment), item);
+ gtk_widget_show (alignment);
+ gtk_widget_show (item);
+
+ gtk_table_attach_defaults (table, alignment, 0, width, y-1, y+1);
+ }
+
+ for (; items != NULL; items = items->next)
+ {
+ item = items->data;
+ alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ gtk_container_add (GTK_CONTAINER (alignment), item);
+ gtk_widget_show (alignment);
+ gtk_widget_show (item);
+
+ if (x >= width)
+ {
+ x = 0;
+ y++;
+ }
+ gtk_table_attach_defaults (table, alignment, x, x+1, y, y+1);
+ x++;
+ }
+
+ y++;
+ }
+ return y;
+}
+