added "sample-merged" property and API. Pass it to

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

	* app/widgets/gimpsamplepointeditor.[ch]: added "sample-merged"
	property and API. Pass it to gimp_image_pick_color().

	* app/actions/Makefile.am
	* app/actions/actions.c
	* app/actions/sample-point-editor-actions.[ch]
	* app/actions/sample-point-editor-commands.[ch]: actions and
	callbacks for the sample point editor's menu.

	* app/widgets/gimphelp-ids.h: its help IDs.

	* app/menus/menus.c
	* menus/Makefile.am
	* menus/sample-point-editor-menu.xml: the sample point editor menu.
This commit is contained in:
Michael Natterer 2005-07-09 11:23:15 +00:00 committed by Michael Natterer
parent 2a71ce5e59
commit df4aa0715a
18 changed files with 525 additions and 7 deletions

View File

@ -1,3 +1,20 @@
2005-07-09 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpsamplepointeditor.[ch]: added "sample-merged"
property and API. Pass it to gimp_image_pick_color().
* app/actions/Makefile.am
* app/actions/actions.c
* app/actions/sample-point-editor-actions.[ch]
* app/actions/sample-point-editor-commands.[ch]: actions and
callbacks for the sample point editor's menu.
* app/widgets/gimphelp-ids.h: its help IDs.
* app/menus/menus.c
* menus/Makefile.am
* menus/sample-point-editor-menu.xml: the sample point editor menu.
2005-07-09 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-pick-color.c (gimp_image_pick_color): if

View File

@ -113,6 +113,10 @@ libappactions_a_SOURCES = \
qmask-actions.h \
qmask-commands.c \
qmask-commands.h \
sample-point-editor-actions.c \
sample-point-editor-actions.h \
sample-point-editor-commands.c \
sample-point-editor-commands.h \
select-actions.c \
select-actions.h \
select-commands.c \

View File

