invalidate the preview when the stock_id changes.

2003-04-13  Michael Natterer  <mitch@gimp.org>

	* app/core/gimptemplate.c (gimp_template_notify): invalidate
	the preview when the stock_id changes.

	* app/widgets/gimptemplateeditor.[ch]: added an optional entry
	to edit the template's name.

	* app/widgets/gimptemplateview.[ch]: added a "duplicate" button and
	function pointers for creating templates, editing templates and
	creating images from templates.

	* app/gui/file-new-dialog.[ch] (file_new_dialog_create): added an
	optional template parameter.

	* app/gui/file-commands.c: pass template == NULL.

	* app/gui/templates-menu.c: added a "Duplicate Template" menu entry.

	* app/gui/templates-commands.[ch]: added the callback for the
	duplicate menu item. Added "New Template" and "Edit Template"
	dialogs. Added a function which opens a file_new_dialog with
	a template preselected.

	* app/gui/dialogs-constructors.c: let GimpTemplateView know
	about the functions.
This commit is contained in:
Michael Natterer
2003-04-13 16:25:14 +00:00
committed by Michael Natterer
parent c16bc592a0
commit 6663cee5f3
19 changed files with 565 additions and 94 deletions

View File

@ -1,3 +1,30 @@
2003-04-13 Michael Natterer <mitch@gimp.org>
* app/core/gimptemplate.c (gimp_template_notify): invalidate
the preview when the stock_id changes.
* app/widgets/gimptemplateeditor.[ch]: added an optional entry
to edit the template's name.
* app/widgets/gimptemplateview.[ch]: added a "duplicate" button and
function pointers for creating templates, editing templates and
creating images from templates.
* app/gui/file-new-dialog.[ch] (file_new_dialog_create): added an
optional template parameter.
* app/gui/file-commands.c: pass template == NULL.
* app/gui/templates-menu.c: added a "Duplicate Template" menu entry.
* app/gui/templates-commands.[ch]: added the callback for the
duplicate menu item. Added "New Template" and "Edit Template"
dialogs. Added a function which opens a file_new_dialog with
a template preselected.
* app/gui/dialogs-constructors.c: let GimpTemplateView know
about the functions.
2003-04-13 Sven Neumann <sven@gimp.org>
* app/paint/gimppaintoptions.c: changed the "fade-length" and

View File

@ -105,7 +105,7 @@ file_new_cmd_callback (GtkWidget *widget,
else
gimage = NULL;
file_new_dialog_create (gimp, gimage);
file_new_dialog_create (gimp, gimage, NULL);
}
void

View File

