added boolean "sample-merged" property, API and GUI. Pick from the active

2005-07-09  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpcursorview.[ch]: added boolean "sample-merged"
	property, API and GUI. Pick from the active drawable if it's
	FALSE.

	* app/actions/Makefile.am
	* app/actions/actions.c
	* app/actions/cursor-info-actions.[ch]
	* app/actions/cursor-info-commands.[ch]: new files with actions
	and callbacks for the cursor info dialog's menu.

	* app/widgets/gimphelp-ids.h: help IDs for above actions.

	* app/dialogs/dialogs.c: follow help ID change.

	* app/menus/menus.c
	* menus/Makefile.am
	* menus/cursor-info-menu.xml: add the cursor-info menu.

	* app/dialogs/dialogs-constructors.c: pass the menu factory to
	gimp_cursor_view_new().
This commit is contained in:
Michael Natterer 2005-07-08 22:54:46 +00:00 committed by Michael Natterer
parent 6248b954db
commit 2f7388db6f
15 changed files with 389 additions and 19 deletions

View File

@ -1,3 +1,26 @@
2005-07-09 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcursorview.[ch]: added boolean "sample-merged"
property, API and GUI. Pick from the active drawable if it's
FALSE.
* app/actions/Makefile.am
* app/actions/actions.c
* app/actions/cursor-info-actions.[ch]
* app/actions/cursor-info-commands.[ch]: new files with actions
and callbacks for the cursor info dialog's menu.
* app/widgets/gimphelp-ids.h: help IDs for above actions.
* app/dialogs/dialogs.c: follow help ID change.
* app/menus/menus.c
* menus/Makefile.am
* menus/cursor-info-menu.xml: add the cursor-info menu.
* app/dialogs/dialogs-constructors.c: pass the menu factory to
gimp_cursor_view_new().
2005-07-09 Sven Neumann <sven@gimp.org>
* app/base/segmentator.c: plugged memory leaks.

View File

@ -25,6 +25,10 @@ libappactions_a_SOURCES = \
context-actions.h \
context-commands.c \
context-commands.h \
cursor-info-actions.c \
cursor-info-actions.h \
cursor-info-commands.c \
cursor-info-commands.h \
data-commands.c \
data-commands.h \
debug-actions.c \

View File

@ -51,6 +51,7 @@
#include "channels-actions.h"
#include "colormap-editor-actions.h"
#include "context-actions.h"
#include "cursor-info-actions.h"
#include "debug-actions.h"
#include "dialogs-actions.h"
#include "dock-actions.h"
@ -107,6 +108,9 @@ static GimpActionFactoryEntry action_groups[] =
{ "context", N_("Context"), NULL,
context_actions_setup,
context_actions_update },
{ "cursor-info", N_("Cursor Info"), NULL,
cursor_info_actions_setup,
cursor_info_actions_update },
{ "debug", N_("Debug"), NULL,
debug_actions_setup,
debug_actions_update },

View File

@ -0,0 +1,80 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimpcursorview.h"
#include "widgets/gimphelp-ids.h"
#include "cursor-info-actions.h"
#include "cursor-info-commands.h"
#include "gimp-intl.h"
static GimpActionEntry cursor_info_actions[] =
{
{ "cursor-info-popup", GIMP_STOCK_CURSOR,
N_("Cursor Info Menu"), NULL, NULL, NULL,
GIMP_HELP_CURSOR_INFO_DIALOG }
};
static GimpToggleActionEntry cursor_info_toggle_actions[] =
{
{ "cursor-info-sample-merged", NULL,
N_("_Sample Merged"), "",
N_("Sample Merged"),
G_CALLBACK (cursor_info_sample_merged_cmd_callback),
TRUE,
GIMP_HELP_CURSOR_INFO_SAMPLE_MERGED }
};
void
cursor_info_actions_setup (GimpActionGroup *group)
{
gimp_action_group_add_actions (group,
cursor_info_actions,
G_N_ELEMENTS (cursor_info_actions));
gimp_action_group_add_toggle_actions (group,
cursor_info_toggle_actions,
G_N_ELEMENTS (cursor_info_toggle_actions));
}
void
cursor_info_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpCursorView *view = GIMP_CURSOR_VIEW (data);
#define SET_ACTIVE(action,condition) \
gimp_action_group_set_action_active (group, action, (condition) != 0)
SET_ACTIVE ("cursor-info-sample-merged",
gimp_cursor_view_get_sample_merged (view));
#undef SET_ACTIVE
}

View File

@ -0,0 +1,28 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 __CURSOR_INFO_ACIONS_H__
#define __CURSOR_INFO_ACIONS_H__
void cursor_info_actions_setup (GimpActionGroup *group);
void cursor_info_actions_update (GimpActionGroup *group,
gpointer data);
#endif /* __CURSOR_INFO_ACTIONS_H__ */

View File