@ -73,6 +73,7 @@
#include "patterns-actions.h"
#include "plug-in-actions.h"
#include "qmask-actions.h"
#include "sample-point-editor-actions.h"
#include "select-actions.h"
#include "templates-actions.h"
#include "text-editor-actions.h"
@ -174,6 +175,9 @@ static GimpActionFactoryEntry action_groups[] =
{ "qmask", N_("QuickMask"), GIMP_STOCK_QMASK_ON,
qmask_actions_setup,
qmask_actions_update },
{ "sample-point-editor", N_("Sample Points"), GIMP_STOCK_SAMPLE_POINT,
sample_point_editor_actions_setup,
sample_point_editor_actions_update },
{ "select", N_("Select"), GIMP_STOCK_SELECTION,
select_actions_setup,
select_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/gimphelp-ids.h"
#include "widgets/gimpsamplepointeditor.h"
#include "sample-point-editor-actions.h"
#include "sample-point-editor-commands.h"
#include "gimp-intl.h"
static GimpActionEntry sample_point_editor_actions[] =
{
{ "sample-point-editor-popup", GIMP_STOCK_SAMPLE_POINT,
N_("Sample Point Menu"), NULL, NULL, NULL,
GIMP_HELP_SAMPLE_POINT_DIALOG }
};
static GimpToggleActionEntry sample_point_editor_toggle_actions[] =
{
{ "sample-point-editor-sample-merged", NULL,
N_("_Sample Merged"), "",
N_("Sample Merged"),
G_CALLBACK (sample_point_editor_sample_merged_cmd_callback),
TRUE,
GIMP_HELP_SAMPLE_POINT_SAMPLE_MERGED }
};
void
sample_point_editor_actions_setup (GimpActionGroup *group)
{
gimp_action_group_add_actions (group,
sample_point_editor_actions,
G_N_ELEMENTS (sample_point_editor_actions));
gimp_action_group_add_toggle_actions (group,
sample_point_editor_toggle_actions,
G_N_ELEMENTS (sample_point_editor_toggle_actions));
}
void
sample_point_editor_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpSamplePointEditor *editor = GIMP_SAMPLE_POINT_EDITOR (data);
#define SET_ACTIVE(action,condition) \
gimp_action_group_set_action_active (group, action, (condition) != 0)
SET_ACTIVE ("sample-point-editor-sample-merged",
gimp_sample_point_editor_get_sample_merged (editor));
#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 __SAMPLE_POINT_EDITOR_ACIONS_H__
#define __SAMPLE_POINT_EDITOR_ACIONS_H__
void sample_point_editor_actions_setup (GimpActionGroup *group);
void sample_point_editor_actions_update (GimpActionGroup *group,
gpointer data);
#endif /* __SAMPLE_POINT_EDITOR_ACTIONS_H__ */

View File

@ -0,0 +1,48 @@
/* 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/gimphelp-ids.h"
#include "widgets/gimpsamplepointeditor.h"
#include "sample-point-editor-commands.h"
#include "gimp-intl.h"
/* public functions */
void
sample_point_editor_sample_merged_cmd_callback (GtkAction *action,
gpointer data)
{
GimpSamplePointEditor *editor = GIMP_SAMPLE_POINT_EDITOR (data);
gboolean active;
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
gimp_sample_point_editor_set_sample_merged (editor, 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 __SAMPLE_POINT_EDITOR_COMMANDS_H__
#define __SAMPLE_POINT_EDITOR_COMMANDS_H__
void sample_point_editor_sample_merged_cmd_callback (GtkAction *action,
gpointer data);
#endif /* __SAMPLE_POINT_EDITOR_COMMANDS_H__ */

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/gimphelp-ids.h"
#include "widgets/gimpsamplepointeditor.h"
#include "sample-point-editor-actions.h"
#include "sample-point-editor-commands.h"
#include "gimp-intl.h"
static GimpActionEntry sample_point_editor_actions[] =
{
{ "sample-point-editor-popup", GIMP_STOCK_SAMPLE_POINT,
N_("Sample Point Menu"), NULL, NULL, NULL,
GIMP_HELP_SAMPLE_POINT_DIALOG }
};
static GimpToggleActionEntry sample_point_editor_toggle_actions[] =
{
{ "sample-point-editor-sample-merged", NULL,
N_("_Sample Merged"), "",
N_("Sample Merged"),
G_CALLBACK (sample_point_editor_sample_merged_cmd_callback),
TRUE,
GIMP_HELP_SAMPLE_POINT_SAMPLE_MERGED }
};
void
sample_point_editor_actions_setup (GimpActionGroup *group)
{
gimp_action_group_add_actions (group,
sample_point_editor_actions,
G_N_ELEMENTS (sample_point_editor_actions));
gimp_action_group_add_toggle_actions (group,
sample_point_editor_toggle_actions,
G_N_ELEMENTS (sample_point_editor_toggle_actions));
}
void
sample_point_editor_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpSamplePointEditor *editor = GIMP_SAMPLE_POINT_EDITOR (data);
#define SET_ACTIVE(action,condition) \
gimp_action_group_set_action_active (group, action, (condition) != 0)
SET_ACTIVE ("sample-point-editor-sample-merged",
gimp_sample_point_editor_get_sample_merged (editor));
#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 __SAMPLE_POINT_EDITOR_ACIONS_H__
#define __SAMPLE_POINT_EDITOR_ACIONS_H__
void sample_point_editor_actions_setup (GimpActionGroup *group);
void sample_point_editor_actions_update (GimpActionGroup *group,
gpointer data);
#endif /* __SAMPLE_POINT_EDITOR_ACTIONS_H__ */

View File

@ -0,0 +1,48 @@
/* 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/gimphelp-ids.h"
#include "widgets/gimpsamplepointeditor.h"
#include "sample-point-editor-commands.h"
#include "gimp-intl.h"
/* public functions */
void
sample_point_editor_sample_merged_cmd_callback (GtkAction *action,
gpointer data)
{
GimpSamplePointEditor *editor = GIMP_SAMPLE_POINT_EDITOR (data);
gboolean active;
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
gimp_sample_point_editor_set_sample_merged (editor, 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 __SAMPLE_POINT_EDITOR_COMMANDS_H__
#define __SAMPLE_POINT_EDITOR_COMMANDS_H__
void sample_point_editor_sample_merged_cmd_callback (GtkAction *action,
gpointer data);
#endif /* __SAMPLE_POINT_EDITOR_COMMANDS_H__ */

View File

@ -317,6 +317,14 @@ menus_init (Gimp *gimp,
"cursor-info-menu.xml",
NULL,
NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<SamplePointEditor>",
"sample-point-editor",
NULL,
"/sample-point-editor-popup",
"sample-point-editor-menu.xml",
NULL,
NULL);
}
void

View File

@ -414,6 +414,9 @@
#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_SAMPLE_POINT_DIALOG "gimp-sample-point-dialog"
#define GIMP_HELP_SAMPLE_POINT_SAMPLE_MERGED "gimp-sample-point-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"
@ -437,7 +440,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_SAMPLE_POINT_DIALOG "gimp-sample-point-dialog"
#define GIMP_HELP_MODULE_DIALOG "gimp-module-dialog"
#define GIMP_HELP_NAVIGATION_DIALOG "gimp-navigation-dialog"
#define GIMP_HELP_TEXT_EDITOR_DIALOG "gimp-text-editor-dialog"

View File

@ -40,12 +40,27 @@
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_SAMPLE_MERGED
};
static void gimp_sample_point_editor_class_init (GimpSamplePointEditorClass *klass);
static void gimp_sample_point_editor_init (GimpSamplePointEditor *editor);
static GObject * gimp_sample_point_editor_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_sample_point_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_sample_point_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_sample_point_editor_dispose (GObject *object);
static void gimp_sample_point_editor_style_set (GtkWidget *widget,
@ -116,11 +131,20 @@ gimp_sample_point_editor_class_init (GimpSamplePointEditorClass* klass)
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_sample_point_editor_constructor;
object_class->get_property = gimp_sample_point_editor_get_property;
object_class->set_property = gimp_sample_point_editor_set_property;
object_class->dispose = gimp_sample_point_editor_dispose;
widget_class->style_set = gimp_sample_point_editor_style_set;
image_editor_class->set_image = gimp_sample_point_editor_set_image;
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
@ -131,6 +155,8 @@ gimp_sample_point_editor_init (GimpSamplePointEditor *editor)
gint row = 0;
gint column = 0;
editor->sample_merged = TRUE;
gtk_widget_style_get (GTK_WIDGET (editor),
"content_spacing", &content_spacing,
NULL);
@ -185,6 +211,45 @@ gimp_sample_point_editor_constructor (GType type,
return object;
}
static void
gimp_sample_point_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpSamplePointEditor *editor = GIMP_SAMPLE_POINT_EDITOR (object);
switch (property_id)
{
case PROP_SAMPLE_MERGED:
gimp_sample_point_editor_set_sample_merged (editor,
g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_sample_point_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpSamplePointEditor *editor = GIMP_SAMPLE_POINT_EDITOR (object);
switch (property_id)
{
case PROP_SAMPLE_MERGED:
g_value_set_boolean (value, editor->sample_merged);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_sample_point_editor_dispose (GObject *object)
{
@ -269,14 +334,42 @@ gimp_sample_point_editor_new (GimpMenuFactory *menu_factory)
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
return g_object_new (GIMP_TYPE_SAMPLE_POINT_EDITOR,
#if 0
"menu-factory", menu_factory,
"menu-identifier", "<SamplePointEditor>",
"ui-path", "/selection-editor-popup",
#endif
"ui-path", "/sample-point-editor-popup",
NULL);
}
void
gimp_sample_point_editor_set_sample_merged (GimpSamplePointEditor *editor,
gboolean sample_merged)
{
g_return_if_fail (GIMP_IS_SAMPLE_POINT_EDITOR (editor));
sample_merged = sample_merged ? TRUE : FALSE;
if (editor->sample_merged != sample_merged)
{
gint i;
editor->sample_merged = sample_merged;
for (i = 0; i < 4; i++)
editor->dirty[i] = TRUE;
gimp_sample_point_editor_dirty (editor, -1);
g_object_notify (G_OBJECT (editor), "sample-merged");
}
}
gboolean
gimp_sample_point_editor_get_sample_merged (GimpSamplePointEditor *editor)
{
g_return_val_if_fail (GIMP_IS_SAMPLE_POINT_EDITOR (editor), FALSE);
return editor->sample_merged;
}
/* private functions */
@ -413,7 +506,8 @@ gimp_sample_point_editor_update (GimpSamplePointEditor *editor)
if (gimp_image_pick_color (image_editor->gimage, NULL,
sample_point->x,
sample_point->y,
TRUE, FALSE, 0.0,
editor->sample_merged,
FALSE, 0.0,
&image_type,
&color,
&color_index))

View File

@ -45,6 +45,8 @@ struct _GimpSamplePointEditor
gboolean dirty[4];
guint dirty_idle_id;
gboolean sample_merged;
};
struct _GimpSamplePointEditorClass
@ -53,9 +55,13 @@ struct _GimpSamplePointEditorClass
};
GType gimp_sample_point_editor_get_type (void) G_GNUC_CONST;
GType gimp_sample_point_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_sample_point_editor_new (GimpMenuFactory *menu_factory);
GtkWidget * gimp_sample_point_editor_new (GimpMenuFactory *menu_factory);
void gimp_sample_point_editor_set_sample_merged (GimpSamplePointEditor *editor,
gboolean sample_merged);
gboolean gimp_sample_point_editor_get_sample_merged (GimpSamplePointEditor *editor);
#endif /* __GIMP_SAMPLE_POINT_EDITOR_H__ */

View File

@ -27,6 +27,7 @@ menudata_DATA = \
palettes-menu.xml \
patterns-menu.xml \
qmask-menu.xml \
sample-point-editor-menu.xml \
selection-editor-menu.xml \
templates-menu.xml \
text-editor-toolbar.xml \

View File

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

View File

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