@ -24,10 +24,22 @@
#include "gui-types.h"
#include "widgets/gimptemplateview.h"
#include "config/gimpconfig-utils.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"
#include "core/gimptemplate.h"
#include "widgets/gimptemplateeditor.h"
#include "widgets/gimptemplateview.h"
#include "widgets/gimpviewabledialog.h"
#include "file-new-dialog.h"
#include "templates-commands.h"
#include "gimp-intl.h"
/* public functions */
@ -35,9 +47,7 @@ void
templates_new_template_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpTemplateView *view;
view = GIMP_TEMPLATE_VIEW (data);
GimpTemplateView *view = GIMP_TEMPLATE_VIEW (data);
gtk_button_clicked (GTK_BUTTON (view->new_button));
}
@ -46,20 +56,25 @@ void
templates_duplicate_template_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpTemplateView *view;
view = GIMP_TEMPLATE_VIEW (data);
GimpTemplateView *view = GIMP_TEMPLATE_VIEW (data);
gtk_button_clicked (GTK_BUTTON (view->duplicate_button));
}
void
templates_edit_template_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpTemplateView *view = GIMP_TEMPLATE_VIEW (data);
gtk_button_clicked (GTK_BUTTON (view->edit_button));
}
void
templates_create_image_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpTemplateView *view;
view = GIMP_TEMPLATE_VIEW (data);
GimpTemplateView *view = GIMP_TEMPLATE_VIEW (data);
gtk_button_clicked (GTK_BUTTON (view->create_button));
}
@ -68,9 +83,157 @@ void
templates_delete_template_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpTemplateView *view;
view = GIMP_TEMPLATE_VIEW (data);
GimpTemplateView *view = GIMP_TEMPLATE_VIEW (data);
gtk_button_clicked (GTK_BUTTON (view->delete_button));
}
static void
templates_new_template_ok_callback (GtkWidget *widget,
GtkWidget *dialog)
{
GimpTemplateEditor *editor;
GimpTemplate *template;
Gimp *gimp;
editor = g_object_get_data (G_OBJECT (dialog), "gimp-template-editor");
template = g_object_get_data (G_OBJECT (dialog), "gimp-template");
gimp = g_object_get_data (G_OBJECT (dialog), "gimp");
gimp_config_copy_properties (G_OBJECT (editor->template),
G_OBJECT (template));
gimp_list_uniquefy_name (GIMP_LIST (gimp->templates),
GIMP_OBJECT (template), TRUE);
gimp_container_add (gimp->templates, GIMP_OBJECT (template));
gimp_context_set_template (gimp_get_user_context (gimp), template);
gtk_widget_destroy (dialog);
}
void
templates_new_template_dialog (Gimp *gimp,
GimpTemplate *template_template)
{
GimpTemplate *template;
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *editor;
template = gimp_template_new (_("Unnamed"));
gimp_template_set_from_config (template, gimp->config);
dialog =
gimp_viewable_dialog_new (NULL,
_("New Template"), "new_template",
GIMP_STOCK_TEMPLATE,
_("Create a New Template"),
gimp_standard_help_func,
"dialogs/new_template.html",
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, (gpointer) 1, NULL, FALSE, TRUE,
GTK_STOCK_OK,
G_CALLBACK (templates_new_template_ok_callback),
NULL, NULL, NULL, TRUE, FALSE,
NULL);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
main_vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_vbox,
TRUE, TRUE, 0);
gtk_widget_show (main_vbox);
editor = gimp_template_editor_new (gimp, TRUE);
gtk_box_pack_start (GTK_BOX (main_vbox), editor, FALSE, FALSE, 0);
gtk_widget_show (editor);
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (editor),
template);
g_object_set_data (G_OBJECT (dialog), "gimp-template-editor", editor);
g_object_set_data (G_OBJECT (dialog), "gimp", gimp);
g_object_set_data_full (G_OBJECT (dialog), "gimp-template", template,
(GDestroyNotify) g_object_unref);
gtk_widget_show (dialog);
}
static void
templates_edit_template_ok_callback (GtkWidget *widget,
GtkWidget *dialog)
{
GimpTemplateEditor *editor;
GimpTemplate *template;
Gimp *gimp;
editor = g_object_get_data (G_OBJECT (dialog), "gimp-template-editor");
template = g_object_get_data (G_OBJECT (dialog), "gimp-template");
gimp = g_object_get_data (G_OBJECT (dialog), "gimp");
gimp_config_copy_properties (G_OBJECT (editor->template),
G_OBJECT (template));
gimp_list_uniquefy_name (GIMP_LIST (gimp->templates),
GIMP_OBJECT (template), TRUE);
gtk_widget_destroy (dialog);
}
void
templates_edit_template_dialog (Gimp *gimp,
GimpTemplate *template)
{
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *editor;
dialog =
gimp_viewable_dialog_new (GIMP_VIEWABLE (template),
_("Edit Template"), "edit_template",
GIMP_STOCK_EDIT,
_("Edit Template"),
gimp_standard_help_func,
"dialogs/edit_template.html",
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, (gpointer) 1, NULL, FALSE, TRUE,
GTK_STOCK_OK,
G_CALLBACK (templates_edit_template_ok_callback),
NULL, NULL, NULL, TRUE, FALSE,
NULL);
main_vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_vbox,
TRUE, TRUE, 0);
gtk_widget_show (main_vbox);
editor = gimp_template_editor_new (gimp, TRUE);
gtk_box_pack_start (GTK_BOX (main_vbox), editor, FALSE, FALSE, 0);
gtk_widget_show (editor);
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (editor),
template);
g_object_set_data (G_OBJECT (dialog), "gimp-template-editor", editor);
g_object_set_data (G_OBJECT (dialog), "gimp-template", template);
g_object_set_data (G_OBJECT (dialog), "gimp", gimp);
gtk_widget_show (dialog);
}
void
templates_file_new_dialog (Gimp *gimp,
GimpTemplate *template)
{
file_new_dialog_create (gimp, NULL, template);
}

