Commit 0f4e2168 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Allow to easily open brushes and patterns as images. Fixes bug #163059.

2005-01-13  Michael Natterer  <mitch@gimp.org>

	Allow to easily open brushes and patterns as images.
	Fixes bug #163059.

	* app/actions/brushes-actions.c
	* app/actions/patterns-actions.c: added "brushes-open-as-image"
	and "patterns-open-as-image" actions.

	* app/actions/data-commands.[ch]: added
	data_open_as_image_cmd_callback() which tries to load
	data->filename as image.

	* app/widgets/gimphelp-ids.h: added help IDs for the new actions.

	* app/widgets/gimpdatafactoryview.c: added buttons.

	* menus/brushes-menu.xml
	* menus/patterns-menu.xml: added them to the menus.
parent 4e942377
2005-01-13 Michael Natterer <mitch@gimp.org>
Allow to easily open brushes and patterns as images.
Fixes bug #163059.
* app/actions/brushes-actions.c
* app/actions/patterns-actions.c: added "brushes-open-as-image"
and "patterns-open-as-image" actions.
* app/actions/data-commands.[ch]: added
data_open_as_image_cmd_callback() which tries to load
data->filename as image.
* app/widgets/gimphelp-ids.h: added help IDs for the new actions.
* app/widgets/gimpdatafactoryview.c: added buttons.
* menus/brushes-menu.xml
* menus/patterns-menu.xml: added them to the menus.
2005-01-13 Michael Natterer <mitch@gimp.org>
Splitting GimpItem::convert() into two virtual functions was
......
......@@ -24,8 +24,8 @@
#include "actions-types.h"
#include "core/gimpbrushgenerated.h"
#include "core/gimpcontext.h"
#include "core/gimpdata.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
......@@ -43,6 +43,12 @@ static GimpActionEntry brushes_actions[] =
N_("Brushes Menu"), NULL, NULL, NULL,
GIMP_HELP_BRUSH_DIALOG },
{ "brushes-open-as-image", GTK_STOCK_OPEN,
N_("_Open Brush as Image"), "",
N_("Open brush as image"),
G_CALLBACK (data_open_as_image_cmd_callback),
GIMP_HELP_BRUSH_OPEN_AS_IMAGE },
{ "brushes-new", GTK_STOCK_NEW,
N_("_New Brush"), "",
N_("New brush"),
......@@ -110,9 +116,10 @@ brushes_actions_update (GimpActionGroup *group,
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
SET_SENSITIVE ("brushes-edit", brush);
SET_SENSITIVE ("brushes-duplicate", brush && GIMP_DATA_GET_CLASS (data)->duplicate);
SET_SENSITIVE ("brushes-delete", brush && data->deletable);
SET_SENSITIVE ("brushes-edit", brush);
SET_SENSITIVE ("brushes-open-as-image", brush && data->filename && ! GIMP_IS_BRUSH_GENERATED (brush));
SET_SENSITIVE ("brushes-duplicate", brush && GIMP_DATA_GET_CLASS (data)->duplicate);
SET_SENSITIVE ("brushes-delete", brush && data->deletable);
#undef SET_SENSITIVE
}
......@@ -29,6 +29,9 @@
#include "core/gimpdata.h"
#include "core/gimpdatafactory.h"
#include "file/file-open.h"
#include "file/file-utils.h"
#include "widgets/gimpcontainerview.h"
#include "widgets/gimpdataeditor.h"
#include "widgets/gimpdatafactoryview.h"
......@@ -62,6 +65,50 @@ static void data_delete_confirm_response (GtkWidget *dialog,
/* public functions */
void
data_open_as_image_cmd_callback (GtkAction *action,
gpointer user_data)
{
GimpDataFactoryView *view = GIMP_DATA_FACTORY_VIEW (user_data);
GimpContext *context;
GimpData *data;
context = gimp_container_view_get_context (GIMP_CONTAINER_EDITOR (view)->view);
data = (GimpData *)
gimp_context_get_by_type (context,
view->factory->container->children_type);
if (data && data->filename)
{
gchar *uri = g_filename_to_uri (data->filename, NULL, NULL);
if (uri)
{
GimpImage *image;
GimpPDBStatusType status;
GError *error = NULL;
image = file_open_with_display (context->gimp, context, NULL, uri,
&status, &error);
if (! image && status != GIMP_PDB_CANCEL)
{
gchar *filename;
filename = file_utils_uri_to_utf8_filename (uri);
g_message (_("Opening '%s' failed:\n\n%s"),
filename, error->message);
g_clear_error (&error);
g_free (filename);
}
g_free (uri);
}
}
}
void
data_new_data_cmd_callback (GtkAction *action,
gpointer user_data)
......
......@@ -20,6 +20,8 @@
#define __DATA_COMMANDS_H__
void data_open_as_image_cmd_callback (GtkAction *action,
gpointer data);
void data_new_data_cmd_callback (GtkAction *action,
gpointer data);
void data_duplicate_data_cmd_callback (GtkAction *action,
......
......@@ -43,6 +43,12 @@ static GimpActionEntry patterns_actions[] =
N_("Patterns Menu"), NULL, NULL, NULL,
GIMP_HELP_PATTERN_DIALOG },
{ "patterns-open-as-image", GTK_STOCK_OPEN,
N_("_Open Pattern as Image"), "",
N_("Open pattern as image"),
G_CALLBACK (data_open_as_image_cmd_callback),
GIMP_HELP_PATTERN_OPEN_AS_IMAGE },
{ "patterns-new", GTK_STOCK_NEW,
N_("_New Pattern"), "",
N_("New pattern"),
......@@ -110,9 +116,10 @@ patterns_actions_update (GimpActionGroup *group,
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
SET_SENSITIVE ("patterns-edit", pattern && FALSE);
SET_SENSITIVE ("patterns-duplicate", pattern && GIMP_DATA_GET_CLASS (data)->duplicate);
SET_SENSITIVE ("patterns-delete", pattern && data->deletable);
SET_SENSITIVE ("patterns-edit", pattern && FALSE);
SET_SENSITIVE ("patterns-open-as-image", pattern && data->filename);
SET_SENSITIVE ("patterns-duplicate", pattern && GIMP_DATA_GET_CLASS (data)->duplicate);
SET_SENSITIVE ("patterns-delete", pattern && data->deletable);
#undef SET_SENSITIVE
}
......@@ -205,6 +205,15 @@ gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
str, NULL);
g_free (str);
str = g_strdup_printf ("%s-open-as-image", action_group);
if (gimp_ui_manager_find_action (GIMP_EDITOR (editor->view)->ui_manager,
action_group, str))
{
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);
......
......@@ -273,25 +273,27 @@
#define GIMP_HELP_TOOLBOX_SWAP_COLORS "gimp-toolbox-swap-colors"
#define GIMP_HELP_BRUSH_DIALOG "gimp-brush-dialog"
#define GIMP_HELP_BRUSH_EDIT "gimp-brush-edit"
#define GIMP_HELP_BRUSH_OPEN_AS_IMAGE "gimp-brush-open-as-image"
#define GIMP_HELP_BRUSH_NEW "gimp-brush-new"
#define GIMP_HELP_BRUSH_DUPLICATE "gimp-brush-duplicate"
#define GIMP_HELP_BRUSH_EDIT "gimp-brush-edit"
#define GIMP_HELP_BRUSH_DELETE "gimp-brush-delete"
#define GIMP_HELP_BRUSH_REFRESH "gimp-brush-refresh"
#define GIMP_HELP_BRUSH_EDITOR_DIALOG "gimp-brush-editor-dialog"
#define GIMP_HELP_PATTERN_DIALOG "gimp-pattern-dialog"
#define GIMP_HELP_PATTERN_EDIT "gimp-pattern-edit"
#define GIMP_HELP_PATTERN_OPEN_AS_IMAGE "gimp-pattern-open-as-image"
#define GIMP_HELP_PATTERN_NEW "gimp-pattern-new"
#define GIMP_HELP_PATTERN_DUPLICATE "gimp-pattern-duplicate"
#define GIMP_HELP_PATTERN_EDIT "gimp-pattern-edit"
#define GIMP_HELP_PATTERN_DELETE "gimp-pattern-delete"
#define GIMP_HELP_PATTERN_REFRESH "gimp-pattern-refresh"
#define GIMP_HELP_GRADIENT_DIALOG "gimp-gradient-dialog"
#define GIMP_HELP_GRADIENT_EDIT "gimp-gradient-edit"
#define GIMP_HELP_GRADIENT_NEW "gimp-gradient-new"
#define GIMP_HELP_GRADIENT_DUPLICATE "gimp-gradient-duplicate"
#define GIMP_HELP_GRADIENT_EDIT "gimp-gradient-edit"
#define GIMP_HELP_GRADIENT_DELETE "gimp-gradient-delete"
#define GIMP_HELP_GRADIENT_REFRESH "gimp-gradient-refresh"
#define GIMP_HELP_GRADIENT_SAVE_AS_POV "gimp-gradient-save-as-pov"
......@@ -319,9 +321,9 @@
#define GIMP_HELP_GRADIENT_EDITOR_ZOOM_ALL "gimp-gradient-editor-zoom-all"
#define GIMP_HELP_PALETTE_DIALOG "gimp-palette-dialog"
#define GIMP_HELP_PALETTE_EDIT "gimp-palette-edit"
#define GIMP_HELP_PALETTE_NEW "gimp-palette-new"
#define GIMP_HELP_PALETTE_DUPLICATE "gimp-palette-duplicate"
#define GIMP_HELP_PALETTE_EDIT "gimp-palette-edit"
#define GIMP_HELP_PALETTE_DELETE "gimp-palette-delete"
#define GIMP_HELP_PALETTE_REFRESH "gimp-palette-refresh"
#define GIMP_HELP_PALETTE_IMPORT "gimp-palette-import"
......
......@@ -4,6 +4,7 @@
<ui>
<popup action="brushes-popup">
<menuitem action="brushes-edit" />
<menuitem action="brushes-open-as-image" />
<separator />
<menuitem action="brushes-new" />
<menuitem action="brushes-duplicate" />
......
......@@ -4,6 +4,8 @@
<ui>
<popup action="patterns-popup">
<menuitem action="patterns-open-as-image" />
<!-- disabled because they are useless now
<menuitem action="patterns-edit" />
<separator />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment