Commit 42f79826 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

implemented gimp_action_group_set_action_color() and

2004-04-22  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpactiongroup.[ch]: implemented
	gimp_action_group_set_action_color() and
	gimp_action_group_set_action_viewable().

	* app/actions/*-actions.c: added stock IDs to all actions which
	represent toplevel popup menus. Fixed typos.

	* menus/brushes-menu.xml
	* menus/colormap-editor-menu.xml
	* menus/dockable-menu.xml
	* menus/gradients-menu.xml
	* menus/patterns-menu.xml
	* menus/toolbox-menu.xml: fixed typos.
parent c6c1688e
2004-04-22 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpactiongroup.[ch]: implemented
gimp_action_group_set_action_color() and
gimp_action_group_set_action_viewable().
* app/actions/*-actions.c: added stock IDs to all actions which
represent toplevel popup menus. Fixed typos.
* menus/brushes-menu.xml
* menus/colormap-editor-menu.xml
* menus/dockable-menu.xml
* menus/gradients-menu.xml
* menus/patterns-menu.xml
* menus/toolbox-menu.xml: fixed typos.
2004-04-22 Sven Neumann <sven@gimp.org>
* plug-ins/rcm/rcm_callback.[ch]
......
......@@ -41,7 +41,7 @@
static GimpActionEntry brushes_actions[] =
{
{ "brushes-popup", NULL, N_("Brushes Menu") },
{ "brushes-popup", GIMP_STOCK_BRUSH, N_("Brushes Menu") },
{ "brushes-edit", GIMP_STOCK_EDIT,
N_("_Edit Brush..."), NULL, NULL,
......
......@@ -39,7 +39,7 @@
static GimpActionEntry buffers_actions[] =
{
{ "buffers-popup", NULL, N_("Buffers Menu") },
{ "buffers-popup", GIMP_STOCK_BUFFER, N_("Buffers Menu") },
{ "buffers-paste", GTK_STOCK_PASTE,
N_("_Paste Buffer"), "", NULL,
......
......@@ -40,7 +40,7 @@
static GimpActionEntry channels_actions[] =
{
{ "channels-popup", NULL, N_("Channels Menu") },
{ "channels-popup", GIMP_STOCK_CHANNELS, N_("Channels Menu") },
{ "channels-edit-attributes", GIMP_STOCK_EDIT,
N_("_Edit Channel Attributes..."), NULL, NULL,
......@@ -48,7 +48,7 @@ static GimpActionEntry channels_actions[] =
GIMP_HELP_CHANNEL_EDIT },
{ "channels-new", GTK_STOCK_NEW,
N_("/_New Channel..."), "", NULL,
N_("_New Channel..."), "", NULL,
G_CALLBACK (channels_new_cmd_callback),
GIMP_HELP_CHANNEL_NEW },
......
......@@ -38,7 +38,8 @@
static GimpActionEntry colormap_editor_actions[] =
{
{ "colormap-editor-popup", NULL, N_("Indexed Palette Menu") },
{ "colormap-editor-popup", GIMP_STOCK_INDEXED_PALETTE,
N_("Indexed Palette Menu") },
{ "colormap-editor-edit-color", GIMP_STOCK_EDIT,
N_("_Edit Color..."), NULL, NULL,
......
......@@ -38,7 +38,8 @@
static GimpActionEntry colormap_editor_actions[] =
{
{ "colormap-editor-popup", NULL, N_("Indexed Palette Menu") },
{ "colormap-editor-popup", GIMP_STOCK_INDEXED_PALETTE,
N_("Indexed Palette Menu") },
{ "colormap-editor-edit-color", GIMP_STOCK_EDIT,
N_("_Edit Color..."), NULL, NULL,
......
......@@ -45,11 +45,11 @@
static GimpActionEntry dockable_actions[] =
{
{ "dockable-popup", NULL, N_("Dialogs Menu") },
{ "dockable-menu", GTK_STOCK_MISSING_IMAGE, NULL },
{ "dockable-add-tab-menu", NULL, N_("_Add Tab") },
{ "dockable-preview-size-menu", NULL, N_("Preview Si_ze") },
{ "dockable-tab-style-menu", NULL, N_("/_Tab Style") },
{ "dockable-popup", NULL, N_("Dialogs Menu") },
{ "dockable-menu", GTK_STOCK_MISSING_IMAGE, "" },
{ "dockable-add-tab-menu", NULL, N_("_Add Tab") },
{ "dockable-preview-size-menu", NULL, N_("Preview Si_ze") },
{ "dockable-tab-style-menu", NULL, N_("_Tab Style") },
{ "dockable-close-tab", GTK_STOCK_CLOSE,
N_("_Close Tab"), "", NULL,
......@@ -108,11 +108,11 @@ static GimpRadioActionEntry dockable_preview_size_actions[] =
static GimpRadioActionEntry dockable_tab_style_actions[] =
{
TAB_STYLE ("icon", N_("_Icon"), GIMP_TAB_STYLE_ICON),
TAB_STYLE ("status", N_("Current _Status"), GIMP_TAB_STYLE_PREVIEW),
TAB_STYLE ("text", N_("_Text"), GIMP_TAB_STYLE_NAME),
TAB_STYLE ("icon-text", N_("I_con & Text"), GIMP_TAB_STYLE_ICON_NAME),
TAB_STYLE ("status-text", N_("St_atus & Text"), GIMP_TAB_STYLE_PREVIEW_NAME)
TAB_STYLE ("icon", N_("_Icon"), GIMP_TAB_STYLE_ICON),
TAB_STYLE ("preview", N_("Current _Status"), GIMP_TAB_STYLE_PREVIEW),
TAB_STYLE ("name", N_("_Text"), GIMP_TAB_STYLE_NAME),
TAB_STYLE ("icon-name", N_("I_con & Text"), GIMP_TAB_STYLE_ICON_NAME),
TAB_STYLE ("preview-name", N_("St_atus & Text"), GIMP_TAB_STYLE_PREVIEW_NAME)
};
#undef PREVIEW_SIZE
......@@ -310,17 +310,17 @@ dockable_actions_update (GimpActionGroup *group,
if (tab_style == GIMP_TAB_STYLE_ICON)
SET_ACTIVE ("dockable-tab-style-icon", TRUE);
else if (tab_style == GIMP_TAB_STYLE_PREVIEW)
SET_ACTIVE ("dockable-tab-style-status", TRUE);
SET_ACTIVE ("dockable-tab-style-preview", TRUE);
else if (tab_style == GIMP_TAB_STYLE_NAME)
SET_ACTIVE ("dockable-tab-style-text", TRUE);
SET_ACTIVE ("dockable-tab-style-name", TRUE);
else if (tab_style == GIMP_TAB_STYLE_ICON_NAME)
SET_ACTIVE ("dockable-tab-style-icon-text", TRUE);
SET_ACTIVE ("dockable-tab-style-icon-name", TRUE);
else if (tab_style == GIMP_TAB_STYLE_PREVIEW_NAME)
SET_ACTIVE ("dockable-tab-style-status-text", TRUE);
SET_ACTIVE ("dockable-tab-style-preview-name", TRUE);
SET_SENSITIVE ("dockable-tab-style-status",
SET_SENSITIVE ("dockable-tab-style-preview",
docked_iface->get_preview);
SET_SENSITIVE ("dockable-tab-style-status-text",
SET_SENSITIVE ("dockable-tab-style-preview-name",
docked_iface->get_preview);
}
......
......@@ -39,7 +39,7 @@
static GimpActionEntry documents_actions[] =
{
{ "ducuments-popup", NULL, N_("Documents Menu") },
{ "documents-popup", GTK_STOCK_OPEN, N_("Documents Menu") },
{ "documents-open", GTK_STOCK_OPEN,
N_("_Open Image"), "", NULL,
......
......@@ -57,6 +57,9 @@ static void edit_actions_foreground_changed (GimpContext *context,
static void edit_actions_background_changed (GimpContext *context,
const GimpRGB *color,
GimpActionGroup *group);
static void edit_actions_pattern_changed (GimpContext *context,
GimpPattern *pattern,
GimpActionGroup *group);
static GimpActionEntry edit_actions[] =
......@@ -175,6 +178,9 @@ edit_actions_setup (GimpActionGroup *group,
g_signal_connect_object (user_context, "background_changed",
G_CALLBACK (edit_actions_background_changed),
group, 0);
g_signal_connect_object (user_context, "pattern_changed",
G_CALLBACK (edit_actions_pattern_changed),
group, 0);
gimp_context_get_foreground (user_context, &color);
edit_actions_foreground_changed (user_context, &color, group);
......@@ -298,3 +304,12 @@ edit_actions_background_changed (GimpContext *context,
{
gimp_action_group_set_action_color (group, "edit-fill-bg", color, FALSE);
}
static void
edit_actions_pattern_changed (GimpContext *context,
GimpPattern *pattern,
GimpActionGroup *group)
{
gimp_action_group_set_action_viewable (group, "edit-fill-pattern",
GIMP_VIEWABLE (pattern));
}
......@@ -36,6 +36,8 @@
static GimpActionEntry error_console_actions[] =
{
{ "error-console-popup", GIMP_STOCK_WARNING, N_("Error Console Menu") },
{ "error-console-clear", GTK_STOCK_CLEAR,
N_("_Clear Errors"), "", NULL,
G_CALLBACK (error_console_clear_cmd_callback),
......
......@@ -41,7 +41,7 @@
static GimpActionEntry fonts_actions[] =
{
{ "fonts-popup", NULL, N_("Fonts Menu") },
{ "fonts-popup", GIMP_STOCK_FONT, N_("Fonts Menu") },
{ "fonts-refresh", GTK_STOCK_REFRESH,
N_("_Rescan Font List"), "", NULL,
......
......@@ -42,7 +42,7 @@
static GimpActionEntry gradient_editor_actions[] =
{
{ "gradient-editor-popup", NULL, N_("Gradient Editor Menu") },
{ "gradient-editor-popup", GIMP_STOCK_GRADIENT, N_("Gradient Editor Menu") },
{ "gradient-editor-left-color", NULL,
N_("L_eft Endpoint's Color..."), NULL, NULL,
......
......@@ -46,10 +46,11 @@
static GimpActionEntry image_actions[] =
{
{ "toolbox-menubar", NULL, N_("Toolbox Menu") },
{ "image-menubar", NULL, N_("Image Menu") },
{ "image-menu", NULL, N_("_Image") },
{ "image-mode-menu", NULL, N_("_Mode") },
{ "image-transform-menu", NULL, N_("_Transform") },
{ "extensions-menu", NULL, N_("_Xtns") },
{ "image-menubar", NULL, N_("Image Menu") },
{ "image-menu", NULL, N_("_Image") },
{ "image-mode-menu", NULL, N_("_Mode") },
{ "image-transform-menu", NULL, N_("_Transform") },
{ "image-convert-rgb", GIMP_STOCK_CONVERT_RGB,
N_("_RGB"), NULL, NULL,
......
......@@ -39,7 +39,7 @@
static GimpActionEntry images_actions[] =
{
{ "images-popup", NULL, N_("Images Menu") },
{ "images-popup", GIMP_STOCK_IMAGES, N_("Images Menu") },
{ "images-raise-views", GTK_STOCK_GOTO_TOP,
N_("_Raise Views"), "", NULL,
......
......@@ -45,7 +45,8 @@
static GimpActionEntry layers_actions[] =
{
{ "layers-popup", NULL, N_("Layers Menu") },
{ "layers-popup", GIMP_STOCK_LAYERS, N_("Layers Menu") },
{ "layers-menu", NULL, N_("_Layer") },
{ "layers-stack-menu", NULL, N_("Stac_k") },
{ "layers-colors-menu", NULL, N_("_Colors") },
......
......@@ -36,7 +36,7 @@
static GimpActionEntry palette_editor_actions[] =
{
{ "palette-editor-popup", NULL, N_("Palette Editor Menu") },
{ "palette-editor-popup", GIMP_STOCK_PALETTE, N_("Palette Editor Menu") },
{ "palette-editor-edit-color", GIMP_STOCK_EDIT,
N_("_Edit Color..."), "", NULL,
......
......@@ -42,7 +42,7 @@
static GimpActionEntry palettes_actions[] =
{
{ "palettes-popup", NULL, N_("Palettes Menu") },
{ "palettes-popup", GIMP_STOCK_PALETTE, N_("Palettes Menu") },
{ "palettes-edit", GIMP_STOCK_EDIT,
N_("_Edit Palette..."), NULL, NULL,
......
......@@ -41,7 +41,7 @@
static GimpActionEntry patterns_actions[] =
{
{ "patterns-popup", NULL, N_("Patterns Menu") },
{ "patterns-popup", GIMP_STOCK_PATTERN, N_("Patterns Menu") },
{ "patterns-edit", GIMP_STOCK_EDIT,
N_("_Edit Pattern..."), NULL, NULL,
......
......@@ -39,7 +39,7 @@
static GimpActionEntry templates_actions[] =
{
{ "templates-popup", NULL, N_("Templates Menu") },
{ "templates-popup", GIMP_STOCK_TEMPLATE, N_("Templates Menu") },
{ "templates-create-image", GIMP_STOCK_IMAGE,
N_("_Create Image from Template..."), "", NULL,
......
......@@ -53,7 +53,8 @@ static void tool_options_actions_update_presets (GimpActionGroup *group,
static GimpActionEntry tool_options_actions[] =
{
{ "tool-options-popup", NULL, N_("Tool Options Menu") },
{ "tool-options-popup", GIMP_STOCK_TOOL_OPTIONS, N_("Tool Options Menu") },
{ "tool-options-save-menu", NULL, N_("_Save Options to") },
{ "tool-options-restore-menu", NULL, N_("_Restore Options from") },
{ "tool-options-rename-menu", NULL, N_("Re_name Saved Options") },
......
......@@ -40,7 +40,7 @@
static GimpActionEntry vectors_actions[] =
{
{ "vectors-popup", NULL, N_("Paths Menu") },
{ "vectors-popup", GIMP_STOCK_PATHS, N_("Paths Menu") },
{ "vectors-path-tool", GIMP_STOCK_TOOL_PATH,
N_("Path _Tool"), NULL, NULL,
......
......@@ -23,12 +23,16 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimp.h"
#include "core/gimpviewable.h"
#include "gimpactiongroup.h"
#include "gimpenumaction.h"
#include "gimppreview.h"
#include "gimpstringaction.h"
#include "gimp-intl.h"
......@@ -475,6 +479,14 @@ gimp_action_group_set_action_active (GimpActionGroup *group,
return;
}
if (! GTK_IS_TOGGLE_ACTION (action))
{
g_warning ("%s: Unable to set \"active\" of action "
"which is not a GtkToggleAction: %s",
G_STRLOC, action_name);
return;
}
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
}
......@@ -508,9 +520,11 @@ 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);
g_return_if_fail (color != NULL);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
......@@ -521,6 +535,143 @@ gimp_action_group_set_action_color (GimpActionGroup *group,
G_STRLOC, 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_free (label);
}
for (list = gtk_action_get_proxies (action); list; list = g_slist_next (list))
{
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);
}
}
void
gimp_action_group_set_action_viewable (GimpActionGroup *group,
const gchar *action_name,
GimpViewable *viewable)
{
GtkAction *action;
GSList *list;
g_return_if_fail (GIMP_IS_ACTION_GROUP (group));
g_return_if_fail (action_name != NULL);
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
if (! action)
{
g_warning ("%s: Unable to set viewable of action "
"which doesn't exist: %s",
G_STRLOC, action_name);
return;
}
for (list = gtk_action_get_proxies (action); list; list = g_slist_next (list))
{
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);
}
}
void
......
......@@ -162,6 +162,9 @@ void gimp_action_group_set_action_color (GimpActionGroup *group,
const gchar *action_name,
const GimpRGB *color,
gboolean set_label);
void gimp_action_group_set_action_viewable (GimpActionGroup *group,
const gchar *action_name,
GimpViewable *viewable);
void gimp_action_group_set_action_important (GimpActionGroup *group,
const gchar *action_name,
gboolean is_important);
......
......@@ -2,7 +2,7 @@
<!DOCTYPE ui SYSTEM "gtkuimanager.dtd">
<ui>
<popup>
<popup action="brushes-popup">
<menuitem action="brushes-edit" />
<separator />
<menuitem action="brushes-new" />
......
......@@ -2,7 +2,7 @@
<!DOCTYPE ui SYSTEM "gtkuimanager.dtd">
<ui>
<popup>
<popup action="colormap-editor-popup">
<menuitem action="colormap-editor-edit-color" />
<menuitem action="colormap-editor-add-color-from-fg" />
<menuitem action="colormap-editor-add-color-from-bg" />
......
......@@ -2,7 +2,7 @@
<!DOCTYPE ui SYSTEM "gtkuimanager.dtd">
<ui>
<popup>
<popup action="colormap-editor-popup">
<menuitem action="colormap-editor-edit-color" />
<menuitem action="colormap-editor-add-color-from-fg" />
<menuitem action="colormap-editor-add-color-from-bg" />
......
......@@ -20,7 +20,7 @@
<menuitem action="dialogs-colors" />
<menuitem action="dialogs-brushes" />
<menuitem action="dialogs-patterns" />
<menuitem action="dialogs-graidents" />
<menuitem action="dialogs-gradients" />
<menuitem action="dialogs-palettes" />
<menuitem action="dialogs-fonts" />
<menuitem action="dialogs-buffers" />
......
......@@ -2,7 +2,7 @@
<!DOCTYPE ui SYSTEM "gtkuimanager.dtd">
<ui>
<popup action="gradients-menu">
<popup action="gradients-popup">
<menuitem action="gradients-edit" />
<separator />
<menuitem action="gradients-new" />
......
......@@ -2,7 +2,7 @@
<!DOCTYPE ui SYSTEM "gtkuimanager.dtd">
<ui>
<popup action="patterns-menu">
<popup action="patterns-popup">
<!-- disabled because they are useless now
<menuitem action="patterns-edit" />
......
......@@ -37,7 +37,7 @@
<menuitem action="dialogs-colors" />
<menuitem action="dialogs-brushes" />
<menuitem action="dialogs-patterns" />
<menuitem action="dialogs-graidents" />
<menuitem action="dialogs-gradients" />
<menuitem action="dialogs-palettes" />
<menuitem action="dialogs-fonts" />
<menuitem action="dialogs-buffers" />
......@@ -57,7 +57,7 @@
</menu>
<menu action="extensions-menu">
<menuitem action="dicloag-module-manager" />
<menuitem action="dialogs-module-manager" />
<separator />
</menu>
......
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