View File

@ -20,14 +20,22 @@
#define __TEMPLATES_COMMANDS_H__
void templates_new_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_duplicate_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_create_image_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_delete_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_new_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_duplicate_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_edit_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_create_image_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_delete_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_new_template_dialog (Gimp *gimp,
GimpTemplate *template);
void templates_edit_template_dialog (Gimp *gimp,
GimpTemplate *template);
void templates_file_new_dialog (Gimp *gimp,
GimpTemplate *template);
#endif /* __TEMPLATES_COMMANDS_H__ */

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
@ -336,6 +338,9 @@ gimp_template_notify (GObject *object,
template->initial_size = (gulong) size;
template->initial_size_too_large = FALSE;
}
if (! strcmp (pspec->name, "stock-id"))
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (object));
}
static gboolean

View File

@ -84,6 +84,7 @@
#include "module-browser.h"
#include "paths-dialog.h"
#include "preferences-dialog.h"
#include "templates-commands.h"
#include "tips-dialog.h"
#include "tool-options-dialog.h"
#include "vectors-commands.h"
@ -896,7 +897,8 @@ dialogs_template_list_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
GtkWidget *view;
GimpTemplateView *template_view;
view = gimp_template_view_new (GIMP_VIEW_TYPE_LIST,
context->gimp->templates,
@ -904,6 +906,12 @@ dialogs_template_list_new (GimpDialogFactory *factory,
preview_size, 0,
factory->menu_factory);
template_view = GIMP_TEMPLATE_VIEW (view);
template_view->new_template_func = templates_new_template_dialog;
template_view->edit_template_func = templates_edit_template_dialog;
template_view->create_image_func = templates_file_new_dialog;
return dialogs_dockable_new (view,
_("List of Templates"), _("Templates"),
GIMP_STOCK_TEMPLATE,

View File

@ -77,17 +77,18 @@ static void file_new_create_image (FileNewDialog *dialog);
/* public functions */
void
file_new_dialog_create (Gimp *gimp,
GimpImage *gimage)
file_new_dialog_create (Gimp *gimp,
GimpImage *gimage,
GimpTemplate *template)
{
FileNewDialog *dialog;
GimpTemplate *template;
GtkWidget *main_vbox;
GtkWidget *table;
GtkWidget *optionmenu;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage));
g_return_if_fail (template == NULL || GIMP_IS_TEMPLATE (template));
dialog = g_new0 (FileNewDialog, 1);
@ -145,7 +146,7 @@ file_new_dialog_create (Gimp *gimp,
dialog);
/* Template editor */
dialog->editor = gimp_template_editor_new (gimp, TRUE);
dialog->editor = gimp_template_editor_new (gimp, FALSE);
gtk_box_pack_start (GTK_BOX (main_vbox), dialog->editor, FALSE, FALSE, 0);
gtk_widget_show (dialog->editor);
@ -153,10 +154,18 @@ file_new_dialog_create (Gimp *gimp,
G_CALLBACK (file_new_template_notify),
dialog);
template = gimp_image_new_get_last_template (gimp, gimage);
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (dialog->editor),
template);
g_object_unref (template);
if (template)
{
gimp_container_menu_select_item (GIMP_CONTAINER_MENU (dialog->template_menu),
GIMP_VIEWABLE (template));
}
else
{
template = gimp_image_new_get_last_template (gimp, gimage);
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (dialog->editor),
template);
g_object_unref (template);
}
gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (GIMP_TEMPLATE_EDITOR (dialog->editor)->size_se));

View File

@ -20,8 +20,9 @@
#define __FILE_NEW_DIALOG_H__
void file_new_dialog_create (Gimp *gimp,
GimpImage *gimage);
void file_new_dialog_create (Gimp *gimp,
GimpImage *gimage,
GimpTemplate *template);
#endif /* __FILE_NEW_DIALOG_H__ */

View File

@ -84,6 +84,7 @@
#include "module-browser.h"
#include "paths-dialog.h"
#include "preferences-dialog.h"
#include "templates-commands.h"
#include "tips-dialog.h"
#include "tool-options-dialog.h"
#include "vectors-commands.h"
@ -896,7 +897,8 @@ dialogs_template_list_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
GtkWidget *view;
GimpTemplateView *template_view;
view = gimp_template_view_new (GIMP_VIEW_TYPE_LIST,
context->gimp->templates,
@ -904,6 +906,12 @@ dialogs_template_list_new (GimpDialogFactory *factory,
preview_size, 0,
factory->menu_factory);
template_view = GIMP_TEMPLATE_VIEW (view);
template_view->new_template_func = templates_new_template_dialog;
template_view->edit_template_func = templates_edit_template_dialog;
template_view->create_image_func = templates_file_new_dialog;
return dialogs_dockable_new (view,
_("List of Templates"), _("Templates"),
GIMP_STOCK_TEMPLATE,

View File

@ -105,7 +105,7 @@ file_new_cmd_callback (GtkWidget *widget,
else
gimage = NULL;
file_new_dialog_create (gimp, gimage);
file_new_dialog_create (gimp, gimage, NULL);
}
void

View File

@ -77,17 +77,18 @@ static void file_new_create_image (FileNewDialog *dialog);
/* public functions */
void
file_new_dialog_create (Gimp *gimp,
GimpImage *gimage)
file_new_dialog_create (Gimp *gimp,
GimpImage *gimage,
GimpTemplate *template)
{
FileNewDialog *dialog;
GimpTemplate *template;
GtkWidget *main_vbox;
GtkWidget *table;
GtkWidget *optionmenu;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage));
g_return_if_fail (template == NULL || GIMP_IS_TEMPLATE (template));
dialog = g_new0 (FileNewDialog, 1);
@ -145,7 +146,7 @@ file_new_dialog_create (Gimp *gimp,
dialog);
/* Template editor */
dialog->editor = gimp_template_editor_new (gimp, TRUE);
dialog->editor = gimp_template_editor_new (gimp, FALSE);
gtk_box_pack_start (GTK_BOX (main_vbox), dialog->editor, FALSE, FALSE, 0);
gtk_widget_show (dialog->editor);
@ -153,10 +154,18 @@ file_new_dialog_create (Gimp *gimp,
G_CALLBACK (file_new_template_notify),
dialog);
template = gimp_image_new_get_last_template (gimp, gimage);
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (dialog->editor),
template);
g_object_unref (template);
if (template)
{
gimp_container_menu_select_item (GIMP_CONTAINER_MENU (dialog->template_menu),
GIMP_VIEWABLE (template));
}
else
{
template = gimp_image_new_get_last_template (gimp, gimage);
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (dialog->editor),
template);
g_object_unref (template);
}
gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (GIMP_TEMPLATE_EDITOR (dialog->editor)->size_se));

View File

@ -20,8 +20,9 @@
#define __FILE_NEW_DIALOG_H__
void file_new_dialog_create (Gimp *gimp,
GimpImage *gimage);
void file_new_dialog_create (Gimp *gimp,
GimpImage *gimage,
GimpTemplate *template);
#endif /* __FILE_NEW_DIALOG_H__ */

View File