@ -0,0 +1,49 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "widgets/gimpcursorview.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "cursor-info-commands.h"
#include "gimp-intl.h"
/* public functions */
void
cursor_info_sample_merged_cmd_callback (GtkAction *action,
gpointer data)
{
GimpCursorView *view = GIMP_CURSOR_VIEW (data);
gboolean active;
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
gimp_cursor_view_set_sample_merged (view, active);
}

View File

@ -0,0 +1,27 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* 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 __CURSOR_INFO_COMMANDS_H__
#define __CURSOR_INFO_COMMANDS_H__
void cursor_info_sample_merged_cmd_callback (GtkAction *action,
gpointer data);
#endif /* __CURSOR_INFO_COMMANDS_H__ */

View File

@ -264,7 +264,7 @@ dialogs_cursor_view_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
return gimp_cursor_view_new ();
return gimp_cursor_view_new (factory->menu_factory);
}

View File

@ -136,7 +136,7 @@ static const GimpDialogFactoryEntry dock_entries[] =
dialogs_error_console_new, 0, TRUE),
DOCKABLE ("gimp-cursor-view",
N_("Cursor"), N_("Cursor Info"), GIMP_STOCK_CURSOR,
GIMP_HELP_CURSOR_DIALOG,
GIMP_HELP_CURSOR_INFO_DIALOG,
dialogs_cursor_view_new, 0, TRUE),
/* list & grid views */

View File

@ -309,6 +309,14 @@ menus_init (Gimp *gimp,
"text-editor-toolbar.xml",
NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<CursorInfo>",
"cursor-info",
NULL,
"/cursor-info-popup",
"cursor-info-menu.xml",
NULL,
NULL);
}
void

View File

