mirror of https://github.com/GNOME/gimp.git
app/widgets/Makefile.am app/widgets/widgets-types.h new GtkAction subclass
2004-05-19 Michael Natterer <mitch@gimp.org> * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpaction.[ch]: new GtkAction subclass which can show either a color or viewable preview in GtkImageMenuItem proxies. * app/widgets/gimpenumaction.[ch] * app/widgets/gimppluginaction.[ch] * app/widgets/gimpstringaction.[ch]: derive them from GimpAction. * app/widgets/gimpactiongroup.c (gimp_action_group_add_actions): add GimpActions, not GtkActions. (gimp_action_group_set_action_color) (gimp_action_group_set_action_viewable): removed all hacks and simply set the "color" or "viewable" properties of the GimpAction to change. Fixes color/viewable previews in menus. * app/actions/file-actions.c: show previews in the "Open Recent" menu items. Unrelated: * app/widgets/widgets-types.h: removed GimpDockedInterface typedef... * app/widgets/gimpdocked.h: ...and added it here. We don't have class struct typedefs in the types header either. * app/actions/edit-actions.c: added <Ctrl>+semicolon as shortcut for "edit-fill-pattern". * app/actions/gradient-editor-actions.c: added some stock IDs. Please comment.
This commit is contained in:
parent
eff2a3d7a8
commit
2849cf23e5
36
ChangeLog
36
ChangeLog
|
@ -1,3 +1,39 @@
|
|||
2004-05-19 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/widgets-types.h
|
||||
* app/widgets/gimpaction.[ch]: new GtkAction subclass which can
|
||||
show either a color or viewable preview in GtkImageMenuItem
|
||||
proxies.
|
||||
|
||||
* app/widgets/gimpenumaction.[ch]
|
||||
* app/widgets/gimppluginaction.[ch]
|
||||
* app/widgets/gimpstringaction.[ch]: derive them from GimpAction.
|
||||
|
||||
* app/widgets/gimpactiongroup.c (gimp_action_group_add_actions):
|
||||
add GimpActions, not GtkActions.
|
||||
|
||||
(gimp_action_group_set_action_color)
|
||||
(gimp_action_group_set_action_viewable): removed all hacks and
|
||||
simply set the "color" or "viewable" properties of the GimpAction
|
||||
to change. Fixes color/viewable previews in menus.
|
||||
|
||||
* app/actions/file-actions.c: show previews in the "Open Recent"
|
||||
menu items.
|
||||
|
||||
Unrelated:
|
||||
|
||||
* app/widgets/widgets-types.h: removed GimpDockedInterface typedef...
|
||||
|
||||
* app/widgets/gimpdocked.h: ...and added it here. We don't have
|
||||
class struct typedefs in the types header either.
|
||||
|
||||
* app/actions/edit-actions.c: added <Ctrl>+semicolon as shortcut
|
||||
for "edit-fill-pattern".
|
||||
|
||||
* app/actions/gradient-editor-actions.c: added some stock IDs.
|
||||
Please comment.
|
||||
|
||||
2004-05-19 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/papertile.c
|
||||
|
|
|
@ -140,7 +140,7 @@ static GimpEnumActionEntry edit_fill_actions[] =
|
|||
GIMP_HELP_EDIT_FILL_BG },
|
||||
|
||||
{ "edit-fill-pattern", GIMP_STOCK_TOOL_BUCKET_FILL,
|
||||
N_("Fill with P_attern"), NULL, NULL,
|
||||
N_("Fill with P_attern"), "<control>semicolon", NULL,
|
||||
GIMP_PATTERN_FILL,
|
||||
GIMP_HELP_EDIT_FILL_PATTERN }
|
||||
};
|
||||
|
|
|
@ -30,9 +30,11 @@
|
|||
#include "core/gimp.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpviewable.h"
|
||||
|
||||
#include "file/file-utils.h"
|
||||
|
||||
#include "widgets/gimpaction.h"
|
||||
#include "widgets/gimpactiongroup.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
||||
|
@ -216,8 +218,7 @@ file_actions_last_opened_update (GimpContainer *container,
|
|||
GimpImagefile *imagefile = (GimpImagefile *)
|
||||
gimp_container_get_child_by_index (container, i);
|
||||
|
||||
if (g_object_get_data (G_OBJECT (action), "gimp-imagefile") !=
|
||||
(gpointer) imagefile)
|
||||
if (GIMP_ACTION (action)->viewable != (GimpViewable *) imagefile)
|
||||
{
|
||||
const gchar *uri;
|
||||
gchar *filename;
|
||||
|
@ -234,22 +235,22 @@ file_actions_last_opened_update (GimpContainer *container,
|
|||
g_free (basename);
|
||||
|
||||
g_object_set (G_OBJECT (action),
|
||||
"label", escaped,
|
||||
"tooltip", filename,
|
||||
"visible", TRUE,
|
||||
"label", escaped,
|
||||
"tooltip", filename,
|
||||
"visible", TRUE,
|
||||
"viewable", imagefile,
|
||||
NULL);
|
||||
|
||||
g_free (filename);
|
||||
g_free (escaped);
|
||||
|
||||
g_object_set_data (G_OBJECT (action),
|
||||
"gimp-imagefile", imagefile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_set_data (G_OBJECT (action), "gimp-imagefile", NULL);
|
||||
g_object_set (G_OBJECT (action), "visible", FALSE, NULL);
|
||||
g_object_set (G_OBJECT (action),
|
||||
"visible", FALSE,
|
||||
"viewable", NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
g_free (name);
|
||||
|
|
|
@ -46,12 +46,18 @@ static GimpActionEntry gradient_editor_actions[] =
|
|||
NULL, NULL, NULL,
|
||||
GIMP_HELP_GRADIENT_EDITOR_DIALOG },
|
||||
|
||||
{ "gradient-editor-load-left-color", NULL, N_("_Load Left Color From") },
|
||||
{ "gradient-editor-save-left-color", NULL, N_("_Save Left Color To") },
|
||||
{ "gradient-editor-load-right-color", NULL, N_("Load Right Color Fr_om") },
|
||||
{ "gradient-editor-save-right-color", NULL, N_("Sa_ve Right Color To") },
|
||||
{ "gradient-editor-blending-func", NULL, "blending-function" },
|
||||
{ "gradient-editor-coloring-type", NULL, "coloring-type" },
|
||||
{ "gradient-editor-load-left-color", GTK_STOCK_REVERT_TO_SAVED,
|
||||
N_("_Load Left Color From") },
|
||||
{ "gradient-editor-save-left-color", GTK_STOCK_SAVE,
|
||||
N_("_Save Left Color To") },
|
||||
|
||||
{ "gradient-editor-load-right-color", GTK_STOCK_REVERT_TO_SAVED,
|
||||
N_("Load Right Color Fr_om") },
|
||||
{ "gradient-editor-save-right-color", GTK_STOCK_SAVE,
|
||||
N_("Sa_ve Right Color To") },
|
||||
|
||||
{ "gradient-editor-blending-func", NULL, "blending-function" },
|
||||
{ "gradient-editor-coloring-type", NULL, "coloring-type" },
|
||||
|
||||
{ "gradient-editor-left-color", NULL,
|
||||
N_("L_eft Endpoint's Color..."), NULL, NULL,
|
||||
|
@ -63,48 +69,48 @@ static GimpActionEntry gradient_editor_actions[] =
|
|||
G_CALLBACK (gradient_editor_right_color_cmd_callback),
|
||||
GIMP_HELP_GRADIENT_EDITOR_RIGHT_COLOR },
|
||||
|
||||
{ "gradient-editor-flip", NULL,
|
||||
"flip", "F", NULL,
|
||||
{ "gradient-editor-flip", GIMP_STOCK_FLIP_HORIZONTAL,
|
||||
"flip", NULL, NULL,
|
||||
G_CALLBACK (gradient_editor_flip_cmd_callback),
|
||||
GIMP_HELP_GRADIENT_EDITOR_FLIP },
|
||||
|
||||
{ "gradient-editor-replicate", NULL,
|
||||
"replicate", "R", NULL,
|
||||
{ "gradient-editor-replicate", GIMP_STOCK_DUPLICATE,
|
||||
"replicate", NULL, NULL,
|
||||
G_CALLBACK (gradient_editor_replicate_cmd_callback),
|
||||
GIMP_HELP_GRADIENT_EDITOR_FLIP },
|
||||
|
||||
{ "gradient-editor-split-midpoint", NULL,
|
||||
"splitmidpoint", "S", NULL,
|
||||
"splitmidpoint", NULL, NULL,
|
||||
G_CALLBACK (gradient_editor_split_midpoint_cmd_callback),
|
||||
GIMP_HELP_GRADIENT_EDITOR_SPLIT_MIDPOINT },
|
||||
|
||||
{ "gradient-editor-split-uniform", NULL,
|
||||
"splituniform", "U", NULL,
|
||||
"splituniform", NULL, NULL,
|
||||
G_CALLBACK (gradient_editor_split_uniformly_cmd_callback),
|
||||
GIMP_HELP_GRADIENT_EDITOR_SPLIT_UNIFORM },
|
||||
|
||||
{ "gradient-editor-delete", NULL,
|
||||
"delete", "D", NULL,
|
||||
{ "gradient-editor-delete", GTK_STOCK_DELETE,
|
||||
"delete", "", NULL,
|
||||
G_CALLBACK (gradient_editor_delete_cmd_callback),
|
||||
GIMP_HELP_GRADIENT_EDITOR_DELETE },
|
||||
|
||||
{ "gradient-editor-recenter", NULL,
|
||||
"recenter", "C", NULL,
|
||||
"recenter", NULL, NULL,
|
||||
G_CALLBACK (gradient_editor_recenter_cmd_callback),
|
||||
GIMP_HELP_GRADIENT_EDITOR_RECENTER },
|
||||
|
||||
{ "gradient-editor-redistribute", NULL,
|
||||
"redistribute", "<control>C", NULL,
|
||||
"redistribute", NULL, NULL,
|
||||
G_CALLBACK (gradient_editor_redistribute_cmd_callback),
|
||||
GIMP_HELP_GRADIENT_EDITOR_REDISTRIBUTE },
|
||||
|
||||
{ "gradient-editor-blend-color", NULL,
|
||||
N_("Ble_nd Endpoints' Colors"), "B", NULL,
|
||||
N_("Ble_nd Endpoints' Colors"), NULL, NULL,
|
||||
G_CALLBACK (gradient_editor_blend_color_cmd_callback),
|
||||
GIMP_HELP_GRADIENT_EDITOR_BLEND_COLOR },
|
||||
|
||||
{ "gradient-editor-blend-opacity", NULL,
|
||||
N_("Blend Endpoints' Opacit_y"), "<control>B", NULL,
|
||||
N_("Blend Endpoints' Opacit_y"), NULL, NULL,
|
||||
G_CALLBACK (gradient_editor_blend_opacity_cmd_callback),
|
||||
GIMP_HELP_GRADIENT_EDITOR_BLEND_OPACITY }
|
||||
};
|
||||
|
|
|
@ -19,6 +19,8 @@ noinst_LIBRARIES = libappwidgets.a
|
|||
libappwidgets_a_sources = \
|
||||
widgets-enums.h \
|
||||
widgets-types.h \
|
||||
gimpaction.c \
|
||||
gimpaction.h \
|
||||
gimpactionfactory.c \
|
||||
gimpactionfactory.h \
|
||||
gimpactiongroup.c \
|
||||
|
|
|
@ -0,0 +1,335 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpaction.c
|
||||
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "config/gimpconfig-params.h"
|
||||
#include "config/gimpconfig-types.h"
|
||||
|
||||
#include "core/gimpmarshal.h"
|
||||
#include "core/gimpviewable.h"
|
||||
|
||||
#include "gimpaction.h"
|
||||
#include "gimppreview.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_COLOR,
|
||||
PROP_VIEWABLE
|
||||
};
|
||||
|
||||
|
||||
static void gimp_action_init (GimpAction *action);
|
||||
static void gimp_action_class_init (GimpActionClass *klass);
|
||||
|
||||
static void gimp_action_finalize (GObject *object);
|
||||
static void gimp_action_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_action_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_action_connect_proxy (GtkAction *action,
|
||||
GtkWidget *proxy);
|
||||
static void gimp_action_set_proxy (GimpAction *action,
|
||||
GtkWidget *proxy);
|
||||
|
||||
|
||||
static GtkActionClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_action_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (!type)
|
||||
{
|
||||
static const GTypeInfo type_info =
|
||||
{
|
||||
sizeof (GimpActionClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_action_class_init,
|
||||
(GClassFinalizeFunc) NULL,
|
||||
NULL,
|
||||
sizeof (GimpAction),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_action_init,
|
||||
};
|
||||
|
||||
type = g_type_register_static (GTK_TYPE_ACTION,
|
||||
"GimpAction",
|
||||
&type_info, 0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_class_init (GimpActionClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
|
||||
GimpRGB black;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gimp_action_finalize;
|
||||
object_class->set_property = gimp_action_set_property;
|
||||
object_class->get_property = gimp_action_get_property;
|
||||
|
||||
action_class->connect_proxy = gimp_action_connect_proxy;
|
||||
|
||||
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
||||
|
||||
g_object_class_install_property (object_class, PROP_COLOR,
|
||||
gimp_param_spec_color ("color",
|
||||
NULL, NULL,
|
||||
&black,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_VIEWABLE,
|
||||
g_param_spec_object ("viewable",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_VIEWABLE,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_init (GimpAction *action)
|
||||
{
|
||||
action->color = NULL;
|
||||
action->viewable = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_finalize (GObject *object)
|
||||
{
|
||||
GimpAction *action = GIMP_ACTION (object);
|
||||
|
||||
if (action->color)
|
||||
{
|
||||
g_free (action->color);
|
||||
action->color = NULL;
|
||||
}
|
||||
|
||||
if (action->viewable)
|
||||
{
|
||||
g_object_unref (action->viewable);
|
||||
action->viewable = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpAction *action = GIMP_ACTION (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_COLOR:
|
||||
g_value_set_boxed (value, action->color);
|
||||
break;
|
||||
case PROP_VIEWABLE:
|
||||
g_value_set_object (value, action->viewable);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpAction *action = GIMP_ACTION (object);
|
||||
gboolean set_proxy = FALSE;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_COLOR:
|
||||
if (action->color)
|
||||
g_free (action->color);
|
||||
action->color = g_value_dup_boxed (value);
|
||||
set_proxy = TRUE;
|
||||
break;
|
||||
case PROP_VIEWABLE:
|
||||
if (action->viewable)
|
||||
g_object_unref (action->viewable);
|
||||
action->viewable = (GimpViewable *) g_value_dup_object (value);
|
||||
set_proxy = TRUE;
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
|
||||
if (set_proxy)
|
||||
{
|
||||
GSList *list;
|
||||
|
||||
for (list = gtk_action_get_proxies (GTK_ACTION (action));
|
||||
list;
|
||||
list = g_slist_next (list))
|
||||
{
|
||||
gimp_action_set_proxy (action, list->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_action_connect_proxy (GtkAction *action,
|
||||
GtkWidget *proxy)
|
||||
{
|
||||
GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
|
||||
|
||||
gimp_action_set_proxy (GIMP_ACTION (action), proxy);
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GimpAction *
|
||||
gimp_action_new (const gchar *name,
|
||||
const gchar *label,
|
||||
const gchar *tooltip,
|
||||
const gchar *stock_id)
|
||||
{
|
||||
return g_object_new (GIMP_TYPE_ACTION,
|
||||
"name", name,
|
||||
"label", label,
|
||||
"tooltip", tooltip,
|
||||
"stock_id", stock_id,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_action_set_proxy (GimpAction *action,
|
||||
GtkWidget *proxy)
|
||||
{
|
||||
if (! GTK_IS_IMAGE_MENU_ITEM (proxy))
|
||||
return;
|
||||
|
||||
if (action->color)
|
||||
{
|
||||
GtkWidget *area;
|
||||
|
||||
area = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));
|
||||
|
||||
if (area && ! GIMP_IS_COLOR_AREA (area))
|
||||
{
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), NULL);
|
||||
area = NULL;
|
||||
}
|
||||
|
||||
if (! area)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GtkSettings *settings;
|
||||
gint width, height;
|
||||
|
||||
area = gimp_color_area_new (action->color,
|
||||
GIMP_COLOR_AREA_SMALL_CHECKS, 0);
|
||||
gimp_color_area_set_draw_border (GIMP_COLOR_AREA (area), TRUE);
|
||||
|
||||
screen = gtk_widget_get_screen (area);
|
||||
settings = gtk_settings_get_for_screen (screen);
|
||||
gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
|
||||
&width, &height);
|
||||
|
||||
gtk_widget_set_size_request (area, width, height);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), area);
|
||||
gtk_widget_show (area);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (area), action->color);
|
||||
}
|
||||
}
|
||||
else if (action->viewable)
|
||||
{
|
||||
GtkWidget *preview;
|
||||
|
||||
preview = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));
|
||||
|
||||
if (preview && ! GIMP_IS_PREVIEW (preview))
|
||||
{
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), NULL);
|
||||
preview = NULL;
|
||||
}
|
||||
|
||||
if (! preview)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
gint width, height;
|
||||
|
||||
screen = gtk_widget_get_screen (proxy);
|
||||
gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen),
|
||||
GTK_ICON_SIZE_MENU,
|
||||
&width, &height);
|
||||
|
||||
preview = gimp_preview_new_full (action->viewable,
|
||||
width - 2, height - 2, 1,
|
||||
FALSE, FALSE, FALSE);
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), preview);
|
||||
gtk_widget_show (preview);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_preview_set_viewable (GIMP_PREVIEW (preview), action->viewable);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *image;
|
||||
|
||||
image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (proxy));
|
||||
|
||||
if (image && (GIMP_IS_PREVIEW (image) || GIMP_IS_COLOR_AREA (image)))
|
||||
{
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), NULL);
|
||||
g_object_notify (G_OBJECT (action), "stock-id");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpaction.h
|
||||
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_ACTION_H__
|
||||
#define __GIMP_ACTION_H__
|
||||
|
||||
|
||||
#include <gtk/gtkaction.h>
|
||||
|
||||
|
||||
#define GIMP_TYPE_ACTION (gimp_action_get_type ())
|
||||
#define GIMP_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ACTION, GimpAction))
|
||||
#define GIMP_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ACTION, GimpActionClass))
|
||||
#define GIMP_IS_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ACTION))
|
||||
#define GIMP_IS_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GIMP_TYPE_ACTION))
|
||||
#define GIMP_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GIMP_TYPE_ACTION, GimpActionClass))
|
||||
|
||||
|
||||
typedef struct _GimpActionClass GimpActionClass;
|
||||
|
||||
struct _GimpAction
|
||||
{
|
||||
GtkAction parent_instance;
|
||||
|
||||
GimpRGB *color;
|
||||
GimpViewable *viewable;
|
||||
};
|
||||
|
||||
struct _GimpActionClass
|
||||
{
|
||||
GtkActionClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_action_get_type (void);
|
||||
GimpAction * gimp_action_new (const gchar *name,
|
||||
const gchar *label,
|
||||
const gchar *tooltip,
|
||||
const gchar *stock_id);
|
||||
|
||||
|
||||
#endif /* __GIMP_ACTION_H__ */
|
|
@ -31,6 +31,7 @@
|
|||
#include "core/gimpviewable.h"
|
||||
|
||||
#include "gimpactiongroup.h"
|
||||
#include "gimpaction.h"
|
||||
#include "gimpenumaction.h"
|
||||
#include "gimppluginaction.h"
|
||||
#include "gimppreview.h"
|
||||
|
@ -293,15 +294,15 @@ gimp_action_group_add_actions (GimpActionGroup *group,
|
|||
|
||||
for (i = 0; i < n_entries; i++)
|
||||
{
|
||||
GtkAction *action;
|
||||
GimpAction *action;
|
||||
const gchar *label;
|
||||
const gchar *tooltip;
|
||||
|
||||
label = gettext (entries[i].label);
|
||||
tooltip = gettext (entries[i].tooltip);
|
||||
|
||||
action = gtk_action_new (entries[i].name, label, tooltip,
|
||||
entries[i].stock_id);
|
||||
action = gimp_action_new (entries[i].name, label, tooltip,
|
||||
entries[i].stock_id);
|
||||
|
||||
if (entries[i].callback)
|
||||
g_signal_connect (action, "activate",
|
||||
|
@ -309,10 +310,11 @@ gimp_action_group_add_actions (GimpActionGroup *group,
|
|||
group->user_data);
|
||||
|
||||
if (entries[i].accelerator && ! entries[i].accelerator[0])
|
||||
gtk_action_group_add_action (GTK_ACTION_GROUP (group), action);
|
||||
gtk_action_group_add_action (GTK_ACTION_GROUP (group),
|
||||
GTK_ACTION (action));
|
||||
else
|
||||
gtk_action_group_add_action_with_accel (GTK_ACTION_GROUP (group),
|
||||
action,
|
||||
GTK_ACTION (action),
|
||||
entries[i].accelerator);
|
||||
|
||||
if (entries[i].help_id)
|
||||
|
@ -666,7 +668,6 @@ gimp_action_group_set_action_color (GimpActionGroup *group,
|
|||
gboolean set_label)
|
||||
{
|
||||
GtkAction *action;
|
||||
GSList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
||||
g_return_if_fail (action_name != NULL);
|
||||
|
@ -682,66 +683,28 @@ gimp_action_group_set_action_color (GimpActionGroup *group,
|
|||
return;
|
||||
}
|
||||
|
||||
if (! GIMP_IS_ACTION (action))
|
||||
{
|
||||
g_warning ("%s: Unable to set \"color\" of action "
|
||||
"which is not a GimpAction: %s",
|
||||
G_STRFUNC, action_name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (set_label)
|
||||
{
|
||||
gchar *label = g_strdup_printf (_("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"),
|
||||
color->r, color->g, color->b, color->a);
|
||||
|
||||
g_object_set (action, "label", label, NULL);
|
||||
g_object_set (action,
|
||||
"color", color,
|
||||
"label", label,
|
||||
NULL);
|
||||
g_free (label);
|
||||
}
|
||||
|
||||
for (list = gtk_action_get_proxies (action); list; list = g_slist_next (list))
|
||||
else
|
||||
{
|
||||
GtkWidget *widget = list->data;
|
||||
GtkWidget *area = NULL;
|
||||
|
||||
if (! GTK_IS_MENU_ITEM (widget))
|
||||
continue;
|
||||
|
||||
if (GTK_IS_HBOX (GTK_BIN (widget)->child))
|
||||
{
|
||||
area = g_object_get_data (G_OBJECT (GTK_BIN (widget)->child),
|
||||
"gimp-color-area");
|
||||
}
|
||||
else if (GTK_IS_LABEL (GTK_BIN (widget)->child))
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GtkWidget *label;
|
||||
GtkWidget *hbox;
|
||||
gint width, height;
|
||||
|
||||
label = GTK_BIN (widget)->child;
|
||||
|
||||
g_object_ref (label);
|
||||
|
||||
gtk_container_remove (GTK_CONTAINER (widget), label);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_container_add (GTK_CONTAINER (widget), hbox);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
screen = gtk_widget_get_screen (widget);
|
||||
gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen),
|
||||
GTK_ICON_SIZE_MENU,
|
||||
&width, &height);
|
||||
|
||||
area = gimp_color_area_new (color, GIMP_COLOR_AREA_SMALL_CHECKS, 0);
|
||||
gimp_color_area_set_draw_border (GIMP_COLOR_AREA (area), TRUE);
|
||||
gtk_widget_set_size_request (area, width, height);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), area, FALSE, FALSE, 0);
|
||||
gtk_widget_show (area);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
g_object_unref (label);
|
||||
|
||||
g_object_set_data (G_OBJECT (hbox), "gimp-color-area", area);
|
||||
}
|
||||
|
||||
if (area)
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (area), color);
|
||||
g_object_set (action, "color", color, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -751,7 +714,6 @@ gimp_action_group_set_action_viewable (GimpActionGroup *group,
|
|||
GimpViewable *viewable)
|
||||
{
|
||||
GtkAction *action;
|
||||
GSList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
|
||||
g_return_if_fail (action_name != NULL);
|
||||
|
@ -767,57 +729,15 @@ gimp_action_group_set_action_viewable (GimpActionGroup *group,
|
|||
return;
|
||||
}
|
||||
|
||||
for (list = gtk_action_get_proxies (action); list; list = g_slist_next (list))
|
||||
if (! GIMP_IS_ACTION (action))
|
||||
{
|
||||
GtkWidget *widget = list->data;
|
||||
GtkWidget *preview = NULL;
|
||||
|
||||
if (! GTK_IS_MENU_ITEM (widget))
|
||||
continue;
|
||||
|
||||
if (GTK_IS_HBOX (GTK_BIN (widget)->child))
|
||||
{
|
||||
preview = g_object_get_data (G_OBJECT (GTK_BIN (widget)->child),
|
||||
"gimp-preview");
|
||||
}
|
||||
else if (GTK_IS_LABEL (GTK_BIN (widget)->child))
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GtkWidget *label;
|
||||
GtkWidget *hbox;
|
||||
gint width, height;
|
||||
|
||||
label = GTK_BIN (widget)->child;
|
||||
|
||||
g_object_ref (label);
|
||||
|
||||
gtk_container_remove (GTK_CONTAINER (widget), label);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_container_add (GTK_CONTAINER (widget), hbox);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
screen = gtk_widget_get_screen (widget);
|
||||
gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen),
|
||||
GTK_ICON_SIZE_MENU,
|
||||
&width, &height);
|
||||
|
||||
preview = gimp_preview_new_full (viewable, width - 2, height - 2, 1,
|
||||
FALSE, FALSE, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
|
||||
gtk_widget_show (preview);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
g_object_unref (label);
|
||||
|
||||
g_object_set_data (G_OBJECT (hbox), "gimp-preview", preview);
|
||||
}
|
||||
|
||||
if (preview)
|
||||
gimp_preview_set_viewable (GIMP_PREVIEW (preview), viewable);
|
||||
g_warning ("%s: Unable to set \"viewable\" of action "
|
||||
"which is not a GimpAction: %s",
|
||||
G_STRFUNC, action_name);
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_set (action, "viewable", viewable, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#define GIMP_DOCKED_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_DOCKED, GimpDockedInterface))
|
||||
|
||||
|
||||
typedef struct _GimpDockedInterface GimpDockedInterface;
|
||||
|
||||
struct _GimpDockedInterface
|
||||
{
|
||||
GTypeInterface base_iface;
|
||||
|
@ -50,8 +52,8 @@ struct _GimpDockedInterface
|
|||
gchar * (* get_title) (GimpDocked *docked);
|
||||
|
||||
void (* set_context) (GimpDocked *docked,
|
||||
GimpContext *context,
|
||||
GimpContext *prev_context);
|
||||
GimpContext *context,
|
||||
GimpContext *prev_context);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ static void gimp_enum_action_get_property (GObject *object,
|
|||
static void gimp_enum_action_activate (GtkAction *action);
|
||||
|
||||
|
||||
static GtkActionClass *parent_class = NULL;
|
||||
static guint action_signals[LAST_SIGNAL] = { 0 };
|
||||
static GimpActionClass *parent_class = NULL;
|
||||
static guint action_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
|
||||
GType
|
||||
|
@ -82,7 +82,7 @@ gimp_enum_action_get_type (void)
|
|||
(GInstanceInitFunc) gimp_enum_action_init,
|
||||
};
|
||||
|
||||
type = g_type_register_static (GTK_TYPE_ACTION,
|
||||
type = g_type_register_static (GIMP_TYPE_ACTION,
|
||||
"GimpEnumAction",
|
||||
&type_info, 0);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define __GIMP_ENUM_ACTION_H__
|
||||
|
||||
|
||||
#include <gtk/gtkaction.h>
|
||||
#include "gimpaction.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_ENUM_ACTION (gimp_enum_action_get_type ())
|
||||
|
@ -38,14 +38,14 @@ typedef struct _GimpEnumActionClass GimpEnumActionClass;
|
|||
|
||||
struct _GimpEnumAction
|
||||
{
|
||||
GtkAction parent_instance;
|
||||
GimpAction parent_instance;
|
||||
|
||||
gint value;
|
||||
gint value;
|
||||
};
|
||||
|
||||
struct _GimpEnumActionClass
|
||||
{
|
||||
GtkActionClass parent_class;
|
||||
GimpActionClass parent_class;
|
||||
|
||||
void (* selected) (GimpEnumAction *action,
|
||||
gint value);
|
||||
|
|
|
@ -86,7 +86,7 @@ gimp_plug_in_action_get_type (void)
|
|||
(GInstanceInitFunc) gimp_plug_in_action_init,
|
||||
};
|
||||
|
||||
type = g_type_register_static (GTK_TYPE_ACTION,
|
||||
type = g_type_register_static (GIMP_TYPE_ACTION,
|
||||
"GimpPlugInAction",
|
||||
&type_info, 0);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define __GIMP_PLUG_IN_ACTION_H__
|
||||
|
||||
|
||||
#include <gtk/gtkaction.h>
|
||||
#include "gimpaction.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_PLUG_IN_ACTION (gimp_plug_in_action_get_type ())
|
||||
|
@ -38,14 +38,14 @@ typedef struct _GimpPlugInActionClass GimpPlugInActionClass;
|
|||
|
||||
struct _GimpPlugInAction
|
||||
{
|
||||
GtkAction parent_instance;
|
||||
GimpAction parent_instance;
|
||||
|
||||
PlugInProcDef *proc_def;
|
||||
};
|
||||
|
||||
struct _GimpPlugInActionClass
|
||||
{
|
||||
GtkActionClass parent_class;
|
||||
GimpActionClass parent_class;
|
||||
|
||||
void (* selected) (GimpPlugInAction *action,
|
||||
PlugInProcDef *proc_def);
|
||||
|
|
|
@ -83,7 +83,7 @@ gimp_string_action_get_type (void)
|
|||
(GInstanceInitFunc) gimp_string_action_init,
|
||||
};
|
||||
|
||||
type = g_type_register_static (GTK_TYPE_ACTION,
|
||||
type = g_type_register_static (GIMP_TYPE_ACTION,
|
||||
"GimpStringAction",
|
||||
&type_info, 0);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define __GIMP_STRING_ACTION_H__
|
||||
|
||||
|
||||
#include <gtk/gtkaction.h>
|
||||
#include "gimpaction.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_STRING_ACTION (gimp_string_action_get_type ())
|
||||
|
@ -38,14 +38,14 @@ typedef struct _GimpStringActionClass GimpStringActionClass;
|
|||
|
||||
struct _GimpStringAction
|
||||
{
|
||||
GtkAction parent_instance;
|
||||
GimpAction parent_instance;
|
||||
|
||||
gchar *value;
|
||||
gchar *value;
|
||||
};
|
||||
|
||||
struct _GimpStringActionClass
|
||||
{
|
||||
GtkActionClass parent_class;
|
||||
GimpActionClass parent_class;
|
||||
|
||||
void (* selected) (GimpStringAction *action,
|
||||
const gchar *value);
|
||||
|
|
|
@ -35,6 +35,7 @@ typedef struct _GimpMenuFactory GimpMenuFactory;
|
|||
|
||||
typedef struct _GimpActionFactory GimpActionFactory;
|
||||
typedef struct _GimpActionGroup GimpActionGroup;
|
||||
typedef struct _GimpAction GimpAction;
|
||||
typedef struct _GimpEnumAction GimpEnumAction;
|
||||
typedef struct _GimpPlugInAction GimpPlugInAction;
|
||||
typedef struct _GimpStringAction GimpStringAction;
|
||||
|
@ -112,7 +113,6 @@ typedef struct _GimpImageDock GimpImageDock;
|
|||
typedef struct _GimpDockable GimpDockable;
|
||||
typedef struct _GimpDockbook GimpDockbook;
|
||||
typedef struct _GimpDocked GimpDocked; /* dummy typedef */
|
||||
typedef struct _GimpDockedInterface GimpDockedInterface;
|
||||
|
||||
typedef struct _GimpContainerPopup GimpContainerPopup;
|
||||
typedef struct _GimpViewableButton GimpViewableButton;
|
||||
|
|
Loading…
Reference in New Issue