@ -24,10 +24,22 @@
#include "gui-types.h"
#include "widgets/gimptemplateview.h"
#include "config/gimpconfig-utils.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"
#include "core/gimptemplate.h"
#include "widgets/gimptemplateeditor.h"
#include "widgets/gimptemplateview.h"
#include "widgets/gimpviewabledialog.h"
#include "file-new-dialog.h"
#include "templates-commands.h"
#include "gimp-intl.h"
/* public functions */
@ -35,9 +47,7 @@ void
templates_new_template_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpTemplateView *view;
view = GIMP_TEMPLATE_VIEW (data);
GimpTemplateView *view = GIMP_TEMPLATE_VIEW (data);
gtk_button_clicked (GTK_BUTTON (view->new_button));
}
@ -46,20 +56,25 @@ void
templates_duplicate_template_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpTemplateView *view;
view = GIMP_TEMPLATE_VIEW (data);
GimpTemplateView *view = GIMP_TEMPLATE_VIEW (data);
gtk_button_clicked (GTK_BUTTON (view->duplicate_button));
}
void
templates_edit_template_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpTemplateView *view = GIMP_TEMPLATE_VIEW (data);
gtk_button_clicked (GTK_BUTTON (view->edit_button));
}
void
templates_create_image_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpTemplateView *view;
view = GIMP_TEMPLATE_VIEW (data);
GimpTemplateView *view = GIMP_TEMPLATE_VIEW (data);
gtk_button_clicked (GTK_BUTTON (view->create_button));
}
@ -68,9 +83,157 @@ void
templates_delete_template_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpTemplateView *view;
view = GIMP_TEMPLATE_VIEW (data);
GimpTemplateView *view = GIMP_TEMPLATE_VIEW (data);
gtk_button_clicked (GTK_BUTTON (view->delete_button));
}
static void
templates_new_template_ok_callback (GtkWidget *widget,
GtkWidget *dialog)
{
GimpTemplateEditor *editor;
GimpTemplate *template;
Gimp *gimp;
editor = g_object_get_data (G_OBJECT (dialog), "gimp-template-editor");
template = g_object_get_data (G_OBJECT (dialog), "gimp-template");
gimp = g_object_get_data (G_OBJECT (dialog), "gimp");
gimp_config_copy_properties (G_OBJECT (editor->template),
G_OBJECT (template));
gimp_list_uniquefy_name (GIMP_LIST (gimp->templates),
GIMP_OBJECT (template), TRUE);
gimp_container_add (gimp->templates, GIMP_OBJECT (template));
gimp_context_set_template (gimp_get_user_context (gimp), template);
gtk_widget_destroy (dialog);
}
void
templates_new_template_dialog (Gimp *gimp,
GimpTemplate *template_template)
{
GimpTemplate *template;
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *editor;
template = gimp_template_new (_("Unnamed"));
gimp_template_set_from_config (template, gimp->config);
dialog =
gimp_viewable_dialog_new (NULL,
_("New Template"), "new_template",
GIMP_STOCK_TEMPLATE,
_("Create a New Template"),
gimp_standard_help_func,
"dialogs/new_template.html",
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, (gpointer) 1, NULL, FALSE, TRUE,
GTK_STOCK_OK,
G_CALLBACK (templates_new_template_ok_callback),
NULL, NULL, NULL, TRUE, FALSE,
NULL);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
main_vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_vbox,
TRUE, TRUE, 0);
gtk_widget_show (main_vbox);
editor = gimp_template_editor_new (gimp, TRUE);
gtk_box_pack_start (GTK_BOX (main_vbox), editor, FALSE, FALSE, 0);
gtk_widget_show (editor);
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (editor),
template);
g_object_set_data (G_OBJECT (dialog), "gimp-template-editor", editor);
g_object_set_data (G_OBJECT (dialog), "gimp", gimp);
g_object_set_data_full (G_OBJECT (dialog), "gimp-template", template,
(GDestroyNotify) g_object_unref);
gtk_widget_show (dialog);
}
static void
templates_edit_template_ok_callback (GtkWidget *widget,
GtkWidget *dialog)
{
GimpTemplateEditor *editor;
GimpTemplate *template;
Gimp *gimp;
editor = g_object_get_data (G_OBJECT (dialog), "gimp-template-editor");
template = g_object_get_data (G_OBJECT (dialog), "gimp-template");
gimp = g_object_get_data (G_OBJECT (dialog), "gimp");
gimp_config_copy_properties (G_OBJECT (editor->template),
G_OBJECT (template));
gimp_list_uniquefy_name (GIMP_LIST (gimp->templates),
GIMP_OBJECT (template), TRUE);
gtk_widget_destroy (dialog);
}
void
templates_edit_template_dialog (Gimp *gimp,
GimpTemplate *template)
{
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *editor;
dialog =
gimp_viewable_dialog_new (GIMP_VIEWABLE (template),
_("Edit Template"), "edit_template",
GIMP_STOCK_EDIT,
_("Edit Template"),
gimp_standard_help_func,
"dialogs/edit_template.html",
GTK_STOCK_CANCEL, gtk_widget_destroy,
NULL, (gpointer) 1, NULL, FALSE, TRUE,
GTK_STOCK_OK,
G_CALLBACK (templates_edit_template_ok_callback),
NULL, NULL, NULL, TRUE, FALSE,
NULL);
main_vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_vbox,
TRUE, TRUE, 0);
gtk_widget_show (main_vbox);
editor = gimp_template_editor_new (gimp, TRUE);
gtk_box_pack_start (GTK_BOX (main_vbox), editor, FALSE, FALSE, 0);
gtk_widget_show (editor);
gimp_template_editor_set_template (GIMP_TEMPLATE_EDITOR (editor),
template);
g_object_set_data (G_OBJECT (dialog), "gimp-template-editor", editor);
g_object_set_data (G_OBJECT (dialog), "gimp-template", template);
g_object_set_data (G_OBJECT (dialog), "gimp", gimp);
gtk_widget_show (dialog);
}
void
templates_file_new_dialog (Gimp *gimp,
GimpTemplate *template)
{
file_new_dialog_create (gimp, NULL, template);
}