@ -32,21 +32,38 @@
#include "widgets-types.h"
#include "core/gimpimage.h"
#include "core/gimpitem.h"
#include "core/gimppickable.h"
#include "core/gimpunit.h"
#include "gimpcolorframe.h"
#include "gimpcursorview.h"
#include "gimpdocked.h"
#include "gimpmenufactory.h"
#include "gimpsessioninfo.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_SAMPLE_MERGED
};
static void gimp_cursor_view_class_init (GimpCursorViewClass *klass);
static void gimp_cursor_view_init (GimpCursorView *view);
static void gimp_cursor_view_docked_iface_init (GimpDockedInterface *docked_iface);
static void gimp_cursor_view_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_cursor_view_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_cursor_view_set_aux_info (GimpDocked *docked,
GList *aux_info);
static GList *gimp_cursor_view_get_aux_info (GimpDocked *docked);
@ -98,19 +115,33 @@ gimp_cursor_view_get_type (void)
static void
gimp_cursor_view_class_init (GimpCursorViewClass* klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
widget_class->style_set = gimp_cursor_view_style_set;
object_class->get_property = gimp_cursor_view_get_property;
object_class->set_property = gimp_cursor_view_set_property;
widget_class->style_set = gimp_cursor_view_style_set;
g_object_class_install_property (object_class, PROP_SAMPLE_MERGED,
g_param_spec_boolean ("sample-merged",
NULL, NULL,
TRUE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
gimp_cursor_view_init (GimpCursorView *view)
{
GtkWidget *frame;
GtkWidget *table;
gint content_spacing;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *toggle;
gint content_spacing;
view->sample_merged = TRUE;
gtk_widget_style_get (GTK_WIDGET (view),
"content_spacing", &content_spacing,
@ -187,6 +218,13 @@ gimp_cursor_view_init (GimpCursorView *view)
gtk_box_pack_start (GTK_BOX (view->color_hbox), view->color_frame_2,
TRUE, TRUE, 0);
gtk_widget_show (view->color_frame_2);
/* sample merged toggle */
toggle = gimp_prop_check_button_new (G_OBJECT (view), "sample-merged",
_("_Sample Merged"));
gtk_box_pack_start (GTK_BOX (view), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle);
}
static void
@ -201,6 +239,44 @@ gimp_cursor_view_docked_iface_init (GimpDockedInterface *docked_iface)
docked_iface->get_aux_info = gimp_cursor_view_get_aux_info;
}
static void
gimp_cursor_view_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCursorView *view = GIMP_CURSOR_VIEW (object);
switch (property_id)
{
case PROP_SAMPLE_MERGED:
view->sample_merged = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_cursor_view_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCursorView *view = GIMP_CURSOR_VIEW (object);
switch (property_id)
{
case PROP_SAMPLE_MERGED:
g_value_set_boolean (value, view->sample_merged);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
#define AUX_INFO_FRAME_1_MODE "frame-1-mode"
#define AUX_INFO_FRAME_2_MODE "frame-2-mode"
@ -289,11 +365,42 @@ gimp_cursor_view_style_set (GtkWidget *widget,
/* public functions */
GtkWidget *
gimp_cursor_view_new (void)
gimp_cursor_view_new (GimpMenuFactory *menu_factory)
{
return g_object_new (GIMP_TYPE_CURSOR_VIEW, NULL);
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
return g_object_new (GIMP_TYPE_CURSOR_VIEW,
"menu-factory", menu_factory,
"menu-identifier", "<CursorInfo>",
"ui-path", "/cursor-info-popup",
NULL);
}
void
gimp_cursor_view_set_sample_merged (GimpCursorView *view,
gboolean sample_merged)
{
g_return_if_fail (GIMP_IS_CURSOR_VIEW (view));
sample_merged = sample_merged ? TRUE : FALSE;
if (view->sample_merged != sample_merged)
{
view->sample_merged = sample_merged;
g_object_notify (G_OBJECT (view), "sample-merged");
}
}
gboolean
gimp_cursor_view_get_sample_merged (GimpCursorView *view)
{
g_return_val_if_fail (GIMP_IS_CURSOR_VIEW (view), FALSE);
return view->sample_merged;
}
void
gimp_cursor_view_update_cursor (GimpCursorView *view,
GimpImage *image,
@ -355,10 +462,33 @@ gimp_cursor_view_update_cursor (GimpCursorView *view,
if (image)
{
pickable = GIMP_PICKABLE (image->projection);
if (view->sample_merged)
{
pickable = GIMP_PICKABLE (image->projection);
color = gimp_pickable_get_color_at (pickable,
(gint) floor (x), (gint) floor (y));
color = gimp_pickable_get_color_at (pickable,
(gint) floor (x),
(gint) floor (y));
}
else
{
GimpDrawable *drawable;
drawable = gimp_image_active_drawable (image);
if (drawable)
{
gint off_x, off_y;
pickable = GIMP_PICKABLE (drawable);
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
color = gimp_pickable_get_color_at (pickable,
((gint) floor (x)) - off_x,
((gint) floor (y)) - off_y);
}
}
}
if (color)

View File

@ -49,6 +49,8 @@ struct _GimpCursorView
GtkWidget *unit_y_label;
GtkWidget *color_frame_1;
GtkWidget *color_frame_2;
gboolean sample_merged;
};
struct _GimpCursorViewClass
@ -57,14 +59,18 @@ struct _GimpCursorViewClass
};
GType gimp_cursor_view_get_type (void) G_GNUC_CONST;
GType gimp_cursor_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_cursor_view_new (void);
GtkWidget * gimp_cursor_view_new (GimpMenuFactory *menu_factory);
void gimp_cursor_view_update_cursor (GimpCursorView *view,
GimpImage *image,
GimpUnit unit,
gdouble x,
gdouble y);
void gimp_cursor_view_set_sample_merged (GimpCursorView *view,
gboolean sample_merged);
gboolean gimp_cursor_view_get_sample_merged (GimpCursorView *view);
void gimp_cursor_view_update_cursor (GimpCursorView *view,
GimpImage *image,
GimpUnit unit,
gdouble x,
gdouble y);
#endif /* __GIMP_CURSOR_VIEW_H__ */

View File

@ -411,6 +411,9 @@
#define GIMP_HELP_INDEXED_PALETTE_EDIT "gimp-indexed-palette-edit"
#define GIMP_HELP_INDEXED_PALETTE_ADD "gimp-indexed-palette-add"
#define GIMP_HELP_CURSOR_INFO_DIALOG "gimp-cursor-info-dialog"
#define GIMP_HELP_CURSOR_INFO_SAMPLE_MERGED "gimp-cursor-info-sample-merged"
#define GIMP_HELP_DOCK "gimp-dock"
#define GIMP_HELP_DOCK_CLOSE "gimp-dock-close"
#define GIMP_HELP_DOCK_IMAGE_MENU "gimp-dock-image-menu"
@ -434,7 +437,6 @@
#define GIMP_HELP_DISPLAY_FILTER_DIALOG "gimp-display-filter-dialog"
#define GIMP_HELP_HISTOGRAM_DIALOG "gimp-histogram-dialog"
#define GIMP_HELP_INFO_DIALOG "gimp-info-dialog"
#define GIMP_HELP_CURSOR_DIALOG "gimp-cursor-dialog"
#define GIMP_HELP_SAMPLE_POINT_DIALOG "gimp-sample-point-dialog"
#define GIMP_HELP_MODULE_DIALOG "gimp-module-dialog"
#define GIMP_HELP_NAVIGATION_DIALOG "gimp-navigation-dialog"

View File

@ -15,6 +15,7 @@ menudata_DATA = \
buffers-menu.xml \
channels-menu.xml \
colormap-editor-menu.xml \
cursor-info-menu.xml \
documents-menu.xml \
error-console-menu.xml \
fonts-menu.xml \

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE ui SYSTEM "gtkuimanager.dtd">
<ui>
<popup action="cursor-info-popup">
<menuitem action="cursor-info-sample-merged" />
</popup>
</ui>