gboolean gimp_data_factory_view_construct (GimpDataFactoryView *factory_view, GimpViewType view_type, GimpDataFactory *factory, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory, const gchar *menu_identifier, const gchar *ui_identifier, const gchar *action_group) { GimpContainerEditor *editor; gchar *str; g_return_val_if_fail (GIMP_IS_DATA_FACTORY_VIEW (factory_view), FALSE); g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), FALSE); g_return_val_if_fail (view_size > 0 && view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, FALSE); g_return_val_if_fail (view_border_width >= 0 && view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH, FALSE); factory_view->factory = factory; if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (factory_view), view_type, factory->container, context, view_size, view_border_width, menu_factory, menu_identifier, ui_identifier)) { return FALSE; } editor = GIMP_CONTAINER_EDITOR (factory_view); if (GIMP_IS_CONTAINER_TREE_VIEW (editor->view)) { GimpContainerTreeView *tree_view; tree_view = GIMP_CONTAINER_TREE_VIEW (editor->view); gimp_container_tree_view_connect_name_edited (tree_view, G_CALLBACK (gimp_data_factory_view_tree_name_edited), factory_view); } str = g_strdup_printf ("%s-edit", action_group); factory_view->edit_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group, str, NULL); g_free (str); if (factory_view->factory->data_new_func) { str = g_strdup_printf ("%s-new", action_group); factory_view->new_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group, str, NULL); g_free (str); } str = g_strdup_printf ("%s-duplicate", action_group); factory_view->duplicate_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group, str, NULL); g_free (str); str = g_strdup_printf ("%s-delete", action_group); factory_view->delete_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group, str, NULL); g_free (str); str = g_strdup_printf ("%s-refresh", action_group); factory_view->refresh_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), action_group, str, NULL); g_free (str); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (factory_view->edit_button), factory->container->children_type); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (factory_view->duplicate_button), factory->container->children_type); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (factory_view->delete_button), factory->container->children_type); gimp_ui_manager_update (GIMP_EDITOR (editor->view)->ui_manager, editor); return TRUE; }
GtkWidget * gimp_template_view_new (GimpViewType view_type, GimpContainer *container, GimpContext *context, gint view_size, gint view_border_width, GimpMenuFactory *menu_factory) { GimpTemplateView *template_view; GimpContainerEditor *editor; template_view = g_object_new (GIMP_TYPE_TEMPLATE_VIEW, NULL); if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (template_view), view_type, container, context, view_size, view_border_width, menu_factory, "<Templates>", "/templates-popup")) { g_object_unref (template_view); return NULL; } editor = GIMP_CONTAINER_EDITOR (template_view); if (GIMP_IS_CONTAINER_TREE_VIEW (editor->view)) { GimpContainerTreeView *tree_view; tree_view = GIMP_CONTAINER_TREE_VIEW (editor->view); gimp_container_tree_view_connect_name_edited (tree_view, G_CALLBACK (gimp_template_view_tree_name_edited), template_view); } template_view->create_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates", "templates-create-image", NULL); template_view->new_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates", "templates-new", NULL); template_view->duplicate_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates", "templates-duplicate", NULL); template_view->edit_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates", "templates-edit", NULL); template_view->delete_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "templates", "templates-delete", NULL); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (template_view->create_button), GIMP_TYPE_TEMPLATE); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (template_view->duplicate_button), GIMP_TYPE_TEMPLATE); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (template_view->edit_button), GIMP_TYPE_TEMPLATE); gimp_container_view_enable_dnd (editor->view, GTK_BUTTON (template_view->delete_button), GIMP_TYPE_TEMPLATE); gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view)), editor); return GTK_WIDGET (template_view); }