View File

@ -20,14 +20,22 @@
#define __TEMPLATES_COMMANDS_H__
void templates_new_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_duplicate_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_create_image_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_delete_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_new_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_duplicate_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_edit_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_create_image_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_delete_template_cmd_callback (GtkWidget *widget,
gpointer data);
void templates_new_template_dialog (Gimp *gimp,
GimpTemplate *template);
void templates_edit_template_dialog (Gimp *gimp,
GimpTemplate *template);
void templates_file_new_dialog (Gimp *gimp,
GimpTemplate *template);
#endif /* __TEMPLATES_COMMANDS_H__ */

View File

@ -39,15 +39,19 @@
GimpItemFactoryEntry templates_menu_entries[] =
{
{ { N_("/New Template"), "",
{ { N_("/New Template..."), "",
templates_new_template_cmd_callback, 0,
"<StockItem>", GTK_STOCK_NEW },
NULL, NULL, NULL },
{ { N_("/Duplicate Template"), "",
{ { N_("/Duplicate Template..."), "",
templates_duplicate_template_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_DUPLICATE },
NULL, NULL, NULL },
{ { N_("/Create Image from Template"), "",
{ { N_("/Edit Template..."), "",
templates_edit_template_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_EDIT },
NULL, NULL, NULL },
{ { N_("/Create Image from Template..."), "",
templates_create_image_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_IMAGE },
NULL, NULL, NULL },
@ -74,10 +78,11 @@ templates_menu_update (GtkItemFactory *factory,
#define SET_SENSITIVE(menu,condition) \
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("/New Template", TRUE);
SET_SENSITIVE ("/Duplicate Template", template);
SET_SENSITIVE ("/Create Image from Template", template);
SET_SENSITIVE ("/Delete Template...", template);
SET_SENSITIVE ("/New Template...", TRUE);
SET_SENSITIVE ("/Duplicate Template...", template);
SET_SENSITIVE ("/Edit Template...", template);
SET_SENSITIVE ("/Create Image from Template...", template);
SET_SENSITIVE ("/Delete Template...", template);
#undef SET_SENSITIVE
}

View File

@ -372,7 +372,7 @@ gimp_template_editor_finalize (GObject *object)
GtkWidget *
gimp_template_editor_new (Gimp *gimp,
gboolean edit_stock_id)
gboolean edit_template)
{
GimpTemplateEditor *editor;
@ -380,9 +380,10 @@ gimp_template_editor_new (Gimp *gimp,
editor = g_object_new (GIMP_TYPE_TEMPLATE_EDITOR, NULL);
if (edit_stock_id)
if (edit_template)
{
GtkWidget *table;
GtkWidget *entry;
GtkWidget *button;
GSList *stock_list;
GSList *list;
@ -411,18 +412,25 @@ gimp_template_editor_new (Gimp *gimp,
g_slist_foreach (stock_list, (GFunc) g_free, NULL);
g_slist_free (stock_list);
table = gtk_table_new (1, 2, FALSE);
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (editor), table, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (editor), table, 0);
gtk_widget_show (table);
entry = gimp_prop_entry_new (G_OBJECT (editor->template), "name", 128);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("_Name:"), 1.0, 0.5,
entry, 1, FALSE);
button = gimp_viewable_button_new (editor->stock_id_container,
editor->stock_id_context,
GIMP_PREVIEW_SIZE_SMALL, 0,
NULL, NULL, NULL, NULL);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
_("_Icon:"), 1.0, 0.5,
button, 1, TRUE);
}
@ -585,4 +593,3 @@ gimp_template_editor_icon_changed (GimpContext *context,
"stock-id", GIMP_OBJECT (template)->name,
NULL);
}

View File

@ -63,7 +63,7 @@ struct _GimpTemplateEditorClass
GType gimp_template_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_template_editor_new (Gimp *gimp,
gboolean edit_stock_id);
gboolean edit_template);
void gimp_template_editor_set_template (GimpTemplateEditor *editor,
GimpTemplate *template);

View File

@ -53,6 +53,8 @@ static void gimp_template_view_new_clicked (GtkWidget *widget,
GimpTemplateView *view);
static void gimp_template_view_duplicate_clicked (GtkWidget *widget,
GimpTemplateView *view);
static void gimp_template_view_edit_clicked (GtkWidget *widget,
GimpTemplateView *view);
static void gimp_template_view_create_clicked (GtkWidget *widget,
GimpTemplateView *view);
static void gimp_template_view_delete_clicked (GtkWidget *widget,
@ -180,6 +182,14 @@ gimp_template_view_new (GimpViewType view_type,
NULL,
editor);
template_view->edit_button =
gimp_editor_add_button (GIMP_EDITOR (editor->view),
GIMP_STOCK_EDIT,
_("Edit the selected template"), NULL,
G_CALLBACK (gimp_template_view_edit_clicked),
NULL,
editor);
template_view->create_button =
gimp_editor_add_button (GIMP_EDITOR (editor->view),
GIMP_STOCK_IMAGE,
@ -205,6 +215,9 @@ gimp_template_view_new (GimpViewType view_type,
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->create_button),
GIMP_TYPE_TEMPLATE);
@ -230,6 +243,9 @@ gimp_template_view_new_clicked (GtkWidget *widget,
GIMP_OBJECT (template)))
{
}
if (view->new_template_func)
view->new_template_func (editor->view->context->gimp, NULL);
}
static void
@ -258,10 +274,32 @@ gimp_template_view_duplicate_clicked (GtkWidget *widget,
editor->view->container->children_type,
GIMP_OBJECT (new_template));
if (view->edit_template_func)
view->edit_template_func (editor->view->context->gimp, new_template);
g_object_unref (new_template);
}
}
static void
gimp_template_view_edit_clicked (GtkWidget *widget,
GimpTemplateView *view)
{
GimpContainerEditor *editor;
GimpTemplate *template;
editor = GIMP_CONTAINER_EDITOR (view);
template = gimp_context_get_template (editor->view->context);
if (template && gimp_container_have (editor->view->container,
GIMP_OBJECT (template)))
{
if (view->edit_template_func)
view->edit_template_func (editor->view->context->gimp, template);
}
}
static void
gimp_template_view_create_clicked (GtkWidget *widget,
GimpTemplateView *view)
@ -276,7 +314,8 @@ gimp_template_view_create_clicked (GtkWidget *widget,
if (template && gimp_container_have (editor->view->container,
GIMP_OBJECT (template)))
{
gimp_template_create_image (editor->view->context->gimp, template);
if (view->create_image_func)
view->create_image_func (editor->view->context->gimp, template);
}
}
@ -313,7 +352,7 @@ gimp_template_view_delete_clicked (GtkWidget *widget,
GimpTemplateView *view)
{
GimpContainerEditor *editor;
GimpTemplate *template;
GimpTemplate *template;
editor = GIMP_CONTAINER_EDITOR (view);
@ -358,8 +397,7 @@ gimp_template_view_select_item (GimpContainerEditor *editor,
GimpViewable *viewable)
{
GimpTemplateView *view;
gboolean create_sensitive = FALSE;
gboolean delete_sensitive = FALSE;
gboolean sensitive = FALSE;
if (GIMP_CONTAINER_EDITOR_CLASS (parent_class)->select_item)
GIMP_CONTAINER_EDITOR_CLASS (parent_class)->select_item (editor, viewable);
@ -369,12 +407,13 @@ gimp_template_view_select_item (GimpContainerEditor *editor,
if (viewable && gimp_container_have (editor->view->container,
GIMP_OBJECT (viewable)))
{
create_sensitive = TRUE;
delete_sensitive = TRUE;
sensitive = TRUE;
}
gtk_widget_set_sensitive (view->create_button, create_sensitive);
gtk_widget_set_sensitive (view->delete_button, delete_sensitive);
gtk_widget_set_sensitive (view->duplicate_button, sensitive);
gtk_widget_set_sensitive (view->edit_button, sensitive);
gtk_widget_set_sensitive (view->create_button, sensitive);
gtk_widget_set_sensitive (view->delete_button, sensitive);
}
static void
@ -391,8 +430,9 @@ gimp_template_view_activate_item (GimpContainerEditor *editor,
if (viewable && gimp_container_have (editor->view->container,
GIMP_OBJECT (viewable)))
{
gimp_template_create_image (editor->view->context->gimp,
GIMP_TEMPLATE (viewable));
if (view->create_image_func)
view->create_image_func (editor->view->context->gimp,
GIMP_TEMPLATE (viewable));
}
}

View File

@ -26,6 +26,10 @@
#include "gimpcontainereditor.h"
typedef void (* GimpTemplateActionFunc) (Gimp *gimp,
GimpTemplate *template);
#define GIMP_TYPE_TEMPLATE_VIEW (gimp_template_view_get_type ())
#define GIMP_TEMPLATE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TEMPLATE_VIEW, GimpTemplateView))
#define GIMP_TEMPLATE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TEMPLATE_VIEW, GimpTemplateViewClass))
@ -38,12 +42,17 @@ typedef struct _GimpTemplateViewClass GimpTemplateViewClass;
struct _GimpTemplateView
{
GimpContainerEditor parent_instance;
GimpContainerEditor parent_instance;
GtkWidget *new_button;
GtkWidget *duplicate_button;
GtkWidget *create_button;
GtkWidget *delete_button;
GimpTemplateActionFunc new_template_func;
GimpTemplateActionFunc edit_template_func;
GimpTemplateActionFunc create_image_func;
GtkWidget *new_button;
GtkWidget *duplicate_button;
GtkWidget *edit_button;
GtkWidget *create_button;
GtkWidget *delete_button;
};
struct _GimpTemplateViewClass